| OLD | NEW |
| 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 #include "src/compiler/node-properties-inl.h" | 7 #include "src/compiler/node-properties-inl.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 Int32BinopMatcher m(node); | 253 Int32BinopMatcher m(node); |
| 254 Node* left = m.left().node(); | 254 Node* left = m.left().node(); |
| 255 Node* right = m.right().node(); | 255 Node* right = m.right().node(); |
| 256 InstructionOperand* inputs[4]; | 256 InstructionOperand* inputs[4]; |
| 257 size_t input_count = 0; | 257 size_t input_count = 0; |
| 258 InstructionOperand* outputs[2]; | 258 InstructionOperand* outputs[2]; |
| 259 size_t output_count = 0; | 259 size_t output_count = 0; |
| 260 | 260 |
| 261 // TODO(turbofan): match complex addressing modes. | 261 // TODO(turbofan): match complex addressing modes. |
| 262 if (g.CanBeImmediate(right)) { | 262 if (g.CanBeImmediate(right)) { |
| 263 inputs[input_count++] = g.Use(left); | 263 inputs[input_count++] = g.UseRegister(left); |
| 264 inputs[input_count++] = g.UseImmediate(right); | 264 inputs[input_count++] = g.UseImmediate(right); |
| 265 } else { | 265 } else { |
| 266 if (node->op()->HasProperty(Operator::kCommutative) && | 266 if (node->op()->HasProperty(Operator::kCommutative) && |
| 267 g.CanBeBetterLeftOperand(right)) { | 267 g.CanBeBetterLeftOperand(right)) { |
| 268 std::swap(left, right); | 268 std::swap(left, right); |
| 269 } | 269 } |
| 270 inputs[input_count++] = g.UseRegister(left); | 270 inputs[input_count++] = g.UseRegister(left); |
| 271 inputs[input_count++] = g.Use(right); | 271 inputs[input_count++] = g.Use(right); |
| 272 } | 272 } |
| 273 | 273 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 308 |
| 309 void InstructionSelector::VisitWord32Or(Node* node) { | 309 void InstructionSelector::VisitWord32Or(Node* node) { |
| 310 VisitBinop(this, node, kIA32Or); | 310 VisitBinop(this, node, kIA32Or); |
| 311 } | 311 } |
| 312 | 312 |
| 313 | 313 |
| 314 void InstructionSelector::VisitWord32Xor(Node* node) { | 314 void InstructionSelector::VisitWord32Xor(Node* node) { |
| 315 IA32OperandGenerator g(this); | 315 IA32OperandGenerator g(this); |
| 316 Int32BinopMatcher m(node); | 316 Int32BinopMatcher m(node); |
| 317 if (m.right().Is(-1)) { | 317 if (m.right().Is(-1)) { |
| 318 Emit(kIA32Not, g.DefineSameAsFirst(node), g.Use(m.left().node())); | 318 Emit(kIA32Not, g.DefineSameAsFirst(node), g.UseRegister(m.left().node())); |
| 319 } else { | 319 } else { |
| 320 VisitBinop(this, node, kIA32Xor); | 320 VisitBinop(this, node, kIA32Xor); |
| 321 } | 321 } |
| 322 } | 322 } |
| 323 | 323 |
| 324 | 324 |
| 325 // Shared routine for multiple shift operations. | 325 // Shared routine for multiple shift operations. |
| 326 static inline void VisitShift(InstructionSelector* selector, Node* node, | 326 static inline void VisitShift(InstructionSelector* selector, Node* node, |
| 327 ArchOpcode opcode) { | 327 ArchOpcode opcode) { |
| 328 IA32OperandGenerator g(selector); | 328 IA32OperandGenerator g(selector); |
| 329 Node* left = node->InputAt(0); | 329 Node* left = node->InputAt(0); |
| 330 Node* right = node->InputAt(1); | 330 Node* right = node->InputAt(1); |
| 331 | 331 |
| 332 if (g.CanBeImmediate(right)) { | 332 if (g.CanBeImmediate(right)) { |
| 333 selector->Emit(opcode, g.DefineSameAsFirst(node), g.Use(left), | 333 selector->Emit(opcode, g.DefineSameAsFirst(node), g.UseRegister(left), |
| 334 g.UseImmediate(right)); | 334 g.UseImmediate(right)); |
| 335 } else { | 335 } else { |
| 336 Int32BinopMatcher m(node); | 336 Int32BinopMatcher m(node); |
| 337 if (m.right().IsWord32And()) { | 337 if (m.right().IsWord32And()) { |
| 338 Int32BinopMatcher mright(right); | 338 Int32BinopMatcher mright(right); |
| 339 if (mright.right().Is(0x1F)) { | 339 if (mright.right().Is(0x1F)) { |
| 340 right = mright.left().node(); | 340 right = mright.left().node(); |
| 341 } | 341 } |
| 342 } | 342 } |
| 343 selector->Emit(opcode, g.DefineSameAsFirst(node), g.Use(left), | 343 selector->Emit(opcode, g.DefineSameAsFirst(node), g.UseRegister(left), |
| 344 g.UseFixed(right, ecx)); | 344 g.UseFixed(right, ecx)); |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 | 347 |
| 348 | 348 |
| 349 void InstructionSelector::VisitWord32Shl(Node* node) { | 349 void InstructionSelector::VisitWord32Shl(Node* node) { |
| 350 VisitShift(this, node, kIA32Shl); | 350 VisitShift(this, node, kIA32Shl); |
| 351 } | 351 } |
| 352 | 352 |
| 353 | 353 |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 call_instr->MarkAsCall(); | 709 call_instr->MarkAsCall(); |
| 710 if (deoptimization != NULL) { | 710 if (deoptimization != NULL) { |
| 711 DCHECK(continuation != NULL); | 711 DCHECK(continuation != NULL); |
| 712 call_instr->MarkAsControl(); | 712 call_instr->MarkAsControl(); |
| 713 } | 713 } |
| 714 } | 714 } |
| 715 | 715 |
| 716 } // namespace compiler | 716 } // namespace compiler |
| 717 } // namespace internal | 717 } // namespace internal |
| 718 } // namespace v8 | 718 } // namespace v8 |
| OLD | NEW |