Commit da7c5a73 authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

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

  port bb2a830d (r32738)

  original commit message:
  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.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#32778}
parent ed698f3d
...@@ -1264,22 +1264,22 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { ...@@ -1264,22 +1264,22 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
case kX87Push: case kX87Push:
if (instr->InputAt(0)->IsDoubleRegister()) { if (instr->InputAt(0)->IsDoubleRegister()) {
auto allocated = AllocatedOperand::cast(*instr->InputAt(0)); auto allocated = AllocatedOperand::cast(*instr->InputAt(0));
if (allocated.machine_type() == kRepFloat32) { if (allocated.representation() == MachineRepresentation::kFloat32) {
__ sub(esp, Immediate(kDoubleSize)); __ sub(esp, Immediate(kDoubleSize));
__ fst_s(Operand(esp, 0)); __ fst_s(Operand(esp, 0));
} else { } else {
DCHECK(allocated.machine_type() == kRepFloat64); DCHECK(allocated.representation() == MachineRepresentation::kFloat64);
__ sub(esp, Immediate(kDoubleSize)); __ sub(esp, Immediate(kDoubleSize));
__ fst_d(Operand(esp, 0)); __ fst_d(Operand(esp, 0));
} }
} else if (instr->InputAt(0)->IsDoubleStackSlot()) { } else if (instr->InputAt(0)->IsDoubleStackSlot()) {
auto allocated = AllocatedOperand::cast(*instr->InputAt(0)); auto allocated = AllocatedOperand::cast(*instr->InputAt(0));
if (allocated.machine_type() == kRepFloat32) { if (allocated.representation() == MachineRepresentation::kFloat32) {
__ sub(esp, Immediate(kDoubleSize)); __ sub(esp, Immediate(kDoubleSize));
__ fld_s(i.InputOperand(0)); __ fld_s(i.InputOperand(0));
__ fstp_s(MemOperand(esp, 0)); __ fstp_s(MemOperand(esp, 0));
} else { } else {
DCHECK(allocated.machine_type() == kRepFloat64); DCHECK(allocated.representation() == MachineRepresentation::kFloat64);
__ sub(esp, Immediate(kDoubleSize)); __ sub(esp, Immediate(kDoubleSize));
__ fld_d(i.InputOperand(0)); __ fld_d(i.InputOperand(0));
__ fstp_d(MemOperand(esp, 0)); __ fstp_d(MemOperand(esp, 0));
...@@ -1868,11 +1868,11 @@ void CodeGenerator::AssembleMove(InstructionOperand* source, ...@@ -1868,11 +1868,11 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
DCHECK(destination->IsDoubleStackSlot()); DCHECK(destination->IsDoubleStackSlot());
Operand dst = g.ToOperand(destination); Operand dst = g.ToOperand(destination);
auto allocated = AllocatedOperand::cast(*source); auto allocated = AllocatedOperand::cast(*source);
switch (allocated.machine_type()) { switch (allocated.representation()) {
case kRepFloat32: case MachineRepresentation::kFloat32:
__ fst_s(dst); __ fst_s(dst);
break; break;
case kRepFloat64: case MachineRepresentation::kFloat64:
__ fst_d(dst); __ fst_d(dst);
break; break;
default: default:
...@@ -1885,11 +1885,11 @@ void CodeGenerator::AssembleMove(InstructionOperand* source, ...@@ -1885,11 +1885,11 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
if (destination->IsDoubleRegister()) { if (destination->IsDoubleRegister()) {
// always only push one value into the x87 stack. // always only push one value into the x87 stack.
__ fstp(0); __ fstp(0);
switch (allocated.machine_type()) { switch (allocated.representation()) {
case kRepFloat32: case MachineRepresentation::kFloat32:
__ fld_s(src); __ fld_s(src);
break; break;
case kRepFloat64: case MachineRepresentation::kFloat64:
__ fld_d(src); __ fld_d(src);
break; break;
default: default:
...@@ -1897,12 +1897,12 @@ void CodeGenerator::AssembleMove(InstructionOperand* source, ...@@ -1897,12 +1897,12 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
} }
} else { } else {
Operand dst = g.ToOperand(destination); Operand dst = g.ToOperand(destination);
switch (allocated.machine_type()) { switch (allocated.representation()) {
case kRepFloat32: case MachineRepresentation::kFloat32:
__ fld_s(src); __ fld_s(src);
__ fstp_s(dst); __ fstp_s(dst);
break; break;
case kRepFloat64: case MachineRepresentation::kFloat64:
__ fld_d(src); __ fld_d(src);
__ fstp_d(dst); __ fstp_d(dst);
break; break;
...@@ -1945,13 +1945,13 @@ void CodeGenerator::AssembleSwap(InstructionOperand* source, ...@@ -1945,13 +1945,13 @@ void CodeGenerator::AssembleSwap(InstructionOperand* source,
UNREACHABLE(); UNREACHABLE();
} else if (source->IsDoubleRegister() && destination->IsDoubleStackSlot()) { } else if (source->IsDoubleRegister() && destination->IsDoubleStackSlot()) {
auto allocated = AllocatedOperand::cast(*source); auto allocated = AllocatedOperand::cast(*source);
switch (allocated.machine_type()) { switch (allocated.representation()) {
case kRepFloat32: case MachineRepresentation::kFloat32:
__ fld_s(g.ToOperand(destination)); __ fld_s(g.ToOperand(destination));
__ fxch(); __ fxch();
__ fstp_s(g.ToOperand(destination)); __ fstp_s(g.ToOperand(destination));
break; break;
case kRepFloat64: case MachineRepresentation::kFloat64:
__ fld_d(g.ToOperand(destination)); __ fld_d(g.ToOperand(destination));
__ fxch(); __ fxch();
__ fstp_d(g.ToOperand(destination)); __ fstp_d(g.ToOperand(destination));
...@@ -1961,14 +1961,14 @@ void CodeGenerator::AssembleSwap(InstructionOperand* source, ...@@ -1961,14 +1961,14 @@ void CodeGenerator::AssembleSwap(InstructionOperand* source,
} }
} else if (source->IsDoubleStackSlot() && destination->IsDoubleStackSlot()) { } else if (source->IsDoubleStackSlot() && destination->IsDoubleStackSlot()) {
auto allocated = AllocatedOperand::cast(*source); auto allocated = AllocatedOperand::cast(*source);
switch (allocated.machine_type()) { switch (allocated.representation()) {
case kRepFloat32: case MachineRepresentation::kFloat32:
__ fld_s(g.ToOperand(source)); __ fld_s(g.ToOperand(source));
__ fld_s(g.ToOperand(destination)); __ fld_s(g.ToOperand(destination));
__ fstp_s(g.ToOperand(source)); __ fstp_s(g.ToOperand(source));
__ fstp_s(g.ToOperand(destination)); __ fstp_s(g.ToOperand(destination));
break; break;
case kRepFloat64: case MachineRepresentation::kFloat64:
__ fld_d(g.ToOperand(source)); __ fld_d(g.ToOperand(source));
__ fld_d(g.ToOperand(destination)); __ fld_d(g.ToOperand(destination));
__ fstp_d(g.ToOperand(source)); __ fstp_d(g.ToOperand(source));
......
...@@ -130,26 +130,25 @@ class X87OperandGenerator final : public OperandGenerator { ...@@ -130,26 +130,25 @@ class X87OperandGenerator final : public OperandGenerator {
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));
ArchOpcode opcode; ArchOpcode opcode;
switch (rep) { switch (load_rep.representation()) {
case kRepFloat32: case MachineRepresentation::kFloat32:
opcode = kX87Movss; opcode = kX87Movss;
break; break;
case kRepFloat64: case MachineRepresentation::kFloat64:
opcode = kX87Movsd; opcode = kX87Movsd;
break; break;
case kRepBit: // Fall through. case MachineRepresentation::kBit: // Fall through.
case kRepWord8: case MachineRepresentation::kWord8:
opcode = typ == kTypeInt32 ? kX87Movsxbl : kX87Movzxbl; opcode = load_rep.IsSigned() ? kX87Movsxbl : kX87Movzxbl;
break; break;
case kRepWord16: case MachineRepresentation::kWord16:
opcode = typ == kTypeInt32 ? kX87Movsxwl : kX87Movzxwl; opcode = load_rep.IsSigned() ? kX87Movsxwl : kX87Movzxwl;
break; break;
case kRepTagged: // Fall through. case MachineRepresentation::kTagged: // Fall through.
case kRepWord32: case MachineRepresentation::kWord32:
opcode = kX87Movl; opcode = kX87Movl;
break; break;
default: default:
...@@ -177,10 +176,10 @@ void InstructionSelector::VisitStore(Node* node) { ...@@ -177,10 +176,10 @@ void InstructionSelector::VisitStore(Node* node) {
StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node);
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.machine_type().representation();
if (write_barrier_kind != kNoWriteBarrier) { if (write_barrier_kind != kNoWriteBarrier) {
DCHECK_EQ(kRepTagged, rep); DCHECK_EQ(MachineRepresentation::kTagged, rep);
AddressingMode addressing_mode; AddressingMode addressing_mode;
InstructionOperand inputs[3]; InstructionOperand inputs[3];
size_t input_count = 0; size_t input_count = 0;
...@@ -219,21 +218,21 @@ void InstructionSelector::VisitStore(Node* node) { ...@@ -219,21 +218,21 @@ void InstructionSelector::VisitStore(Node* node) {
} else { } else {
ArchOpcode opcode; ArchOpcode opcode;
switch (rep) { switch (rep) {
case kRepFloat32: case MachineRepresentation::kFloat32:
opcode = kX87Movss; opcode = kX87Movss;
break; break;
case kRepFloat64: case MachineRepresentation::kFloat64:
opcode = kX87Movsd; opcode = kX87Movsd;
break; break;
case kRepBit: // Fall through. case MachineRepresentation::kBit: // Fall through.
case kRepWord8: case MachineRepresentation::kWord8:
opcode = kX87Movb; opcode = kX87Movb;
break; break;
case kRepWord16: case MachineRepresentation::kWord16:
opcode = kX87Movw; opcode = kX87Movw;
break; break;
case kRepTagged: // Fall through. case MachineRepresentation::kTagged: // Fall through.
case kRepWord32: case MachineRepresentation::kWord32:
opcode = kX87Movl; opcode = kX87Movl;
break; break;
default: default:
...@@ -244,7 +243,8 @@ void InstructionSelector::VisitStore(Node* node) { ...@@ -244,7 +243,8 @@ void InstructionSelector::VisitStore(Node* node) {
InstructionOperand val; InstructionOperand val;
if (g.CanBeImmediate(value)) { if (g.CanBeImmediate(value)) {
val = g.UseImmediate(value); val = g.UseImmediate(value);
} else if (rep == kRepWord8 || rep == kRepBit) { } else if (rep == MachineRepresentation::kWord8 ||
rep == MachineRepresentation::kBit) {
val = g.UseByteRegister(value); val = g.UseByteRegister(value);
} else { } else {
val = g.UseRegister(value); val = g.UseRegister(value);
...@@ -263,27 +263,26 @@ void InstructionSelector::VisitStore(Node* node) { ...@@ -263,27 +263,26 @@ 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));
X87OperandGenerator g(this); X87OperandGenerator g(this);
Node* const buffer = node->InputAt(0); Node* const buffer = 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 kRepFloat32: case MachineRepresentation::kFloat32:
opcode = kCheckedLoadFloat32; opcode = kCheckedLoadFloat32;
break; break;
case kRepFloat64: case MachineRepresentation::kFloat64:
opcode = kCheckedLoadFloat64; opcode = kCheckedLoadFloat64;
break; break;
default: default:
...@@ -306,7 +305,8 @@ void InstructionSelector::VisitCheckedLoad(Node* node) { ...@@ -306,7 +305,8 @@ 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()).representation();
X87OperandGenerator g(this); X87OperandGenerator g(this);
Node* const buffer = node->InputAt(0); Node* const buffer = node->InputAt(0);
Node* const offset = node->InputAt(1); Node* const offset = node->InputAt(1);
...@@ -314,19 +314,19 @@ void InstructionSelector::VisitCheckedStore(Node* node) { ...@@ -314,19 +314,19 @@ 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 kRepFloat32: case MachineRepresentation::kFloat32:
opcode = kCheckedStoreFloat32; opcode = kCheckedStoreFloat32;
break; break;
case kRepFloat64: case MachineRepresentation::kFloat64:
opcode = kCheckedStoreFloat64; opcode = kCheckedStoreFloat64;
break; break;
default: default:
...@@ -334,9 +334,10 @@ void InstructionSelector::VisitCheckedStore(Node* node) { ...@@ -334,9 +334,10 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
return; return;
} }
InstructionOperand value_operand = InstructionOperand value_operand =
g.CanBeImmediate(value) g.CanBeImmediate(value) ? g.UseImmediate(value)
? g.UseImmediate(value) : ((rep == MachineRepresentation::kWord8 ||
: ((rep == kRepWord8 || rep == kRepBit) ? g.UseByteRegister(value) rep == MachineRepresentation::kBit)
? g.UseByteRegister(value)
: g.UseRegister(value)); : g.UseRegister(value));
InstructionOperand offset_operand = g.UseRegister(offset); InstructionOperand offset_operand = g.UseRegister(offset);
InstructionOperand length_operand = InstructionOperand length_operand =
......
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