From a5bc362fca3d8a7c6d49b35dcf0b63440d23303c Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Tue, 26 Jun 2018 14:44:27 +0100 Subject: Add configuration registers so __SetConfig ASL can be translated Registers can now be marked as configuration registers, for example: register configuration CFG_RVBAR = 0x1300000 They work like ordinary registers except they can only be set by functions with the 'configuration' effect and have no effect when read. They also have an initialiser, like a let-binding. Internally there is a new reg_dec constructor DEC_config. They are intended to represent configuration parameters for the model, which can change between runs, but don't change during execution. Currently they'll only work when compiled to C. Internally registers can now have custom effects for reads and writes rather than just rreg and wreg, so the type signatures of Env.add_register and Env.get_register have changed, as well as the Register lvar, so in the type checker we now write: Env.add_register id read_effect write_effect typ rather than Env.add_register id typ For the corresponding change to ASL parser there's a function is_config in asl_to_sail.ml which controls what becomes a configuration register for ARM. Some things we have to keep as let-bindings because Sail can't handle them changing at runtime - e.g. the length of vectors in other top-level definitions. Luckily __SetConfig doesn't (yet) try to change those options. Together these changes allow us to translate the ASL __SetConfig function, which means we should get command-line option compatibility with ArchEx for running the ARM conformance tests. --- src/parser.mly | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/parser.mly') diff --git a/src/parser.mly b/src/parser.mly index 60ccc81f..0637d61a 100644 --- a/src/parser.mly +++ b/src/parser.mly @@ -178,7 +178,7 @@ let rec desugar_rchain chain s e = %token Pure Register Return Scattered Sizeof Struct Then True TwoCaret TYPE Typedef %token Undefined Union Newtype With Val Constraint Throw Try Catch Exit Bitfield %token Barr Depend Rreg Wreg Rmem Rmemt Wmem Wmv Wmvt Eamem Exmem Undef Unspec Nondet Escape -%token Repeat Until While Do Mutual Var Ref +%token Repeat Until While Do Mutual Var Ref Configuration %nonassoc Then %nonassoc Else @@ -634,6 +634,8 @@ effect: { mk_effect BE_nondet $startpos $endpos } | Escape { mk_effect BE_escape $startpos $endpos } + | Configuration + { mk_effect BE_config $startpos $endpos } effect_list: | effect @@ -1331,6 +1333,8 @@ val_spec_def: register_def: | Register id Colon typ { mk_reg_dec (DEC_reg ($4, $2)) $startpos $endpos } + | Register Configuration id Colon typ Eq exp + { mk_reg_dec (DEC_config ($3, $5, $7)) $startpos $endpos } default_def: | Default base_kind Inc -- cgit v1.2.3