[regalloc] Cleanup use of kMaxFpRegisters

Minor refactoring to introduce kMaxRegisters instead of relying on
the fact that kMaxGpRegisters <= kMaxFpRegisters.

Bug: v8:8562
Change-Id: If8221a799199c62d5262cfad762489a5088351c7
Reviewed-on: https://chromium-review.googlesource.com/c/1403120
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Stephan Herhut <herhut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58687}
This commit is contained in:
Stephan Herhut 2019-01-09 16:41:22 +01:00 committed by Commit Bot
parent d3f07e0018
commit ba56d28251
3 changed files with 10 additions and 16 deletions

View File

@ -2806,10 +2806,6 @@ LinearScanAllocator::LinearScanAllocator(RegisterAllocationData* data,
next_inactive_ranges_change_(LifetimePosition::Invalid()) {
active_live_ranges().reserve(8);
inactive_live_ranges().reserve(8);
// TryAllocateFreeReg and AllocateBlockedReg assume this
// when allocating local arrays.
DCHECK_GE(RegisterConfiguration::kMaxFPRegisters,
this->data()->config()->num_general_registers());
}
void LinearScanAllocator::AllocateRegisters() {
@ -3121,9 +3117,8 @@ void LinearScanAllocator::FindFreeRegistersForRange(
// - a phi. The same analysis as in the case of the input constraint applies.
//
void LinearScanAllocator::ProcessCurrentRange(LiveRange* current) {
LifetimePosition free_until_pos_buff[RegisterConfiguration::kMaxFPRegisters];
Vector<LifetimePosition> free_until_pos(
free_until_pos_buff, RegisterConfiguration::kMaxFPRegisters);
EmbeddedVector<LifetimePosition, RegisterConfiguration::kMaxRegisters>
free_until_pos;
FindFreeRegistersForRange(current, free_until_pos);
if (!TryAllocatePreferredReg(current, free_until_pos)) {
if (current->TopLevel()->IsSplinter()) {
@ -3245,8 +3240,8 @@ void LinearScanAllocator::AllocateBlockedReg(LiveRange* current) {
// use_pos keeps track of positions a register/alias is used at.
// block_pos keeps track of positions where a register/alias is blocked
// from.
LifetimePosition use_pos[RegisterConfiguration::kMaxFPRegisters];
LifetimePosition block_pos[RegisterConfiguration::kMaxFPRegisters];
LifetimePosition use_pos[RegisterConfiguration::kMaxRegisters];
LifetimePosition block_pos[RegisterConfiguration::kMaxRegisters];
for (int i = 0; i < num_regs; i++) {
use_pos[i] = block_pos[i] = LifetimePosition::MaxPosition();
}

View File

@ -242,11 +242,7 @@ enum class UsePositionHintType : uint8_t {
kUnresolved
};
static const int32_t kUnassignedRegister =
RegisterConfiguration::kMaxGeneralRegisters;
static_assert(kUnassignedRegister <= RegisterConfiguration::kMaxFPRegisters,
"kUnassignedRegister too small");
static const int32_t kUnassignedRegister = RegisterConfiguration::kMaxRegisters;
// Representation of a use position.
class V8_EXPORT_PRIVATE UsePosition final

View File

@ -9,6 +9,7 @@
#include "src/globals.h"
#include "src/machine-type.h"
#include "src/reglist.h"
#include "src/utils.h"
namespace v8 {
namespace internal {
@ -25,8 +26,10 @@ class V8_EXPORT_PRIVATE RegisterConfiguration {
};
// Architecture independent maxes.
static const int kMaxGeneralRegisters = 32;
static const int kMaxFPRegisters = 32;
static constexpr int kMaxGeneralRegisters = 32;
static constexpr int kMaxFPRegisters = 32;
static constexpr int kMaxRegisters =
Max(kMaxFPRegisters, kMaxGeneralRegisters);
// Default RegisterConfigurations for the target architecture.
static const RegisterConfiguration* Default();