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
3 // found in the LICENSE file.
5 #ifndef V8_COMPILER_GRAPH_UNITTEST_H_
6 #define V8_COMPILER_GRAPH_UNITTEST_H_
8 #include "src/compiler/common-operator.h"
9 #include "src/compiler/graph.h"
10 #include "src/compiler/machine-operator.h"
11 #include "src/test/test-utils.h"
12 #include "testing/gmock/include/gmock/gmock.h"
17 // Forward declarations.
24 using ::testing::Matcher;
27 class GraphTest : public TestWithContext, public TestWithZone {
29 explicit GraphTest(int parameters = 1);
33 Node* Parameter(int32_t index);
34 Node* Float32Constant(volatile float value);
35 Node* Float64Constant(volatile double value);
36 Node* Int32Constant(int32_t value);
37 Node* Int64Constant(int64_t value);
38 Node* NumberConstant(volatile double value);
39 Node* HeapConstant(const Unique<HeapObject>& value);
40 Node* FalseConstant();
43 Matcher<Node*> IsFalseConstant();
44 Matcher<Node*> IsTrueConstant();
46 CommonOperatorBuilder* common() { return &common_; }
47 Graph* graph() { return &graph_; }
50 CommonOperatorBuilder common_;
55 Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher,
56 const Matcher<Node*>& control_matcher);
57 Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
58 const Matcher<Node*>& control1_matcher);
59 Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher);
60 Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher);
61 Matcher<Node*> IsControlEffect(const Matcher<Node*>& control_matcher);
62 Matcher<Node*> IsValueEffect(const Matcher<Node*>& value_matcher);
63 Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher,
64 const Matcher<Node*>& effect_matcher);
65 Matcher<Node*> IsExternalConstant(
66 const Matcher<ExternalReference>& value_matcher);
67 Matcher<Node*> IsHeapConstant(
68 const Matcher<Unique<HeapObject> >& value_matcher);
69 Matcher<Node*> IsFloat32Constant(const Matcher<float>& value_matcher);
70 Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher);
71 Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher);
72 Matcher<Node*> IsInt64Constant(const Matcher<int64_t>& value_matcher);
73 Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher);
74 Matcher<Node*> IsPhi(const Matcher<MachineType>& type_matcher,
75 const Matcher<Node*>& value0_matcher,
76 const Matcher<Node*>& value1_matcher,
77 const Matcher<Node*>& merge_matcher);
78 Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher,
79 const Matcher<Node*>& base_matcher);
80 Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher,
81 const Matcher<Node*>& value0_matcher,
82 const Matcher<Node*>& value1_matcher,
83 const Matcher<Node*>& value2_matcher,
84 const Matcher<Node*>& value3_matcher,
85 const Matcher<Node*>& effect_matcher,
86 const Matcher<Node*>& control_matcher);
88 Matcher<Node*> IsNumberLessThan(const Matcher<Node*>& lhs_matcher,
89 const Matcher<Node*>& rhs_matcher);
91 Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher,
92 const Matcher<Node*>& base_matcher,
93 const Matcher<Node*>& index_matcher,
94 const Matcher<Node*>& effect_matcher);
95 Matcher<Node*> IsStore(const Matcher<MachineType>& type_matcher,
96 const Matcher<WriteBarrierKind>& write_barrier_matcher,
97 const Matcher<Node*>& base_matcher,
98 const Matcher<Node*>& index_matcher,
99 const Matcher<Node*>& value_matcher,
100 const Matcher<Node*>& effect_matcher,
101 const Matcher<Node*>& control_matcher);
102 Matcher<Node*> IsWord32And(const Matcher<Node*>& lhs_matcher,
103 const Matcher<Node*>& rhs_matcher);
104 Matcher<Node*> IsWord32Sar(const Matcher<Node*>& lhs_matcher,
105 const Matcher<Node*>& rhs_matcher);
106 Matcher<Node*> IsWord32Shl(const Matcher<Node*>& lhs_matcher,
107 const Matcher<Node*>& rhs_matcher);
108 Matcher<Node*> IsWord32Ror(const Matcher<Node*>& lhs_matcher,
109 const Matcher<Node*>& rhs_matcher);
110 Matcher<Node*> IsWord32Equal(const Matcher<Node*>& lhs_matcher,
111 const Matcher<Node*>& rhs_matcher);
112 Matcher<Node*> IsWord64And(const Matcher<Node*>& lhs_matcher,
113 const Matcher<Node*>& rhs_matcher);
114 Matcher<Node*> IsWord64Shl(const Matcher<Node*>& lhs_matcher,
115 const Matcher<Node*>& rhs_matcher);
116 Matcher<Node*> IsWord64Sar(const Matcher<Node*>& lhs_matcher,
117 const Matcher<Node*>& rhs_matcher);
118 Matcher<Node*> IsWord64Equal(const Matcher<Node*>& lhs_matcher,
119 const Matcher<Node*>& rhs_matcher);
120 Matcher<Node*> IsInt32AddWithOverflow(const Matcher<Node*>& lhs_matcher,
121 const Matcher<Node*>& rhs_matcher);
122 Matcher<Node*> IsInt32Mul(const Matcher<Node*>& lhs_matcher,
123 const Matcher<Node*>& rhs_matcher);
124 Matcher<Node*> IsUint32LessThanOrEqual(const Matcher<Node*>& lhs_matcher,
125 const Matcher<Node*>& rhs_matcher);
126 Matcher<Node*> IsChangeFloat64ToInt32(const Matcher<Node*>& input_matcher);
127 Matcher<Node*> IsChangeFloat64ToUint32(const Matcher<Node*>& input_matcher);
128 Matcher<Node*> IsChangeInt32ToFloat64(const Matcher<Node*>& input_matcher);
129 Matcher<Node*> IsChangeInt32ToInt64(const Matcher<Node*>& input_matcher);
130 Matcher<Node*> IsChangeUint32ToFloat64(const Matcher<Node*>& input_matcher);
131 Matcher<Node*> IsChangeUint32ToUint64(const Matcher<Node*>& input_matcher);
132 Matcher<Node*> IsTruncateFloat64ToInt32(const Matcher<Node*>& input_matcher);
133 Matcher<Node*> IsTruncateInt64ToInt32(const Matcher<Node*>& input_matcher);
134 Matcher<Node*> IsFloat64Sqrt(const Matcher<Node*>& input_matcher);
136 } // namespace compiler
137 } // namespace internal
140 #endif // V8_COMPILER_GRAPH_UNITTEST_H_