Commit 01269228 authored by titzer's avatar titzer Committed by Commit bot

[turbofan] Add RegisterAllocator::NewLiveRange() utility method.

R=dcarney@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1036433002

Cr-Commit-Position: refs/heads/master@{#27405}
parent 00844d46
...@@ -736,15 +736,19 @@ InstructionOperand* RegisterAllocator::AllocateFixed( ...@@ -736,15 +736,19 @@ InstructionOperand* RegisterAllocator::AllocateFixed(
} }
LiveRange* RegisterAllocator::NewLiveRange(int index) {
// The LiveRange object itself can go in the local zone, but the
// InstructionOperand needs to go in the code zone, since it may survive
// register allocation.
return new (local_zone()) LiveRange(index, code_zone());
}
LiveRange* RegisterAllocator::FixedLiveRangeFor(int index) { LiveRange* RegisterAllocator::FixedLiveRangeFor(int index) {
DCHECK(index < config()->num_general_registers()); DCHECK(index < config()->num_general_registers());
auto result = fixed_live_ranges()[index]; auto result = fixed_live_ranges()[index];
if (result == nullptr) { if (result == nullptr) {
// TODO(titzer): add a utility method to allocate a new LiveRange: result = NewLiveRange(FixedLiveRangeID(index));
// The LiveRange object itself can go in this zone, but the
// InstructionOperand needs
// to go in the code zone, since it may survive register allocation.
result = new (local_zone()) LiveRange(FixedLiveRangeID(index), code_zone());
DCHECK(result->IsFixed()); DCHECK(result->IsFixed());
result->kind_ = GENERAL_REGISTERS; result->kind_ = GENERAL_REGISTERS;
SetLiveRangeAssignedRegister(result, index); SetLiveRangeAssignedRegister(result, index);
...@@ -758,8 +762,7 @@ LiveRange* RegisterAllocator::FixedDoubleLiveRangeFor(int index) { ...@@ -758,8 +762,7 @@ LiveRange* RegisterAllocator::FixedDoubleLiveRangeFor(int index) {
DCHECK(index < config()->num_aliased_double_registers()); DCHECK(index < config()->num_aliased_double_registers());
auto result = fixed_double_live_ranges()[index]; auto result = fixed_double_live_ranges()[index];
if (result == nullptr) { if (result == nullptr) {
result = new (local_zone()) result = NewLiveRange(FixedDoubleLiveRangeID(index));
LiveRange(FixedDoubleLiveRangeID(index), code_zone());
DCHECK(result->IsFixed()); DCHECK(result->IsFixed());
result->kind_ = DOUBLE_REGISTERS; result->kind_ = DOUBLE_REGISTERS;
SetLiveRangeAssignedRegister(result, index); SetLiveRangeAssignedRegister(result, index);
...@@ -775,7 +778,7 @@ LiveRange* RegisterAllocator::LiveRangeFor(int index) { ...@@ -775,7 +778,7 @@ LiveRange* RegisterAllocator::LiveRangeFor(int index) {
} }
auto result = live_ranges()[index]; auto result = live_ranges()[index];
if (result == nullptr) { if (result == nullptr) {
result = new (local_zone()) LiveRange(index, code_zone()); result = NewLiveRange(index);
live_ranges()[index] = result; live_ranges()[index] = result;
} }
return result; return result;
......
...@@ -470,6 +470,9 @@ class RegisterAllocator FINAL : public ZoneObject { ...@@ -470,6 +470,9 @@ class RegisterAllocator FINAL : public ZoneObject {
// Returns the register kind required by the given virtual register. // Returns the register kind required by the given virtual register.
RegisterKind RequiredRegisterKind(int virtual_register) const; RegisterKind RequiredRegisterKind(int virtual_register) const;
// Creates a new live range.
LiveRange* NewLiveRange(int index);
// This zone is for InstructionOperands and moves that live beyond register // This zone is for InstructionOperands and moves that live beyond register
// allocation. // allocation.
Zone* code_zone() const { return code()->zone(); } Zone* code_zone() const { return code()->zone(); }
......
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