summaryrefslogtreecommitdiff
path: root/src/constant_fold.ml
diff options
context:
space:
mode:
authorAlasdair2018-11-28 00:29:10 +0000
committerAlasdair2018-11-28 00:36:13 +0000
commit3a0bcd6e7f1dd565fb41574285c9c09bbbe14697 (patch)
treef6fc3f0720eea07fe376c28ebad8d23b86e008c2 /src/constant_fold.ml
parent134ceff00b6a4837b133cb49b6d775161420dc62 (diff)
Allow folding constant expressions into single register reads
Essentially all we have to do to make this work is introduce a member of the Value type, V_attempted_read <reg>, which is returned whenever we try to read a register value with allow_registers disabled. This defers the failure from reading the register to the point where the register value is used (simply because nothing knows how to deal with V_attempted_read). However, if V_attempted_read is returned directly as the result of evaluating an expression, then we can replace the expression with a single direct register read. This optimises some indirection in the ARM specification.
Diffstat (limited to 'src/constant_fold.ml')
-rw-r--r--src/constant_fold.ml1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/constant_fold.ml b/src/constant_fold.ml
index f22b48de..0e34ed5b 100644
--- a/src/constant_fold.ml
+++ b/src/constant_fold.ml
@@ -78,6 +78,7 @@ and exp_of_value =
| V_tuple vs ->
mk_exp (E_tuple (List.map exp_of_value vs))
| V_unit -> mk_lit_exp L_unit
+ | V_attempted_read str -> mk_exp (E_id (mk_id str))
| _ -> failwith "No expression for value"
(* We want to avoid evaluating things like print statements at compile