summaryrefslogtreecommitdiff
path: root/mips_new_tc/mips_extras_embed.lem
diff options
context:
space:
mode:
authorThomas Bauereiss2017-12-19 11:53:23 +0000
committerThomas Bauereiss2017-12-19 12:03:48 +0000
commitb938fd99a9f16d4bb2ef1c483574a2850aa6e640 (patch)
tree0e160767d304677005c06222a28a574792257f4f /mips_new_tc/mips_extras_embed.lem
parent5c0b807f89b99b1f7adb2a2f6aebdea52a8bdd80 (diff)
Support user-defined exceptions in Lem shallow embedding
The type-checker already supports a user-defined "exception" type that can be used in throw and try-catch expressions. This patch adds support for that to the Lem shallow embedding by adapting the existing exception mechanisms of the state and prompt monads. User-defined exceptions are distinguished from builtin exception cases. For example, the state monad uses type ex 'e = | Exit | Assert of string | Throw of 'e to distinguish between calls to "exit", failed assertions, and user-defined exceptions, respectively. Early return is also handled using the exception mechanism, by lifting to a monad with "either 'r exception" as the exception type, where 'r is the expected return type and "exception" is the user-defined exception type.
Diffstat (limited to 'mips_new_tc/mips_extras_embed.lem')
-rw-r--r--mips_new_tc/mips_extras_embed.lem28
1 files changed, 14 insertions, 14 deletions
diff --git a/mips_new_tc/mips_extras_embed.lem b/mips_new_tc/mips_extras_embed.lem
index 82f208f6..bda70274 100644
--- a/mips_new_tc/mips_extras_embed.lem
+++ b/mips_new_tc/mips_extras_embed.lem
@@ -4,10 +4,10 @@ open import Sail_impl_base
open import Sail_values
open import Prompt
-val MEMr : forall 'a 'b. Bitvector 'a, Bitvector 'b => ('a * integer) -> M 'b
-val MEMr_reserve : forall 'a 'b. Bitvector 'a, Bitvector 'b => ('a * integer) -> M 'b
-val MEMr_tag : forall 'a 'b. Bitvector 'a, Bitvector 'b => ('a * integer) -> M 'b
-val MEMr_tag_reserve : forall 'a 'b. Bitvector 'a, Bitvector 'b => ('a * integer) -> M 'b
+val MEMr : forall 'a 'b 'e. Bitvector 'a, Bitvector 'b => ('a * integer) -> M 'b 'e
+val MEMr_reserve : forall 'a 'b 'e. Bitvector 'a, Bitvector 'b => ('a * integer) -> M 'b 'e
+val MEMr_tag : forall 'a 'b 'e. Bitvector 'a, Bitvector 'b => ('a * integer) -> M 'b 'e
+val MEMr_tag_reserve : forall 'a 'b 'e. Bitvector 'a, Bitvector 'b => ('a * integer) -> M 'b 'e
let MEMr (addr,size) = read_mem false Read_plain addr size
let MEMr_reserve (addr,size) = read_mem false Read_reserve addr size
@@ -16,10 +16,10 @@ let MEMr_tag (addr,size) = read_mem false Read_plain addr size
let MEMr_tag_reserve (addr,size) = read_mem false Read_reserve addr size
-val MEMea : forall 'a. Bitvector 'a => ('a * integer) -> M unit
-val MEMea_conditional : forall 'a. Bitvector 'a => ('a * integer) -> M unit
-val MEMea_tag : forall 'a. Bitvector 'a => ('a * integer) -> M unit
-val MEMea_tag_conditional : forall 'a. Bitvector 'a => ('a * integer) -> M unit
+val MEMea : forall 'a 'e. Bitvector 'a => ('a * integer) -> M unit 'e
+val MEMea_conditional : forall 'a 'e. Bitvector 'a => ('a * integer) -> M unit 'e
+val MEMea_tag : forall 'a 'e. Bitvector 'a => ('a * integer) -> M unit 'e
+val MEMea_tag_conditional : forall 'a 'e. Bitvector 'a => ('a * integer) -> M unit 'e
let MEMea (addr,size) = write_mem_ea Write_plain addr size
let MEMea_conditional (addr,size) = write_mem_ea Write_conditional addr size
@@ -28,10 +28,10 @@ let MEMea_tag (addr,size) = write_mem_ea Write_plain addr size
let MEMea_tag_conditional (addr,size) = write_mem_ea Write_conditional addr size
-val MEMval : forall 'a 'b. Bitvector 'a, Bitvector 'b => ('a * integer * 'b) -> M unit
-val MEMval_conditional : forall 'a 'b. Bitvector 'a, Bitvector 'b => ('a * integer * 'b) -> M bool
-val MEMval_tag : forall 'a 'b. Bitvector 'a, Bitvector 'b => ('a * integer * 'b) -> M unit
-val MEMval_tag_conditional : forall 'a 'b. Bitvector 'a, Bitvector 'b => ('a * integer * 'b) -> M bool
+val MEMval : forall 'a 'b 'e. Bitvector 'a, Bitvector 'b => ('a * integer * 'b) -> M unit 'e
+val MEMval_conditional : forall 'a 'b 'e. Bitvector 'a, Bitvector 'b => ('a * integer * 'b) -> M bool 'e
+val MEMval_tag : forall 'a 'b 'e. Bitvector 'a, Bitvector 'b => ('a * integer * 'b) -> M unit 'e
+val MEMval_tag_conditional : forall 'a 'b 'e. Bitvector 'a, Bitvector 'b => ('a * integer * 'b) -> M bool 'e
let MEMval (_,_,v) = write_mem_val v >>= fun _ -> return ()
let MEMval_conditional (_,_,v) = write_mem_val v >>= fun b -> return (if b then true else false)
@@ -39,9 +39,9 @@ let MEMval_tag (_,_,v) = write_mem_val v >>= fun _ -> return ()
let MEMval_tag_conditional (_,_,v) = write_mem_val v >>= fun b -> return (if b then true else false)
(* TODO *)
-val TAGw : (vector bitU * vector bitU) -> M unit
+val TAGw : forall 'e. (vector bitU * vector bitU) -> M unit 'e
let TAGw (addr, tag) = failwith "TAGw not implemented"
-val MEM_sync : unit -> M unit
+val MEM_sync : forall 'e. unit -> M unit 'e
let MEM_sync () = barrier Barrier_Isync