From ea2ff78cf675298df64e8ebacca7156b68f3c5c8 Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Fri, 2 Mar 2018 19:17:51 +0000 Subject: Use sail_lib.lem values in C backend Rather than just using strings to represent literals, now use value types from sail_lib.lem to represent them. This allows for expressions to be evaluated at compile time, which will be useful for future optimisations involving constant folding and propagation, and allows the intermediate bytecode to be interpreted using the same lem builtins that the shallow embedding uses. To get this to work I had to tweak the build process slightly to allow ml files to import lem files from gen_lib/. Hopefully this doesn't break anything! --- language/bytecode.ott | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'language/bytecode.ott') diff --git a/language/bytecode.ott b/language/bytecode.ott index e9e6eb77..30c9195f 100644 --- a/language/bytecode.ott +++ b/language/bytecode.ott @@ -32,10 +32,16 @@ metavar bool ::= {{ ocaml bool }} {{ lem bool }} +metavar value ::= + {{ phantom }} + {{ lem vl }} + {{ ocaml vl }} + embed {{ lem open import Ast +open import Value2 }} @@ -45,7 +51,7 @@ grammar % expressions, used by the aval and cval types. fragment :: 'F_' ::= | id :: :: id - | string :: :: lit + | value :: :: lit | have_exception :: :: have_exception | current_exception :: :: current_exception | fragment op fragment' :: :: op -- cgit v1.2.3