Index: src/compiler/instruction-selector-impl.h |
diff --git a/src/compiler/instruction-selector-impl.h b/src/compiler/instruction-selector-impl.h |
index f8e9857357c8dde081d05b0ed6e5d2d0abad3eca..0eb3fbe6d0bc181125d8ebe9ca0b8c0b0bd35b8d 100644 |
--- a/src/compiler/instruction-selector-impl.h |
+++ b/src/compiler/instruction-selector-impl.h |
@@ -21,126 +21,129 @@ class OperandGenerator { |
explicit OperandGenerator(InstructionSelector* selector) |
: selector_(selector) {} |
- InstructionOperand* DefineAsRegister(Node* node) { |
+ InstructionOperand NoOutput() { |
+ return InstructionOperand(); // Generates an invalid operand. |
+ } |
+ |
+ InstructionOperand DefineAsRegister(Node* node) { |
return Define(node, |
- new (zone()) UnallocatedOperand( |
- UnallocatedOperand::MUST_HAVE_REGISTER, GetVReg(node))); |
+ UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, |
+ GetVReg(node))); |
} |
- InstructionOperand* DefineSameAsFirst(Node* node) { |
+ InstructionOperand DefineSameAsFirst(Node* node) { |
return Define(node, |
- new (zone()) UnallocatedOperand( |
- UnallocatedOperand::SAME_AS_FIRST_INPUT, GetVReg(node))); |
+ UnallocatedOperand(UnallocatedOperand::SAME_AS_FIRST_INPUT, |
+ GetVReg(node))); |
} |
- InstructionOperand* DefineAsFixed(Node* node, Register reg) { |
- return Define(node, new (zone()) UnallocatedOperand( |
- UnallocatedOperand::FIXED_REGISTER, |
- Register::ToAllocationIndex(reg), GetVReg(node))); |
+ InstructionOperand DefineAsFixed(Node* node, Register reg) { |
+ return Define(node, UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER, |
+ Register::ToAllocationIndex(reg), |
+ GetVReg(node))); |
} |
- InstructionOperand* DefineAsFixed(Node* node, DoubleRegister reg) { |
+ InstructionOperand DefineAsFixed(Node* node, DoubleRegister reg) { |
return Define(node, |
- new (zone()) UnallocatedOperand( |
- UnallocatedOperand::FIXED_DOUBLE_REGISTER, |
- DoubleRegister::ToAllocationIndex(reg), GetVReg(node))); |
+ UnallocatedOperand(UnallocatedOperand::FIXED_DOUBLE_REGISTER, |
+ DoubleRegister::ToAllocationIndex(reg), |
+ GetVReg(node))); |
} |
- InstructionOperand* DefineAsConstant(Node* node) { |
+ InstructionOperand DefineAsConstant(Node* node) { |
selector()->MarkAsDefined(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) { |
+ 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, GetVReg(node))); |
+ 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, GetVReg(node))); |
+ 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, |
- GetVReg(node))); |
+ 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, GetVReg(node))); |
+ 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), GetVReg(node))); |
+ InstructionOperand UseFixed(Node* node, Register reg) { |
+ return Use(node, UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER, |
+ Register::ToAllocationIndex(reg), |
+ GetVReg(node))); |
} |
- InstructionOperand* UseFixed(Node* node, DoubleRegister reg) { |
+ InstructionOperand UseFixed(Node* node, DoubleRegister reg) { |
return Use(node, |
- new (zone()) UnallocatedOperand( |
- UnallocatedOperand::FIXED_DOUBLE_REGISTER, |
- DoubleRegister::ToAllocationIndex(reg), GetVReg(node))); |
+ UnallocatedOperand(UnallocatedOperand::FIXED_DOUBLE_REGISTER, |
+ 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) { |
+ InstructionOperand UseLocation(Node* node, LinkageLocation location, |
+ MachineType type) { |
return Use(node, ToUnallocatedOperand(location, type, GetVReg(node))); |
} |
- InstructionOperand* TempRegister() { |
- return new (zone()) UnallocatedOperand( |
- UnallocatedOperand::MUST_HAVE_REGISTER, |
- UnallocatedOperand::USED_AT_START, sequence()->NextVirtualRegister()); |
+ InstructionOperand TempRegister() { |
+ return UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, |
+ UnallocatedOperand::USED_AT_START, |
+ sequence()->NextVirtualRegister()); |
} |
- InstructionOperand* TempDoubleRegister() { |
- UnallocatedOperand* op = new (zone()) UnallocatedOperand( |
+ InstructionOperand TempDoubleRegister() { |
+ UnallocatedOperand op = UnallocatedOperand( |
UnallocatedOperand::MUST_HAVE_REGISTER, |
UnallocatedOperand::USED_AT_START, sequence()->NextVirtualRegister()); |
- sequence()->MarkAsDouble(op->virtual_register()); |
+ sequence()->MarkAsDouble(op.virtual_register()); |
return op; |
} |
- InstructionOperand* TempRegister(Register reg) { |
- return new (zone()) UnallocatedOperand( |
- UnallocatedOperand::FIXED_REGISTER, Register::ToAllocationIndex(reg), |
- UnallocatedOperand::kInvalidVirtualRegister); |
+ InstructionOperand TempRegister(Register reg) { |
+ return UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER, |
+ Register::ToAllocationIndex(reg), |
+ UnallocatedOperand::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) { |
+ 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: |
@@ -173,51 +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); |
- DCHECK_EQ(operand->virtual_register(), GetVReg(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); |
- DCHECK_EQ(operand->virtual_register(), GetVReg(node)); |
+ DCHECK_EQ(operand.virtual_register(), GetVReg(node)); |
selector()->MarkAsUsed(node); |
return operand; |
} |
- UnallocatedOperand* ToUnallocatedOperand(LinkageLocation location, |
- MachineType type, |
- int virtual_register) { |
+ UnallocatedOperand ToUnallocatedOperand(LinkageLocation location, |
+ MachineType type, |
+ int virtual_register) { |
if (location.location_ == LinkageLocation::ANY_REGISTER) { |
// any machine register. |
- return new (zone()) UnallocatedOperand( |
- UnallocatedOperand::MUST_HAVE_REGISTER, virtual_register); |
+ return UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, |
+ virtual_register); |
} |
if (location.location_ < 0) { |
// a location on the caller frame. |
- return new (zone()) UnallocatedOperand( |
- UnallocatedOperand::FIXED_SLOT, location.location_, virtual_register); |
+ return UnallocatedOperand(UnallocatedOperand::FIXED_SLOT, |
+ location.location_, virtual_register); |
} |
if (location.location_ > LinkageLocation::ANY_REGISTER) { |
// a spill location on this (callee) frame. |
- return new (zone()) UnallocatedOperand( |
+ 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_, virtual_register); |
+ return UnallocatedOperand(UnallocatedOperand::FIXED_DOUBLE_REGISTER, |
+ location.location_, virtual_register); |
} |
- return new (zone()) |
- UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER, |
- location.location_, virtual_register); |
+ return UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER, |
+ location.location_, virtual_register); |
} |
InstructionSelector* selector_; |