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

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

Issue 552653003: [turbofan] Fix the node matchers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address nit. Created 6 years, 3 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
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 9ffaa89d02f77fedc655c9b48f9ce5a7da611e78..55d50c18f0499b8f2ee879eac960f39e547e552a 100644
--- a/src/compiler/arm64/instruction-selector-arm64.cc
+++ b/src/compiler/arm64/instruction-selector-arm64.cc
@@ -34,15 +34,9 @@ class Arm64OperandGenerator FINAL : public OperandGenerator {
}
bool CanBeImmediate(Node* node, ImmediateMode mode) {
- int64_t value;
- switch (node->opcode()) {
- // TODO(turbofan): SMI number constants as immediates.
- case IrOpcode::kInt32Constant:
- value = ValueOf<int32_t>(node->op());
- break;
- default:
- return false;
- }
+ Int32Matcher m(node);
+ if (!m.HasValue()) return false;
+ int64_t value = m.Value();
unsigned ignored;
switch (mode) {
case kLogical32Imm:
@@ -259,27 +253,25 @@ void InstructionSelector::VisitWord64Or(Node* node) {
}
-template <typename T>
-static void VisitXor(InstructionSelector* selector, Node* node,
- ArchOpcode xor_opcode, ArchOpcode not_opcode) {
- Arm64OperandGenerator g(selector);
- BinopMatcher<IntMatcher<T>, IntMatcher<T> > m(node);
+void InstructionSelector::VisitWord32Xor(Node* node) {
+ Arm64OperandGenerator g(this);
+ Int32BinopMatcher m(node);
if (m.right().Is(-1)) {
- selector->Emit(not_opcode, g.DefineAsRegister(node),
- g.UseRegister(m.left().node()));
+ Emit(kArm64Not32, g.DefineAsRegister(node), g.UseRegister(m.left().node()));
} else {
- VisitBinop(selector, node, xor_opcode, kLogical32Imm);
+ VisitBinop(this, node, kArm64Xor32, kLogical32Imm);
}
}
-void InstructionSelector::VisitWord32Xor(Node* node) {
- VisitXor<int32_t>(this, node, kArm64Xor32, kArm64Not32);
-}
-
-
void InstructionSelector::VisitWord64Xor(Node* node) {
- VisitXor<int64_t>(this, node, kArm64Xor, kArm64Not);
+ Arm64OperandGenerator g(this);
+ Int64BinopMatcher m(node);
+ if (m.right().Is(-1)) {
+ Emit(kArm64Not, g.DefineAsRegister(node), g.UseRegister(m.left().node()));
+ } else {
+ VisitBinop(this, node, kArm64Xor, kLogical32Imm);
+ }
}
@@ -333,27 +325,26 @@ void InstructionSelector::VisitInt64Add(Node* node) {
}
-template <typename T>
-static void VisitSub(InstructionSelector* selector, Node* node,
- ArchOpcode sub_opcode, ArchOpcode neg_opcode) {
- Arm64OperandGenerator g(selector);
- BinopMatcher<IntMatcher<T>, IntMatcher<T> > m(node);
+void InstructionSelector::VisitInt32Sub(Node* node) {
+ Arm64OperandGenerator g(this);
+ Int32BinopMatcher m(node);
if (m.left().Is(0)) {
- selector->Emit(neg_opcode, g.DefineAsRegister(node),
- g.UseRegister(m.right().node()));
+ Emit(kArm64Neg32, g.DefineAsRegister(node),
+ g.UseRegister(m.right().node()));
} else {
- VisitBinop(selector, node, sub_opcode, kArithimeticImm);
+ VisitBinop(this, node, kArm64Sub32, kArithimeticImm);
}
}
-void InstructionSelector::VisitInt32Sub(Node* node) {
- VisitSub<int32_t>(this, node, kArm64Sub32, kArm64Neg32);
-}
-
-
void InstructionSelector::VisitInt64Sub(Node* node) {
- VisitSub<int64_t>(this, node, kArm64Sub, kArm64Neg);
+ Arm64OperandGenerator g(this);
+ Int64BinopMatcher m(node);
+ if (m.left().Is(0)) {
+ Emit(kArm64Neg, g.DefineAsRegister(node), g.UseRegister(m.right().node()));
+ } else {
+ VisitBinop(this, node, kArm64Sub, kArithimeticImm);
+ }
}
« no previous file with comments | « src/compiler/arm/instruction-selector-arm.cc ('k') | src/compiler/arm64/instruction-selector-arm64-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698