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