Skip to content

Commit

Permalink
Remove the --abstract-types feature gate flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Alasdair committed Mar 7, 2025
1 parent f980914 commit c622c29
Show file tree
Hide file tree
Showing 29 changed files with 484 additions and 81 deletions.
5 changes: 1 addition & 4 deletions doc/asciidoc/language.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,6 @@ to avoid us having to think about this particular detail.
=== Abstract types
:abstract-ty: sail_doc/abstract_xlen.json

NOTE: This feature is currently experimental and is enabled with the
`--abstract-types` flag.

Consider the following problem: We want to specify an architecture
like RISC-V, which permits both 32-bit and a 64-bit implementations,
with the two implementations being mostly the same other than the base
Expand Down Expand Up @@ -642,7 +639,7 @@ generating definitions. We do this using the `--instantiate` option,
so if the above file is called `xlen.sail`, we could do:
[source,sh]
----
sail xlen.sail --lem --abstract-types --instantiate xlen=32
sail xlen.sail --lem --instantiate xlen=32
----
To create lem definitions for the `xlen = 32` case.

Expand Down
2 changes: 0 additions & 2 deletions doc/examples/abstract_xlen.sail
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
default Order dec
$include <prelude.sail>

$option --abstract-types

$span start XLEN
type xlen : Int

