Index: src/compiler/register-allocator.cc |
diff --git a/src/compiler/register-allocator.cc b/src/compiler/register-allocator.cc |
index 14ceae11c33a8481703dad7a410ff96627c801d1..01c9bde874c0282f5a5104ac23ecec41707b2d54 100644 |
--- a/src/compiler/register-allocator.cc |
+++ b/src/compiler/register-allocator.cc |
@@ -1344,6 +1344,8 @@ RegisterAllocationData::RegisterAllocationData( |
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), |
@@ -1521,12 +1523,14 @@ 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); |
@@ -1857,17 +1861,22 @@ void LiveRangeBuilder::AddInitialIntervals(const InstructionBlock* block, |
} |
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: |
- return -index - 1 - config()->num_general_registers(); |
+ result -= config()->num_double_registers(); |
+ // Fall through. |
case MachineRepresentation::kFloat64: |
- return -index - 1 - config()->num_general_registers() - |
- config()->num_float_registers(); |
+ result -= config()->num_general_registers(); |
+ break; |
default: |
+ UNREACHABLE(); |
break; |
} |
- UNREACHABLE(); |
- return 0; |
+ return result; |
} |
TopLevelLiveRange* LiveRangeBuilder::FixedLiveRangeFor(int index) { |
@@ -1887,27 +1896,44 @@ TopLevelLiveRange* LiveRangeBuilder::FixedLiveRangeFor(int index) { |
TopLevelLiveRange* LiveRangeBuilder::FixedFPLiveRangeFor( |
int index, MachineRepresentation rep) { |
TopLevelLiveRange* result = nullptr; |
- if (rep == MachineRepresentation::kFloat64) { |
- DCHECK(index < config()->num_double_registers()); |
- result = data()->fixed_double_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_double_live_ranges()[index] = result; |
- } |
- } else { |
- 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; |
- } |
+ 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: |
+ DCHECK(index < config()->num_double_registers()); |
+ result = data()->fixed_double_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_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; |
} |
return result; |
} |
@@ -2051,6 +2077,14 @@ void LiveRangeBuilder::ProcessInstructions(const InstructionBlock* block, |
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()); |
+ } |
} |
} |
@@ -2787,15 +2821,22 @@ 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 && |
- (current->representation() == MachineRepresentation::kFloat32)) { |
- num_regs = data()->config()->num_float_registers(); |
- num_codes = data()->config()->num_allocatable_float_registers(); |
- codes = data()->config()->allocatable_float_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++) { |
free_until_pos[i] = LifetimePosition::MaxPosition(); |
@@ -2810,8 +2851,8 @@ bool LinearScanAllocator::TryAllocateFreeReg(LiveRange* current) { |
} else { |
int alias_base_index = -1; |
int aliases = data()->config()->GetAliases( |
- cur_active->representation(), cur_reg, current->representation(), |
- &alias_base_index); |
+ 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] = |
@@ -2833,8 +2874,8 @@ bool LinearScanAllocator::TryAllocateFreeReg(LiveRange* current) { |
} else { |
int alias_base_index = -1; |
int aliases = data()->config()->GetAliases( |
- cur_inactive->representation(), cur_reg, current->representation(), |
- &alias_base_index); |
+ 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] = |
@@ -2904,14 +2945,20 @@ 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 && |
- (current->representation() == MachineRepresentation::kFloat32)) { |
- num_regs = data()->config()->num_float_registers(); |
- num_codes = data()->config()->num_allocatable_float_registers(); |
- codes = data()->config()->allocatable_float_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]; |
@@ -2940,8 +2987,8 @@ void LinearScanAllocator::AllocateBlockedReg(LiveRange* current) { |
} else { |
int alias_base_index = -1; |
int aliases = data()->config()->GetAliases( |
- range->representation(), cur_reg, current->representation(), |
- &alias_base_index); |
+ 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) { |
@@ -2976,8 +3023,8 @@ void LinearScanAllocator::AllocateBlockedReg(LiveRange* current) { |
} else { |
int alias_base_index = -1; |
int aliases = data()->config()->GetAliases( |
- range->representation(), cur_reg, current->representation(), |
- &alias_base_index); |
+ 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) { |