diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/auxil.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/auxil.md index 1ed01b680..2cd20e5f1 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/auxil.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/auxil.md @@ -24,7 +24,7 @@ module WASM-AUXIL #clearConfig => .K ... _ => .Int _ => .ValStack - _ => .Map + _ => .List _ => .Bag _ => .Map _ => 0 diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/test.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/test.md index a9a27dc59..55e91d37b 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/test.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/test.md @@ -430,7 +430,8 @@ The operator `#assertLocal`/`#assertGlobal` operators perform a check for a loca ```k rule #assertLocal INDEX VALUE _ => .K ... - ... INDEX |-> VALUE ... + LOCALS + requires LOCALS[INDEX] ==K VALUE rule #assertGlobal TFIDX VALUE _ => .K ... CUR diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/wasm-text.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/wasm-text.md index da377db1f..22ca53e56 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/wasm-text.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/wasm-text.md @@ -1186,7 +1186,6 @@ They are currently supported in KWasm text files, but may be deprecated. rule #t2aInstr(#block(VT:VecType, IS:Instrs, BLOCKINFO)) => #block(VT, #t2aInstrs(IS), BLOCKINFO) - rule #t2aInstr<_>(init_local I V) => init_local I V rule #t2aInstr<_>(init_locals VS) => init_locals VS ``` diff --git a/pykwasm/src/pykwasm/kdist/wasm-semantics/wasm.md b/pykwasm/src/pykwasm/kdist/wasm-semantics/wasm.md index 1c90d62da..721162e43 100644 --- a/pykwasm/src/pykwasm/kdist/wasm-semantics/wasm.md +++ b/pykwasm/src/pykwasm/kdist/wasm-semantics/wasm.md @@ -163,10 +163,9 @@ Internal Syntax module WASM-INTERNAL-SYNTAX imports WASM-DATA-INTERNAL-SYNTAX - syntax Instr ::= "init_local" Int Val - | "init_locals" ValStack - | "#init_locals" Int ValStack - // -------------------------------------------- + syntax Instr ::= "init_locals" ValStack + | "#init_locals" ValStack + // ---------------------------------------- syntax Int ::= #pageSize() [function, total] syntax Int ::= #maxMemorySize() [function, total] @@ -200,8 +199,8 @@ module WASM .K .ValStack - .Map - .Int + .List + .Int .Map .Map @@ -558,17 +557,15 @@ Variable Operators The various `init_local` variants assist in setting up the `locals` cell. ```k - rule init_local INDEX VALUE => .K ... - LOCALS => LOCALS [ INDEX <- VALUE ] - - rule init_locals VALUES => #init_locals 0 VALUES ... + rule init_locals VALUES => #init_locals VALUES ... + _ => .List - rule #init_locals _ .ValStack => .K ... - rule #init_locals N (VALUE : VALSTACK) - => init_local N VALUE - ~> #init_locals (N +Int 1) VALSTACK + rule #init_locals .ValStack => .K ... + rule #init_locals (VALUE : VALSTACK) + => #init_locals VALSTACK ... + ... .List => ListItem(VALUE) ``` The `*_local` instructions are defined here. @@ -579,18 +576,18 @@ The `*_local` instructions are defined here. | "#local.tee" "(" Int ")" [symbol(aLocal.tee)] // ---------------------------------------------------------------------- rule #local.get(I) => .K ... - VALSTACK => VALUE : VALSTACK - ... I |-> VALUE ... + VALSTACK => {LOCALS [ I ]}:>Val : VALSTACK + LOCALS rule #local.set(I) => .K ... VALUE : VALSTACK => VALSTACK LOCALS => LOCALS[I <- VALUE] - requires I in_keys(LOCALS) + requires I >=Int 0 andBool I #local.tee(I) => .K ... VALUE : _VALSTACK LOCALS => LOCALS[I <- VALUE] - requires I in_keys(LOCALS) + requires I >=Int 0 andBool I ` cell), and Unlike labels, only one frame can be "broken" through at a time. ```k - syntax Frame ::= "frame" Int ValTypes ValStack Map - // -------------------------------------------------- + syntax Frame ::= "frame" Int ValTypes ValStack List + // --------------------------------------------------- rule frame MODIDX' TRANGE VALSTACK' LOCAL' => .K ... VALSTACK => #take(lengthValTypes(TRANGE), VALSTACK) ++ VALSTACK' _ => LOCAL' @@ -1196,7 +1193,7 @@ The `#take` function will return the parameter stack in the reversed order, then ... VALSTACK => .ValStack - LOCAL => .Map + LOCAL MODIDX => MODIDX' FADDR diff --git a/tests/success-llvm.out b/tests/success-llvm.out index 0eae581e8..bdfd25dfa 100644 --- a/tests/success-llvm.out +++ b/tests/success-llvm.out @@ -11,7 +11,7 @@ - .Map + .List .Int