[ewasm] Properly encode i32/i64.select in the text format

This commit is contained in:
Alex Beregszaszi 2020-12-01 02:00:45 +00:00
parent 91e67472bf
commit a29a7ad680
2 changed files with 6 additions and 3 deletions

View File

@ -122,8 +122,11 @@ string TextTransform::operator()(wasm::BuiltinCall const& _builtinCall)
{
string args = joinTransformed(_builtinCall.arguments);
string funcName = _builtinCall.functionName;
// These are prefixed in the dialect, but are actually overloaded instructions in WebAssembly.
if (funcName == "i32.drop" || funcName == "i64.drop")
funcName = "drop";
else if (funcName == "i32.select" || funcName == "i64.select")
funcName = "select";
return "(" + funcName + (args.empty() ? "" : " " + args) + ")";
}

View File

@ -412,13 +412,13 @@ Text representation:
(local.set $z (i32.const 0))
(local.set $_1 (i32.const 4294967295))
(block
(local.set $condition (i32.select (local.get $_1) (i64.ne (local.get $x1) (local.get $y1)) (i64.lt_u (local.get $x1) (local.get $y1))))
(local.set $condition (select (local.get $_1) (i64.ne (local.get $x1) (local.get $y1)) (i64.lt_u (local.get $x1) (local.get $y1))))
(if (i32.eq (local.get $condition) (i32.const 0)) (then
(block
(local.set $condition_11 (i32.select (local.get $_1) (i64.ne (local.get $x2) (local.get $y2)) (i64.lt_u (local.get $x2) (local.get $y2))))
(local.set $condition_11 (select (local.get $_1) (i64.ne (local.get $x2) (local.get $y2)) (i64.lt_u (local.get $x2) (local.get $y2))))
(if (i32.eq (local.get $condition_11) (i32.const 0)) (then
(block
(local.set $condition_12 (i32.select (local.get $_1) (i64.ne (local.get $x3) (local.get $y3)) (i64.lt_u (local.get $x3) (local.get $y3))))
(local.set $condition_12 (select (local.get $_1) (i64.ne (local.get $x3) (local.get $y3)) (i64.lt_u (local.get $x3) (local.get $y3))))
(if (i32.eq (local.get $condition_12) (i32.const 0)) (then
(local.set $z (i64.lt_u (local.get $x4) (local.get $y4)))
)(else