From 3a0bcd6e7f1dd565fb41574285c9c09bbbe14697 Mon Sep 17 00:00:00 2001 From: Alasdair Date: Wed, 28 Nov 2018 00:29:10 +0000 Subject: 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 , 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. --- src/constant_fold.ml | 1 + 1 file changed, 1 insertion(+) (limited to 'src/constant_fold.ml') 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 -- cgit v1.2.3