mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 01:35:35 +00:00
Bug 1627618 - Part 14: Add MUrsh::NewWasm for MUrsh users in wasm code. r=jandem
Similar to `MAdd::NewWasm` and `MSub::NewWasm` from earlier patches, add a separate `MUrsh::NewWasm` function to handle wasm-specific initialisation for `MUrsh`. That frees up the `MUrsh(MDefinition, MDefinition, MIRType)` constructor to only set the specialisation without performing any wasm-specific actions. Differential Revision: https://phabricator.services.mozilla.com/D69794 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
e9cbe2bedf
commit
5a1fd8e7e4
@ -3664,6 +3664,13 @@ MUrsh* MUrsh::New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
|
||||
MIRType type) {
|
||||
MUrsh* ins = new (alloc) MUrsh(left, right, type);
|
||||
ins->specializeAs(type);
|
||||
return ins;
|
||||
}
|
||||
|
||||
MUrsh* MUrsh::NewWasm(TempAllocator& alloc, MDefinition* left,
|
||||
MDefinition* right, MIRType type) {
|
||||
MUrsh* ins = new (alloc) MUrsh(left, right, type);
|
||||
ins->specializeAs(type);
|
||||
|
||||
// Since Ion has no UInt32 type, we use Int32 and we have a special
|
||||
// exception to the type rules: we can return values in
|
||||
|
@ -4665,6 +4665,8 @@ class MUrsh : public MShiftInstruction {
|
||||
MDefinition* right);
|
||||
static MUrsh* New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
|
||||
MIRType type);
|
||||
static MUrsh* NewWasm(TempAllocator& alloc, MDefinition* left,
|
||||
MDefinition* right, MIRType type);
|
||||
|
||||
MDefinition* foldIfZero(size_t operand) override {
|
||||
// 0 >>> x => 0
|
||||
|
@ -340,6 +340,15 @@ class FunctionCompiler {
|
||||
return ins;
|
||||
}
|
||||
|
||||
MDefinition* ursh(MDefinition* lhs, MDefinition* rhs, MIRType type) {
|
||||
if (inDeadCode()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto* ins = MUrsh::NewWasm(alloc(), lhs, rhs, type);
|
||||
curBlock_->add(ins);
|
||||
return ins;
|
||||
}
|
||||
|
||||
MDefinition* add(MDefinition* lhs, MDefinition* rhs, MIRType type) {
|
||||
if (inDeadCode()) {
|
||||
return nullptr;
|
||||
@ -2582,6 +2591,18 @@ static bool EmitBitwise(FunctionCompiler& f, ValType operandType,
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool EmitUrsh(FunctionCompiler& f, ValType operandType,
|
||||
MIRType mirType) {
|
||||
MDefinition* lhs;
|
||||
MDefinition* rhs;
|
||||
if (!f.iter().readBinary(operandType, &lhs, &rhs)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
f.iter().setResult(f.ursh(lhs, rhs, mirType));
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool EmitMul(FunctionCompiler& f, ValType operandType, MIRType mirType) {
|
||||
MDefinition* lhs;
|
||||
MDefinition* rhs;
|
||||
@ -4128,7 +4149,7 @@ static bool EmitBodyExprs(FunctionCompiler& f) {
|
||||
case uint16_t(Op::I32ShrS):
|
||||
CHECK(EmitBitwise<MRsh>(f, ValType::I32, MIRType::Int32));
|
||||
case uint16_t(Op::I32ShrU):
|
||||
CHECK(EmitBitwise<MUrsh>(f, ValType::I32, MIRType::Int32));
|
||||
CHECK(EmitUrsh(f, ValType::I32, MIRType::Int32));
|
||||
case uint16_t(Op::I32Rotl):
|
||||
case uint16_t(Op::I32Rotr):
|
||||
CHECK(EmitRotate(f, ValType::I32, Op(op.b0) == Op::I32Rotl));
|
||||
@ -4163,7 +4184,7 @@ static bool EmitBodyExprs(FunctionCompiler& f) {
|
||||
case uint16_t(Op::I64ShrS):
|
||||
CHECK(EmitBitwise<MRsh>(f, ValType::I64, MIRType::Int64));
|
||||
case uint16_t(Op::I64ShrU):
|
||||
CHECK(EmitBitwise<MUrsh>(f, ValType::I64, MIRType::Int64));
|
||||
CHECK(EmitUrsh(f, ValType::I64, MIRType::Int64));
|
||||
case uint16_t(Op::I64Rotl):
|
||||
case uint16_t(Op::I64Rotr):
|
||||
CHECK(EmitRotate(f, ValType::I64, Op(op.b0) == Op::I64Rotl));
|
||||
|
Loading…
Reference in New Issue
Block a user