Bug 1627618 - Part 16: Remove MBinaryBitwiseInstruction::specializeAs. r=jandem

Remove `MBinaryBitwiseInstruction::specializeAs()` and instead directly set the
specialisation in the `MBinaryBitwiseInstruction` constructor.

For BitAnd, BitOr, and BitXor also set the "commutative" flag in the constructor.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
André Bargull 2020-04-07 08:41:22 +00:00
parent 569eef9d41
commit 3fb2ff637f
2 changed files with 20 additions and 76 deletions

View File

@ -2532,19 +2532,6 @@ MDefinition* MBinaryBitwiseInstruction::foldUnnecessaryBitop() {
return this;
}
void MBinaryBitwiseInstruction::specializeAs(MIRType type) {
MOZ_ASSERT(type == MIRType::Int32 || type == MIRType::Int64 ||
(isUrsh() && type == MIRType::Double));
MOZ_ASSERT(this->type() == MIRType::Value || this->type() == type);
specialization_ = type;
setResultType(type);
if (isBitOr() || isBitAnd() || isBitXor()) {
setCommutative();
}
}
static inline bool CanProduceNegativeZero(MDefinition* def) {
// Test if this instruction can produce negative zero even when bailing out
// and changing types.
@ -3599,52 +3586,9 @@ void MTypeOf::cacheInputMaybeCallableOrEmulatesUndefined(
}
}
MBitAnd* MBitAnd::New(TempAllocator& alloc, MDefinition* left,
MDefinition* right, MIRType type) {
MBitAnd* ins = new (alloc) MBitAnd(left, right, type);
ins->specializeAs(type);
return ins;
}
MBitOr* MBitOr::New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
MIRType type) {
MBitOr* ins = new (alloc) MBitOr(left, right, type);
ins->specializeAs(type);
return ins;
}
MBitXor* MBitXor::New(TempAllocator& alloc, MDefinition* left,
MDefinition* right, MIRType type) {
MBitXor* ins = new (alloc) MBitXor(left, right, type);
ins->specializeAs(type);
return ins;
}
MLsh* MLsh::New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
MIRType type) {
MLsh* ins = new (alloc) MLsh(left, right, type);
ins->specializeAs(type);
return ins;
}
MRsh* MRsh::New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
MIRType type) {
MRsh* ins = new (alloc) MRsh(left, right, type);
ins->specializeAs(type);
return ins;
}
MUrsh* MUrsh::New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
MIRType type) {
MUrsh* ins = new (alloc) MUrsh(left, right, MIRType::Int32);
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

View File

@ -4455,12 +4455,13 @@ class MBinaryBitwiseInstruction : public MBinaryInstruction,
: MBinaryInstruction(op, left, right),
maskMatchesLeftRange(false),
maskMatchesRightRange(false) {
MOZ_ASSERT(type == MIRType::Int32 || type == MIRType::Int64);
setResultType(MIRType::Value);
MOZ_ASSERT(type == MIRType::Int32 || type == MIRType::Int64 ||
(isUrsh() && type == MIRType::Double));
specialization_ = type;
setResultType(type);
setMovable();
}
void specializeAs(MIRType type);
bool maskMatchesLeftRange;
bool maskMatchesRightRange;
@ -4493,12 +4494,13 @@ class MBinaryBitwiseInstruction : public MBinaryInstruction,
class MBitAnd : public MBinaryBitwiseInstruction {
MBitAnd(MDefinition* left, MDefinition* right, MIRType type)
: MBinaryBitwiseInstruction(classOpcode, left, right, type) {}
: MBinaryBitwiseInstruction(classOpcode, left, right, type) {
setCommutative();
}
public:
INSTRUCTION_HEADER(BitAnd)
static MBitAnd* New(TempAllocator& alloc, MDefinition* left,
MDefinition* right, MIRType type);
TRIVIAL_NEW_WRAPPERS
MDefinition* foldIfZero(size_t operand) override {
return getOperand(operand); // 0 & x => 0;
@ -4526,12 +4528,13 @@ class MBitAnd : public MBinaryBitwiseInstruction {
class MBitOr : public MBinaryBitwiseInstruction {
MBitOr(MDefinition* left, MDefinition* right, MIRType type)
: MBinaryBitwiseInstruction(classOpcode, left, right, type) {}
: MBinaryBitwiseInstruction(classOpcode, left, right, type) {
setCommutative();
}
public:
INSTRUCTION_HEADER(BitOr)
static MBitOr* New(TempAllocator& alloc, MDefinition* left,
MDefinition* right, MIRType type);
TRIVIAL_NEW_WRAPPERS
MDefinition* foldIfZero(size_t operand) override {
return getOperand(1 -
@ -4556,12 +4559,13 @@ class MBitOr : public MBinaryBitwiseInstruction {
class MBitXor : public MBinaryBitwiseInstruction {
MBitXor(MDefinition* left, MDefinition* right, MIRType type)
: MBinaryBitwiseInstruction(classOpcode, left, right, type) {}
: MBinaryBitwiseInstruction(classOpcode, left, right, type) {
setCommutative();
}
public:
INSTRUCTION_HEADER(BitXor)
static MBitXor* New(TempAllocator& alloc, MDefinition* left,
MDefinition* right, MIRType type);
TRIVIAL_NEW_WRAPPERS
MDefinition* foldIfZero(size_t operand) override {
return getOperand(1 - operand); // 0 ^ x => x
@ -4598,8 +4602,7 @@ class MLsh : public MShiftInstruction {
public:
INSTRUCTION_HEADER(Lsh)
static MLsh* New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
MIRType type);
TRIVIAL_NEW_WRAPPERS
MDefinition* foldIfZero(size_t operand) override {
// 0 << x => 0
@ -4623,8 +4626,7 @@ class MRsh : public MShiftInstruction {
public:
INSTRUCTION_HEADER(Rsh)
static MRsh* New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
MIRType type);
TRIVIAL_NEW_WRAPPERS
MDefinition* foldIfZero(size_t operand) override {
// 0 >> x => 0
@ -4653,10 +4655,8 @@ class MUrsh : public MShiftInstruction {
public:
INSTRUCTION_HEADER(Ursh)
static MUrsh* New(TempAllocator& alloc, MDefinition* left,
MDefinition* right);
static MUrsh* New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
MIRType type);
TRIVIAL_NEW_WRAPPERS
static MUrsh* NewWasm(TempAllocator& alloc, MDefinition* left,
MDefinition* right, MIRType type);