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_UNITTESTS_COMPILER_NODE_TEST_UTILS_H_
6 #define V8_UNITTESTS_COMPILER_NODE_TEST_UTILS_H_
8 #include "src/compiler/machine-operator.h"
9 #include "src/compiler/machine-type.h"
10 #include "testing/gmock/include/gmock/gmock.h"
15 // Forward declarations.
16 class ExternalReference;
23 // Forward declarations.
31 using ::testing::Matcher;
34 Matcher<Node*> IsAlways();
35 Matcher<Node*> IsEnd(const Matcher<Node*>& control_matcher);
36 Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher,
37 const Matcher<Node*>& control_matcher);
38 Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
39 const Matcher<Node*>& control1_matcher);
40 Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
41 const Matcher<Node*>& control1_matcher,
42 const Matcher<Node*>& control2_matcher);
43 Matcher<Node*> IsLoop(const Matcher<Node*>& control0_matcher,
44 const Matcher<Node*>& control1_matcher);
45 Matcher<Node*> IsLoop(const Matcher<Node*>& control0_matcher,
46 const Matcher<Node*>& control1_matcher,
47 const Matcher<Node*>& control2_matcher);
48 Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher);
49 Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher);
50 Matcher<Node*> IsSwitch(const Matcher<Node*>& value_matcher,
51 const Matcher<Node*>& control_matcher);
52 Matcher<Node*> IsIfValue(const Matcher<int32_t>& value_matcher,
53 const Matcher<Node*>& control_matcher);
54 Matcher<Node*> IsIfDefault(const Matcher<Node*>& control_matcher);
55 Matcher<Node*> IsValueEffect(const Matcher<Node*>& value_matcher);
56 Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher,
57 const Matcher<Node*>& effect_matcher);
58 Matcher<Node*> IsReturn(const Matcher<Node*>& value_matcher,
59 const Matcher<Node*>& effect_matcher,
60 const Matcher<Node*>& control_matcher);
61 Matcher<Node*> IsExternalConstant(
62 const Matcher<ExternalReference>& value_matcher);
63 Matcher<Node*> IsHeapConstant(
64 const Matcher<Unique<HeapObject> >& value_matcher);
65 Matcher<Node*> IsFloat32Constant(const Matcher<float>& value_matcher);
66 Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher);
67 Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher);
68 Matcher<Node*> IsInt64Constant(const Matcher<int64_t>& value_matcher);
69 Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher);
70 Matcher<Node*> IsSelect(const Matcher<MachineType>& type_matcher,
71 const Matcher<Node*>& value0_matcher,
72 const Matcher<Node*>& value1_matcher,
73 const Matcher<Node*>& value2_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*> IsPhi(const Matcher<MachineType>& type_matcher,
79 const Matcher<Node*>& value0_matcher,
80 const Matcher<Node*>& value1_matcher,
81 const Matcher<Node*>& value2_matcher,
82 const Matcher<Node*>& merge_matcher);
83 Matcher<Node*> IsEffectPhi(const Matcher<Node*>& effect0_matcher,
84 const Matcher<Node*>& effect1_matcher,
85 const Matcher<Node*>& merge_matcher);
86 Matcher<Node*> IsEffectSet(const Matcher<Node*>& effect0_matcher,
87 const Matcher<Node*>& effect1_matcher);
88 Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher,
89 const Matcher<Node*>& base_matcher);
90 Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher,
91 const Matcher<Node*>& value0_matcher,
92 const Matcher<Node*>& value1_matcher,
93 const Matcher<Node*>& effect_matcher,
94 const Matcher<Node*>& control_matcher);
95 Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher,
96 const Matcher<Node*>& value0_matcher,
97 const Matcher<Node*>& value1_matcher,
98 const Matcher<Node*>& value2_matcher,
99 const Matcher<Node*>& value3_matcher,
100 const Matcher<Node*>& effect_matcher,
101 const Matcher<Node*>& control_matcher);
103 Matcher<Node*> IsAnyToBoolean(const Matcher<Node*>& value_matcher);
104 Matcher<Node*> IsBooleanNot(const Matcher<Node*>& value_matcher);
105 Matcher<Node*> IsNumberEqual(const Matcher<Node*>& lhs_matcher,
106 const Matcher<Node*>& rhs_matcher);
107 Matcher<Node*> IsNumberLessThan(const Matcher<Node*>& lhs_matcher,
108 const Matcher<Node*>& rhs_matcher);
109 Matcher<Node*> IsNumberSubtract(const Matcher<Node*>& lhs_matcher,
110 const Matcher<Node*>& rhs_matcher);
111 Matcher<Node*> IsNumberMultiply(const Matcher<Node*>& lhs_matcher,
112 const Matcher<Node*>& rhs_matcher);
113 Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher,
114 const Matcher<Node*>& base_matcher,
115 const Matcher<Node*>& effect_matcher,
116 const Matcher<Node*>& control_matcher);
117 Matcher<Node*> IsStoreField(const Matcher<FieldAccess>& access_matcher,
118 const Matcher<Node*>& base_matcher,
119 const Matcher<Node*>& value_matcher,
120 const Matcher<Node*>& effect_matcher,
121 const Matcher<Node*>& control_matcher);
122 Matcher<Node*> IsLoadBuffer(const Matcher<BufferAccess>& access_matcher,
123 const Matcher<Node*>& buffer_matcher,
124 const Matcher<Node*>& offset_matcher,
125 const Matcher<Node*>& length_matcher,
126 const Matcher<Node*>& effect_matcher,
127 const Matcher<Node*>& control_matcher);
128 Matcher<Node*> IsStoreBuffer(const Matcher<BufferAccess>& access_matcher,
129 const Matcher<Node*>& buffer_matcher,
130 const Matcher<Node*>& offset_matcher,
131 const Matcher<Node*>& length_matcher,
132 const Matcher<Node*>& value_matcher,
133 const Matcher<Node*>& effect_matcher,
134 const Matcher<Node*>& control_matcher);
135 Matcher<Node*> IsLoadElement(const Matcher<ElementAccess>& access_matcher,
136 const Matcher<Node*>& base_matcher,
137 const Matcher<Node*>& index_matcher,
138 const Matcher<Node*>& control_matcher,
139 const Matcher<Node*>& effect_matcher);
140 Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher,
141 const Matcher<Node*>& base_matcher,
142 const Matcher<Node*>& index_matcher,
143 const Matcher<Node*>& value_matcher,
144 const Matcher<Node*>& effect_matcher,
145 const Matcher<Node*>& control_matcher);
146 Matcher<Node*> IsObjectIsSmi(const Matcher<Node*>& value_matcher);
147 Matcher<Node*> IsObjectIsNonNegativeSmi(const Matcher<Node*>& value_matcher);
149 Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher,
150 const Matcher<Node*>& base_matcher,
151 const Matcher<Node*>& index_matcher,
152 const Matcher<Node*>& effect_matcher,
153 const Matcher<Node*>& control_matcher);
154 Matcher<Node*> IsStore(const Matcher<StoreRepresentation>& rep_matcher,
155 const Matcher<Node*>& base_matcher,
156 const Matcher<Node*>& index_matcher,
157 const Matcher<Node*>& value_matcher,
158 const Matcher<Node*>& effect_matcher,
159 const Matcher<Node*>& control_matcher);
160 Matcher<Node*> IsWord32And(const Matcher<Node*>& lhs_matcher,
161 const Matcher<Node*>& rhs_matcher);
162 Matcher<Node*> IsWord32Sar(const Matcher<Node*>& lhs_matcher,
163 const Matcher<Node*>& rhs_matcher);
164 Matcher<Node*> IsWord32Shl(const Matcher<Node*>& lhs_matcher,
165 const Matcher<Node*>& rhs_matcher);
166 Matcher<Node*> IsWord32Shr(const Matcher<Node*>& lhs_matcher,
167 const Matcher<Node*>& rhs_matcher);
168 Matcher<Node*> IsWord32Ror(const Matcher<Node*>& lhs_matcher,
169 const Matcher<Node*>& rhs_matcher);
170 Matcher<Node*> IsWord32Equal(const Matcher<Node*>& lhs_matcher,
171 const Matcher<Node*>& rhs_matcher);
172 Matcher<Node*> IsWord64And(const Matcher<Node*>& lhs_matcher,
173 const Matcher<Node*>& rhs_matcher);
174 Matcher<Node*> IsWord64Shl(const Matcher<Node*>& lhs_matcher,
175 const Matcher<Node*>& rhs_matcher);
176 Matcher<Node*> IsWord64Sar(const Matcher<Node*>& lhs_matcher,
177 const Matcher<Node*>& rhs_matcher);
178 Matcher<Node*> IsWord64Equal(const Matcher<Node*>& lhs_matcher,
179 const Matcher<Node*>& rhs_matcher);
180 Matcher<Node*> IsInt32AddWithOverflow(const Matcher<Node*>& lhs_matcher,
181 const Matcher<Node*>& rhs_matcher);
182 Matcher<Node*> IsInt32Add(const Matcher<Node*>& lhs_matcher,
183 const Matcher<Node*>& rhs_matcher);
184 Matcher<Node*> IsInt32Sub(const Matcher<Node*>& lhs_matcher,
185 const Matcher<Node*>& rhs_matcher);
186 Matcher<Node*> IsInt32Mul(const Matcher<Node*>& lhs_matcher,
187 const Matcher<Node*>& rhs_matcher);
188 Matcher<Node*> IsInt32MulHigh(const Matcher<Node*>& lhs_matcher,
189 const Matcher<Node*>& rhs_matcher);
190 Matcher<Node*> IsInt32LessThan(const Matcher<Node*>& lhs_matcher,
191 const Matcher<Node*>& rhs_matcher);
192 Matcher<Node*> IsUint32LessThan(const Matcher<Node*>& lhs_matcher,
193 const Matcher<Node*>& rhs_matcher);
194 Matcher<Node*> IsUint32LessThanOrEqual(const Matcher<Node*>& lhs_matcher,
195 const Matcher<Node*>& rhs_matcher);
196 Matcher<Node*> IsChangeFloat64ToInt32(const Matcher<Node*>& input_matcher);
197 Matcher<Node*> IsChangeFloat64ToUint32(const Matcher<Node*>& input_matcher);
198 Matcher<Node*> IsChangeInt32ToFloat64(const Matcher<Node*>& input_matcher);
199 Matcher<Node*> IsChangeInt32ToInt64(const Matcher<Node*>& input_matcher);
200 Matcher<Node*> IsChangeUint32ToFloat64(const Matcher<Node*>& input_matcher);
201 Matcher<Node*> IsChangeUint32ToUint64(const Matcher<Node*>& input_matcher);
202 Matcher<Node*> IsTruncateFloat64ToFloat32(const Matcher<Node*>& input_matcher);
203 Matcher<Node*> IsTruncateFloat64ToInt32(const Matcher<Node*>& input_matcher);
204 Matcher<Node*> IsTruncateInt64ToInt32(const Matcher<Node*>& input_matcher);
205 Matcher<Node*> IsFloat64Sub(const Matcher<Node*>& lhs_matcher,
206 const Matcher<Node*>& rhs_matcher);
207 Matcher<Node*> IsFloat64Sqrt(const Matcher<Node*>& input_matcher);
208 Matcher<Node*> IsFloat64Floor(const Matcher<Node*>& input_matcher);
209 Matcher<Node*> IsFloat64Ceil(const Matcher<Node*>& input_matcher);
210 Matcher<Node*> IsFloat64RoundTruncate(const Matcher<Node*>& input_matcher);
211 Matcher<Node*> IsFloat64RoundTiesAway(const Matcher<Node*>& input_matcher);
212 Matcher<Node*> IsToNumber(const Matcher<Node*>& base_matcher,
213 const Matcher<Node*>& context_matcher,
214 const Matcher<Node*>& effect_matcher,
215 const Matcher<Node*>& control_matcher);
216 Matcher<Node*> IsNumberToInt32(const Matcher<Node*>& input_matcher);
217 Matcher<Node*> IsNumberToUint32(const Matcher<Node*>& input_matcher);
219 } // namespace compiler
220 } // namespace internal
223 #endif // V8_UNITTESTS_COMPILER_NODE_TEST_UTILS_H_