Commit f50d9500 authored by bbudge's avatar bbudge Committed by Commit bot

Turbofan: Rename UnallocatedOperand policies from '*DOUBLE*' to '*FP*'.

- Renames UnallocatedOperandenum values to reflect the fact that there are
multiple FP machine representations.
- Renames enum values for RegisterAllocatorVerifier enum.
- Template-izes DefineAsFixed and UseFixed methods to handle multiple FP
register types.

BUG=v8:4124

Review-Url: https://codereview.chromium.org/2017733002
Cr-Commit-Position: refs/heads/master@{#36558}
parent 6390282f
...@@ -177,12 +177,12 @@ class InstructionScheduler final : public ZoneObject { ...@@ -177,12 +177,12 @@ class InstructionScheduler final : public ZoneObject {
// Identify nops used as a definition point for live-in registers at // Identify nops used as a definition point for live-in registers at
// function entry. // function entry.
bool IsFixedRegisterParameter(const Instruction* instr) const { bool IsFixedRegisterParameter(const Instruction* instr) const {
return (instr->arch_opcode() == kArchNop) && return (instr->arch_opcode() == kArchNop) && (instr->OutputCount() == 1) &&
(instr->OutputCount() == 1) &&
(instr->OutputAt(0)->IsUnallocated()) && (instr->OutputAt(0)->IsUnallocated()) &&
(UnallocatedOperand::cast(instr->OutputAt(0))->HasFixedRegisterPolicy() || (UnallocatedOperand::cast(instr->OutputAt(0))
UnallocatedOperand::cast( ->HasFixedRegisterPolicy() ||
instr->OutputAt(0))->HasFixedDoubleRegisterPolicy()); UnallocatedOperand::cast(instr->OutputAt(0))
->HasFixedFPRegisterPolicy());
} }
void ComputeTotalLatencies(); void ComputeTotalLatencies();
......
...@@ -54,9 +54,10 @@ class OperandGenerator { ...@@ -54,9 +54,10 @@ class OperandGenerator {
reg.code(), GetVReg(node))); reg.code(), GetVReg(node)));
} }
InstructionOperand DefineAsFixed(Node* node, DoubleRegister reg) { template <typename FPRegType>
InstructionOperand DefineAsFixed(Node* node, FPRegType reg) {
return Define(node, return Define(node,
UnallocatedOperand(UnallocatedOperand::FIXED_DOUBLE_REGISTER, UnallocatedOperand(UnallocatedOperand::FIXED_FP_REGISTER,
reg.code(), GetVReg(node))); reg.code(), GetVReg(node)));
} }
...@@ -122,9 +123,9 @@ class OperandGenerator { ...@@ -122,9 +123,9 @@ class OperandGenerator {
reg.code(), GetVReg(node))); reg.code(), GetVReg(node)));
} }
InstructionOperand UseFixed(Node* node, DoubleRegister reg) { template <typename FPRegType>
return Use(node, InstructionOperand UseFixed(Node* node, FPRegType reg) {
UnallocatedOperand(UnallocatedOperand::FIXED_DOUBLE_REGISTER, return Use(node, UnallocatedOperand(UnallocatedOperand::FIXED_FP_REGISTER,
reg.code(), GetVReg(node))); reg.code(), GetVReg(node)));
} }
...@@ -274,7 +275,7 @@ class OperandGenerator { ...@@ -274,7 +275,7 @@ class OperandGenerator {
} }
// a fixed register. // a fixed register.
if (IsFloatingPoint(rep)) { if (IsFloatingPoint(rep)) {
return UnallocatedOperand(UnallocatedOperand::FIXED_DOUBLE_REGISTER, return UnallocatedOperand(UnallocatedOperand::FIXED_FP_REGISTER,
location.AsRegister(), virtual_register); location.AsRegister(), virtual_register);
} }
return UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER, return UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER,
......
...@@ -95,7 +95,7 @@ std::ostream& operator<<(std::ostream& os, ...@@ -95,7 +95,7 @@ std::ostream& operator<<(std::ostream& os,
<< conf->GetGeneralRegisterName( << conf->GetGeneralRegisterName(
unalloc->fixed_register_index()) unalloc->fixed_register_index())
<< ")"; << ")";
case UnallocatedOperand::FIXED_DOUBLE_REGISTER: case UnallocatedOperand::FIXED_FP_REGISTER:
return os << "(=" return os << "(="
<< conf->GetDoubleRegisterName( << conf->GetDoubleRegisterName(
unalloc->fixed_register_index()) unalloc->fixed_register_index())
......
...@@ -155,7 +155,7 @@ class UnallocatedOperand : public InstructionOperand { ...@@ -155,7 +155,7 @@ class UnallocatedOperand : public InstructionOperand {
NONE, NONE,
ANY, ANY,
FIXED_REGISTER, FIXED_REGISTER,
FIXED_DOUBLE_REGISTER, FIXED_FP_REGISTER,
MUST_HAVE_REGISTER, MUST_HAVE_REGISTER,
MUST_HAVE_SLOT, MUST_HAVE_SLOT,
SAME_AS_FIRST_INPUT SAME_AS_FIRST_INPUT
...@@ -192,7 +192,7 @@ class UnallocatedOperand : public InstructionOperand { ...@@ -192,7 +192,7 @@ class UnallocatedOperand : public InstructionOperand {
UnallocatedOperand(ExtendedPolicy policy, int index, int virtual_register) UnallocatedOperand(ExtendedPolicy policy, int index, int virtual_register)
: UnallocatedOperand(virtual_register) { : UnallocatedOperand(virtual_register) {
DCHECK(policy == FIXED_REGISTER || policy == FIXED_DOUBLE_REGISTER); DCHECK(policy == FIXED_REGISTER || policy == FIXED_FP_REGISTER);
value_ |= BasicPolicyField::encode(EXTENDED_POLICY); value_ |= BasicPolicyField::encode(EXTENDED_POLICY);
value_ |= ExtendedPolicyField::encode(policy); value_ |= ExtendedPolicyField::encode(policy);
value_ |= LifetimeField::encode(USED_AT_END); value_ |= LifetimeField::encode(USED_AT_END);
...@@ -220,7 +220,7 @@ class UnallocatedOperand : public InstructionOperand { ...@@ -220,7 +220,7 @@ class UnallocatedOperand : public InstructionOperand {
bool HasFixedPolicy() const { bool HasFixedPolicy() const {
return basic_policy() == FIXED_SLOT || return basic_policy() == FIXED_SLOT ||
extended_policy() == FIXED_REGISTER || extended_policy() == FIXED_REGISTER ||
extended_policy() == FIXED_DOUBLE_REGISTER; extended_policy() == FIXED_FP_REGISTER;
} }
bool HasRegisterPolicy() const { bool HasRegisterPolicy() const {
return basic_policy() == EXTENDED_POLICY && return basic_policy() == EXTENDED_POLICY &&
...@@ -239,9 +239,9 @@ class UnallocatedOperand : public InstructionOperand { ...@@ -239,9 +239,9 @@ class UnallocatedOperand : public InstructionOperand {
return basic_policy() == EXTENDED_POLICY && return basic_policy() == EXTENDED_POLICY &&
extended_policy() == FIXED_REGISTER; extended_policy() == FIXED_REGISTER;
} }
bool HasFixedDoubleRegisterPolicy() const { bool HasFixedFPRegisterPolicy() const {
return basic_policy() == EXTENDED_POLICY && return basic_policy() == EXTENDED_POLICY &&
extended_policy() == FIXED_DOUBLE_REGISTER; extended_policy() == FIXED_FP_REGISTER;
} }
bool HasSecondaryStorage() const { bool HasSecondaryStorage() const {
return basic_policy() == EXTENDED_POLICY && return basic_policy() == EXTENDED_POLICY &&
...@@ -272,9 +272,9 @@ class UnallocatedOperand : public InstructionOperand { ...@@ -272,9 +272,9 @@ class UnallocatedOperand : public InstructionOperand {
FixedSlotIndexField::kShift); FixedSlotIndexField::kShift);
} }
// [fixed_register_index]: Only for FIXED_REGISTER or FIXED_DOUBLE_REGISTER. // [fixed_register_index]: Only for FIXED_REGISTER or FIXED_FP_REGISTER.
int fixed_register_index() const { int fixed_register_index() const {
DCHECK(HasFixedRegisterPolicy() || HasFixedDoubleRegisterPolicy()); DCHECK(HasFixedRegisterPolicy() || HasFixedFPRegisterPolicy());
return FixedRegisterField::decode(value_); return FixedRegisterField::decode(value_);
} }
...@@ -421,30 +421,31 @@ class LocationOperand : public InstructionOperand { ...@@ -421,30 +421,31 @@ class LocationOperand : public InstructionOperand {
return static_cast<int64_t>(value_) >> IndexField::kShift; return static_cast<int64_t>(value_) >> IndexField::kShift;
} }
int register_code() const {
DCHECK(IsRegister() || IsFPRegister());
return static_cast<int64_t>(value_) >> IndexField::kShift;
}
Register GetRegister() const { Register GetRegister() const {
DCHECK(IsRegister()); DCHECK(IsRegister());
return Register::from_code(static_cast<int64_t>(value_) >> return Register::from_code(register_code());
IndexField::kShift);
} }
FloatRegister GetFloatRegister() const { FloatRegister GetFloatRegister() const {
DCHECK(IsFloatRegister()); DCHECK(IsFloatRegister());
return FloatRegister::from_code(static_cast<int64_t>(value_) >> return FloatRegister::from_code(register_code());
IndexField::kShift);
} }
DoubleRegister GetDoubleRegister() const { DoubleRegister GetDoubleRegister() const {
// TODO(bbudge) Tighten this test to IsDoubleRegister when all code // TODO(bbudge) Tighten this test to IsDoubleRegister when all code
// generators are changed to use the correct Get*Register method. // generators are changed to use the correct Get*Register method.
DCHECK(IsFPRegister()); DCHECK(IsFPRegister());
return DoubleRegister::from_code(static_cast<int64_t>(value_) >> return DoubleRegister::from_code(register_code());
IndexField::kShift);
} }
Simd128Register GetSimd128Register() const { Simd128Register GetSimd128Register() const {
DCHECK(IsSimd128Register()); DCHECK(IsSimd128Register());
return Simd128Register::from_code(static_cast<int64_t>(value_) >> return Simd128Register::from_code(register_code());
IndexField::kShift);
} }
LocationKind location_kind() const { LocationKind location_kind() const {
......
...@@ -160,14 +160,14 @@ void RegisterAllocatorVerifier::BuildConstraint(const InstructionOperand* op, ...@@ -160,14 +160,14 @@ void RegisterAllocatorVerifier::BuildConstraint(const InstructionOperand* op,
int vreg = unallocated->virtual_register(); int vreg = unallocated->virtual_register();
constraint->virtual_register_ = vreg; constraint->virtual_register_ = vreg;
if (unallocated->basic_policy() == UnallocatedOperand::FIXED_SLOT) { if (unallocated->basic_policy() == UnallocatedOperand::FIXED_SLOT) {
constraint->type_ = sequence()->IsFP(vreg) ? kDoubleSlot : kSlot; constraint->type_ = sequence()->IsFP(vreg) ? kFPSlot : kSlot;
constraint->value_ = unallocated->fixed_slot_index(); constraint->value_ = unallocated->fixed_slot_index();
} else { } else {
switch (unallocated->extended_policy()) { switch (unallocated->extended_policy()) {
case UnallocatedOperand::ANY: case UnallocatedOperand::ANY:
case UnallocatedOperand::NONE: case UnallocatedOperand::NONE:
if (sequence()->IsFP(vreg)) { if (sequence()->IsFP(vreg)) {
constraint->type_ = kNoneDouble; constraint->type_ = kNoneFP;
} else { } else {
constraint->type_ = kNone; constraint->type_ = kNone;
} }
...@@ -181,19 +181,19 @@ void RegisterAllocatorVerifier::BuildConstraint(const InstructionOperand* op, ...@@ -181,19 +181,19 @@ void RegisterAllocatorVerifier::BuildConstraint(const InstructionOperand* op,
} }
constraint->value_ = unallocated->fixed_register_index(); constraint->value_ = unallocated->fixed_register_index();
break; break;
case UnallocatedOperand::FIXED_DOUBLE_REGISTER: case UnallocatedOperand::FIXED_FP_REGISTER:
constraint->type_ = kFixedDoubleRegister; constraint->type_ = kFixedFPRegister;
constraint->value_ = unallocated->fixed_register_index(); constraint->value_ = unallocated->fixed_register_index();
break; break;
case UnallocatedOperand::MUST_HAVE_REGISTER: case UnallocatedOperand::MUST_HAVE_REGISTER:
if (sequence()->IsFP(vreg)) { if (sequence()->IsFP(vreg)) {
constraint->type_ = kDoubleRegister; constraint->type_ = kFPRegister;
} else { } else {
constraint->type_ = kRegister; constraint->type_ = kRegister;
} }
break; break;
case UnallocatedOperand::MUST_HAVE_SLOT: case UnallocatedOperand::MUST_HAVE_SLOT:
constraint->type_ = sequence()->IsFP(vreg) ? kDoubleSlot : kSlot; constraint->type_ = sequence()->IsFP(vreg) ? kFPSlot : kSlot;
break; break;
case UnallocatedOperand::SAME_AS_FIRST_INPUT: case UnallocatedOperand::SAME_AS_FIRST_INPUT:
constraint->type_ = kSameAsFirst; constraint->type_ = kSameAsFirst;
...@@ -223,7 +223,7 @@ void RegisterAllocatorVerifier::CheckConstraint( ...@@ -223,7 +223,7 @@ void RegisterAllocatorVerifier::CheckConstraint(
case kRegister: case kRegister:
CHECK(op->IsRegister()); CHECK(op->IsRegister());
return; return;
case kDoubleRegister: case kFPRegister:
CHECK(op->IsFPRegister()); CHECK(op->IsFPRegister());
return; return;
case kExplicit: case kExplicit:
...@@ -232,13 +232,11 @@ void RegisterAllocatorVerifier::CheckConstraint( ...@@ -232,13 +232,11 @@ void RegisterAllocatorVerifier::CheckConstraint(
case kFixedRegister: case kFixedRegister:
case kRegisterAndSlot: case kRegisterAndSlot:
CHECK(op->IsRegister()); CHECK(op->IsRegister());
CHECK_EQ(LocationOperand::cast(op)->GetRegister().code(), CHECK_EQ(LocationOperand::cast(op)->register_code(), constraint->value_);
constraint->value_);
return; return;
case kFixedDoubleRegister: case kFixedFPRegister:
CHECK(op->IsFPRegister()); CHECK(op->IsFPRegister());
CHECK_EQ(LocationOperand::cast(op)->GetDoubleRegister().code(), CHECK_EQ(LocationOperand::cast(op)->register_code(), constraint->value_);
constraint->value_);
return; return;
case kFixedSlot: case kFixedSlot:
CHECK(op->IsStackSlot()); CHECK(op->IsStackSlot());
...@@ -247,13 +245,13 @@ void RegisterAllocatorVerifier::CheckConstraint( ...@@ -247,13 +245,13 @@ void RegisterAllocatorVerifier::CheckConstraint(
case kSlot: case kSlot:
CHECK(op->IsStackSlot()); CHECK(op->IsStackSlot());
return; return;
case kDoubleSlot: case kFPSlot:
CHECK(op->IsFPStackSlot()); CHECK(op->IsFPStackSlot());
return; return;
case kNone: case kNone:
CHECK(op->IsRegister() || op->IsStackSlot()); CHECK(op->IsRegister() || op->IsStackSlot());
return; return;
case kNoneDouble: case kNoneFP:
CHECK(op->IsFPRegister() || op->IsFPStackSlot()); CHECK(op->IsFPRegister() || op->IsFPStackSlot());
return; return;
case kSameAsFirst: case kSameAsFirst:
......
...@@ -175,13 +175,13 @@ class RegisterAllocatorVerifier final : public ZoneObject { ...@@ -175,13 +175,13 @@ class RegisterAllocatorVerifier final : public ZoneObject {
kImmediate, kImmediate,
kRegister, kRegister,
kFixedRegister, kFixedRegister,
kDoubleRegister, kFPRegister,
kFixedDoubleRegister, kFixedFPRegister,
kSlot, kSlot,
kDoubleSlot, kFPSlot,
kFixedSlot, kFixedSlot,
kNone, kNone,
kNoneDouble, kNoneFP,
kExplicit, kExplicit,
kSameAsFirst, kSameAsFirst,
kRegisterAndSlot kRegisterAndSlot
......
...@@ -1618,7 +1618,7 @@ InstructionOperand* ConstraintBuilder::AllocateFixed( ...@@ -1618,7 +1618,7 @@ InstructionOperand* ConstraintBuilder::AllocateFixed(
DCHECK(!IsFloatingPoint(rep)); DCHECK(!IsFloatingPoint(rep));
allocated = AllocatedOperand(AllocatedOperand::REGISTER, rep, allocated = AllocatedOperand(AllocatedOperand::REGISTER, rep,
operand->fixed_register_index()); operand->fixed_register_index());
} else if (operand->HasFixedDoubleRegisterPolicy()) { } else if (operand->HasFixedFPRegisterPolicy()) {
DCHECK(IsFloatingPoint(rep)); DCHECK(IsFloatingPoint(rep));
DCHECK_NE(InstructionOperand::kInvalidVirtualRegister, virtual_register); DCHECK_NE(InstructionOperand::kInvalidVirtualRegister, virtual_register);
allocated = AllocatedOperand(AllocatedOperand::REGISTER, rep, allocated = AllocatedOperand(AllocatedOperand::REGISTER, rep,
......
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