Index: src/compiler/arm64/instruction-selector-arm64.cc |
diff --git a/src/compiler/arm64/instruction-selector-arm64.cc b/src/compiler/arm64/instruction-selector-arm64.cc |
index fee086ca536ca524839b0cf59f9205e6c7901bd1..a1f1ffa7e75b1100b8457bf8922e564f9e6f4504 100644 |
--- a/src/compiler/arm64/instruction-selector-arm64.cc |
+++ b/src/compiler/arm64/instruction-selector-arm64.cc |
@@ -114,6 +114,39 @@ static void VisitBinop(InstructionSelector* selector, Node* node, |
} |
+static void VisitBinopWithOverflow(InstructionSelector* selector, Node* node, |
+ InstructionCode opcode) { |
+ Arm64OperandGenerator g(selector); |
+ Int32BinopMatcher m(node); |
+ InstructionOperand* inputs[2]; |
+ size_t input_count = 0; |
+ InstructionOperand* outputs[2]; |
+ size_t output_count = 0; |
+ |
+ inputs[input_count++] = g.UseRegister(m.left().node()); |
+ inputs[input_count++] = g.UseRegister(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.DefineAsRegister(projections[0]); |
+ } |
+ if (projections[1]) { |
+ opcode |= FlagsModeField::encode(kFlags_set); |
+ opcode |= FlagsConditionField::encode(kOverflow); |
+ outputs[output_count++] = g.DefineAsRegister(projections[1]); |
+ } |
+ |
+ ASSERT_NE(0, input_count); |
+ ASSERT_NE(0, output_count); |
+ ASSERT_GE(ARRAY_SIZE(inputs), input_count); |
+ ASSERT_GE(ARRAY_SIZE(outputs), output_count); |
+ |
+ selector->Emit(opcode, output_count, outputs, input_count, inputs); |
+} |
+ |
+ |
void InstructionSelector::VisitLoad(Node* node) { |
MachineRepresentation rep = OpParameter<MachineRepresentation>(node); |
Arm64OperandGenerator g(this); |
@@ -299,6 +332,11 @@ void InstructionSelector::VisitInt32Add(Node* node) { |
} |
+void InstructionSelector::VisitInt32AddWithOverflow(Node* node) { |
+ VisitBinopWithOverflow(this, node, kArm64Add32); |
+} |
+ |
+ |
void InstructionSelector::VisitInt64Add(Node* node) { |
VisitBinop(this, node, kArm64Add, kArithimeticImm, true); |
} |