Chromium Code Reviews| Index: src/compiler/register-allocator.cc |
| diff --git a/src/compiler/register-allocator.cc b/src/compiler/register-allocator.cc |
| index 38e4a96b3b52c810bf87c1f5d80396d9e8a01cba..5e9631844ab52f618354f25ae60880dea858272c 100644 |
| --- a/src/compiler/register-allocator.cc |
| +++ b/src/compiler/register-allocator.cc |
| @@ -33,7 +33,7 @@ int GetRegisterCount(const RegisterConfiguration* cfg, RegisterKind kind) { |
| int GetAllocatableRegisterCount(const RegisterConfiguration* cfg, |
| RegisterKind kind) { |
| - return kind == FP_REGISTERS ? cfg->num_allocatable_double_registers() |
| + return kind == FP_REGISTERS ? cfg->num_allocatable_aliased_double_registers() |
| : cfg->num_allocatable_general_registers(); |
| } |
| @@ -72,8 +72,14 @@ int GetByteWidth(MachineRepresentation rep) { |
| case MachineRepresentation::kWord16: |
| case MachineRepresentation::kWord32: |
| case MachineRepresentation::kTagged: |
| + return kPointerSize; |
| case MachineRepresentation::kFloat32: |
| +// TODO(bbudge) Eliminate this when FP register aliasing works. |
| +#if V8_TARGET_ARCH_ARM |
| + return 8; |
|
Mircea Trofin
2016/07/27 23:29:31
isn't there a constant we could use instead of "8"
bbudge
2016/07/29 00:45:39
Fixed here and the rest too.
|
| +#else |
| return kPointerSize; |
| +#endif |
| case MachineRepresentation::kWord64: |
| case MachineRepresentation::kFloat64: |
| return 8; |
| @@ -1335,12 +1341,8 @@ RegisterAllocationData::RegisterAllocationData( |
| allocation_zone()), |
| fixed_live_ranges_(this->config()->num_general_registers(), nullptr, |
| allocation_zone()), |
| - fixed_float_live_ranges_(this->config()->num_float_registers(), nullptr, |
| - allocation_zone()), |
| fixed_double_live_ranges_(this->config()->num_double_registers(), nullptr, |
| allocation_zone()), |
| - fixed_simd128_live_ranges_(this->config()->num_simd128_registers(), |
| - nullptr, allocation_zone()), |
| spill_ranges_(code->VirtualRegisterCount(), nullptr, allocation_zone()), |
| delayed_references_(allocation_zone()), |
| assigned_registers_(nullptr), |
| @@ -1518,21 +1520,8 @@ void RegisterAllocationData::MarkAllocated(MachineRepresentation rep, |
| int index) { |
| switch (rep) { |
| case MachineRepresentation::kFloat32: |
| - case MachineRepresentation::kSimd128: |
| - if (kSimpleFPAliasing) { |
| - assigned_double_registers_->Add(index); |
| - } else { |
| - int alias_base_index = -1; |
| - int aliases = config()->GetAliases( |
| - rep, index, MachineRepresentation::kFloat64, &alias_base_index); |
| - DCHECK(aliases > 0 || (aliases == 0 && alias_base_index == -1)); |
| - while (aliases--) { |
| - int aliased_reg = alias_base_index + aliases; |
| - assigned_double_registers_->Add(aliased_reg); |
| - } |
| - } |
| - break; |
| case MachineRepresentation::kFloat64: |
| + case MachineRepresentation::kSimd128: |
| assigned_double_registers_->Add(index); |
| break; |
| default: |
| @@ -1859,11 +1848,7 @@ int LiveRangeBuilder::FixedFPLiveRangeID(int index, MachineRepresentation rep) { |
| int result = -index - 1; |
| switch (rep) { |
| case MachineRepresentation::kSimd128: |
| - result -= config()->num_float_registers(); |
| - // Fall through. |
| case MachineRepresentation::kFloat32: |
| - result -= config()->num_double_registers(); |
| - // Fall through. |
| case MachineRepresentation::kFloat64: |
| result -= config()->num_general_registers(); |
| break; |
| @@ -1893,18 +1878,8 @@ TopLevelLiveRange* LiveRangeBuilder::FixedFPLiveRangeFor( |
| TopLevelLiveRange* result = nullptr; |
| switch (rep) { |
| case MachineRepresentation::kFloat32: |
| - DCHECK(rep == MachineRepresentation::kFloat32); |
| - DCHECK(index < config()->num_float_registers()); |
| - result = data()->fixed_float_live_ranges()[index]; |
| - if (result == nullptr) { |
| - result = data()->NewLiveRange(FixedFPLiveRangeID(index, rep), rep); |
| - DCHECK(result->IsFixed()); |
| - result->set_assigned_register(index); |
| - data()->MarkAllocated(rep, index); |
| - data()->fixed_float_live_ranges()[index] = result; |
| - } |
| - break; |
| case MachineRepresentation::kFloat64: |
| + case MachineRepresentation::kSimd128: |
| DCHECK(index < config()->num_double_registers()); |
| result = data()->fixed_double_live_ranges()[index]; |
| if (result == nullptr) { |
| @@ -1915,17 +1890,6 @@ TopLevelLiveRange* LiveRangeBuilder::FixedFPLiveRangeFor( |
| data()->fixed_double_live_ranges()[index] = result; |
| } |
| break; |
| - case MachineRepresentation::kSimd128: |
| - DCHECK(index < config()->num_simd128_registers()); |
| - result = data()->fixed_simd128_live_ranges()[index]; |
| - if (result == nullptr) { |
| - result = data()->NewLiveRange(FixedFPLiveRangeID(index, rep), rep); |
| - DCHECK(result->IsFixed()); |
| - result->set_assigned_register(index); |
| - data()->MarkAllocated(rep, index); |
| - data()->fixed_simd128_live_ranges()[index] = result; |
| - } |
| - break; |
| default: |
| UNREACHABLE(); |
| break; |
| @@ -2052,7 +2016,8 @@ void LiveRangeBuilder::ProcessInstructions(const InstructionBlock* block, |
| } |
| if (instr->ClobbersDoubleRegisters()) { |
| - for (int i = 0; i < config()->num_allocatable_double_registers(); ++i) { |
| + for (int i = 0; i < config()->num_allocatable_aliased_double_registers(); |
| + ++i) { |
| // Add a UseInterval for all DoubleRegisters. See comment above for |
| // general registers. |
| int code = config()->GetAllocatableDoubleCode(i); |
| @@ -2061,26 +2026,6 @@ void LiveRangeBuilder::ProcessInstructions(const InstructionBlock* block, |
| range->AddUseInterval(curr_position, curr_position.End(), |
| allocation_zone()); |
| } |
| - // Preserve fixed float registers on archs with non-simple aliasing. |
| - if (!kSimpleFPAliasing) { |
| - for (int i = 0; i < config()->num_allocatable_float_registers(); ++i) { |
| - // Add a UseInterval for all FloatRegisters. See comment above for |
| - // general registers. |
| - int code = config()->GetAllocatableFloatCode(i); |
| - TopLevelLiveRange* range = |
| - FixedFPLiveRangeFor(code, MachineRepresentation::kFloat32); |
| - range->AddUseInterval(curr_position, curr_position.End(), |
| - allocation_zone()); |
| - } |
| - for (int i = 0; i < config()->num_allocatable_simd128_registers(); |
| - ++i) { |
| - int code = config()->GetAllocatableSimd128Code(i); |
| - TopLevelLiveRange* range = |
| - FixedFPLiveRangeFor(code, MachineRepresentation::kSimd128); |
| - range->AddUseInterval(curr_position, curr_position.End(), |
| - allocation_zone()); |
| - } |
| - } |
| } |
| for (size_t i = 0; i < instr->InputCount(); i++) { |
| @@ -2644,15 +2589,9 @@ void LinearScanAllocator::AllocateRegisters() { |
| if (current != nullptr) AddToInactive(current); |
| } |
| } else { |
| - for (TopLevelLiveRange* current : data()->fixed_float_live_ranges()) { |
| - if (current != nullptr) AddToInactive(current); |
| - } |
| for (TopLevelLiveRange* current : data()->fixed_double_live_ranges()) { |
| if (current != nullptr) AddToInactive(current); |
| } |
| - for (TopLevelLiveRange* current : data()->fixed_simd128_live_ranges()) { |
| - if (current != nullptr) AddToInactive(current); |
| - } |
| } |
| while (!unhandled_live_ranges().empty()) { |
| @@ -2819,21 +2758,9 @@ void LinearScanAllocator::InactiveToActive(LiveRange* range) { |
| bool LinearScanAllocator::TryAllocateFreeReg(LiveRange* current) { |
| - MachineRepresentation rep = current->representation(); |
| int num_regs = num_registers(); |
| int num_codes = num_allocatable_registers(); |
| const int* codes = allocatable_register_codes(); |
| - if (!kSimpleFPAliasing) { |
| - if (rep == MachineRepresentation::kFloat32) { |
| - num_regs = data()->config()->num_float_registers(); |
| - num_codes = data()->config()->num_allocatable_float_registers(); |
| - codes = data()->config()->allocatable_float_codes(); |
| - } else if (rep == MachineRepresentation::kSimd128) { |
| - num_regs = data()->config()->num_simd128_registers(); |
| - num_codes = data()->config()->num_allocatable_simd128_registers(); |
| - codes = data()->config()->allocatable_simd128_codes(); |
| - } |
| - } |
| LifetimePosition free_until_pos[RegisterConfiguration::kMaxFPRegisters]; |
| for (int i = 0; i < num_regs; i++) { |
| @@ -2842,21 +2769,9 @@ bool LinearScanAllocator::TryAllocateFreeReg(LiveRange* current) { |
| for (LiveRange* cur_active : active_live_ranges()) { |
| int cur_reg = cur_active->assigned_register(); |
| - if (kSimpleFPAliasing || mode() == GENERAL_REGISTERS) { |
| - free_until_pos[cur_reg] = LifetimePosition::GapFromInstructionIndex(0); |
| - TRACE("Register %s is free until pos %d (1)\n", RegisterName(cur_reg), |
| - LifetimePosition::GapFromInstructionIndex(0).value()); |
| - } else { |
| - int alias_base_index = -1; |
| - int aliases = data()->config()->GetAliases( |
| - cur_active->representation(), cur_reg, rep, &alias_base_index); |
| - DCHECK(aliases > 0 || (aliases == 0 && alias_base_index == -1)); |
| - while (aliases--) { |
| - int aliased_reg = alias_base_index + aliases; |
| - free_until_pos[aliased_reg] = |
| - LifetimePosition::GapFromInstructionIndex(0); |
| - } |
| - } |
| + free_until_pos[cur_reg] = LifetimePosition::GapFromInstructionIndex(0); |
| + TRACE("Register %s is free until pos %d (1)\n", RegisterName(cur_reg), |
| + LifetimePosition::GapFromInstructionIndex(0).value()); |
| } |
| for (LiveRange* cur_inactive : inactive_live_ranges()) { |
| @@ -2865,21 +2780,9 @@ bool LinearScanAllocator::TryAllocateFreeReg(LiveRange* current) { |
| cur_inactive->FirstIntersection(current); |
| if (!next_intersection.IsValid()) continue; |
| int cur_reg = cur_inactive->assigned_register(); |
| - if (kSimpleFPAliasing || mode() == GENERAL_REGISTERS) { |
| - free_until_pos[cur_reg] = Min(free_until_pos[cur_reg], next_intersection); |
| - TRACE("Register %s is free until pos %d (2)\n", RegisterName(cur_reg), |
| - Min(free_until_pos[cur_reg], next_intersection).value()); |
| - } else { |
| - int alias_base_index = -1; |
| - int aliases = data()->config()->GetAliases( |
| - cur_inactive->representation(), cur_reg, rep, &alias_base_index); |
| - DCHECK(aliases > 0 || (aliases == 0 && alias_base_index == -1)); |
| - while (aliases--) { |
| - int aliased_reg = alias_base_index + aliases; |
| - free_until_pos[aliased_reg] = |
| - Min(free_until_pos[aliased_reg], next_intersection); |
| - } |
| - } |
| + free_until_pos[cur_reg] = Min(free_until_pos[cur_reg], next_intersection); |
| + TRACE("Register %s is free until pos %d (2)\n", RegisterName(cur_reg), |
| + Min(free_until_pos[cur_reg], next_intersection).value()); |
| } |
| int hint_register; |
| @@ -2943,21 +2846,9 @@ void LinearScanAllocator::AllocateBlockedReg(LiveRange* current) { |
| return; |
| } |
| - MachineRepresentation rep = current->representation(); |
| int num_regs = num_registers(); |
| int num_codes = num_allocatable_registers(); |
| const int* codes = allocatable_register_codes(); |
| - if (!kSimpleFPAliasing) { |
| - if (rep == MachineRepresentation::kFloat32) { |
| - num_regs = data()->config()->num_float_registers(); |
| - num_codes = data()->config()->num_allocatable_float_registers(); |
| - codes = data()->config()->allocatable_float_codes(); |
| - } else if (rep == MachineRepresentation::kSimd128) { |
| - num_regs = data()->config()->num_simd128_registers(); |
| - num_codes = data()->config()->num_allocatable_simd128_registers(); |
| - codes = data()->config()->allocatable_simd128_codes(); |
| - } |
| - } |
| LifetimePosition use_pos[RegisterConfiguration::kMaxFPRegisters]; |
| LifetimePosition block_pos[RegisterConfiguration::kMaxFPRegisters]; |
| @@ -2969,38 +2860,16 @@ void LinearScanAllocator::AllocateBlockedReg(LiveRange* current) { |
| int cur_reg = range->assigned_register(); |
| bool is_fixed_or_cant_spill = |
| range->TopLevel()->IsFixed() || !range->CanBeSpilled(current->Start()); |
| - if (kSimpleFPAliasing || mode() == GENERAL_REGISTERS) { |
| - if (is_fixed_or_cant_spill) { |
| - block_pos[cur_reg] = use_pos[cur_reg] = |
| - LifetimePosition::GapFromInstructionIndex(0); |
| - } else { |
| - UsePosition* next_use = |
| - range->NextUsePositionRegisterIsBeneficial(current->Start()); |
| - if (next_use == nullptr) { |
| - use_pos[cur_reg] = range->End(); |
| - } else { |
| - use_pos[cur_reg] = next_use->pos(); |
| - } |
| - } |
| + if (is_fixed_or_cant_spill) { |
| + block_pos[cur_reg] = use_pos[cur_reg] = |
| + LifetimePosition::GapFromInstructionIndex(0); |
| } else { |
| - int alias_base_index = -1; |
| - int aliases = data()->config()->GetAliases( |
| - range->representation(), cur_reg, rep, &alias_base_index); |
| - DCHECK(aliases > 0 || (aliases == 0 && alias_base_index == -1)); |
| - while (aliases--) { |
| - int aliased_reg = alias_base_index + aliases; |
| - if (is_fixed_or_cant_spill) { |
| - block_pos[aliased_reg] = use_pos[aliased_reg] = |
| - LifetimePosition::GapFromInstructionIndex(0); |
| - } else { |
| - UsePosition* next_use = |
| - range->NextUsePositionRegisterIsBeneficial(current->Start()); |
| - if (next_use == nullptr) { |
| - use_pos[aliased_reg] = range->End(); |
| - } else { |
| - use_pos[aliased_reg] = next_use->pos(); |
| - } |
| - } |
| + UsePosition* next_use = |
| + range->NextUsePositionRegisterIsBeneficial(current->Start()); |
| + if (next_use == nullptr) { |
| + use_pos[cur_reg] = range->End(); |
| + } else { |
| + use_pos[cur_reg] = next_use->pos(); |
| } |
| } |
| } |
| @@ -3011,29 +2880,11 @@ void LinearScanAllocator::AllocateBlockedReg(LiveRange* current) { |
| if (!next_intersection.IsValid()) continue; |
| int cur_reg = range->assigned_register(); |
| bool is_fixed = range->TopLevel()->IsFixed(); |
| - if (kSimpleFPAliasing || mode() == GENERAL_REGISTERS) { |
| - if (is_fixed) { |
| - block_pos[cur_reg] = Min(block_pos[cur_reg], next_intersection); |
| - use_pos[cur_reg] = Min(block_pos[cur_reg], use_pos[cur_reg]); |
| - } else { |
| - use_pos[cur_reg] = Min(use_pos[cur_reg], next_intersection); |
| - } |
| + if (is_fixed) { |
| + block_pos[cur_reg] = Min(block_pos[cur_reg], next_intersection); |
| + use_pos[cur_reg] = Min(block_pos[cur_reg], use_pos[cur_reg]); |
| } else { |
| - int alias_base_index = -1; |
| - int aliases = data()->config()->GetAliases( |
| - range->representation(), cur_reg, rep, &alias_base_index); |
| - DCHECK(aliases > 0 || (aliases == 0 && alias_base_index == -1)); |
| - while (aliases--) { |
| - int aliased_reg = alias_base_index + aliases; |
| - if (is_fixed) { |
| - block_pos[aliased_reg] = |
| - Min(block_pos[aliased_reg], next_intersection); |
| - use_pos[aliased_reg] = |
| - Min(block_pos[aliased_reg], use_pos[aliased_reg]); |
| - } else { |
| - use_pos[aliased_reg] = Min(use_pos[aliased_reg], next_intersection); |
| - } |
| - } |
| + use_pos[cur_reg] = Min(use_pos[cur_reg], next_intersection); |
| } |
| } |
| @@ -3085,15 +2936,7 @@ void LinearScanAllocator::SplitAndSpillIntersecting(LiveRange* current) { |
| LifetimePosition split_pos = current->Start(); |
| for (size_t i = 0; i < active_live_ranges().size(); ++i) { |
| LiveRange* range = active_live_ranges()[i]; |
| - if (kSimpleFPAliasing || mode() == GENERAL_REGISTERS) { |
| - if (range->assigned_register() != reg) continue; |
| - } else { |
| - if (!data()->config()->AreAliases(current->representation(), reg, |
| - range->representation(), |
| - range->assigned_register())) { |
| - continue; |
| - } |
| - } |
| + if (range->assigned_register() != reg) continue; |
| UsePosition* next_pos = range->NextRegisterPosition(current->Start()); |
| LifetimePosition spill_pos = FindOptimalSpillingPos(range, split_pos); |
| @@ -3120,14 +2963,7 @@ void LinearScanAllocator::SplitAndSpillIntersecting(LiveRange* current) { |
| LiveRange* range = inactive_live_ranges()[i]; |
| DCHECK(range->End() > current->Start()); |
| if (range->TopLevel()->IsFixed()) continue; |
| - if (kSimpleFPAliasing || mode() == GENERAL_REGISTERS) { |
| - if (range->assigned_register() != reg) continue; |
| - } else { |
| - if (!data()->config()->AreAliases(current->representation(), reg, |
| - range->representation(), |
| - range->assigned_register())) |
| - continue; |
| - } |
| + if (range->assigned_register() != reg) continue; |
| LifetimePosition next_intersection = range->FirstIntersection(current); |
| if (next_intersection.IsValid()) { |