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

Side by Side Diff: test/compiler-unittests/graph-unittest.cc

Issue 479793004: [turbofan] Initial import of SimplifiedOperatorReducer. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 6 years, 4 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 "test/compiler-unittests/graph-unittest.h" 5 #include "test/compiler-unittests/graph-unittest.h"
6 6
7 #include <ostream> // NOLINT(readability/streams) 7 #include <ostream> // NOLINT(readability/streams)
8 8
9 #include "src/compiler/node-properties-inl.h" 9 #include "src/compiler/node-properties-inl.h"
10 10
(...skipping 22 matching lines...) Expand all
33 namespace compiler { 33 namespace compiler {
34 34
35 GraphTest::GraphTest(int num_parameters) : graph_(zone()) { 35 GraphTest::GraphTest(int num_parameters) : graph_(zone()) {
36 graph()->SetStart(graph()->NewNode(common()->Start(num_parameters))); 36 graph()->SetStart(graph()->NewNode(common()->Start(num_parameters)));
37 } 37 }
38 38
39 39
40 GraphTest::~GraphTest() {} 40 GraphTest::~GraphTest() {}
41 41
42 42
43 Node* GraphTest::Parameter(int32_t index) {
44 return graph()->NewNode(common()->Parameter(index), graph()->start());
45 }
46
47
48 Node* GraphTest::Float64Constant(double value) {
49 return graph()->NewNode(common()->Float64Constant(value));
50 }
51
52
53 Node* GraphTest::Int32Constant(int32_t value) {
54 return graph()->NewNode(common()->Int32Constant(value));
55 }
56
57
58 Node* GraphTest::NumberConstant(double value) {
59 return graph()->NewNode(common()->NumberConstant(value));
60 }
61
62
63 Node* GraphTest::HeapConstant(const PrintableUnique<HeapObject>& value) {
64 return graph()->NewNode(common()->HeapConstant(value));
65 }
66
67
68 Node* GraphTest::FalseConstant() {
69 return HeapConstant(PrintableUnique<HeapObject>::CreateImmovable(
70 zone(), factory()->false_value()));
71 }
72
73
74 Node* GraphTest::TrueConstant() {
75 return HeapConstant(PrintableUnique<HeapObject>::CreateImmovable(
76 zone(), factory()->true_value()));
77 }
78
79
80 Matcher<Node*> GraphTest::IsFalseConstant() {
81 return IsHeapConstant(PrintableUnique<HeapObject>::CreateImmovable(
82 zone(), factory()->false_value()));
83 }
84
85
86 Matcher<Node*> GraphTest::IsTrueConstant() {
87 return IsHeapConstant(PrintableUnique<HeapObject>::CreateImmovable(
88 zone(), factory()->true_value()));
89 }
90
43 namespace { 91 namespace {
44 92
45 template <typename T> 93 template <typename T>
46 bool PrintMatchAndExplain(const T& value, const char* value_name, 94 bool PrintMatchAndExplain(const T& value, const char* value_name,
47 const Matcher<T>& value_matcher, 95 const Matcher<T>& value_matcher,
48 MatchResultListener* listener) { 96 MatchResultListener* listener) {
49 StringMatchResultListener value_listener; 97 StringMatchResultListener value_listener;
50 if (!value_matcher.MatchAndExplain(value, &value_listener)) { 98 if (!value_matcher.MatchAndExplain(value, &value_listener)) {
51 *listener << "whose " << value_name << " " << value << " doesn't match"; 99 *listener << "whose " << value_name << " " << value << " doesn't match";
52 if (value_listener.str() != "") { 100 if (value_listener.str() != "") {
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 IrOpcode::kHeapConstant, value_matcher)); 640 IrOpcode::kHeapConstant, value_matcher));
593 } 641 }
594 642
595 643
596 Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher) { 644 Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher) {
597 return MakeMatcher( 645 return MakeMatcher(
598 new IsConstantMatcher<int32_t>(IrOpcode::kInt32Constant, value_matcher)); 646 new IsConstantMatcher<int32_t>(IrOpcode::kInt32Constant, value_matcher));
599 } 647 }
600 648
601 649
650 Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher) {
651 return MakeMatcher(
652 new IsConstantMatcher<double>(IrOpcode::kFloat64Constant, value_matcher));
653 }
654
655
602 Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher) { 656 Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher) {
603 return MakeMatcher( 657 return MakeMatcher(
604 new IsConstantMatcher<double>(IrOpcode::kNumberConstant, value_matcher)); 658 new IsConstantMatcher<double>(IrOpcode::kNumberConstant, value_matcher));
605 } 659 }
606 660
607 661
608 Matcher<Node*> IsPhi(const Matcher<Node*>& value0_matcher, 662 Matcher<Node*> IsPhi(const Matcher<Node*>& value0_matcher,
609 const Matcher<Node*>& value1_matcher, 663 const Matcher<Node*>& value1_matcher,
610 const Matcher<Node*>& merge_matcher) { 664 const Matcher<Node*>& merge_matcher) {
611 return MakeMatcher( 665 return MakeMatcher(
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 IS_UNOP_MATCHER(ChangeInt32ToInt64) 737 IS_UNOP_MATCHER(ChangeInt32ToInt64)
684 IS_UNOP_MATCHER(ChangeUint32ToFloat64) 738 IS_UNOP_MATCHER(ChangeUint32ToFloat64)
685 IS_UNOP_MATCHER(ChangeUint32ToUint64) 739 IS_UNOP_MATCHER(ChangeUint32ToUint64)
686 IS_UNOP_MATCHER(TruncateFloat64ToInt32) 740 IS_UNOP_MATCHER(TruncateFloat64ToInt32)
687 IS_UNOP_MATCHER(TruncateInt64ToInt32) 741 IS_UNOP_MATCHER(TruncateInt64ToInt32)
688 #undef IS_UNOP_MATCHER 742 #undef IS_UNOP_MATCHER
689 743
690 } // namespace compiler 744 } // namespace compiler
691 } // namespace internal 745 } // namespace internal
692 } // namespace v8 746 } // namespace v8
OLDNEW
« no previous file with comments | « test/compiler-unittests/graph-unittest.h ('k') | test/compiler-unittests/machine-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698