From 74c07521145bda4368e723f1c5c89833dec12d27 Mon Sep 17 00:00:00 2001 From: Luke Wagner Date: Wed, 30 Sep 2015 10:03:42 -0500 Subject: [PATCH] Rename StoreTrunc to StoreWrap for consistency --- ml-proto/README.md | 10 ++++------ ml-proto/src/host/lexer.mll | 6 +++--- ml-proto/src/host/parser.mly | 4 ++-- ml-proto/src/spec/ast.ml | 4 ++-- ml-proto/src/spec/check.ml | 6 +++--- ml-proto/src/spec/eval.ml | 4 ++-- ml-proto/src/spec/memory.ml | 2 +- ml-proto/src/spec/memory.mli | 2 +- 8 files changed, 18 insertions(+), 20 deletions(-) diff --git a/ml-proto/README.md b/ml-proto/README.md index 5627b75618..0296f5db6d 100644 --- a/ml-proto/README.md +++ b/ml-proto/README.md @@ -126,10 +126,10 @@ type expr = | GetParam of var (* read parameter | GetLocal of var (* read local variable | SetLocal of var * expr (* write local variable - | LoadGlobal of var (* read global variable - | StoreGlobal of var * expr (* write global variable - | Load of loadop * expr (* read memory address - | Store of storeop * expr * expr (* write memory address + | Load of memop * expr (* read memory address + | Store of memop * expr * expr (* write memory address + | LoadExtend of extendop * expr (* read memory address with sign- or zero-extension + | StoreWrap of wrapop * expr * expr (* write memory address with wrapping | Const of value (* constant | Unary of unop * expr (* unary arithmetic operator | Binary of binop * expr * expr (* binary arithmetic operator @@ -178,8 +178,6 @@ expr: ( return ? ) ( get_local ) ( set_local ) - ( load_global ) - ( store_global ) ( .load((8|16)_)?(/)? ) ( .store(/)? ) ( .const ) diff --git a/ml-proto/src/host/lexer.mll b/ml-proto/src/host/lexer.mll index 3483b5803a..79fd5f2942 100644 --- a/ml-proto/src/host/lexer.mll +++ b/ml-proto/src/host/lexer.mll @@ -77,7 +77,7 @@ let extension = function let extendop t sz s a = {memop = memop t a; sz = mem_size sz; ext = extension s} -let truncop t sz a = +let wrapop t sz a = {memop = memop t a; sz = mem_size sz} } @@ -147,9 +147,9 @@ rule token = parse | (ixx as t)".load"(mem_size as sz)"_"(sign as s)"/"(align as a) { LOADEXTEND (extendop t sz s a) } | (ixx as t)".store"(mem_size as sz) - { STORETRUNC (truncop t sz "") } + { STOREWRAP (wrapop t sz "") } | (ixx as t)".store"(mem_size as sz)"/"(align as a) - { STORETRUNC (truncop t sz a) } + { STOREWRAP (wrapop t sz a) } | (nxx as t)".switch" { SWITCH (value_type t) } | (nxx as t)".const" { CONST (value_type t) } diff --git a/ml-proto/src/host/parser.mly b/ml-proto/src/host/parser.mly index c671035a39..ef7650dc15 100644 --- a/ml-proto/src/host/parser.mly +++ b/ml-proto/src/host/parser.mly @@ -116,7 +116,7 @@ let anon_label c = {c with labels = VarMap.map ((+) 1) c.labels} %token LOAD %token STORE %token LOADEXTEND -%token STORETRUNC +%token STOREWRAP %start script %type script @@ -182,7 +182,7 @@ oper : | LOAD expr { fun c -> Load ($1, $2 c) } | STORE expr expr { fun c -> Store ($1, $2 c, $3 c) } | LOADEXTEND expr { fun c -> LoadExtend ($1, $2 c) } - | STORETRUNC expr expr { fun c -> StoreTrunc ($1, $2 c, $3 c) } + | STOREWRAP expr expr { fun c -> StoreWrap ($1, $2 c, $3 c) } | CONST literal { let at = at() in fun c -> Const (literal at $2 $1) } | UNARY expr { fun c -> Unary ($1, $2 c) } | BINARY expr expr { fun c -> Binary ($1, $2 c, $3 c) } diff --git a/ml-proto/src/spec/ast.ml b/ml-proto/src/spec/ast.ml index 1605f68b9b..aa3b7af1c6 100644 --- a/ml-proto/src/spec/ast.ml +++ b/ml-proto/src/spec/ast.ml @@ -65,7 +65,7 @@ type cvt = (Int32Op.cvt, Int64Op.cvt, Float32Op.cvt, Float64Op.cvt) op type memop = {ty : Types.value_type; align : int option} type extendop = {memop : memop; sz : Memory.mem_size; ext : Memory.extension} -type truncop = {memop : memop; sz : Memory.mem_size} +type wrapop = {memop : memop; sz : Memory.mem_size} (* Expressions *) @@ -90,7 +90,7 @@ and expr' = | Load of memop * expr | Store of memop * expr * expr | LoadExtend of extendop * expr - | StoreTrunc of truncop * expr * expr + | StoreWrap of wrapop * expr * expr | Const of literal | Unary of unop * expr | Binary of binop * expr * expr diff --git a/ml-proto/src/spec/check.ml b/ml-proto/src/spec/check.ml index 1ca52be718..6981820f89 100644 --- a/ml-proto/src/spec/check.ml +++ b/ml-proto/src/spec/check.ml @@ -184,9 +184,9 @@ let rec check_expr c et e = check_mem_type extendop.memop.ty extendop.sz e.at; check_load c et extendop.memop e1 e.at - | StoreTrunc (truncop, e1, e2) -> - check_mem_type truncop.memop.ty truncop.sz e.at; - check_store c et truncop.memop e1 e2 e.at + | StoreWrap (wrapop, e1, e2) -> + check_mem_type wrapop.memop.ty wrapop.sz e.at; + check_store c et wrapop.memop e1 e2 e.at | Const v -> check_literal c et v diff --git a/ml-proto/src/spec/eval.ml b/ml-proto/src/spec/eval.ml index 16eab27afa..9baf92daf4 100644 --- a/ml-proto/src/spec/eval.ml +++ b/ml-proto/src/spec/eval.ml @@ -188,11 +188,11 @@ let rec eval_expr (c : config) (e : expr) = (try Some (Memory.load_extend c.modul.memory a sz ext ty) with exn -> memory_error e.at exn) - | StoreTrunc ({memop = {ty; align = _}; sz}, e1, e2) -> + | StoreWrap ({memop = {ty; align = _}; sz}, e1, e2) -> let v1 = some (eval_expr c e1) e1.at in let v2 = some (eval_expr c e2) e2.at in let a = Memory.address_of_value v1 in - (try Memory.store_trunc c.modul.memory a sz v2 + (try Memory.store_wrap c.modul.memory a sz v2 with exn -> memory_error e.at exn); None diff --git a/ml-proto/src/spec/memory.ml b/ml-proto/src/spec/memory.ml index 8b317c258d..4263b9fa69 100644 --- a/ml-proto/src/spec/memory.ml +++ b/ml-proto/src/spec/memory.ml @@ -115,7 +115,7 @@ let load_extend mem a sz ext t = | Mem32, SX, Int64Type -> Int64 (loadn_sx mem 4 a) | _ -> raise Type -let store_trunc mem a sz v = +let store_wrap mem a sz v = match sz, v with | Mem8, Int32 x -> storen mem 1 a (Int64.of_int32 x) | Mem8, Int64 x -> storen mem 1 a x diff --git a/ml-proto/src/spec/memory.mli b/ml-proto/src/spec/memory.mli index eda9fdd897..6f7112a29f 100644 --- a/ml-proto/src/spec/memory.mli +++ b/ml-proto/src/spec/memory.mli @@ -23,6 +23,6 @@ val resize : memory -> size -> unit val load : memory -> address -> value_type -> value val store : memory -> address -> value -> unit val load_extend : memory -> address -> mem_size -> extension -> value_type -> value -val store_trunc : memory -> address -> mem_size -> value -> unit +val store_wrap : memory -> address -> mem_size -> value -> unit val address_of_value : Values.value -> address