summaryrefslogtreecommitdiff
path: root/src/bytecode_util.ml
diff options
context:
space:
mode:
authorAlasdair Armstrong2018-06-26 14:44:27 +0100
committerAlasdair Armstrong2018-06-26 22:48:16 +0100
commita5bc362fca3d8a7c6d49b35dcf0b63440d23303c (patch)
tree2a942f6cf06c2fcd5888484861300b416b93060f /src/bytecode_util.ml
parente65b6b3cd2a3259f1d709fc8a0fb11fdbf667a39 (diff)
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.
Diffstat (limited to 'src/bytecode_util.ml')
-rw-r--r--src/bytecode_util.ml5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/bytecode_util.ml b/src/bytecode_util.ml
index 9f23412e..2e6e1e29 100644
--- a/src/bytecode_util.ml
+++ b/src/bytecode_util.ml
@@ -287,8 +287,9 @@ let pp_cdef = function
pp_keyword "function" ^^ pp_id id ^^ ret ^^ parens (separate_map (comma ^^ space) pp_id args) ^^ space
^^ surround 2 0 lbrace (separate_map (semi ^^ hardline) pp_instr instrs) rbrace
^^ hardline
- | CDEF_reg_dec (id, ctyp) ->
- pp_keyword "register" ^^ pp_id id ^^ string " : " ^^ pp_ctyp ctyp
+ | CDEF_reg_dec (id, ctyp, instrs) ->
+ pp_keyword "register" ^^ pp_id id ^^ string " : " ^^ pp_ctyp ctyp ^^ space
+ ^^ surround 2 0 lbrace (separate_map (semi ^^ hardline) pp_instr instrs) rbrace
^^ hardline
| CDEF_type tdef -> pp_ctype_def tdef ^^ hardline
| CDEF_let (n, bindings, instrs) ->