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

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

Issue 548453002: [turbofan] Add ARM64 overflow selector tests (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Separate commutative overflow tests 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/compiler/arm64/instruction-selector-arm64-unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
11 11
12 enum ImmediateMode { 12 enum ImmediateMode {
13 kArithimeticImm, // 12 bit unsigned immediate shifted left 0 or 12 bits 13 kArithmeticImm, // 12 bit unsigned immediate shifted left 0 or 12 bits
14 kShift32Imm, // 0 - 31 14 kShift32Imm, // 0 - 31
15 kShift64Imm, // 0 -63 15 kShift64Imm, // 0 - 63
16 kLogical32Imm, 16 kLogical32Imm,
17 kLogical64Imm, 17 kLogical64Imm,
18 kLoadStoreImm, // unsigned 9 bit or signed 7 bit 18 kLoadStoreImm, // unsigned 9 bit or signed 7 bit
19 kNoImmediate 19 kNoImmediate
20 }; 20 };
21 21
22 22
23 // Adds Arm64-specific methods for generating operands. 23 // Adds Arm64-specific methods for generating operands.
24 class Arm64OperandGenerator FINAL : public OperandGenerator { 24 class Arm64OperandGenerator FINAL : public OperandGenerator {
25 public: 25 public:
(...skipping 20 matching lines...) Expand all
46 unsigned ignored; 46 unsigned ignored;
47 switch (mode) { 47 switch (mode) {
48 case kLogical32Imm: 48 case kLogical32Imm:
49 // TODO(dcarney): some unencodable values can be handled by 49 // TODO(dcarney): some unencodable values can be handled by
50 // switching instructions. 50 // switching instructions.
51 return Assembler::IsImmLogical(static_cast<uint64_t>(value), 32, 51 return Assembler::IsImmLogical(static_cast<uint64_t>(value), 32,
52 &ignored, &ignored, &ignored); 52 &ignored, &ignored, &ignored);
53 case kLogical64Imm: 53 case kLogical64Imm:
54 return Assembler::IsImmLogical(static_cast<uint64_t>(value), 64, 54 return Assembler::IsImmLogical(static_cast<uint64_t>(value), 64,
55 &ignored, &ignored, &ignored); 55 &ignored, &ignored, &ignored);
56 case kArithimeticImm: 56 case kArithmeticImm:
57 // TODO(dcarney): -values can be handled by instruction swapping 57 // TODO(dcarney): -values can be handled by instruction swapping
58 return Assembler::IsImmAddSub(value); 58 return Assembler::IsImmAddSub(value);
59 case kShift32Imm: 59 case kShift32Imm:
60 return 0 <= value && value < 32; 60 return 0 <= value && value < 32;
61 case kShift64Imm: 61 case kShift64Imm:
62 return 0 <= value && value < 64; 62 return 0 <= value && value < 64;
63 case kLoadStoreImm: 63 case kLoadStoreImm:
64 return (0 <= value && value < (1 << 9)) || 64 return (0 <= value && value < (1 << 9)) ||
65 (-(1 << 6) <= value && value < (1 << 6)); 65 (-(1 << 6) <= value && value < (1 << 6));
66 case kNoImmediate: 66 case kNoImmediate:
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 VisitRRO(this, kArm64Ror32, node, kShift32Imm); 317 VisitRRO(this, kArm64Ror32, node, kShift32Imm);
318 } 318 }
319 319
320 320
321 void InstructionSelector::VisitWord64Ror(Node* node) { 321 void InstructionSelector::VisitWord64Ror(Node* node) {
322 VisitRRO(this, kArm64Ror, node, kShift64Imm); 322 VisitRRO(this, kArm64Ror, node, kShift64Imm);
323 } 323 }
324 324
325 325
326 void InstructionSelector::VisitInt32Add(Node* node) { 326 void InstructionSelector::VisitInt32Add(Node* node) {
327 VisitBinop(this, node, kArm64Add32, kArithimeticImm); 327 VisitBinop(this, node, kArm64Add32, kArithmeticImm);
328 } 328 }
329 329
330 330
331 void InstructionSelector::VisitInt64Add(Node* node) { 331 void InstructionSelector::VisitInt64Add(Node* node) {
332 VisitBinop(this, node, kArm64Add, kArithimeticImm); 332 VisitBinop(this, node, kArm64Add, kArithmeticImm);
333 } 333 }
334 334
335 335
336 template <typename T> 336 template <typename T>
337 static void VisitSub(InstructionSelector* selector, Node* node, 337 static void VisitSub(InstructionSelector* selector, Node* node,
338 ArchOpcode sub_opcode, ArchOpcode neg_opcode) { 338 ArchOpcode sub_opcode, ArchOpcode neg_opcode) {
339 Arm64OperandGenerator g(selector); 339 Arm64OperandGenerator g(selector);
340 BinopMatcher<IntMatcher<T>, IntMatcher<T> > m(node); 340 BinopMatcher<IntMatcher<T>, IntMatcher<T> > m(node);
341 if (m.left().Is(0)) { 341 if (m.left().Is(0)) {
342 selector->Emit(neg_opcode, g.DefineAsRegister(node), 342 selector->Emit(neg_opcode, g.DefineAsRegister(node),
343 g.UseRegister(m.right().node())); 343 g.UseRegister(m.right().node()));
344 } else { 344 } else {
345 VisitBinop(selector, node, sub_opcode, kArithimeticImm); 345 VisitBinop(selector, node, sub_opcode, kArithmeticImm);
346 } 346 }
347 } 347 }
348 348
349 349
350 void InstructionSelector::VisitInt32Sub(Node* node) { 350 void InstructionSelector::VisitInt32Sub(Node* node) {
351 VisitSub<int32_t>(this, node, kArm64Sub32, kArm64Neg32); 351 VisitSub<int32_t>(this, node, kArm64Sub32, kArm64Neg32);
352 } 352 }
353 353
354 354
355 void InstructionSelector::VisitInt64Sub(Node* node) { 355 void InstructionSelector::VisitInt64Sub(Node* node) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 void InstructionSelector::VisitFloat64Mod(Node* node) { 476 void InstructionSelector::VisitFloat64Mod(Node* node) {
477 Arm64OperandGenerator g(this); 477 Arm64OperandGenerator g(this);
478 Emit(kArm64Float64Mod, g.DefineAsFixed(node, d0), 478 Emit(kArm64Float64Mod, g.DefineAsFixed(node, d0),
479 g.UseFixed(node->InputAt(0), d0), 479 g.UseFixed(node->InputAt(0), d0),
480 g.UseFixed(node->InputAt(1), d1))->MarkAsCall(); 480 g.UseFixed(node->InputAt(1), d1))->MarkAsCall();
481 } 481 }
482 482
483 483
484 void InstructionSelector::VisitInt32AddWithOverflow(Node* node, 484 void InstructionSelector::VisitInt32AddWithOverflow(Node* node,
485 FlagsContinuation* cont) { 485 FlagsContinuation* cont) {
486 VisitBinop(this, node, kArm64Add32, kArithimeticImm, cont); 486 VisitBinop(this, node, kArm64Add32, kArithmeticImm, cont);
487 } 487 }
488 488
489 489
490 void InstructionSelector::VisitInt32SubWithOverflow(Node* node, 490 void InstructionSelector::VisitInt32SubWithOverflow(Node* node,
491 FlagsContinuation* cont) { 491 FlagsContinuation* cont) {
492 VisitBinop(this, node, kArm64Sub32, kArithimeticImm, cont); 492 VisitBinop(this, node, kArm64Sub32, kArithmeticImm, cont);
493 } 493 }
494 494
495 495
496 // Shared routine for multiple compare operations. 496 // Shared routine for multiple compare operations.
497 static void VisitCompare(InstructionSelector* selector, InstructionCode opcode, 497 static void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
498 InstructionOperand* left, InstructionOperand* right, 498 InstructionOperand* left, InstructionOperand* right,
499 FlagsContinuation* cont) { 499 FlagsContinuation* cont) {
500 Arm64OperandGenerator g(selector); 500 Arm64OperandGenerator g(selector);
501 opcode = cont->Encode(opcode); 501 opcode = cont->Encode(opcode);
502 if (cont->IsBranch()) { 502 if (cont->IsBranch()) {
503 selector->Emit(opcode, NULL, left, right, g.Label(cont->true_block()), 503 selector->Emit(opcode, NULL, left, right, g.Label(cont->true_block()),
504 g.Label(cont->false_block()))->MarkAsControl(); 504 g.Label(cont->false_block()))->MarkAsControl();
505 } else { 505 } else {
506 DCHECK(cont->IsSet()); 506 DCHECK(cont->IsSet());
507 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); 507 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right);
508 } 508 }
509 } 509 }
510 510
511 511
512 // Shared routine for multiple word compare operations. 512 // Shared routine for multiple word compare operations.
513 static void VisitWordCompare(InstructionSelector* selector, Node* node, 513 static void VisitWordCompare(InstructionSelector* selector, Node* node,
514 InstructionCode opcode, FlagsContinuation* cont, 514 InstructionCode opcode, FlagsContinuation* cont,
515 bool commutative) { 515 bool commutative) {
516 Arm64OperandGenerator g(selector); 516 Arm64OperandGenerator g(selector);
517 Node* left = node->InputAt(0); 517 Node* left = node->InputAt(0);
518 Node* right = node->InputAt(1); 518 Node* right = node->InputAt(1);
519 519
520 // Match immediates on left or right side of comparison. 520 // Match immediates on left or right side of comparison.
521 if (g.CanBeImmediate(right, kArithimeticImm)) { 521 if (g.CanBeImmediate(right, kArithmeticImm)) {
522 VisitCompare(selector, opcode, g.UseRegister(left), g.UseImmediate(right), 522 VisitCompare(selector, opcode, g.UseRegister(left), g.UseImmediate(right),
523 cont); 523 cont);
524 } else if (g.CanBeImmediate(left, kArithimeticImm)) { 524 } else if (g.CanBeImmediate(left, kArithmeticImm)) {
525 if (!commutative) cont->Commute(); 525 if (!commutative) cont->Commute();
526 VisitCompare(selector, opcode, g.UseRegister(right), g.UseImmediate(left), 526 VisitCompare(selector, opcode, g.UseRegister(right), g.UseImmediate(left),
527 cont); 527 cont);
528 } else { 528 } else {
529 VisitCompare(selector, opcode, g.UseRegister(left), g.UseRegister(right), 529 VisitCompare(selector, opcode, g.UseRegister(left), g.UseRegister(right),
530 cont); 530 cont);
531 } 531 }
532 } 532 }
533 533
534 534
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 // Caller clean up of stack for C-style calls. 666 // Caller clean up of stack for C-style calls.
667 if (is_c_frame && aligned_push_count > 0) { 667 if (is_c_frame && aligned_push_count > 0) {
668 DCHECK(deoptimization == NULL && continuation == NULL); 668 DCHECK(deoptimization == NULL && continuation == NULL);
669 Emit(kArchDrop | MiscField::encode(aligned_push_count), NULL); 669 Emit(kArchDrop | MiscField::encode(aligned_push_count), NULL);
670 } 670 }
671 } 671 }
672 672
673 } // namespace compiler 673 } // namespace compiler
674 } // namespace internal 674 } // namespace internal
675 } // namespace v8 675 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/arm64/instruction-selector-arm64-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698