From a29a7ad680eb8e7b9e234fd8c2834dccb3ec83ad Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 1 Dec 2020 02:00:45 +0000 Subject: [PATCH] [ewasm] Properly encode i32/i64.select in the text format --- libyul/backends/wasm/TextTransform.cpp | 3 +++ test/cmdlineTests/evm_to_wasm_break/output | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libyul/backends/wasm/TextTransform.cpp b/libyul/backends/wasm/TextTransform.cpp index d178003b4..65c2bbb37 100644 --- a/libyul/backends/wasm/TextTransform.cpp +++ b/libyul/backends/wasm/TextTransform.cpp @@ -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) + ")"; } diff --git a/test/cmdlineTests/evm_to_wasm_break/output b/test/cmdlineTests/evm_to_wasm_break/output index 2a70119d9..88212dd94 100644 --- a/test/cmdlineTests/evm_to_wasm_break/output +++ b/test/cmdlineTests/evm_to_wasm_break/output @@ -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