summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cheri/Holmakefile2
-rw-r--r--cheri/Makefile2
-rw-r--r--lib/hol/prompt.lem6
-rw-r--r--lib/hol/prompt_monad.lem18
-rw-r--r--riscv/Holmakefile2
-rw-r--r--riscv/Makefile8
-rw-r--r--src/gen_lib/prompt_monad.lem7
-rw-r--r--src/pretty_print_lem.ml4
8 files changed, 38 insertions, 11 deletions
diff --git a/cheri/Holmakefile b/cheri/Holmakefile
index 604555b5..d64fc3fd 100644
--- a/cheri/Holmakefile
+++ b/cheri/Holmakefile
@@ -2,7 +2,7 @@ LEMDIR=../../lem/hol-lib
INCLUDES = $(LEMDIR) ../lib/hol
-all: cheri_sequentialTheory.uo
+all: cheriTheory.uo
.PHONY: all
ifdef POLY
diff --git a/cheri/Makefile b/cheri/Makefile
index a1fb337e..1f3e5179 100644
--- a/cheri/Makefile
+++ b/cheri/Makefile
@@ -80,7 +80,7 @@ C%.thy: c%.lem c%_types.lem $(MIPS_SAIL_DIR)/mips_extras.lem
lem -isa -outdir . -lib $(SAIL_DIR)/src/gen_lib -lib $(SAIL_DIR)/src/lem_interp $^
sed -i 's/datatype ast/datatype (plugins only: size) ast/' C$*_types.thy
-%Script.sml: %.lem %_types.lem $(MIPS_SAIL_DIR)/mips_extras_sequential.lem
+%Script.sml: %.lem %_types.lem $(MIPS_SAIL_DIR)/mips_extras.lem
lem -hol -outdir . -lib $(SAIL_DIR)/lib/hol -lib $(SAIL_DIR)/src/gen_lib -lib $(SAIL_DIR)/src/lem_interp $^
clean:
diff --git a/lib/hol/prompt.lem b/lib/hol/prompt.lem
index a04e0a0a..edbd3752 100644
--- a/lib/hol/prompt.lem
+++ b/lib/hol/prompt.lem
@@ -10,3 +10,9 @@ let inline of_bits_oracle = of_bits_oracleS
let inline of_bits_fail = of_bits_failS
let inline mword_oracle = mword_oracleS
let inline reg_deref = read_regS
+
+let inline foreachM = foreachS
+let inline whileM = whileS
+let inline untilM = untilS
+let inline and_boolM = and_boolS
+let inline or_boolM = or_boolS
diff --git a/lib/hol/prompt_monad.lem b/lib/hol/prompt_monad.lem
index 4481f623..8fcd645a 100644
--- a/lib/hol/prompt_monad.lem
+++ b/lib/hol/prompt_monad.lem
@@ -9,27 +9,41 @@ open import State_monad
type monad 'rv 'a 'e = monadS 'rv 'a 'e
type monadR 'rv 'a 'e 'r = monadRS 'rv 'a 'e 'r
+(* We need to use a target_rep for these because HOL doesn't handle unused
+ type parameters well. *)
+
+type base_monad 'regval 'regstate 'a 'e = monad 'regstate 'a 'e
+declare hol target_rep type base_monad 'regval 'regstate 'a 'e = `monad` 'regstate 'a 'e
+type base_monadR 'regval 'regstate 'a 'r 'e = monadR 'regstate 'a 'r 'e
+declare hol target_rep type base_monadR 'regval 'regstate 'a 'r 'e = `monadR` 'regstate 'a 'r 'e
+
let inline return = returnS
let inline bind = bindS
let inline (>>=) = (>>$=)
let inline (>>) = (>>$)
+let inline exit = exitS
+
let inline throw = throwS
let inline try_catch = try_catchS
let inline catch_early_return = catch_early_returnS
let inline early_return = early_returnS
+let inline liftR = liftRS
+let inline try_catchR = try_catchRS
let inline maybe_fail = maybe_failS
+let inline read_mem_bytes = read_mem_bytesS
let inline read_reg = read_regS
let inline reg_deref = read_regS
let inline read_mem = read_memS
let inline read_tag = read_tagS
+let inline excl_result = excl_resultS
+let inline write_reg = write_regS
let inline write_tag = write_tagS
let inline write_mem_ea wk addr sz = write_mem_eaS wk addr (nat_of_int sz)
let inline write_mem_val = write_mem_valS
let barrier _ = return ()
-let inline excl_result = excl_resultS
-let inline assert_exp = assert_expS \ No newline at end of file
+let inline assert_exp = assert_expS
diff --git a/riscv/Holmakefile b/riscv/Holmakefile
index 626e6f2f..8269bc36 100644
--- a/riscv/Holmakefile
+++ b/riscv/Holmakefile
@@ -2,7 +2,7 @@ LEMDIR=../../lem/hol-lib
INCLUDES = $(LEMDIR) ../lib/hol
-all: riscv_sequentialTheory.uo
+all: riscvTheory.uo
.PHONY: all
ifdef POLY
diff --git a/riscv/Makefile b/riscv/Makefile
index 9d3a2196..110236d7 100644
--- a/riscv/Makefile
+++ b/riscv/Makefile
@@ -37,11 +37,11 @@ riscv.lem: $(SAIL_SRCS) Makefile
riscv_sequential.lem: $(SAIL_SRCS) Makefile
$(SAIL_DIR)/sail -lem -lem_sequential -o riscv_sequential -lem_mwords -lem_lib Riscv_extras_sequential $(SAIL_SRCS)
-riscv_sequentialScript.sml : riscv_sequential.lem riscv_extras_sequential.lem
+riscvScript.sml : riscv.lem riscv_extras.lem
lem -hol -outdir . -lib ../lib/hol -lib ../src/lem_interp -lib ../src/gen_lib \
- riscv_extras_sequential.lem \
- riscv_sequential_types.lem \
- riscv_sequential.lem
+ riscv_extras.lem \
+ riscv_types.lem \
+ riscv.lem
# we exclude prelude.sail here, most code there should move to sail lib
LOC_FILES:=$(SAIL_SRCS) main.sail
diff --git a/src/gen_lib/prompt_monad.lem b/src/gen_lib/prompt_monad.lem
index 9eb59319..87c9af39 100644
--- a/src/gen_lib/prompt_monad.lem
+++ b/src/gen_lib/prompt_monad.lem
@@ -212,3 +212,10 @@ let barrier bk = Barrier bk (Done ())
val footprint : forall 'rv 'e. unit -> monad 'rv unit 'e
let footprint _ = Footprint (Done ())
+
+(* Define a type synonym that also takes the register state as a type parameter,
+ in order to make switching to the state monad without changing generated
+ definitions easier, see also lib/hol/prompt_monad.lem. *)
+
+type base_monad 'regval 'regstate 'a 'e = monad 'regval 'a 'e
+type base_monadR 'regval 'regstate 'a 'r 'e = monadR 'regval 'a 'r 'e
diff --git a/src/pretty_print_lem.ml b/src/pretty_print_lem.ml
index 332d5681..36794348 100644
--- a/src/pretty_print_lem.ml
+++ b/src/pretty_print_lem.ml
@@ -1455,8 +1455,8 @@ let pp_defs_lem (types_file,types_modules) (defs_file,defs_modules) (Defs defs)
]
else
concat [
- string ("type MR 'a 'r = monadR register_value 'a 'r " ^ exc_typ); hardline;
- string ("type M 'a = monad register_value 'a " ^ exc_typ); hardline
+ string ("type MR 'a 'r = base_monadR register_value regstate 'a 'r " ^ exc_typ); hardline;
+ string ("type M 'a = base_monad register_value regstate 'a " ^ exc_typ); hardline
]
]);
(print defs_file)