1 // Copyright 2013 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 #ifndef V8_COMPILER_OPCODES_H_
6 #define V8_COMPILER_OPCODES_H_
7 
8 #include <iosfwd>
9 
10 #include "src/globals.h"
11 
12 // Opcodes for control operators.
13 #define CONTROL_OP_LIST(V) \
14   V(Start)                 \
15   V(Loop)                  \
16   V(Branch)                \
17   V(Switch)                \
18   V(IfTrue)                \
19   V(IfFalse)               \
20   V(IfSuccess)             \
21   V(IfException)           \
22   V(IfValue)               \
23   V(IfDefault)             \
24   V(Merge)                 \
25   V(Deoptimize)            \
26   V(DeoptimizeIf)          \
27   V(DeoptimizeUnless)      \
28   V(Return)                \
29   V(TailCall)              \
30   V(Terminate)             \
31   V(OsrNormalEntry)        \
32   V(OsrLoopEntry)          \
33   V(Throw)                 \
34   V(End)
35 
36 // Opcodes for constant operators.
37 #define CONSTANT_OP_LIST(V)   \
38   V(Int32Constant)            \
39   V(Int64Constant)            \
40   V(Float32Constant)          \
41   V(Float64Constant)          \
42   V(ExternalConstant)         \
43   V(NumberConstant)           \
44   V(PointerConstant)          \
45   V(HeapConstant)             \
46   V(RelocatableInt32Constant) \
47   V(RelocatableInt64Constant)
48 
49 #define INNER_OP_LIST(V)  \
50   V(Select)               \
51   V(Phi)                  \
52   V(EffectPhi)            \
53   V(InductionVariablePhi) \
54   V(Checkpoint)           \
55   V(BeginRegion)          \
56   V(FinishRegion)         \
57   V(FrameState)           \
58   V(StateValues)          \
59   V(TypedStateValues)     \
60   V(ObjectState)          \
61   V(TypedObjectState)     \
62   V(Call)                 \
63   V(Parameter)            \
64   V(OsrValue)             \
65   V(OsrGuard)             \
66   V(LoopExit)             \
67   V(LoopExitValue)        \
68   V(LoopExitEffect)       \
69   V(Projection)           \
70   V(Retain)               \
71   V(TypeGuard)
72 
73 #define COMMON_OP_LIST(V) \
74   CONSTANT_OP_LIST(V)     \
75   INNER_OP_LIST(V)        \
76   V(Dead)
77 
78 // Opcodes for JavaScript operators.
79 #define JS_COMPARE_BINOP_LIST(V) \
80   V(JSEqual)                     \
81   V(JSNotEqual)                  \
82   V(JSStrictEqual)               \
83   V(JSStrictNotEqual)            \
84   V(JSLessThan)                  \
85   V(JSGreaterThan)               \
86   V(JSLessThanOrEqual)           \
87   V(JSGreaterThanOrEqual)
88 
89 #define JS_BITWISE_BINOP_LIST(V) \
90   V(JSBitwiseOr)                 \
91   V(JSBitwiseXor)                \
92   V(JSBitwiseAnd)                \
93   V(JSShiftLeft)                 \
94   V(JSShiftRight)                \
95   V(JSShiftRightLogical)
96 
97 #define JS_ARITH_BINOP_LIST(V) \
98   V(JSAdd)                     \
99   V(JSSubtract)                \
100   V(JSMultiply)                \
101   V(JSDivide)                  \
102   V(JSModulus)
103 
104 #define JS_SIMPLE_BINOP_LIST(V) \
105   JS_COMPARE_BINOP_LIST(V)      \
106   JS_BITWISE_BINOP_LIST(V)      \
107   JS_ARITH_BINOP_LIST(V)
108 
109 #define JS_CONVERSION_UNOP_LIST(V) \
110   V(JSToBoolean)                   \
111   V(JSToInteger)                   \
112   V(JSToLength)                    \
113   V(JSToName)                      \
114   V(JSToNumber)                    \
115   V(JSToObject)                    \
116   V(JSToString)
117 
118 #define JS_OTHER_UNOP_LIST(V) \
119   V(JSTypeOf)
120 
121 #define JS_SIMPLE_UNOP_LIST(V) \
122   JS_CONVERSION_UNOP_LIST(V)   \
123   JS_OTHER_UNOP_LIST(V)
124 
125 #define JS_OBJECT_OP_LIST(V)  \
126   V(JSCreate)                 \
127   V(JSCreateArguments)        \
128   V(JSCreateArray)            \
129   V(JSCreateClosure)          \
130   V(JSCreateIterResultObject) \
131   V(JSCreateKeyValueArray)    \
132   V(JSCreateLiteralArray)     \
133   V(JSCreateLiteralObject)    \
134   V(JSCreateLiteralRegExp)    \
135   V(JSLoadProperty)           \
136   V(JSLoadNamed)              \
137   V(JSLoadGlobal)             \
138   V(JSStoreProperty)          \
139   V(JSStoreNamed)             \
140   V(JSStoreGlobal)            \
141   V(JSDeleteProperty)         \
142   V(JSHasProperty)            \
143   V(JSInstanceOf)             \
144   V(JSOrdinaryHasInstance)
145 
146 #define JS_CONTEXT_OP_LIST(V) \
147   V(JSLoadContext)            \
148   V(JSStoreContext)           \
149   V(JSCreateFunctionContext)  \
150   V(JSCreateCatchContext)     \
151   V(JSCreateWithContext)      \
152   V(JSCreateBlockContext)     \
153   V(JSCreateScriptContext)
154 
155 #define JS_OTHER_OP_LIST(V)         \
156   V(JSCallConstruct)                \
157   V(JSCallFunction)                 \
158   V(JSCallRuntime)                  \
159   V(JSConvertReceiver)              \
160   V(JSForInNext)                    \
161   V(JSForInPrepare)                 \
162   V(JSLoadMessage)                  \
163   V(JSStoreMessage)                 \
164   V(JSLoadModule)                   \
165   V(JSStoreModule)                  \
166   V(JSGeneratorStore)               \
167   V(JSGeneratorRestoreContinuation) \
168   V(JSGeneratorRestoreRegister)     \
169   V(JSStackCheck)
170 
171 #define JS_OP_LIST(V)     \
172   JS_SIMPLE_BINOP_LIST(V) \
173   JS_SIMPLE_UNOP_LIST(V)  \
174   JS_OBJECT_OP_LIST(V)    \
175   JS_CONTEXT_OP_LIST(V)   \
176   JS_OTHER_OP_LIST(V)
177 
178 // Opcodes for VirtuaMachine-level operators.
179 #define SIMPLIFIED_CHANGE_OP_LIST(V) \
180   V(ChangeTaggedSignedToInt32)       \
181   V(ChangeTaggedToInt32)             \
182   V(ChangeTaggedToUint32)            \
183   V(ChangeTaggedToFloat64)           \
184   V(ChangeInt31ToTaggedSigned)       \
185   V(ChangeInt32ToTagged)             \
186   V(ChangeUint32ToTagged)            \
187   V(ChangeFloat64ToTagged)           \
188   V(ChangeFloat64ToTaggedPointer)    \
189   V(ChangeTaggedToBit)               \
190   V(ChangeBitToTagged)               \
191   V(TruncateTaggedToWord32)          \
192   V(TruncateTaggedToFloat64)         \
193   V(TruncateTaggedToBit)
194 
195 #define SIMPLIFIED_CHECKED_OP_LIST(V) \
196   V(CheckedInt32Add)                  \
197   V(CheckedInt32Sub)                  \
198   V(CheckedInt32Div)                  \
199   V(CheckedInt32Mod)                  \
200   V(CheckedUint32Div)                 \
201   V(CheckedUint32Mod)                 \
202   V(CheckedInt32Mul)                  \
203   V(CheckedInt32ToTaggedSigned)       \
204   V(CheckedUint32ToInt32)             \
205   V(CheckedUint32ToTaggedSigned)      \
206   V(CheckedFloat64ToInt32)            \
207   V(CheckedTaggedSignedToInt32)       \
208   V(CheckedTaggedToInt32)             \
209   V(CheckedTruncateTaggedToWord32)    \
210   V(CheckedTaggedToFloat64)           \
211   V(CheckedTaggedToTaggedSigned)      \
212   V(CheckedTaggedToTaggedPointer)
213 
214 #define SIMPLIFIED_COMPARE_BINOP_LIST(V) \
215   V(NumberEqual)                         \
216   V(NumberLessThan)                      \
217   V(NumberLessThanOrEqual)               \
218   V(SpeculativeNumberEqual)              \
219   V(SpeculativeNumberLessThan)           \
220   V(SpeculativeNumberLessThanOrEqual)    \
221   V(ReferenceEqual)                      \
222   V(StringEqual)                         \
223   V(StringLessThan)                      \
224   V(StringLessThanOrEqual)
225 
226 #define SIMPLIFIED_NUMBER_BINOP_LIST(V) \
227   V(NumberAdd)                          \
228   V(NumberSubtract)                     \
229   V(NumberMultiply)                     \
230   V(NumberDivide)                       \
231   V(NumberModulus)                      \
232   V(NumberBitwiseOr)                    \
233   V(NumberBitwiseXor)                   \
234   V(NumberBitwiseAnd)                   \
235   V(NumberShiftLeft)                    \
236   V(NumberShiftRight)                   \
237   V(NumberShiftRightLogical)            \
238   V(NumberAtan2)                        \
239   V(NumberImul)                         \
240   V(NumberMax)                          \
241   V(NumberMin)                          \
242   V(NumberPow)
243 
244 #define SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(V) \
245   V(SpeculativeNumberAdd)                           \
246   V(SpeculativeNumberSubtract)                      \
247   V(SpeculativeNumberMultiply)                      \
248   V(SpeculativeNumberDivide)                        \
249   V(SpeculativeNumberModulus)                       \
250   V(SpeculativeNumberBitwiseAnd)                    \
251   V(SpeculativeNumberBitwiseOr)                     \
252   V(SpeculativeNumberBitwiseXor)                    \
253   V(SpeculativeNumberShiftLeft)                     \
254   V(SpeculativeNumberShiftRight)                    \
255   V(SpeculativeNumberShiftRightLogical)
256 
257 #define SIMPLIFIED_NUMBER_UNOP_LIST(V) \
258   V(NumberAbs)                         \
259   V(NumberAcos)                        \
260   V(NumberAcosh)                       \
261   V(NumberAsin)                        \
262   V(NumberAsinh)                       \
263   V(NumberAtan)                        \
264   V(NumberAtanh)                       \
265   V(NumberCbrt)                        \
266   V(NumberCeil)                        \
267   V(NumberClz32)                       \
268   V(NumberCos)                         \
269   V(NumberCosh)                        \
270   V(NumberExp)                         \
271   V(NumberExpm1)                       \
272   V(NumberFloor)                       \
273   V(NumberFround)                      \
274   V(NumberLog)                         \
275   V(NumberLog1p)                       \
276   V(NumberLog2)                        \
277   V(NumberLog10)                       \
278   V(NumberRound)                       \
279   V(NumberSign)                        \
280   V(NumberSin)                         \
281   V(NumberSinh)                        \
282   V(NumberSqrt)                        \
283   V(NumberTan)                         \
284   V(NumberTanh)                        \
285   V(NumberTrunc)                       \
286   V(NumberToBoolean)                   \
287   V(NumberToInt32)                     \
288   V(NumberToUint32)                    \
289   V(NumberToUint8Clamped)              \
290   V(NumberSilenceNaN)
291 
292 #define SIMPLIFIED_OTHER_OP_LIST(V) \
293   V(PlainPrimitiveToNumber)         \
294   V(PlainPrimitiveToWord32)         \
295   V(PlainPrimitiveToFloat64)        \
296   V(BooleanNot)                     \
297   V(StringCharCodeAt)               \
298   V(StringFromCharCode)             \
299   V(StringFromCodePoint)            \
300   V(CheckBounds)                    \
301   V(CheckIf)                        \
302   V(CheckMaps)                      \
303   V(CheckNumber)                    \
304   V(CheckString)                    \
305   V(CheckSmi)                       \
306   V(CheckHeapObject)                \
307   V(CheckFloat64Hole)               \
308   V(CheckTaggedHole)                \
309   V(ConvertTaggedHoleToUndefined)   \
310   V(Allocate)                       \
311   V(LoadField)                      \
312   V(LoadBuffer)                     \
313   V(LoadElement)                    \
314   V(LoadTypedElement)               \
315   V(StoreField)                     \
316   V(StoreBuffer)                    \
317   V(StoreElement)                   \
318   V(StoreTypedElement)              \
319   V(ObjectIsCallable)               \
320   V(ObjectIsNumber)                 \
321   V(ObjectIsReceiver)               \
322   V(ObjectIsSmi)                    \
323   V(ObjectIsString)                 \
324   V(ObjectIsUndetectable)           \
325   V(ArrayBufferWasNeutered)         \
326   V(EnsureWritableFastElements)     \
327   V(MaybeGrowFastElements)          \
328   V(TransitionElementsKind)
329 
330 #define SIMPLIFIED_OP_LIST(V)                 \
331   SIMPLIFIED_CHANGE_OP_LIST(V)                \
332   SIMPLIFIED_CHECKED_OP_LIST(V)               \
333   SIMPLIFIED_COMPARE_BINOP_LIST(V)            \
334   SIMPLIFIED_NUMBER_BINOP_LIST(V)             \
335   SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(V) \
336   SIMPLIFIED_NUMBER_UNOP_LIST(V)              \
337   SIMPLIFIED_OTHER_OP_LIST(V)
338 
339 // Opcodes for Machine-level operators.
340 #define MACHINE_COMPARE_BINOP_LIST(V) \
341   V(Word32Equal)                      \
342   V(Word64Equal)                      \
343   V(Int32LessThan)                    \
344   V(Int32LessThanOrEqual)             \
345   V(Uint32LessThan)                   \
346   V(Uint32LessThanOrEqual)            \
347   V(Int64LessThan)                    \
348   V(Int64LessThanOrEqual)             \
349   V(Uint64LessThan)                   \
350   V(Uint64LessThanOrEqual)            \
351   V(Float32Equal)                     \
352   V(Float32LessThan)                  \
353   V(Float32LessThanOrEqual)           \
354   V(Float64Equal)                     \
355   V(Float64LessThan)                  \
356   V(Float64LessThanOrEqual)
357 
358 #define MACHINE_UNOP_32_LIST(V) \
359   V(Word32Clz)                  \
360   V(Word32Ctz)                  \
361   V(Word32ReverseBits)          \
362   V(Word32ReverseBytes)
363 
364 #define MACHINE_BINOP_32_LIST(V) \
365   V(Word32And)                   \
366   V(Word32Or)                    \
367   V(Word32Xor)                   \
368   V(Word32Shl)                   \
369   V(Word32Shr)                   \
370   V(Word32Sar)                   \
371   V(Word32Ror)                   \
372   V(Int32Add)                    \
373   V(Int32AddWithOverflow)        \
374   V(Int32Sub)                    \
375   V(Int32SubWithOverflow)        \
376   V(Int32Mul)                    \
377   V(Int32MulWithOverflow)        \
378   V(Int32MulHigh)                \
379   V(Int32Div)                    \
380   V(Int32Mod)                    \
381   V(Uint32Div)                   \
382   V(Uint32Mod)                   \
383   V(Uint32MulHigh)
384 
385 #define MACHINE_BINOP_64_LIST(V) \
386   V(Word64And)                   \
387   V(Word64Or)                    \
388   V(Word64Xor)                   \
389   V(Word64Shl)                   \
390   V(Word64Shr)                   \
391   V(Word64Sar)                   \
392   V(Word64Ror)                   \
393   V(Int64Add)                    \
394   V(Int64AddWithOverflow)        \
395   V(Int64Sub)                    \
396   V(Int64SubWithOverflow)        \
397   V(Int64Mul)                    \
398   V(Int64Div)                    \
399   V(Int64Mod)                    \
400   V(Uint64Div)                   \
401   V(Uint64Mod)
402 
403 #define MACHINE_FLOAT32_UNOP_LIST(V) \
404   V(Float32Abs)                      \
405   V(Float32Neg)                      \
406   V(Float32RoundDown)                \
407   V(Float32RoundTiesEven)            \
408   V(Float32RoundTruncate)            \
409   V(Float32RoundUp)                  \
410   V(Float32Sqrt)
411 
412 #define MACHINE_FLOAT32_BINOP_LIST(V) \
413   V(Float32Add)                       \
414   V(Float32Sub)                       \
415   V(Float32Mul)                       \
416   V(Float32Div)                       \
417   V(Float32Max)                       \
418   V(Float32Min)
419 
420 #define MACHINE_FLOAT64_UNOP_LIST(V) \
421   V(Float64Abs)                      \
422   V(Float64Acos)                     \
423   V(Float64Acosh)                    \
424   V(Float64Asin)                     \
425   V(Float64Asinh)                    \
426   V(Float64Atan)                     \
427   V(Float64Atanh)                    \
428   V(Float64Cbrt)                     \
429   V(Float64Cos)                      \
430   V(Float64Cosh)                     \
431   V(Float64Exp)                      \
432   V(Float64Expm1)                    \
433   V(Float64Log)                      \
434   V(Float64Log1p)                    \
435   V(Float64Log10)                    \
436   V(Float64Log2)                     \
437   V(Float64Neg)                      \
438   V(Float64RoundDown)                \
439   V(Float64RoundTiesAway)            \
440   V(Float64RoundTiesEven)            \
441   V(Float64RoundTruncate)            \
442   V(Float64RoundUp)                  \
443   V(Float64Sin)                      \
444   V(Float64Sinh)                     \
445   V(Float64Sqrt)                     \
446   V(Float64Tan)                      \
447   V(Float64Tanh)
448 
449 #define MACHINE_FLOAT64_BINOP_LIST(V) \
450   V(Float64Atan2)                     \
451   V(Float64Max)                       \
452   V(Float64Min)                       \
453   V(Float64Add)                       \
454   V(Float64Sub)                       \
455   V(Float64Mul)                       \
456   V(Float64Div)                       \
457   V(Float64Mod)                       \
458   V(Float64Pow)
459 
460 #define MACHINE_OP_LIST(V)      \
461   MACHINE_UNOP_32_LIST(V)       \
462   MACHINE_BINOP_32_LIST(V)      \
463   MACHINE_BINOP_64_LIST(V)      \
464   MACHINE_COMPARE_BINOP_LIST(V) \
465   MACHINE_FLOAT32_BINOP_LIST(V) \
466   MACHINE_FLOAT32_UNOP_LIST(V)  \
467   MACHINE_FLOAT64_BINOP_LIST(V) \
468   MACHINE_FLOAT64_UNOP_LIST(V)  \
469   V(DebugBreak)                 \
470   V(Comment)                    \
471   V(Load)                       \
472   V(Store)                      \
473   V(StackSlot)                  \
474   V(Word32Popcnt)               \
475   V(Word64Popcnt)               \
476   V(Word64Clz)                  \
477   V(Word64Ctz)                  \
478   V(Word64ReverseBits)          \
479   V(Word64ReverseBytes)         \
480   V(BitcastTaggedToWord)        \
481   V(BitcastWordToTagged)        \
482   V(BitcastWordToTaggedSigned)  \
483   V(TruncateFloat64ToWord32)    \
484   V(ChangeFloat32ToFloat64)     \
485   V(ChangeFloat64ToInt32)       \
486   V(ChangeFloat64ToUint32)      \
487   V(Float64SilenceNaN)          \
488   V(TruncateFloat64ToUint32)    \
489   V(TruncateFloat32ToInt32)     \
490   V(TruncateFloat32ToUint32)    \
491   V(TryTruncateFloat32ToInt64)  \
492   V(TryTruncateFloat64ToInt64)  \
493   V(TryTruncateFloat32ToUint64) \
494   V(TryTruncateFloat64ToUint64) \
495   V(ChangeInt32ToFloat64)       \
496   V(ChangeInt32ToInt64)         \
497   V(ChangeUint32ToFloat64)      \
498   V(ChangeUint32ToUint64)       \
499   V(TruncateFloat64ToFloat32)   \
500   V(TruncateInt64ToInt32)       \
501   V(RoundFloat64ToInt32)        \
502   V(RoundInt32ToFloat32)        \
503   V(RoundInt64ToFloat32)        \
504   V(RoundInt64ToFloat64)        \
505   V(RoundUint32ToFloat32)       \
506   V(RoundUint64ToFloat32)       \
507   V(RoundUint64ToFloat64)       \
508   V(BitcastFloat32ToInt32)      \
509   V(BitcastFloat64ToInt64)      \
510   V(BitcastInt32ToFloat32)      \
511   V(BitcastInt64ToFloat64)      \
512   V(Float64ExtractLowWord32)    \
513   V(Float64ExtractHighWord32)   \
514   V(Float64InsertLowWord32)     \
515   V(Float64InsertHighWord32)    \
516   V(LoadStackPointer)           \
517   V(LoadFramePointer)           \
518   V(LoadParentFramePointer)     \
519   V(CheckedLoad)                \
520   V(CheckedStore)               \
521   V(UnalignedLoad)              \
522   V(UnalignedStore)             \
523   V(Int32PairAdd)               \
524   V(Int32PairSub)               \
525   V(Int32PairMul)               \
526   V(Word32PairShl)              \
527   V(Word32PairShr)              \
528   V(Word32PairSar)              \
529   V(ProtectedLoad)              \
530   V(AtomicLoad)                 \
531   V(AtomicStore)                \
532   V(UnsafePointerAdd)
533 
534 #define MACHINE_SIMD_RETURN_SIMD_OP_LIST(V) \
535   V(CreateFloat32x4)                        \
536   V(Float32x4ReplaceLane)                   \
537   V(Float32x4Abs)                           \
538   V(Float32x4Neg)                           \
539   V(Float32x4Sqrt)                          \
540   V(Float32x4RecipApprox)                   \
541   V(Float32x4RecipSqrtApprox)               \
542   V(Float32x4Add)                           \
543   V(Float32x4Sub)                           \
544   V(Float32x4Mul)                           \
545   V(Float32x4Div)                           \
546   V(Float32x4Min)                           \
547   V(Float32x4Max)                           \
548   V(Float32x4MinNum)                        \
549   V(Float32x4MaxNum)                        \
550   V(Float32x4Equal)                         \
551   V(Float32x4NotEqual)                      \
552   V(Float32x4LessThan)                      \
553   V(Float32x4LessThanOrEqual)               \
554   V(Float32x4GreaterThan)                   \
555   V(Float32x4GreaterThanOrEqual)            \
556   V(Float32x4Select)                        \
557   V(Float32x4Swizzle)                       \
558   V(Float32x4Shuffle)                       \
559   V(Float32x4FromInt32x4)                   \
560   V(Float32x4FromUint32x4)                  \
561   V(CreateInt32x4)                          \
562   V(Int32x4ReplaceLane)                     \
563   V(Int32x4Neg)                             \
564   V(Int32x4Add)                             \
565   V(Int32x4Sub)                             \
566   V(Int32x4Mul)                             \
567   V(Int32x4Min)                             \
568   V(Int32x4Max)                             \
569   V(Int32x4ShiftLeftByScalar)               \
570   V(Int32x4ShiftRightByScalar)              \
571   V(Int32x4Equal)                           \
572   V(Int32x4NotEqual)                        \
573   V(Int32x4LessThan)                        \
574   V(Int32x4LessThanOrEqual)                 \
575   V(Int32x4GreaterThan)                     \
576   V(Int32x4GreaterThanOrEqual)              \
577   V(Int32x4Select)                          \
578   V(Int32x4Swizzle)                         \
579   V(Int32x4Shuffle)                         \
580   V(Int32x4FromFloat32x4)                   \
581   V(Uint32x4Min)                            \
582   V(Uint32x4Max)                            \
583   V(Uint32x4ShiftLeftByScalar)              \
584   V(Uint32x4ShiftRightByScalar)             \
585   V(Uint32x4LessThan)                       \
586   V(Uint32x4LessThanOrEqual)                \
587   V(Uint32x4GreaterThan)                    \
588   V(Uint32x4GreaterThanOrEqual)             \
589   V(Uint32x4FromFloat32x4)                  \
590   V(CreateBool32x4)                         \
591   V(Bool32x4ReplaceLane)                    \
592   V(Bool32x4And)                            \
593   V(Bool32x4Or)                             \
594   V(Bool32x4Xor)                            \
595   V(Bool32x4Not)                            \
596   V(Bool32x4Swizzle)                        \
597   V(Bool32x4Shuffle)                        \
598   V(Bool32x4Equal)                          \
599   V(Bool32x4NotEqual)                       \
600   V(CreateInt16x8)                          \
601   V(Int16x8ReplaceLane)                     \
602   V(Int16x8Neg)                             \
603   V(Int16x8Add)                             \
604   V(Int16x8AddSaturate)                     \
605   V(Int16x8Sub)                             \
606   V(Int16x8SubSaturate)                     \
607   V(Int16x8Mul)                             \
608   V(Int16x8Min)                             \
609   V(Int16x8Max)                             \
610   V(Int16x8ShiftLeftByScalar)               \
611   V(Int16x8ShiftRightByScalar)              \
612   V(Int16x8Equal)                           \
613   V(Int16x8NotEqual)                        \
614   V(Int16x8LessThan)                        \
615   V(Int16x8LessThanOrEqual)                 \
616   V(Int16x8GreaterThan)                     \
617   V(Int16x8GreaterThanOrEqual)              \
618   V(Int16x8Select)                          \
619   V(Int16x8Swizzle)                         \
620   V(Int16x8Shuffle)                         \
621   V(Uint16x8AddSaturate)                    \
622   V(Uint16x8SubSaturate)                    \
623   V(Uint16x8Min)                            \
624   V(Uint16x8Max)                            \
625   V(Uint16x8ShiftLeftByScalar)              \
626   V(Uint16x8ShiftRightByScalar)             \
627   V(Uint16x8LessThan)                       \
628   V(Uint16x8LessThanOrEqual)                \
629   V(Uint16x8GreaterThan)                    \
630   V(Uint16x8GreaterThanOrEqual)             \
631   V(CreateBool16x8)                         \
632   V(Bool16x8ReplaceLane)                    \
633   V(Bool16x8And)                            \
634   V(Bool16x8Or)                             \
635   V(Bool16x8Xor)                            \
636   V(Bool16x8Not)                            \
637   V(Bool16x8Swizzle)                        \
638   V(Bool16x8Shuffle)                        \
639   V(Bool16x8Equal)                          \
640   V(Bool16x8NotEqual)                       \
641   V(CreateInt8x16)                          \
642   V(Int8x16ReplaceLane)                     \
643   V(Int8x16Neg)                             \
644   V(Int8x16Add)                             \
645   V(Int8x16AddSaturate)                     \
646   V(Int8x16Sub)                             \
647   V(Int8x16SubSaturate)                     \
648   V(Int8x16Mul)                             \
649   V(Int8x16Min)                             \
650   V(Int8x16Max)                             \
651   V(Int8x16ShiftLeftByScalar)               \
652   V(Int8x16ShiftRightByScalar)              \
653   V(Int8x16Equal)                           \
654   V(Int8x16NotEqual)                        \
655   V(Int8x16LessThan)                        \
656   V(Int8x16LessThanOrEqual)                 \
657   V(Int8x16GreaterThan)                     \
658   V(Int8x16GreaterThanOrEqual)              \
659   V(Int8x16Select)                          \
660   V(Int8x16Swizzle)                         \
661   V(Int8x16Shuffle)                         \
662   V(Uint8x16AddSaturate)                    \
663   V(Uint8x16SubSaturate)                    \
664   V(Uint8x16Min)                            \
665   V(Uint8x16Max)                            \
666   V(Uint8x16ShiftLeftByScalar)              \
667   V(Uint8x16ShiftRightByScalar)             \
668   V(Uint8x16LessThan)                       \
669   V(Uint8x16LessThanOrEqual)                \
670   V(Uint8x16GreaterThan)                    \
671   V(Uint8x16GreaterThanOrEqual)             \
672   V(CreateBool8x16)                         \
673   V(Bool8x16ReplaceLane)                    \
674   V(Bool8x16And)                            \
675   V(Bool8x16Or)                             \
676   V(Bool8x16Xor)                            \
677   V(Bool8x16Not)                            \
678   V(Bool8x16Swizzle)                        \
679   V(Bool8x16Shuffle)                        \
680   V(Bool8x16Equal)                          \
681   V(Bool8x16NotEqual)
682 
683 #define MACHINE_SIMD_RETURN_NUM_OP_LIST(V) \
684   V(Float32x4ExtractLane)                  \
685   V(Int32x4ExtractLane)                    \
686   V(Int16x8ExtractLane)                    \
687   V(Int8x16ExtractLane)
688 
689 #define MACHINE_SIMD_RETURN_BOOL_OP_LIST(V) \
690   V(Bool32x4ExtractLane)                    \
691   V(Bool32x4AnyTrue)                        \
692   V(Bool32x4AllTrue)                        \
693   V(Bool16x8ExtractLane)                    \
694   V(Bool16x8AnyTrue)                        \
695   V(Bool16x8AllTrue)                        \
696   V(Bool8x16ExtractLane)                    \
697   V(Bool8x16AnyTrue)                        \
698   V(Bool8x16AllTrue)
699 
700 #define MACHINE_SIMD_GENERIC_OP_LIST(V) \
701   V(Simd128Load)                        \
702   V(Simd128Load1)                       \
703   V(Simd128Load2)                       \
704   V(Simd128Load3)                       \
705   V(Simd128Store)                       \
706   V(Simd128Store1)                      \
707   V(Simd128Store2)                      \
708   V(Simd128Store3)                      \
709   V(Simd128And)                         \
710   V(Simd128Or)                          \
711   V(Simd128Xor)                         \
712   V(Simd128Not)
713 
714 #define MACHINE_SIMD_OP_LIST(V)       \
715   MACHINE_SIMD_RETURN_SIMD_OP_LIST(V) \
716   MACHINE_SIMD_RETURN_NUM_OP_LIST(V)  \
717   MACHINE_SIMD_RETURN_BOOL_OP_LIST(V) \
718   MACHINE_SIMD_GENERIC_OP_LIST(V)
719 
720 #define VALUE_OP_LIST(V)  \
721   COMMON_OP_LIST(V)       \
722   SIMPLIFIED_OP_LIST(V)   \
723   MACHINE_OP_LIST(V)      \
724   MACHINE_SIMD_OP_LIST(V) \
725   JS_OP_LIST(V)
726 
727 // The combination of all operators at all levels and the common operators.
728 #define ALL_OP_LIST(V) \
729   CONTROL_OP_LIST(V)   \
730   VALUE_OP_LIST(V)
731 
732 namespace v8 {
733 namespace internal {
734 namespace compiler {
735 
736 // Declare an enumeration with all the opcodes at all levels so that they
737 // can be globally, uniquely numbered.
738 class V8_EXPORT_PRIVATE IrOpcode {
739  public:
740   enum Value {
741 #define DECLARE_OPCODE(x) k##x,
742     ALL_OP_LIST(DECLARE_OPCODE)
743 #undef DECLARE_OPCODE
744     kLast = -1
745 #define COUNT_OPCODE(x) +1
746             ALL_OP_LIST(COUNT_OPCODE)
747 #undef COUNT_OPCODE
748   };
749 
750   // Returns the mnemonic name of an opcode.
751   static char const* Mnemonic(Value value);
752 
753   // Returns true if opcode for common operator.
IsCommonOpcode(Value value)754   static bool IsCommonOpcode(Value value) {
755     return kStart <= value && value <= kDead;
756   }
757 
758   // Returns true if opcode for control operator.
IsControlOpcode(Value value)759   static bool IsControlOpcode(Value value) {
760     return kStart <= value && value <= kEnd;
761   }
762 
763   // Returns true if opcode for JavaScript operator.
IsJsOpcode(Value value)764   static bool IsJsOpcode(Value value) {
765     return kJSEqual <= value && value <= kJSStackCheck;
766   }
767 
768   // Returns true if opcode for constant operator.
IsConstantOpcode(Value value)769   static bool IsConstantOpcode(Value value) {
770     return kInt32Constant <= value && value <= kRelocatableInt64Constant;
771   }
772 
IsPhiOpcode(Value value)773   static bool IsPhiOpcode(Value value) {
774     return value == kPhi || value == kEffectPhi;
775   }
776 
IsMergeOpcode(Value value)777   static bool IsMergeOpcode(Value value) {
778     return value == kMerge || value == kLoop;
779   }
780 
IsIfProjectionOpcode(Value value)781   static bool IsIfProjectionOpcode(Value value) {
782     return kIfTrue <= value && value <= kIfDefault;
783   }
784 
785   // Returns true if opcode can be inlined.
IsInlineeOpcode(Value value)786   static bool IsInlineeOpcode(Value value) {
787     return value == kJSCallConstruct || value == kJSCallFunction;
788   }
789 
790   // Returns true if opcode for comparison operator.
IsComparisonOpcode(Value value)791   static bool IsComparisonOpcode(Value value) {
792     return (kJSEqual <= value && value <= kJSGreaterThanOrEqual) ||
793            (kNumberEqual <= value && value <= kStringLessThanOrEqual) ||
794            (kWord32Equal <= value && value <= kFloat64LessThanOrEqual);
795   }
796 };
797 
798 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, IrOpcode::Value);
799 
800 }  // namespace compiler
801 }  // namespace internal
802 }  // namespace v8
803 
804 #endif  // V8_COMPILER_OPCODES_H_
805