summaryrefslogtreecommitdiff
path: root/src/interpreter.ml
diff options
context:
space:
mode:
authorAlasdair2018-11-28 00:29:10 +0000
committerAlasdair2018-11-28 00:36:13 +0000
commit3a0bcd6e7f1dd565fb41574285c9c09bbbe14697 (patch)
treef6fc3f0720eea07fe376c28ebad8d23b86e008c2 /src/interpreter.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/interpreter.ml')
-rw-r--r--src/interpreter.ml4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/interpreter.ml b/src/interpreter.ml
index 07a4b4ae..03877600 100644
--- a/src/interpreter.ml
+++ b/src/interpreter.ml
@@ -390,13 +390,15 @@ let rec step (E_aux (e_aux, annot) as orig_exp) =
Type_check.check_exp (env_of_annot annot) exp (typ_of orig_exp)
in
return exp
+ | Register _ when not gstate.allow_registers ->
+ return (exp_of_value (V_attempted_read (string_of_id id)))
| Local (Mutable, _) -> return (local_variable id lstate gstate)
| Local (Immutable, _) ->
let chain = build_letchain id gstate.letbinds orig_exp in
return chain
| Enum _ ->
return (exp_of_value (V_ctor (string_of_id id, [])))
- | _ -> failwith ("Coudln't find id " ^ string_of_id id)
+ | _ -> failwith ("Couldn't find id " ^ string_of_id id)
end
| E_record (FES_aux (FES_Fexps (fexps, flag), fes_annot)) ->