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(ArgumentsElementsState)       \
63   V(ArgumentsLengthState)         \
64   V(ObjectState)                  \
65   V(ObjectId)                     \
66   V(TypedObjectState)             \
67   V(Call)                         \
68   V(CallWithCallerSavedRegisters) \
69   V(Parameter)                    \
70   V(OsrValue)                     \
71   V(LoopExit)                     \
72   V(LoopExitValue)                \
73   V(LoopExitEffect)               \
74   V(Projection)                   \
75   V(Retain)                       \
76   V(MapGuard)                     \
77   V(TypeGuard)
78 
79 #define COMMON_OP_LIST(V) \
80   CONSTANT_OP_LIST(V)     \
81   INNER_OP_LIST(V)        \
82   V(Unreachable)          \
83   V(DeadValue)            \
84   V(Dead)
85 
86 // Opcodes for JavaScript operators.
87 #define JS_COMPARE_BINOP_LIST(V) \
88   V(JSEqual)                     \
89   V(JSStrictEqual)               \
90   V(JSLessThan)                  \
91   V(JSGreaterThan)               \
92   V(JSLessThanOrEqual)           \
93   V(JSGreaterThanOrEqual)
94 
95 #define JS_BITWISE_BINOP_LIST(V) \
96   V(JSBitwiseOr)                 \
97   V(JSBitwiseXor)                \
98   V(JSBitwiseAnd)                \
99   V(JSShiftLeft)                 \
100   V(JSShiftRight)                \
101   V(JSShiftRightLogical)
102 
103 #define JS_ARITH_BINOP_LIST(V) \
104   V(JSAdd)                     \
105   V(JSSubtract)                \
106   V(JSMultiply)                \
107   V(JSDivide)                  \
108   V(JSModulus)                 \
109   V(JSExponentiate)
110 
111 #define JS_SIMPLE_BINOP_LIST(V) \
112   JS_COMPARE_BINOP_LIST(V)      \
113   JS_BITWISE_BINOP_LIST(V)      \
114   JS_ARITH_BINOP_LIST(V)        \
115   V(JSHasInPrototypeChain)      \
116   V(JSInstanceOf)               \
117   V(JSOrdinaryHasInstance)
118 
119 #define JS_CONVERSION_UNOP_LIST(V) \
120   V(JSToInteger)                   \
121   V(JSToLength)                    \
122   V(JSToName)                      \
123   V(JSToNumber)                    \
124   V(JSToNumeric)                   \
125   V(JSToObject)                    \
126   V(JSToString)                    \
127   V(JSParseInt)
128 
129 #define JS_SIMPLE_UNOP_LIST(V) \
130   JS_CONVERSION_UNOP_LIST(V)   \
131   V(JSBitwiseNot)              \
132   V(JSDecrement)               \
133   V(JSIncrement)               \
134   V(JSNegate)
135 
136 #define JS_CREATE_OP_LIST(V)    \
137   V(JSCreate)                   \
138   V(JSCreateArguments)          \
139   V(JSCreateArray)              \
140   V(JSCreateArrayIterator)      \
141   V(JSCreateBoundFunction)      \
142   V(JSCreateClosure)            \
143   V(JSCreateCollectionIterator) \
144   V(JSCreateGeneratorObject)    \
145   V(JSCreateIterResultObject)   \
146   V(JSCreateStringIterator)     \
147   V(JSCreateKeyValueArray)      \
148   V(JSCreateObject)             \
149   V(JSCreatePromise)            \
150   V(JSCreateTypedArray)         \
151   V(JSCreateLiteralArray)       \
152   V(JSCreateEmptyLiteralArray)  \
153   V(JSCreateLiteralObject)      \
154   V(JSCreateEmptyLiteralObject) \
155   V(JSCreateLiteralRegExp)
156 
157 #define JS_OBJECT_OP_LIST(V)      \
158   JS_CREATE_OP_LIST(V)            \
159   V(JSLoadProperty)               \
160   V(JSLoadNamed)                  \
161   V(JSLoadGlobal)                 \
162   V(JSStoreProperty)              \
163   V(JSStoreNamed)                 \
164   V(JSStoreNamedOwn)              \
165   V(JSStoreGlobal)                \
166   V(JSStoreDataPropertyInLiteral) \
167   V(JSStoreInArrayLiteral)        \
168   V(JSDeleteProperty)             \
169   V(JSHasProperty)                \
170   V(JSGetSuperConstructor)
171 
172 #define JS_CONTEXT_OP_LIST(V) \
173   V(JSLoadContext)            \
174   V(JSStoreContext)           \
175   V(JSCreateFunctionContext)  \
176   V(JSCreateCatchContext)     \
177   V(JSCreateWithContext)      \
178   V(JSCreateBlockContext)
179 
180 #define JS_CONSTRUCT_OP_LIST(V) \
181   V(JSConstructForwardVarargs)  \
182   V(JSConstruct)                \
183   V(JSConstructWithArrayLike)   \
184   V(JSConstructWithSpread)
185 
186 #define JS_OTHER_OP_LIST(V)            \
187   JS_CONSTRUCT_OP_LIST(V)              \
188   V(JSCallForwardVarargs)              \
189   V(JSCall)                            \
190   V(JSCallWithArrayLike)               \
191   V(JSCallWithSpread)                  \
192   V(JSCallRuntime)                     \
193   V(JSForInEnumerate)                  \
194   V(JSForInNext)                       \
195   V(JSForInPrepare)                    \
196   V(JSLoadMessage)                     \
197   V(JSStoreMessage)                    \
198   V(JSLoadModule)                      \
199   V(JSStoreModule)                     \
200   V(JSGeneratorStore)                  \
201   V(JSGeneratorRestoreContinuation)    \
202   V(JSGeneratorRestoreContext)         \
203   V(JSGeneratorRestoreRegister)        \
204   V(JSGeneratorRestoreInputOrDebugPos) \
205   V(JSFulfillPromise)                  \
206   V(JSPerformPromiseThen)              \
207   V(JSPromiseResolve)                  \
208   V(JSRejectPromise)                   \
209   V(JSResolvePromise)                  \
210   V(JSStackCheck)                      \
211   V(JSObjectIsArray)                   \
212   V(JSDebugger)
213 
214 #define JS_OP_LIST(V)     \
215   JS_SIMPLE_BINOP_LIST(V) \
216   JS_SIMPLE_UNOP_LIST(V)  \
217   JS_OBJECT_OP_LIST(V)    \
218   JS_CONTEXT_OP_LIST(V)   \
219   JS_OTHER_OP_LIST(V)
220 
221 // Opcodes for VirtuaMachine-level operators.
222 #define SIMPLIFIED_CHANGE_OP_LIST(V) \
223   V(ChangeTaggedSignedToInt32)       \
224   V(ChangeTaggedToInt32)             \
225   V(ChangeTaggedToUint32)            \
226   V(ChangeTaggedToFloat64)           \
227   V(ChangeTaggedToTaggedSigned)      \
228   V(ChangeInt31ToTaggedSigned)       \
229   V(ChangeInt32ToTagged)             \
230   V(ChangeUint32ToTagged)            \
231   V(ChangeFloat64ToTagged)           \
232   V(ChangeFloat64ToTaggedPointer)    \
233   V(ChangeTaggedToBit)               \
234   V(ChangeBitToTagged)               \
235   V(TruncateTaggedToWord32)          \
236   V(TruncateTaggedToFloat64)         \
237   V(TruncateTaggedToBit)             \
238   V(TruncateTaggedPointerToBit)
239 
240 #define SIMPLIFIED_CHECKED_OP_LIST(V) \
241   V(CheckedInt32Add)                  \
242   V(CheckedInt32Sub)                  \
243   V(CheckedInt32Div)                  \
244   V(CheckedInt32Mod)                  \
245   V(CheckedUint32Div)                 \
246   V(CheckedUint32Mod)                 \
247   V(CheckedInt32Mul)                  \
248   V(CheckedInt32ToTaggedSigned)       \
249   V(CheckedUint32ToInt32)             \
250   V(CheckedUint32ToTaggedSigned)      \
251   V(CheckedFloat64ToInt32)            \
252   V(CheckedTaggedSignedToInt32)       \
253   V(CheckedTaggedToInt32)             \
254   V(CheckedTruncateTaggedToWord32)    \
255   V(CheckedTaggedToFloat64)           \
256   V(CheckedTaggedToTaggedSigned)      \
257   V(CheckedTaggedToTaggedPointer)
258 
259 #define SIMPLIFIED_COMPARE_BINOP_LIST(V) \
260   V(NumberEqual)                         \
261   V(NumberLessThan)                      \
262   V(NumberLessThanOrEqual)               \
263   V(SpeculativeNumberEqual)              \
264   V(SpeculativeNumberLessThan)           \
265   V(SpeculativeNumberLessThanOrEqual)    \
266   V(ReferenceEqual)                      \
267   V(SameValue)                           \
268   V(StringEqual)                         \
269   V(StringLessThan)                      \
270   V(StringLessThanOrEqual)
271 
272 #define SIMPLIFIED_NUMBER_BINOP_LIST(V) \
273   V(NumberAdd)                          \
274   V(NumberSubtract)                     \
275   V(NumberMultiply)                     \
276   V(NumberDivide)                       \
277   V(NumberModulus)                      \
278   V(NumberBitwiseOr)                    \
279   V(NumberBitwiseXor)                   \
280   V(NumberBitwiseAnd)                   \
281   V(NumberShiftLeft)                    \
282   V(NumberShiftRight)                   \
283   V(NumberShiftRightLogical)            \
284   V(NumberAtan2)                        \
285   V(NumberImul)                         \
286   V(NumberMax)                          \
287   V(NumberMin)                          \
288   V(NumberPow)
289 
290 #define SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(V) \
291   V(SpeculativeNumberAdd)                           \
292   V(SpeculativeNumberSubtract)                      \
293   V(SpeculativeNumberMultiply)                      \
294   V(SpeculativeNumberDivide)                        \
295   V(SpeculativeNumberModulus)                       \
296   V(SpeculativeNumberBitwiseAnd)                    \
297   V(SpeculativeNumberBitwiseOr)                     \
298   V(SpeculativeNumberBitwiseXor)                    \
299   V(SpeculativeNumberShiftLeft)                     \
300   V(SpeculativeNumberShiftRight)                    \
301   V(SpeculativeNumberShiftRightLogical)             \
302   V(SpeculativeSafeIntegerAdd)                      \
303   V(SpeculativeSafeIntegerSubtract)
304 
305 #define SIMPLIFIED_NUMBER_UNOP_LIST(V) \
306   V(NumberAbs)                         \
307   V(NumberAcos)                        \
308   V(NumberAcosh)                       \
309   V(NumberAsin)                        \
310   V(NumberAsinh)                       \
311   V(NumberAtan)                        \
312   V(NumberAtanh)                       \
313   V(NumberCbrt)                        \
314   V(NumberCeil)                        \
315   V(NumberClz32)                       \
316   V(NumberCos)                         \
317   V(NumberCosh)                        \
318   V(NumberExp)                         \
319   V(NumberExpm1)                       \
320   V(NumberFloor)                       \
321   V(NumberFround)                      \
322   V(NumberLog)                         \
323   V(NumberLog1p)                       \
324   V(NumberLog2)                        \
325   V(NumberLog10)                       \
326   V(NumberRound)                       \
327   V(NumberSign)                        \
328   V(NumberSin)                         \
329   V(NumberSinh)                        \
330   V(NumberSqrt)                        \
331   V(NumberTan)                         \
332   V(NumberTanh)                        \
333   V(NumberTrunc)                       \
334   V(NumberToBoolean)                   \
335   V(NumberToInt32)                     \
336   V(NumberToString)                    \
337   V(NumberToUint32)                    \
338   V(NumberToUint8Clamped)              \
339   V(NumberSilenceNaN)
340 
341 #define SIMPLIFIED_SPECULATIVE_NUMBER_UNOP_LIST(V) V(SpeculativeToNumber)
342 
343 #define SIMPLIFIED_OTHER_OP_LIST(V)     \
344   V(PlainPrimitiveToNumber)             \
345   V(PlainPrimitiveToWord32)             \
346   V(PlainPrimitiveToFloat64)            \
347   V(BooleanNot)                         \
348   V(StringToNumber)                     \
349   V(StringCharCodeAt)                   \
350   V(StringCodePointAt)                  \
351   V(StringFromSingleCharCode)           \
352   V(StringFromSingleCodePoint)          \
353   V(StringIndexOf)                      \
354   V(StringLength)                       \
355   V(StringToLowerCaseIntl)              \
356   V(StringToUpperCaseIntl)              \
357   V(StringSubstring)                    \
358   V(CheckBounds)                        \
359   V(CheckIf)                            \
360   V(CheckMaps)                          \
361   V(CheckNumber)                        \
362   V(CheckInternalizedString)            \
363   V(CheckReceiver)                      \
364   V(CheckString)                        \
365   V(CheckSymbol)                        \
366   V(CheckSmi)                           \
367   V(CheckHeapObject)                    \
368   V(CheckFloat64Hole)                   \
369   V(CheckNotTaggedHole)                 \
370   V(CheckEqualsInternalizedString)      \
371   V(CheckEqualsSymbol)                  \
372   V(CompareMaps)                        \
373   V(ConvertReceiver)                    \
374   V(ConvertTaggedHoleToUndefined)       \
375   V(TypeOf)                             \
376   V(Allocate)                           \
377   V(AllocateRaw)                        \
378   V(LoadFieldByIndex)                   \
379   V(LoadField)                          \
380   V(LoadElement)                        \
381   V(LoadTypedElement)                   \
382   V(StoreField)                         \
383   V(StoreElement)                       \
384   V(StoreTypedElement)                  \
385   V(StoreSignedSmallElement)            \
386   V(TransitionAndStoreElement)          \
387   V(TransitionAndStoreNumberElement)    \
388   V(TransitionAndStoreNonNumberElement) \
389   V(ToBoolean)                          \
390   V(NumberIsFloat64Hole)                \
391   V(NumberIsFinite)                     \
392   V(ObjectIsFiniteNumber)               \
393   V(NumberIsInteger)                    \
394   V(ObjectIsSafeInteger)                \
395   V(NumberIsSafeInteger)                \
396   V(ObjectIsInteger)                    \
397   V(ObjectIsArrayBufferView)            \
398   V(ObjectIsBigInt)                     \
399   V(ObjectIsCallable)                   \
400   V(ObjectIsConstructor)                \
401   V(ObjectIsDetectableCallable)         \
402   V(ObjectIsMinusZero)                  \
403   V(ObjectIsNaN)                        \
404   V(NumberIsNaN)                        \
405   V(ObjectIsNonCallable)                \
406   V(ObjectIsNumber)                     \
407   V(ObjectIsReceiver)                   \
408   V(ObjectIsSmi)                        \
409   V(ObjectIsString)                     \
410   V(ObjectIsSymbol)                     \
411   V(ObjectIsUndetectable)               \
412   V(ArgumentsFrame)                     \
413   V(ArgumentsLength)                    \
414   V(NewDoubleElements)                  \
415   V(NewSmiOrObjectElements)             \
416   V(NewArgumentsElements)               \
417   V(NewConsString)                      \
418   V(ArrayBufferWasNeutered)             \
419   V(EnsureWritableFastElements)         \
420   V(MaybeGrowFastElements)              \
421   V(TransitionElementsKind)             \
422   V(FindOrderedHashMapEntry)            \
423   V(FindOrderedHashMapEntryForInt32Key) \
424   V(PoisonIndex)                        \
425   V(RuntimeAbort)                       \
426   V(DateNow)
427 
428 #define SIMPLIFIED_OP_LIST(V)                 \
429   SIMPLIFIED_CHANGE_OP_LIST(V)                \
430   SIMPLIFIED_CHECKED_OP_LIST(V)               \
431   SIMPLIFIED_COMPARE_BINOP_LIST(V)            \
432   SIMPLIFIED_NUMBER_BINOP_LIST(V)             \
433   SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(V) \
434   SIMPLIFIED_NUMBER_UNOP_LIST(V)              \
435   SIMPLIFIED_SPECULATIVE_NUMBER_UNOP_LIST(V)  \
436   SIMPLIFIED_OTHER_OP_LIST(V)
437 
438 // Opcodes for Machine-level operators.
439 #define MACHINE_COMPARE_BINOP_LIST(V) \
440   V(Word32Equal)                      \
441   V(Word64Equal)                      \
442   V(Int32LessThan)                    \
443   V(Int32LessThanOrEqual)             \
444   V(Uint32LessThan)                   \
445   V(Uint32LessThanOrEqual)            \
446   V(Int64LessThan)                    \
447   V(Int64LessThanOrEqual)             \
448   V(Uint64LessThan)                   \
449   V(Uint64LessThanOrEqual)            \
450   V(Float32Equal)                     \
451   V(Float32LessThan)                  \
452   V(Float32LessThanOrEqual)           \
453   V(Float64Equal)                     \
454   V(Float64LessThan)                  \
455   V(Float64LessThanOrEqual)
456 
457 #define MACHINE_UNOP_32_LIST(V) \
458   V(Word32Clz)                  \
459   V(Word32Ctz)                  \
460   V(Int32AbsWithOverflow)       \
461   V(Word32ReverseBits)          \
462   V(Word32ReverseBytes)
463 
464 #define MACHINE_BINOP_32_LIST(V) \
465   V(Word32And)                   \
466   V(Word32Or)                    \
467   V(Word32Xor)                   \
468   V(Word32Shl)                   \
469   V(Word32Shr)                   \
470   V(Word32Sar)                   \
471   V(Word32Ror)                   \
472   V(Int32Add)                    \
473   V(Int32AddWithOverflow)        \
474   V(Int32Sub)                    \
475   V(Int32SubWithOverflow)        \
476   V(Int32Mul)                    \
477   V(Int32MulWithOverflow)        \
478   V(Int32MulHigh)                \
479   V(Int32Div)                    \
480   V(Int32Mod)                    \
481   V(Uint32Div)                   \
482   V(Uint32Mod)                   \
483   V(Uint32MulHigh)
484 
485 #define MACHINE_BINOP_64_LIST(V) \
486   V(Word64And)                   \
487   V(Word64Or)                    \
488   V(Word64Xor)                   \
489   V(Word64Shl)                   \
490   V(Word64Shr)                   \
491   V(Word64Sar)                   \
492   V(Word64Ror)                   \
493   V(Int64Add)                    \
494   V(Int64AddWithOverflow)        \
495   V(Int64Sub)                    \
496   V(Int64SubWithOverflow)        \
497   V(Int64Mul)                    \
498   V(Int64Div)                    \
499   V(Int64Mod)                    \
500   V(Uint64Div)                   \
501   V(Uint64Mod)
502 
503 #define MACHINE_FLOAT32_UNOP_LIST(V) \
504   V(Float32Abs)                      \
505   V(Float32Neg)                      \
506   V(Float32RoundDown)                \
507   V(Float32RoundTiesEven)            \
508   V(Float32RoundTruncate)            \
509   V(Float32RoundUp)                  \
510   V(Float32Sqrt)
511 
512 #define MACHINE_FLOAT32_BINOP_LIST(V) \
513   V(Float32Add)                       \
514   V(Float32Sub)                       \
515   V(Float32Mul)                       \
516   V(Float32Div)                       \
517   V(Float32Max)                       \
518   V(Float32Min)
519 
520 #define MACHINE_FLOAT64_UNOP_LIST(V) \
521   V(Float64Abs)                      \
522   V(Float64Acos)                     \
523   V(Float64Acosh)                    \
524   V(Float64Asin)                     \
525   V(Float64Asinh)                    \
526   V(Float64Atan)                     \
527   V(Float64Atanh)                    \
528   V(Float64Cbrt)                     \
529   V(Float64Cos)                      \
530   V(Float64Cosh)                     \
531   V(Float64Exp)                      \
532   V(Float64Expm1)                    \
533   V(Float64Log)                      \
534   V(Float64Log1p)                    \
535   V(Float64Log10)                    \
536   V(Float64Log2)                     \
537   V(Float64Neg)                      \
538   V(Float64RoundDown)                \
539   V(Float64RoundTiesAway)            \
540   V(Float64RoundTiesEven)            \
541   V(Float64RoundTruncate)            \
542   V(Float64RoundUp)                  \
543   V(Float64Sin)                      \
544   V(Float64Sinh)                     \
545   V(Float64Sqrt)                     \
546   V(Float64Tan)                      \
547   V(Float64Tanh)
548 
549 #define MACHINE_FLOAT64_BINOP_LIST(V) \
550   V(Float64Atan2)                     \
551   V(Float64Max)                       \
552   V(Float64Min)                       \
553   V(Float64Add)                       \
554   V(Float64Sub)                       \
555   V(Float64Mul)                       \
556   V(Float64Div)                       \
557   V(Float64Mod)                       \
558   V(Float64Pow)
559 
560 #define MACHINE_OP_LIST(V)       \
561   MACHINE_UNOP_32_LIST(V)        \
562   MACHINE_BINOP_32_LIST(V)       \
563   MACHINE_BINOP_64_LIST(V)       \
564   MACHINE_COMPARE_BINOP_LIST(V)  \
565   MACHINE_FLOAT32_BINOP_LIST(V)  \
566   MACHINE_FLOAT32_UNOP_LIST(V)   \
567   MACHINE_FLOAT64_BINOP_LIST(V)  \
568   MACHINE_FLOAT64_UNOP_LIST(V)   \
569   V(DebugAbort)                  \
570   V(DebugBreak)                  \
571   V(Comment)                     \
572   V(Load)                        \
573   V(PoisonedLoad)                \
574   V(Store)                       \
575   V(StackSlot)                   \
576   V(Word32Popcnt)                \
577   V(Word64Popcnt)                \
578   V(Word64Clz)                   \
579   V(Word64Ctz)                   \
580   V(Word64ReverseBits)           \
581   V(Word64ReverseBytes)          \
582   V(Int64AbsWithOverflow)        \
583   V(BitcastTaggedToWord)         \
584   V(BitcastWordToTagged)         \
585   V(BitcastWordToTaggedSigned)   \
586   V(TruncateFloat64ToWord32)     \
587   V(ChangeFloat32ToFloat64)      \
588   V(ChangeFloat64ToInt32)        \
589   V(ChangeFloat64ToUint32)       \
590   V(ChangeFloat64ToUint64)       \
591   V(Float64SilenceNaN)           \
592   V(TruncateFloat64ToUint32)     \
593   V(TruncateFloat32ToInt32)      \
594   V(TruncateFloat32ToUint32)     \
595   V(TryTruncateFloat32ToInt64)   \
596   V(TryTruncateFloat64ToInt64)   \
597   V(TryTruncateFloat32ToUint64)  \
598   V(TryTruncateFloat64ToUint64)  \
599   V(ChangeInt32ToFloat64)        \
600   V(ChangeInt32ToInt64)          \
601   V(ChangeUint32ToFloat64)       \
602   V(ChangeUint32ToUint64)        \
603   V(TruncateFloat64ToFloat32)    \
604   V(TruncateInt64ToInt32)        \
605   V(RoundFloat64ToInt32)         \
606   V(RoundInt32ToFloat32)         \
607   V(RoundInt64ToFloat32)         \
608   V(RoundInt64ToFloat64)         \
609   V(RoundUint32ToFloat32)        \
610   V(RoundUint64ToFloat32)        \
611   V(RoundUint64ToFloat64)        \
612   V(BitcastFloat32ToInt32)       \
613   V(BitcastFloat64ToInt64)       \
614   V(BitcastInt32ToFloat32)       \
615   V(BitcastInt64ToFloat64)       \
616   V(Float64ExtractLowWord32)     \
617   V(Float64ExtractHighWord32)    \
618   V(Float64InsertLowWord32)      \
619   V(Float64InsertHighWord32)     \
620   V(TaggedPoisonOnSpeculation)   \
621   V(Word32PoisonOnSpeculation)   \
622   V(Word64PoisonOnSpeculation)   \
623   V(LoadStackPointer)            \
624   V(LoadFramePointer)            \
625   V(LoadParentFramePointer)      \
626   V(LoadRootsPointer)            \
627   V(UnalignedLoad)               \
628   V(UnalignedStore)              \
629   V(Int32PairAdd)                \
630   V(Int32PairSub)                \
631   V(Int32PairMul)                \
632   V(Word32PairShl)               \
633   V(Word32PairShr)               \
634   V(Word32PairSar)               \
635   V(ProtectedLoad)               \
636   V(ProtectedStore)              \
637   V(Word32AtomicLoad)            \
638   V(Word32AtomicStore)           \
639   V(Word32AtomicExchange)        \
640   V(Word32AtomicCompareExchange) \
641   V(Word32AtomicAdd)             \
642   V(Word32AtomicSub)             \
643   V(Word32AtomicAnd)             \
644   V(Word32AtomicOr)              \
645   V(Word32AtomicXor)             \
646   V(Word64AtomicLoad)            \
647   V(Word64AtomicStore)           \
648   V(Word64AtomicAdd)             \
649   V(Word64AtomicSub)             \
650   V(Word64AtomicAnd)             \
651   V(Word64AtomicOr)              \
652   V(Word64AtomicXor)             \
653   V(Word64AtomicExchange)        \
654   V(Word64AtomicCompareExchange) \
655   V(SpeculationFence)            \
656   V(SignExtendWord8ToInt32)      \
657   V(SignExtendWord16ToInt32)     \
658   V(SignExtendWord8ToInt64)      \
659   V(SignExtendWord16ToInt64)     \
660   V(SignExtendWord32ToInt64)     \
661   V(UnsafePointerAdd)
662 
663 #define MACHINE_SIMD_OP_LIST(V) \
664   V(F32x4Splat)                 \
665   V(F32x4ExtractLane)           \
666   V(F32x4ReplaceLane)           \
667   V(F32x4SConvertI32x4)         \
668   V(F32x4UConvertI32x4)         \
669   V(F32x4Abs)                   \
670   V(F32x4Neg)                   \
671   V(F32x4RecipApprox)           \
672   V(F32x4RecipSqrtApprox)       \
673   V(F32x4Add)                   \
674   V(F32x4AddHoriz)              \
675   V(F32x4Sub)                   \
676   V(F32x4Mul)                   \
677   V(F32x4Min)                   \
678   V(F32x4Max)                   \
679   V(F32x4Eq)                    \
680   V(F32x4Ne)                    \
681   V(F32x4Lt)                    \
682   V(F32x4Le)                    \
683   V(F32x4Gt)                    \
684   V(F32x4Ge)                    \
685   V(I32x4Splat)                 \
686   V(I32x4ExtractLane)           \
687   V(I32x4ReplaceLane)           \
688   V(I32x4SConvertF32x4)         \
689   V(I32x4SConvertI16x8Low)      \
690   V(I32x4SConvertI16x8High)     \
691   V(I32x4Neg)                   \
692   V(I32x4Shl)                   \
693   V(I32x4ShrS)                  \
694   V(I32x4Add)                   \
695   V(I32x4AddHoriz)              \
696   V(I32x4Sub)                   \
697   V(I32x4Mul)                   \
698   V(I32x4MinS)                  \
699   V(I32x4MaxS)                  \
700   V(I32x4Eq)                    \
701   V(I32x4Ne)                    \
702   V(I32x4LtS)                   \
703   V(I32x4LeS)                   \
704   V(I32x4GtS)                   \
705   V(I32x4GeS)                   \
706   V(I32x4UConvertF32x4)         \
707   V(I32x4UConvertI16x8Low)      \
708   V(I32x4UConvertI16x8High)     \
709   V(I32x4ShrU)                  \
710   V(I32x4MinU)                  \
711   V(I32x4MaxU)                  \
712   V(I32x4LtU)                   \
713   V(I32x4LeU)                   \
714   V(I32x4GtU)                   \
715   V(I32x4GeU)                   \
716   V(I16x8Splat)                 \
717   V(I16x8ExtractLane)           \
718   V(I16x8ReplaceLane)           \
719   V(I16x8SConvertI8x16Low)      \
720   V(I16x8SConvertI8x16High)     \
721   V(I16x8Neg)                   \
722   V(I16x8Shl)                   \
723   V(I16x8ShrS)                  \
724   V(I16x8SConvertI32x4)         \
725   V(I16x8Add)                   \
726   V(I16x8AddSaturateS)          \
727   V(I16x8AddHoriz)              \
728   V(I16x8Sub)                   \
729   V(I16x8SubSaturateS)          \
730   V(I16x8Mul)                   \
731   V(I16x8MinS)                  \
732   V(I16x8MaxS)                  \
733   V(I16x8Eq)                    \
734   V(I16x8Ne)                    \
735   V(I16x8LtS)                   \
736   V(I16x8LeS)                   \
737   V(I16x8GtS)                   \
738   V(I16x8GeS)                   \
739   V(I16x8UConvertI8x16Low)      \
740   V(I16x8UConvertI8x16High)     \
741   V(I16x8ShrU)                  \
742   V(I16x8UConvertI32x4)         \
743   V(I16x8AddSaturateU)          \
744   V(I16x8SubSaturateU)          \
745   V(I16x8MinU)                  \
746   V(I16x8MaxU)                  \
747   V(I16x8LtU)                   \
748   V(I16x8LeU)                   \
749   V(I16x8GtU)                   \
750   V(I16x8GeU)                   \
751   V(I8x16Splat)                 \
752   V(I8x16ExtractLane)           \
753   V(I8x16ReplaceLane)           \
754   V(I8x16SConvertI16x8)         \
755   V(I8x16Neg)                   \
756   V(I8x16Shl)                   \
757   V(I8x16ShrS)                  \
758   V(I8x16Add)                   \
759   V(I8x16AddSaturateS)          \
760   V(I8x16Sub)                   \
761   V(I8x16SubSaturateS)          \
762   V(I8x16Mul)                   \
763   V(I8x16MinS)                  \
764   V(I8x16MaxS)                  \
765   V(I8x16Eq)                    \
766   V(I8x16Ne)                    \
767   V(I8x16LtS)                   \
768   V(I8x16LeS)                   \
769   V(I8x16GtS)                   \
770   V(I8x16GeS)                   \
771   V(I8x16UConvertI16x8)         \
772   V(I8x16AddSaturateU)          \
773   V(I8x16SubSaturateU)          \
774   V(I8x16ShrU)                  \
775   V(I8x16MinU)                  \
776   V(I8x16MaxU)                  \
777   V(I8x16LtU)                   \
778   V(I8x16LeU)                   \
779   V(I8x16GtU)                   \
780   V(I8x16GeU)                   \
781   V(S128Load)                   \
782   V(S128Store)                  \
783   V(S128Zero)                   \
784   V(S128Not)                    \
785   V(S128And)                    \
786   V(S128Or)                     \
787   V(S128Xor)                    \
788   V(S128Select)                 \
789   V(S8x16Shuffle)               \
790   V(S1x4AnyTrue)                \
791   V(S1x4AllTrue)                \
792   V(S1x8AnyTrue)                \
793   V(S1x8AllTrue)                \
794   V(S1x16AnyTrue)               \
795   V(S1x16AllTrue)
796 
797 #define VALUE_OP_LIST(V)  \
798   COMMON_OP_LIST(V)       \
799   SIMPLIFIED_OP_LIST(V)   \
800   MACHINE_OP_LIST(V)      \
801   MACHINE_SIMD_OP_LIST(V) \
802   JS_OP_LIST(V)
803 
804 // The combination of all operators at all levels and the common operators.
805 #define ALL_OP_LIST(V) \
806   CONTROL_OP_LIST(V)   \
807   VALUE_OP_LIST(V)
808 
809 namespace v8 {
810 namespace internal {
811 namespace compiler {
812 
813 // Declare an enumeration with all the opcodes at all levels so that they
814 // can be globally, uniquely numbered.
815 class V8_EXPORT_PRIVATE IrOpcode {
816  public:
817   enum Value {
818 #define DECLARE_OPCODE(x) k##x,
819     ALL_OP_LIST(DECLARE_OPCODE)
820 #undef DECLARE_OPCODE
821     kLast = -1
822 #define COUNT_OPCODE(x) +1
823             ALL_OP_LIST(COUNT_OPCODE)
824 #undef COUNT_OPCODE
825   };
826 
827   // Returns the mnemonic name of an opcode.
828   static char const* Mnemonic(Value value);
829 
830   // Returns true if opcode for common operator.
IsCommonOpcode(Value value)831   static bool IsCommonOpcode(Value value) {
832     return kStart <= value && value <= kDead;
833   }
834 
835   // Returns true if opcode for control operator.
IsControlOpcode(Value value)836   static bool IsControlOpcode(Value value) {
837     return kStart <= value && value <= kEnd;
838   }
839 
840   // Returns true if opcode for JavaScript operator.
IsJsOpcode(Value value)841   static bool IsJsOpcode(Value value) {
842     return kJSEqual <= value && value <= kJSDebugger;
843   }
844 
845   // Returns true if opcode for constant operator.
IsConstantOpcode(Value value)846   static bool IsConstantOpcode(Value value) {
847     return kInt32Constant <= value && value <= kRelocatableInt64Constant;
848   }
849 
IsPhiOpcode(Value value)850   static bool IsPhiOpcode(Value value) {
851     return value == kPhi || value == kEffectPhi;
852   }
853 
IsMergeOpcode(Value value)854   static bool IsMergeOpcode(Value value) {
855     return value == kMerge || value == kLoop;
856   }
857 
IsIfProjectionOpcode(Value value)858   static bool IsIfProjectionOpcode(Value value) {
859     return kIfTrue <= value && value <= kIfDefault;
860   }
861 
862   // Returns true if opcode terminates control flow in a graph (i.e. respective
863   // nodes are expected to have control uses by the graphs {End} node only).
IsGraphTerminator(Value value)864   static bool IsGraphTerminator(Value value) {
865     return value == kDeoptimize || value == kReturn || value == kTailCall ||
866            value == kTerminate || value == kThrow;
867   }
868 
869   // Returns true if opcode can be inlined.
IsInlineeOpcode(Value value)870   static bool IsInlineeOpcode(Value value) {
871     return value == kJSConstruct || value == kJSCall;
872   }
873 
874   // Returns true if opcode for comparison operator.
IsComparisonOpcode(Value value)875   static bool IsComparisonOpcode(Value value) {
876     return (kJSEqual <= value && value <= kJSGreaterThanOrEqual) ||
877            (kNumberEqual <= value && value <= kStringLessThanOrEqual) ||
878            (kWord32Equal <= value && value <= kFloat64LessThanOrEqual);
879   }
880 
IsContextChainExtendingOpcode(Value value)881   static bool IsContextChainExtendingOpcode(Value value) {
882     return kJSCreateFunctionContext <= value && value <= kJSCreateBlockContext;
883   }
884 };
885 
886 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, IrOpcode::Value);
887 
888 }  // namespace compiler
889 }  // namespace internal
890 }  // namespace v8
891 
892 #endif  // V8_COMPILER_OPCODES_H_
893