Commit 965916c7 authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[arm] Reduce confusion between max and actual double register counts

The actual number of double regs available on arm depends on the
current CPU. In some cases, we care about the max count of double regs
(e.g.  around Save/RestoreFPRegs which always reserves spaces for the
max); in others, we care about the actual count.

Use DwVfpRegister::kNumRegisters to fetch the max (= 32).
Use DwVfpRegister::SupportedRegisterCount() for the actual count (16
or 32).

Bug: v8:11062
Change-Id: I7d0c3f1263433ef5dc8efa69a68dff92a7168ae6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2501842Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70795}
parent b72c32c0
...@@ -51,7 +51,7 @@ bool CpuFeatures::SupportsOptimizer() { return true; } ...@@ -51,7 +51,7 @@ bool CpuFeatures::SupportsOptimizer() { return true; }
bool CpuFeatures::SupportsWasmSimd128() { return IsSupported(NEON); } bool CpuFeatures::SupportsWasmSimd128() { return IsSupported(NEON); }
int DoubleRegister::NumRegisters() { int DoubleRegister::SupportedRegisterCount() {
return CpuFeatures::IsSupported(VFP32DREGS) ? 32 : 16; return CpuFeatures::IsSupported(VFP32DREGS) ? 32 : 16;
} }
......
...@@ -57,7 +57,7 @@ int TurboAssembler::RequiredStackSizeForCallerSaved(SaveFPRegsMode fp_mode, ...@@ -57,7 +57,7 @@ int TurboAssembler::RequiredStackSizeForCallerSaved(SaveFPRegsMode fp_mode,
bytes += NumRegs(list) * kPointerSize; bytes += NumRegs(list) * kPointerSize;
if (fp_mode == kSaveFPRegs) { if (fp_mode == kSaveFPRegs) {
bytes += DwVfpRegister::NumRegisters() * DwVfpRegister::kSizeInBytes; bytes += DwVfpRegister::kNumRegisters * DwVfpRegister::kSizeInBytes;
} }
return bytes; return bytes;
...@@ -84,7 +84,7 @@ int TurboAssembler::PushCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1, ...@@ -84,7 +84,7 @@ int TurboAssembler::PushCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1,
if (fp_mode == kSaveFPRegs) { if (fp_mode == kSaveFPRegs) {
SaveFPRegs(sp, lr); SaveFPRegs(sp, lr);
bytes += DwVfpRegister::NumRegisters() * DwVfpRegister::kSizeInBytes; bytes += DwVfpRegister::kNumRegisters * DwVfpRegister::kSizeInBytes;
} }
return bytes; return bytes;
...@@ -95,7 +95,7 @@ int TurboAssembler::PopCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1, ...@@ -95,7 +95,7 @@ int TurboAssembler::PopCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1,
int bytes = 0; int bytes = 0;
if (fp_mode == kSaveFPRegs) { if (fp_mode == kSaveFPRegs) {
RestoreFPRegs(sp, lr); RestoreFPRegs(sp, lr);
bytes += DwVfpRegister::NumRegisters() * DwVfpRegister::kSizeInBytes; bytes += DwVfpRegister::kNumRegisters * DwVfpRegister::kSizeInBytes;
} }
RegList exclusions = 0; RegList exclusions = 0;
...@@ -2279,11 +2279,11 @@ int TurboAssembler::CalculateStackPassedWords(int num_reg_arguments, ...@@ -2279,11 +2279,11 @@ int TurboAssembler::CalculateStackPassedWords(int num_reg_arguments,
int num_double_arguments) { int num_double_arguments) {
int stack_passed_words = 0; int stack_passed_words = 0;
if (use_eabi_hardfloat()) { if (use_eabi_hardfloat()) {
// In the hard floating point calling convention, we can use // In the hard floating point calling convention, we can use all double
// all double registers to pass doubles. // registers to pass doubles.
if (num_double_arguments > DoubleRegister::NumRegisters()) { if (num_double_arguments > DoubleRegister::SupportedRegisterCount()) {
stack_passed_words += stack_passed_words +=
2 * (num_double_arguments - DoubleRegister::NumRegisters()); 2 * (num_double_arguments - DoubleRegister::SupportedRegisterCount());
} }
} else { } else {
// In the soft floating point calling convention, every double // In the soft floating point calling convention, every double
......
...@@ -181,7 +181,10 @@ class DwVfpRegister : public RegisterBase<DwVfpRegister, kDoubleAfterLast> { ...@@ -181,7 +181,10 @@ class DwVfpRegister : public RegisterBase<DwVfpRegister, kDoubleAfterLast> {
public: public:
static constexpr int kSizeInBytes = 8; static constexpr int kSizeInBytes = 8;
inline static int NumRegisters(); // This function differs from kNumRegisters by returning the number of double
// registers supported by the current CPU, while kNumRegisters always returns
// 32.
inline static int SupportedRegisterCount();
static void split_code(int reg_code, int* vm, int* m) { static void split_code(int reg_code, int* vm, int* m) {
DCHECK(from_code(reg_code).is_valid()); DCHECK(from_code(reg_code).is_valid());
......
...@@ -248,7 +248,7 @@ void ArmDebugger::Debug() { ...@@ -248,7 +248,7 @@ void ArmDebugger::Debug() {
PrintF("\n"); PrintF("\n");
} }
} }
for (int i = 0; i < DwVfpRegister::NumRegisters(); i++) { for (int i = 0; i < DwVfpRegister::SupportedRegisterCount(); i++) {
dvalue = GetVFPDoubleRegisterValue(i); dvalue = GetVFPDoubleRegisterValue(i);
uint64_t as_words = bit_cast<uint64_t>(dvalue); uint64_t as_words = bit_cast<uint64_t>(dvalue);
PrintF("%3s: %f 0x%08x %08x\n", VFPRegisters::Name(i, true), PrintF("%3s: %f 0x%08x %08x\n", VFPRegisters::Name(i, true),
...@@ -753,22 +753,22 @@ void Simulator::set_dw_register(int dreg, const int* dbl) { ...@@ -753,22 +753,22 @@ void Simulator::set_dw_register(int dreg, const int* dbl) {
} }
void Simulator::get_d_register(int dreg, uint64_t* value) { void Simulator::get_d_register(int dreg, uint64_t* value) {
DCHECK((dreg >= 0) && (dreg < DwVfpRegister::NumRegisters())); DCHECK((dreg >= 0) && (dreg < DwVfpRegister::SupportedRegisterCount()));
memcpy(value, vfp_registers_ + dreg * 2, sizeof(*value)); memcpy(value, vfp_registers_ + dreg * 2, sizeof(*value));
} }
void Simulator::set_d_register(int dreg, const uint64_t* value) { void Simulator::set_d_register(int dreg, const uint64_t* value) {
DCHECK((dreg >= 0) && (dreg < DwVfpRegister::NumRegisters())); DCHECK((dreg >= 0) && (dreg < DwVfpRegister::SupportedRegisterCount()));
memcpy(vfp_registers_ + dreg * 2, value, sizeof(*value)); memcpy(vfp_registers_ + dreg * 2, value, sizeof(*value));
} }
void Simulator::get_d_register(int dreg, uint32_t* value) { void Simulator::get_d_register(int dreg, uint32_t* value) {
DCHECK((dreg >= 0) && (dreg < DwVfpRegister::NumRegisters())); DCHECK((dreg >= 0) && (dreg < DwVfpRegister::SupportedRegisterCount()));
memcpy(value, vfp_registers_ + dreg * 2, sizeof(*value) * 2); memcpy(value, vfp_registers_ + dreg * 2, sizeof(*value) * 2);
} }
void Simulator::set_d_register(int dreg, const uint32_t* value) { void Simulator::set_d_register(int dreg, const uint32_t* value) {
DCHECK((dreg >= 0) && (dreg < DwVfpRegister::NumRegisters())); DCHECK((dreg >= 0) && (dreg < DwVfpRegister::SupportedRegisterCount()));
memcpy(vfp_registers_ + dreg * 2, value, sizeof(*value) * 2); memcpy(vfp_registers_ + dreg * 2, value, sizeof(*value) * 2);
} }
...@@ -818,7 +818,8 @@ void Simulator::SetVFPRegister(int reg_index, const InputType& value) { ...@@ -818,7 +818,8 @@ void Simulator::SetVFPRegister(int reg_index, const InputType& value) {
DCHECK_EQ(sizeof(InputType), bytes); DCHECK_EQ(sizeof(InputType), bytes);
DCHECK_GE(reg_index, 0); DCHECK_GE(reg_index, 0);
if (register_size == 1) DCHECK(reg_index < num_s_registers); if (register_size == 1) DCHECK(reg_index < num_s_registers);
if (register_size == 2) DCHECK(reg_index < DwVfpRegister::NumRegisters()); if (register_size == 2)
DCHECK(reg_index < DwVfpRegister::SupportedRegisterCount());
memcpy(&vfp_registers_[reg_index * register_size], &value, bytes); memcpy(&vfp_registers_[reg_index * register_size], &value, bytes);
} }
...@@ -829,7 +830,8 @@ ReturnType Simulator::GetFromVFPRegister(int reg_index) { ...@@ -829,7 +830,8 @@ ReturnType Simulator::GetFromVFPRegister(int reg_index) {
DCHECK_EQ(sizeof(ReturnType), bytes); DCHECK_EQ(sizeof(ReturnType), bytes);
DCHECK_GE(reg_index, 0); DCHECK_GE(reg_index, 0);
if (register_size == 1) DCHECK(reg_index < num_s_registers); if (register_size == 1) DCHECK(reg_index < num_s_registers);
if (register_size == 2) DCHECK(reg_index < DwVfpRegister::NumRegisters()); if (register_size == 2)
DCHECK(reg_index < DwVfpRegister::SupportedRegisterCount());
ReturnType value; ReturnType value;
memcpy(&value, &vfp_registers_[register_size * reg_index], bytes); memcpy(&value, &vfp_registers_[register_size * reg_index], bytes);
......
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