Commit 4903f82c authored by mbrandy's avatar mbrandy Committed by Commit bot

PPC: [turbofan] Make MachineType a pair of enums.

Port bb2a830d
Port 56673804

Original commit messages:
    MachineType is now a class with two enum fields:
    - MachineRepresentation
    - MachineSemantic

    Both enums are usable on their own, and this change switches some places
    from using MachineType to use just MachineRepresentation. Most notably:
    - register allocator now uses just the representation.
    - Phi and Select nodes only refer to representations.

   Store nodes use only MachineRepresentation, not MachineType.

R=jarin@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=

Review URL: https://codereview.chromium.org/1523373003

Cr-Commit-Position: refs/heads/master@{#32916}
parent 7c06eaf4
...@@ -142,32 +142,30 @@ void VisitBinop(InstructionSelector* selector, Node* node, ArchOpcode opcode, ...@@ -142,32 +142,30 @@ void VisitBinop(InstructionSelector* selector, Node* node, ArchOpcode opcode,
void InstructionSelector::VisitLoad(Node* node) { void InstructionSelector::VisitLoad(Node* node) {
MachineType rep = RepresentationOf(OpParameter<LoadRepresentation>(node)); LoadRepresentation load_rep = LoadRepresentationOf(node->op());
MachineType typ = TypeOf(OpParameter<LoadRepresentation>(node));
PPCOperandGenerator g(this); PPCOperandGenerator g(this);
Node* base = node->InputAt(0); Node* base = node->InputAt(0);
Node* offset = node->InputAt(1); Node* offset = node->InputAt(1);
ArchOpcode opcode; ArchOpcode opcode;
ImmediateMode mode = kInt16Imm; ImmediateMode mode = kInt16Imm;
switch (rep) { switch (load_rep.representation()) {
case kRepFloat32: case MachineRepresentation::kFloat32:
opcode = kPPC_LoadFloat32; opcode = kPPC_LoadFloat32;
break; break;
case kRepFloat64: case MachineRepresentation::kFloat64:
opcode = kPPC_LoadDouble; opcode = kPPC_LoadDouble;
break; break;
case kRepBit: // Fall through. case MachineRepresentation::kBit: // Fall through.
case kRepWord8: case MachineRepresentation::kWord8:
opcode = (typ == kTypeInt32) ? kPPC_LoadWordS8 : kPPC_LoadWordU8; opcode = load_rep.IsSigned() ? kPPC_LoadWordS8 : kPPC_LoadWordU8;
break; break;
case kRepWord16: case MachineRepresentation::kWord16:
opcode = (typ == kTypeInt32) ? kPPC_LoadWordS16 : kPPC_LoadWordU16; opcode = load_rep.IsSigned() ? kPPC_LoadWordS16 : kPPC_LoadWordU16;
break; break;
#if !V8_TARGET_ARCH_PPC64 #if !V8_TARGET_ARCH_PPC64
case kRepTagged: // Fall through. case MachineRepresentation::kTagged: // Fall through.
#endif #endif
case kRepWord32: case MachineRepresentation::kWord32:
opcode = kPPC_LoadWordS32; opcode = kPPC_LoadWordS32;
#if V8_TARGET_ARCH_PPC64 #if V8_TARGET_ARCH_PPC64
// TODO(mbrandy): this applies to signed loads only (lwa) // TODO(mbrandy): this applies to signed loads only (lwa)
...@@ -175,8 +173,8 @@ void InstructionSelector::VisitLoad(Node* node) { ...@@ -175,8 +173,8 @@ void InstructionSelector::VisitLoad(Node* node) {
#endif #endif
break; break;
#if V8_TARGET_ARCH_PPC64 #if V8_TARGET_ARCH_PPC64
case kRepTagged: // Fall through. case MachineRepresentation::kTagged: // Fall through.
case kRepWord64: case MachineRepresentation::kWord64:
opcode = kPPC_LoadWord64; opcode = kPPC_LoadWord64;
mode = kInt16Imm_4ByteAligned; mode = kInt16Imm_4ByteAligned;
break; break;
...@@ -204,13 +202,13 @@ void InstructionSelector::VisitStore(Node* node) { ...@@ -204,13 +202,13 @@ void InstructionSelector::VisitStore(Node* node) {
Node* offset = node->InputAt(1); Node* offset = node->InputAt(1);
Node* value = node->InputAt(2); Node* value = node->InputAt(2);
StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); StoreRepresentation store_rep = StoreRepresentationOf(node->op());
WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind();
MachineType rep = RepresentationOf(store_rep.machine_type()); MachineRepresentation rep = store_rep.representation();
// TODO(ppc): I guess this could be done in a better way. // TODO(ppc): I guess this could be done in a better way.
if (write_barrier_kind != kNoWriteBarrier) { if (write_barrier_kind != kNoWriteBarrier) {
DCHECK_EQ(kRepTagged, rep); DCHECK_EQ(MachineRepresentation::kTagged, rep);
InstructionOperand inputs[3]; InstructionOperand inputs[3];
size_t input_count = 0; size_t input_count = 0;
inputs[input_count++] = g.UseUniqueRegister(base); inputs[input_count++] = g.UseUniqueRegister(base);
...@@ -242,28 +240,28 @@ void InstructionSelector::VisitStore(Node* node) { ...@@ -242,28 +240,28 @@ void InstructionSelector::VisitStore(Node* node) {
ArchOpcode opcode; ArchOpcode opcode;
ImmediateMode mode = kInt16Imm; ImmediateMode mode = kInt16Imm;
switch (rep) { switch (rep) {
case kRepFloat32: case MachineRepresentation::kFloat32:
opcode = kPPC_StoreFloat32; opcode = kPPC_StoreFloat32;
break; break;
case kRepFloat64: case MachineRepresentation::kFloat64:
opcode = kPPC_StoreDouble; opcode = kPPC_StoreDouble;
break; break;
case kRepBit: // Fall through. case MachineRepresentation::kBit: // Fall through.
case kRepWord8: case MachineRepresentation::kWord8:
opcode = kPPC_StoreWord8; opcode = kPPC_StoreWord8;
break; break;
case kRepWord16: case MachineRepresentation::kWord16:
opcode = kPPC_StoreWord16; opcode = kPPC_StoreWord16;
break; break;
#if !V8_TARGET_ARCH_PPC64 #if !V8_TARGET_ARCH_PPC64
case kRepTagged: // Fall through. case MachineRepresentation::kTagged: // Fall through.
#endif #endif
case kRepWord32: case MachineRepresentation::kWord32:
opcode = kPPC_StoreWord32; opcode = kPPC_StoreWord32;
break; break;
#if V8_TARGET_ARCH_PPC64 #if V8_TARGET_ARCH_PPC64
case kRepTagged: // Fall through. case MachineRepresentation::kTagged: // Fall through.
case kRepWord64: case MachineRepresentation::kWord64:
opcode = kPPC_StoreWord64; opcode = kPPC_StoreWord64;
mode = kInt16Imm_4ByteAligned; mode = kInt16Imm_4ByteAligned;
break; break;
...@@ -287,30 +285,29 @@ void InstructionSelector::VisitStore(Node* node) { ...@@ -287,30 +285,29 @@ void InstructionSelector::VisitStore(Node* node) {
void InstructionSelector::VisitCheckedLoad(Node* node) { void InstructionSelector::VisitCheckedLoad(Node* node) {
MachineType rep = RepresentationOf(OpParameter<MachineType>(node)); CheckedLoadRepresentation load_rep = CheckedLoadRepresentationOf(node->op());
MachineType typ = TypeOf(OpParameter<MachineType>(node));
PPCOperandGenerator g(this); PPCOperandGenerator g(this);
Node* const base = node->InputAt(0); Node* const base = node->InputAt(0);
Node* const offset = node->InputAt(1); Node* const offset = node->InputAt(1);
Node* const length = node->InputAt(2); Node* const length = node->InputAt(2);
ArchOpcode opcode; ArchOpcode opcode;
switch (rep) { switch (load_rep.representation()) {
case kRepWord8: case MachineRepresentation::kWord8:
opcode = typ == kTypeInt32 ? kCheckedLoadInt8 : kCheckedLoadUint8; opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8;
break; break;
case kRepWord16: case MachineRepresentation::kWord16:
opcode = typ == kTypeInt32 ? kCheckedLoadInt16 : kCheckedLoadUint16; opcode = load_rep.IsSigned() ? kCheckedLoadInt16 : kCheckedLoadUint16;
break; break;
case kRepWord32: case MachineRepresentation::kWord32:
opcode = kCheckedLoadWord32; opcode = kCheckedLoadWord32;
break; break;
case kRepWord64: case MachineRepresentation::kWord64:
opcode = kCheckedLoadWord64; opcode = kCheckedLoadWord64;
break; break;
case kRepFloat32: case MachineRepresentation::kFloat32:
opcode = kCheckedLoadFloat32; opcode = kCheckedLoadFloat32;
break; break;
case kRepFloat64: case MachineRepresentation::kFloat64:
opcode = kCheckedLoadFloat64; opcode = kCheckedLoadFloat64;
break; break;
default: default:
...@@ -325,7 +322,7 @@ void InstructionSelector::VisitCheckedLoad(Node* node) { ...@@ -325,7 +322,7 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
void InstructionSelector::VisitCheckedStore(Node* node) { void InstructionSelector::VisitCheckedStore(Node* node) {
MachineType rep = RepresentationOf(OpParameter<MachineType>(node)); MachineRepresentation rep = CheckedStoreRepresentationOf(node->op());
PPCOperandGenerator g(this); PPCOperandGenerator g(this);
Node* const base = node->InputAt(0); Node* const base = node->InputAt(0);
Node* const offset = node->InputAt(1); Node* const offset = node->InputAt(1);
...@@ -333,22 +330,22 @@ void InstructionSelector::VisitCheckedStore(Node* node) { ...@@ -333,22 +330,22 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
Node* const value = node->InputAt(3); Node* const value = node->InputAt(3);
ArchOpcode opcode; ArchOpcode opcode;
switch (rep) { switch (rep) {
case kRepWord8: case MachineRepresentation::kWord8:
opcode = kCheckedStoreWord8; opcode = kCheckedStoreWord8;
break; break;
case kRepWord16: case MachineRepresentation::kWord16:
opcode = kCheckedStoreWord16; opcode = kCheckedStoreWord16;
break; break;
case kRepWord32: case MachineRepresentation::kWord32:
opcode = kCheckedStoreWord32; opcode = kCheckedStoreWord32;
break; break;
case kRepWord64: case MachineRepresentation::kWord64:
opcode = kCheckedStoreWord64; opcode = kCheckedStoreWord64;
break; break;
case kRepFloat32: case MachineRepresentation::kFloat32:
opcode = kCheckedStoreFloat32; opcode = kCheckedStoreFloat32;
break; break;
case kRepFloat64: case MachineRepresentation::kFloat64:
opcode = kCheckedStoreFloat64; opcode = kCheckedStoreFloat64;
break; break;
default: default:
......
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