V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
machine-operator.cc
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 bool operator==(StoreRepresentation lhs, StoreRepresentation rhs) {
16  return lhs.representation() == rhs.representation() &&
17  lhs.write_barrier_kind() == rhs.write_barrier_kind();
18 }
19 
20 
21 bool operator!=(StoreRepresentation lhs, StoreRepresentation rhs) {
22  return !(lhs == rhs);
23 }
24 
25 
26 size_t hash_value(StoreRepresentation rep) {
27  return base::hash_combine(rep.representation(), rep.write_barrier_kind());
28 }
29 
30 
31 std::ostream& operator<<(std::ostream& os, StoreRepresentation rep) {
32  return os << "(" << rep.representation() << " : " << rep.write_barrier_kind()
33  << ")";
34 }
35 
36 
37 LoadRepresentation LoadRepresentationOf(Operator const* op) {
38  DCHECK(IrOpcode::kLoad == op->opcode() ||
39  IrOpcode::kProtectedLoad == op->opcode() ||
40  IrOpcode::kWord32AtomicLoad == op->opcode() ||
41  IrOpcode::kWord64AtomicLoad == op->opcode() ||
42  IrOpcode::kWord32AtomicPairLoad == op->opcode() ||
43  IrOpcode::kPoisonedLoad == op->opcode() ||
44  IrOpcode::kUnalignedLoad == op->opcode());
45  return OpParameter<LoadRepresentation>(op);
46 }
47 
48 
49 StoreRepresentation const& StoreRepresentationOf(Operator const* op) {
50  DCHECK(IrOpcode::kStore == op->opcode() ||
51  IrOpcode::kProtectedStore == op->opcode());
52  return OpParameter<StoreRepresentation>(op);
53 }
54 
55 UnalignedStoreRepresentation const& UnalignedStoreRepresentationOf(
56  Operator const* op) {
57  DCHECK_EQ(IrOpcode::kUnalignedStore, op->opcode());
58  return OpParameter<UnalignedStoreRepresentation>(op);
59 }
60 
61 bool operator==(StackSlotRepresentation lhs, StackSlotRepresentation rhs) {
62  return lhs.size() == rhs.size() && lhs.alignment() == rhs.alignment();
63 }
64 
65 bool operator!=(StackSlotRepresentation lhs, StackSlotRepresentation rhs) {
66  return !(lhs == rhs);
67 }
68 
69 size_t hash_value(StackSlotRepresentation rep) {
70  return base::hash_combine(rep.size(), rep.alignment());
71 }
72 
73 std::ostream& operator<<(std::ostream& os, StackSlotRepresentation rep) {
74  return os << "(" << rep.size() << " : " << rep.alignment() << ")";
75 }
76 
77 StackSlotRepresentation const& StackSlotRepresentationOf(Operator const* op) {
78  DCHECK_EQ(IrOpcode::kStackSlot, op->opcode());
79  return OpParameter<StackSlotRepresentation>(op);
80 }
81 
82 MachineRepresentation AtomicStoreRepresentationOf(Operator const* op) {
83  DCHECK(IrOpcode::kWord32AtomicStore == op->opcode() ||
84  IrOpcode::kWord64AtomicStore == op->opcode());
85  return OpParameter<MachineRepresentation>(op);
86 }
87 
88 MachineType AtomicOpType(Operator const* op) {
89  return OpParameter<MachineType>(op);
90 }
91 
92 #define PURE_BINARY_OP_LIST_32(V) \
93  V(Word32And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
94  V(Word32Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
95  V(Word32Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
96  V(Word32Shl, Operator::kNoProperties, 2, 0, 1) \
97  V(Word32Shr, Operator::kNoProperties, 2, 0, 1) \
98  V(Word32Sar, Operator::kNoProperties, 2, 0, 1) \
99  V(Word32Ror, Operator::kNoProperties, 2, 0, 1) \
100  V(Word32Equal, Operator::kCommutative, 2, 0, 1) \
101  V(Int32Add, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
102  V(Int32Sub, Operator::kNoProperties, 2, 0, 1) \
103  V(Int32Mul, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
104  V(Int32MulHigh, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
105  V(Int32Div, Operator::kNoProperties, 2, 1, 1) \
106  V(Int32Mod, Operator::kNoProperties, 2, 1, 1) \
107  V(Int32LessThan, Operator::kNoProperties, 2, 0, 1) \
108  V(Int32LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \
109  V(Uint32Div, Operator::kNoProperties, 2, 1, 1) \
110  V(Uint32LessThan, Operator::kNoProperties, 2, 0, 1) \
111  V(Uint32LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \
112  V(Uint32Mod, Operator::kNoProperties, 2, 1, 1) \
113  V(Uint32MulHigh, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)
114 
115 #define PURE_BINARY_OP_LIST_64(V) \
116  V(Word64And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
117  V(Word64Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
118  V(Word64Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
119  V(Word64Shl, Operator::kNoProperties, 2, 0, 1) \
120  V(Word64Shr, Operator::kNoProperties, 2, 0, 1) \
121  V(Word64Sar, Operator::kNoProperties, 2, 0, 1) \
122  V(Word64Ror, Operator::kNoProperties, 2, 0, 1) \
123  V(Word64Equal, Operator::kCommutative, 2, 0, 1) \
124  V(Int64Add, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
125  V(Int64Sub, Operator::kNoProperties, 2, 0, 1) \
126  V(Int64Mul, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
127  V(Int64Div, Operator::kNoProperties, 2, 1, 1) \
128  V(Int64Mod, Operator::kNoProperties, 2, 1, 1) \
129  V(Int64LessThan, Operator::kNoProperties, 2, 0, 1) \
130  V(Int64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \
131  V(Uint64Div, Operator::kNoProperties, 2, 1, 1) \
132  V(Uint64Mod, Operator::kNoProperties, 2, 1, 1) \
133  V(Uint64LessThan, Operator::kNoProperties, 2, 0, 1) \
134  V(Uint64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)
135 
136 #define MACHINE_PURE_OP_LIST(V) \
137  PURE_BINARY_OP_LIST_32(V) \
138  PURE_BINARY_OP_LIST_64(V) \
139  V(Word32Clz, Operator::kNoProperties, 1, 0, 1) \
140  V(Word64Clz, Operator::kNoProperties, 1, 0, 1) \
141  V(Word32ReverseBytes, Operator::kNoProperties, 1, 0, 1) \
142  V(Word64ReverseBytes, Operator::kNoProperties, 1, 0, 1) \
143  V(BitcastWordToTaggedSigned, Operator::kNoProperties, 1, 0, 1) \
144  V(TruncateFloat64ToWord32, Operator::kNoProperties, 1, 0, 1) \
145  V(ChangeFloat32ToFloat64, Operator::kNoProperties, 1, 0, 1) \
146  V(ChangeFloat64ToInt32, Operator::kNoProperties, 1, 0, 1) \
147  V(ChangeFloat64ToInt64, Operator::kNoProperties, 1, 0, 1) \
148  V(ChangeFloat64ToUint32, Operator::kNoProperties, 1, 0, 1) \
149  V(ChangeFloat64ToUint64, Operator::kNoProperties, 1, 0, 1) \
150  V(TruncateFloat64ToInt64, Operator::kNoProperties, 1, 0, 1) \
151  V(TruncateFloat64ToUint32, Operator::kNoProperties, 1, 0, 1) \
152  V(TruncateFloat32ToInt32, Operator::kNoProperties, 1, 0, 1) \
153  V(TruncateFloat32ToUint32, Operator::kNoProperties, 1, 0, 1) \
154  V(TryTruncateFloat32ToInt64, Operator::kNoProperties, 1, 0, 2) \
155  V(TryTruncateFloat64ToInt64, Operator::kNoProperties, 1, 0, 2) \
156  V(TryTruncateFloat32ToUint64, Operator::kNoProperties, 1, 0, 2) \
157  V(TryTruncateFloat64ToUint64, Operator::kNoProperties, 1, 0, 2) \
158  V(ChangeInt32ToFloat64, Operator::kNoProperties, 1, 0, 1) \
159  V(ChangeInt64ToFloat64, Operator::kNoProperties, 1, 0, 1) \
160  V(Float64SilenceNaN, Operator::kNoProperties, 1, 0, 1) \
161  V(RoundFloat64ToInt32, Operator::kNoProperties, 1, 0, 1) \
162  V(RoundInt32ToFloat32, Operator::kNoProperties, 1, 0, 1) \
163  V(RoundInt64ToFloat32, Operator::kNoProperties, 1, 0, 1) \
164  V(RoundInt64ToFloat64, Operator::kNoProperties, 1, 0, 1) \
165  V(RoundUint32ToFloat32, Operator::kNoProperties, 1, 0, 1) \
166  V(RoundUint64ToFloat32, Operator::kNoProperties, 1, 0, 1) \
167  V(RoundUint64ToFloat64, Operator::kNoProperties, 1, 0, 1) \
168  V(ChangeInt32ToInt64, Operator::kNoProperties, 1, 0, 1) \
169  V(ChangeUint32ToFloat64, Operator::kNoProperties, 1, 0, 1) \
170  V(ChangeUint32ToUint64, Operator::kNoProperties, 1, 0, 1) \
171  V(TruncateFloat64ToFloat32, Operator::kNoProperties, 1, 0, 1) \
172  V(TruncateInt64ToInt32, Operator::kNoProperties, 1, 0, 1) \
173  V(BitcastFloat32ToInt32, Operator::kNoProperties, 1, 0, 1) \
174  V(BitcastFloat64ToInt64, Operator::kNoProperties, 1, 0, 1) \
175  V(BitcastInt32ToFloat32, Operator::kNoProperties, 1, 0, 1) \
176  V(BitcastInt64ToFloat64, Operator::kNoProperties, 1, 0, 1) \
177  V(SignExtendWord8ToInt32, Operator::kNoProperties, 1, 0, 1) \
178  V(SignExtendWord16ToInt32, Operator::kNoProperties, 1, 0, 1) \
179  V(SignExtendWord8ToInt64, Operator::kNoProperties, 1, 0, 1) \
180  V(SignExtendWord16ToInt64, Operator::kNoProperties, 1, 0, 1) \
181  V(SignExtendWord32ToInt64, Operator::kNoProperties, 1, 0, 1) \
182  V(Float32Abs, Operator::kNoProperties, 1, 0, 1) \
183  V(Float32Add, Operator::kCommutative, 2, 0, 1) \
184  V(Float32Sub, Operator::kNoProperties, 2, 0, 1) \
185  V(Float32Mul, Operator::kCommutative, 2, 0, 1) \
186  V(Float32Div, Operator::kNoProperties, 2, 0, 1) \
187  V(Float32Neg, Operator::kNoProperties, 1, 0, 1) \
188  V(Float32Sqrt, Operator::kNoProperties, 1, 0, 1) \
189  V(Float32Max, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
190  V(Float32Min, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
191  V(Float64Abs, Operator::kNoProperties, 1, 0, 1) \
192  V(Float64Acos, Operator::kNoProperties, 1, 0, 1) \
193  V(Float64Acosh, Operator::kNoProperties, 1, 0, 1) \
194  V(Float64Asin, Operator::kNoProperties, 1, 0, 1) \
195  V(Float64Asinh, Operator::kNoProperties, 1, 0, 1) \
196  V(Float64Atan, Operator::kNoProperties, 1, 0, 1) \
197  V(Float64Atan2, Operator::kNoProperties, 2, 0, 1) \
198  V(Float64Atanh, Operator::kNoProperties, 1, 0, 1) \
199  V(Float64Cbrt, Operator::kNoProperties, 1, 0, 1) \
200  V(Float64Cos, Operator::kNoProperties, 1, 0, 1) \
201  V(Float64Cosh, Operator::kNoProperties, 1, 0, 1) \
202  V(Float64Exp, Operator::kNoProperties, 1, 0, 1) \
203  V(Float64Expm1, Operator::kNoProperties, 1, 0, 1) \
204  V(Float64Log, Operator::kNoProperties, 1, 0, 1) \
205  V(Float64Log1p, Operator::kNoProperties, 1, 0, 1) \
206  V(Float64Log2, Operator::kNoProperties, 1, 0, 1) \
207  V(Float64Log10, Operator::kNoProperties, 1, 0, 1) \
208  V(Float64Max, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
209  V(Float64Min, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
210  V(Float64Neg, Operator::kNoProperties, 1, 0, 1) \
211  V(Float64Add, Operator::kCommutative, 2, 0, 1) \
212  V(Float64Sub, Operator::kNoProperties, 2, 0, 1) \
213  V(Float64Mul, Operator::kCommutative, 2, 0, 1) \
214  V(Float64Div, Operator::kNoProperties, 2, 0, 1) \
215  V(Float64Mod, Operator::kNoProperties, 2, 0, 1) \
216  V(Float64Pow, Operator::kNoProperties, 2, 0, 1) \
217  V(Float64Sin, Operator::kNoProperties, 1, 0, 1) \
218  V(Float64Sinh, Operator::kNoProperties, 1, 0, 1) \
219  V(Float64Sqrt, Operator::kNoProperties, 1, 0, 1) \
220  V(Float64Tan, Operator::kNoProperties, 1, 0, 1) \
221  V(Float64Tanh, Operator::kNoProperties, 1, 0, 1) \
222  V(Float32Equal, Operator::kCommutative, 2, 0, 1) \
223  V(Float32LessThan, Operator::kNoProperties, 2, 0, 1) \
224  V(Float32LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \
225  V(Float64Equal, Operator::kCommutative, 2, 0, 1) \
226  V(Float64LessThan, Operator::kNoProperties, 2, 0, 1) \
227  V(Float64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \
228  V(Float64ExtractLowWord32, Operator::kNoProperties, 1, 0, 1) \
229  V(Float64ExtractHighWord32, Operator::kNoProperties, 1, 0, 1) \
230  V(Float64InsertLowWord32, Operator::kNoProperties, 2, 0, 1) \
231  V(Float64InsertHighWord32, Operator::kNoProperties, 2, 0, 1) \
232  V(LoadStackPointer, Operator::kNoProperties, 0, 0, 1) \
233  V(LoadFramePointer, Operator::kNoProperties, 0, 0, 1) \
234  V(LoadParentFramePointer, Operator::kNoProperties, 0, 0, 1) \
235  V(Int32PairAdd, Operator::kNoProperties, 4, 0, 2) \
236  V(Int32PairSub, Operator::kNoProperties, 4, 0, 2) \
237  V(Int32PairMul, Operator::kNoProperties, 4, 0, 2) \
238  V(Word32PairShl, Operator::kNoProperties, 3, 0, 2) \
239  V(Word32PairShr, Operator::kNoProperties, 3, 0, 2) \
240  V(Word32PairSar, Operator::kNoProperties, 3, 0, 2) \
241  V(F32x4Splat, Operator::kNoProperties, 1, 0, 1) \
242  V(F32x4SConvertI32x4, Operator::kNoProperties, 1, 0, 1) \
243  V(F32x4UConvertI32x4, Operator::kNoProperties, 1, 0, 1) \
244  V(F32x4Abs, Operator::kNoProperties, 1, 0, 1) \
245  V(F32x4Neg, Operator::kNoProperties, 1, 0, 1) \
246  V(F32x4RecipApprox, Operator::kNoProperties, 1, 0, 1) \
247  V(F32x4RecipSqrtApprox, Operator::kNoProperties, 1, 0, 1) \
248  V(F32x4Add, Operator::kCommutative, 2, 0, 1) \
249  V(F32x4AddHoriz, Operator::kNoProperties, 2, 0, 1) \
250  V(F32x4Sub, Operator::kNoProperties, 2, 0, 1) \
251  V(F32x4Mul, Operator::kCommutative, 2, 0, 1) \
252  V(F32x4Min, Operator::kCommutative, 2, 0, 1) \
253  V(F32x4Max, Operator::kCommutative, 2, 0, 1) \
254  V(F32x4Eq, Operator::kCommutative, 2, 0, 1) \
255  V(F32x4Ne, Operator::kCommutative, 2, 0, 1) \
256  V(F32x4Lt, Operator::kNoProperties, 2, 0, 1) \
257  V(F32x4Le, Operator::kNoProperties, 2, 0, 1) \
258  V(I32x4Splat, Operator::kNoProperties, 1, 0, 1) \
259  V(I32x4SConvertF32x4, Operator::kNoProperties, 1, 0, 1) \
260  V(I32x4SConvertI16x8Low, Operator::kNoProperties, 1, 0, 1) \
261  V(I32x4SConvertI16x8High, Operator::kNoProperties, 1, 0, 1) \
262  V(I32x4Neg, Operator::kNoProperties, 1, 0, 1) \
263  V(I32x4Add, Operator::kCommutative, 2, 0, 1) \
264  V(I32x4AddHoriz, Operator::kNoProperties, 2, 0, 1) \
265  V(I32x4Sub, Operator::kNoProperties, 2, 0, 1) \
266  V(I32x4Mul, Operator::kCommutative, 2, 0, 1) \
267  V(I32x4MinS, Operator::kCommutative, 2, 0, 1) \
268  V(I32x4MaxS, Operator::kCommutative, 2, 0, 1) \
269  V(I32x4Eq, Operator::kCommutative, 2, 0, 1) \
270  V(I32x4Ne, Operator::kCommutative, 2, 0, 1) \
271  V(I32x4GtS, Operator::kNoProperties, 2, 0, 1) \
272  V(I32x4GeS, Operator::kNoProperties, 2, 0, 1) \
273  V(I32x4UConvertF32x4, Operator::kNoProperties, 1, 0, 1) \
274  V(I32x4UConvertI16x8Low, Operator::kNoProperties, 1, 0, 1) \
275  V(I32x4UConvertI16x8High, Operator::kNoProperties, 1, 0, 1) \
276  V(I32x4MinU, Operator::kCommutative, 2, 0, 1) \
277  V(I32x4MaxU, Operator::kCommutative, 2, 0, 1) \
278  V(I32x4GtU, Operator::kNoProperties, 2, 0, 1) \
279  V(I32x4GeU, Operator::kNoProperties, 2, 0, 1) \
280  V(I16x8Splat, Operator::kNoProperties, 1, 0, 1) \
281  V(I16x8SConvertI8x16Low, Operator::kNoProperties, 1, 0, 1) \
282  V(I16x8SConvertI8x16High, Operator::kNoProperties, 1, 0, 1) \
283  V(I16x8Neg, Operator::kNoProperties, 1, 0, 1) \
284  V(I16x8SConvertI32x4, Operator::kNoProperties, 2, 0, 1) \
285  V(I16x8Add, Operator::kCommutative, 2, 0, 1) \
286  V(I16x8AddSaturateS, Operator::kCommutative, 2, 0, 1) \
287  V(I16x8AddHoriz, Operator::kNoProperties, 2, 0, 1) \
288  V(I16x8Sub, Operator::kNoProperties, 2, 0, 1) \
289  V(I16x8SubSaturateS, Operator::kNoProperties, 2, 0, 1) \
290  V(I16x8Mul, Operator::kCommutative, 2, 0, 1) \
291  V(I16x8MinS, Operator::kCommutative, 2, 0, 1) \
292  V(I16x8MaxS, Operator::kCommutative, 2, 0, 1) \
293  V(I16x8Eq, Operator::kCommutative, 2, 0, 1) \
294  V(I16x8Ne, Operator::kCommutative, 2, 0, 1) \
295  V(I16x8GtS, Operator::kNoProperties, 2, 0, 1) \
296  V(I16x8GeS, Operator::kNoProperties, 2, 0, 1) \
297  V(I16x8UConvertI8x16Low, Operator::kNoProperties, 1, 0, 1) \
298  V(I16x8UConvertI8x16High, Operator::kNoProperties, 1, 0, 1) \
299  V(I16x8UConvertI32x4, Operator::kNoProperties, 2, 0, 1) \
300  V(I16x8AddSaturateU, Operator::kCommutative, 2, 0, 1) \
301  V(I16x8SubSaturateU, Operator::kNoProperties, 2, 0, 1) \
302  V(I16x8MinU, Operator::kCommutative, 2, 0, 1) \
303  V(I16x8MaxU, Operator::kCommutative, 2, 0, 1) \
304  V(I16x8GtU, Operator::kNoProperties, 2, 0, 1) \
305  V(I16x8GeU, Operator::kNoProperties, 2, 0, 1) \
306  V(I8x16Splat, Operator::kNoProperties, 1, 0, 1) \
307  V(I8x16Neg, Operator::kNoProperties, 1, 0, 1) \
308  V(I8x16SConvertI16x8, Operator::kNoProperties, 2, 0, 1) \
309  V(I8x16Add, Operator::kCommutative, 2, 0, 1) \
310  V(I8x16AddSaturateS, Operator::kCommutative, 2, 0, 1) \
311  V(I8x16Sub, Operator::kNoProperties, 2, 0, 1) \
312  V(I8x16SubSaturateS, Operator::kNoProperties, 2, 0, 1) \
313  V(I8x16Mul, Operator::kCommutative, 2, 0, 1) \
314  V(I8x16MinS, Operator::kCommutative, 2, 0, 1) \
315  V(I8x16MaxS, Operator::kCommutative, 2, 0, 1) \
316  V(I8x16Eq, Operator::kCommutative, 2, 0, 1) \
317  V(I8x16Ne, Operator::kCommutative, 2, 0, 1) \
318  V(I8x16GtS, Operator::kNoProperties, 2, 0, 1) \
319  V(I8x16GeS, Operator::kNoProperties, 2, 0, 1) \
320  V(I8x16UConvertI16x8, Operator::kNoProperties, 2, 0, 1) \
321  V(I8x16AddSaturateU, Operator::kCommutative, 2, 0, 1) \
322  V(I8x16SubSaturateU, Operator::kNoProperties, 2, 0, 1) \
323  V(I8x16MinU, Operator::kCommutative, 2, 0, 1) \
324  V(I8x16MaxU, Operator::kCommutative, 2, 0, 1) \
325  V(I8x16GtU, Operator::kNoProperties, 2, 0, 1) \
326  V(I8x16GeU, Operator::kNoProperties, 2, 0, 1) \
327  V(S128Load, Operator::kNoProperties, 2, 0, 1) \
328  V(S128Store, Operator::kNoProperties, 3, 0, 1) \
329  V(S128Zero, Operator::kNoProperties, 0, 0, 1) \
330  V(S128And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
331  V(S128Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
332  V(S128Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
333  V(S128Not, Operator::kNoProperties, 1, 0, 1) \
334  V(S128Select, Operator::kNoProperties, 3, 0, 1) \
335  V(S1x4AnyTrue, Operator::kNoProperties, 1, 0, 1) \
336  V(S1x4AllTrue, Operator::kNoProperties, 1, 0, 1) \
337  V(S1x8AnyTrue, Operator::kNoProperties, 1, 0, 1) \
338  V(S1x8AllTrue, Operator::kNoProperties, 1, 0, 1) \
339  V(S1x16AnyTrue, Operator::kNoProperties, 1, 0, 1) \
340  V(S1x16AllTrue, Operator::kNoProperties, 1, 0, 1)
341 
342 #define PURE_OPTIONAL_OP_LIST(V) \
343  V(Word32Ctz, Operator::kNoProperties, 1, 0, 1) \
344  V(Word64Ctz, Operator::kNoProperties, 1, 0, 1) \
345  V(Word32ReverseBits, Operator::kNoProperties, 1, 0, 1) \
346  V(Word64ReverseBits, Operator::kNoProperties, 1, 0, 1) \
347  V(Int32AbsWithOverflow, Operator::kNoProperties, 1, 0, 2) \
348  V(Int64AbsWithOverflow, Operator::kNoProperties, 1, 0, 2) \
349  V(Word32Popcnt, Operator::kNoProperties, 1, 0, 1) \
350  V(Word64Popcnt, Operator::kNoProperties, 1, 0, 1) \
351  V(Float32RoundDown, Operator::kNoProperties, 1, 0, 1) \
352  V(Float64RoundDown, Operator::kNoProperties, 1, 0, 1) \
353  V(Float32RoundUp, Operator::kNoProperties, 1, 0, 1) \
354  V(Float64RoundUp, Operator::kNoProperties, 1, 0, 1) \
355  V(Float32RoundTruncate, Operator::kNoProperties, 1, 0, 1) \
356  V(Float64RoundTruncate, Operator::kNoProperties, 1, 0, 1) \
357  V(Float64RoundTiesAway, Operator::kNoProperties, 1, 0, 1) \
358  V(Float32RoundTiesEven, Operator::kNoProperties, 1, 0, 1) \
359  V(Float64RoundTiesEven, Operator::kNoProperties, 1, 0, 1)
360 
361 #define OVERFLOW_OP_LIST(V) \
362  V(Int32AddWithOverflow, Operator::kAssociative | Operator::kCommutative) \
363  V(Int32SubWithOverflow, Operator::kNoProperties) \
364  V(Int32MulWithOverflow, Operator::kAssociative | Operator::kCommutative) \
365  V(Int64AddWithOverflow, Operator::kAssociative | Operator::kCommutative) \
366  V(Int64SubWithOverflow, Operator::kNoProperties)
367 
368 #define MACHINE_TYPE_LIST(V) \
369  V(Float32) \
370  V(Float64) \
371  V(Simd128) \
372  V(Int8) \
373  V(Uint8) \
374  V(Int16) \
375  V(Uint16) \
376  V(Int32) \
377  V(Uint32) \
378  V(Int64) \
379  V(Uint64) \
380  V(Pointer) \
381  V(TaggedSigned) \
382  V(TaggedPointer) \
383  V(AnyTagged)
384 
385 #define MACHINE_REPRESENTATION_LIST(V) \
386  V(kFloat32) \
387  V(kFloat64) \
388  V(kSimd128) \
389  V(kWord8) \
390  V(kWord16) \
391  V(kWord32) \
392  V(kWord64) \
393  V(kTaggedSigned) \
394  V(kTaggedPointer) \
395  V(kTagged)
396 
397 #define ATOMIC_U32_TYPE_LIST(V) \
398  V(Uint8) \
399  V(Uint16) \
400  V(Uint32)
401 
402 #define ATOMIC_TYPE_LIST(V) \
403  ATOMIC_U32_TYPE_LIST(V) \
404  V(Int8) \
405  V(Int16) \
406  V(Int32)
407 
408 #define ATOMIC_U64_TYPE_LIST(V) \
409  ATOMIC_U32_TYPE_LIST(V) \
410  V(Uint64)
411 
412 #define ATOMIC_REPRESENTATION_LIST(V) \
413  V(kWord8) \
414  V(kWord16) \
415  V(kWord32)
416 
417 #define ATOMIC64_REPRESENTATION_LIST(V) \
418  ATOMIC_REPRESENTATION_LIST(V) \
419  V(kWord64)
420 
421 #define ATOMIC_PAIR_BINOP_LIST(V) \
422  V(Add) \
423  V(Sub) \
424  V(And) \
425  V(Or) \
426  V(Xor) \
427  V(Exchange)
428 
429 #define SIMD_LANE_OP_LIST(V) \
430  V(F32x4, 4) \
431  V(I32x4, 4) \
432  V(I16x8, 8) \
433  V(I8x16, 16)
434 
435 #define SIMD_FORMAT_LIST(V) \
436  V(32x4, 32) \
437  V(16x8, 16) \
438  V(8x16, 8)
439 
440 #define STACK_SLOT_CACHED_SIZES_ALIGNMENTS_LIST(V) \
441  V(4, 0) V(8, 0) V(16, 0) V(4, 4) V(8, 8) V(16, 16)
442 
443 struct StackSlotOperator : public Operator1<StackSlotRepresentation> {
444  explicit StackSlotOperator(int size, int alignment)
446  IrOpcode::kStackSlot, Operator::kNoDeopt | Operator::kNoThrow,
447  "StackSlot", 0, 0, 0, 1, 0, 0,
448  StackSlotRepresentation(size, alignment)) {}
449 };
450 
452 #define PURE(Name, properties, value_input_count, control_input_count, \
453  output_count) \
454  struct Name##Operator final : public Operator { \
455  Name##Operator() \
456  : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \
457  value_input_count, 0, control_input_count, output_count, 0, \
458  0) {} \
459  }; \
460  Name##Operator k##Name;
461  MACHINE_PURE_OP_LIST(PURE)
462  PURE_OPTIONAL_OP_LIST(PURE)
463 #undef PURE
464 
465 #define OVERFLOW_OP(Name, properties) \
466  struct Name##Operator final : public Operator { \
467  Name##Operator() \
468  : Operator(IrOpcode::k##Name, \
469  Operator::kEliminatable | Operator::kNoRead | properties, \
470  #Name, 2, 0, 1, 2, 0, 0) {} \
471  }; \
472  Name##Operator k##Name;
473  OVERFLOW_OP_LIST(OVERFLOW_OP)
474 #undef OVERFLOW_OP
475 
476 #define LOAD(Type) \
477  struct Load##Type##Operator final : public Operator1<LoadRepresentation> { \
478  Load##Type##Operator() \
479  : Operator1<LoadRepresentation>( \
480  IrOpcode::kLoad, \
481  Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \
482  "Load", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \
483  }; \
484  struct PoisonedLoad##Type##Operator final \
485  : public Operator1<LoadRepresentation> { \
486  PoisonedLoad##Type##Operator() \
487  : Operator1<LoadRepresentation>( \
488  IrOpcode::kPoisonedLoad, \
489  Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \
490  "PoisonedLoad", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \
491  }; \
492  struct UnalignedLoad##Type##Operator final \
493  : public Operator1<LoadRepresentation> { \
494  UnalignedLoad##Type##Operator() \
495  : Operator1<LoadRepresentation>( \
496  IrOpcode::kUnalignedLoad, \
497  Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \
498  "UnalignedLoad", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \
499  }; \
500  struct ProtectedLoad##Type##Operator final \
501  : public Operator1<LoadRepresentation> { \
502  ProtectedLoad##Type##Operator() \
503  : Operator1<LoadRepresentation>( \
504  IrOpcode::kProtectedLoad, \
505  Operator::kNoDeopt | Operator::kNoThrow, "ProtectedLoad", 2, 1, \
506  1, 1, 1, 0, MachineType::Type()) {} \
507  }; \
508  Load##Type##Operator kLoad##Type; \
509  PoisonedLoad##Type##Operator kPoisonedLoad##Type; \
510  UnalignedLoad##Type##Operator kUnalignedLoad##Type; \
511  ProtectedLoad##Type##Operator kProtectedLoad##Type;
512  MACHINE_TYPE_LIST(LOAD)
513 #undef LOAD
514 
515 #define STACKSLOT(Size, Alignment) \
516  struct StackSlotOfSize##Size##OfAlignment##Alignment##Operator final \
517  : public StackSlotOperator { \
518  StackSlotOfSize##Size##OfAlignment##Alignment##Operator() \
519  : StackSlotOperator(Size, Alignment) {} \
520  }; \
521  StackSlotOfSize##Size##OfAlignment##Alignment##Operator \
522  kStackSlotOfSize##Size##OfAlignment##Alignment;
523  STACK_SLOT_CACHED_SIZES_ALIGNMENTS_LIST(STACKSLOT)
524 #undef STACKSLOT
525 
526 #define STORE(Type) \
527  struct Store##Type##Operator : public Operator1<StoreRepresentation> { \
528  explicit Store##Type##Operator(WriteBarrierKind write_barrier_kind) \
529  : Operator1<StoreRepresentation>( \
530  IrOpcode::kStore, \
531  Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \
532  "Store", 3, 1, 1, 0, 1, 0, \
533  StoreRepresentation(MachineRepresentation::Type, \
534  write_barrier_kind)) {} \
535  }; \
536  struct Store##Type##NoWriteBarrier##Operator final \
537  : public Store##Type##Operator { \
538  Store##Type##NoWriteBarrier##Operator() \
539  : Store##Type##Operator(kNoWriteBarrier) {} \
540  }; \
541  struct Store##Type##MapWriteBarrier##Operator final \
542  : public Store##Type##Operator { \
543  Store##Type##MapWriteBarrier##Operator() \
544  : Store##Type##Operator(kMapWriteBarrier) {} \
545  }; \
546  struct Store##Type##PointerWriteBarrier##Operator final \
547  : public Store##Type##Operator { \
548  Store##Type##PointerWriteBarrier##Operator() \
549  : Store##Type##Operator(kPointerWriteBarrier) {} \
550  }; \
551  struct Store##Type##FullWriteBarrier##Operator final \
552  : public Store##Type##Operator { \
553  Store##Type##FullWriteBarrier##Operator() \
554  : Store##Type##Operator(kFullWriteBarrier) {} \
555  }; \
556  struct UnalignedStore##Type##Operator final \
557  : public Operator1<UnalignedStoreRepresentation> { \
558  UnalignedStore##Type##Operator() \
559  : Operator1<UnalignedStoreRepresentation>( \
560  IrOpcode::kUnalignedStore, \
561  Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \
562  "UnalignedStore", 3, 1, 1, 0, 1, 0, \
563  MachineRepresentation::Type) {} \
564  }; \
565  struct ProtectedStore##Type##Operator \
566  : public Operator1<StoreRepresentation> { \
567  explicit ProtectedStore##Type##Operator() \
568  : Operator1<StoreRepresentation>( \
569  IrOpcode::kProtectedStore, \
570  Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \
571  "Store", 3, 1, 1, 0, 1, 0, \
572  StoreRepresentation(MachineRepresentation::Type, \
573  kNoWriteBarrier)) {} \
574  }; \
575  Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \
576  Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier; \
577  Store##Type##PointerWriteBarrier##Operator \
578  kStore##Type##PointerWriteBarrier; \
579  Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier; \
580  UnalignedStore##Type##Operator kUnalignedStore##Type; \
581  ProtectedStore##Type##Operator kProtectedStore##Type;
582  MACHINE_REPRESENTATION_LIST(STORE)
583 #undef STORE
584 
585 #define ATOMIC_LOAD(Type) \
586  struct Word32AtomicLoad##Type##Operator final \
587  : public Operator1<LoadRepresentation> { \
588  Word32AtomicLoad##Type##Operator() \
589  : Operator1<LoadRepresentation>( \
590  IrOpcode::kWord32AtomicLoad, \
591  Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \
592  "Word32AtomicLoad", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \
593  }; \
594  Word32AtomicLoad##Type##Operator kWord32AtomicLoad##Type;
595  ATOMIC_TYPE_LIST(ATOMIC_LOAD)
596 #undef ATOMIC_LOAD
597 
598 #define ATOMIC_LOAD(Type) \
599  struct Word64AtomicLoad##Type##Operator final \
600  : public Operator1<LoadRepresentation> { \
601  Word64AtomicLoad##Type##Operator() \
602  : Operator1<LoadRepresentation>( \
603  IrOpcode::kWord64AtomicLoad, \
604  Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \
605  "Word64AtomicLoad", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \
606  }; \
607  Word64AtomicLoad##Type##Operator kWord64AtomicLoad##Type;
608  ATOMIC_U64_TYPE_LIST(ATOMIC_LOAD)
609 #undef ATOMIC_LOAD
610 
611 #define ATOMIC_STORE(Type) \
612  struct Word32AtomicStore##Type##Operator \
613  : public Operator1<MachineRepresentation> { \
614  Word32AtomicStore##Type##Operator() \
615  : Operator1<MachineRepresentation>( \
616  IrOpcode::kWord32AtomicStore, \
617  Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \
618  "Word32AtomicStore", 3, 1, 1, 0, 1, 0, \
619  MachineRepresentation::Type) {} \
620  }; \
621  Word32AtomicStore##Type##Operator kWord32AtomicStore##Type;
622  ATOMIC_REPRESENTATION_LIST(ATOMIC_STORE)
623 #undef ATOMIC_STORE
624 
625 #define ATOMIC_STORE(Type) \
626  struct Word64AtomicStore##Type##Operator \
627  : public Operator1<MachineRepresentation> { \
628  Word64AtomicStore##Type##Operator() \
629  : Operator1<MachineRepresentation>( \
630  IrOpcode::kWord64AtomicStore, \
631  Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow, \
632  "Word64AtomicStore", 3, 1, 1, 0, 1, 0, \
633  MachineRepresentation::Type) {} \
634  }; \
635  Word64AtomicStore##Type##Operator kWord64AtomicStore##Type;
636  ATOMIC64_REPRESENTATION_LIST(ATOMIC_STORE)
637 #undef ATOMIC_STORE
638 
639 #define ATOMIC_OP(op, type) \
640  struct op##type##Operator : public Operator1<MachineType> { \
641  op##type##Operator() \
642  : Operator1<MachineType>(IrOpcode::k##op, \
643  Operator::kNoDeopt | Operator::kNoThrow, #op, \
644  3, 1, 1, 1, 1, 0, MachineType::type()) {} \
645  }; \
646  op##type##Operator k##op##type;
647 #define ATOMIC_OP_LIST(type) \
648  ATOMIC_OP(Word32AtomicAdd, type) \
649  ATOMIC_OP(Word32AtomicSub, type) \
650  ATOMIC_OP(Word32AtomicAnd, type) \
651  ATOMIC_OP(Word32AtomicOr, type) \
652  ATOMIC_OP(Word32AtomicXor, type) \
653  ATOMIC_OP(Word32AtomicExchange, type)
654  ATOMIC_TYPE_LIST(ATOMIC_OP_LIST)
655 #undef ATOMIC_OP_LIST
656 #define ATOMIC64_OP_LIST(type) \
657  ATOMIC_OP(Word64AtomicAdd, type) \
658  ATOMIC_OP(Word64AtomicSub, type) \
659  ATOMIC_OP(Word64AtomicAnd, type) \
660  ATOMIC_OP(Word64AtomicOr, type) \
661  ATOMIC_OP(Word64AtomicXor, type) \
662  ATOMIC_OP(Word64AtomicExchange, type)
663  ATOMIC_U64_TYPE_LIST(ATOMIC64_OP_LIST)
664 #undef ATOMIC64_OP_LIST
665 #undef ATOMIC_OP
666 
667 #define ATOMIC_COMPARE_EXCHANGE(Type) \
668  struct Word32AtomicCompareExchange##Type##Operator \
669  : public Operator1<MachineType> { \
670  Word32AtomicCompareExchange##Type##Operator() \
671  : Operator1<MachineType>(IrOpcode::kWord32AtomicCompareExchange, \
672  Operator::kNoDeopt | Operator::kNoThrow, \
673  "Word32AtomicCompareExchange", 4, 1, 1, 1, 1, \
674  0, MachineType::Type()) {} \
675  }; \
676  Word32AtomicCompareExchange##Type##Operator \
677  kWord32AtomicCompareExchange##Type;
678  ATOMIC_TYPE_LIST(ATOMIC_COMPARE_EXCHANGE)
679 #undef ATOMIC_COMPARE_EXCHANGE
680 
681 #define ATOMIC_COMPARE_EXCHANGE(Type) \
682  struct Word64AtomicCompareExchange##Type##Operator \
683  : public Operator1<MachineType> { \
684  Word64AtomicCompareExchange##Type##Operator() \
685  : Operator1<MachineType>(IrOpcode::kWord64AtomicCompareExchange, \
686  Operator::kNoDeopt | Operator::kNoThrow, \
687  "Word64AtomicCompareExchange", 4, 1, 1, 1, 1, \
688  0, MachineType::Type()) {} \
689  }; \
690  Word64AtomicCompareExchange##Type##Operator \
691  kWord64AtomicCompareExchange##Type;
692  ATOMIC_U64_TYPE_LIST(ATOMIC_COMPARE_EXCHANGE)
693 #undef ATOMIC_COMPARE_EXCHANGE
694 
697  : Operator(IrOpcode::kWord32AtomicPairLoad,
698  Operator::kNoDeopt | Operator::kNoThrow,
699  "Word32AtomicPairLoad", 2, 1, 1, 2, 1, 0) {}
700  };
701  Word32AtomicPairLoadOperator kWord32AtomicPairLoad;
702 
705  : Operator(IrOpcode::kWord32AtomicPairStore,
706  Operator::kNoDeopt | Operator::kNoThrow,
707  "Word32AtomicPairStore", 4, 1, 1, 0, 1, 0) {}
708  };
709  Word32AtomicPairStoreOperator kWord32AtomicPairStore;
710 
711 #define ATOMIC_PAIR_OP(op) \
712  struct Word32AtomicPair##op##Operator : public Operator { \
713  Word32AtomicPair##op##Operator() \
714  : Operator(IrOpcode::kWord32AtomicPair##op, \
715  Operator::kNoDeopt | Operator::kNoThrow, \
716  "Word32AtomicPair##op", 4, 1, 1, 2, 1, 0) {} \
717  }; \
718  Word32AtomicPair##op##Operator kWord32AtomicPair##op;
719  ATOMIC_PAIR_BINOP_LIST(ATOMIC_PAIR_OP)
720 #undef ATOMIC_PAIR_OP
721 #undef ATOMIC_PAIR_BINOP_LIST
722 
725  : Operator(IrOpcode::kWord32AtomicPairCompareExchange,
726  Operator::kNoDeopt | Operator::kNoThrow,
727  "Word32AtomicPairCompareExchange", 6, 1, 1, 2, 1, 0) {}
728  };
729  Word32AtomicPairCompareExchangeOperator kWord32AtomicPairCompareExchange;
730 
731  // The {BitcastWordToTagged} operator must not be marked as pure (especially
732  // not idempotent), because otherwise the splitting logic in the Scheduler
733  // might decide to split these operators, thus potentially creating live
734  // ranges of allocation top across calls or other things that might allocate.
735  // See https://bugs.chromium.org/p/v8/issues/detail?id=6059 for more details.
738  : Operator(IrOpcode::kBitcastWordToTagged,
739  Operator::kEliminatable | Operator::kNoWrite,
740  "BitcastWordToTagged", 1, 1, 1, 1, 1, 0) {}
741  };
742  BitcastWordToTaggedOperator kBitcastWordToTagged;
743 
746  : Operator(IrOpcode::kBitcastTaggedToWord,
747  Operator::kEliminatable | Operator::kNoWrite,
748  "BitcastTaggedToWord", 1, 1, 1, 1, 1, 0) {}
749  };
750  BitcastTaggedToWordOperator kBitcastTaggedToWord;
751 
754  : Operator(IrOpcode::kBitcastTaggedToWord,
755  Operator::kEliminatable | Operator::kNoWrite,
756  "BitcastMaybeObjectToWord", 1, 1, 1, 1, 1, 0) {}
757  };
758  BitcastMaybeObjectToWordOperator kBitcastMaybeObjectToWord;
759 
762  : Operator(IrOpcode::kTaggedPoisonOnSpeculation,
763  Operator::kEliminatable | Operator::kNoWrite,
764  "TaggedPoisonOnSpeculation", 1, 1, 1, 1, 1, 0) {}
765  };
766  TaggedPoisonOnSpeculation kTaggedPoisonOnSpeculation;
767 
770  : Operator(IrOpcode::kWord32PoisonOnSpeculation,
771  Operator::kEliminatable | Operator::kNoWrite,
772  "Word32PoisonOnSpeculation", 1, 1, 1, 1, 1, 0) {}
773  };
774  Word32PoisonOnSpeculation kWord32PoisonOnSpeculation;
775 
778  : Operator(IrOpcode::kWord64PoisonOnSpeculation,
779  Operator::kEliminatable | Operator::kNoWrite,
780  "Word64PoisonOnSpeculation", 1, 1, 1, 1, 1, 0) {}
781  };
782  Word64PoisonOnSpeculation kWord64PoisonOnSpeculation;
783 
786  : Operator(IrOpcode::kSpeculationFence, Operator::kNoThrow,
787  "SpeculationFence", 0, 1, 1, 0, 1, 0) {}
788  };
789  SpeculationFenceOperator kSpeculationFence;
790 
791  struct DebugAbortOperator : public Operator {
793  : Operator(IrOpcode::kDebugAbort, Operator::kNoThrow, "DebugAbort", 1,
794  1, 1, 0, 1, 0) {}
795  };
796  DebugAbortOperator kDebugAbort;
797 
798  struct DebugBreakOperator : public Operator {
800  : Operator(IrOpcode::kDebugBreak, Operator::kNoThrow, "DebugBreak", 0,
801  1, 1, 0, 1, 0) {}
802  };
803  DebugBreakOperator kDebugBreak;
804 
805  struct UnsafePointerAddOperator final : public Operator {
807  : Operator(IrOpcode::kUnsafePointerAdd, Operator::kKontrol,
808  "UnsafePointerAdd", 2, 1, 1, 1, 1, 0) {}
809  };
810  UnsafePointerAddOperator kUnsafePointerAdd;
811 };
812 
813 struct CommentOperator : public Operator1<const char*> {
814  explicit CommentOperator(const char* msg)
815  : Operator1<const char*>(IrOpcode::kComment, Operator::kNoThrow,
816  "Comment", 0, 0, 0, 0, 0, 0, msg) {}
817 };
818 
820  kMachineOperatorGlobalCache = LAZY_INSTANCE_INITIALIZER;
821 
822 MachineOperatorBuilder::MachineOperatorBuilder(
823  Zone* zone, MachineRepresentation word, Flags flags,
824  AlignmentRequirements alignmentRequirements)
825  : zone_(zone),
826  cache_(kMachineOperatorGlobalCache.Get()),
827  word_(word),
828  flags_(flags),
829  alignment_requirements_(alignmentRequirements) {
830  DCHECK(word == MachineRepresentation::kWord32 ||
831  word == MachineRepresentation::kWord64);
832 }
833 
834 const Operator* MachineOperatorBuilder::UnalignedLoad(LoadRepresentation rep) {
835 #define LOAD(Type) \
836  if (rep == MachineType::Type()) { \
837  return &cache_.kUnalignedLoad##Type; \
838  }
839  MACHINE_TYPE_LIST(LOAD)
840 #undef LOAD
841  UNREACHABLE();
842 }
843 
844 const Operator* MachineOperatorBuilder::UnalignedStore(
845  UnalignedStoreRepresentation rep) {
846  switch (rep) {
847 #define STORE(kRep) \
848  case MachineRepresentation::kRep: \
849  return &cache_.kUnalignedStore##kRep;
850  MACHINE_REPRESENTATION_LIST(STORE)
851 #undef STORE
852  case MachineRepresentation::kBit:
853  case MachineRepresentation::kNone:
854  break;
855  }
856  UNREACHABLE();
857 }
858 
859 #define PURE(Name, properties, value_input_count, control_input_count, \
860  output_count) \
861  const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; }
862 MACHINE_PURE_OP_LIST(PURE)
863 #undef PURE
864 
865 #define PURE(Name, properties, value_input_count, control_input_count, \
866  output_count) \
867  const OptionalOperator MachineOperatorBuilder::Name() { \
868  return OptionalOperator(flags_ & k##Name, &cache_.k##Name); \
869  }
870 PURE_OPTIONAL_OP_LIST(PURE)
871 #undef PURE
872 
873 #define OVERFLOW_OP(Name, properties) \
874  const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; }
875 OVERFLOW_OP_LIST(OVERFLOW_OP)
876 #undef OVERFLOW_OP
877 
878 const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) {
879 #define LOAD(Type) \
880  if (rep == MachineType::Type()) { \
881  return &cache_.kLoad##Type; \
882  }
883  MACHINE_TYPE_LIST(LOAD)
884 #undef LOAD
885  UNREACHABLE();
886 }
887 
888 const Operator* MachineOperatorBuilder::PoisonedLoad(LoadRepresentation rep) {
889 #define LOAD(Type) \
890  if (rep == MachineType::Type()) { \
891  return &cache_.kPoisonedLoad##Type; \
892  }
893  MACHINE_TYPE_LIST(LOAD)
894 #undef LOAD
895  UNREACHABLE();
896 }
897 
898 const Operator* MachineOperatorBuilder::ProtectedLoad(LoadRepresentation rep) {
899 #define LOAD(Type) \
900  if (rep == MachineType::Type()) { \
901  return &cache_.kProtectedLoad##Type; \
902  }
903  MACHINE_TYPE_LIST(LOAD)
904 #undef LOAD
905  UNREACHABLE();
906 }
907 
908 const Operator* MachineOperatorBuilder::StackSlot(int size, int alignment) {
909  DCHECK_LE(0, size);
910  DCHECK(alignment == 0 || alignment == 4 || alignment == 8 || alignment == 16);
911 #define CASE_CACHED_SIZE(Size, Alignment) \
912  if (size == Size && alignment == Alignment) { \
913  return &cache_.kStackSlotOfSize##Size##OfAlignment##Alignment; \
914  }
915 
916  STACK_SLOT_CACHED_SIZES_ALIGNMENTS_LIST(CASE_CACHED_SIZE)
917 
918 #undef CASE_CACHED_SIZE
919  return new (zone_) StackSlotOperator(size, alignment);
920 }
921 
922 const Operator* MachineOperatorBuilder::StackSlot(MachineRepresentation rep,
923  int alignment) {
924  return StackSlot(1 << ElementSizeLog2Of(rep), alignment);
925 }
926 
927 const Operator* MachineOperatorBuilder::Store(StoreRepresentation store_rep) {
928  switch (store_rep.representation()) {
929 #define STORE(kRep) \
930  case MachineRepresentation::kRep: \
931  switch (store_rep.write_barrier_kind()) { \
932  case kNoWriteBarrier: \
933  return &cache_.k##Store##kRep##NoWriteBarrier; \
934  case kMapWriteBarrier: \
935  return &cache_.k##Store##kRep##MapWriteBarrier; \
936  case kPointerWriteBarrier: \
937  return &cache_.k##Store##kRep##PointerWriteBarrier; \
938  case kFullWriteBarrier: \
939  return &cache_.k##Store##kRep##FullWriteBarrier; \
940  } \
941  break;
942  MACHINE_REPRESENTATION_LIST(STORE)
943 #undef STORE
944  case MachineRepresentation::kBit:
945  case MachineRepresentation::kNone:
946  break;
947  }
948  UNREACHABLE();
949 }
950 
951 const Operator* MachineOperatorBuilder::ProtectedStore(
952  MachineRepresentation rep) {
953  switch (rep) {
954 #define STORE(kRep) \
955  case MachineRepresentation::kRep: \
956  return &cache_.kProtectedStore##kRep; \
957  break;
958  MACHINE_REPRESENTATION_LIST(STORE)
959 #undef STORE
960  case MachineRepresentation::kBit:
961  case MachineRepresentation::kNone:
962  break;
963  }
964  UNREACHABLE();
965 }
966 
967 const Operator* MachineOperatorBuilder::UnsafePointerAdd() {
968  return &cache_.kUnsafePointerAdd;
969 }
970 
971 const Operator* MachineOperatorBuilder::BitcastWordToTagged() {
972  return &cache_.kBitcastWordToTagged;
973 }
974 
975 const Operator* MachineOperatorBuilder::BitcastTaggedToWord() {
976  return &cache_.kBitcastTaggedToWord;
977 }
978 
979 const Operator* MachineOperatorBuilder::BitcastMaybeObjectToWord() {
980  return &cache_.kBitcastMaybeObjectToWord;
981 }
982 
983 const Operator* MachineOperatorBuilder::DebugAbort() {
984  return &cache_.kDebugAbort;
985 }
986 
987 const Operator* MachineOperatorBuilder::DebugBreak() {
988  return &cache_.kDebugBreak;
989 }
990 
991 const Operator* MachineOperatorBuilder::Comment(const char* msg) {
992  return new (zone_) CommentOperator(msg);
993 }
994 
995 const Operator* MachineOperatorBuilder::Word32AtomicLoad(
996  LoadRepresentation rep) {
997 #define LOAD(Type) \
998  if (rep == MachineType::Type()) { \
999  return &cache_.kWord32AtomicLoad##Type; \
1000  }
1001  ATOMIC_TYPE_LIST(LOAD)
1002 #undef LOAD
1003  UNREACHABLE();
1004 }
1005 
1006 const Operator* MachineOperatorBuilder::Word32AtomicStore(
1007  MachineRepresentation rep) {
1008 #define STORE(kRep) \
1009  if (rep == MachineRepresentation::kRep) { \
1010  return &cache_.kWord32AtomicStore##kRep; \
1011  }
1012  ATOMIC_REPRESENTATION_LIST(STORE)
1013 #undef STORE
1014  UNREACHABLE();
1015 }
1016 
1017 const Operator* MachineOperatorBuilder::Word32AtomicExchange(MachineType type) {
1018 #define EXCHANGE(kType) \
1019  if (type == MachineType::kType()) { \
1020  return &cache_.kWord32AtomicExchange##kType; \
1021  }
1022  ATOMIC_TYPE_LIST(EXCHANGE)
1023 #undef EXCHANGE
1024  UNREACHABLE();
1025 }
1026 
1027 const Operator* MachineOperatorBuilder::Word32AtomicCompareExchange(
1028  MachineType type) {
1029 #define COMPARE_EXCHANGE(kType) \
1030  if (type == MachineType::kType()) { \
1031  return &cache_.kWord32AtomicCompareExchange##kType; \
1032  }
1033  ATOMIC_TYPE_LIST(COMPARE_EXCHANGE)
1034 #undef COMPARE_EXCHANGE
1035  UNREACHABLE();
1036 }
1037 
1038 const Operator* MachineOperatorBuilder::Word32AtomicAdd(MachineType type) {
1039 #define ADD(kType) \
1040  if (type == MachineType::kType()) { \
1041  return &cache_.kWord32AtomicAdd##kType; \
1042  }
1043  ATOMIC_TYPE_LIST(ADD)
1044 #undef ADD
1045  UNREACHABLE();
1046 }
1047 
1048 const Operator* MachineOperatorBuilder::Word32AtomicSub(MachineType type) {
1049 #define SUB(kType) \
1050  if (type == MachineType::kType()) { \
1051  return &cache_.kWord32AtomicSub##kType; \
1052  }
1053  ATOMIC_TYPE_LIST(SUB)
1054 #undef SUB
1055  UNREACHABLE();
1056 }
1057 
1058 const Operator* MachineOperatorBuilder::Word32AtomicAnd(MachineType type) {
1059 #define AND(kType) \
1060  if (type == MachineType::kType()) { \
1061  return &cache_.kWord32AtomicAnd##kType; \
1062  }
1063  ATOMIC_TYPE_LIST(AND)
1064 #undef AND
1065  UNREACHABLE();
1066 }
1067 
1068 const Operator* MachineOperatorBuilder::Word32AtomicOr(MachineType type) {
1069 #define OR(kType) \
1070  if (type == MachineType::kType()) { \
1071  return &cache_.kWord32AtomicOr##kType; \
1072  }
1073  ATOMIC_TYPE_LIST(OR)
1074 #undef OR
1075  UNREACHABLE();
1076 }
1077 
1078 const Operator* MachineOperatorBuilder::Word32AtomicXor(MachineType type) {
1079 #define XOR(kType) \
1080  if (type == MachineType::kType()) { \
1081  return &cache_.kWord32AtomicXor##kType; \
1082  }
1083  ATOMIC_TYPE_LIST(XOR)
1084 #undef XOR
1085  UNREACHABLE();
1086 }
1087 
1088 const Operator* MachineOperatorBuilder::Word64AtomicLoad(
1089  LoadRepresentation rep) {
1090 #define LOAD(Type) \
1091  if (rep == MachineType::Type()) { \
1092  return &cache_.kWord64AtomicLoad##Type; \
1093  }
1094  ATOMIC_U64_TYPE_LIST(LOAD)
1095 #undef LOAD
1096  UNREACHABLE();
1097 }
1098 
1099 const Operator* MachineOperatorBuilder::Word64AtomicStore(
1100  MachineRepresentation rep) {
1101 #define STORE(kRep) \
1102  if (rep == MachineRepresentation::kRep) { \
1103  return &cache_.kWord64AtomicStore##kRep; \
1104  }
1105  ATOMIC64_REPRESENTATION_LIST(STORE)
1106 #undef STORE
1107  UNREACHABLE();
1108 }
1109 
1110 const Operator* MachineOperatorBuilder::Word64AtomicAdd(MachineType type) {
1111 #define ADD(kType) \
1112  if (type == MachineType::kType()) { \
1113  return &cache_.kWord64AtomicAdd##kType; \
1114  }
1115  ATOMIC_U64_TYPE_LIST(ADD)
1116 #undef ADD
1117  UNREACHABLE();
1118 }
1119 
1120 const Operator* MachineOperatorBuilder::Word64AtomicSub(MachineType type) {
1121 #define SUB(kType) \
1122  if (type == MachineType::kType()) { \
1123  return &cache_.kWord64AtomicSub##kType; \
1124  }
1125  ATOMIC_U64_TYPE_LIST(SUB)
1126 #undef SUB
1127  UNREACHABLE();
1128 }
1129 
1130 const Operator* MachineOperatorBuilder::Word64AtomicAnd(MachineType type) {
1131 #define AND(kType) \
1132  if (type == MachineType::kType()) { \
1133  return &cache_.kWord64AtomicAnd##kType; \
1134  }
1135  ATOMIC_U64_TYPE_LIST(AND)
1136 #undef AND
1137  UNREACHABLE();
1138 }
1139 
1140 const Operator* MachineOperatorBuilder::Word64AtomicOr(MachineType type) {
1141 #define OR(kType) \
1142  if (type == MachineType::kType()) { \
1143  return &cache_.kWord64AtomicOr##kType; \
1144  }
1145  ATOMIC_U64_TYPE_LIST(OR)
1146 #undef OR
1147  UNREACHABLE();
1148 }
1149 
1150 const Operator* MachineOperatorBuilder::Word64AtomicXor(MachineType type) {
1151 #define XOR(kType) \
1152  if (type == MachineType::kType()) { \
1153  return &cache_.kWord64AtomicXor##kType; \
1154  }
1155  ATOMIC_U64_TYPE_LIST(XOR)
1156 #undef XOR
1157  UNREACHABLE();
1158 }
1159 
1160 const Operator* MachineOperatorBuilder::Word64AtomicExchange(MachineType type) {
1161 #define EXCHANGE(kType) \
1162  if (type == MachineType::kType()) { \
1163  return &cache_.kWord64AtomicExchange##kType; \
1164  }
1165  ATOMIC_U64_TYPE_LIST(EXCHANGE)
1166 #undef EXCHANGE
1167  UNREACHABLE();
1168 }
1169 
1170 const Operator* MachineOperatorBuilder::Word64AtomicCompareExchange(
1171  MachineType type) {
1172 #define COMPARE_EXCHANGE(kType) \
1173  if (type == MachineType::kType()) { \
1174  return &cache_.kWord64AtomicCompareExchange##kType; \
1175  }
1176  ATOMIC_U64_TYPE_LIST(COMPARE_EXCHANGE)
1177 #undef COMPARE_EXCHANGE
1178  UNREACHABLE();
1179 }
1180 
1181 const Operator* MachineOperatorBuilder::Word32AtomicPairLoad() {
1182  return &cache_.kWord32AtomicPairLoad;
1183 }
1184 
1185 const Operator* MachineOperatorBuilder::Word32AtomicPairStore() {
1186  return &cache_.kWord32AtomicPairStore;
1187 }
1188 
1189 const Operator* MachineOperatorBuilder::Word32AtomicPairAdd() {
1190  return &cache_.kWord32AtomicPairAdd;
1191 }
1192 
1193 const Operator* MachineOperatorBuilder::Word32AtomicPairSub() {
1194  return &cache_.kWord32AtomicPairSub;
1195 }
1196 
1197 const Operator* MachineOperatorBuilder::Word32AtomicPairAnd() {
1198  return &cache_.kWord32AtomicPairAnd;
1199 }
1200 
1201 const Operator* MachineOperatorBuilder::Word32AtomicPairOr() {
1202  return &cache_.kWord32AtomicPairOr;
1203 }
1204 
1205 const Operator* MachineOperatorBuilder::Word32AtomicPairXor() {
1206  return &cache_.kWord32AtomicPairXor;
1207 }
1208 
1209 const Operator* MachineOperatorBuilder::Word32AtomicPairExchange() {
1210  return &cache_.kWord32AtomicPairExchange;
1211 }
1212 
1213 const Operator* MachineOperatorBuilder::Word32AtomicPairCompareExchange() {
1214  return &cache_.kWord32AtomicPairCompareExchange;
1215 }
1216 
1217 const Operator* MachineOperatorBuilder::TaggedPoisonOnSpeculation() {
1218  return &cache_.kTaggedPoisonOnSpeculation;
1219 }
1220 
1221 const Operator* MachineOperatorBuilder::Word32PoisonOnSpeculation() {
1222  return &cache_.kWord32PoisonOnSpeculation;
1223 }
1224 
1225 const Operator* MachineOperatorBuilder::Word64PoisonOnSpeculation() {
1226  return &cache_.kWord64PoisonOnSpeculation;
1227 }
1228 
1229 const OptionalOperator MachineOperatorBuilder::SpeculationFence() {
1230  return OptionalOperator(flags_ & kSpeculationFence,
1231  &cache_.kSpeculationFence);
1232 }
1233 
1234 #define SIMD_LANE_OPS(Type, lane_count) \
1235  const Operator* MachineOperatorBuilder::Type##ExtractLane( \
1236  int32_t lane_index) { \
1237  DCHECK(0 <= lane_index && lane_index < lane_count); \
1238  return new (zone_) \
1239  Operator1<int32_t>(IrOpcode::k##Type##ExtractLane, Operator::kPure, \
1240  "Extract lane", 1, 0, 0, 1, 0, 0, lane_index); \
1241  } \
1242  const Operator* MachineOperatorBuilder::Type##ReplaceLane( \
1243  int32_t lane_index) { \
1244  DCHECK(0 <= lane_index && lane_index < lane_count); \
1245  return new (zone_) \
1246  Operator1<int32_t>(IrOpcode::k##Type##ReplaceLane, Operator::kPure, \
1247  "Replace lane", 2, 0, 0, 1, 0, 0, lane_index); \
1248  }
1249 SIMD_LANE_OP_LIST(SIMD_LANE_OPS)
1250 #undef SIMD_LANE_OPS
1251 
1252 #define SIMD_SHIFT_OPS(format, bits) \
1253  const Operator* MachineOperatorBuilder::I##format##Shl(int32_t shift) { \
1254  DCHECK(0 <= shift && shift < bits); \
1255  return new (zone_) \
1256  Operator1<int32_t>(IrOpcode::kI##format##Shl, Operator::kPure, \
1257  "Shift left", 1, 0, 0, 1, 0, 0, shift); \
1258  } \
1259  const Operator* MachineOperatorBuilder::I##format##ShrS(int32_t shift) { \
1260  DCHECK(0 < shift && shift <= bits); \
1261  return new (zone_) \
1262  Operator1<int32_t>(IrOpcode::kI##format##ShrS, Operator::kPure, \
1263  "Arithmetic shift right", 1, 0, 0, 1, 0, 0, shift); \
1264  } \
1265  const Operator* MachineOperatorBuilder::I##format##ShrU(int32_t shift) { \
1266  DCHECK(0 <= shift && shift < bits); \
1267  return new (zone_) \
1268  Operator1<int32_t>(IrOpcode::kI##format##ShrU, Operator::kPure, \
1269  "Shift right", 1, 0, 0, 1, 0, 0, shift); \
1270  }
1271 SIMD_FORMAT_LIST(SIMD_SHIFT_OPS)
1272 #undef SIMD_SHIFT_OPS
1273 
1274 const Operator* MachineOperatorBuilder::S8x16Shuffle(
1275  const uint8_t shuffle[16]) {
1276  uint8_t* array = zone_->NewArray<uint8_t>(16);
1277  memcpy(array, shuffle, 16);
1278  return new (zone_)
1279  Operator1<uint8_t*>(IrOpcode::kS8x16Shuffle, Operator::kPure, "Shuffle",
1280  2, 0, 0, 1, 0, 0, array);
1281 }
1282 
1283 #undef PURE_BINARY_OP_LIST_32
1284 #undef PURE_BINARY_OP_LIST_64
1285 #undef MACHINE_PURE_OP_LIST
1286 #undef PURE_OPTIONAL_OP_LIST
1287 #undef OVERFLOW_OP_LIST
1288 #undef MACHINE_TYPE_LIST
1289 #undef MACHINE_REPRESENTATION_LIST
1290 #undef ATOMIC_TYPE_LIST
1291 #undef ATOMIC_U64_TYPE_LIST
1292 #undef ATOMIC_U32_TYPE_LIST
1293 #undef ATOMIC_REPRESENTATION_LIST
1294 #undef ATOMIC64_REPRESENTATION_LIST
1295 #undef SIMD_LANE_OP_LIST
1296 #undef SIMD_FORMAT_LIST
1297 #undef STACK_SLOT_CACHED_SIZES_ALIGNMENTS_LIST
1298 
1299 } // namespace compiler
1300 } // namespace internal
1301 } // namespace v8
Definition: libplatform.h:13