summaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler/instruction-selector-impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/compiler/instruction-selector-impl.h')
-rw-r--r--deps/v8/src/compiler/instruction-selector-impl.h196
1 files changed, 100 insertions, 96 deletions
diff --git a/deps/v8/src/compiler/instruction-selector-impl.h b/deps/v8/src/compiler/instruction-selector-impl.h
index bdcd952b5f..90898ba947 100644
--- a/deps/v8/src/compiler/instruction-selector-impl.h
+++ b/deps/v8/src/compiler/instruction-selector-impl.h
@@ -21,132 +21,139 @@ class OperandGenerator {
explicit OperandGenerator(InstructionSelector* selector)
: selector_(selector) {}
- InstructionOperand* DefineAsRegister(Node* node) {
- return Define(node, new (zone())
- UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER));
+ InstructionOperand NoOutput() {
+ return InstructionOperand(); // Generates an invalid operand.
}
- InstructionOperand* DefineSameAsFirst(Node* result) {
- return Define(result, new (zone())
- UnallocatedOperand(UnallocatedOperand::SAME_AS_FIRST_INPUT));
+ InstructionOperand DefineAsRegister(Node* node) {
+ return Define(node,
+ UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER,
+ GetVReg(node)));
}
- InstructionOperand* DefineAsFixed(Node* node, Register reg) {
- return Define(node, new (zone())
- UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER,
- Register::ToAllocationIndex(reg)));
+ InstructionOperand DefineSameAsFirst(Node* node) {
+ return Define(node,
+ UnallocatedOperand(UnallocatedOperand::SAME_AS_FIRST_INPUT,
+ GetVReg(node)));
}
- InstructionOperand* DefineAsFixed(Node* node, DoubleRegister reg) {
- return Define(node, new (zone())
+ InstructionOperand DefineAsFixed(Node* node, Register reg) {
+ return Define(node, UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER,
+ Register::ToAllocationIndex(reg),
+ GetVReg(node)));
+ }
+
+ InstructionOperand DefineAsFixed(Node* node, DoubleRegister reg) {
+ return Define(node,
UnallocatedOperand(UnallocatedOperand::FIXED_DOUBLE_REGISTER,
- DoubleRegister::ToAllocationIndex(reg)));
+ DoubleRegister::ToAllocationIndex(reg),
+ GetVReg(node)));
}
- InstructionOperand* DefineAsConstant(Node* node) {
+ InstructionOperand DefineAsConstant(Node* node) {
selector()->MarkAsDefined(node);
- int virtual_register = selector_->GetVirtualRegister(node);
+ int virtual_register = GetVReg(node);
sequence()->AddConstant(virtual_register, ToConstant(node));
- return ConstantOperand::Create(virtual_register, zone());
+ return ConstantOperand(virtual_register);
}
- InstructionOperand* DefineAsLocation(Node* node, LinkageLocation location,
- MachineType type) {
- return Define(node, ToUnallocatedOperand(location, type));
+ InstructionOperand DefineAsLocation(Node* node, LinkageLocation location,
+ MachineType type) {
+ return Define(node, ToUnallocatedOperand(location, type, GetVReg(node)));
}
- InstructionOperand* Use(Node* node) {
- return Use(
- node, new (zone()) UnallocatedOperand(
- UnallocatedOperand::NONE, UnallocatedOperand::USED_AT_START));
+ InstructionOperand Use(Node* node) {
+ return Use(node, UnallocatedOperand(UnallocatedOperand::NONE,
+ UnallocatedOperand::USED_AT_START,
+ GetVReg(node)));
}
- InstructionOperand* UseRegister(Node* node) {
- return Use(node, new (zone())
- UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER,
- UnallocatedOperand::USED_AT_START));
+ InstructionOperand UseRegister(Node* node) {
+ return Use(node, UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER,
+ UnallocatedOperand::USED_AT_START,
+ GetVReg(node)));
}
// Use register or operand for the node. If a register is chosen, it won't
// alias any temporary or output registers.
- InstructionOperand* UseUnique(Node* node) {
- return Use(node, new (zone()) UnallocatedOperand(UnallocatedOperand::NONE));
+ InstructionOperand UseUnique(Node* node) {
+ return Use(node,
+ UnallocatedOperand(UnallocatedOperand::NONE, GetVReg(node)));
}
// Use a unique register for the node that does not alias any temporary or
// output registers.
- InstructionOperand* UseUniqueRegister(Node* node) {
- return Use(node, new (zone())
- UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER));
+ InstructionOperand UseUniqueRegister(Node* node) {
+ return Use(node, UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER,
+ GetVReg(node)));
}
- InstructionOperand* UseFixed(Node* node, Register reg) {
- return Use(node, new (zone())
- UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER,
- Register::ToAllocationIndex(reg)));
+ InstructionOperand UseFixed(Node* node, Register reg) {
+ return Use(node, UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER,
+ Register::ToAllocationIndex(reg),
+ GetVReg(node)));
}
- InstructionOperand* UseFixed(Node* node, DoubleRegister reg) {
- return Use(node, new (zone())
+ InstructionOperand UseFixed(Node* node, DoubleRegister reg) {
+ return Use(node,
UnallocatedOperand(UnallocatedOperand::FIXED_DOUBLE_REGISTER,
- DoubleRegister::ToAllocationIndex(reg)));
+ DoubleRegister::ToAllocationIndex(reg),
+ GetVReg(node)));
}
- InstructionOperand* UseImmediate(Node* node) {
+ InstructionOperand UseImmediate(Node* node) {
int index = sequence()->AddImmediate(ToConstant(node));
- return ImmediateOperand::Create(index, zone());
+ return ImmediateOperand(index);
}
- InstructionOperand* UseLocation(Node* node, LinkageLocation location,
- MachineType type) {
- return Use(node, ToUnallocatedOperand(location, type));
+ InstructionOperand UseLocation(Node* node, LinkageLocation location,
+ MachineType type) {
+ return Use(node, ToUnallocatedOperand(location, type, GetVReg(node)));
}
- InstructionOperand* TempRegister() {
- UnallocatedOperand* op =
- new (zone()) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER,
- UnallocatedOperand::USED_AT_START);
- op->set_virtual_register(sequence()->NextVirtualRegister());
- return op;
+ InstructionOperand TempRegister() {
+ return UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER,
+ UnallocatedOperand::USED_AT_START,
+ sequence()->NextVirtualRegister());
}
- InstructionOperand* TempDoubleRegister() {
- UnallocatedOperand* op =
- new (zone()) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER,
- UnallocatedOperand::USED_AT_START);
- op->set_virtual_register(sequence()->NextVirtualRegister());
- sequence()->MarkAsDouble(op->virtual_register());
+ InstructionOperand TempDoubleRegister() {
+ UnallocatedOperand op = UnallocatedOperand(
+ UnallocatedOperand::MUST_HAVE_REGISTER,
+ UnallocatedOperand::USED_AT_START, sequence()->NextVirtualRegister());
+ sequence()->MarkAsDouble(op.virtual_register());
return op;
}
- InstructionOperand* TempRegister(Register reg) {
- return new (zone()) UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER,
- Register::ToAllocationIndex(reg));
+ InstructionOperand TempRegister(Register reg) {
+ return UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER,
+ Register::ToAllocationIndex(reg),
+ InstructionOperand::kInvalidVirtualRegister);
}
- InstructionOperand* TempImmediate(int32_t imm) {
+ InstructionOperand TempImmediate(int32_t imm) {
int index = sequence()->AddImmediate(Constant(imm));
- return ImmediateOperand::Create(index, zone());
+ return ImmediateOperand(index);
}
- InstructionOperand* TempLocation(LinkageLocation location, MachineType type) {
- UnallocatedOperand* op = ToUnallocatedOperand(location, type);
- op->set_virtual_register(sequence()->NextVirtualRegister());
- return op;
+ InstructionOperand TempLocation(LinkageLocation location, MachineType type) {
+ return ToUnallocatedOperand(location, type,
+ sequence()->NextVirtualRegister());
}
- InstructionOperand* Label(BasicBlock* block) {
+ InstructionOperand Label(BasicBlock* block) {
int index = sequence()->AddImmediate(Constant(block->GetRpoNumber()));
- return ImmediateOperand::Create(index, zone());
+ return ImmediateOperand(index);
}
protected:
InstructionSelector* selector() const { return selector_; }
InstructionSequence* sequence() const { return selector()->sequence(); }
- Isolate* isolate() const { return zone()->isolate(); }
Zone* zone() const { return selector()->instruction_zone(); }
private:
+ int GetVReg(Node* node) const { return selector_->GetVirtualRegister(node); }
+
static Constant ToConstant(const Node* node) {
switch (node->opcode()) {
case IrOpcode::kInt32Constant:
@@ -169,38 +176,47 @@ class OperandGenerator {
return Constant(static_cast<int32_t>(0));
}
- UnallocatedOperand* Define(Node* node, UnallocatedOperand* operand) {
+ UnallocatedOperand Define(Node* node, UnallocatedOperand operand) {
DCHECK_NOT_NULL(node);
- DCHECK_NOT_NULL(operand);
- operand->set_virtual_register(selector_->GetVirtualRegister(node));
+ DCHECK_EQ(operand.virtual_register(), GetVReg(node));
selector()->MarkAsDefined(node);
return operand;
}
- UnallocatedOperand* Use(Node* node, UnallocatedOperand* operand) {
+ UnallocatedOperand Use(Node* node, UnallocatedOperand operand) {
DCHECK_NOT_NULL(node);
- DCHECK_NOT_NULL(operand);
- operand->set_virtual_register(selector_->GetVirtualRegister(node));
+ DCHECK_EQ(operand.virtual_register(), GetVReg(node));
selector()->MarkAsUsed(node);
return operand;
}
- UnallocatedOperand* ToUnallocatedOperand(LinkageLocation location,
- MachineType type) {
+ UnallocatedOperand ToUnallocatedOperand(LinkageLocation location,
+ MachineType type,
+ int virtual_register) {
if (location.location_ == LinkageLocation::ANY_REGISTER) {
- return new (zone())
- UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER);
+ // any machine register.
+ return UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER,
+ virtual_register);
}
if (location.location_ < 0) {
- return new (zone()) UnallocatedOperand(UnallocatedOperand::FIXED_SLOT,
- location.location_);
+ // a location on the caller frame.
+ return UnallocatedOperand(UnallocatedOperand::FIXED_SLOT,
+ location.location_, virtual_register);
}
+ if (location.location_ > LinkageLocation::ANY_REGISTER) {
+ // a spill location on this (callee) frame.
+ return UnallocatedOperand(
+ UnallocatedOperand::FIXED_SLOT,
+ location.location_ - LinkageLocation::ANY_REGISTER - 1,
+ virtual_register);
+ }
+ // a fixed register.
if (RepresentationOf(type) == kRepFloat64) {
- return new (zone()) UnallocatedOperand(
- UnallocatedOperand::FIXED_DOUBLE_REGISTER, location.location_);
+ return UnallocatedOperand(UnallocatedOperand::FIXED_DOUBLE_REGISTER,
+ location.location_, virtual_register);
}
- return new (zone()) UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER,
- location.location_);
+ return UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER,
+ location.location_, virtual_register);
}
InstructionSelector* selector_;
@@ -294,18 +310,6 @@ class FlagsContinuation FINAL {
case kUnorderedEqual:
case kUnorderedNotEqual:
return;
- case kUnorderedLessThan:
- condition_ = kUnorderedGreaterThan;
- return;
- case kUnorderedGreaterThanOrEqual:
- condition_ = kUnorderedLessThanOrEqual;
- return;
- case kUnorderedLessThanOrEqual:
- condition_ = kUnorderedGreaterThanOrEqual;
- return;
- case kUnorderedGreaterThan:
- condition_ = kUnorderedLessThan;
- return;
}
UNREACHABLE();
}