Commit 5dde8b31 authored by bbudge's avatar bbudge Committed by Commit bot

[Turbofan] Remove UnallocatedOperand::set_virtual_register.

- Removes set_virtual_register method. InstructionOperands are immutable.
- Adds a new ctor to copy an UnallocatedOperand with a new vreg.
- Removes some DCHECKs in UnallocatedOperand that are always true. To
  make sure, make UnallocatedOperand final.
- Cleans up some comments on UnallocatedOperand Lifetime enum.

BUG=v8:6325

Review-Url: https://codereview.chromium.org/2897203002
Cr-Commit-Position: refs/heads/master@{#45533}
parent 0c6c3974
......@@ -302,10 +302,11 @@ int InstructionSelector::GetRename(int virtual_register) {
void InstructionSelector::TryRename(InstructionOperand* op) {
if (!op->IsUnallocated()) return;
int vreg = UnallocatedOperand::cast(op)->virtual_register();
UnallocatedOperand* unalloc = UnallocatedOperand::cast(op);
int vreg = unalloc->virtual_register();
int rename = GetRename(vreg);
if (rename != vreg) {
UnallocatedOperand::cast(op)->set_virtual_register(rename);
*unalloc = UnallocatedOperand(*unalloc, rename);
}
}
......
......@@ -167,7 +167,7 @@ std::ostream& operator<<(std::ostream& os,
return *static_cast<const OperandType*>(&op); \
}
class UnallocatedOperand : public InstructionOperand {
class UnallocatedOperand final : public InstructionOperand {
public:
enum BasicPolicy { FIXED_SLOT, EXTENDED_POLICY };
......@@ -183,15 +183,14 @@ class UnallocatedOperand : public InstructionOperand {
// Lifetime of operand inside the instruction.
enum Lifetime {
// USED_AT_START operand is guaranteed to be live only at
// instruction start. Register allocator is free to assign the same register
// to some other operand used inside instruction (i.e. temporary or
// output).
// USED_AT_START operand is guaranteed to be live only at instruction start.
// The register allocator is free to assign the same register to some other
// operand used inside instruction (i.e. temporary or output).
USED_AT_START,
// USED_AT_END operand is treated as live until the end of
// instruction. This means that register allocator will not reuse it's
// register for any other operand inside instruction.
// USED_AT_END operand is treated as live until the end of instruction.
// This means that register allocator will not reuse its register for any
// other operand inside instruction.
USED_AT_END
};
......@@ -233,6 +232,12 @@ class UnallocatedOperand : public InstructionOperand {
value_ |= SecondaryStorageField::encode(slot_id);
}
UnallocatedOperand(const UnallocatedOperand& other, int virtual_register) {
DCHECK_NE(kInvalidVirtualRegister, virtual_register);
value_ = VirtualRegisterField::update(
other.value_, static_cast<uint32_t>(virtual_register));
}
// Predicates for the operand policy.
bool HasAnyPolicy() const {
return basic_policy() == EXTENDED_POLICY && extended_policy() == ANY;
......@@ -275,7 +280,6 @@ class UnallocatedOperand : public InstructionOperand {
// [basic_policy]: Distinguish between FIXED_SLOT and all other policies.
BasicPolicy basic_policy() const {
DCHECK_EQ(UNALLOCATED, kind());
return BasicPolicyField::decode(value_);
}
......@@ -300,16 +304,9 @@ class UnallocatedOperand : public InstructionOperand {
// [virtual_register]: The virtual register ID for this operand.
int32_t virtual_register() const {
DCHECK_EQ(UNALLOCATED, kind());
return static_cast<int32_t>(VirtualRegisterField::decode(value_));
}
// TODO(dcarney): remove this.
void set_virtual_register(int32_t id) {
DCHECK_EQ(UNALLOCATED, kind());
value_ = VirtualRegisterField::update(value_, static_cast<uint32_t>(id));
}
// [lifetime]: Only for non-FIXED_SLOT.
bool IsUsedAtStart() const {
DCHECK(basic_policy() == EXTENDED_POLICY);
......
......@@ -1777,7 +1777,8 @@ void ConstraintBuilder::MeetConstraintsBefore(int instr_index) {
int output_vreg = second_output->virtual_register();
int input_vreg = cur_input->virtual_register();
UnallocatedOperand input_copy(UnallocatedOperand::ANY, input_vreg);
cur_input->set_virtual_register(second_output->virtual_register());
*cur_input =
UnallocatedOperand(*cur_input, second_output->virtual_register());
MoveOperands* gap_move = data()->AddGapMove(instr_index, Instruction::END,
input_copy, *cur_input);
if (code()->IsReference(input_vreg) && !code()->IsReference(output_vreg)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment