Chromium Code Reviews| Index: src/compiler/instruction.h |
| diff --git a/src/compiler/instruction.h b/src/compiler/instruction.h |
| index 72299efedda8a5e8fbe0b281466a791f993a4d94..c6a65bfd11454bc347ff7e022c3044eaadc22b17 100644 |
| --- a/src/compiler/instruction.h |
| +++ b/src/compiler/instruction.h |
| @@ -33,7 +33,17 @@ class InstructionOperand { |
| // TODO(dcarney): recover bit. INVALID can be represented as UNALLOCATED with |
| // kInvalidVirtualRegister and some DCHECKS. |
| - enum Kind { INVALID, UNALLOCATED, CONSTANT, IMMEDIATE, EXPLICIT, ALLOCATED }; |
| + enum Kind { |
| + INVALID, |
| + UNALLOCATED, |
| + CONSTANT, |
| + IMMEDIATE, |
| + // Location operand kinds. |
| + EXPLICIT, |
| + ALLOCATED, |
| + FIRST_LOCATION_OPERAND_KIND = EXPLICIT |
| + // Location operand kinds must be last. |
| + }; |
| InstructionOperand() : InstructionOperand(INVALID) {} |
| @@ -64,6 +74,7 @@ class InstructionOperand { |
| INSTRUCTION_OPERAND_PREDICATE(Allocated, ALLOCATED) |
| #undef INSTRUCTION_OPERAND_PREDICATE |
| + inline bool IsLocation() const; |
|
Mircea Trofin
2016/09/30 21:52:10
As discussed offline, how about these names:
IsLo
bbudge
2016/10/03 21:37:18
Done.
|
| inline bool IsAnyRegister() const; |
| inline bool IsRegister() const; |
| inline bool IsFPRegister() const; |
| @@ -75,6 +86,7 @@ class InstructionOperand { |
| inline bool IsFloatStackSlot() const; |
| inline bool IsDoubleStackSlot() const; |
| inline bool IsSimd128StackSlot() const; |
| + inline bool IsFPLocation() const; |
| template <typename SubKindOperand> |
| static SubKindOperand* New(Zone* zone, const SubKindOperand& op) { |
| @@ -482,17 +494,17 @@ class LocationOperand : public InstructionOperand { |
| } |
| static LocationOperand* cast(InstructionOperand* op) { |
| - DCHECK(ALLOCATED == op->kind() || EXPLICIT == op->kind()); |
| + DCHECK(op->IsLocation()); |
| return static_cast<LocationOperand*>(op); |
| } |
| static const LocationOperand* cast(const InstructionOperand* op) { |
| - DCHECK(ALLOCATED == op->kind() || EXPLICIT == op->kind()); |
| + DCHECK(op->IsLocation()); |
| return static_cast<const LocationOperand*>(op); |
| } |
| static LocationOperand cast(const InstructionOperand& op) { |
| - DCHECK(ALLOCATED == op.kind() || EXPLICIT == op.kind()); |
| + DCHECK(op.IsLocation()); |
| return *static_cast<const LocationOperand*>(&op); |
| } |
| @@ -532,9 +544,12 @@ class AllocatedOperand : public LocationOperand { |
| #undef INSTRUCTION_OPERAND_CASTS |
| +bool InstructionOperand::IsLocation() const { |
| + return this->kind() >= FIRST_LOCATION_OPERAND_KIND; |
| +} |
| bool InstructionOperand::IsAnyRegister() const { |
| - return (IsAllocated() || IsExplicit()) && |
| + return IsLocation() && |
| LocationOperand::cast(this)->location_kind() == |
| LocationOperand::REGISTER; |
| } |
| @@ -569,21 +584,21 @@ bool InstructionOperand::IsSimd128Register() const { |
| } |
| bool InstructionOperand::IsStackSlot() const { |
| - return (IsAllocated() || IsExplicit()) && |
| + return IsLocation() && |
| LocationOperand::cast(this)->location_kind() == |
| LocationOperand::STACK_SLOT && |
| !IsFloatingPoint(LocationOperand::cast(this)->representation()); |
| } |
| bool InstructionOperand::IsFPStackSlot() const { |
| - return (IsAllocated() || IsExplicit()) && |
| + return IsLocation() && |
| LocationOperand::cast(this)->location_kind() == |
| LocationOperand::STACK_SLOT && |
| IsFloatingPoint(LocationOperand::cast(this)->representation()); |
| } |
| bool InstructionOperand::IsFloatStackSlot() const { |
| - return (IsAllocated() || IsExplicit()) && |
| + return IsLocation() && |
| LocationOperand::cast(this)->location_kind() == |
| LocationOperand::STACK_SLOT && |
| LocationOperand::cast(this)->representation() == |
| @@ -591,7 +606,7 @@ bool InstructionOperand::IsFloatStackSlot() const { |
| } |
| bool InstructionOperand::IsDoubleStackSlot() const { |
| - return (IsAllocated() || IsExplicit()) && |
| + return IsLocation() && |
| LocationOperand::cast(this)->location_kind() == |
| LocationOperand::STACK_SLOT && |
| LocationOperand::cast(this)->representation() == |
| @@ -599,15 +614,20 @@ bool InstructionOperand::IsDoubleStackSlot() const { |
| } |
| bool InstructionOperand::IsSimd128StackSlot() const { |
| - return (IsAllocated() || IsExplicit()) && |
| + return IsLocation() && |
| LocationOperand::cast(this)->location_kind() == |
| LocationOperand::STACK_SLOT && |
| LocationOperand::cast(this)->representation() == |
| MachineRepresentation::kSimd128; |
| } |
| +bool InstructionOperand::IsFPLocation() const { |
| + return IsLocation() && |
| + IsFloatingPoint(LocationOperand::cast(this)->representation()); |
| +} |
| + |
| uint64_t InstructionOperand::GetCanonicalizedValue() const { |
| - if (IsAllocated() || IsExplicit()) { |
| + if (IsLocation()) { |
| MachineRepresentation canonical = MachineRepresentation::kNone; |
| if (IsFPRegister()) { |
| // We treat all FP register operands the same for simple aliasing. |