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 
operator ==(StoreRepresentation lhs,StoreRepresentation rhs)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 
operator !=(StoreRepresentation lhs,StoreRepresentation rhs)21 bool operator!=(StoreRepresentation lhs, StoreRepresentation rhs) {
22   return !(lhs == rhs);
23 }
24 
25 
hash_value(StoreRepresentation rep)26 size_t hash_value(StoreRepresentation rep) {
27   return base::hash_combine(rep.representation(), rep.write_barrier_kind());
28 }
29 
30 
operator <<(std::ostream & os,StoreRepresentation rep)31 std::ostream& operator<<(std::ostream& os, StoreRepresentation rep) {
32   return os << "(" << rep.representation() << " : " << rep.write_barrier_kind()
33             << ")";
34 }
35 
36 
LoadRepresentationOf(Operator const * op)37 LoadRepresentation LoadRepresentationOf(Operator const* op) {
38   DCHECK(IrOpcode::kLoad == op->opcode() ||
39          IrOpcode::kProtectedLoad == op->opcode() ||
40          IrOpcode::kAtomicLoad == op->opcode());
41   return OpParameter<LoadRepresentation>(op);
42 }
43 
44 
StoreRepresentationOf(Operator const * op)45 StoreRepresentation const& StoreRepresentationOf(Operator const* op) {
46   DCHECK_EQ(IrOpcode::kStore, op->opcode());
47   return OpParameter<StoreRepresentation>(op);
48 }
49 
UnalignedLoadRepresentationOf(Operator const * op)50 UnalignedLoadRepresentation UnalignedLoadRepresentationOf(Operator const* op) {
51   DCHECK_EQ(IrOpcode::kUnalignedLoad, op->opcode());
52   return OpParameter<UnalignedLoadRepresentation>(op);
53 }
54 
UnalignedStoreRepresentationOf(Operator const * op)55 UnalignedStoreRepresentation const& UnalignedStoreRepresentationOf(
56     Operator const* op) {
57   DCHECK_EQ(IrOpcode::kUnalignedStore, op->opcode());
58   return OpParameter<UnalignedStoreRepresentation>(op);
59 }
60 
CheckedLoadRepresentationOf(Operator const * op)61 CheckedLoadRepresentation CheckedLoadRepresentationOf(Operator const* op) {
62   DCHECK_EQ(IrOpcode::kCheckedLoad, op->opcode());
63   return OpParameter<CheckedLoadRepresentation>(op);
64 }
65 
66 
CheckedStoreRepresentationOf(Operator const * op)67 CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) {
68   DCHECK_EQ(IrOpcode::kCheckedStore, op->opcode());
69   return OpParameter<CheckedStoreRepresentation>(op);
70 }
71 
StackSlotRepresentationOf(Operator const * op)72 MachineRepresentation StackSlotRepresentationOf(Operator const* op) {
73   DCHECK_EQ(IrOpcode::kStackSlot, op->opcode());
74   return OpParameter<MachineRepresentation>(op);
75 }
76 
AtomicStoreRepresentationOf(Operator const * op)77 MachineRepresentation AtomicStoreRepresentationOf(Operator const* op) {
78   DCHECK_EQ(IrOpcode::kAtomicStore, op->opcode());
79   return OpParameter<MachineRepresentation>(op);
80 }
81 
82 #define PURE_BINARY_OP_LIST_32(V)                                           \
83   V(Word32And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)    \
84   V(Word32Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)     \
85   V(Word32Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)    \
86   V(Word32Shl, Operator::kNoProperties, 2, 0, 1)                            \
87   V(Word32Shr, Operator::kNoProperties, 2, 0, 1)                            \
88   V(Word32Sar, Operator::kNoProperties, 2, 0, 1)                            \
89   V(Word32Ror, Operator::kNoProperties, 2, 0, 1)                            \
90   V(Word32Equal, Operator::kCommutative, 2, 0, 1)                           \
91   V(Int32Add, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)     \
92   V(Int32Sub, Operator::kNoProperties, 2, 0, 1)                             \
93   V(Int32Mul, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)     \
94   V(Int32MulHigh, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
95   V(Int32Div, Operator::kNoProperties, 2, 1, 1)                             \
96   V(Int32Mod, Operator::kNoProperties, 2, 1, 1)                             \
97   V(Int32LessThan, Operator::kNoProperties, 2, 0, 1)                        \
98   V(Int32LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)                 \
99   V(Uint32Div, Operator::kNoProperties, 2, 1, 1)                            \
100   V(Uint32LessThan, Operator::kNoProperties, 2, 0, 1)                       \
101   V(Uint32LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)                \
102   V(Uint32Mod, Operator::kNoProperties, 2, 1, 1)                            \
103   V(Uint32MulHigh, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)
104 
105 #define PURE_BINARY_OP_LIST_64(V)                                        \
106   V(Word64And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
107   V(Word64Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
108   V(Word64Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
109   V(Word64Shl, Operator::kNoProperties, 2, 0, 1)                         \
110   V(Word64Shr, Operator::kNoProperties, 2, 0, 1)                         \
111   V(Word64Sar, Operator::kNoProperties, 2, 0, 1)                         \
112   V(Word64Ror, Operator::kNoProperties, 2, 0, 1)                         \
113   V(Word64Equal, Operator::kCommutative, 2, 0, 1)                        \
114   V(Int64Add, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
115   V(Int64Sub, Operator::kNoProperties, 2, 0, 1)                          \
116   V(Int64Mul, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
117   V(Int64Div, Operator::kNoProperties, 2, 1, 1)                          \
118   V(Int64Mod, Operator::kNoProperties, 2, 1, 1)                          \
119   V(Int64LessThan, Operator::kNoProperties, 2, 0, 1)                     \
120   V(Int64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)              \
121   V(Uint64Div, Operator::kNoProperties, 2, 1, 1)                         \
122   V(Uint64Mod, Operator::kNoProperties, 2, 1, 1)                         \
123   V(Uint64LessThan, Operator::kNoProperties, 2, 0, 1)                    \
124   V(Uint64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)
125 
126 #define PURE_OP_LIST(V)                                                    \
127   PURE_BINARY_OP_LIST_32(V)                                                \
128   PURE_BINARY_OP_LIST_64(V)                                                \
129   V(Word32Clz, Operator::kNoProperties, 1, 0, 1)                           \
130   V(Word64Clz, Operator::kNoProperties, 1, 0, 1)                           \
131   V(BitcastTaggedToWord, Operator::kNoProperties, 1, 0, 1)                 \
132   V(BitcastWordToTagged, Operator::kNoProperties, 1, 0, 1)                 \
133   V(BitcastWordToTaggedSigned, Operator::kNoProperties, 1, 0, 1)           \
134   V(TruncateFloat64ToWord32, Operator::kNoProperties, 1, 0, 1)             \
135   V(ChangeFloat32ToFloat64, Operator::kNoProperties, 1, 0, 1)              \
136   V(ChangeFloat64ToInt32, Operator::kNoProperties, 1, 0, 1)                \
137   V(ChangeFloat64ToUint32, Operator::kNoProperties, 1, 0, 1)               \
138   V(TruncateFloat64ToUint32, Operator::kNoProperties, 1, 0, 1)             \
139   V(TruncateFloat32ToInt32, Operator::kNoProperties, 1, 0, 1)              \
140   V(TruncateFloat32ToUint32, Operator::kNoProperties, 1, 0, 1)             \
141   V(TryTruncateFloat32ToInt64, Operator::kNoProperties, 1, 0, 2)           \
142   V(TryTruncateFloat64ToInt64, Operator::kNoProperties, 1, 0, 2)           \
143   V(TryTruncateFloat32ToUint64, Operator::kNoProperties, 1, 0, 2)          \
144   V(TryTruncateFloat64ToUint64, Operator::kNoProperties, 1, 0, 2)          \
145   V(ChangeInt32ToFloat64, Operator::kNoProperties, 1, 0, 1)                \
146   V(Float64SilenceNaN, Operator::kNoProperties, 1, 0, 1)                   \
147   V(RoundFloat64ToInt32, Operator::kNoProperties, 1, 0, 1)                 \
148   V(RoundInt32ToFloat32, Operator::kNoProperties, 1, 0, 1)                 \
149   V(RoundInt64ToFloat32, Operator::kNoProperties, 1, 0, 1)                 \
150   V(RoundInt64ToFloat64, Operator::kNoProperties, 1, 0, 1)                 \
151   V(RoundUint32ToFloat32, Operator::kNoProperties, 1, 0, 1)                \
152   V(RoundUint64ToFloat32, Operator::kNoProperties, 1, 0, 1)                \
153   V(RoundUint64ToFloat64, Operator::kNoProperties, 1, 0, 1)                \
154   V(ChangeInt32ToInt64, Operator::kNoProperties, 1, 0, 1)                  \
155   V(ChangeUint32ToFloat64, Operator::kNoProperties, 1, 0, 1)               \
156   V(ChangeUint32ToUint64, Operator::kNoProperties, 1, 0, 1)                \
157   V(TruncateFloat64ToFloat32, Operator::kNoProperties, 1, 0, 1)            \
158   V(TruncateInt64ToInt32, Operator::kNoProperties, 1, 0, 1)                \
159   V(BitcastFloat32ToInt32, Operator::kNoProperties, 1, 0, 1)               \
160   V(BitcastFloat64ToInt64, Operator::kNoProperties, 1, 0, 1)               \
161   V(BitcastInt32ToFloat32, Operator::kNoProperties, 1, 0, 1)               \
162   V(BitcastInt64ToFloat64, Operator::kNoProperties, 1, 0, 1)               \
163   V(Float32Abs, Operator::kNoProperties, 1, 0, 1)                          \
164   V(Float32Add, Operator::kCommutative, 2, 0, 1)                           \
165   V(Float32Sub, Operator::kNoProperties, 2, 0, 1)                          \
166   V(Float32Mul, Operator::kCommutative, 2, 0, 1)                           \
167   V(Float32Div, Operator::kNoProperties, 2, 0, 1)                          \
168   V(Float32Neg, Operator::kNoProperties, 1, 0, 1)                          \
169   V(Float32Sqrt, Operator::kNoProperties, 1, 0, 1)                         \
170   V(Float32Max, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
171   V(Float32Min, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
172   V(Float64Abs, Operator::kNoProperties, 1, 0, 1)                          \
173   V(Float64Acos, Operator::kNoProperties, 1, 0, 1)                         \
174   V(Float64Acosh, Operator::kNoProperties, 1, 0, 1)                        \
175   V(Float64Asin, Operator::kNoProperties, 1, 0, 1)                         \
176   V(Float64Asinh, Operator::kNoProperties, 1, 0, 1)                        \
177   V(Float64Atan, Operator::kNoProperties, 1, 0, 1)                         \
178   V(Float64Atan2, Operator::kNoProperties, 2, 0, 1)                        \
179   V(Float64Atanh, Operator::kNoProperties, 1, 0, 1)                        \
180   V(Float64Cbrt, Operator::kNoProperties, 1, 0, 1)                         \
181   V(Float64Cos, Operator::kNoProperties, 1, 0, 1)                          \
182   V(Float64Cosh, Operator::kNoProperties, 1, 0, 1)                         \
183   V(Float64Exp, Operator::kNoProperties, 1, 0, 1)                          \
184   V(Float64Expm1, Operator::kNoProperties, 1, 0, 1)                        \
185   V(Float64Log, Operator::kNoProperties, 1, 0, 1)                          \
186   V(Float64Log1p, Operator::kNoProperties, 1, 0, 1)                        \
187   V(Float64Log2, Operator::kNoProperties, 1, 0, 1)                         \
188   V(Float64Log10, Operator::kNoProperties, 1, 0, 1)                        \
189   V(Float64Max, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
190   V(Float64Min, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
191   V(Float64Neg, Operator::kNoProperties, 1, 0, 1)                          \
192   V(Float64Add, Operator::kCommutative, 2, 0, 1)                           \
193   V(Float64Sub, Operator::kNoProperties, 2, 0, 1)                          \
194   V(Float64Mul, Operator::kCommutative, 2, 0, 1)                           \
195   V(Float64Div, Operator::kNoProperties, 2, 0, 1)                          \
196   V(Float64Mod, Operator::kNoProperties, 2, 0, 1)                          \
197   V(Float64Pow, Operator::kNoProperties, 2, 0, 1)                          \
198   V(Float64Sin, Operator::kNoProperties, 1, 0, 1)                          \
199   V(Float64Sinh, Operator::kNoProperties, 1, 0, 1)                         \
200   V(Float64Sqrt, Operator::kNoProperties, 1, 0, 1)                         \
201   V(Float64Tan, Operator::kNoProperties, 1, 0, 1)                          \
202   V(Float64Tanh, Operator::kNoProperties, 1, 0, 1)                         \
203   V(Float32Equal, Operator::kCommutative, 2, 0, 1)                         \
204   V(Float32LessThan, Operator::kNoProperties, 2, 0, 1)                     \
205   V(Float32LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)              \
206   V(Float64Equal, Operator::kCommutative, 2, 0, 1)                         \
207   V(Float64LessThan, Operator::kNoProperties, 2, 0, 1)                     \
208   V(Float64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)              \
209   V(Float64ExtractLowWord32, Operator::kNoProperties, 1, 0, 1)             \
210   V(Float64ExtractHighWord32, Operator::kNoProperties, 1, 0, 1)            \
211   V(Float64InsertLowWord32, Operator::kNoProperties, 2, 0, 1)              \
212   V(Float64InsertHighWord32, Operator::kNoProperties, 2, 0, 1)             \
213   V(LoadStackPointer, Operator::kNoProperties, 0, 0, 1)                    \
214   V(LoadFramePointer, Operator::kNoProperties, 0, 0, 1)                    \
215   V(LoadParentFramePointer, Operator::kNoProperties, 0, 0, 1)              \
216   V(Int32PairAdd, Operator::kNoProperties, 4, 0, 2)                        \
217   V(Int32PairSub, Operator::kNoProperties, 4, 0, 2)                        \
218   V(Int32PairMul, Operator::kNoProperties, 4, 0, 2)                        \
219   V(Word32PairShl, Operator::kNoProperties, 3, 0, 2)                       \
220   V(Word32PairShr, Operator::kNoProperties, 3, 0, 2)                       \
221   V(Word32PairSar, Operator::kNoProperties, 3, 0, 2)                       \
222   V(CreateFloat32x4, Operator::kNoProperties, 4, 0, 1)                     \
223   V(Float32x4ExtractLane, Operator::kNoProperties, 2, 0, 1)                \
224   V(Float32x4ReplaceLane, Operator::kNoProperties, 3, 0, 1)                \
225   V(Float32x4Abs, Operator::kNoProperties, 1, 0, 1)                        \
226   V(Float32x4Neg, Operator::kNoProperties, 1, 0, 1)                        \
227   V(Float32x4Sqrt, Operator::kNoProperties, 1, 0, 1)                       \
228   V(Float32x4RecipApprox, Operator::kNoProperties, 1, 0, 1)                \
229   V(Float32x4RecipSqrtApprox, Operator::kNoProperties, 1, 0, 1)            \
230   V(Float32x4Add, Operator::kCommutative, 2, 0, 1)                         \
231   V(Float32x4Sub, Operator::kNoProperties, 2, 0, 1)                        \
232   V(Float32x4Mul, Operator::kCommutative, 2, 0, 1)                         \
233   V(Float32x4Div, Operator::kNoProperties, 2, 0, 1)                        \
234   V(Float32x4Min, Operator::kCommutative, 2, 0, 1)                         \
235   V(Float32x4Max, Operator::kCommutative, 2, 0, 1)                         \
236   V(Float32x4MinNum, Operator::kCommutative, 2, 0, 1)                      \
237   V(Float32x4MaxNum, Operator::kCommutative, 2, 0, 1)                      \
238   V(Float32x4Equal, Operator::kCommutative, 2, 0, 1)                       \
239   V(Float32x4NotEqual, Operator::kCommutative, 2, 0, 1)                    \
240   V(Float32x4LessThan, Operator::kNoProperties, 2, 0, 1)                   \
241   V(Float32x4LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)            \
242   V(Float32x4GreaterThan, Operator::kNoProperties, 2, 0, 1)                \
243   V(Float32x4GreaterThanOrEqual, Operator::kNoProperties, 2, 0, 1)         \
244   V(Float32x4Select, Operator::kNoProperties, 3, 0, 1)                     \
245   V(Float32x4Swizzle, Operator::kNoProperties, 5, 0, 1)                    \
246   V(Float32x4Shuffle, Operator::kNoProperties, 6, 0, 1)                    \
247   V(Float32x4FromInt32x4, Operator::kNoProperties, 1, 0, 1)                \
248   V(Float32x4FromUint32x4, Operator::kNoProperties, 1, 0, 1)               \
249   V(CreateInt32x4, Operator::kNoProperties, 4, 0, 1)                       \
250   V(Int32x4ExtractLane, Operator::kNoProperties, 2, 0, 1)                  \
251   V(Int32x4ReplaceLane, Operator::kNoProperties, 3, 0, 1)                  \
252   V(Int32x4Neg, Operator::kNoProperties, 1, 0, 1)                          \
253   V(Int32x4Add, Operator::kCommutative, 2, 0, 1)                           \
254   V(Int32x4Sub, Operator::kNoProperties, 2, 0, 1)                          \
255   V(Int32x4Mul, Operator::kCommutative, 2, 0, 1)                           \
256   V(Int32x4Min, Operator::kCommutative, 2, 0, 1)                           \
257   V(Int32x4Max, Operator::kCommutative, 2, 0, 1)                           \
258   V(Int32x4ShiftLeftByScalar, Operator::kNoProperties, 2, 0, 1)            \
259   V(Int32x4ShiftRightByScalar, Operator::kNoProperties, 2, 0, 1)           \
260   V(Int32x4Equal, Operator::kCommutative, 2, 0, 1)                         \
261   V(Int32x4NotEqual, Operator::kCommutative, 2, 0, 1)                      \
262   V(Int32x4LessThan, Operator::kNoProperties, 2, 0, 1)                     \
263   V(Int32x4LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)              \
264   V(Int32x4GreaterThan, Operator::kNoProperties, 2, 0, 1)                  \
265   V(Int32x4GreaterThanOrEqual, Operator::kNoProperties, 2, 0, 1)           \
266   V(Int32x4Select, Operator::kNoProperties, 3, 0, 1)                       \
267   V(Int32x4Swizzle, Operator::kNoProperties, 5, 0, 1)                      \
268   V(Int32x4Shuffle, Operator::kNoProperties, 6, 0, 1)                      \
269   V(Int32x4FromFloat32x4, Operator::kNoProperties, 1, 0, 1)                \
270   V(Uint32x4Min, Operator::kCommutative, 2, 0, 1)                          \
271   V(Uint32x4Max, Operator::kCommutative, 2, 0, 1)                          \
272   V(Uint32x4ShiftLeftByScalar, Operator::kNoProperties, 2, 0, 1)           \
273   V(Uint32x4ShiftRightByScalar, Operator::kNoProperties, 2, 0, 1)          \
274   V(Uint32x4LessThan, Operator::kNoProperties, 2, 0, 1)                    \
275   V(Uint32x4LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)             \
276   V(Uint32x4GreaterThan, Operator::kNoProperties, 2, 0, 1)                 \
277   V(Uint32x4GreaterThanOrEqual, Operator::kNoProperties, 2, 0, 1)          \
278   V(Uint32x4FromFloat32x4, Operator::kNoProperties, 1, 0, 1)               \
279   V(CreateBool32x4, Operator::kNoProperties, 4, 0, 1)                      \
280   V(Bool32x4ExtractLane, Operator::kNoProperties, 2, 0, 1)                 \
281   V(Bool32x4ReplaceLane, Operator::kNoProperties, 3, 0, 1)                 \
282   V(Bool32x4And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
283   V(Bool32x4Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
284   V(Bool32x4Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
285   V(Bool32x4Not, Operator::kNoProperties, 1, 0, 1)                         \
286   V(Bool32x4AnyTrue, Operator::kNoProperties, 1, 0, 1)                     \
287   V(Bool32x4AllTrue, Operator::kNoProperties, 1, 0, 1)                     \
288   V(Bool32x4Swizzle, Operator::kNoProperties, 5, 0, 1)                     \
289   V(Bool32x4Shuffle, Operator::kNoProperties, 6, 0, 1)                     \
290   V(Bool32x4Equal, Operator::kCommutative, 2, 0, 1)                        \
291   V(Bool32x4NotEqual, Operator::kCommutative, 2, 0, 1)                     \
292   V(CreateInt16x8, Operator::kNoProperties, 8, 0, 1)                       \
293   V(Int16x8ExtractLane, Operator::kNoProperties, 2, 0, 1)                  \
294   V(Int16x8ReplaceLane, Operator::kNoProperties, 3, 0, 1)                  \
295   V(Int16x8Neg, Operator::kNoProperties, 1, 0, 1)                          \
296   V(Int16x8Add, Operator::kCommutative, 2, 0, 1)                           \
297   V(Int16x8AddSaturate, Operator::kCommutative, 2, 0, 1)                   \
298   V(Int16x8Sub, Operator::kNoProperties, 2, 0, 1)                          \
299   V(Int16x8SubSaturate, Operator::kNoProperties, 2, 0, 1)                  \
300   V(Int16x8Mul, Operator::kCommutative, 2, 0, 1)                           \
301   V(Int16x8Min, Operator::kCommutative, 2, 0, 1)                           \
302   V(Int16x8Max, Operator::kCommutative, 2, 0, 1)                           \
303   V(Int16x8ShiftLeftByScalar, Operator::kNoProperties, 2, 0, 1)            \
304   V(Int16x8ShiftRightByScalar, Operator::kNoProperties, 2, 0, 1)           \
305   V(Int16x8Equal, Operator::kCommutative, 2, 0, 1)                         \
306   V(Int16x8NotEqual, Operator::kCommutative, 2, 0, 1)                      \
307   V(Int16x8LessThan, Operator::kNoProperties, 2, 0, 1)                     \
308   V(Int16x8LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)              \
309   V(Int16x8GreaterThan, Operator::kNoProperties, 2, 0, 1)                  \
310   V(Int16x8GreaterThanOrEqual, Operator::kNoProperties, 2, 0, 1)           \
311   V(Int16x8Select, Operator::kNoProperties, 3, 0, 1)                       \
312   V(Int16x8Swizzle, Operator::kNoProperties, 9, 0, 1)                      \
313   V(Int16x8Shuffle, Operator::kNoProperties, 10, 0, 1)                     \
314   V(Uint16x8AddSaturate, Operator::kCommutative, 2, 0, 1)                  \
315   V(Uint16x8SubSaturate, Operator::kNoProperties, 2, 0, 1)                 \
316   V(Uint16x8Min, Operator::kCommutative, 2, 0, 1)                          \
317   V(Uint16x8Max, Operator::kCommutative, 2, 0, 1)                          \
318   V(Uint16x8ShiftLeftByScalar, Operator::kNoProperties, 2, 0, 1)           \
319   V(Uint16x8ShiftRightByScalar, Operator::kNoProperties, 2, 0, 1)          \
320   V(Uint16x8LessThan, Operator::kNoProperties, 2, 0, 1)                    \
321   V(Uint16x8LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)             \
322   V(Uint16x8GreaterThan, Operator::kNoProperties, 2, 0, 1)                 \
323   V(Uint16x8GreaterThanOrEqual, Operator::kNoProperties, 2, 0, 1)          \
324   V(CreateBool16x8, Operator::kNoProperties, 8, 0, 1)                      \
325   V(Bool16x8ExtractLane, Operator::kNoProperties, 2, 0, 1)                 \
326   V(Bool16x8ReplaceLane, Operator::kNoProperties, 3, 0, 1)                 \
327   V(Bool16x8And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
328   V(Bool16x8Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
329   V(Bool16x8Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
330   V(Bool16x8Not, Operator::kNoProperties, 1, 0, 1)                         \
331   V(Bool16x8AnyTrue, Operator::kNoProperties, 1, 0, 1)                     \
332   V(Bool16x8AllTrue, Operator::kNoProperties, 1, 0, 1)                     \
333   V(Bool16x8Swizzle, Operator::kNoProperties, 9, 0, 1)                     \
334   V(Bool16x8Shuffle, Operator::kNoProperties, 10, 0, 1)                    \
335   V(Bool16x8Equal, Operator::kCommutative, 2, 0, 1)                        \
336   V(Bool16x8NotEqual, Operator::kCommutative, 2, 0, 1)                     \
337   V(CreateInt8x16, Operator::kNoProperties, 16, 0, 1)                      \
338   V(Int8x16ExtractLane, Operator::kNoProperties, 2, 0, 1)                  \
339   V(Int8x16ReplaceLane, Operator::kNoProperties, 3, 0, 1)                  \
340   V(Int8x16Neg, Operator::kNoProperties, 1, 0, 1)                          \
341   V(Int8x16Add, Operator::kCommutative, 2, 0, 1)                           \
342   V(Int8x16AddSaturate, Operator::kCommutative, 2, 0, 1)                   \
343   V(Int8x16Sub, Operator::kNoProperties, 2, 0, 1)                          \
344   V(Int8x16SubSaturate, Operator::kNoProperties, 2, 0, 1)                  \
345   V(Int8x16Mul, Operator::kCommutative, 2, 0, 1)                           \
346   V(Int8x16Min, Operator::kCommutative, 2, 0, 1)                           \
347   V(Int8x16Max, Operator::kCommutative, 2, 0, 1)                           \
348   V(Int8x16ShiftLeftByScalar, Operator::kNoProperties, 2, 0, 1)            \
349   V(Int8x16ShiftRightByScalar, Operator::kNoProperties, 2, 0, 1)           \
350   V(Int8x16Equal, Operator::kCommutative, 2, 0, 1)                         \
351   V(Int8x16NotEqual, Operator::kCommutative, 2, 0, 1)                      \
352   V(Int8x16LessThan, Operator::kNoProperties, 2, 0, 1)                     \
353   V(Int8x16LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)              \
354   V(Int8x16GreaterThan, Operator::kNoProperties, 2, 0, 1)                  \
355   V(Int8x16GreaterThanOrEqual, Operator::kNoProperties, 2, 0, 1)           \
356   V(Int8x16Select, Operator::kNoProperties, 3, 0, 1)                       \
357   V(Int8x16Swizzle, Operator::kNoProperties, 17, 0, 1)                     \
358   V(Int8x16Shuffle, Operator::kNoProperties, 18, 0, 1)                     \
359   V(Uint8x16AddSaturate, Operator::kCommutative, 2, 0, 1)                  \
360   V(Uint8x16SubSaturate, Operator::kNoProperties, 2, 0, 1)                 \
361   V(Uint8x16Min, Operator::kCommutative, 2, 0, 1)                          \
362   V(Uint8x16Max, Operator::kCommutative, 2, 0, 1)                          \
363   V(Uint8x16ShiftLeftByScalar, Operator::kNoProperties, 2, 0, 1)           \
364   V(Uint8x16ShiftRightByScalar, Operator::kNoProperties, 2, 0, 1)          \
365   V(Uint8x16LessThan, Operator::kNoProperties, 2, 0, 1)                    \
366   V(Uint8x16LessThanOrEqual, Operator::kNoProperties, 2, 0, 1)             \
367   V(Uint8x16GreaterThan, Operator::kNoProperties, 2, 0, 1)                 \
368   V(Uint8x16GreaterThanOrEqual, Operator::kNoProperties, 2, 0, 1)          \
369   V(CreateBool8x16, Operator::kNoProperties, 16, 0, 1)                     \
370   V(Bool8x16ExtractLane, Operator::kNoProperties, 2, 0, 1)                 \
371   V(Bool8x16ReplaceLane, Operator::kNoProperties, 3, 0, 1)                 \
372   V(Bool8x16And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
373   V(Bool8x16Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
374   V(Bool8x16Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
375   V(Bool8x16Not, Operator::kNoProperties, 1, 0, 1)                         \
376   V(Bool8x16AnyTrue, Operator::kNoProperties, 1, 0, 1)                     \
377   V(Bool8x16AllTrue, Operator::kNoProperties, 1, 0, 1)                     \
378   V(Bool8x16Swizzle, Operator::kNoProperties, 17, 0, 1)                    \
379   V(Bool8x16Shuffle, Operator::kNoProperties, 18, 0, 1)                    \
380   V(Bool8x16Equal, Operator::kCommutative, 2, 0, 1)                        \
381   V(Bool8x16NotEqual, Operator::kCommutative, 2, 0, 1)                     \
382   V(Simd128Load, Operator::kNoProperties, 2, 0, 1)                         \
383   V(Simd128Load1, Operator::kNoProperties, 2, 0, 1)                        \
384   V(Simd128Load2, Operator::kNoProperties, 2, 0, 1)                        \
385   V(Simd128Load3, Operator::kNoProperties, 2, 0, 1)                        \
386   V(Simd128Store, Operator::kNoProperties, 3, 0, 1)                        \
387   V(Simd128Store1, Operator::kNoProperties, 3, 0, 1)                       \
388   V(Simd128Store2, Operator::kNoProperties, 3, 0, 1)                       \
389   V(Simd128Store3, Operator::kNoProperties, 3, 0, 1)                       \
390   V(Simd128And, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
391   V(Simd128Or, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)   \
392   V(Simd128Xor, Operator::kAssociative | Operator::kCommutative, 2, 0, 1)  \
393   V(Simd128Not, Operator::kNoProperties, 1, 0, 1)
394 
395 #define PURE_OPTIONAL_OP_LIST(V)                            \
396   V(Word32Ctz, Operator::kNoProperties, 1, 0, 1)            \
397   V(Word64Ctz, Operator::kNoProperties, 1, 0, 1)            \
398   V(Word32ReverseBits, Operator::kNoProperties, 1, 0, 1)    \
399   V(Word64ReverseBits, Operator::kNoProperties, 1, 0, 1)    \
400   V(Word32ReverseBytes, Operator::kNoProperties, 1, 0, 1)   \
401   V(Word64ReverseBytes, Operator::kNoProperties, 1, 0, 1)   \
402   V(Word32Popcnt, Operator::kNoProperties, 1, 0, 1)         \
403   V(Word64Popcnt, Operator::kNoProperties, 1, 0, 1)         \
404   V(Float32RoundDown, Operator::kNoProperties, 1, 0, 1)     \
405   V(Float64RoundDown, Operator::kNoProperties, 1, 0, 1)     \
406   V(Float32RoundUp, Operator::kNoProperties, 1, 0, 1)       \
407   V(Float64RoundUp, Operator::kNoProperties, 1, 0, 1)       \
408   V(Float32RoundTruncate, Operator::kNoProperties, 1, 0, 1) \
409   V(Float64RoundTruncate, Operator::kNoProperties, 1, 0, 1) \
410   V(Float64RoundTiesAway, Operator::kNoProperties, 1, 0, 1) \
411   V(Float32RoundTiesEven, Operator::kNoProperties, 1, 0, 1) \
412   V(Float64RoundTiesEven, Operator::kNoProperties, 1, 0, 1)
413 
414 #define OVERFLOW_OP_LIST(V)                                                \
415   V(Int32AddWithOverflow, Operator::kAssociative | Operator::kCommutative) \
416   V(Int32SubWithOverflow, Operator::kNoProperties)                         \
417   V(Int32MulWithOverflow, Operator::kAssociative | Operator::kCommutative) \
418   V(Int64AddWithOverflow, Operator::kAssociative | Operator::kCommutative) \
419   V(Int64SubWithOverflow, Operator::kNoProperties)
420 
421 #define MACHINE_TYPE_LIST(V) \
422   V(Float32)                 \
423   V(Float64)                 \
424   V(Simd128)                 \
425   V(Int8)                    \
426   V(Uint8)                   \
427   V(Int16)                   \
428   V(Uint16)                  \
429   V(Int32)                   \
430   V(Uint32)                  \
431   V(Int64)                   \
432   V(Uint64)                  \
433   V(Pointer)                 \
434   V(TaggedSigned)            \
435   V(TaggedPointer)           \
436   V(AnyTagged)
437 
438 #define MACHINE_REPRESENTATION_LIST(V) \
439   V(kFloat32)                          \
440   V(kFloat64)                          \
441   V(kSimd128)                          \
442   V(kWord8)                            \
443   V(kWord16)                           \
444   V(kWord32)                           \
445   V(kWord64)                           \
446   V(kTaggedSigned)                     \
447   V(kTaggedPointer)                    \
448   V(kTagged)
449 
450 #define ATOMIC_TYPE_LIST(V) \
451   V(Int8)                   \
452   V(Uint8)                  \
453   V(Int16)                  \
454   V(Uint16)                 \
455   V(Int32)                  \
456   V(Uint32)
457 
458 #define ATOMIC_REPRESENTATION_LIST(V) \
459   V(kWord8)                           \
460   V(kWord16)                          \
461   V(kWord32)
462 
463 struct MachineOperatorGlobalCache {
464 #define PURE(Name, properties, value_input_count, control_input_count,         \
465              output_count)                                                     \
466   struct Name##Operator final : public Operator {                              \
467     Name##Operator()                                                           \
468         : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name,     \
469                    value_input_count, 0, control_input_count, output_count, 0, \
470                    0) {}                                                       \
471   };                                                                           \
472   Name##Operator k##Name;
473   PURE_OP_LIST(PURE)
474   PURE_OPTIONAL_OP_LIST(PURE)
475 #undef PURE
476 
477 #define OVERFLOW_OP(Name, properties)                                        \
478   struct Name##Operator final : public Operator {                            \
479     Name##Operator()                                                         \
480         : Operator(IrOpcode::k##Name,                                        \
481                    Operator::kEliminatable | Operator::kNoRead | properties, \
482                    #Name, 2, 0, 1, 2, 0, 0) {}                               \
483   };                                                                         \
484   Name##Operator k##Name;
485   OVERFLOW_OP_LIST(OVERFLOW_OP)
486 #undef OVERFLOW_OP
487 
488 #define LOAD(Type)                                                           \
489   struct Load##Type##Operator final : public Operator1<LoadRepresentation> { \
490     Load##Type##Operator()                                                   \
491         : Operator1<LoadRepresentation>(                                     \
492               IrOpcode::kLoad,                                               \
493               Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite,  \
494               "Load", 2, 1, 1, 1, 1, 0, MachineType::Type()) {}              \
495   };                                                                         \
496   struct UnalignedLoad##Type##Operator final                                 \
497       : public Operator1<UnalignedLoadRepresentation> {                      \
498     UnalignedLoad##Type##Operator()                                          \
499         : Operator1<UnalignedLoadRepresentation>(                            \
500               IrOpcode::kUnalignedLoad,                                      \
501               Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite,  \
502               "UnalignedLoad", 2, 1, 1, 1, 1, 0, MachineType::Type()) {}     \
503   };                                                                         \
504   struct CheckedLoad##Type##Operator final                                   \
505       : public Operator1<CheckedLoadRepresentation> {                        \
506     CheckedLoad##Type##Operator()                                            \
507         : Operator1<CheckedLoadRepresentation>(                              \
508               IrOpcode::kCheckedLoad,                                        \
509               Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite,  \
510               "CheckedLoad", 3, 1, 1, 1, 1, 0, MachineType::Type()) {}       \
511   };                                                                         \
512   struct ProtectedLoad##Type##Operator final                                 \
513       : public Operator1<ProtectedLoadRepresentation> {                      \
514     ProtectedLoad##Type##Operator()                                          \
515         : Operator1<ProtectedLoadRepresentation>(                            \
516               IrOpcode::kProtectedLoad,                                      \
517               Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite,  \
518               "ProtectedLoad", 4, 1, 1, 1, 1, 0, MachineType::Type()) {}     \
519   };                                                                         \
520   Load##Type##Operator kLoad##Type;                                          \
521   UnalignedLoad##Type##Operator kUnalignedLoad##Type;                        \
522   CheckedLoad##Type##Operator kCheckedLoad##Type;                            \
523   ProtectedLoad##Type##Operator kProtectedLoad##Type;
524   MACHINE_TYPE_LIST(LOAD)
525 #undef LOAD
526 
527 #define STACKSLOT(Type)                                                      \
528   struct StackSlot##Type##Operator final                                     \
529       : public Operator1<MachineRepresentation> {                            \
530     StackSlot##Type##Operator()                                              \
531         : Operator1<MachineRepresentation>(                                  \
532               IrOpcode::kStackSlot, Operator::kNoDeopt | Operator::kNoThrow, \
533               "StackSlot", 0, 0, 0, 1, 0, 0,                                 \
534               MachineType::Type().representation()) {}                       \
535   };                                                                         \
536   StackSlot##Type##Operator kStackSlot##Type;
537   MACHINE_TYPE_LIST(STACKSLOT)
538 #undef STACKSLOT
539 
540 #define STORE(Type)                                                            \
541   struct Store##Type##Operator : public Operator1<StoreRepresentation> {       \
542     explicit Store##Type##Operator(WriteBarrierKind write_barrier_kind)        \
543         : Operator1<StoreRepresentation>(                                      \
544               IrOpcode::kStore,                                                \
545               Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow,     \
546               "Store", 3, 1, 1, 0, 1, 0,                                       \
547               StoreRepresentation(MachineRepresentation::Type,                 \
548                                   write_barrier_kind)) {}                      \
549   };                                                                           \
550   struct Store##Type##NoWriteBarrier##Operator final                           \
551       : public Store##Type##Operator {                                         \
552     Store##Type##NoWriteBarrier##Operator()                                    \
553         : Store##Type##Operator(kNoWriteBarrier) {}                            \
554   };                                                                           \
555   struct Store##Type##MapWriteBarrier##Operator final                          \
556       : public Store##Type##Operator {                                         \
557     Store##Type##MapWriteBarrier##Operator()                                   \
558         : Store##Type##Operator(kMapWriteBarrier) {}                           \
559   };                                                                           \
560   struct Store##Type##PointerWriteBarrier##Operator final                      \
561       : public Store##Type##Operator {                                         \
562     Store##Type##PointerWriteBarrier##Operator()                               \
563         : Store##Type##Operator(kPointerWriteBarrier) {}                       \
564   };                                                                           \
565   struct Store##Type##FullWriteBarrier##Operator final                         \
566       : public Store##Type##Operator {                                         \
567     Store##Type##FullWriteBarrier##Operator()                                  \
568         : Store##Type##Operator(kFullWriteBarrier) {}                          \
569   };                                                                           \
570   struct UnalignedStore##Type##Operator final                                  \
571       : public Operator1<UnalignedStoreRepresentation> {                       \
572     UnalignedStore##Type##Operator()                                           \
573         : Operator1<UnalignedStoreRepresentation>(                             \
574               IrOpcode::kUnalignedStore,                                       \
575               Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow,     \
576               "UnalignedStore", 3, 1, 1, 0, 1, 0,                              \
577               MachineRepresentation::Type) {}                                  \
578   };                                                                           \
579   struct CheckedStore##Type##Operator final                                    \
580       : public Operator1<CheckedStoreRepresentation> {                         \
581     CheckedStore##Type##Operator()                                             \
582         : Operator1<CheckedStoreRepresentation>(                               \
583               IrOpcode::kCheckedStore,                                         \
584               Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow,     \
585               "CheckedStore", 4, 1, 1, 0, 1, 0, MachineRepresentation::Type) { \
586     }                                                                          \
587   };                                                                           \
588   Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier;          \
589   Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier;        \
590   Store##Type##PointerWriteBarrier##Operator                                   \
591       kStore##Type##PointerWriteBarrier;                                       \
592   Store##Type##FullWriteBarrier##Operator kStore##Type##FullWriteBarrier;      \
593   UnalignedStore##Type##Operator kUnalignedStore##Type;                        \
594   CheckedStore##Type##Operator kCheckedStore##Type;
595   MACHINE_REPRESENTATION_LIST(STORE)
596 #undef STORE
597 
598 #define ATOMIC_LOAD(Type)                                                   \
599   struct AtomicLoad##Type##Operator final                                   \
600       : public Operator1<LoadRepresentation> {                              \
601     AtomicLoad##Type##Operator()                                            \
602         : Operator1<LoadRepresentation>(                                    \
603               IrOpcode::kAtomicLoad,                                        \
604               Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \
605               "AtomicLoad", 2, 1, 1, 1, 1, 0, MachineType::Type()) {}       \
606   };                                                                        \
607   AtomicLoad##Type##Operator kAtomicLoad##Type;
608   ATOMIC_TYPE_LIST(ATOMIC_LOAD)
609 #undef ATOMIC_LOAD
610 
611 #define ATOMIC_STORE(Type)                                                     \
612   struct AtomicStore##Type##Operator                                           \
613       : public Operator1<MachineRepresentation> {                              \
614     AtomicStore##Type##Operator()                                              \
615         : Operator1<MachineRepresentation>(                                    \
616               IrOpcode::kAtomicStore,                                          \
617               Operator::kNoDeopt | Operator::kNoRead | Operator::kNoThrow,     \
618               "AtomicStore", 3, 1, 1, 0, 1, 0, MachineRepresentation::Type) {} \
619   };                                                                           \
620   AtomicStore##Type##Operator kAtomicStore##Type;
621   ATOMIC_REPRESENTATION_LIST(ATOMIC_STORE)
622 #undef STORE
623 
624   struct DebugBreakOperator : public Operator {
DebugBreakOperatorv8::internal::compiler::MachineOperatorGlobalCache::DebugBreakOperator625     DebugBreakOperator()
626         : Operator(IrOpcode::kDebugBreak, Operator::kNoThrow, "DebugBreak", 0,
627                    0, 0, 0, 0, 0) {}
628   };
629   DebugBreakOperator kDebugBreak;
630 
631   struct UnsafePointerAddOperator final : public Operator {
UnsafePointerAddOperatorv8::internal::compiler::MachineOperatorGlobalCache::UnsafePointerAddOperator632     UnsafePointerAddOperator()
633         : Operator(IrOpcode::kUnsafePointerAdd, Operator::kKontrol,
634                    "UnsafePointerAdd", 2, 1, 1, 1, 1, 0) {}
635   };
636   UnsafePointerAddOperator kUnsafePointerAdd;
637 };
638 
639 struct CommentOperator : public Operator1<const char*> {
CommentOperatorv8::internal::compiler::CommentOperator640   explicit CommentOperator(const char* msg)
641       : Operator1<const char*>(IrOpcode::kComment, Operator::kNoThrow,
642                                "Comment", 0, 0, 0, 0, 0, 0, msg) {}
643 };
644 
645 static base::LazyInstance<MachineOperatorGlobalCache>::type kCache =
646     LAZY_INSTANCE_INITIALIZER;
647 
MachineOperatorBuilder(Zone * zone,MachineRepresentation word,Flags flags,AlignmentRequirements alignmentRequirements)648 MachineOperatorBuilder::MachineOperatorBuilder(
649     Zone* zone, MachineRepresentation word, Flags flags,
650     AlignmentRequirements alignmentRequirements)
651     : zone_(zone),
652       cache_(kCache.Get()),
653       word_(word),
654       flags_(flags),
655       alignment_requirements_(alignmentRequirements) {
656   DCHECK(word == MachineRepresentation::kWord32 ||
657          word == MachineRepresentation::kWord64);
658 }
659 
UnalignedLoad(UnalignedLoadRepresentation rep)660 const Operator* MachineOperatorBuilder::UnalignedLoad(
661     UnalignedLoadRepresentation rep) {
662 #define LOAD(Type)                       \
663   if (rep == MachineType::Type()) {      \
664     return &cache_.kUnalignedLoad##Type; \
665   }
666   MACHINE_TYPE_LIST(LOAD)
667 #undef LOAD
668   UNREACHABLE();
669   return nullptr;
670 }
671 
UnalignedStore(UnalignedStoreRepresentation rep)672 const Operator* MachineOperatorBuilder::UnalignedStore(
673     UnalignedStoreRepresentation rep) {
674   switch (rep) {
675 #define STORE(kRep)                 \
676   case MachineRepresentation::kRep: \
677     return &cache_.kUnalignedStore##kRep;
678     MACHINE_REPRESENTATION_LIST(STORE)
679 #undef STORE
680     case MachineRepresentation::kBit:
681     case MachineRepresentation::kNone:
682       break;
683   }
684   UNREACHABLE();
685   return nullptr;
686 }
687 
688 #define PURE(Name, properties, value_input_count, control_input_count, \
689              output_count)                                             \
690   const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; }
691 PURE_OP_LIST(PURE)
692 #undef PURE
693 
694 #define PURE(Name, properties, value_input_count, control_input_count, \
695              output_count)                                             \
696   const OptionalOperator MachineOperatorBuilder::Name() {              \
697     return OptionalOperator(flags_ & k##Name, &cache_.k##Name);        \
698   }
PURE_OPTIONAL_OP_LIST(PURE)699 PURE_OPTIONAL_OP_LIST(PURE)
700 #undef PURE
701 
702 #define OVERFLOW_OP(Name, properties) \
703   const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; }
704 OVERFLOW_OP_LIST(OVERFLOW_OP)
705 #undef OVERFLOW_OP
706 
707 const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) {
708 #define LOAD(Type)                  \
709   if (rep == MachineType::Type()) { \
710     return &cache_.kLoad##Type;     \
711   }
712     MACHINE_TYPE_LIST(LOAD)
713 #undef LOAD
714   UNREACHABLE();
715   return nullptr;
716 }
717 
ProtectedLoad(LoadRepresentation rep)718 const Operator* MachineOperatorBuilder::ProtectedLoad(LoadRepresentation rep) {
719 #define LOAD(Type)                       \
720   if (rep == MachineType::Type()) {      \
721     return &cache_.kProtectedLoad##Type; \
722   }
723   MACHINE_TYPE_LIST(LOAD)
724 #undef LOAD
725   UNREACHABLE();
726   return nullptr;
727 }
728 
StackSlot(MachineRepresentation rep)729 const Operator* MachineOperatorBuilder::StackSlot(MachineRepresentation rep) {
730 #define STACKSLOT(Type)                              \
731   if (rep == MachineType::Type().representation()) { \
732     return &cache_.kStackSlot##Type;                 \
733   }
734   MACHINE_TYPE_LIST(STACKSLOT)
735 #undef STACKSLOT
736   UNREACHABLE();
737   return nullptr;
738 }
739 
Store(StoreRepresentation store_rep)740 const Operator* MachineOperatorBuilder::Store(StoreRepresentation store_rep) {
741   switch (store_rep.representation()) {
742 #define STORE(kRep)                                         \
743   case MachineRepresentation::kRep:                         \
744     switch (store_rep.write_barrier_kind()) {               \
745       case kNoWriteBarrier:                                 \
746         return &cache_.k##Store##kRep##NoWriteBarrier;      \
747       case kMapWriteBarrier:                                \
748         return &cache_.k##Store##kRep##MapWriteBarrier;     \
749       case kPointerWriteBarrier:                            \
750         return &cache_.k##Store##kRep##PointerWriteBarrier; \
751       case kFullWriteBarrier:                               \
752         return &cache_.k##Store##kRep##FullWriteBarrier;    \
753     }                                                       \
754     break;
755     MACHINE_REPRESENTATION_LIST(STORE)
756 #undef STORE
757     case MachineRepresentation::kBit:
758     case MachineRepresentation::kNone:
759       break;
760   }
761   UNREACHABLE();
762   return nullptr;
763 }
764 
UnsafePointerAdd()765 const Operator* MachineOperatorBuilder::UnsafePointerAdd() {
766   return &cache_.kUnsafePointerAdd;
767 }
768 
DebugBreak()769 const Operator* MachineOperatorBuilder::DebugBreak() {
770   return &cache_.kDebugBreak;
771 }
772 
Comment(const char * msg)773 const Operator* MachineOperatorBuilder::Comment(const char* msg) {
774   return new (zone_) CommentOperator(msg);
775 }
776 
CheckedLoad(CheckedLoadRepresentation rep)777 const Operator* MachineOperatorBuilder::CheckedLoad(
778     CheckedLoadRepresentation rep) {
779 #define LOAD(Type)                     \
780   if (rep == MachineType::Type()) {    \
781     return &cache_.kCheckedLoad##Type; \
782   }
783     MACHINE_TYPE_LIST(LOAD)
784 #undef LOAD
785   UNREACHABLE();
786   return nullptr;
787 }
788 
789 
CheckedStore(CheckedStoreRepresentation rep)790 const Operator* MachineOperatorBuilder::CheckedStore(
791     CheckedStoreRepresentation rep) {
792   switch (rep) {
793 #define STORE(kRep)                 \
794   case MachineRepresentation::kRep: \
795     return &cache_.kCheckedStore##kRep;
796     MACHINE_REPRESENTATION_LIST(STORE)
797 #undef STORE
798     case MachineRepresentation::kBit:
799     case MachineRepresentation::kNone:
800       break;
801   }
802   UNREACHABLE();
803   return nullptr;
804 }
805 
AtomicLoad(LoadRepresentation rep)806 const Operator* MachineOperatorBuilder::AtomicLoad(LoadRepresentation rep) {
807 #define LOAD(Type)                    \
808   if (rep == MachineType::Type()) {   \
809     return &cache_.kAtomicLoad##Type; \
810   }
811   ATOMIC_TYPE_LIST(LOAD)
812 #undef LOAD
813   UNREACHABLE();
814   return nullptr;
815 }
816 
AtomicStore(MachineRepresentation rep)817 const Operator* MachineOperatorBuilder::AtomicStore(MachineRepresentation rep) {
818 #define STORE(kRep)                         \
819   if (rep == MachineRepresentation::kRep) { \
820     return &cache_.kAtomicStore##kRep;      \
821   }
822   ATOMIC_REPRESENTATION_LIST(STORE)
823 #undef STORE
824   UNREACHABLE();
825   return nullptr;
826 }
827 
828 }  // namespace compiler
829 }  // namespace internal
830 }  // namespace v8
831