Index: src/compiler/register-allocator.cc |
diff --git a/src/compiler/register-allocator.cc b/src/compiler/register-allocator.cc |
index bfda1940bd70410d14b5931b590c3db0c0a76ab8..0068d84e5015a80c0f76befc68355cd8103955cf 100644 |
--- a/src/compiler/register-allocator.cc |
+++ b/src/compiler/register-allocator.cc |
@@ -1375,6 +1375,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), |
@@ -1552,6 +1554,7 @@ void RegisterAllocationData::MarkAllocated(MachineRepresentation rep, |
int index) { |
switch (rep) { |
case MachineRepresentation::kFloat32: |
+ case MachineRepresentation::kSimd128: |
if (kSimpleFPAliasing) { |
assigned_double_registers_->Add(index); |
} else { |
@@ -1888,17 +1891,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) { |
@@ -1918,27 +1926,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; |
} |
@@ -2080,6 +2105,16 @@ void LiveRangeBuilder::ProcessInstructions(const InstructionBlock* block, |
allocation_zone()); |
} |
} |
+ for (int i = 0; i < config()->num_allocatable_simd128_registers(); ++i) { |
+ int code = config()->GetAllocatableSimd128Code(i); |
+ if (!IsOutputFPRegisterOf(instr, MachineRepresentation::kSimd128, |
+ code)) { |
+ TopLevelLiveRange* range = |
+ FixedFPLiveRangeFor(code, MachineRepresentation::kSimd128); |
+ range->AddUseInterval(curr_position, curr_position.End(), |
+ allocation_zone()); |
+ } |
+ } |
} |
for (size_t i = 0; i < instr->InputCount(); i++) { |
@@ -2815,15 +2850,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(); |
@@ -2838,8 +2880,7 @@ 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); |
while (aliases--) { |
int aliased_reg = alias_base_index + aliases; |
free_until_pos[aliased_reg] = |
@@ -2861,8 +2902,7 @@ 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); |
while (aliases--) { |
int aliased_reg = alias_base_index + aliases; |
free_until_pos[aliased_reg] = |
@@ -2932,14 +2972,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]; |
@@ -2968,8 +3014,7 @@ 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); |
while (aliases--) { |
int aliased_reg = alias_base_index + aliases; |
if (is_fixed_or_cant_spill) { |
@@ -3004,8 +3049,7 @@ 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); |
while (aliases--) { |
int aliased_reg = alias_base_index + aliases; |
if (is_fixed) { |