Commit 739c0187 authored by jarin's avatar jarin Committed by Commit bot

[turbofan] Exhaustive switches for MachineRepresentation.

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

Cr-Commit-Position: refs/heads/master@{#33011}
parent b7ff2bd5
......@@ -308,7 +308,7 @@ void InstructionSelector::VisitLoad(Node* node) {
Node* base = node->InputAt(0);
Node* index = node->InputAt(1);
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (load_rep.representation()) {
case MachineRepresentation::kFloat32:
opcode = kArmVldrF32;
......@@ -327,7 +327,8 @@ void InstructionSelector::VisitLoad(Node* node) {
case MachineRepresentation::kWord32:
opcode = kArmLdr;
break;
default:
case MachineRepresentation::kNone: // Fall through.
case MachineRepresentation::kWord64:
UNREACHABLE();
return;
}
......@@ -382,7 +383,7 @@ void InstructionSelector::VisitStore(Node* node) {
code |= MiscField::encode(static_cast<int>(record_write_mode));
Emit(code, 0, nullptr, input_count, inputs, temp_count, temps);
} else {
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (rep) {
case MachineRepresentation::kFloat32:
opcode = kArmVstrF32;
......@@ -401,7 +402,8 @@ void InstructionSelector::VisitStore(Node* node) {
case MachineRepresentation::kWord32:
opcode = kArmStr;
break;
default:
case MachineRepresentation::kNone: // Fall through.
case MachineRepresentation::kWord64:
UNREACHABLE();
return;
}
......@@ -423,7 +425,7 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
Node* const buffer = node->InputAt(0);
Node* const offset = node->InputAt(1);
Node* const length = node->InputAt(2);
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (load_rep.representation()) {
case MachineRepresentation::kWord8:
opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8;
......@@ -440,7 +442,10 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
case MachineRepresentation::kFloat64:
opcode = kCheckedLoadFloat64;
break;
default:
case MachineRepresentation::kBit: // Fall through.
case MachineRepresentation::kTagged: // Fall through.
case MachineRepresentation::kWord64: // Fall through.
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......@@ -461,7 +466,7 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
Node* const offset = node->InputAt(1);
Node* const length = node->InputAt(2);
Node* const value = node->InputAt(3);
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (rep) {
case MachineRepresentation::kWord8:
opcode = kCheckedStoreWord8;
......@@ -478,7 +483,10 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
case MachineRepresentation::kFloat64:
opcode = kCheckedStoreFloat64;
break;
default:
case MachineRepresentation::kBit: // Fall through.
case MachineRepresentation::kTagged: // Fall through.
case MachineRepresentation::kWord64: // Fall through.
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......
......@@ -342,7 +342,7 @@ void InstructionSelector::VisitLoad(Node* node) {
Arm64OperandGenerator g(this);
Node* base = node->InputAt(0);
Node* index = node->InputAt(1);
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
ImmediateMode immediate_mode = kNoImmediate;
switch (load_rep.representation()) {
case MachineRepresentation::kFloat32:
......@@ -371,7 +371,7 @@ void InstructionSelector::VisitLoad(Node* node) {
opcode = kArm64Ldr;
immediate_mode = kLoadStoreImm64;
break;
default:
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......@@ -426,7 +426,7 @@ void InstructionSelector::VisitStore(Node* node) {
code |= MiscField::encode(static_cast<int>(record_write_mode));
Emit(code, 0, nullptr, input_count, inputs, temp_count, temps);
} else {
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
ImmediateMode immediate_mode = kNoImmediate;
switch (rep) {
case MachineRepresentation::kFloat32:
......@@ -455,7 +455,7 @@ void InstructionSelector::VisitStore(Node* node) {
opcode = kArm64Str;
immediate_mode = kLoadStoreImm64;
break;
default:
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......@@ -476,7 +476,7 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
Node* const buffer = node->InputAt(0);
Node* const offset = node->InputAt(1);
Node* const length = node->InputAt(2);
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (load_rep.representation()) {
case MachineRepresentation::kWord8:
opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8;
......@@ -496,7 +496,9 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
case MachineRepresentation::kFloat64:
opcode = kCheckedLoadFloat64;
break;
default:
case MachineRepresentation::kBit: // Fall through.
case MachineRepresentation::kTagged: // Fall through.
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......@@ -512,7 +514,7 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
Node* const offset = node->InputAt(1);
Node* const length = node->InputAt(2);
Node* const value = node->InputAt(3);
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (rep) {
case MachineRepresentation::kWord8:
opcode = kCheckedStoreWord8;
......@@ -532,7 +534,9 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
case MachineRepresentation::kFloat64:
opcode = kCheckedStoreFloat64;
break;
default:
case MachineRepresentation::kBit: // Fall through.
case MachineRepresentation::kTagged: // Fall through.
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......
......@@ -171,7 +171,7 @@ void VisitFloatUnop(InstructionSelector* selector, Node* node, Node* input,
void InstructionSelector::VisitLoad(Node* node) {
LoadRepresentation load_rep = LoadRepresentationOf(node->op());
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (load_rep.representation()) {
case MachineRepresentation::kFloat32:
opcode = kIA32Movss;
......@@ -190,7 +190,8 @@ void InstructionSelector::VisitLoad(Node* node) {
case MachineRepresentation::kWord32:
opcode = kIA32Movl;
break;
default:
case MachineRepresentation::kWord64: // Fall through.
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......@@ -255,7 +256,7 @@ void InstructionSelector::VisitStore(Node* node) {
code |= MiscField::encode(static_cast<int>(record_write_mode));
Emit(code, 0, nullptr, input_count, inputs, temp_count, temps);
} else {
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (rep) {
case MachineRepresentation::kFloat32:
opcode = kIA32Movss;
......@@ -274,7 +275,8 @@ void InstructionSelector::VisitStore(Node* node) {
case MachineRepresentation::kWord32:
opcode = kIA32Movl;
break;
default:
case MachineRepresentation::kWord64: // Fall through.
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......@@ -307,7 +309,7 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
Node* const buffer = node->InputAt(0);
Node* const offset = node->InputAt(1);
Node* const length = node->InputAt(2);
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (load_rep.representation()) {
case MachineRepresentation::kWord8:
opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8;
......@@ -324,7 +326,10 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
case MachineRepresentation::kFloat64:
opcode = kCheckedLoadFloat64;
break;
default:
case MachineRepresentation::kBit: // Fall through.
case MachineRepresentation::kTagged: // Fall through.
case MachineRepresentation::kWord64: // Fall through.
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......@@ -350,7 +355,7 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
Node* const offset = node->InputAt(1);
Node* const length = node->InputAt(2);
Node* const value = node->InputAt(3);
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (rep) {
case MachineRepresentation::kWord8:
opcode = kCheckedStoreWord8;
......@@ -367,7 +372,10 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
case MachineRepresentation::kFloat64:
opcode = kCheckedStoreFloat64;
break;
default:
case MachineRepresentation::kBit: // Fall through.
case MachineRepresentation::kTagged: // Fall through.
case MachineRepresentation::kWord64: // Fall through.
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......
......@@ -139,6 +139,18 @@ std::ostream& operator<<(std::ostream& os,
os << "|E";
}
switch (allocated.representation()) {
case MachineRepresentation::kNone:
os << "|-";
break;
case MachineRepresentation::kBit:
os << "|b";
break;
case MachineRepresentation::kWord8:
os << "|w8";
break;
case MachineRepresentation::kWord16:
os << "|w16";
break;
case MachineRepresentation::kWord32:
os << "|w32";
break;
......@@ -154,9 +166,6 @@ std::ostream& operator<<(std::ostream& os,
case MachineRepresentation::kTagged:
os << "|t";
break;
default:
os << "|?";
break;
}
return os << "]";
}
......@@ -718,7 +727,7 @@ static MachineRepresentation FilterRepresentation(MachineRepresentation rep) {
case MachineRepresentation::kFloat64:
case MachineRepresentation::kTagged:
return rep;
default:
case MachineRepresentation::kNone:
break;
}
UNREACHABLE();
......
......@@ -437,9 +437,14 @@ class LocationOperand : public InstructionOperand {
case MachineRepresentation::kFloat64:
case MachineRepresentation::kTagged:
return true;
default:
case MachineRepresentation::kBit:
case MachineRepresentation::kWord8:
case MachineRepresentation::kWord16:
case MachineRepresentation::kNone:
return false;
}
UNREACHABLE();
return false;
}
static LocationOperand* cast(InstructionOperand* op) {
......@@ -1150,13 +1155,7 @@ class InstructionSequence final : public ZoneObject {
MachineRepresentation::kTagged;
}
bool IsFloat(int virtual_register) const {
switch (GetRepresentation(virtual_register)) {
case MachineRepresentation::kFloat32:
case MachineRepresentation::kFloat64:
return true;
default:
return false;
}
return IsFloatingPoint(GetRepresentation(virtual_register));
}
Instruction* GetBlockStart(RpoNumber rpo) const;
......
......@@ -394,7 +394,8 @@ const Operator* MachineOperatorBuilder::Store(StoreRepresentation store_rep) {
break;
MACHINE_REPRESENTATION_LIST(STORE)
#undef STORE
default:
case MachineRepresentation::kBit:
case MachineRepresentation::kNone:
break;
}
UNREACHABLE();
......@@ -423,7 +424,8 @@ const Operator* MachineOperatorBuilder::CheckedStore(
return &cache_.kCheckedStore##kRep;
MACHINE_REPRESENTATION_LIST(STORE)
#undef STORE
default:
case MachineRepresentation::kBit:
case MachineRepresentation::kNone:
break;
}
UNREACHABLE();
......
......@@ -132,7 +132,7 @@ void InstructionSelector::VisitLoad(Node* node) {
Node* base = node->InputAt(0);
Node* index = node->InputAt(1);
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (load_rep.representation()) {
case MachineRepresentation::kFloat32:
opcode = kMipsLwc1;
......@@ -151,7 +151,8 @@ void InstructionSelector::VisitLoad(Node* node) {
case MachineRepresentation::kWord32:
opcode = kMipsLw;
break;
default:
case MachineRepresentation::kWord64: // Fall through.
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......@@ -211,7 +212,7 @@ void InstructionSelector::VisitStore(Node* node) {
code |= MiscField::encode(static_cast<int>(record_write_mode));
Emit(code, 0, nullptr, input_count, inputs, temp_count, temps);
} else {
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (rep) {
case MachineRepresentation::kFloat32:
opcode = kMipsSwc1;
......@@ -230,7 +231,8 @@ void InstructionSelector::VisitStore(Node* node) {
case MachineRepresentation::kWord32:
opcode = kMipsSw;
break;
default:
case MachineRepresentation::kWord64: // Fall through.
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......@@ -850,7 +852,7 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
Node* const buffer = node->InputAt(0);
Node* const offset = node->InputAt(1);
Node* const length = node->InputAt(2);
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (load_rep.representation()) {
case MachineRepresentation::kWord8:
opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8;
......@@ -867,7 +869,10 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
case MachineRepresentation::kFloat64:
opcode = kCheckedLoadFloat64;
break;
default:
case MachineRepresentation::kBit: // Fall through.
case MachineRepresentation::kTagged: // Fall through.
case MachineRepresentation::kWord64: // Fall through.
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......@@ -894,7 +899,7 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
Node* const offset = node->InputAt(1);
Node* const length = node->InputAt(2);
Node* const value = node->InputAt(3);
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (rep) {
case MachineRepresentation::kWord8:
opcode = kCheckedStoreWord8;
......
......@@ -137,7 +137,7 @@ void InstructionSelector::VisitLoad(Node* node) {
Node* base = node->InputAt(0);
Node* index = node->InputAt(1);
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (load_rep.representation()) {
case MachineRepresentation::kFloat32:
opcode = kMips64Lwc1;
......@@ -159,7 +159,7 @@ void InstructionSelector::VisitLoad(Node* node) {
case MachineRepresentation::kWord64:
opcode = kMips64Ld;
break;
default:
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......@@ -219,7 +219,7 @@ void InstructionSelector::VisitStore(Node* node) {
code |= MiscField::encode(static_cast<int>(record_write_mode));
Emit(code, 0, nullptr, input_count, inputs, temp_count, temps);
} else {
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (rep) {
case MachineRepresentation::kFloat32:
opcode = kMips64Swc1;
......@@ -241,7 +241,7 @@ void InstructionSelector::VisitStore(Node* node) {
case MachineRepresentation::kWord64:
opcode = kMips64Sd;
break;
default:
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......@@ -1285,7 +1285,7 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
Node* const buffer = node->InputAt(0);
Node* const offset = node->InputAt(1);
Node* const length = node->InputAt(2);
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (load_rep.representation()) {
case MachineRepresentation::kWord8:
opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8;
......@@ -1305,7 +1305,9 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
case MachineRepresentation::kFloat64:
opcode = kCheckedLoadFloat64;
break;
default:
case MachineRepresentation::kBit:
case MachineRepresentation::kTagged:
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......@@ -1332,7 +1334,7 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
Node* const offset = node->InputAt(1);
Node* const length = node->InputAt(2);
Node* const value = node->InputAt(3);
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (rep) {
case MachineRepresentation::kWord8:
opcode = kCheckedStoreWord8;
......@@ -1352,7 +1354,9 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
case MachineRepresentation::kFloat64:
opcode = kCheckedStoreFloat64;
break;
default:
case MachineRepresentation::kBit:
case MachineRepresentation::kTagged:
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......
......@@ -198,7 +198,10 @@ void InstructionSelector::VisitLoad(Node* node) {
mode = kInt16Imm_4ByteAligned;
break;
#endif
default:
#if !V8_TARGET_ARCH_PPC64
case MachineRepresentation::kWord64:
#endif
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......
......@@ -104,10 +104,11 @@ int GetByteWidth(MachineRepresentation rep) {
case MachineRepresentation::kWord64:
case MachineRepresentation::kFloat64:
return 8;
default:
UNREACHABLE();
return 0;
case MachineRepresentation::kNone:
break;
}
UNREACHABLE();
return 0;
}
} // namespace
......
......@@ -145,7 +145,7 @@ Node* RepresentationChanger::GetRepresentationFor(Node* node,
return GetWord32RepresentationFor(node, output_type);
case MachineRepresentation::kWord64:
return GetWord64RepresentationFor(node, output_type);
default:
case MachineRepresentation::kNone:
return node;
}
UNREACHABLE();
......
......@@ -184,8 +184,6 @@ bool MachineTypeIsSubtype(MachineSemantic t1, MachineSemantic t2) {
return t2 == MachineSemantic::kNumber || t2 == MachineSemantic::kAny;
case MachineSemantic::kAny:
return t2 == MachineSemantic::kAny;
default:
break;
}
UNREACHABLE();
return false;
......@@ -231,8 +229,6 @@ bool MachineRepresentationIsSubtype(MachineRepresentation r1,
r2 == MachineRepresentation::kTagged;
case MachineRepresentation::kTagged:
return r2 == MachineRepresentation::kTagged;
default:
break;
}
UNREACHABLE();
return false;
......
......@@ -111,7 +111,7 @@ void InstructionSelector::VisitLoad(Node* node) {
LoadRepresentation load_rep = LoadRepresentationOf(node->op());
X64OperandGenerator g(this);
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (load_rep.representation()) {
case MachineRepresentation::kFloat32:
opcode = kX64Movss;
......@@ -133,7 +133,7 @@ void InstructionSelector::VisitLoad(Node* node) {
case MachineRepresentation::kWord64:
opcode = kX64Movq;
break;
default:
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......@@ -197,7 +197,7 @@ void InstructionSelector::VisitStore(Node* node) {
code |= MiscField::encode(static_cast<int>(record_write_mode));
Emit(code, 0, nullptr, input_count, inputs, temp_count, temps);
} else {
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (rep) {
case MachineRepresentation::kFloat32:
opcode = kX64Movss;
......@@ -219,7 +219,7 @@ void InstructionSelector::VisitStore(Node* node) {
case MachineRepresentation::kWord64:
opcode = kX64Movq;
break;
default:
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......@@ -243,7 +243,7 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
Node* const buffer = node->InputAt(0);
Node* const offset = node->InputAt(1);
Node* const length = node->InputAt(2);
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (load_rep.representation()) {
case MachineRepresentation::kWord8:
opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8;
......@@ -263,7 +263,9 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
case MachineRepresentation::kFloat64:
opcode = kCheckedLoadFloat64;
break;
default:
case MachineRepresentation::kBit:
case MachineRepresentation::kTagged:
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......@@ -293,7 +295,7 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
Node* const offset = node->InputAt(1);
Node* const length = node->InputAt(2);
Node* const value = node->InputAt(3);
ArchOpcode opcode;
ArchOpcode opcode = kArchNop;
switch (rep) {
case MachineRepresentation::kWord8:
opcode = kCheckedStoreWord8;
......@@ -313,7 +315,9 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
case MachineRepresentation::kFloat64:
opcode = kCheckedStoreFloat64;
break;
default:
case MachineRepresentation::kBit:
case MachineRepresentation::kTagged:
case MachineRepresentation::kNone:
UNREACHABLE();
return;
}
......
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