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