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

Side by Side Diff: test/unittests/compiler/node-test-utils.cc

Issue 1468003002: [Interpreter] Add support for cast operators to bytecode graph builder and (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed review comments. Created 5 years 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
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 "test/unittests/compiler/node-test-utils.h" 5 #include "test/unittests/compiler/node-test-utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "src/assembler.h" 9 #include "src/assembler.h"
10 #include "src/compiler/common-operator.h" 10 #include "src/compiler/common-operator.h"
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 return (NodeMatcher::MatchAndExplain(node, listener) && 1399 return (NodeMatcher::MatchAndExplain(node, listener) &&
1400 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), 1400 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
1401 "input", input_matcher_, listener)); 1401 "input", input_matcher_, listener));
1402 } 1402 }
1403 1403
1404 private: 1404 private:
1405 const Matcher<Node*> input_matcher_; 1405 const Matcher<Node*> input_matcher_;
1406 }; 1406 };
1407 1407
1408 1408
1409 class IsJSBinopMatcher final : public NodeMatcher {
1410 public:
1411 IsJSBinopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher,
1412 const Matcher<Node*>& rhs_matcher,
1413 const Matcher<Node*>& effect_matcher,
1414 const Matcher<Node*>& control_matcher)
1415 : NodeMatcher(opcode),
1416 lhs_matcher_(lhs_matcher),
1417 rhs_matcher_(rhs_matcher),
1418 effect_matcher_(effect_matcher),
1419 control_matcher_(control_matcher) {}
1420
1421 void DescribeTo(std::ostream* os) const final {
1422 NodeMatcher::DescribeTo(os);
1423 *os << " whose lhs (";
1424 lhs_matcher_.DescribeTo(os);
1425 *os << "), and rhs (";
1426 rhs_matcher_.DescribeTo(os);
1427 *os << "), and effect (";
1428 rhs_matcher_.DescribeTo(os);
1429 *os << "), and control (";
1430 rhs_matcher_.DescribeTo(os);
1431 *os << ")";
1432 }
1433
1434 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
1435 return (NodeMatcher::MatchAndExplain(node, listener) &&
1436 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs",
1437 lhs_matcher_, listener) &&
1438 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "rhs",
1439 rhs_matcher_, listener) &&
1440 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
1441 effect_matcher_, listener) &&
1442 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
1443 "control", control_matcher_, listener));
1444 }
1445
1446 private:
1447 const Matcher<Node*> lhs_matcher_;
1448 const Matcher<Node*> rhs_matcher_;
1449 const Matcher<Node*> effect_matcher_;
1450 const Matcher<Node*> control_matcher_;
1451 };
1452
1453
1454 class IsUnopWithEffectMatcher final : public NodeMatcher {
1455 public:
1456 IsUnopWithEffectMatcher(IrOpcode::Value opcode,
1457 const Matcher<Node*>& input_matcher,
1458 const Matcher<Node*>& effect_matcher)
1459 : NodeMatcher(opcode),
1460 input_matcher_(input_matcher),
1461 effect_matcher_(effect_matcher) {}
1462
1463 void DescribeTo(std::ostream* os) const final {
1464 NodeMatcher::DescribeTo(os);
1465 *os << " whose input (";
1466 input_matcher_.DescribeTo(os);
1467 *os << "), effect (";
1468 effect_matcher_.DescribeTo(os);
1469 *os << ")";
1470 }
1471
1472 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
1473 return (NodeMatcher::MatchAndExplain(node, listener) &&
1474 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
1475 "input", input_matcher_, listener) &&
1476 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
1477 effect_matcher_, listener));
1478 }
1479
1480 private:
1481 const Matcher<Node*> input_matcher_;
1482 const Matcher<Node*> effect_matcher_;
1483 };
1484
1485
1486 class IsUnopEffectControlMatcher final : public NodeMatcher {
1487 public:
1488 IsUnopEffectControlMatcher(IrOpcode::Value opcode,
1489 const Matcher<Node*>& input_matcher,
1490 const Matcher<Node*>& effect_matcher,
1491 const Matcher<Node*>& control_matcher)
1492 : NodeMatcher(opcode),
1493 input_matcher_(input_matcher),
1494 effect_matcher_(effect_matcher),
1495 control_matcher_(control_matcher) {}
1496
1497 void DescribeTo(std::ostream* os) const final {
1498 NodeMatcher::DescribeTo(os);
1499 *os << " whose input (";
1500 input_matcher_.DescribeTo(os);
1501 *os << "), effect (";
1502 effect_matcher_.DescribeTo(os);
1503 *os << "), control (";
1504 control_matcher_.DescribeTo(os);
1505 *os << ")";
1506 }
1507
1508 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
1509 return (NodeMatcher::MatchAndExplain(node, listener) &&
1510 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
1511 "input", input_matcher_, listener) &&
1512 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
1513 effect_matcher_, listener) &&
1514 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
1515 "control", control_matcher_, listener));
1516 }
1517
1518 private:
1519 const Matcher<Node*> input_matcher_;
1520 const Matcher<Node*> effect_matcher_;
1521 const Matcher<Node*> control_matcher_;
1522 };
1523
1524
1409 class IsParameterMatcher final : public NodeMatcher { 1525 class IsParameterMatcher final : public NodeMatcher {
1410 public: 1526 public:
1411 explicit IsParameterMatcher(const Matcher<int>& index_matcher) 1527 explicit IsParameterMatcher(const Matcher<int>& index_matcher)
1412 : NodeMatcher(IrOpcode::kParameter), index_matcher_(index_matcher) {} 1528 : NodeMatcher(IrOpcode::kParameter), index_matcher_(index_matcher) {}
1413 1529
1414 void DescribeTo(std::ostream* os) const override { 1530 void DescribeTo(std::ostream* os) const override {
1415 *os << "is a Parameter node with index("; 1531 *os << "is a Parameter node with index(";
1416 index_matcher_.DescribeTo(os); 1532 index_matcher_.DescribeTo(os);
1417 *os << ")"; 1533 *os << ")";
1418 } 1534 }
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2528 2644
2529 Matcher<Node*> IsJSCallRuntime(std::vector<Matcher<Node*>> value_matchers, 2645 Matcher<Node*> IsJSCallRuntime(std::vector<Matcher<Node*>> value_matchers,
2530 const Matcher<Node*>& effect_matcher, 2646 const Matcher<Node*>& effect_matcher,
2531 const Matcher<Node*>& control_matcher) { 2647 const Matcher<Node*>& control_matcher) {
2532 return MakeMatcher(new IsJSCallMatcher(IrOpcode::kJSCallRuntime, 2648 return MakeMatcher(new IsJSCallMatcher(IrOpcode::kJSCallRuntime,
2533 value_matchers, effect_matcher, 2649 value_matchers, effect_matcher,
2534 control_matcher)); 2650 control_matcher));
2535 } 2651 }
2536 2652
2537 2653
2654 Matcher<Node*> IsJSBinaryOperation(IrOpcode::Value opcode,
2655 const Matcher<Node*>& lhs_matcher,
2656 const Matcher<Node*>& rhs_matcher,
2657 const Matcher<Node*>& effect_matcher,
2658 const Matcher<Node*>& control_matcher) {
2659 return MakeMatcher(new IsJSBinopMatcher(opcode, lhs_matcher, rhs_matcher,
2660 effect_matcher, control_matcher));
2661 }
2662
2663
2538 #define IS_BINOP_MATCHER(Name) \ 2664 #define IS_BINOP_MATCHER(Name) \
2539 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ 2665 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \
2540 const Matcher<Node*>& rhs_matcher) { \ 2666 const Matcher<Node*>& rhs_matcher) { \
2541 return MakeMatcher( \ 2667 return MakeMatcher( \
2542 new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \ 2668 new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \
2543 } 2669 }
2544 IS_BINOP_MATCHER(NumberEqual) 2670 IS_BINOP_MATCHER(NumberEqual)
2545 IS_BINOP_MATCHER(NumberLessThan) 2671 IS_BINOP_MATCHER(NumberLessThan)
2546 IS_BINOP_MATCHER(NumberSubtract) 2672 IS_BINOP_MATCHER(NumberSubtract)
2547 IS_BINOP_MATCHER(NumberMultiply) 2673 IS_BINOP_MATCHER(NumberMultiply)
(...skipping 17 matching lines...) Expand all
2565 IS_BINOP_MATCHER(Int32Add) 2691 IS_BINOP_MATCHER(Int32Add)
2566 IS_BINOP_MATCHER(Int32Sub) 2692 IS_BINOP_MATCHER(Int32Sub)
2567 IS_BINOP_MATCHER(Int32Mul) 2693 IS_BINOP_MATCHER(Int32Mul)
2568 IS_BINOP_MATCHER(Int32MulHigh) 2694 IS_BINOP_MATCHER(Int32MulHigh)
2569 IS_BINOP_MATCHER(Int32LessThan) 2695 IS_BINOP_MATCHER(Int32LessThan)
2570 IS_BINOP_MATCHER(Uint32LessThan) 2696 IS_BINOP_MATCHER(Uint32LessThan)
2571 IS_BINOP_MATCHER(Uint32LessThanOrEqual) 2697 IS_BINOP_MATCHER(Uint32LessThanOrEqual)
2572 IS_BINOP_MATCHER(Int64Add) 2698 IS_BINOP_MATCHER(Int64Add)
2573 IS_BINOP_MATCHER(Int64Sub) 2699 IS_BINOP_MATCHER(Int64Sub)
2574 IS_BINOP_MATCHER(Int64Mul) 2700 IS_BINOP_MATCHER(Int64Mul)
2575 IS_BINOP_MATCHER(JSAdd)
2576 IS_BINOP_MATCHER(Float32Max) 2701 IS_BINOP_MATCHER(Float32Max)
2577 IS_BINOP_MATCHER(Float32Min) 2702 IS_BINOP_MATCHER(Float32Min)
2578 IS_BINOP_MATCHER(Float32Equal) 2703 IS_BINOP_MATCHER(Float32Equal)
2579 IS_BINOP_MATCHER(Float32LessThan) 2704 IS_BINOP_MATCHER(Float32LessThan)
2580 IS_BINOP_MATCHER(Float32LessThanOrEqual) 2705 IS_BINOP_MATCHER(Float32LessThanOrEqual)
2581 IS_BINOP_MATCHER(Float64Max) 2706 IS_BINOP_MATCHER(Float64Max)
2582 IS_BINOP_MATCHER(Float64Min) 2707 IS_BINOP_MATCHER(Float64Min)
2583 IS_BINOP_MATCHER(Float64Sub) 2708 IS_BINOP_MATCHER(Float64Sub)
2584 IS_BINOP_MATCHER(Float64InsertLowWord32) 2709 IS_BINOP_MATCHER(Float64InsertLowWord32)
2585 IS_BINOP_MATCHER(Float64InsertHighWord32) 2710 IS_BINOP_MATCHER(Float64InsertHighWord32)
(...skipping 20 matching lines...) Expand all
2606 IS_UNOP_MATCHER(Float64Sqrt) 2731 IS_UNOP_MATCHER(Float64Sqrt)
2607 IS_UNOP_MATCHER(Float64RoundDown) 2732 IS_UNOP_MATCHER(Float64RoundDown)
2608 IS_UNOP_MATCHER(Float64RoundTruncate) 2733 IS_UNOP_MATCHER(Float64RoundTruncate)
2609 IS_UNOP_MATCHER(Float64RoundTiesAway) 2734 IS_UNOP_MATCHER(Float64RoundTiesAway)
2610 IS_UNOP_MATCHER(Float64ExtractLowWord32) 2735 IS_UNOP_MATCHER(Float64ExtractLowWord32)
2611 IS_UNOP_MATCHER(Float64ExtractHighWord32) 2736 IS_UNOP_MATCHER(Float64ExtractHighWord32)
2612 IS_UNOP_MATCHER(NumberToInt32) 2737 IS_UNOP_MATCHER(NumberToInt32)
2613 IS_UNOP_MATCHER(NumberToUint32) 2738 IS_UNOP_MATCHER(NumberToUint32)
2614 IS_UNOP_MATCHER(ObjectIsSmi) 2739 IS_UNOP_MATCHER(ObjectIsSmi)
2615 IS_UNOP_MATCHER(Word32Clz) 2740 IS_UNOP_MATCHER(Word32Clz)
2616 IS_UNOP_MATCHER(JSUnaryNot)
2617 IS_UNOP_MATCHER(JSTypeOf)
2618 #undef IS_UNOP_MATCHER 2741 #undef IS_UNOP_MATCHER
2619 2742
2743
2744 #define IS_UNOP_EFFECT_MATCHER(Name) \
2745 Matcher<Node*> Is##Name(const Matcher<Node*>& input_matcher, \
2746 const Matcher<Node*>& effect_matcher) { \
2747 return MakeMatcher(new IsUnopWithEffectMatcher( \
2748 IrOpcode::k##Name, input_matcher, effect_matcher)); \
2749 }
2750 IS_UNOP_EFFECT_MATCHER(JSUnaryNot)
2751 IS_UNOP_EFFECT_MATCHER(JSTypeOf)
2752 IS_UNOP_EFFECT_MATCHER(JSToBoolean)
2753 #undef IS_UNOP_EFFECT_MATCHER
2754
2755
2756 #define IS_UNOP_EFFECT_CONTROL_MATCHER(Name) \
2757 Matcher<Node*> Is##Name(const Matcher<Node*>& input_matcher, \
2758 const Matcher<Node*>& effect_matcher, \
2759 const Matcher<Node*>& control_matcher) { \
2760 return MakeMatcher(new IsUnopEffectControlMatcher( \
2761 IrOpcode::k##Name, input_matcher, effect_matcher, control_matcher)); \
2762 }
2763 IS_UNOP_EFFECT_CONTROL_MATCHER(JSToName)
2764 IS_UNOP_EFFECT_CONTROL_MATCHER(JSToObject)
2765 #undef IS_UNOP_EFFECT_CONTROL_MATCHER
2766
2620 } // namespace compiler 2767 } // namespace compiler
2621 } // namespace internal 2768 } // namespace internal
2622 } // namespace v8 2769 } // namespace v8
OLDNEW
« src/interpreter/bytecode-array-builder.cc ('K') | « test/unittests/compiler/node-test-utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698