mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[ewasm] Add i32.select/i64.select
This commit is contained in:
parent
a5a560e163
commit
9640cfd77e
@ -4,6 +4,7 @@ Language Features:
|
|||||||
* Code generator: Support copying dynamically encoded structs from calldata to memory.
|
* Code generator: Support copying dynamically encoded structs from calldata to memory.
|
||||||
* Code generator: Support copying of nested arrays from calldata to memory.
|
* Code generator: Support copying of nested arrays from calldata to memory.
|
||||||
* The fallback function can now also have a single ``calldata`` argument (equaling ``msg.data``) and return ``bytes memory`` (which will not be ABI-encoded but returned as-is).
|
* The fallback function can now also have a single ``calldata`` argument (equaling ``msg.data``) and return ``bytes memory`` (which will not be ABI-encoded but returned as-is).
|
||||||
|
* Wasm backend: Add ``i32.select`` and ``i64.select`` instructions.
|
||||||
|
|
||||||
Compiler Features:
|
Compiler Features:
|
||||||
* Code Generator: Avoid memory allocation for default value if it is not used.
|
* Code Generator: Avoid memory allocation for default value if it is not used.
|
||||||
|
@ -156,6 +156,8 @@ Opcode constOpcodeFor(ValueType _type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static map<string, uint8_t> const builtins = {
|
static map<string, uint8_t> const builtins = {
|
||||||
|
{"i32.select", 0x1b},
|
||||||
|
{"i64.select", 0x1b},
|
||||||
{"i32.load", 0x28},
|
{"i32.load", 0x28},
|
||||||
{"i64.load", 0x29},
|
{"i64.load", 0x29},
|
||||||
{"i32.load8_s", 0x2c},
|
{"i32.load8_s", 0x2c},
|
||||||
|
@ -120,6 +120,10 @@ WasmDialect::WasmDialect()
|
|||||||
addFunction("i32.drop", {i32}, {});
|
addFunction("i32.drop", {i32}, {});
|
||||||
addFunction("i64.drop", {i64}, {});
|
addFunction("i64.drop", {i64}, {});
|
||||||
|
|
||||||
|
// Select is also overloaded.
|
||||||
|
addFunction("i32.select", {i32, i32, i32}, {i32});
|
||||||
|
addFunction("i64.select", {i64, i64, i32}, {i64});
|
||||||
|
|
||||||
addFunction("nop", {}, {});
|
addFunction("nop", {}, {});
|
||||||
addFunction("unreachable", {}, {}, false);
|
addFunction("unreachable", {}, {}, false);
|
||||||
m_functions["unreachable"_yulstring].sideEffects.storage = SideEffects::None;
|
m_functions["unreachable"_yulstring].sideEffects.storage = SideEffects::None;
|
||||||
|
@ -154,6 +154,20 @@ u256 EwasmBuiltinInterpreter::evalBuiltin(
|
|||||||
}
|
}
|
||||||
else if (fun == "i32.drop" || fun == "i64.drop" || fun == "nop")
|
else if (fun == "i32.drop" || fun == "i64.drop" || fun == "nop")
|
||||||
return {};
|
return {};
|
||||||
|
else if (fun == "i32.select")
|
||||||
|
{
|
||||||
|
if ((arg.at(2) & 0xffffffff) == 0)
|
||||||
|
return arg.at(1);
|
||||||
|
else
|
||||||
|
return arg.at(0);
|
||||||
|
}
|
||||||
|
else if (fun == "i64.select")
|
||||||
|
{
|
||||||
|
if ((arg.at(2) & 0xffffffffffffffff) == 0)
|
||||||
|
return arg.at(1);
|
||||||
|
else
|
||||||
|
return arg.at(0);
|
||||||
|
}
|
||||||
else if (fun == "i32.wrap_i64")
|
else if (fun == "i32.wrap_i64")
|
||||||
return arg.at(0) & uint32_t(-1);
|
return arg.at(0) & uint32_t(-1);
|
||||||
else if (fun == "i64.extend_i32_u")
|
else if (fun == "i64.extend_i32_u")
|
||||||
|
Loading…
Reference in New Issue
Block a user