Expand Down
497 changes: 468 additions & 29 deletions doc/manual.html

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/bin/sail.ml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ let rec options =
Arg.String (fun file -> opt_output_schema_file := Some file),
"<file> output configuration schema"
);
("-abstract_types", Arg.Set Initial_check.opt_abstract_types, " (experimental) allow abstract types");
("-fmt", Arg.Set opt_format, " format input source code");
( "-fmt_backup",
Arg.String (fun suffix -> opt_format_backup := Some suffix),
Expand Down
5 changes: 0 additions & 5 deletions src/lib/initial_check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,8 @@ module P = Parse_ast
(* See mli file for details on what these flags do *)
let opt_fast_undefined = ref false
let opt_magic_hash = ref false
let opt_abstract_types = ref false
let opt_strict_bitvector = ref false

let abstract_type_error = "Abstract types are currently experimental, use the --abstract-types flag to enable"

module StringSet = Set.Make (String)
module StringMap = Map.Make (String)

Expand Down Expand Up @@ -1716,7 +1713,6 @@ let rec to_ast_typedef ctx def_annot (P.TD_aux (aux, l) : P.type_def) : untyped_
{ ctx with type_constructors = Bindings.add id ([], P.K_type) ctx.type_constructors }
)
| P.TD_abstract (id, kind, instantiation) -> (
if not !opt_abstract_types then raise (Reporting.err_general l abstract_type_error);
let id = to_ast_reserved_type_id ctx id in
let instantiation = match instantiation with Some key -> TDC_key key | None -> TDC_none in
match to_ast_kind kind with
Expand Down Expand Up @@ -2050,7 +2046,6 @@ let rec to_ast_def doc attrs vis ctx (P.DEF_aux (def, l)) : untyped_def list ctx
let d = to_ast_dec ctx dec in
([DEF_aux (DEF_register d, annot)], ctx)
| P.DEF_constraint nc ->
if not !opt_abstract_types then raise (Reporting.err_general l abstract_type_error);
let nc = to_ast_constraint ctx nc in
([DEF_aux (DEF_constraint nc, annot)], ctx)
| P.DEF_pragma (pragma, P.Pragma_line (arg, ltrim)) ->
Expand Down
4 changes: 0 additions & 4 deletions src/lib/initial_check.mli
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ open Ast_util

(** {2 Options} *)

(** Enable abstract types in the AST. If unset, will report an error
if they are encountered. *)
val opt_abstract_types : bool ref

(** If enabled, bitvector types are only well-formed if their
arguments are natural numbers. *)
val opt_strict_bitvector : bool ref
Expand Down
4 changes: 2 additions & 2 deletions src/sail_doc_backend/sail_plugin_doc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ let doc_target out_file { ast; _ } =
else Printf.eprintf "Unknown documentation format: %s\n" !opt_doc_format

let _ =
Target.register ~name:"doc" ~options:doc_options ~supports_abstract_types:true
Target.register ~name:"doc" ~options:doc_options ~supports_abstract_types:true ~supports_runtime_config:true
~pre_parse_hook:(fun () ->
Type_check.opt_expand_valspec := false;
Type_check.opt_no_bitfield_expansion := true
Expand Down Expand Up @@ -200,7 +200,7 @@ let html_target files out_dir_opt { ast; _ } =

let _ =
let files : Html_source.file_info list ref = ref [] in
Target.register ~name:"html" ~options:html_options ~supports_abstract_types:true
Target.register ~name:"html" ~options:html_options ~supports_abstract_types:true ~supports_runtime_config:true
~pre_initial_check_hook:(fun filenames ->
List.iter
(fun filename ->
Expand Down
2 changes: 0 additions & 2 deletions test/c/abstract_type.sail
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
default Order dec
$include <prelude.sail>

$option --abstract-types

type xlen : Int

constraint xlen in {32, 64}
Expand Down
2 changes: 0 additions & 2 deletions test/c/config_abstract_bool.sail
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ default Order dec

$include <prelude.sail>

$option --abstract-types

$iftarget c
$c_in_main sail_config_set_file("config_abstract_bool.json");
$c_in_main sail_set_abstract_have_ext();
Expand Down
2 changes: 0 additions & 2 deletions test/c/config_abstract_type.sail
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
default Order dec
$include <prelude.sail>

$option --abstract-types

type xlen : Int = config arch.xlen

constraint xlen in {32, 64}
Expand Down
2 changes: 0 additions & 2 deletions test/c/config_abstract_type2.sail
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
default Order dec
$include <prelude.sail>

$option --abstract-types

type xlen : Int = config arch.xlen

constraint xlen >= 0
Expand Down
2 changes: 0 additions & 2 deletions test/c/config_abstract_type3.sail
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
default Order dec
$include <prelude.sail>

$option --abstract-types

type other : Bool

type xlen : Int = config arch.xlen
Expand Down
2 changes: 1 addition & 1 deletion test/oneoff/instantiate_cmdline/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

set -e

sail xlen.sail --abstract-types --instantiate "xlen = 3 2" 2> xlen.result || true
sail xlen.sail --instantiate "xlen = 3 2" 2> xlen.result || true
diff xlen.result xlen.expect
4 changes: 2 additions & 2 deletions test/oneoff/instantiate_cmdline/xlen.expect
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Syntax error:
ARGV:5.9-9:
5 |xlen = 3 2
ARGV:4.9-9:
4 |xlen = 3 2
 | ^
 | Failed to parse ' 3 2' at token '2'
2 changes: 1 addition & 1 deletion test/oneoff/instantiate_directive/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

set -e

sail xlen.sail --abstract-types 2> xlen.result || true
sail xlen.sail 2> xlen.result || true
diff xlen.result xlen.expect
2 changes: 1 addition & 1 deletion test/oneoff/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test():
tests[dir] = os.fork()
if tests[dir] == 0:
os.chdir(dir)
step('./test.sh')
step('./test.sh', name=dir)
print_ok(dir)
sys.exit()
results.collect(tests)
Expand Down
8 changes: 4 additions & 4 deletions test/typecheck/fail/abstract_bool_inconsistent.expect
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Type error:
fail/abstract_bool_inconsistent.sail:10.0-17:
10 |constraint not(b)
 |^---------------^
 | Global constraint appears inconsistent with previous global constraints
fail/abstract_bool_inconsistent.sail:8.0-17:
8 |constraint not(b)
 |^---------------^
 | Global constraint appears inconsistent with previous global constraints
2 changes: 0 additions & 2 deletions test/typecheck/fail/abstract_bool_inconsistent.sail
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ default Order dec

$include <prelude.sail>

$option -abstract_types

type b : Bool

constraint b
Expand Down
4 changes: 2 additions & 2 deletions test/typecheck/fail/abstract_type_type.expect
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Error:
fail/abstract_type_type.sail:3.0-13:
3 |type a : Type
fail/abstract_type_type.sail:2.0-13:
2 |type a : Type
 |^-----------^
 | Abstract type must be either a boolean or integer type
1 change: 0 additions & 1 deletion test/typecheck/fail/abstract_type_type.sail
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
$option --abstract-types

type a : Type
4 changes: 2 additions & 2 deletions test/typecheck/fail/global_false_constraint.expect
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Type error:
fail/global_false_constraint.sail:3.0-16:
3 |constraint false
fail/global_false_constraint.sail:2.0-16:
2 |constraint false
 |^--------------^
 | Global constraint appears inconsistent with previous global constraints
1 change: 0 additions & 1 deletion test/typecheck/fail/global_false_constraint.sail
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
$option -abstract_types

constraint false
1 change: 0 additions & 1 deletion test/typecheck/pass/abstract_bitfield_width.sail
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ default Order dec

$include <prelude.sail>

$option --abstract-types
$option --instantiate w=32

type w : Int
Expand Down
1 change: 0 additions & 1 deletion test/typecheck/pass/abstract_bool.sail
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ default Order dec

$include <prelude.sail>

$option --abstract-types
$option --instantiate b=true

type b : Bool
Expand Down
1 change: 0 additions & 1 deletion test/typecheck/pass/abstract_bool2.sail
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ default Order dec

$include <prelude.sail>

$option --abstract-types
$option --instantiate b=true

type b : Bool
Expand Down
1 change: 0 additions & 1 deletion test/typecheck/pass/abstract_config.sail
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
default Order dec

$option --abstract-types
$option --config ../typecheck/pass/abstract_config.json

type xlen : Int = config arch.xlen
Expand Down
1 change: 0 additions & 1 deletion test/typecheck/pass/abstract_extend.sail
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ default Order dec

$include <prelude.sail>

$option --abstract-types
$option --instantiate xlen=32

type xlen : Int
Expand Down
1 change: 0 additions & 1 deletion test/typecheck/pass/abstract_ones.sail
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ default Order dec

$include <prelude.sail>

$option --abstract-types
$option --instantiate xlen=32

type xlen : Int
Expand Down
1 change: 0 additions & 1 deletion test/typecheck/pass/constraint_syn.sail
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
default Order dec
$include <prelude.sail>

$option --abstract-types
$option --instantiate xlen=32

type xlen : Int
Expand Down

0 comments on commit c622c29

Please sign in to comment.