| 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 #ifndef V8_COMPILER_NODE_MATCHERS_H_ | 5 #ifndef V8_COMPILER_NODE_MATCHERS_H_ |
| 6 #define V8_COMPILER_NODE_MATCHERS_H_ | 6 #define V8_COMPILER_NODE_MATCHERS_H_ |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 // TODO(turbofan): Move ExternalReference out of assembler.h | 10 // TODO(turbofan): Move ExternalReference out of assembler.h |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 AddMatcher m(node, options & AddressOption::kAllowInputSwap); | 482 AddMatcher m(node, options & AddressOption::kAllowInputSwap); |
| 483 Node* left = m.left().node(); | 483 Node* left = m.left().node(); |
| 484 Node* right = m.right().node(); | 484 Node* right = m.right().node(); |
| 485 Node* displacement = nullptr; | 485 Node* displacement = nullptr; |
| 486 Node* base = nullptr; | 486 Node* base = nullptr; |
| 487 Node* index = nullptr; | 487 Node* index = nullptr; |
| 488 Node* scale_expression = nullptr; | 488 Node* scale_expression = nullptr; |
| 489 bool power_of_two_plus_one = false; | 489 bool power_of_two_plus_one = false; |
| 490 DisplacementMode displacement_mode = kPositiveDisplacement; | 490 DisplacementMode displacement_mode = kPositiveDisplacement; |
| 491 int scale = 0; | 491 int scale = 0; |
| 492 if (m.HasIndexInput() && left->OwnedBy(node)) { | 492 if (m.HasIndexInput() && left->OwnedByAddressingOperand()) { |
| 493 index = m.IndexInput(); | 493 index = m.IndexInput(); |
| 494 scale = m.scale(); | 494 scale = m.scale(); |
| 495 scale_expression = left; | 495 scale_expression = left; |
| 496 power_of_two_plus_one = m.power_of_two_plus_one(); | 496 power_of_two_plus_one = m.power_of_two_plus_one(); |
| 497 bool match_found = false; | 497 bool match_found = false; |
| 498 if (right->opcode() == AddMatcher::kSubOpcode && right->OwnedBy(node)) { | 498 if (right->opcode() == AddMatcher::kSubOpcode && |
| 499 right->OwnedByAddressingOperand()) { |
| 499 AddMatcher right_matcher(right); | 500 AddMatcher right_matcher(right); |
| 500 if (right_matcher.right().HasValue()) { | 501 if (right_matcher.right().HasValue()) { |
| 501 // (S + (B - D)) | 502 // (S + (B - D)) |
| 502 base = right_matcher.left().node(); | 503 base = right_matcher.left().node(); |
| 503 displacement = right_matcher.right().node(); | 504 displacement = right_matcher.right().node(); |
| 504 displacement_mode = kNegativeDisplacement; | 505 displacement_mode = kNegativeDisplacement; |
| 505 match_found = true; | 506 match_found = true; |
| 506 } | 507 } |
| 507 } | 508 } |
| 508 if (!match_found) { | 509 if (!match_found) { |
| 509 if (right->opcode() == AddMatcher::kAddOpcode && right->OwnedBy(node)) { | 510 if (right->opcode() == AddMatcher::kAddOpcode && |
| 511 right->OwnedByAddressingOperand()) { |
| 510 AddMatcher right_matcher(right); | 512 AddMatcher right_matcher(right); |
| 511 if (right_matcher.right().HasValue()) { | 513 if (right_matcher.right().HasValue()) { |
| 512 // (S + (B + D)) | 514 // (S + (B + D)) |
| 513 base = right_matcher.left().node(); | 515 base = right_matcher.left().node(); |
| 514 displacement = right_matcher.right().node(); | 516 displacement = right_matcher.right().node(); |
| 515 } else { | 517 } else { |
| 516 // (S + (B + B)) | 518 // (S + (B + B)) |
| 517 base = right; | 519 base = right; |
| 518 } | 520 } |
| 519 } else if (m.right().HasValue()) { | 521 } else if (m.right().HasValue()) { |
| 520 // (S + D) | 522 // (S + D) |
| 521 displacement = right; | 523 displacement = right; |
| 522 } else { | 524 } else { |
| 523 // (S + B) | 525 // (S + B) |
| 524 base = right; | 526 base = right; |
| 525 } | 527 } |
| 526 } | 528 } |
| 527 } else { | 529 } else { |
| 528 bool match_found = false; | 530 bool match_found = false; |
| 529 if (left->opcode() == AddMatcher::kSubOpcode && left->OwnedBy(node)) { | 531 if (left->opcode() == AddMatcher::kSubOpcode && |
| 532 left->OwnedByAddressingOperand()) { |
| 530 AddMatcher left_matcher(left); | 533 AddMatcher left_matcher(left); |
| 531 Node* left_left = left_matcher.left().node(); | 534 Node* left_left = left_matcher.left().node(); |
| 532 Node* left_right = left_matcher.right().node(); | 535 Node* left_right = left_matcher.right().node(); |
| 533 if (left_matcher.right().HasValue()) { | 536 if (left_matcher.right().HasValue()) { |
| 534 if (left_matcher.HasIndexInput() && left_left->OwnedBy(left)) { | 537 if (left_matcher.HasIndexInput() && left_left->OwnedBy(left)) { |
| 535 // ((S - D) + B) | 538 // ((S - D) + B) |
| 536 index = left_matcher.IndexInput(); | 539 index = left_matcher.IndexInput(); |
| 537 scale = left_matcher.scale(); | 540 scale = left_matcher.scale(); |
| 538 scale_expression = left_left; | 541 scale_expression = left_left; |
| 539 power_of_two_plus_one = left_matcher.power_of_two_plus_one(); | 542 power_of_two_plus_one = left_matcher.power_of_two_plus_one(); |
| 540 displacement = left_right; | 543 displacement = left_right; |
| 541 displacement_mode = kNegativeDisplacement; | 544 displacement_mode = kNegativeDisplacement; |
| 542 base = right; | 545 base = right; |
| 543 } else { | 546 } else { |
| 544 // ((B - D) + B) | 547 // ((B - D) + B) |
| 545 index = left_left; | 548 index = left_left; |
| 546 displacement = left_right; | 549 displacement = left_right; |
| 547 displacement_mode = kNegativeDisplacement; | 550 displacement_mode = kNegativeDisplacement; |
| 548 base = right; | 551 base = right; |
| 549 } | 552 } |
| 550 match_found = true; | 553 match_found = true; |
| 551 } | 554 } |
| 552 } | 555 } |
| 553 if (!match_found) { | 556 if (!match_found) { |
| 554 if (left->opcode() == AddMatcher::kAddOpcode && left->OwnedBy(node)) { | 557 if (left->opcode() == AddMatcher::kAddOpcode && |
| 558 left->OwnedByAddressingOperand()) { |
| 555 AddMatcher left_matcher(left); | 559 AddMatcher left_matcher(left); |
| 556 Node* left_left = left_matcher.left().node(); | 560 Node* left_left = left_matcher.left().node(); |
| 557 Node* left_right = left_matcher.right().node(); | 561 Node* left_right = left_matcher.right().node(); |
| 558 if (left_matcher.HasIndexInput() && left_left->OwnedBy(left)) { | 562 if (left_matcher.HasIndexInput() && left_left->OwnedBy(left)) { |
| 559 if (left_matcher.right().HasValue()) { | 563 if (left_matcher.right().HasValue()) { |
| 560 // ((S + D) + B) | 564 // ((S + D) + B) |
| 561 index = left_matcher.IndexInput(); | 565 index = left_matcher.IndexInput(); |
| 562 scale = left_matcher.scale(); | 566 scale = left_matcher.scale(); |
| 563 scale_expression = left_left; | 567 scale_expression = left_left; |
| 564 power_of_two_plus_one = left_matcher.power_of_two_plus_one(); | 568 power_of_two_plus_one = left_matcher.power_of_two_plus_one(); |
| 565 displacement = left_right; | 569 displacement = left_right; |
| 566 base = right; | 570 base = right; |
| 567 } else if (m.right().HasValue()) { | 571 } else if (m.right().HasValue()) { |
| 568 // ((S + B) + D) | 572 if (left->OwnedBy(node)) { |
| 569 index = left_matcher.IndexInput(); | 573 // ((S + B) + D) |
| 570 scale = left_matcher.scale(); | 574 index = left_matcher.IndexInput(); |
| 571 scale_expression = left_left; | 575 scale = left_matcher.scale(); |
| 572 power_of_two_plus_one = left_matcher.power_of_two_plus_one(); | 576 scale_expression = left_left; |
| 573 base = left_right; | 577 power_of_two_plus_one = left_matcher.power_of_two_plus_one(); |
| 574 displacement = right; | 578 base = left_right; |
| 579 displacement = right; |
| 580 } else { |
| 581 // (B + D) |
| 582 base = left; |
| 583 displacement = right; |
| 584 } |
| 575 } else { | 585 } else { |
| 576 // (B + B) | 586 // (B + B) |
| 577 index = left; | 587 index = left; |
| 578 base = right; | 588 base = right; |
| 579 } | 589 } |
| 580 } else { | 590 } else { |
| 581 if (left_matcher.right().HasValue()) { | 591 if (left_matcher.right().HasValue()) { |
| 582 // ((B + D) + B) | 592 // ((B + D) + B) |
| 583 index = left_left; | 593 index = left_left; |
| 584 displacement = left_right; | 594 displacement = left_right; |
| 585 base = right; | 595 base = right; |
| 586 } else if (m.right().HasValue()) { | 596 } else if (m.right().HasValue()) { |
| 587 // ((B + B) + D) | 597 if (left->OwnedBy(node)) { |
| 588 index = left_left; | 598 // ((B + B) + D) |
| 589 base = left_right; | 599 index = left_left; |
| 590 displacement = right; | 600 base = left_right; |
| 601 displacement = right; |
| 602 } else { |
| 603 // (B + D) |
| 604 base = left; |
| 605 displacement = right; |
| 606 } |
| 591 } else { | 607 } else { |
| 592 // (B + B) | 608 // (B + B) |
| 593 index = left; | 609 index = left; |
| 594 base = right; | 610 base = right; |
| 595 } | 611 } |
| 596 } | 612 } |
| 597 } else { | 613 } else { |
| 598 if (m.right().HasValue()) { | 614 if (m.right().HasValue()) { |
| 599 // (B + D) | 615 // (B + D) |
| 600 base = left; | 616 base = left; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 Node* branch_; | 718 Node* branch_; |
| 703 Node* if_true_; | 719 Node* if_true_; |
| 704 Node* if_false_; | 720 Node* if_false_; |
| 705 }; | 721 }; |
| 706 | 722 |
| 707 } // namespace compiler | 723 } // namespace compiler |
| 708 } // namespace internal | 724 } // namespace internal |
| 709 } // namespace v8 | 725 } // namespace v8 |
| 710 | 726 |
| 711 #endif // V8_COMPILER_NODE_MATCHERS_H_ | 727 #endif // V8_COMPILER_NODE_MATCHERS_H_ |
| OLD | NEW |