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

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

Issue 415403005: [turbofan] Support for combining branches with <Operation>WithOverflow. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months 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/node.cc ('k') | test/cctest/compiler/test-instruction-selector-arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/x64/instruction-selector-x64.cc
diff --git a/src/compiler/x64/instruction-selector-x64.cc b/src/compiler/x64/instruction-selector-x64.cc
index fd33f85cd82e14a5782c7a53390d9ca14510d568..c0401583270737f9272049eff369f7bc914f5f4c 100644
--- a/src/compiler/x64/instruction-selector-x64.cc
+++ b/src/compiler/x64/instruction-selector-x64.cc
@@ -176,31 +176,10 @@ void InstructionSelector::VisitStore(Node* node) {
// Shared routine for multiple binary operations.
static void VisitBinop(InstructionSelector* selector, Node* node,
- ArchOpcode opcode, bool commutative) {
- X64OperandGenerator g(selector);
- Node* left = node->InputAt(0);
- Node* right = node->InputAt(1);
- // TODO(turbofan): match complex addressing modes.
- // TODO(turbofan): if commutative, pick the non-live-in operand as the left as
- // this might be the last use and therefore its register can be reused.
- if (g.CanBeImmediate(right)) {
- selector->Emit(opcode, g.DefineSameAsFirst(node), g.Use(left),
- g.UseImmediate(right));
- } else if (commutative && g.CanBeImmediate(left)) {
- selector->Emit(opcode, g.DefineSameAsFirst(node), g.Use(right),
- g.UseImmediate(left));
- } else {
- selector->Emit(opcode, g.DefineSameAsFirst(node), g.UseRegister(left),
- g.Use(right));
- }
-}
-
-
-static void VisitBinopWithOverflow(InstructionSelector* selector, Node* node,
- InstructionCode opcode) {
+ InstructionCode opcode, FlagsContinuation* cont) {
X64OperandGenerator g(selector);
Int32BinopMatcher m(node);
- InstructionOperand* inputs[2];
+ InstructionOperand* inputs[4];
size_t input_count = 0;
InstructionOperand* outputs[2];
size_t output_count = 0;
@@ -216,18 +195,14 @@ static void VisitBinopWithOverflow(InstructionSelector* selector, Node* node,
inputs[input_count++] = g.Use(m.right().node());
}
- // Define outputs depending on the projections.
- Node* projections[2];
- node->CollectProjections(ARRAY_SIZE(projections), projections);
- if (projections[0]) {
- outputs[output_count++] = g.DefineSameAsFirst(projections[0]);
+ if (cont->IsBranch()) {
+ inputs[input_count++] = g.Label(cont->true_block());
+ inputs[input_count++] = g.Label(cont->false_block());
}
- if (projections[1]) {
- opcode |= FlagsModeField::encode(kFlags_set);
- opcode |= FlagsConditionField::encode(kOverflow);
- outputs[output_count++] =
- (projections[0] ? g.DefineAsRegister(projections[1])
- : g.DefineSameAsFirst(projections[1]));
+
+ outputs[output_count++] = g.DefineSameAsFirst(node);
+ if (cont->IsSet()) {
+ outputs[output_count++] = g.DefineAsRegister(cont->result());
}
ASSERT_NE(0, input_count);
@@ -235,27 +210,37 @@ static void VisitBinopWithOverflow(InstructionSelector* selector, Node* node,
ASSERT_GE(ARRAY_SIZE(inputs), input_count);
ASSERT_GE(ARRAY_SIZE(outputs), output_count);
- selector->Emit(opcode, output_count, outputs, input_count, inputs);
+ Instruction* instr = selector->Emit(cont->Encode(opcode), output_count,
+ outputs, input_count, inputs);
+ if (cont->IsBranch()) instr->MarkAsControl();
+}
+
+
+// Shared routine for multiple binary operations.
+static void VisitBinop(InstructionSelector* selector, Node* node,
+ InstructionCode opcode) {
+ FlagsContinuation cont;
+ VisitBinop(selector, node, opcode, &cont);
}
void InstructionSelector::VisitWord32And(Node* node) {
- VisitBinop(this, node, kX64And32, true);
+ VisitBinop(this, node, kX64And32);
}
void InstructionSelector::VisitWord64And(Node* node) {
- VisitBinop(this, node, kX64And, true);
+ VisitBinop(this, node, kX64And);
}
void InstructionSelector::VisitWord32Or(Node* node) {
- VisitBinop(this, node, kX64Or32, true);
+ VisitBinop(this, node, kX64Or32);
}
void InstructionSelector::VisitWord64Or(Node* node) {
- VisitBinop(this, node, kX64Or, true);
+ VisitBinop(this, node, kX64Or);
}
@@ -268,7 +253,7 @@ static void VisitXor(InstructionSelector* selector, Node* node,
selector->Emit(not_opcode, g.DefineSameAsFirst(node),
g.Use(m.left().node()));
} else {
- VisitBinop(selector, node, xor_opcode, true);
+ VisitBinop(selector, node, xor_opcode);
}
}
@@ -366,17 +351,12 @@ void InstructionSelector::VisitWord64Sar(Node* node) {
void InstructionSelector::VisitInt32Add(Node* node) {
- VisitBinop(this, node, kX64Add32, true);
-}
-
-
-void InstructionSelector::VisitInt32AddWithOverflow(Node* node) {
- VisitBinopWithOverflow(this, node, kX64Add32);
+ VisitBinop(this, node, kX64Add32);
}
void InstructionSelector::VisitInt64Add(Node* node) {
- VisitBinop(this, node, kX64Add, true);
+ VisitBinop(this, node, kX64Add);
}
@@ -389,7 +369,7 @@ static void VisitSub(InstructionSelector* selector, Node* node,
selector->Emit(neg_opcode, g.DefineSameAsFirst(node),
g.Use(m.right().node()));
} else {
- VisitBinop(selector, node, sub_opcode, false);
+ VisitBinop(selector, node, sub_opcode);
}
}
@@ -399,11 +379,6 @@ void InstructionSelector::VisitInt32Sub(Node* node) {
}
-void InstructionSelector::VisitInt32SubWithOverflow(Node* node) {
- VisitBinopWithOverflow(this, node, kX64Sub32);
-}
-
-
void InstructionSelector::VisitInt64Sub(Node* node) {
VisitSub<int64_t>(this, node, kX64Sub, kX64Neg);
}
@@ -584,6 +559,18 @@ void InstructionSelector::VisitConvertInt32ToInt64(Node* node) {
}
+void InstructionSelector::VisitInt32AddWithOverflow(Node* node,
+ FlagsContinuation* cont) {
+ VisitBinop(this, node, kX64Add32, cont);
+}
+
+
+void InstructionSelector::VisitInt32SubWithOverflow(Node* node,
+ FlagsContinuation* cont) {
+ VisitBinop(this, node, kX64Sub32, cont);
+}
+
+
// Shared routine for multiple compare operations.
static void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
InstructionOperand* left, InstructionOperand* right,
« no previous file with comments | « src/compiler/node.cc ('k') | test/cctest/compiler/test-instruction-selector-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698