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

Side by Side Diff: src/compiler/arm64/instruction-selector-arm64.cc

Issue 642923003: [turbofan] Add support for shifted and rotated operands on ARM64. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/instruction-selector-impl.h" 5 #include "src/compiler/instruction-selector-impl.h"
6 #include "src/compiler/node-matchers.h" 6 #include "src/compiler/node-matchers.h"
7 7
8 namespace v8 { 8 namespace v8 {
9 namespace internal { 9 namespace internal {
10 namespace compiler { 10 namespace compiler {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 static void VisitRRO(InstructionSelector* selector, ArchOpcode opcode, 107 static void VisitRRO(InstructionSelector* selector, ArchOpcode opcode,
108 Node* node, ImmediateMode operand_mode) { 108 Node* node, ImmediateMode operand_mode) {
109 Arm64OperandGenerator g(selector); 109 Arm64OperandGenerator g(selector);
110 selector->Emit(opcode, g.DefineAsRegister(node), 110 selector->Emit(opcode, g.DefineAsRegister(node),
111 g.UseRegister(node->InputAt(0)), 111 g.UseRegister(node->InputAt(0)),
112 g.UseOperand(node->InputAt(1), operand_mode)); 112 g.UseOperand(node->InputAt(1), operand_mode));
113 } 113 }
114 114
115 115
116 template <typename Matcher>
117 static bool TryMatchShift(InstructionSelector* selector, Node* node,
118 InstructionCode* opcode, IrOpcode::Value shift_opcode,
119 ImmediateMode imm_mode,
120 AddressingMode addressing_mode) {
121 if (node->opcode() != shift_opcode) return false;
122 Arm64OperandGenerator g(selector);
123 Matcher m(node);
124 if (g.CanBeImmediate(m.right().node(), imm_mode)) {
125 *opcode |= AddressingModeField::encode(addressing_mode);
126 return true;
127 }
128 return false;
129 }
130
131
132 static bool TryMatchAnyShift(InstructionSelector* selector, Node* node,
133 InstructionCode* opcode, bool try_ror) {
134 return TryMatchShift<Int32BinopMatcher>(selector, node, opcode,
135 IrOpcode::kWord32Shl, kShift32Imm,
136 kMode_Operand2_R_LSL_I) ||
137 TryMatchShift<Int32BinopMatcher>(selector, node, opcode,
138 IrOpcode::kWord32Shr, kShift32Imm,
139 kMode_Operand2_R_LSR_I) ||
140 TryMatchShift<Int32BinopMatcher>(selector, node, opcode,
141 IrOpcode::kWord32Sar, kShift32Imm,
142 kMode_Operand2_R_ASR_I) ||
143 (try_ror && TryMatchShift<Int32BinopMatcher>(
144 selector, node, opcode, IrOpcode::kWord32Ror,
145 kShift32Imm, kMode_Operand2_R_ROR_I)) ||
146 TryMatchShift<Int64BinopMatcher>(selector, node, opcode,
147 IrOpcode::kWord64Shl, kShift64Imm,
148 kMode_Operand2_R_LSL_I) ||
149 TryMatchShift<Int64BinopMatcher>(selector, node, opcode,
150 IrOpcode::kWord64Shr, kShift64Imm,
151 kMode_Operand2_R_LSR_I) ||
152 TryMatchShift<Int64BinopMatcher>(selector, node, opcode,
153 IrOpcode::kWord64Sar, kShift64Imm,
154 kMode_Operand2_R_ASR_I) ||
155 (try_ror && TryMatchShift<Int64BinopMatcher>(
156 selector, node, opcode, IrOpcode::kWord64Ror,
157 kShift64Imm, kMode_Operand2_R_ROR_I));
158 }
159
160
116 // Shared routine for multiple binary operations. 161 // Shared routine for multiple binary operations.
117 template <typename Matcher> 162 template <typename Matcher>
118 static void VisitBinop(InstructionSelector* selector, Node* node, 163 static void VisitBinop(InstructionSelector* selector, Node* node,
119 InstructionCode opcode, ImmediateMode operand_mode, 164 InstructionCode opcode, ImmediateMode operand_mode,
120 FlagsContinuation* cont) { 165 FlagsContinuation* cont) {
121 Arm64OperandGenerator g(selector); 166 Arm64OperandGenerator g(selector);
122 Matcher m(node); 167 Matcher m(node);
123 InstructionOperand* inputs[4]; 168 InstructionOperand* inputs[4];
124 size_t input_count = 0; 169 size_t input_count = 0;
125 InstructionOperand* outputs[2]; 170 InstructionOperand* outputs[2];
126 size_t output_count = 0; 171 size_t output_count = 0;
172 bool try_ror_operand = true;
127 173
128 inputs[input_count++] = g.UseRegister(m.left().node()); 174 if (m.IsInt32Add() || m.IsInt64Add() || m.IsInt32Sub() || m.IsInt64Sub()) {
129 inputs[input_count++] = g.UseOperand(m.right().node(), operand_mode); 175 try_ror_operand = false;
176 }
177
178 if (g.CanBeImmediate(m.right().node(), operand_mode)) {
179 inputs[input_count++] = g.UseRegister(m.left().node());
180 inputs[input_count++] = g.UseImmediate(m.right().node());
181 } else if (TryMatchAnyShift(selector, m.right().node(), &opcode,
182 try_ror_operand)) {
183 Matcher m_shift(m.right().node());
184 inputs[input_count++] = g.UseRegister(m.left().node());
185 inputs[input_count++] = g.UseRegister(m_shift.left().node());
186 inputs[input_count++] = g.UseImmediate(m_shift.right().node());
187 } else if (m.HasProperty(Operator::kCommutative) &&
188 TryMatchAnyShift(selector, m.left().node(), &opcode,
189 try_ror_operand)) {
190 Matcher m_shift(m.left().node());
191 inputs[input_count++] = g.UseRegister(m.right().node());
192 inputs[input_count++] = g.UseRegister(m_shift.left().node());
193 inputs[input_count++] = g.UseImmediate(m_shift.right().node());
194 } else {
195 inputs[input_count++] = g.UseRegister(m.left().node());
196 inputs[input_count++] = g.UseRegister(m.right().node());
197 }
130 198
131 if (cont->IsBranch()) { 199 if (cont->IsBranch()) {
132 inputs[input_count++] = g.Label(cont->true_block()); 200 inputs[input_count++] = g.Label(cont->true_block());
133 inputs[input_count++] = g.Label(cont->false_block()); 201 inputs[input_count++] = g.Label(cont->false_block());
134 } 202 }
135 203
136 outputs[output_count++] = g.DefineAsRegister(node); 204 outputs[output_count++] = g.DefineAsRegister(node);
137 if (cont->IsSet()) { 205 if (cont->IsSet()) {
138 outputs[output_count++] = g.DefineAsRegister(cont->result()); 206 outputs[output_count++] = g.DefineAsRegister(cont->result());
139 } 207 }
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 call_instr->MarkAsCall(); 1056 call_instr->MarkAsCall();
989 if (deoptimization != NULL) { 1057 if (deoptimization != NULL) {
990 DCHECK(continuation != NULL); 1058 DCHECK(continuation != NULL);
991 call_instr->MarkAsControl(); 1059 call_instr->MarkAsControl();
992 } 1060 }
993 } 1061 }
994 1062
995 } // namespace compiler 1063 } // namespace compiler
996 } // namespace internal 1064 } // namespace internal
997 } // namespace v8 1065 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/arm64/instruction-codes-arm64.h ('k') | test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698