diff options
Diffstat (limited to 'test/binaryen.js')
-rw-r--r-- | test/binaryen.js/stackir.js | 27 | ||||
-rw-r--r-- | test/binaryen.js/stackir.js.txt | 50 |
2 files changed, 77 insertions, 0 deletions
diff --git a/test/binaryen.js/stackir.js b/test/binaryen.js/stackir.js new file mode 100644 index 000000000..5c4b14f9d --- /dev/null +++ b/test/binaryen.js/stackir.js @@ -0,0 +1,27 @@ +var wast = ` +(module + (type $i (func (param i32) (result i32))) + (memory $0 0) + (export "test" (func $test)) + (func $test (; 0 ;) (type $i) (param $0 i32) (result i32) + (block (result i32) + (block (result i32) + (if (result i32) + (get_local $0) + (get_local $0) + (i32.const 0) + ) + ) + ) + ) +) +`; +console.log("=== input wast ===" + wast); + +var module = Binaryen.parseText(wast); + +console.log("=== default ==="); +console.log(module.emitStackIR()); + +console.log("=== optimize ==="); // should omit the second block +console.log(module.emitStackIR(true)); diff --git a/test/binaryen.js/stackir.js.txt b/test/binaryen.js/stackir.js.txt new file mode 100644 index 000000000..f0985ee5c --- /dev/null +++ b/test/binaryen.js/stackir.js.txt @@ -0,0 +1,50 @@ +=== input wast === +(module + (type $i (func (param i32) (result i32))) + (memory $0 0) + (export "test" (func $test)) + (func $test (; 0 ;) (type $i) (param $0 i32) (result i32) + (block (result i32) + (block (result i32) + (if (result i32) + (get_local $0) + (get_local $0) + (i32.const 0) + ) + ) + ) + ) +) + +=== default === +(module + (type $i (func (param i32) (result i32))) + (memory $0 0) + (export "test" (func $test)) + (func $test (; 0 ;) (; has Stack IR ;) (type $i) (param $0 i32) (result i32) + block $block0 (result i32) + get_local $0 + if (result i32) + get_local $0 + else + i32.const 0 + end + end + ) +) + +=== optimize === +(module + (type $i (func (param i32) (result i32))) + (memory $0 0) + (export "test" (func $test)) + (func $test (; 0 ;) (; has Stack IR ;) (type $i) (param $0 i32) (result i32) + get_local $0 + if (result i32) + get_local $0 + else + i32.const 0 + end + ) +) + |