Bug 1627618 - Part 3: Add MSub::NewWasm for MSub users in wasm code. r=jandem

Similar to the previous part, add `MSub::NewWasm` to handle the wasm-specific
initialisation bits, so that `MSub(MDefinition, MDefinition, MIRType)` only
sets the return type and the specialisation.

Differential Revision: https://phabricator.services.mozilla.com/D69780

--HG--
extra : moz-landing-system : lando
This commit is contained in:
André Bargull 2020-04-07 08:35:32 +00:00
parent 3a85148fe9
commit 530df1cf02
2 changed files with 12 additions and 7 deletions

View File

@ -5407,21 +5407,26 @@ class MSub : public MBinaryArithInstruction {
setResultType(MIRType::Value);
}
MSub(MDefinition* left, MDefinition* right, MIRType type,
bool mustPreserveNaN = false)
MSub(MDefinition* left, MDefinition* right, MIRType type)
: MSub(left, right) {
specialization_ = type;
setResultType(type);
setMustPreserveNaN(mustPreserveNaN);
if (type == MIRType::Int32) {
setTruncateKind(Truncate);
}
}
public:
INSTRUCTION_HEADER(Sub)
TRIVIAL_NEW_WRAPPERS
static MSub* NewWasm(TempAllocator& alloc, MDefinition* left,
MDefinition* right, MIRType type, bool mustPreserveNaN) {
auto* ret = new (alloc) MSub(left, right, type);
ret->setMustPreserveNaN(mustPreserveNaN);
if (type == MIRType::Int32) {
ret->setTruncateKind(Truncate);
}
return ret;
}
double getIdentity() override { return 0; }
bool isFloat32Commutative() const override { return true; }

View File

@ -359,7 +359,7 @@ class FunctionCompiler {
}
// wasm can't fold x - 0.0 because of NaN with custom payloads.
MSub* ins = MSub::New(alloc(), lhs, rhs, type, mustPreserveNaN(type));
MSub* ins = MSub::NewWasm(alloc(), lhs, rhs, type, mustPreserveNaN(type));
curBlock_->add(ins);
return ins;
}