Transition to TypeFlags for specific type checks; Optimize logical ops a bit

This commit is contained in:
dcodeIO
2018-01-10 23:19:14 +01:00
parent fc777b3a89
commit d89703cdad
18 changed files with 750 additions and 720 deletions

View File

@ -0,0 +1,19 @@
var binaryen = require("binaryen");
var mod = new binaryen.Module();
var funcType = mod.addFunctionType("i", binaryen.i32, [ binaryen.i32 ]);
var func = mod.addFunction("test", funcType, [],
mod.if(
mod.i32.eqz(mod.getLocal(0, binaryen.i32)),
mod.i32.const(0),
mod.getLocal(0, binaryen.i32)
)
);
mod.addExport("test", "test");
console.log(mod.emitText());
if (!mod.validate())
console.log("-> does not validate");
mod.optimize();
console.log(mod.emitText());

View File

@ -0,0 +1,14 @@
(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)
(if (result i32)
(i32.eqz
(get_local $0)
)
(i32.const 0)
(get_local $0)
)
)
)