Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Unified Diff: src/compiler/mips64/instruction-selector-mips64.cc

Issue 732403002: MIPS64: Add turbofan support for mips64. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments and code cleanup. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/mips64/instruction-codes-mips64.h ('k') | src/compiler/mips64/linkage-mips64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/mips64/instruction-selector-mips64.cc
diff --git a/src/compiler/mips/instruction-selector-mips.cc b/src/compiler/mips64/instruction-selector-mips64.cc
similarity index 55%
copy from src/compiler/mips/instruction-selector-mips.cc
copy to src/compiler/mips64/instruction-selector-mips64.cc
index 4862e986046f16bae1a7893d9bdb37adfef76349..f1a585d0596e1df6044fd6ca106746c9e4aacbc6 100644
--- a/src/compiler/mips/instruction-selector-mips.cc
+++ b/src/compiler/mips64/instruction-selector-mips64.cc
@@ -17,9 +17,9 @@ namespace compiler {
// Adds Mips-specific methods for generating InstructionOperands.
-class MipsOperandGenerator FINAL : public OperandGenerator {
+class Mips64OperandGenerator FINAL : public OperandGenerator {
public:
- explicit MipsOperandGenerator(InstructionSelector* selector)
+ explicit Mips64OperandGenerator(InstructionSelector* selector)
: OperandGenerator(selector) {}
InstructionOperand* UseOperand(Node* node, InstructionCode opcode) {
@@ -30,24 +30,61 @@ class MipsOperandGenerator FINAL : public OperandGenerator {
}
bool CanBeImmediate(Node* node, InstructionCode opcode) {
- Int32Matcher m(node);
- if (!m.HasValue()) return false;
- int32_t value = m.Value();
+ int64_t value;
+ if (node->opcode() == IrOpcode::kInt32Constant)
+ value = OpParameter<int32_t>(node);
+ else if (node->opcode() == IrOpcode::kInt64Constant)
+ value = OpParameter<int64_t>(node);
+ else
+ return false;
switch (ArchOpcodeField::decode(opcode)) {
- case kMipsShl:
- case kMipsSar:
- case kMipsShr:
+ case kMips64Shl:
+ case kMips64Sar:
+ case kMips64Shr:
return is_uint5(value);
- case kMipsXor:
+ case kMips64Dshl:
+ case kMips64Dsar:
+ case kMips64Dshr:
+ return is_uint6(value);
+ case kMips64Xor:
return is_uint16(value);
- case kMipsLdc1:
- case kMipsSdc1:
+ case kMips64Ldc1:
+ case kMips64Sdc1:
return is_int16(value + kIntSize);
default:
return is_int16(value);
}
}
+
+ bool CanBeImmediate(Node* node, InstructionCode opcode,
+ FlagsContinuation* cont) {
+ int64_t value;
+ if (node->opcode() == IrOpcode::kInt32Constant)
+ value = OpParameter<int32_t>(node);
+ else if (node->opcode() == IrOpcode::kInt64Constant)
+ value = OpParameter<int64_t>(node);
+ else
+ return false;
+ switch (ArchOpcodeField::decode(opcode)) {
+ case kMips64Cmp32:
+ switch (cont->condition()) {
+ case kUnsignedLessThan:
+ case kUnsignedGreaterThanOrEqual:
+ case kUnsignedLessThanOrEqual:
+ case kUnsignedGreaterThan:
+ // Immediate operands for unsigned 32-bit compare operations
+ // should not be sign-extended.
+ return is_uint15(value);
+ default:
+ return false;
+ }
+ default:
+ return is_int16(value);
+ }
+ }
+
+
private:
bool ImmediateFitsAddrMode1Instruction(int32_t imm) const {
TRACE_UNIMPL();
@@ -56,9 +93,17 @@ class MipsOperandGenerator FINAL : public OperandGenerator {
};
+static void VisitRR(InstructionSelector* selector, ArchOpcode opcode,
+ Node* node) {
+ Mips64OperandGenerator g(selector);
+ selector->Emit(opcode, g.DefineAsRegister(node),
+ g.UseRegister(node->InputAt(0)));
+}
+
+
static void VisitRRR(InstructionSelector* selector, ArchOpcode opcode,
Node* node) {
- MipsOperandGenerator g(selector);
+ Mips64OperandGenerator g(selector);
selector->Emit(opcode, g.DefineAsRegister(node),
g.UseRegister(node->InputAt(0)),
g.UseRegister(node->InputAt(1)));
@@ -67,7 +112,7 @@ static void VisitRRR(InstructionSelector* selector, ArchOpcode opcode,
static void VisitRRO(InstructionSelector* selector, ArchOpcode opcode,
Node* node) {
- MipsOperandGenerator g(selector);
+ Mips64OperandGenerator g(selector);
selector->Emit(opcode, g.DefineAsRegister(node),
g.UseRegister(node->InputAt(0)),
g.UseOperand(node->InputAt(1), opcode));
@@ -76,7 +121,7 @@ static void VisitRRO(InstructionSelector* selector, ArchOpcode opcode,
static void VisitBinop(InstructionSelector* selector, Node* node,
InstructionCode opcode, FlagsContinuation* cont) {
- MipsOperandGenerator g(selector);
+ Mips64OperandGenerator g(selector);
Int32BinopMatcher m(node);
InstructionOperand* inputs[4];
size_t input_count = 0;
@@ -117,28 +162,31 @@ static void VisitBinop(InstructionSelector* selector, Node* node,
void InstructionSelector::VisitLoad(Node* node) {
MachineType rep = RepresentationOf(OpParameter<LoadRepresentation>(node));
MachineType typ = TypeOf(OpParameter<LoadRepresentation>(node));
- MipsOperandGenerator g(this);
+ Mips64OperandGenerator g(this);
Node* base = node->InputAt(0);
Node* index = node->InputAt(1);
ArchOpcode opcode;
switch (rep) {
case kRepFloat32:
- opcode = kMipsLwc1;
+ opcode = kMips64Lwc1;
break;
case kRepFloat64:
- opcode = kMipsLdc1;
+ opcode = kMips64Ldc1;
break;
case kRepBit: // Fall through.
case kRepWord8:
- opcode = typ == kTypeUint32 ? kMipsLbu : kMipsLb;
+ opcode = typ == kTypeUint32 ? kMips64Lbu : kMips64Lb;
break;
case kRepWord16:
- opcode = typ == kTypeUint32 ? kMipsLhu : kMipsLh;
+ opcode = typ == kTypeUint32 ? kMips64Lhu : kMips64Lh;
break;
- case kRepTagged: // Fall through.
case kRepWord32:
- opcode = kMipsLw;
+ opcode = kMips64Lw;
+ break;
+ case kRepTagged: // Fall through.
+ case kRepWord64:
+ opcode = kMips64Ld;
break;
default:
UNREACHABLE();
@@ -150,7 +198,7 @@ void InstructionSelector::VisitLoad(Node* node) {
g.DefineAsRegister(node), g.UseRegister(base), g.UseImmediate(index));
} else {
InstructionOperand* addr_reg = g.TempRegister();
- Emit(kMipsAdd | AddressingModeField::encode(kMode_None), addr_reg,
+ Emit(kMips64Dadd | AddressingModeField::encode(kMode_None), addr_reg,
g.UseRegister(index), g.UseRegister(base));
// Emit desired load opcode, using temp addr_reg.
Emit(opcode | AddressingModeField::encode(kMode_MRI),
@@ -160,7 +208,7 @@ void InstructionSelector::VisitLoad(Node* node) {
void InstructionSelector::VisitStore(Node* node) {
- MipsOperandGenerator g(this);
+ Mips64OperandGenerator g(this);
Node* base = node->InputAt(0);
Node* index = node->InputAt(1);
Node* value = node->InputAt(2);
@@ -173,7 +221,7 @@ void InstructionSelector::VisitStore(Node* node) {
// and pass them here instead of using fixed regs
// TODO(dcarney): handle immediate indices.
InstructionOperand* temps[] = {g.TempRegister(t1), g.TempRegister(t2)};
- Emit(kMipsStoreWriteBarrier, NULL, g.UseFixed(base, t0),
+ Emit(kMips64StoreWriteBarrier, NULL, g.UseFixed(base, t0),
g.UseFixed(index, t1), g.UseFixed(value, t2), arraysize(temps), temps);
return;
}
@@ -182,21 +230,24 @@ void InstructionSelector::VisitStore(Node* node) {
ArchOpcode opcode;
switch (rep) {
case kRepFloat32:
- opcode = kMipsSwc1;
+ opcode = kMips64Swc1;
break;
case kRepFloat64:
- opcode = kMipsSdc1;
+ opcode = kMips64Sdc1;
break;
case kRepBit: // Fall through.
case kRepWord8:
- opcode = kMipsSb;
+ opcode = kMips64Sb;
break;
case kRepWord16:
- opcode = kMipsSh;
+ opcode = kMips64Sh;
break;
- case kRepTagged: // Fall through.
case kRepWord32:
- opcode = kMipsSw;
+ opcode = kMips64Sw;
+ break;
+ case kRepTagged: // Fall through.
+ case kRepWord64:
+ opcode = kMips64Sd;
break;
default:
UNREACHABLE();
@@ -208,7 +259,7 @@ void InstructionSelector::VisitStore(Node* node) {
g.UseRegister(base), g.UseImmediate(index), g.UseRegister(value));
} else {
InstructionOperand* addr_reg = g.TempRegister();
- Emit(kMipsAdd | AddressingModeField::encode(kMode_None), addr_reg,
+ Emit(kMips64Dadd | AddressingModeField::encode(kMode_None), addr_reg,
g.UseRegister(index), g.UseRegister(base));
// Emit desired store opcode, using temp addr_reg.
Emit(opcode | AddressingModeField::encode(kMode_MRI), NULL, addr_reg,
@@ -218,212 +269,357 @@ void InstructionSelector::VisitStore(Node* node) {
void InstructionSelector::VisitWord32And(Node* node) {
- VisitBinop(this, node, kMipsAnd);
+ VisitBinop(this, node, kMips64And);
+}
+
+
+void InstructionSelector::VisitWord64And(Node* node) {
+ VisitBinop(this, node, kMips64And);
}
void InstructionSelector::VisitWord32Or(Node* node) {
- VisitBinop(this, node, kMipsOr);
+ VisitBinop(this, node, kMips64Or);
+}
+
+
+void InstructionSelector::VisitWord64Or(Node* node) {
+ VisitBinop(this, node, kMips64Or);
}
void InstructionSelector::VisitWord32Xor(Node* node) {
- VisitBinop(this, node, kMipsXor);
+ VisitBinop(this, node, kMips64Xor);
+}
+
+
+void InstructionSelector::VisitWord64Xor(Node* node) {
+ VisitBinop(this, node, kMips64Xor);
}
void InstructionSelector::VisitWord32Shl(Node* node) {
- VisitRRO(this, kMipsShl, node);
+ VisitRRO(this, kMips64Shl, node);
}
void InstructionSelector::VisitWord32Shr(Node* node) {
- VisitRRO(this, kMipsShr, node);
+ VisitRRO(this, kMips64Shr, node);
}
void InstructionSelector::VisitWord32Sar(Node* node) {
- VisitRRO(this, kMipsSar, node);
+ VisitRRO(this, kMips64Sar, node);
+}
+
+
+void InstructionSelector::VisitWord64Shl(Node* node) {
+ VisitRRO(this, kMips64Dshl, node);
+}
+
+
+void InstructionSelector::VisitWord64Shr(Node* node) {
+ VisitRRO(this, kMips64Dshr, node);
+}
+
+
+void InstructionSelector::VisitWord64Sar(Node* node) {
+ VisitRRO(this, kMips64Dsar, node);
}
void InstructionSelector::VisitWord32Ror(Node* node) {
- VisitRRO(this, kMipsRor, node);
+ VisitRRO(this, kMips64Ror, node);
+}
+
+
+void InstructionSelector::VisitWord64Ror(Node* node) {
+ VisitRRO(this, kMips64Dror, node);
}
void InstructionSelector::VisitInt32Add(Node* node) {
- MipsOperandGenerator g(this);
+ Mips64OperandGenerator g(this);
+ // TODO(plind): Consider multiply & add optimization from arm port.
+ VisitBinop(this, node, kMips64Add);
+}
+
+void InstructionSelector::VisitInt64Add(Node* node) {
+ Mips64OperandGenerator g(this);
// TODO(plind): Consider multiply & add optimization from arm port.
- VisitBinop(this, node, kMipsAdd);
+ VisitBinop(this, node, kMips64Dadd);
}
void InstructionSelector::VisitInt32Sub(Node* node) {
- VisitBinop(this, node, kMipsSub);
+ VisitBinop(this, node, kMips64Sub);
+}
+
+
+void InstructionSelector::VisitInt64Sub(Node* node) {
+ VisitBinop(this, node, kMips64Dsub);
}
void InstructionSelector::VisitInt32Mul(Node* node) {
- MipsOperandGenerator g(this);
+ Mips64OperandGenerator g(this);
Int32BinopMatcher m(node);
if (m.right().HasValue() && m.right().Value() > 0) {
int32_t value = m.right().Value();
if (base::bits::IsPowerOfTwo32(value)) {
- Emit(kMipsShl | AddressingModeField::encode(kMode_None),
+ Emit(kMips64Shl | AddressingModeField::encode(kMode_None),
g.DefineAsRegister(node), g.UseRegister(m.left().node()),
g.TempImmediate(WhichPowerOf2(value)));
return;
}
if (base::bits::IsPowerOfTwo32(value - 1)) {
InstructionOperand* temp = g.TempRegister();
- Emit(kMipsShl | AddressingModeField::encode(kMode_None), temp,
+ Emit(kMips64Shl | AddressingModeField::encode(kMode_None), temp,
g.UseRegister(m.left().node()),
g.TempImmediate(WhichPowerOf2(value - 1)));
- Emit(kMipsAdd | AddressingModeField::encode(kMode_None),
+ Emit(kMips64Add | AddressingModeField::encode(kMode_None),
g.DefineAsRegister(node), g.UseRegister(m.left().node()), temp);
return;
}
if (base::bits::IsPowerOfTwo32(value + 1)) {
InstructionOperand* temp = g.TempRegister();
- Emit(kMipsShl | AddressingModeField::encode(kMode_None), temp,
+ Emit(kMips64Shl | AddressingModeField::encode(kMode_None), temp,
g.UseRegister(m.left().node()),
g.TempImmediate(WhichPowerOf2(value + 1)));
- Emit(kMipsSub | AddressingModeField::encode(kMode_None),
+ Emit(kMips64Sub | AddressingModeField::encode(kMode_None),
g.DefineAsRegister(node), temp, g.UseRegister(m.left().node()));
return;
}
}
- Emit(kMipsMul, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
+ Emit(kMips64Mul, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
g.UseRegister(m.right().node()));
}
void InstructionSelector::VisitInt32MulHigh(Node* node) {
- MipsOperandGenerator g(this);
- Emit(kMipsMulHigh, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)),
- g.UseRegister(node->InputAt(1)));
+ Mips64OperandGenerator g(this);
+ Emit(kMips64MulHigh, g.DefineAsRegister(node),
+ g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1)));
}
void InstructionSelector::VisitUint32MulHigh(Node* node) {
- MipsOperandGenerator g(this);
- Emit(kMipsMulHighU, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)),
+ Mips64OperandGenerator g(this);
+ InstructionOperand* const dmul_operand = g.TempRegister();
+ Emit(kMips64MulHighU, dmul_operand, g.UseRegister(node->InputAt(0)),
g.UseRegister(node->InputAt(1)));
+ Emit(kMips64Ext, g.DefineAsRegister(node), dmul_operand, g.TempImmediate(0),
+ g.TempImmediate(32));
+}
+
+
+void InstructionSelector::VisitInt64Mul(Node* node) {
+ Mips64OperandGenerator g(this);
+ Int64BinopMatcher m(node);
+ // TODO(dusmil): Add optimization for shifts larger than 32.
+ if (m.right().HasValue() && m.right().Value() > 0) {
+ int64_t value = m.right().Value();
+ if (base::bits::IsPowerOfTwo32(value)) {
+ Emit(kMips64Dshl | AddressingModeField::encode(kMode_None),
+ g.DefineAsRegister(node), g.UseRegister(m.left().node()),
+ g.TempImmediate(WhichPowerOf2(value)));
+ return;
+ }
+ if (base::bits::IsPowerOfTwo32(value - 1)) {
+ InstructionOperand* temp = g.TempRegister();
+ Emit(kMips64Dshl | AddressingModeField::encode(kMode_None), temp,
+ g.UseRegister(m.left().node()),
+ g.TempImmediate(WhichPowerOf2(value - 1)));
+ Emit(kMips64Dadd | AddressingModeField::encode(kMode_None),
+ g.DefineAsRegister(node), g.UseRegister(m.left().node()), temp);
+ return;
+ }
+ if (base::bits::IsPowerOfTwo32(value + 1)) {
+ InstructionOperand* temp = g.TempRegister();
+ Emit(kMips64Dshl | AddressingModeField::encode(kMode_None), temp,
+ g.UseRegister(m.left().node()),
+ g.TempImmediate(WhichPowerOf2(value + 1)));
+ Emit(kMips64Dsub | AddressingModeField::encode(kMode_None),
+ g.DefineAsRegister(node), temp, g.UseRegister(m.left().node()));
+ return;
+ }
+ }
+ Emit(kMips64Dmul, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
+ g.UseRegister(m.right().node()));
}
void InstructionSelector::VisitInt32Div(Node* node) {
- MipsOperandGenerator g(this);
+ Mips64OperandGenerator g(this);
Int32BinopMatcher m(node);
- Emit(kMipsDiv, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
+ Emit(kMips64Div, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
g.UseRegister(m.right().node()));
}
void InstructionSelector::VisitUint32Div(Node* node) {
- MipsOperandGenerator g(this);
+ Mips64OperandGenerator g(this);
Int32BinopMatcher m(node);
- Emit(kMipsDivU, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
+ Emit(kMips64DivU, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
g.UseRegister(m.right().node()));
}
void InstructionSelector::VisitInt32Mod(Node* node) {
- MipsOperandGenerator g(this);
+ Mips64OperandGenerator g(this);
Int32BinopMatcher m(node);
- Emit(kMipsMod, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
+ Emit(kMips64Mod, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
g.UseRegister(m.right().node()));
}
void InstructionSelector::VisitUint32Mod(Node* node) {
- MipsOperandGenerator g(this);
+ Mips64OperandGenerator g(this);
Int32BinopMatcher m(node);
- Emit(kMipsModU, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
+ Emit(kMips64ModU, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
+ g.UseRegister(m.right().node()));
+}
+
+
+void InstructionSelector::VisitInt64Div(Node* node) {
+ Mips64OperandGenerator g(this);
+ Int64BinopMatcher m(node);
+ Emit(kMips64Ddiv, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
+ g.UseRegister(m.right().node()));
+}
+
+
+void InstructionSelector::VisitUint64Div(Node* node) {
+ Mips64OperandGenerator g(this);
+ Int64BinopMatcher m(node);
+ Emit(kMips64DdivU, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
+ g.UseRegister(m.right().node()));
+}
+
+
+void InstructionSelector::VisitInt64Mod(Node* node) {
+ Mips64OperandGenerator g(this);
+ Int64BinopMatcher m(node);
+ Emit(kMips64Dmod, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
+ g.UseRegister(m.right().node()));
+}
+
+
+void InstructionSelector::VisitUint64Mod(Node* node) {
+ Mips64OperandGenerator g(this);
+ Int64BinopMatcher m(node);
+ Emit(kMips64DmodU, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
g.UseRegister(m.right().node()));
}
void InstructionSelector::VisitChangeFloat32ToFloat64(Node* node) {
- MipsOperandGenerator g(this);
- Emit(kMipsCvtDS, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)));
+ Mips64OperandGenerator g(this);
+ Emit(kMips64CvtDS, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)));
}
void InstructionSelector::VisitChangeInt32ToFloat64(Node* node) {
- MipsOperandGenerator g(this);
- Emit(kMipsCvtDW, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)));
+ Mips64OperandGenerator g(this);
+ Emit(kMips64CvtDW, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)));
}
void InstructionSelector::VisitChangeUint32ToFloat64(Node* node) {
- MipsOperandGenerator g(this);
- Emit(kMipsCvtDUw, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)));
+ Mips64OperandGenerator g(this);
+ Emit(kMips64CvtDUw, g.DefineAsRegister(node),
+ g.UseRegister(node->InputAt(0)));
}
void InstructionSelector::VisitChangeFloat64ToInt32(Node* node) {
- MipsOperandGenerator g(this);
- Emit(kMipsTruncWD, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)));
+ Mips64OperandGenerator g(this);
+ Emit(kMips64TruncWD, g.DefineAsRegister(node),
+ g.UseRegister(node->InputAt(0)));
}
void InstructionSelector::VisitChangeFloat64ToUint32(Node* node) {
- MipsOperandGenerator g(this);
- Emit(kMipsTruncUwD, g.DefineAsRegister(node),
+ Mips64OperandGenerator g(this);
+ Emit(kMips64TruncUwD, g.DefineAsRegister(node),
g.UseRegister(node->InputAt(0)));
}
+void InstructionSelector::VisitChangeInt32ToInt64(Node* node) {
+ Mips64OperandGenerator g(this);
+ Emit(kMips64Shl, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)),
+ g.TempImmediate(0));
+}
+
+
+void InstructionSelector::VisitChangeUint32ToUint64(Node* node) {
+ Mips64OperandGenerator g(this);
+ Emit(kMips64Dext, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)),
+ g.TempImmediate(0), g.TempImmediate(32));
+}
+
+
+void InstructionSelector::VisitTruncateInt64ToInt32(Node* node) {
+ Mips64OperandGenerator g(this);
+ Emit(kMips64Ext, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)),
+ g.TempImmediate(0), g.TempImmediate(32));
+}
+
+
void InstructionSelector::VisitTruncateFloat64ToFloat32(Node* node) {
- MipsOperandGenerator g(this);
- Emit(kMipsCvtSD, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)));
+ Mips64OperandGenerator g(this);
+ Emit(kMips64CvtSD, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)));
}
void InstructionSelector::VisitFloat64Add(Node* node) {
- VisitRRR(this, kMipsAddD, node);
+ VisitRRR(this, kMips64AddD, node);
}
void InstructionSelector::VisitFloat64Sub(Node* node) {
- VisitRRR(this, kMipsSubD, node);
+ VisitRRR(this, kMips64SubD, node);
}
void InstructionSelector::VisitFloat64Mul(Node* node) {
- VisitRRR(this, kMipsMulD, node);
+ VisitRRR(this, kMips64MulD, node);
}
void InstructionSelector::VisitFloat64Div(Node* node) {
- VisitRRR(this, kMipsDivD, node);
+ VisitRRR(this, kMips64DivD, node);
}
void InstructionSelector::VisitFloat64Mod(Node* node) {
- MipsOperandGenerator g(this);
- Emit(kMipsModD, g.DefineAsFixed(node, f0), g.UseFixed(node->InputAt(0), f12),
+ Mips64OperandGenerator g(this);
+ Emit(kMips64ModD, g.DefineAsFixed(node, f0),
+ g.UseFixed(node->InputAt(0), f12),
g.UseFixed(node->InputAt(1), f14))->MarkAsCall();
}
void InstructionSelector::VisitFloat64Sqrt(Node* node) {
- MipsOperandGenerator g(this);
- Emit(kMipsSqrtD, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)));
+ Mips64OperandGenerator g(this);
+ Emit(kMips64SqrtD, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)));
}
-void InstructionSelector::VisitFloat64Floor(Node* node) { UNREACHABLE(); }
+void InstructionSelector::VisitFloat64Floor(Node* node) {
+ VisitRR(this, kMips64FloorD, node);
+}
-void InstructionSelector::VisitFloat64Ceil(Node* node) { UNREACHABLE(); }
+void InstructionSelector::VisitFloat64Ceil(Node* node) {
+ VisitRR(this, kMips64CeilD, node);
+}
void InstructionSelector::VisitFloat64RoundTruncate(Node* node) {
- UNREACHABLE();
+ VisitRR(this, kMips64RoundTruncateD, node);
}
@@ -433,7 +629,7 @@ void InstructionSelector::VisitFloat64RoundTiesAway(Node* node) {
void InstructionSelector::VisitCall(Node* node) {
- MipsOperandGenerator g(this);
+ Mips64OperandGenerator g(this);
CallDescriptor* descriptor = OpParameter<CallDescriptor*>(node);
FrameStateDescriptor* frame_state_descriptor = NULL;
@@ -454,7 +650,7 @@ void InstructionSelector::VisitCall(Node* node) {
// TODO(plind): inefficient for MIPS, use MultiPush here.
// - Also need to align the stack. See arm64.
// - Maybe combine with arg slot stuff in DirectCEntry stub.
- Emit(kMipsPush, NULL, g.UseRegister(*input));
+ Emit(kMips64Push, NULL, g.UseRegister(*input));
}
// Select the appropriate opcode based on the call type.
@@ -474,11 +670,10 @@ void InstructionSelector::VisitCall(Node* node) {
opcode |= MiscField::encode(descriptor->flags());
// Emit the call instruction.
- InstructionOperand** first_output =
- buffer.outputs.size() > 0 ? &buffer.outputs.front() : NULL;
Instruction* call_instr =
- Emit(opcode, buffer.outputs.size(), first_output,
+ Emit(opcode, buffer.outputs.size(), &buffer.outputs.front(),
buffer.instruction_args.size(), &buffer.instruction_args.front());
+
call_instr->MarkAsCall();
}
@@ -489,14 +684,13 @@ namespace {
static void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
InstructionOperand* left, InstructionOperand* right,
FlagsContinuation* cont) {
- MipsOperandGenerator g(selector);
+ Mips64OperandGenerator g(selector);
opcode = cont->Encode(opcode);
if (cont->IsBranch()) {
selector->Emit(opcode, NULL, left, right, g.Label(cont->true_block()),
g.Label(cont->false_block()))->MarkAsControl();
} else {
DCHECK(cont->IsSet());
- // TODO(plind): Revisit and test this path.
selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right);
}
}
@@ -505,10 +699,10 @@ static void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
// Shared routine for multiple float compare operations.
void VisitFloat64Compare(InstructionSelector* selector, Node* node,
FlagsContinuation* cont) {
- MipsOperandGenerator g(selector);
+ Mips64OperandGenerator g(selector);
Node* left = node->InputAt(0);
Node* right = node->InputAt(1);
- VisitCompare(selector, kMipsCmpD, g.UseRegister(left), g.UseRegister(right),
+ VisitCompare(selector, kMips64CmpD, g.UseRegister(left), g.UseRegister(right),
cont);
}
@@ -517,15 +711,15 @@ void VisitFloat64Compare(InstructionSelector* selector, Node* node,
void VisitWordCompare(InstructionSelector* selector, Node* node,
InstructionCode opcode, FlagsContinuation* cont,
bool commutative) {
- MipsOperandGenerator g(selector);
+ Mips64OperandGenerator g(selector);
Node* left = node->InputAt(0);
Node* right = node->InputAt(1);
// Match immediates on left or right side of comparison.
- if (g.CanBeImmediate(right, opcode)) {
+ if (g.CanBeImmediate(right, opcode, cont)) {
VisitCompare(selector, opcode, g.UseRegister(left), g.UseImmediate(right),
cont);
- } else if (g.CanBeImmediate(left, opcode)) {
+ } else if (g.CanBeImmediate(left, opcode, cont)) {
if (!commutative) cont->Commute();
VisitCompare(selector, opcode, g.UseRegister(right), g.UseImmediate(left),
cont);
@@ -536,18 +730,46 @@ void VisitWordCompare(InstructionSelector* selector, Node* node,
}
-void VisitWordCompare(InstructionSelector* selector, Node* node,
- FlagsContinuation* cont) {
- VisitWordCompare(selector, node, kMipsCmp, cont, false);
+void VisitWord32Compare(InstructionSelector* selector, Node* node,
+ FlagsContinuation* cont) {
+ VisitWordCompare(selector, node, kMips64Cmp32, cont, false);
+}
+
+
+void VisitWord64Compare(InstructionSelector* selector, Node* node,
+ FlagsContinuation* cont) {
+ VisitWordCompare(selector, node, kMips64Cmp, cont, false);
}
} // namespace
+void EmitWordCompareZero(InstructionSelector* selector, InstructionCode opcode,
+ Node* value, FlagsContinuation* cont) {
+ Mips64OperandGenerator g(selector);
+ opcode = cont->Encode(opcode);
+ InstructionOperand* const value_operand = g.UseRegister(value);
+ if (cont->IsBranch()) {
+ selector->Emit(opcode, nullptr, value_operand, g.TempImmediate(0),
+ g.Label(cont->true_block()),
+ g.Label(cont->false_block()))->MarkAsControl();
+ } else {
+ selector->Emit(opcode, g.DefineAsRegister(cont->result()), value_operand,
+ g.TempImmediate(0));
+ }
+}
+
+
// Shared routine for word comparisons against zero.
void VisitWordCompareZero(InstructionSelector* selector, Node* user,
Node* value, FlagsContinuation* cont) {
+ // Initially set comparison against 0 to be 64-bit variant for branches that
+ // cannot combine.
+ InstructionCode opcode = kMips64Cmp;
while (selector->CanCover(user, value)) {
+ if (user->opcode() == IrOpcode::kWord32Equal) {
+ opcode = kMips64Cmp32;
+ }
switch (value->opcode()) {
case IrOpcode::kWord32Equal: {
// Combine with comparisons against 0 by simply inverting the
@@ -557,23 +779,46 @@ void VisitWordCompareZero(InstructionSelector* selector, Node* user,
user = value;
value = m.left().node();
cont->Negate();
+ opcode = kMips64Cmp32;
continue;
}
cont->OverwriteAndNegateIfEqual(kEqual);
- return VisitWordCompare(selector, value, cont);
+ return VisitWord32Compare(selector, value, cont);
}
case IrOpcode::kInt32LessThan:
cont->OverwriteAndNegateIfEqual(kSignedLessThan);
- return VisitWordCompare(selector, value, cont);
+ return VisitWord32Compare(selector, value, cont);
case IrOpcode::kInt32LessThanOrEqual:
cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual);
- return VisitWordCompare(selector, value, cont);
+ return VisitWord32Compare(selector, value, cont);
case IrOpcode::kUint32LessThan:
cont->OverwriteAndNegateIfEqual(kUnsignedLessThan);
- return VisitWordCompare(selector, value, cont);
+ return VisitWord32Compare(selector, value, cont);
case IrOpcode::kUint32LessThanOrEqual:
cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual);
- return VisitWordCompare(selector, value, cont);
+ return VisitWord32Compare(selector, value, cont);
+ case IrOpcode::kWord64Equal: {
+ // Combine with comparisons against 0 by simply inverting the
+ // continuation.
+ Int64BinopMatcher m(value);
+ if (m.right().Is(0)) {
+ user = value;
+ value = m.left().node();
+ cont->Negate();
+ continue;
+ }
+ cont->OverwriteAndNegateIfEqual(kEqual);
+ return VisitWord64Compare(selector, value, cont);
+ }
+ case IrOpcode::kInt64LessThan:
+ cont->OverwriteAndNegateIfEqual(kSignedLessThan);
+ return VisitWord64Compare(selector, value, cont);
+ case IrOpcode::kInt64LessThanOrEqual:
+ cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual);
+ return VisitWord64Compare(selector, value, cont);
+ case IrOpcode::kUint64LessThan:
+ cont->OverwriteAndNegateIfEqual(kUnsignedLessThan);
+ return VisitWord64Compare(selector, value, cont);
case IrOpcode::kFloat64Equal:
cont->OverwriteAndNegateIfEqual(kUnorderedEqual);
return VisitFloat64Compare(selector, value, cont);
@@ -592,16 +837,16 @@ void VisitWordCompareZero(InstructionSelector* selector, Node* user,
// <Operation> is either NULL, which means there's no use of the
// actual value, or was already defined, which means it is scheduled
// *AFTER* this branch).
- Node* const node = value->InputAt(0);
- Node* const result = node->FindProjection(0);
- if (!result || selector->IsDefined(result)) {
+ Node* node = value->InputAt(0);
+ Node* result = node->FindProjection(0);
+ if (result == NULL || selector->IsDefined(result)) {
switch (node->opcode()) {
case IrOpcode::kInt32AddWithOverflow:
cont->OverwriteAndNegateIfEqual(kOverflow);
- return VisitBinop(selector, node, kMipsAddOvf, cont);
+ return VisitBinop(selector, node, kMips64Dadd, cont);
case IrOpcode::kInt32SubWithOverflow:
cont->OverwriteAndNegateIfEqual(kOverflow);
- return VisitBinop(selector, node, kMipsSubOvf, cont);
+ return VisitBinop(selector, node, kMips64Dsub, cont);
default:
break;
}
@@ -609,7 +854,9 @@ void VisitWordCompareZero(InstructionSelector* selector, Node* user,
}
break;
case IrOpcode::kWord32And:
- return VisitWordCompare(selector, value, kMipsTst, cont, true);
+ return VisitWordCompare(selector, value, kMips64Tst32, cont, true);
+ case IrOpcode::kWord64And:
+ return VisitWordCompare(selector, value, kMips64Tst, cont, true);
default:
break;
}
@@ -617,17 +864,7 @@ void VisitWordCompareZero(InstructionSelector* selector, Node* user,
}
// Continuation could not be combined with a compare, emit compare against 0.
- MipsOperandGenerator g(selector);
- InstructionCode const opcode = cont->Encode(kMipsCmp);
- InstructionOperand* const value_operand = g.UseRegister(value);
- if (cont->IsBranch()) {
- selector->Emit(opcode, nullptr, value_operand, g.TempImmediate(0),
- g.Label(cont->true_block()),
- g.Label(cont->false_block()))->MarkAsControl();
- } else {
- selector->Emit(opcode, g.DefineAsRegister(cont->result()), value_operand,
- g.TempImmediate(0));
- }
+ EmitWordCompareZero(selector, opcode, value, cont);
}
@@ -639,6 +876,7 @@ void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch,
cont.Negate();
cont.SwapBlocks();
}
+
VisitWordCompareZero(this, branch, branch->InputAt(0), &cont);
}
@@ -649,51 +887,81 @@ void InstructionSelector::VisitWord32Equal(Node* const node) {
if (m.right().Is(0)) {
return VisitWordCompareZero(this, m.node(), m.left().node(), &cont);
}
- VisitWordCompare(this, node, &cont);
+
+ VisitWord32Compare(this, node, &cont);
}
void InstructionSelector::VisitInt32LessThan(Node* node) {
FlagsContinuation cont(kSignedLessThan, node);
- VisitWordCompare(this, node, &cont);
+ VisitWord32Compare(this, node, &cont);
}
void InstructionSelector::VisitInt32LessThanOrEqual(Node* node) {
FlagsContinuation cont(kSignedLessThanOrEqual, node);
- VisitWordCompare(this, node, &cont);
+ VisitWord32Compare(this, node, &cont);
}
void InstructionSelector::VisitUint32LessThan(Node* node) {
FlagsContinuation cont(kUnsignedLessThan, node);
- VisitWordCompare(this, node, &cont);
+ VisitWord32Compare(this, node, &cont);
}
void InstructionSelector::VisitUint32LessThanOrEqual(Node* node) {
FlagsContinuation cont(kUnsignedLessThanOrEqual, node);
- VisitWordCompare(this, node, &cont);
+ VisitWord32Compare(this, node, &cont);
}
void InstructionSelector::VisitInt32AddWithOverflow(Node* node) {
if (Node* ovf = node->FindProjection(1)) {
FlagsContinuation cont(kOverflow, ovf);
- return VisitBinop(this, node, kMipsAddOvf, &cont);
+ return VisitBinop(this, node, kMips64Dadd, &cont);
}
FlagsContinuation cont;
- VisitBinop(this, node, kMipsAddOvf, &cont);
+ VisitBinop(this, node, kMips64Dadd, &cont);
}
void InstructionSelector::VisitInt32SubWithOverflow(Node* node) {
if (Node* ovf = node->FindProjection(1)) {
FlagsContinuation cont(kOverflow, ovf);
- return VisitBinop(this, node, kMipsSubOvf, &cont);
+ return VisitBinop(this, node, kMips64Dsub, &cont);
}
FlagsContinuation cont;
- VisitBinop(this, node, kMipsSubOvf, &cont);
+ VisitBinop(this, node, kMips64Dsub, &cont);
+}
+
+
+void InstructionSelector::VisitWord64Equal(Node* const node) {
+ FlagsContinuation cont(kEqual, node);
+ Int64BinopMatcher m(node);
+ if (m.right().Is(0)) {
+ return VisitWordCompareZero(this, m.node(), m.left().node(), &cont);
+ }
+
+ VisitWord64Compare(this, node, &cont);
+}
+
+
+void InstructionSelector::VisitInt64LessThan(Node* node) {
+ FlagsContinuation cont(kSignedLessThan, node);
+ VisitWord64Compare(this, node, &cont);
+}
+
+
+void InstructionSelector::VisitInt64LessThanOrEqual(Node* node) {
+ FlagsContinuation cont(kSignedLessThanOrEqual, node);
+ VisitWord64Compare(this, node, &cont);
+}
+
+
+void InstructionSelector::VisitUint64LessThan(Node* node) {
+ FlagsContinuation cont(kUnsignedLessThan, node);
+ VisitWord64Compare(this, node, &cont);
}
« no previous file with comments | « src/compiler/mips64/instruction-codes-mips64.h ('k') | src/compiler/mips64/linkage-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698