Line data Source code
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.
4 :
5 : #include "src/compiler/machine-operator.h"
6 :
7 : #include "src/base/lazy-instance.h"
8 : #include "src/compiler/opcodes.h"
9 : #include "src/compiler/operator.h"
10 :
11 : namespace v8 {
12 : namespace internal {
13 : namespace compiler {
14 :
15 336 : bool operator==(StoreRepresentation lhs, StoreRepresentation rhs) {
16 672 : return lhs.representation() == rhs.representation() &&
17 672 : lhs.write_barrier_kind() == rhs.write_barrier_kind();
18 : }
19 :
20 :
21 0 : bool operator!=(StoreRepresentation lhs, StoreRepresentation rhs) {
22 0 : return !(lhs == rhs);
23 : }
24 :
25 :
26 0 : size_t hash_value(StoreRepresentation rep) {
27 0 : return base::hash_combine(rep.representation(), rep.write_barrier_kind());
28 : }
29 :
30 :
31 0 : std::ostream& operator<<(std::ostream& os, StoreRepresentation rep) {
32 0 : return os << "(" << rep.representation() << " : " << rep.write_barrier_kind()
33 0 : << ")";
34 : }
35 :
36 :
37 8557914 : LoadRepresentation LoadRepresentationOf(Operator const* op) {
38 : DCHECK(IrOpcode::kLoad == op->opcode() ||
39 : IrOpcode::kProtectedLoad == op->opcode() ||
40 : IrOpcode::kAtomicLoad == op->opcode());
41 8557914 : return OpParameter<LoadRepresentation>(op);
42 : }
43 :
44 :
45 3724848 : StoreRepresentation const& StoreRepresentationOf(Operator const* op) {
46 : DCHECK(IrOpcode::kStore == op->opcode() ||
47 : IrOpcode::kProtectedStore == op->opcode());
48 3724848 : return OpParameter<StoreRepresentation>(op);
49 : }
50 :
51 1 : UnalignedLoadRepresentation UnalignedLoadRepresentationOf(Operator const* op) {
52 : DCHECK_EQ(IrOpcode::kUnalignedLoad, op->opcode());
53 1 : return OpParameter<UnalignedLoadRepresentation>(op);
54 : }
55 :
56 1 : UnalignedStoreRepresentation const& UnalignedStoreRepresentationOf(
57 : Operator const* op) {
58 : DCHECK_EQ(IrOpcode::kUnalignedStore, op->opcode());
59 1 : return OpParameter<UnalignedStoreRepresentation>(op);
60 : }
61 :
62 148380 : CheckedLoadRepresentation CheckedLoadRepresentationOf(Operator const* op) {
63 : DCHECK_EQ(IrOpcode::kCheckedLoad, op->opcode());
64 148380 : return OpParameter<CheckedLoadRepresentation>(op);
65 : }
66 :
67 :
68 117298 : CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) {
69 : DCHECK_EQ(IrOpcode::kCheckedStore, op->opcode());
70 117298 : return OpParameter<CheckedStoreRepresentation>(op);
71 : }
72 :
73 1418 : int StackSlotSizeOf(Operator const* op) {
74 : DCHECK_EQ(IrOpcode::kStackSlot, op->opcode());
75 1418 : return OpParameter<int>(op);
76 : }
77 :
78 129 : MachineRepresentation AtomicStoreRepresentationOf(Operator const* op) {
79 : DCHECK_EQ(IrOpcode::kAtomicStore, op->opcode());
80 129 : return OpParameter<MachineRepresentation>(op);
81 : }
82 :
83 3612 : MachineType AtomicOpRepresentationOf(Operator const* op) {
84 3612 : return OpParameter<MachineType>(op);
85 : }
86 :
87 : #define PURE_BINARY_OP_LIST_32(V) \
88 : V(Word32And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
89 : V(Word32Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
90 : V(Word32Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
91 : V(Word32Shl, Operator::kNoProperties, 2, 0, 1) \
92 : V(Word32Shr, Operator::kNoProperties, 2, 0, 1) \
93 : V(Word32Sar, Operator::kNoProperties, 2, 0, 1) \
94 : V(Word32Ror, Operator::kNoProperties, 2, 0, 1) \
95 : V(Word32Equal, Operator::kCommutative, 2, 0, 1) \
96 : V(Int32Add, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
97 : V(Int32Sub, Operator::kNoProperties, 2, 0, 1) \
98 : V(Int32Mul, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
99 : V(Int32MulHigh, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
100 : V(Int32Div, Operator::kNoProperties, 2, 1, 1) \
101 : V(Int32Mod, Operator::kNoProperties, 2, 1, 1) \
102 : V(Int32LessThan, Operator::kNoProperties, 2, 0, 1) \
103 : V(Int32LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \
104 : V(Uint32Div, Operator::kNoProperties, 2, 1, 1) \
105 : V(Uint32LessThan, Operator::kNoProperties, 2, 0, 1) \
106 : V(Uint32LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \
107 : V(Uint32Mod, Operator::kNoProperties, 2, 1, 1) \
108 : V(Uint32MulHigh, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)
109 :
110 : #define PURE_BINARY_OP_LIST_64(V) \
111 : V(Word64And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
112 : V(Word64Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
113 : V(Word64Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
114 : V(Word64Shl, Operator::kNoProperties, 2, 0, 1) \
115 : V(Word64Shr, Operator::kNoProperties, 2, 0, 1) \
116 : V(Word64Sar, Operator::kNoProperties, 2, 0, 1) \
117 : V(Word64Ror, Operator::kNoProperties, 2, 0, 1) \
118 : V(Word64Equal, Operator::kCommutative, 2, 0, 1) \
119 : V(Int64Add, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
120 : V(Int64Sub, Operator::kNoProperties, 2, 0, 1) \
121 : V(Int64Mul, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
122 : V(Int64Div, Operator::kNoProperties, 2, 1, 1) \
123 : V(Int64Mod, Operator::kNoProperties, 2, 1, 1) \
124 : V(Int64LessThan, Operator::kNoProperties, 2, 0, 1) \
125 : V(Int64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \
126 : V(Uint64Div, Operator::kNoProperties, 2, 1, 1) \
127 : V(Uint64Mod, Operator::kNoProperties, 2, 1, 1) \
128 : V(Uint64LessThan, Operator::kNoProperties, 2, 0, 1) \
129 : V(Uint64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)
130 :
131 : #define PURE_OP_LIST(V) \
132 : PURE_BINARY_OP_LIST_32(V) \
133 : PURE_BINARY_OP_LIST_64(V) \
134 : V(Word32Clz, Operator::kNoProperties, 1, 0, 1) \
135 : V(Word64Clz, Operator::kNoProperties, 1, 0, 1) \
136 : V(BitcastTaggedToWord, Operator::kNoProperties, 1, 0, 1) \
137 : V(BitcastWordToTaggedSigned, Operator::kNoProperties, 1, 0, 1) \
138 : V(TruncateFloat64ToWord32, Operator::kNoProperties, 1, 0, 1) \
139 : V(ChangeFloat32ToFloat64, Operator::kNoProperties, 1, 0, 1) \
140 : V(ChangeFloat64ToInt32, Operator::kNoProperties, 1, 0, 1) \
141 : V(ChangeFloat64ToUint32, Operator::kNoProperties, 1, 0, 1) \
142 : V(ChangeFloat64ToUint64, Operator::kNoProperties, 1, 0, 1) \
143 : V(TruncateFloat64ToUint32, Operator::kNoProperties, 1, 0, 1) \
144 : V(TruncateFloat32ToInt32, Operator::kNoProperties, 1, 0, 1) \
145 : V(TruncateFloat32ToUint32, Operator::kNoProperties, 1, 0, 1) \
146 : V(TryTruncateFloat32ToInt64, Operator::kNoProperties, 1, 0, 2) \
147 : V(TryTruncateFloat64ToInt64, Operator::kNoProperties, 1, 0, 2) \
148 : V(TryTruncateFloat32ToUint64, Operator::kNoProperties, 1, 0, 2) \
149 : V(TryTruncateFloat64ToUint64, Operator::kNoProperties, 1, 0, 2) \
150 : V(ChangeInt32ToFloat64, Operator::kNoProperties, 1, 0, 1) \
151 : V(Float64SilenceNaN, Operator::kNoProperties, 1, 0, 1) \
152 : V(RoundFloat64ToInt32, Operator::kNoProperties, 1, 0, 1) \
153 : V(RoundInt32ToFloat32, Operator::kNoProperties, 1, 0, 1) \
154 : V(RoundInt64ToFloat32, Operator::kNoProperties, 1, 0, 1) \
155 : V(RoundInt64ToFloat64, Operator::kNoProperties, 1, 0, 1) \
156 : V(RoundUint32ToFloat32, Operator::kNoProperties, 1, 0, 1) \
157 : V(RoundUint64ToFloat32, Operator::kNoProperties, 1, 0, 1) \
158 : V(RoundUint64ToFloat64, Operator::kNoProperties, 1, 0, 1) \
159 : V(ChangeInt32ToInt64, Operator::kNoProperties, 1, 0, 1) \
160 : V(ChangeUint32ToFloat64, Operator::kNoProperties, 1, 0, 1) \
161 : V(ChangeUint32ToUint64, Operator::kNoProperties, 1, 0, 1) \
162 : V(TruncateFloat64ToFloat32, Operator::kNoProperties, 1, 0, 1) \
163 : V(TruncateInt64ToInt32, Operator::kNoProperties, 1, 0, 1) \
164 : V(BitcastFloat32ToInt32, Operator::kNoProperties, 1, 0, 1) \
165 : V(BitcastFloat64ToInt64, Operator::kNoProperties, 1, 0, 1) \
166 : V(BitcastInt32ToFloat32, Operator::kNoProperties, 1, 0, 1) \
167 : V(BitcastInt64ToFloat64, Operator::kNoProperties, 1, 0, 1) \
168 : V(Float32Abs, Operator::kNoProperties, 1, 0, 1) \
169 : V(Float32Add, Operator::kCommutative, 2, 0, 1) \
170 : V(Float32Sub, Operator::kNoProperties, 2, 0, 1) \
171 : V(Float32Mul, Operator::kCommutative, 2, 0, 1) \
172 : V(Float32Div, Operator::kNoProperties, 2, 0, 1) \
173 : V(Float32Neg, Operator::kNoProperties, 1, 0, 1) \
174 : V(Float32Sqrt, Operator::kNoProperties, 1, 0, 1) \
175 : V(Float32Max, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
176 : V(Float32Min, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
177 : V(Float64Abs, Operator::kNoProperties, 1, 0, 1) \
178 : V(Float64Acos, Operator::kNoProperties, 1, 0, 1) \
179 : V(Float64Acosh, Operator::kNoProperties, 1, 0, 1) \
180 : V(Float64Asin, Operator::kNoProperties, 1, 0, 1) \
181 : V(Float64Asinh, Operator::kNoProperties, 1, 0, 1) \
182 : V(Float64Atan, Operator::kNoProperties, 1, 0, 1) \
183 : V(Float64Atan2, Operator::kNoProperties, 2, 0, 1) \
184 : V(Float64Atanh, Operator::kNoProperties, 1, 0, 1) \
185 : V(Float64Cbrt, Operator::kNoProperties, 1, 0, 1) \
186 : V(Float64Cos, Operator::kNoProperties, 1, 0, 1) \
187 : V(Float64Cosh, Operator::kNoProperties, 1, 0, 1) \
188 : V(Float64Exp, Operator::kNoProperties, 1, 0, 1) \
189 : V(Float64Expm1, Operator::kNoProperties, 1, 0, 1) \
190 : V(Float64Log, Operator::kNoProperties, 1, 0, 1) \
191 : V(Float64Log1p, Operator::kNoProperties, 1, 0, 1) \
192 : V(Float64Log2, Operator::kNoProperties, 1, 0, 1) \
193 : V(Float64Log10, Operator::kNoProperties, 1, 0, 1) \
194 : V(Float64Max, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
195 : V(Float64Min, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
196 : V(Float64Neg, Operator::kNoProperties, 1, 0, 1) \
197 : V(Float64Add, Operator::kCommutative, 2, 0, 1) \
198 : V(Float64Sub, Operator::kNoProperties, 2, 0, 1) \
199 : V(Float64Mul, Operator::kCommutative, 2, 0, 1) \
200 : V(Float64Div, Operator::kNoProperties, 2, 0, 1) \
201 : V(Float64Mod, Operator::kNoProperties, 2, 0, 1) \
202 : V(Float64Pow, Operator::kNoProperties, 2, 0, 1) \
203 : V(Float64Sin, Operator::kNoProperties, 1, 0, 1) \
204 : V(Float64Sinh, Operator::kNoProperties, 1, 0, 1) \
205 : V(Float64Sqrt, Operator::kNoProperties, 1, 0, 1) \
206 : V(Float64Tan, Operator::kNoProperties, 1, 0, 1) \
207 : V(Float64Tanh, Operator::kNoProperties, 1, 0, 1) \
208 : V(Float32Equal, Operator::kCommutative, 2, 0, 1) \
209 : V(Float32LessThan, Operator::kNoProperties, 2, 0, 1) \
210 : V(Float32LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \
211 : V(Float64Equal, Operator::kCommutative, 2, 0, 1) \
212 : V(Float64LessThan, Operator::kNoProperties, 2, 0, 1) \
213 : V(Float64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \
214 : V(Float64ExtractLowWord32, Operator::kNoProperties, 1, 0, 1) \
215 : V(Float64ExtractHighWord32, Operator::kNoProperties, 1, 0, 1) \
216 : V(Float64InsertLowWord32, Operator::kNoProperties, 2, 0, 1) \
217 : V(Float64InsertHighWord32, Operator::kNoProperties, 2, 0, 1) \
218 : V(LoadStackPointer, Operator::kNoProperties, 0, 0, 1) \
219 : V(LoadFramePointer, Operator::kNoProperties, 0, 0, 1) \
220 : V(LoadParentFramePointer, Operator::kNoProperties, 0, 0, 1) \
221 : V(Int32PairAdd, Operator::kNoProperties, 4, 0, 2) \
222 : V(Int32PairSub, Operator::kNoProperties, 4, 0, 2) \
223 : V(Int32PairMul, Operator::kNoProperties, 4, 0, 2) \
224 : V(Word32PairShl, Operator::kNoProperties, 3, 0, 2) \
225 : V(Word32PairShr, Operator::kNoProperties, 3, 0, 2) \
226 : V(Word32PairSar, Operator::kNoProperties, 3, 0, 2) \
227 : V(F32x4Splat, Operator::kNoProperties, 1, 0, 1) \
228 : V(F32x4SConvertI32x4, Operator::kNoProperties, 1, 0, 1) \
229 : V(F32x4UConvertI32x4, Operator::kNoProperties, 1, 0, 1) \
230 : V(F32x4Abs, Operator::kNoProperties, 1, 0, 1) \
231 : V(F32x4Neg, Operator::kNoProperties, 1, 0, 1) \
232 : V(F32x4RecipApprox, Operator::kNoProperties, 1, 0, 1) \
233 : V(F32x4RecipSqrtApprox, Operator::kNoProperties, 1, 0, 1) \
234 : V(F32x4Add, Operator::kCommutative, 2, 0, 1) \
235 : V(F32x4AddHoriz, Operator::kNoProperties, 2, 0, 1) \
236 : V(F32x4Sub, Operator::kNoProperties, 2, 0, 1) \
237 : V(F32x4Mul, Operator::kCommutative, 2, 0, 1) \
238 : V(F32x4Min, Operator::kCommutative, 2, 0, 1) \
239 : V(F32x4Max, Operator::kCommutative, 2, 0, 1) \
240 : V(F32x4Eq, Operator::kCommutative, 2, 0, 1) \
241 : V(F32x4Ne, Operator::kCommutative, 2, 0, 1) \
242 : V(F32x4Lt, Operator::kNoProperties, 2, 0, 1) \
243 : V(F32x4Le, Operator::kNoProperties, 2, 0, 1) \
244 : V(I32x4Splat, Operator::kNoProperties, 1, 0, 1) \
245 : V(I32x4SConvertF32x4, Operator::kNoProperties, 1, 0, 1) \
246 : V(I32x4SConvertI16x8Low, Operator::kNoProperties, 1, 0, 1) \
247 : V(I32x4SConvertI16x8High, Operator::kNoProperties, 1, 0, 1) \
248 : V(I32x4Neg, Operator::kNoProperties, 1, 0, 1) \
249 : V(I32x4Add, Operator::kCommutative, 2, 0, 1) \
250 : V(I32x4AddHoriz, Operator::kNoProperties, 2, 0, 1) \
251 : V(I32x4Sub, Operator::kNoProperties, 2, 0, 1) \
252 : V(I32x4Mul, Operator::kCommutative, 2, 0, 1) \
253 : V(I32x4MinS, Operator::kCommutative, 2, 0, 1) \
254 : V(I32x4MaxS, Operator::kCommutative, 2, 0, 1) \
255 : V(I32x4Eq, Operator::kCommutative, 2, 0, 1) \
256 : V(I32x4Ne, Operator::kCommutative, 2, 0, 1) \
257 : V(I32x4LtS, Operator::kNoProperties, 2, 0, 1) \
258 : V(I32x4LeS, Operator::kNoProperties, 2, 0, 1) \
259 : V(I32x4UConvertF32x4, Operator::kNoProperties, 1, 0, 1) \
260 : V(I32x4UConvertI16x8Low, Operator::kNoProperties, 1, 0, 1) \
261 : V(I32x4UConvertI16x8High, Operator::kNoProperties, 1, 0, 1) \
262 : V(I32x4MinU, Operator::kCommutative, 2, 0, 1) \
263 : V(I32x4MaxU, Operator::kCommutative, 2, 0, 1) \
264 : V(I32x4LtU, Operator::kNoProperties, 2, 0, 1) \
265 : V(I32x4LeU, Operator::kNoProperties, 2, 0, 1) \
266 : V(I16x8Splat, Operator::kNoProperties, 1, 0, 1) \
267 : V(I16x8SConvertI8x16Low, Operator::kNoProperties, 1, 0, 1) \
268 : V(I16x8SConvertI8x16High, Operator::kNoProperties, 1, 0, 1) \
269 : V(I16x8Neg, Operator::kNoProperties, 1, 0, 1) \
270 : V(I16x8SConvertI32x4, Operator::kNoProperties, 2, 0, 1) \
271 : V(I16x8Add, Operator::kCommutative, 2, 0, 1) \
272 : V(I16x8AddSaturateS, Operator::kCommutative, 2, 0, 1) \
273 : V(I16x8AddHoriz, Operator::kNoProperties, 2, 0, 1) \
274 : V(I16x8Sub, Operator::kNoProperties, 2, 0, 1) \
275 : V(I16x8SubSaturateS, Operator::kNoProperties, 2, 0, 1) \
276 : V(I16x8Mul, Operator::kCommutative, 2, 0, 1) \
277 : V(I16x8MinS, Operator::kCommutative, 2, 0, 1) \
278 : V(I16x8MaxS, Operator::kCommutative, 2, 0, 1) \
279 : V(I16x8Eq, Operator::kCommutative, 2, 0, 1) \
280 : V(I16x8Ne, Operator::kCommutative, 2, 0, 1) \
281 : V(I16x8LtS, Operator::kNoProperties, 2, 0, 1) \
282 : V(I16x8LeS, Operator::kNoProperties, 2, 0, 1) \
283 : V(I16x8UConvertI8x16Low, Operator::kNoProperties, 1, 0, 1) \
284 : V(I16x8UConvertI8x16High, Operator::kNoProperties, 1, 0, 1) \
285 : V(I16x8UConvertI32x4, Operator::kNoProperties, 2, 0, 1) \
286 : V(I16x8AddSaturateU, Operator::kCommutative, 2, 0, 1) \
287 : V(I16x8SubSaturateU, Operator::kNoProperties, 2, 0, 1) \
288 : V(I16x8MinU, Operator::kCommutative, 2, 0, 1) \
289 : V(I16x8MaxU, Operator::kCommutative, 2, 0, 1) \
290 : V(I16x8LtU, Operator::kNoProperties, 2, 0, 1) \
291 : V(I16x8LeU, Operator::kNoProperties, 2, 0, 1) \
292 : V(I8x16Splat, Operator::kNoProperties, 1, 0, 1) \
293 : V(I8x16Neg, Operator::kNoProperties, 1, 0, 1) \
294 : V(I8x16SConvertI16x8, Operator::kNoProperties, 2, 0, 1) \
295 : V(I8x16Add, Operator::kCommutative, 2, 0, 1) \
296 : V(I8x16AddSaturateS, Operator::kCommutative, 2, 0, 1) \
297 : V(I8x16Sub, Operator::kNoProperties, 2, 0, 1) \
298 : V(I8x16SubSaturateS, Operator::kNoProperties, 2, 0, 1) \
299 : V(I8x16Mul, Operator::kCommutative, 2, 0, 1) \
300 : V(I8x16MinS, Operator::kCommutative, 2, 0, 1) \
301 : V(I8x16MaxS, Operator::kCommutative, 2, 0, 1) \
302 : V(I8x16Eq, Operator::kCommutative, 2, 0, 1) \
303 : V(I8x16Ne, Operator::kCommutative, 2, 0, 1) \
304 : V(I8x16LtS, Operator::kNoProperties, 2, 0, 1) \
305 : V(I8x16LeS, Operator::kNoProperties, 2, 0, 1) \
306 : V(I8x16UConvertI16x8, Operator::kNoProperties, 2, 0, 1) \
307 : V(I8x16AddSaturateU, Operator::kCommutative, 2, 0, 1) \
308 : V(I8x16SubSaturateU, Operator::kNoProperties, 2, 0, 1) \
309 : V(I8x16MinU, Operator::kCommutative, 2, 0, 1) \
310 : V(I8x16MaxU, Operator::kCommutative, 2, 0, 1) \
311 : V(I8x16LtU, Operator::kNoProperties, 2, 0, 1) \
312 : V(I8x16LeU, Operator::kNoProperties, 2, 0, 1) \
313 : V(S128Load, Operator::kNoProperties, 2, 0, 1) \
314 : V(S128Store, Operator::kNoProperties, 3, 0, 1) \
315 : V(S128Zero, Operator::kNoProperties, 0, 0, 1) \
316 : V(S128And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
317 : V(S128Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
318 : V(S128Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
319 : V(S128Not, Operator::kNoProperties, 1, 0, 1) \
320 : V(S32x4ZipLeft, Operator::kNoProperties, 2, 0, 1) \
321 : V(S32x4ZipRight, Operator::kNoProperties, 2, 0, 1) \
322 : V(S32x4UnzipLeft, Operator::kNoProperties, 2, 0, 1) \
323 : V(S32x4UnzipRight, Operator::kNoProperties, 2, 0, 1) \
324 : V(S32x4TransposeLeft, Operator::kNoProperties, 2, 0, 1) \
325 : V(S32x4TransposeRight, Operator::kNoProperties, 2, 0, 1) \
326 : V(S32x4Select, Operator::kNoProperties, 3, 0, 1) \
327 : V(S16x8ZipLeft, Operator::kNoProperties, 2, 0, 1) \
328 : V(S16x8ZipRight, Operator::kNoProperties, 2, 0, 1) \
329 : V(S16x8UnzipLeft, Operator::kNoProperties, 2, 0, 1) \
330 : V(S16x8UnzipRight, Operator::kNoProperties, 2, 0, 1) \
331 : V(S16x8TransposeLeft, Operator::kNoProperties, 2, 0, 1) \
332 : V(S16x8TransposeRight, Operator::kNoProperties, 2, 0, 1) \
333 : V(S16x8Select, Operator::kNoProperties, 3, 0, 1) \
334 : V(S8x16ZipLeft, Operator::kNoProperties, 2, 0, 1) \
335 : V(S8x16ZipRight, Operator::kNoProperties, 2, 0, 1) \
336 : V(S8x16UnzipLeft, Operator::kNoProperties, 2, 0, 1) \
337 : V(S8x16UnzipRight, Operator::kNoProperties, 2, 0, 1) \
338 : V(S8x16TransposeLeft, Operator::kNoProperties, 2, 0, 1) \
339 : V(S8x16TransposeRight, Operator::kNoProperties, 2, 0, 1) \
340 : V(S8x16Select, Operator::kNoProperties, 3, 0, 1) \
341 : V(S32x2Reverse, Operator::kNoProperties, 1, 0, 1) \
342 : V(S16x4Reverse, Operator::kNoProperties, 1, 0, 1) \
343 : V(S16x2Reverse, Operator::kNoProperties, 1, 0, 1) \
344 : V(S8x8Reverse, Operator::kNoProperties, 1, 0, 1) \
345 : V(S8x4Reverse, Operator::kNoProperties, 1, 0, 1) \
346 : V(S8x2Reverse, Operator::kNoProperties, 1, 0, 1) \
347 : V(S1x4Zero, Operator::kNoProperties, 0, 0, 1) \
348 : V(S1x4And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
349 : V(S1x4Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
350 : V(S1x4Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
351 : V(S1x4Not, Operator::kNoProperties, 1, 0, 1) \
352 : V(S1x4AnyTrue, Operator::kNoProperties, 1, 0, 1) \
353 : V(S1x4AllTrue, Operator::kNoProperties, 1, 0, 1) \
354 : V(S1x8Zero, Operator::kNoProperties, 0, 0, 1) \
355 : V(S1x8And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
356 : V(S1x8Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
357 : V(S1x8Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
358 : V(S1x8Not, Operator::kNoProperties, 1, 0, 1) \
359 : V(S1x8AnyTrue, Operator::kNoProperties, 1, 0, 1) \
360 : V(S1x8AllTrue, Operator::kNoProperties, 1, 0, 1) \
361 : V(S1x16Zero, Operator::kNoProperties, 0, 0, 1) \
362 : V(S1x16And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
363 : V(S1x16Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
364 : V(S1x16Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
365 : V(S1x16Not, Operator::kNoProperties, 1, 0, 1) \
366 : V(S1x16AnyTrue, Operator::kNoProperties, 1, 0, 1) \
367 : V(S1x16AllTrue, Operator::kNoProperties, 1, 0, 1)
368 :
369 : #define PURE_OPTIONAL_OP_LIST(V) \
370 : V(Word32Ctz, Operator::kNoProperties, 1, 0, 1) \
371 : V(Word64Ctz, Operator::kNoProperties, 1, 0, 1) \
372 : V(Word32ReverseBits, Operator::kNoProperties, 1, 0, 1) \
373 : V(Word64ReverseBits, Operator::kNoProperties, 1, 0, 1) \
374 : V(Word32ReverseBytes, Operator::kNoProperties, 1, 0, 1) \
375 : V(Word64ReverseBytes, Operator::kNoProperties, 1, 0, 1) \
376 : V(Int32AbsWithOverflow, Operator::kNoProperties, 1, 0, 1) \
377 : V(Int64AbsWithOverflow, Operator::kNoProperties, 1, 0, 1) \
378 : V(Word32Popcnt, Operator::kNoProperties, 1, 0, 1) \
379 : V(Word64Popcnt, Operator::kNoProperties, 1, 0, 1) \
380 : V(Float32RoundDown, Operator::kNoProperties, 1, 0, 1) \
381 : V(Float64RoundDown, Operator::kNoProperties, 1, 0, 1) \
382 : V(Float32RoundUp, Operator::kNoProperties, 1, 0, 1) \
383 : V(Float64RoundUp, Operator::kNoProperties, 1, 0, 1) \
384 : V(Float32RoundTruncate, Operator::kNoProperties, 1, 0, 1) \
385 : V(Float64RoundTruncate, Operator::kNoProperties, 1, 0, 1) \
386 : V(Float64RoundTiesAway, Operator::kNoProperties, 1, 0, 1) \
387 : V(Float32RoundTiesEven, Operator::kNoProperties, 1, 0, 1) \
388 : V(Float64RoundTiesEven, Operator::kNoProperties, 1, 0, 1)
389 :
390 : #define OVERFLOW_OP_LIST(V) \
391 : V(Int32AddWithOverflow, Operator::kAssociative | Operator::kCommutative) \
392 : V(Int32SubWithOverflow, Operator::kNoProperties) \
393 : V(Int32MulWithOverflow, Operator::kAssociative | Operator::kCommutative) \
394 : V(Int64AddWithOverflow, Operator::kAssociative | Operator::kCommutative) \
395 : V(Int64SubWithOverflow, Operator::kNoProperties)
396 :
397 : #define MACHINE_TYPE_LIST(V) \
398 : V(Float32) \
399 : V(Float64) \
400 : V(Simd128) \
401 : V(Int8) \
402 : V(Uint8) \
403 : V(Int16) \
404 : V(Uint16) \
405 : V(Int32) \
406 : V(Uint32) \
407 : V(Int64) \
408 : V(Uint64) \
409 : V(Pointer) \
410 : V(TaggedSigned) \
411 : V(TaggedPointer) \
412 : V(AnyTagged)
413 :
414 : #define MACHINE_REPRESENTATION_LIST(V) \
415 : V(kFloat32) \
416 : V(kFloat64) \
417 : V(kSimd128) \
418 : V(kWord8) \
419 : V(kWord16) \
420 : V(kWord32) \
421 : V(kWord64) \
422 : V(kTaggedSigned) \
423 : V(kTaggedPointer) \
424 : V(kTagged)
425 :
426 : #define ATOMIC_TYPE_LIST(V) \
427 : V(Int8) \
428 : V(Uint8) \
429 : V(Int16) \
430 : V(Uint16) \
431 : V(Int32) \
432 : V(Uint32)
433 :
434 : #define ATOMIC_REPRESENTATION_LIST(V) \
435 : V(kWord8) \
436 : V(kWord16) \
437 : V(kWord32)
438 :
439 : #define SIMD_LANE_OP_LIST(V) \
440 : V(F32x4, 4) \
441 : V(I32x4, 4) \
442 : V(I16x8, 8) \
443 : V(I8x16, 16)
444 :
445 : #define SIMD_FORMAT_LIST(V) \
446 : V(32x4, 32) \
447 : V(16x8, 16) \
448 : V(8x16, 8)
449 :
450 : #define STACK_SLOT_CACHED_SIZES_LIST(V) V(4) V(8) V(16)
451 :
452 0 : struct StackSlotOperator : public Operator1<int> {
453 105076 : explicit StackSlotOperator(int size)
454 : : Operator1<int>(IrOpcode::kStackSlot,
455 : Operator::kNoDeopt | Operator::kNoThrow, "StackSlot", 0,
456 105076 : 0, 0, 1, 0, 0, size) {}
457 : };
458 :
459 385143 : struct MachineOperatorGlobalCache {
460 : #define PURE(Name, properties, value_input_count, control_input_count, \
461 : output_count) \
462 : struct Name##Operator final : public Operator { \
463 : Name##Operator() \
464 : : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \
465 : value_input_count, 0, control_input_count, output_count, 0, \
466 : 0) {} \
467 : }; \
468 : Name##Operator k##Name;
469 9593562 : PURE_OP_LIST(PURE)
470 665247 : PURE_OPTIONAL_OP_LIST(PURE)
471 : #undef PURE
472 :
473 : #define OVERFLOW_OP(Name, properties) \
474 : struct Name##Operator final : public Operator { \
475 : Name##Operator() \
476 : : Operator(IrOpcode::k##Name, \
477 : Operator::kEliminatable | Operator::kNoRead | properties, \
478 : #Name, 2, 0, 1, 2, 0, 0) {} \
479 : }; \
480 : Name##Operator k##Name;
481 175065 : OVERFLOW_OP_LIST(OVERFLOW_OP)
482 : #undef OVERFLOW_OP
483 :
484 : #define LOAD(Type) \
485 : struct Load##Type##Operator final : public Operator1<LoadRepresentation> { \
486 : Load##Type##Operator() \
487 : : Operator1<LoadRepresentation>( \
488 : IrOpcode::kLoad, \
489 : Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \
490 : "Load", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \
491 : }; \
492 : struct UnalignedLoad##Type##Operator final \
493 : : public Operator1<UnalignedLoadRepresentation> { \
494 : UnalignedLoad##Type##Operator() \
495 : : Operator1<UnalignedLoadRepresentation>( \
496 : IrOpcode::kUnalignedLoad, \
497 : Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \
498 : "UnalignedLoad", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \
499 : }; \
500 : struct CheckedLoad##Type##Operator final \
501 : : public Operator1<CheckedLoadRepresentation> { \
502 : CheckedLoad##Type##Operator() \
503 : : Operator1<CheckedLoadRepresentation>( \
504 : IrOpcode::kCheckedLoad, \
505 : Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \
506 : "CheckedLoad", 3, 1, 1, 1, 1, 0, MachineType::Type()) {} \
507 : }; \
508 : struct ProtectedLoad##Type##Operator final \
509 : : public Operator1<LoadRepresentation> { \
510 : ProtectedLoad##Type##Operator() \
511 : : Operator1<LoadRepresentation>( \
512 : IrOpcode::kProtectedLoad, \
513 : Operator::kNoDeopt | Operator::kNoThrow, "ProtectedLoad", 3, 1, \
514 : 1, 1, 1, 0, MachineType::Type()) {} \
515 : }; \
516 : Load##Type##Operator kLoad##Type; \
517 : UnalignedLoad##Type##Operator kUnalignedLoad##Type; \
518 : CheckedLoad##Type##Operator kCheckedLoad##Type; \
519 : ProtectedLoad##Type##Operator kProtectedLoad##Type;
520 4201560 : MACHINE_TYPE_LIST(LOAD)
521 : #undef LOAD
522 :
523 : #define STACKSLOT(Size) \
524 : struct StackSlotOfSize##Size##Operator final : public StackSlotOperator { \
525 : StackSlotOfSize##Size##Operator() : StackSlotOperator(Size) {} \
526 : }; \
527 : StackSlotOfSize##Size##Operator kStackSlotSize##Size;
528 35013 : STACK_SLOT_CACHED_SIZES_LIST(STACKSLOT)
529 : #undef STACKSLOT
530 :
531 : #define STORE(Type) \
532 : struct Store##Type##Operator : public Operator1<StoreRepresentation> { \
533 : explicit Store##Type##Operator(WriteBarrierKind write_barrier_kind) \
534 : : Operator1<StoreRepresentation>( \
535 : IrOpcode::kStore, \
536 : Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \
537 : "Store", 3, 1, 1, 0, 1, 0, \
538 : StoreRepresentation(MachineRepresentation::Type, \
539 : write_barrier_kind)) {} \
540 : }; \
541 : struct Store##Type##NoWriteBarrier##Operator final \
542 : : public Store##Type##Operator { \
543 : Store##Type##NoWriteBarrier##Operator() \
544 : : Store##Type##Operator(kNoWriteBarrier) {} \
545 : }; \
546 : struct Store##Type##MapWriteBarrier##Operator final \
547 : : public Store##Type##Operator { \
548 : Store##Type##MapWriteBarrier##Operator() \
549 : : Store##Type##Operator(kMapWriteBarrier) {} \
550 : }; \
551 : struct Store##Type##PointerWriteBarrier##Operator final \
552 : : public Store##Type##Operator { \
553 : Store##Type##PointerWriteBarrier##Operator() \
554 : : Store##Type##Operator(kPointerWriteBarrier) {} \
555 : }; \
556 : struct Store##Type##FullWriteBarrier##Operator final \
557 : : public Store##Type##Operator { \
558 : Store##Type##FullWriteBarrier##Operator() \
559 : : Store##Type##Operator(kFullWriteBarrier) {} \
560 : }; \
561 : struct UnalignedStore##Type##Operator final \
562 : : public Operator1<UnalignedStoreRepresentation> { \
563 : UnalignedStore##Type##Operator() \
564 : : Operator1<UnalignedStoreRepresentation>( \
565 : IrOpcode::kUnalignedStore, \
566 : Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \
567 : "UnalignedStore", 3, 1, 1, 0, 1, 0, \
568 : MachineRepresentation::Type) {} \
569 : }; \
570 : struct CheckedStore##Type##Operator final \
571 : : public Operator1<CheckedStoreRepresentation> { \
572 : CheckedStore##Type##Operator() \
573 : : Operator1<CheckedStoreRepresentation>( \
574 : IrOpcode::kCheckedStore, \
575 : Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \
576 : "CheckedStore", 4, 1, 1, 0, 1, 0, MachineRepresentation::Type) { \
577 : } \
578 : }; \
579 : struct ProtectedStore##Type##Operator \
580 : : public Operator1<StoreRepresentation> { \
581 : explicit ProtectedStore##Type##Operator() \
582 : : Operator1<StoreRepresentation>( \
583 : IrOpcode::kProtectedStore, \
584 : Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \
585 : "Store", 4, 1, 1, 0, 1, 0, \
586 : StoreRepresentation(MachineRepresentation::Type, \
587 : kNoWriteBarrier)) {} \
588 : }; \
589 : Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \
590 : Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier; \
591 : Store##Type##PointerWriteBarrier##Operator \
592 : kStore##Type##PointerWriteBarrier; \
593 : Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier; \
594 : UnalignedStore##Type##Operator kUnalignedStore##Type; \
595 : CheckedStore##Type##Operator kCheckedStore##Type; \
596 : ProtectedStore##Type##Operator kProtectedStore##Type;
597 5251950 : MACHINE_REPRESENTATION_LIST(STORE)
598 : #undef STORE
599 :
600 : #define ATOMIC_LOAD(Type) \
601 : struct AtomicLoad##Type##Operator final \
602 : : public Operator1<LoadRepresentation> { \
603 : AtomicLoad##Type##Operator() \
604 : : Operator1<LoadRepresentation>( \
605 : IrOpcode::kAtomicLoad, \
606 : Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \
607 : "AtomicLoad", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \
608 : }; \
609 : AtomicLoad##Type##Operator kAtomicLoad##Type;
610 420156 : ATOMIC_TYPE_LIST(ATOMIC_LOAD)
611 : #undef ATOMIC_LOAD
612 :
613 : #define ATOMIC_STORE(Type) \
614 : struct AtomicStore##Type##Operator \
615 : : public Operator1<MachineRepresentation> { \
616 : AtomicStore##Type##Operator() \
617 : : Operator1<MachineRepresentation>( \
618 : IrOpcode::kAtomicStore, \
619 : Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \
620 : "AtomicStore", 3, 1, 1, 0, 1, 0, MachineRepresentation::Type) {} \
621 : }; \
622 : AtomicStore##Type##Operator kAtomicStore##Type;
623 210078 : ATOMIC_REPRESENTATION_LIST(ATOMIC_STORE)
624 : #undef STORE
625 :
626 : #define ATOMIC_OP(op, type) \
627 : struct op##type##Operator : public Operator1<MachineType> { \
628 : op##type##Operator() \
629 : : Operator1<MachineType>(IrOpcode::k##op, \
630 : Operator::kNoDeopt | Operator::kNoThrow, #op, \
631 : 3, 1, 1, 1, 1, 0, MachineType::type()) {} \
632 : }; \
633 : op##type##Operator k##op##type;
634 : #define ATOMIC_OP_LIST(type) \
635 : ATOMIC_OP(AtomicExchange, type) \
636 : ATOMIC_OP(AtomicAdd, type) \
637 : ATOMIC_OP(AtomicSub, type) \
638 : ATOMIC_OP(AtomicAnd, type) \
639 : ATOMIC_OP(AtomicOr, type) \
640 : ATOMIC_OP(AtomicXor, type)
641 2520936 : ATOMIC_TYPE_LIST(ATOMIC_OP_LIST)
642 : #undef ATOMIC_OP_LIST
643 : #undef ATOMIC_OP
644 :
645 : #define ATOMIC_COMPARE_EXCHANGE(Type) \
646 : struct AtomicCompareExchange##Type##Operator \
647 : : public Operator1<MachineType> { \
648 : AtomicCompareExchange##Type##Operator() \
649 : : Operator1<MachineType>(IrOpcode::kAtomicCompareExchange, \
650 : Operator::kNoDeopt | Operator::kNoThrow, \
651 : "AtomicCompareExchange", 4, 1, 1, 1, 1, 0, \
652 : MachineType::Type()) {} \
653 : }; \
654 : AtomicCompareExchange##Type##Operator kAtomicCompareExchange##Type;
655 420156 : ATOMIC_TYPE_LIST(ATOMIC_COMPARE_EXCHANGE)
656 : #undef ATOMIC_COMPARE_EXCHANGE
657 :
658 : // The {BitcastWordToTagged} operator must not be marked as pure (especially
659 : // not idempotent), because otherwise the splitting logic in the Scheduler
660 : // might decide to split these operators, thus potentially creating live
661 : // ranges of allocation top across calls or other things that might allocate.
662 : // See https://bugs.chromium.org/p/v8/issues/detail?id=6059 for more details.
663 0 : struct BitcastWordToTaggedOperator : public Operator {
664 35013 : BitcastWordToTaggedOperator()
665 : : Operator(IrOpcode::kBitcastWordToTagged,
666 : Operator::kEliminatable | Operator::kNoWrite,
667 35013 : "BitcastWordToTagged", 1, 0, 0, 1, 0, 0) {}
668 : };
669 : BitcastWordToTaggedOperator kBitcastWordToTagged;
670 :
671 0 : struct DebugBreakOperator : public Operator {
672 35013 : DebugBreakOperator()
673 : : Operator(IrOpcode::kDebugBreak, Operator::kNoThrow, "DebugBreak", 0,
674 35013 : 0, 0, 0, 0, 0) {}
675 : };
676 : DebugBreakOperator kDebugBreak;
677 :
678 0 : struct UnsafePointerAddOperator final : public Operator {
679 35013 : UnsafePointerAddOperator()
680 : : Operator(IrOpcode::kUnsafePointerAdd, Operator::kKontrol,
681 35013 : "UnsafePointerAdd", 2, 1, 1, 1, 1, 0) {}
682 : };
683 : UnsafePointerAddOperator kUnsafePointerAdd;
684 : };
685 :
686 0 : struct CommentOperator : public Operator1<const char*> {
687 0 : explicit CommentOperator(const char* msg)
688 : : Operator1<const char*>(IrOpcode::kComment, Operator::kNoThrow,
689 0 : "Comment", 0, 0, 0, 0, 0, 0, msg) {}
690 : };
691 :
692 : static base::LazyInstance<MachineOperatorGlobalCache>::type kCache =
693 : LAZY_INSTANCE_INITIALIZER;
694 :
695 999375 : MachineOperatorBuilder::MachineOperatorBuilder(
696 : Zone* zone, MachineRepresentation word, Flags flags,
697 : AlignmentRequirements alignmentRequirements)
698 : : zone_(zone),
699 : cache_(kCache.Get()),
700 : word_(word),
701 : flags_(flags),
702 1998750 : alignment_requirements_(alignmentRequirements) {
703 : DCHECK(word == MachineRepresentation::kWord32 ||
704 : word == MachineRepresentation::kWord64);
705 999375 : }
706 :
707 2 : const Operator* MachineOperatorBuilder::UnalignedLoad(
708 : UnalignedLoadRepresentation rep) {
709 : #define LOAD(Type) \
710 : if (rep == MachineType::Type()) { \
711 : return &cache_.kUnalignedLoad##Type; \
712 : }
713 18 : MACHINE_TYPE_LIST(LOAD)
714 : #undef LOAD
715 0 : UNREACHABLE();
716 : return nullptr;
717 : }
718 :
719 2 : const Operator* MachineOperatorBuilder::UnalignedStore(
720 : UnalignedStoreRepresentation rep) {
721 2 : switch (rep) {
722 : #define STORE(kRep) \
723 : case MachineRepresentation::kRep: \
724 : return &cache_.kUnalignedStore##kRep;
725 0 : MACHINE_REPRESENTATION_LIST(STORE)
726 : #undef STORE
727 : case MachineRepresentation::kBit:
728 : case MachineRepresentation::kSimd1x4:
729 : case MachineRepresentation::kSimd1x8:
730 : case MachineRepresentation::kSimd1x16:
731 : case MachineRepresentation::kNone:
732 : break;
733 : }
734 0 : UNREACHABLE();
735 : return nullptr;
736 : }
737 :
738 : #define PURE(Name, properties, value_input_count, control_input_count, \
739 : output_count) \
740 : const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; }
741 10955517 : PURE_OP_LIST(PURE)
742 : #undef PURE
743 :
744 : #define PURE(Name, properties, value_input_count, control_input_count, \
745 : output_count) \
746 : const OptionalOperator MachineOperatorBuilder::Name() { \
747 : return OptionalOperator(flags_ & k##Name, &cache_.k##Name); \
748 : }
749 147456 : PURE_OPTIONAL_OP_LIST(PURE)
750 : #undef PURE
751 :
752 : #define OVERFLOW_OP(Name, properties) \
753 : const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; }
754 231464 : OVERFLOW_OP_LIST(OVERFLOW_OP)
755 : #undef OVERFLOW_OP
756 :
757 4139293 : const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) {
758 : #define LOAD(Type) \
759 : if (rep == MachineType::Type()) { \
760 : return &cache_.kLoad##Type; \
761 : }
762 49314204 : MACHINE_TYPE_LIST(LOAD)
763 : #undef LOAD
764 0 : UNREACHABLE();
765 : return nullptr;
766 : }
767 :
768 1470 : const Operator* MachineOperatorBuilder::ProtectedLoad(LoadRepresentation rep) {
769 : #define LOAD(Type) \
770 : if (rep == MachineType::Type()) { \
771 : return &cache_.kProtectedLoad##Type; \
772 : }
773 7479 : MACHINE_TYPE_LIST(LOAD)
774 : #undef LOAD
775 0 : UNREACHABLE();
776 : return nullptr;
777 : }
778 :
779 1420 : const Operator* MachineOperatorBuilder::StackSlot(int size) {
780 : DCHECK_LE(0, size);
781 : #define CASE_CACHED_SIZE(Size) \
782 : case Size: \
783 : return &cache_.kStackSlotSize##Size;
784 1420 : switch (size) {
785 1074 : STACK_SLOT_CACHED_SIZES_LIST(CASE_CACHED_SIZE);
786 : default:
787 74 : return new (zone_) StackSlotOperator(size);
788 : }
789 : #undef CASE_CACHED_SIZE
790 : }
791 :
792 160 : const Operator* MachineOperatorBuilder::StackSlot(MachineRepresentation rep) {
793 160 : return StackSlot(1 << ElementSizeLog2Of(rep));
794 : }
795 :
796 2336494 : const Operator* MachineOperatorBuilder::Store(StoreRepresentation store_rep) {
797 2336494 : switch (store_rep.representation()) {
798 : #define STORE(kRep) \
799 : case MachineRepresentation::kRep: \
800 : switch (store_rep.write_barrier_kind()) { \
801 : case kNoWriteBarrier: \
802 : return &cache_.k##Store##kRep##NoWriteBarrier; \
803 : case kMapWriteBarrier: \
804 : return &cache_.k##Store##kRep##MapWriteBarrier; \
805 : case kPointerWriteBarrier: \
806 : return &cache_.k##Store##kRep##PointerWriteBarrier; \
807 : case kFullWriteBarrier: \
808 : return &cache_.k##Store##kRep##FullWriteBarrier; \
809 : } \
810 : break;
811 7899 : MACHINE_REPRESENTATION_LIST(STORE)
812 : #undef STORE
813 : case MachineRepresentation::kBit:
814 : case MachineRepresentation::kSimd1x4:
815 : case MachineRepresentation::kSimd1x8:
816 : case MachineRepresentation::kSimd1x16:
817 : case MachineRepresentation::kNone:
818 : break;
819 : }
820 2 : UNREACHABLE();
821 : return nullptr;
822 : }
823 :
824 180 : const Operator* MachineOperatorBuilder::ProtectedStore(
825 : MachineRepresentation rep) {
826 180 : switch (rep) {
827 : #define STORE(kRep) \
828 : case MachineRepresentation::kRep: \
829 : return &cache_.kProtectedStore##kRep; \
830 : break;
831 23 : MACHINE_REPRESENTATION_LIST(STORE)
832 : #undef STORE
833 : case MachineRepresentation::kBit:
834 : case MachineRepresentation::kSimd1x4:
835 : case MachineRepresentation::kSimd1x8:
836 : case MachineRepresentation::kSimd1x16:
837 : case MachineRepresentation::kNone:
838 : break;
839 : }
840 0 : UNREACHABLE();
841 : return nullptr;
842 : }
843 :
844 3673 : const Operator* MachineOperatorBuilder::UnsafePointerAdd() {
845 3673 : return &cache_.kUnsafePointerAdd;
846 : }
847 :
848 239284 : const Operator* MachineOperatorBuilder::BitcastWordToTagged() {
849 239284 : return &cache_.kBitcastWordToTagged;
850 : }
851 :
852 9087 : const Operator* MachineOperatorBuilder::DebugBreak() {
853 9087 : return &cache_.kDebugBreak;
854 : }
855 :
856 0 : const Operator* MachineOperatorBuilder::Comment(const char* msg) {
857 0 : return new (zone_) CommentOperator(msg);
858 : }
859 :
860 74352 : const Operator* MachineOperatorBuilder::CheckedLoad(
861 : CheckedLoadRepresentation rep) {
862 : #define LOAD(Type) \
863 : if (rep == MachineType::Type()) { \
864 : return &cache_.kCheckedLoad##Type; \
865 : }
866 501276 : MACHINE_TYPE_LIST(LOAD)
867 : #undef LOAD
868 0 : UNREACHABLE();
869 : return nullptr;
870 : }
871 :
872 :
873 53187 : const Operator* MachineOperatorBuilder::CheckedStore(
874 : CheckedStoreRepresentation rep) {
875 53187 : switch (rep) {
876 : #define STORE(kRep) \
877 : case MachineRepresentation::kRep: \
878 : return &cache_.kCheckedStore##kRep;
879 5484 : MACHINE_REPRESENTATION_LIST(STORE)
880 : #undef STORE
881 : case MachineRepresentation::kBit:
882 : case MachineRepresentation::kSimd1x4:
883 : case MachineRepresentation::kSimd1x8:
884 : case MachineRepresentation::kSimd1x16:
885 : case MachineRepresentation::kNone:
886 : break;
887 : }
888 0 : UNREACHABLE();
889 : return nullptr;
890 : }
891 :
892 258 : const Operator* MachineOperatorBuilder::AtomicLoad(LoadRepresentation rep) {
893 : #define LOAD(Type) \
894 : if (rep == MachineType::Type()) { \
895 : return &cache_.kAtomicLoad##Type; \
896 : }
897 903 : ATOMIC_TYPE_LIST(LOAD)
898 : #undef LOAD
899 0 : UNREACHABLE();
900 : return nullptr;
901 : }
902 :
903 129 : const Operator* MachineOperatorBuilder::AtomicStore(MachineRepresentation rep) {
904 : #define STORE(kRep) \
905 : if (rep == MachineRepresentation::kRep) { \
906 : return &cache_.kAtomicStore##kRep; \
907 : }
908 129 : ATOMIC_REPRESENTATION_LIST(STORE)
909 : #undef STORE
910 0 : UNREACHABLE();
911 : return nullptr;
912 : }
913 :
914 258 : const Operator* MachineOperatorBuilder::AtomicExchange(MachineType rep) {
915 : #define EXCHANGE(kRep) \
916 : if (rep == MachineType::kRep()) { \
917 : return &cache_.kAtomicExchange##kRep; \
918 : }
919 903 : ATOMIC_TYPE_LIST(EXCHANGE)
920 : #undef EXCHANGE
921 0 : UNREACHABLE();
922 : return nullptr;
923 : }
924 :
925 258 : const Operator* MachineOperatorBuilder::AtomicCompareExchange(MachineType rep) {
926 : #define COMPARE_EXCHANGE(kRep) \
927 : if (rep == MachineType::kRep()) { \
928 : return &cache_.kAtomicCompareExchange##kRep; \
929 : }
930 903 : ATOMIC_TYPE_LIST(COMPARE_EXCHANGE)
931 : #undef COMPARE_EXCHANGE
932 0 : UNREACHABLE();
933 : return nullptr;
934 : }
935 :
936 258 : const Operator* MachineOperatorBuilder::AtomicAdd(MachineType rep) {
937 : #define ADD(kRep) \
938 : if (rep == MachineType::kRep()) { \
939 : return &cache_.kAtomicAdd##kRep; \
940 : }
941 903 : ATOMIC_TYPE_LIST(ADD)
942 : #undef ADD
943 0 : UNREACHABLE();
944 : return nullptr;
945 : }
946 :
947 258 : const Operator* MachineOperatorBuilder::AtomicSub(MachineType rep) {
948 : #define SUB(kRep) \
949 : if (rep == MachineType::kRep()) { \
950 : return &cache_.kAtomicSub##kRep; \
951 : }
952 903 : ATOMIC_TYPE_LIST(SUB)
953 : #undef SUB
954 0 : UNREACHABLE();
955 : return nullptr;
956 : }
957 :
958 258 : const Operator* MachineOperatorBuilder::AtomicAnd(MachineType rep) {
959 : #define AND(kRep) \
960 : if (rep == MachineType::kRep()) { \
961 : return &cache_.kAtomicAnd##kRep; \
962 : }
963 903 : ATOMIC_TYPE_LIST(AND)
964 : #undef AND
965 0 : UNREACHABLE();
966 : return nullptr;
967 : }
968 :
969 258 : const Operator* MachineOperatorBuilder::AtomicOr(MachineType rep) {
970 : #define OR(kRep) \
971 : if (rep == MachineType::kRep()) { \
972 : return &cache_.kAtomicOr##kRep; \
973 : }
974 903 : ATOMIC_TYPE_LIST(OR)
975 : #undef OR
976 0 : UNREACHABLE();
977 : return nullptr;
978 : }
979 :
980 258 : const Operator* MachineOperatorBuilder::AtomicXor(MachineType rep) {
981 : #define XOR(kRep) \
982 : if (rep == MachineType::kRep()) { \
983 : return &cache_.kAtomicXor##kRep; \
984 : }
985 903 : ATOMIC_TYPE_LIST(XOR)
986 : #undef XOR
987 0 : UNREACHABLE();
988 : return nullptr;
989 : }
990 :
991 : #define SIMD_LANE_OPS(Type, lane_count) \
992 : const Operator* MachineOperatorBuilder::Type##ExtractLane( \
993 : int32_t lane_index) { \
994 : DCHECK(0 <= lane_index && lane_index < lane_count); \
995 : return new (zone_) \
996 : Operator1<int32_t>(IrOpcode::k##Type##ExtractLane, Operator::kPure, \
997 : "Extract lane", 1, 0, 0, 1, 0, 0, lane_index); \
998 : } \
999 : const Operator* MachineOperatorBuilder::Type##ReplaceLane( \
1000 : int32_t lane_index) { \
1001 : DCHECK(0 <= lane_index && lane_index < lane_count); \
1002 : return new (zone_) \
1003 : Operator1<int32_t>(IrOpcode::k##Type##ReplaceLane, Operator::kPure, \
1004 : "Replace lane", 2, 0, 0, 1, 0, 0, lane_index); \
1005 : }
1006 10780 : SIMD_LANE_OP_LIST(SIMD_LANE_OPS)
1007 : #undef SIMD_LANE_OPS
1008 :
1009 : #define SIMD_SHIFT_OPS(format, bits) \
1010 : const Operator* MachineOperatorBuilder::I##format##Shl(int32_t shift) { \
1011 : DCHECK(0 <= shift && shift < bits); \
1012 : return new (zone_) \
1013 : Operator1<int32_t>(IrOpcode::kI##format##Shl, Operator::kPure, \
1014 : "Shift left", 1, 0, 0, 1, 0, 0, shift); \
1015 : } \
1016 : const Operator* MachineOperatorBuilder::I##format##ShrS(int32_t shift) { \
1017 : DCHECK(0 < shift && shift <= bits); \
1018 : return new (zone_) \
1019 : Operator1<int32_t>(IrOpcode::kI##format##ShrS, Operator::kPure, \
1020 : "Arithmetic shift right", 1, 0, 0, 1, 0, 0, shift); \
1021 : } \
1022 : const Operator* MachineOperatorBuilder::I##format##ShrU(int32_t shift) { \
1023 : DCHECK(0 <= shift && shift < bits); \
1024 : return new (zone_) \
1025 : Operator1<int32_t>(IrOpcode::kI##format##ShrU, Operator::kPure, \
1026 : "Shift right", 1, 0, 0, 1, 0, 0, shift); \
1027 : }
1028 84 : SIMD_FORMAT_LIST(SIMD_SHIFT_OPS)
1029 : #undef SIMD_SHIFT_OPS
1030 :
1031 0 : const Operator* MachineOperatorBuilder::S8x16Concat(int32_t bytes) {
1032 : DCHECK(0 <= bytes && bytes < kSimd128Size);
1033 : return new (zone_) Operator1<int32_t>(IrOpcode::kS8x16Concat, Operator::kPure,
1034 0 : "Concat", 2, 0, 0, 1, 0, 0, bytes);
1035 : }
1036 :
1037 : } // namespace compiler
1038 : } // namespace internal
1039 : } // namespace v8
|