opcodes.h 33.6 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2013 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_COMPILER_OPCODES_H_
#define V8_COMPILER_OPCODES_H_

8 9
#include <iosfwd>

10
#include "src/common/globals.h"
11

12
// Opcodes for control operators.
13 14
#define CONTROL_OP_LIST(V) \
  V(Start)                 \
15 16 17 18 19 20 21 22 23 24 25
  V(Loop)                  \
  V(Branch)                \
  V(Switch)                \
  V(IfTrue)                \
  V(IfFalse)               \
  V(IfSuccess)             \
  V(IfException)           \
  V(IfValue)               \
  V(IfDefault)             \
  V(Merge)                 \
  V(Deoptimize)            \
26 27
  V(DeoptimizeIf)          \
  V(DeoptimizeUnless)      \
28 29
  V(TrapIf)                \
  V(TrapUnless)            \
30
  V(Return)                \
31
  V(TailCall)              \
32
  V(Terminate)             \
33 34 35
  V(OsrNormalEntry)        \
  V(OsrLoopEntry)          \
  V(Throw)                 \
36 37
  V(End)

38
// Opcodes for constant operators.
39 40 41 42 43 44 45
#define CONSTANT_OP_LIST(V)   \
  V(Int32Constant)            \
  V(Int64Constant)            \
  V(Float32Constant)          \
  V(Float64Constant)          \
  V(ExternalConstant)         \
  V(NumberConstant)           \
46
  V(PointerConstant)          \
47
  V(HeapConstant)             \
48
  V(CompressedHeapConstant)   \
49 50
  V(RelocatableInt32Constant) \
  V(RelocatableInt64Constant)
51

52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
#define INNER_OP_LIST(V)          \
  V(Select)                       \
  V(Phi)                          \
  V(EffectPhi)                    \
  V(InductionVariablePhi)         \
  V(Checkpoint)                   \
  V(BeginRegion)                  \
  V(FinishRegion)                 \
  V(FrameState)                   \
  V(StateValues)                  \
  V(TypedStateValues)             \
  V(ArgumentsElementsState)       \
  V(ArgumentsLengthState)         \
  V(ObjectState)                  \
  V(ObjectId)                     \
  V(TypedObjectState)             \
  V(Call)                         \
  V(CallWithCallerSavedRegisters) \
  V(Parameter)                    \
  V(OsrValue)                     \
  V(LoopExit)                     \
  V(LoopExitValue)                \
  V(LoopExitEffect)               \
  V(Projection)                   \
  V(Retain)                       \
  V(MapGuard)                     \
78
  V(TypeGuard)
79 80

#define COMMON_OP_LIST(V) \
81
  CONSTANT_OP_LIST(V)     \
82
  INNER_OP_LIST(V)        \
83 84
  V(Unreachable)          \
  V(DeadValue)            \
85 86
  V(Dead)                 \
  V(StaticAssert)
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

// Opcodes for JavaScript operators.
#define JS_COMPARE_BINOP_LIST(V) \
  V(JSEqual)                     \
  V(JSStrictEqual)               \
  V(JSLessThan)                  \
  V(JSGreaterThan)               \
  V(JSLessThanOrEqual)           \
  V(JSGreaterThanOrEqual)

#define JS_BITWISE_BINOP_LIST(V) \
  V(JSBitwiseOr)                 \
  V(JSBitwiseXor)                \
  V(JSBitwiseAnd)                \
  V(JSShiftLeft)                 \
  V(JSShiftRight)                \
  V(JSShiftRightLogical)

#define JS_ARITH_BINOP_LIST(V) \
  V(JSAdd)                     \
  V(JSSubtract)                \
  V(JSMultiply)                \
  V(JSDivide)                  \
110 111
  V(JSModulus)                 \
  V(JSExponentiate)
112 113 114 115

#define JS_SIMPLE_BINOP_LIST(V) \
  JS_COMPARE_BINOP_LIST(V)      \
  JS_BITWISE_BINOP_LIST(V)      \
116
  JS_ARITH_BINOP_LIST(V)        \
117
  V(JSHasInPrototypeChain)      \
118 119
  V(JSInstanceOf)               \
  V(JSOrdinaryHasInstance)
120 121

#define JS_CONVERSION_UNOP_LIST(V) \
122
  V(JSToLength)                    \
123
  V(JSToName)                      \
124
  V(JSToNumber)                    \
125
  V(JSToNumberConvertBigInt)       \
126
  V(JSToNumeric)                   \
127
  V(JSToObject)                    \
128 129
  V(JSToString)                    \
  V(JSParseInt)
130

131 132
#define JS_SIMPLE_UNOP_LIST(V) \
  JS_CONVERSION_UNOP_LIST(V)   \
133
  V(JSBitwiseNot)              \
134 135
  V(JSDecrement)               \
  V(JSIncrement)               \
136
  V(JSNegate)
137

138
#define JS_CREATE_OP_LIST(V)     \
139
  V(JSCloneObject)               \
140 141 142
  V(JSCreate)                    \
  V(JSCreateArguments)           \
  V(JSCreateArray)               \
143
  V(JSCreateArrayFromIterable)   \
144 145 146 147 148
  V(JSCreateArrayIterator)       \
  V(JSCreateAsyncFunctionObject) \
  V(JSCreateBoundFunction)       \
  V(JSCreateClosure)             \
  V(JSCreateCollectionIterator)  \
149 150
  V(JSCreateEmptyLiteralArray)   \
  V(JSCreateEmptyLiteralObject)  \
151 152 153 154 155
  V(JSCreateGeneratorObject)     \
  V(JSCreateIterResultObject)    \
  V(JSCreateKeyValueArray)       \
  V(JSCreateLiteralArray)        \
  V(JSCreateLiteralObject)       \
156 157 158 159 160
  V(JSCreateLiteralRegExp)       \
  V(JSCreateObject)              \
  V(JSCreatePromise)             \
  V(JSCreateStringIterator)      \
  V(JSCreateTypedArray)
161

162
#define JS_OBJECT_OP_LIST(V)      \
163
  JS_CREATE_OP_LIST(V)            \
164 165 166 167 168
  V(JSLoadProperty)               \
  V(JSLoadNamed)                  \
  V(JSLoadGlobal)                 \
  V(JSStoreProperty)              \
  V(JSStoreNamed)                 \
169
  V(JSStoreNamedOwn)              \
170 171
  V(JSStoreGlobal)                \
  V(JSStoreDataPropertyInLiteral) \
172
  V(JSStoreInArrayLiteral)        \
173
  V(JSDeleteProperty)             \
174 175
  V(JSHasProperty)                \
  V(JSGetSuperConstructor)
176 177 178 179 180 181 182

#define JS_CONTEXT_OP_LIST(V) \
  V(JSLoadContext)            \
  V(JSStoreContext)           \
  V(JSCreateFunctionContext)  \
  V(JSCreateCatchContext)     \
  V(JSCreateWithContext)      \
183
  V(JSCreateBlockContext)
184

185 186 187 188 189 190
#define JS_CALL_OP_LIST(V) \
  V(JSCall)                \
  V(JSCallForwardVarargs)  \
  V(JSCallWithArrayLike)   \
  V(JSCallWithSpread)

191 192 193 194 195 196
#define JS_CONSTRUCT_OP_LIST(V) \
  V(JSConstructForwardVarargs)  \
  V(JSConstruct)                \
  V(JSConstructWithArrayLike)   \
  V(JSConstructWithSpread)

197
#define JS_OTHER_OP_LIST(V)            \
198
  JS_CALL_OP_LIST(V)                   \
199
  JS_CONSTRUCT_OP_LIST(V)              \
200 201 202
  V(JSAsyncFunctionEnter)              \
  V(JSAsyncFunctionReject)             \
  V(JSAsyncFunctionResolve)            \
203 204 205 206 207 208 209 210 211 212
  V(JSCallRuntime)                     \
  V(JSForInEnumerate)                  \
  V(JSForInNext)                       \
  V(JSForInPrepare)                    \
  V(JSLoadMessage)                     \
  V(JSStoreMessage)                    \
  V(JSLoadModule)                      \
  V(JSStoreModule)                     \
  V(JSGeneratorStore)                  \
  V(JSGeneratorRestoreContinuation)    \
213
  V(JSGeneratorRestoreContext)         \
214 215
  V(JSGeneratorRestoreRegister)        \
  V(JSGeneratorRestoreInputOrDebugPos) \
216
  V(JSFulfillPromise)                  \
217
  V(JSPerformPromiseThen)              \
218
  V(JSPromiseResolve)                  \
219 220
  V(JSRejectPromise)                   \
  V(JSResolvePromise)                  \
221
  V(JSStackCheck)                      \
222
  V(JSObjectIsArray)                   \
223
  V(JSRegExpTest)                      \
224
  V(JSDebugger)
225 226 227 228 229 230 231 232

#define JS_OP_LIST(V)     \
  JS_SIMPLE_BINOP_LIST(V) \
  JS_SIMPLE_UNOP_LIST(V)  \
  JS_OBJECT_OP_LIST(V)    \
  JS_CONTEXT_OP_LIST(V)   \
  JS_OTHER_OP_LIST(V)

233
// Opcodes for VirtuaMachine-level operators.
234 235
#define SIMPLIFIED_CHANGE_OP_LIST(V) \
  V(ChangeTaggedSignedToInt32)       \
236
  V(ChangeTaggedSignedToInt64)       \
237
  V(ChangeTaggedToInt32)             \
238
  V(ChangeTaggedToInt64)             \
239 240
  V(ChangeTaggedToUint32)            \
  V(ChangeTaggedToFloat64)           \
241
  V(ChangeTaggedToTaggedSigned)      \
242 243
  V(ChangeCompressedToTaggedSigned)  \
  V(ChangeTaggedToCompressedSigned)  \
244 245
  V(ChangeInt31ToTaggedSigned)       \
  V(ChangeInt32ToTagged)             \
246
  V(ChangeInt64ToTagged)             \
247
  V(ChangeUint32ToTagged)            \
248
  V(ChangeUint64ToTagged)            \
249
  V(ChangeFloat64ToTagged)           \
250
  V(ChangeFloat64ToTaggedPointer)    \
251 252 253
  V(ChangeTaggedToBit)               \
  V(ChangeBitToTagged)               \
  V(TruncateTaggedToWord32)          \
254
  V(TruncateTaggedToFloat64)         \
255 256
  V(TruncateTaggedToBit)             \
  V(TruncateTaggedPointerToBit)
257 258 259 260

#define SIMPLIFIED_CHECKED_OP_LIST(V) \
  V(CheckedInt32Add)                  \
  V(CheckedInt32Sub)                  \
261 262
  V(CheckedInt32Div)                  \
  V(CheckedInt32Mod)                  \
263 264
  V(CheckedUint32Div)                 \
  V(CheckedUint32Mod)                 \
265
  V(CheckedInt32Mul)                  \
266
  V(CheckedInt32ToTaggedSigned)       \
267 268
  V(CheckedInt64ToInt32)              \
  V(CheckedInt64ToTaggedSigned)       \
269
  V(CheckedUint32Bounds)              \
270
  V(CheckedUint32ToInt32)             \
271
  V(CheckedUint32ToTaggedSigned)      \
272
  V(CheckedUint64Bounds)              \
273 274
  V(CheckedUint64ToInt32)             \
  V(CheckedUint64ToTaggedSigned)      \
275
  V(CheckedFloat64ToInt32)            \
276
  V(CheckedFloat64ToInt64)            \
277
  V(CheckedTaggedSignedToInt32)       \
278
  V(CheckedTaggedToInt32)             \
279
  V(CheckedTruncateTaggedToWord32)    \
280
  V(CheckedTaggedToFloat64)           \
281
  V(CheckedTaggedToInt64)             \
282
  V(CheckedTaggedToTaggedSigned)      \
283 284 285 286 287
  V(CheckedTaggedToTaggedPointer)     \
  V(CheckedCompressedToTaggedSigned)  \
  V(CheckedCompressedToTaggedPointer) \
  V(CheckedTaggedToCompressedSigned)  \
  V(CheckedTaggedToCompressedPointer)
288

289 290 291 292
#define SIMPLIFIED_COMPARE_BINOP_LIST(V) \
  V(NumberEqual)                         \
  V(NumberLessThan)                      \
  V(NumberLessThanOrEqual)               \
293 294 295
  V(SpeculativeNumberEqual)              \
  V(SpeculativeNumberLessThan)           \
  V(SpeculativeNumberLessThanOrEqual)    \
296
  V(ReferenceEqual)                      \
297
  V(SameValue)                           \
298
  V(SameValueNumbersOnly)                \
299
  V(NumberSameValue)                     \
300 301 302 303
  V(StringEqual)                         \
  V(StringLessThan)                      \
  V(StringLessThanOrEqual)

304
#define SIMPLIFIED_NUMBER_BINOP_LIST(V) \
305 306 307 308 309 310 311 312 313
  V(NumberAdd)                          \
  V(NumberSubtract)                     \
  V(NumberMultiply)                     \
  V(NumberDivide)                       \
  V(NumberModulus)                      \
  V(NumberBitwiseOr)                    \
  V(NumberBitwiseXor)                   \
  V(NumberBitwiseAnd)                   \
  V(NumberShiftLeft)                    \
314 315
  V(NumberShiftRight)                   \
  V(NumberShiftRightLogical)            \
316
  V(NumberAtan2)                        \
317
  V(NumberImul)                         \
318 319
  V(NumberMax)                          \
  V(NumberMin)                          \
320 321 322 323 324 325 326 327 328 329 330 331 332
  V(NumberPow)

#define SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(V) \
  V(SpeculativeNumberAdd)                           \
  V(SpeculativeNumberSubtract)                      \
  V(SpeculativeNumberMultiply)                      \
  V(SpeculativeNumberDivide)                        \
  V(SpeculativeNumberModulus)                       \
  V(SpeculativeNumberBitwiseAnd)                    \
  V(SpeculativeNumberBitwiseOr)                     \
  V(SpeculativeNumberBitwiseXor)                    \
  V(SpeculativeNumberShiftLeft)                     \
  V(SpeculativeNumberShiftRight)                    \
333 334 335
  V(SpeculativeNumberShiftRightLogical)             \
  V(SpeculativeSafeIntegerAdd)                      \
  V(SpeculativeSafeIntegerSubtract)
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365

#define SIMPLIFIED_NUMBER_UNOP_LIST(V) \
  V(NumberAbs)                         \
  V(NumberAcos)                        \
  V(NumberAcosh)                       \
  V(NumberAsin)                        \
  V(NumberAsinh)                       \
  V(NumberAtan)                        \
  V(NumberAtanh)                       \
  V(NumberCbrt)                        \
  V(NumberCeil)                        \
  V(NumberClz32)                       \
  V(NumberCos)                         \
  V(NumberCosh)                        \
  V(NumberExp)                         \
  V(NumberExpm1)                       \
  V(NumberFloor)                       \
  V(NumberFround)                      \
  V(NumberLog)                         \
  V(NumberLog1p)                       \
  V(NumberLog2)                        \
  V(NumberLog10)                       \
  V(NumberRound)                       \
  V(NumberSign)                        \
  V(NumberSin)                         \
  V(NumberSinh)                        \
  V(NumberSqrt)                        \
  V(NumberTan)                         \
  V(NumberTanh)                        \
  V(NumberTrunc)                       \
366
  V(NumberToBoolean)                   \
367
  V(NumberToInt32)                     \
368
  V(NumberToString)                    \
369
  V(NumberToUint32)                    \
370
  V(NumberToUint8Clamped)              \
371 372
  V(NumberSilenceNaN)

373 374
#define SIMPLIFIED_SPECULATIVE_NUMBER_UNOP_LIST(V) V(SpeculativeToNumber)

375 376 377 378 379
#define SIMPLIFIED_OTHER_OP_LIST(V)     \
  V(PlainPrimitiveToNumber)             \
  V(PlainPrimitiveToWord32)             \
  V(PlainPrimitiveToFloat64)            \
  V(BooleanNot)                         \
380
  V(StringConcat)                       \
381 382
  V(StringToNumber)                     \
  V(StringCharCodeAt)                   \
383
  V(StringCodePointAt)                  \
384
  V(StringFromSingleCharCode)           \
385
  V(StringFromSingleCodePoint)          \
386
  V(StringIndexOf)                      \
387
  V(StringLength)                       \
388 389
  V(StringToLowerCaseIntl)              \
  V(StringToUpperCaseIntl)              \
390
  V(StringSubstring)                    \
391 392 393 394
  V(CheckBounds)                        \
  V(CheckIf)                            \
  V(CheckMaps)                          \
  V(CheckNumber)                        \
395
  V(CheckInternalizedString)            \
396
  V(CheckReceiver)                      \
397
  V(CheckReceiverOrNullOrUndefined)     \
398 399 400 401 402 403 404 405 406
  V(CheckString)                        \
  V(CheckSymbol)                        \
  V(CheckSmi)                           \
  V(CheckHeapObject)                    \
  V(CheckFloat64Hole)                   \
  V(CheckNotTaggedHole)                 \
  V(CheckEqualsInternalizedString)      \
  V(CheckEqualsSymbol)                  \
  V(CompareMaps)                        \
407
  V(ConvertReceiver)                    \
408 409 410
  V(ConvertTaggedHoleToUndefined)       \
  V(TypeOf)                             \
  V(Allocate)                           \
411
  V(AllocateRaw)                        \
412 413 414 415
  V(LoadFieldByIndex)                   \
  V(LoadField)                          \
  V(LoadElement)                        \
  V(LoadTypedElement)                   \
416
  V(LoadFromObject)                     \
417
  V(LoadDataViewElement)                \
418 419 420
  V(StoreField)                         \
  V(StoreElement)                       \
  V(StoreTypedElement)                  \
421
  V(StoreToObject)                      \
422
  V(StoreDataViewElement)               \
423 424 425 426 427
  V(StoreSignedSmallElement)            \
  V(TransitionAndStoreElement)          \
  V(TransitionAndStoreNumberElement)    \
  V(TransitionAndStoreNonNumberElement) \
  V(ToBoolean)                          \
428
  V(NumberIsFloat64Hole)                \
429 430
  V(NumberIsFinite)                     \
  V(ObjectIsFiniteNumber)               \
431
  V(NumberIsInteger)                    \
432 433
  V(ObjectIsSafeInteger)                \
  V(NumberIsSafeInteger)                \
434
  V(ObjectIsInteger)                    \
435
  V(ObjectIsArrayBufferView)            \
436
  V(ObjectIsBigInt)                     \
437 438 439 440
  V(ObjectIsCallable)                   \
  V(ObjectIsConstructor)                \
  V(ObjectIsDetectableCallable)         \
  V(ObjectIsMinusZero)                  \
441
  V(NumberIsMinusZero)                  \
442
  V(ObjectIsNaN)                        \
443
  V(NumberIsNaN)                        \
444 445 446 447 448 449 450 451 452 453 454 455
  V(ObjectIsNonCallable)                \
  V(ObjectIsNumber)                     \
  V(ObjectIsReceiver)                   \
  V(ObjectIsSmi)                        \
  V(ObjectIsString)                     \
  V(ObjectIsSymbol)                     \
  V(ObjectIsUndetectable)               \
  V(ArgumentsFrame)                     \
  V(ArgumentsLength)                    \
  V(NewDoubleElements)                  \
  V(NewSmiOrObjectElements)             \
  V(NewArgumentsElements)               \
456
  V(NewConsString)                      \
457
  V(DelayedStringConstant)              \
458 459 460 461 462
  V(EnsureWritableFastElements)         \
  V(MaybeGrowFastElements)              \
  V(TransitionElementsKind)             \
  V(FindOrderedHashMapEntry)            \
  V(FindOrderedHashMapEntryForInt32Key) \
463
  V(PoisonIndex)                        \
464 465
  V(RuntimeAbort)                       \
  V(DateNow)
466

467 468 469 470 471 472 473
#define SIMPLIFIED_OP_LIST(V)                 \
  SIMPLIFIED_CHANGE_OP_LIST(V)                \
  SIMPLIFIED_CHECKED_OP_LIST(V)               \
  SIMPLIFIED_COMPARE_BINOP_LIST(V)            \
  SIMPLIFIED_NUMBER_BINOP_LIST(V)             \
  SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(V) \
  SIMPLIFIED_NUMBER_UNOP_LIST(V)              \
474
  SIMPLIFIED_SPECULATIVE_NUMBER_UNOP_LIST(V)  \
475 476
  SIMPLIFIED_OTHER_OP_LIST(V)

477
// Opcodes for Machine-level operators.
478 479 480 481 482 483 484 485 486 487
#define MACHINE_COMPARE_BINOP_LIST(V) \
  V(Word32Equal)                      \
  V(Word64Equal)                      \
  V(Int32LessThan)                    \
  V(Int32LessThanOrEqual)             \
  V(Uint32LessThan)                   \
  V(Uint32LessThanOrEqual)            \
  V(Int64LessThan)                    \
  V(Int64LessThanOrEqual)             \
  V(Uint64LessThan)                   \
488
  V(Uint64LessThanOrEqual)            \
489 490 491
  V(Float32Equal)                     \
  V(Float32LessThan)                  \
  V(Float32LessThanOrEqual)           \
492 493 494 495
  V(Float64Equal)                     \
  V(Float64LessThan)                  \
  V(Float64LessThanOrEqual)

496 497 498
#define MACHINE_UNOP_32_LIST(V) \
  V(Word32Clz)                  \
  V(Word32Ctz)                  \
499
  V(Int32AbsWithOverflow)       \
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598
  V(Word32ReverseBits)          \
  V(Word32ReverseBytes)

#define MACHINE_BINOP_32_LIST(V) \
  V(Word32And)                   \
  V(Word32Or)                    \
  V(Word32Xor)                   \
  V(Word32Shl)                   \
  V(Word32Shr)                   \
  V(Word32Sar)                   \
  V(Word32Ror)                   \
  V(Int32Add)                    \
  V(Int32AddWithOverflow)        \
  V(Int32Sub)                    \
  V(Int32SubWithOverflow)        \
  V(Int32Mul)                    \
  V(Int32MulWithOverflow)        \
  V(Int32MulHigh)                \
  V(Int32Div)                    \
  V(Int32Mod)                    \
  V(Uint32Div)                   \
  V(Uint32Mod)                   \
  V(Uint32MulHigh)

#define MACHINE_BINOP_64_LIST(V) \
  V(Word64And)                   \
  V(Word64Or)                    \
  V(Word64Xor)                   \
  V(Word64Shl)                   \
  V(Word64Shr)                   \
  V(Word64Sar)                   \
  V(Word64Ror)                   \
  V(Int64Add)                    \
  V(Int64AddWithOverflow)        \
  V(Int64Sub)                    \
  V(Int64SubWithOverflow)        \
  V(Int64Mul)                    \
  V(Int64Div)                    \
  V(Int64Mod)                    \
  V(Uint64Div)                   \
  V(Uint64Mod)

#define MACHINE_FLOAT32_UNOP_LIST(V) \
  V(Float32Abs)                      \
  V(Float32Neg)                      \
  V(Float32RoundDown)                \
  V(Float32RoundTiesEven)            \
  V(Float32RoundTruncate)            \
  V(Float32RoundUp)                  \
  V(Float32Sqrt)

#define MACHINE_FLOAT32_BINOP_LIST(V) \
  V(Float32Add)                       \
  V(Float32Sub)                       \
  V(Float32Mul)                       \
  V(Float32Div)                       \
  V(Float32Max)                       \
  V(Float32Min)

#define MACHINE_FLOAT64_UNOP_LIST(V) \
  V(Float64Abs)                      \
  V(Float64Acos)                     \
  V(Float64Acosh)                    \
  V(Float64Asin)                     \
  V(Float64Asinh)                    \
  V(Float64Atan)                     \
  V(Float64Atanh)                    \
  V(Float64Cbrt)                     \
  V(Float64Cos)                      \
  V(Float64Cosh)                     \
  V(Float64Exp)                      \
  V(Float64Expm1)                    \
  V(Float64Log)                      \
  V(Float64Log1p)                    \
  V(Float64Log10)                    \
  V(Float64Log2)                     \
  V(Float64Neg)                      \
  V(Float64RoundDown)                \
  V(Float64RoundTiesAway)            \
  V(Float64RoundTiesEven)            \
  V(Float64RoundTruncate)            \
  V(Float64RoundUp)                  \
  V(Float64Sin)                      \
  V(Float64Sinh)                     \
  V(Float64Sqrt)                     \
  V(Float64Tan)                      \
  V(Float64Tanh)

#define MACHINE_FLOAT64_BINOP_LIST(V) \
  V(Float64Atan2)                     \
  V(Float64Max)                       \
  V(Float64Min)                       \
  V(Float64Add)                       \
  V(Float64Sub)                       \
  V(Float64Mul)                       \
  V(Float64Div)                       \
  V(Float64Mod)                       \
  V(Float64Pow)

599 600 601 602 603 604 605 606 607
#define MACHINE_WORD64_ATOMIC_OP_LIST(V) \
  V(Word64AtomicLoad)                    \
  V(Word64AtomicStore)                   \
  V(Word64AtomicAdd)                     \
  V(Word64AtomicSub)                     \
  V(Word64AtomicAnd)                     \
  V(Word64AtomicOr)                      \
  V(Word64AtomicXor)                     \
  V(Word64AtomicExchange)                \
608
  V(Word64AtomicCompareExchange)
609

610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718
#define MACHINE_OP_LIST(V)                  \
  MACHINE_UNOP_32_LIST(V)                   \
  MACHINE_BINOP_32_LIST(V)                  \
  MACHINE_BINOP_64_LIST(V)                  \
  MACHINE_COMPARE_BINOP_LIST(V)             \
  MACHINE_FLOAT32_BINOP_LIST(V)             \
  MACHINE_FLOAT32_UNOP_LIST(V)              \
  MACHINE_FLOAT64_BINOP_LIST(V)             \
  MACHINE_FLOAT64_UNOP_LIST(V)              \
  MACHINE_WORD64_ATOMIC_OP_LIST(V)          \
  V(DebugAbort)                             \
  V(DebugBreak)                             \
  V(Comment)                                \
  V(Load)                                   \
  V(PoisonedLoad)                           \
  V(Store)                                  \
  V(StackSlot)                              \
  V(Word32Popcnt)                           \
  V(Word64Popcnt)                           \
  V(Word64Clz)                              \
  V(Word64Ctz)                              \
  V(Word64ReverseBits)                      \
  V(Word64ReverseBytes)                     \
  V(Int64AbsWithOverflow)                   \
  V(BitcastTaggedToWord)                    \
  V(BitcastWordToTagged)                    \
  V(BitcastWordToTaggedSigned)              \
  V(TruncateFloat64ToWord32)                \
  V(ChangeFloat32ToFloat64)                 \
  V(ChangeFloat64ToInt32)                   \
  V(ChangeFloat64ToInt64)                   \
  V(ChangeFloat64ToUint32)                  \
  V(ChangeFloat64ToUint64)                  \
  V(Float64SilenceNaN)                      \
  V(TruncateFloat64ToInt64)                 \
  V(TruncateFloat64ToUint32)                \
  V(TruncateFloat32ToInt32)                 \
  V(TruncateFloat32ToUint32)                \
  V(TryTruncateFloat32ToInt64)              \
  V(TryTruncateFloat64ToInt64)              \
  V(TryTruncateFloat32ToUint64)             \
  V(TryTruncateFloat64ToUint64)             \
  V(ChangeInt32ToFloat64)                   \
  V(ChangeInt32ToInt64)                     \
  V(ChangeInt64ToFloat64)                   \
  V(ChangeUint32ToFloat64)                  \
  V(ChangeUint32ToUint64)                   \
  V(ChangeTaggedToCompressed)               \
  V(ChangeTaggedPointerToCompressedPointer) \
  V(ChangeTaggedSignedToCompressedSigned)   \
  V(ChangeCompressedToTagged)               \
  V(ChangeCompressedPointerToTaggedPointer) \
  V(ChangeCompressedSignedToTaggedSigned)   \
  V(TruncateFloat64ToFloat32)               \
  V(TruncateInt64ToInt32)                   \
  V(RoundFloat64ToInt32)                    \
  V(RoundInt32ToFloat32)                    \
  V(RoundInt64ToFloat32)                    \
  V(RoundInt64ToFloat64)                    \
  V(RoundUint32ToFloat32)                   \
  V(RoundUint64ToFloat32)                   \
  V(RoundUint64ToFloat64)                   \
  V(BitcastFloat32ToInt32)                  \
  V(BitcastFloat64ToInt64)                  \
  V(BitcastInt32ToFloat32)                  \
  V(BitcastInt64ToFloat64)                  \
  V(Float64ExtractLowWord32)                \
  V(Float64ExtractHighWord32)               \
  V(Float64InsertLowWord32)                 \
  V(Float64InsertHighWord32)                \
  V(TaggedPoisonOnSpeculation)              \
  V(Word32PoisonOnSpeculation)              \
  V(Word64PoisonOnSpeculation)              \
  V(LoadStackPointer)                       \
  V(LoadFramePointer)                       \
  V(LoadParentFramePointer)                 \
  V(UnalignedLoad)                          \
  V(UnalignedStore)                         \
  V(Int32PairAdd)                           \
  V(Int32PairSub)                           \
  V(Int32PairMul)                           \
  V(Word32PairShl)                          \
  V(Word32PairShr)                          \
  V(Word32PairSar)                          \
  V(ProtectedLoad)                          \
  V(ProtectedStore)                         \
  V(Word32AtomicLoad)                       \
  V(Word32AtomicStore)                      \
  V(Word32AtomicExchange)                   \
  V(Word32AtomicCompareExchange)            \
  V(Word32AtomicAdd)                        \
  V(Word32AtomicSub)                        \
  V(Word32AtomicAnd)                        \
  V(Word32AtomicOr)                         \
  V(Word32AtomicXor)                        \
  V(Word32AtomicPairLoad)                   \
  V(Word32AtomicPairStore)                  \
  V(Word32AtomicPairAdd)                    \
  V(Word32AtomicPairSub)                    \
  V(Word32AtomicPairAnd)                    \
  V(Word32AtomicPairOr)                     \
  V(Word32AtomicPairXor)                    \
  V(Word32AtomicPairExchange)               \
  V(Word32AtomicPairCompareExchange)        \
  V(SignExtendWord8ToInt32)                 \
  V(SignExtendWord16ToInt32)                \
  V(SignExtendWord8ToInt64)                 \
  V(SignExtendWord16ToInt64)                \
  V(SignExtendWord32ToInt64)                \
719
  V(UnsafePointerAdd)
720

721 722 723 724 725 726 727 728 729 730 731
#define MACHINE_SIMD_OP_LIST(V) \
  V(F32x4Splat)                 \
  V(F32x4ExtractLane)           \
  V(F32x4ReplaceLane)           \
  V(F32x4SConvertI32x4)         \
  V(F32x4UConvertI32x4)         \
  V(F32x4Abs)                   \
  V(F32x4Neg)                   \
  V(F32x4RecipApprox)           \
  V(F32x4RecipSqrtApprox)       \
  V(F32x4Add)                   \
732
  V(F32x4AddHoriz)              \
733 734 735 736 737 738 739 740 741 742 743 744 745 746
  V(F32x4Sub)                   \
  V(F32x4Mul)                   \
  V(F32x4Min)                   \
  V(F32x4Max)                   \
  V(F32x4Eq)                    \
  V(F32x4Ne)                    \
  V(F32x4Lt)                    \
  V(F32x4Le)                    \
  V(F32x4Gt)                    \
  V(F32x4Ge)                    \
  V(I32x4Splat)                 \
  V(I32x4ExtractLane)           \
  V(I32x4ReplaceLane)           \
  V(I32x4SConvertF32x4)         \
747 748
  V(I32x4SConvertI16x8Low)      \
  V(I32x4SConvertI16x8High)     \
749 750 751 752
  V(I32x4Neg)                   \
  V(I32x4Shl)                   \
  V(I32x4ShrS)                  \
  V(I32x4Add)                   \
753
  V(I32x4AddHoriz)              \
754 755 756 757 758 759 760 761 762 763 764
  V(I32x4Sub)                   \
  V(I32x4Mul)                   \
  V(I32x4MinS)                  \
  V(I32x4MaxS)                  \
  V(I32x4Eq)                    \
  V(I32x4Ne)                    \
  V(I32x4LtS)                   \
  V(I32x4LeS)                   \
  V(I32x4GtS)                   \
  V(I32x4GeS)                   \
  V(I32x4UConvertF32x4)         \
765 766
  V(I32x4UConvertI16x8Low)      \
  V(I32x4UConvertI16x8High)     \
767 768 769 770 771 772 773 774 775 776
  V(I32x4ShrU)                  \
  V(I32x4MinU)                  \
  V(I32x4MaxU)                  \
  V(I32x4LtU)                   \
  V(I32x4LeU)                   \
  V(I32x4GtU)                   \
  V(I32x4GeU)                   \
  V(I16x8Splat)                 \
  V(I16x8ExtractLane)           \
  V(I16x8ReplaceLane)           \
777 778
  V(I16x8SConvertI8x16Low)      \
  V(I16x8SConvertI8x16High)     \
779 780 781
  V(I16x8Neg)                   \
  V(I16x8Shl)                   \
  V(I16x8ShrS)                  \
782
  V(I16x8SConvertI32x4)         \
783 784
  V(I16x8Add)                   \
  V(I16x8AddSaturateS)          \
785
  V(I16x8AddHoriz)              \
786 787 788 789 790 791 792 793 794 795 796
  V(I16x8Sub)                   \
  V(I16x8SubSaturateS)          \
  V(I16x8Mul)                   \
  V(I16x8MinS)                  \
  V(I16x8MaxS)                  \
  V(I16x8Eq)                    \
  V(I16x8Ne)                    \
  V(I16x8LtS)                   \
  V(I16x8LeS)                   \
  V(I16x8GtS)                   \
  V(I16x8GeS)                   \
797 798 799 800
  V(I16x8UConvertI8x16Low)      \
  V(I16x8UConvertI8x16High)     \
  V(I16x8ShrU)                  \
  V(I16x8UConvertI32x4)         \
801 802 803 804 805 806 807 808 809 810 811
  V(I16x8AddSaturateU)          \
  V(I16x8SubSaturateU)          \
  V(I16x8MinU)                  \
  V(I16x8MaxU)                  \
  V(I16x8LtU)                   \
  V(I16x8LeU)                   \
  V(I16x8GtU)                   \
  V(I16x8GeU)                   \
  V(I8x16Splat)                 \
  V(I8x16ExtractLane)           \
  V(I8x16ReplaceLane)           \
812
  V(I8x16SConvertI16x8)         \
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828
  V(I8x16Neg)                   \
  V(I8x16Shl)                   \
  V(I8x16ShrS)                  \
  V(I8x16Add)                   \
  V(I8x16AddSaturateS)          \
  V(I8x16Sub)                   \
  V(I8x16SubSaturateS)          \
  V(I8x16Mul)                   \
  V(I8x16MinS)                  \
  V(I8x16MaxS)                  \
  V(I8x16Eq)                    \
  V(I8x16Ne)                    \
  V(I8x16LtS)                   \
  V(I8x16LeS)                   \
  V(I8x16GtS)                   \
  V(I8x16GeS)                   \
829
  V(I8x16UConvertI16x8)         \
830 831 832 833 834 835 836 837 838 839 840 841
  V(I8x16AddSaturateU)          \
  V(I8x16SubSaturateU)          \
  V(I8x16ShrU)                  \
  V(I8x16MinU)                  \
  V(I8x16MaxU)                  \
  V(I8x16LtU)                   \
  V(I8x16LeU)                   \
  V(I8x16GtU)                   \
  V(I8x16GeU)                   \
  V(S128Load)                   \
  V(S128Store)                  \
  V(S128Zero)                   \
842
  V(S128Not)                    \
843 844 845
  V(S128And)                    \
  V(S128Or)                     \
  V(S128Xor)                    \
846
  V(S128Select)                 \
847
  V(S8x16Shuffle)               \
848 849 850 851 852 853
  V(S1x4AnyTrue)                \
  V(S1x4AllTrue)                \
  V(S1x8AnyTrue)                \
  V(S1x8AllTrue)                \
  V(S1x16AnyTrue)               \
  V(S1x16AllTrue)
854 855 856 857 858 859

#define VALUE_OP_LIST(V)  \
  COMMON_OP_LIST(V)       \
  SIMPLIFIED_OP_LIST(V)   \
  MACHINE_OP_LIST(V)      \
  MACHINE_SIMD_OP_LIST(V) \
860 861 862 863 864 865 866 867 868 869 870 871 872
  JS_OP_LIST(V)

// The combination of all operators at all levels and the common operators.
#define ALL_OP_LIST(V) \
  CONTROL_OP_LIST(V)   \
  VALUE_OP_LIST(V)

namespace v8 {
namespace internal {
namespace compiler {

// Declare an enumeration with all the opcodes at all levels so that they
// can be globally, uniquely numbered.
873
class V8_EXPORT_PRIVATE IrOpcode {
874 875 876 877 878 879 880 881 882 883 884 885
 public:
  enum Value {
#define DECLARE_OPCODE(x) k##x,
    ALL_OP_LIST(DECLARE_OPCODE)
#undef DECLARE_OPCODE
    kLast = -1
#define COUNT_OPCODE(x) +1
            ALL_OP_LIST(COUNT_OPCODE)
#undef COUNT_OPCODE
  };

  // Returns the mnemonic name of an opcode.
886
  static char const* Mnemonic(Value value);
887

888 889
  // Returns true if opcode for common operator.
  static bool IsCommonOpcode(Value value) {
890
    return kStart <= value && value <= kStaticAssert;
891 892
  }

893 894
  // Returns true if opcode for control operator.
  static bool IsControlOpcode(Value value) {
895
    return kStart <= value && value <= kEnd;
896 897
  }

898 899
  // Returns true if opcode for JavaScript operator.
  static bool IsJsOpcode(Value value) {
900
    return kJSEqual <= value && value <= kJSDebugger;
901 902
  }

903 904
  // Returns true if opcode for constant operator.
  static bool IsConstantOpcode(Value value) {
905
    return kInt32Constant <= value && value <= kRelocatableInt64Constant;
906
  }
907

908 909 910 911 912 913
  static bool IsPhiOpcode(Value value) {
    return value == kPhi || value == kEffectPhi;
  }

  static bool IsMergeOpcode(Value value) {
    return value == kMerge || value == kLoop;
914
  }
915

916 917 918 919
  static bool IsIfProjectionOpcode(Value value) {
    return kIfTrue <= value && value <= kIfDefault;
  }

920 921 922 923 924 925 926
  // Returns true if opcode terminates control flow in a graph (i.e. respective
  // nodes are expected to have control uses by the graphs {End} node only).
  static bool IsGraphTerminator(Value value) {
    return value == kDeoptimize || value == kReturn || value == kTailCall ||
           value == kTerminate || value == kThrow;
  }

927 928
  // Returns true if opcode can be inlined.
  static bool IsInlineeOpcode(Value value) {
929
    return value == kJSConstruct || value == kJSCall;
930 931
  }

932 933 934 935 936 937
  // Returns true if opcode for comparison operator.
  static bool IsComparisonOpcode(Value value) {
    return (kJSEqual <= value && value <= kJSGreaterThanOrEqual) ||
           (kNumberEqual <= value && value <= kStringLessThanOrEqual) ||
           (kWord32Equal <= value && value <= kFloat64LessThanOrEqual);
  }
938

939 940 941 942 943 944 945 946 947 948 949 950
  // Returns true if opcode for decompress operator.
  static bool IsDecompressOpcode(Value value) {
    return kChangeCompressedToTagged <= value &&
           value <= kChangeCompressedSignedToTaggedSigned;
  }

  // Returns true if opcode for compress operator.
  static bool IsCompressOpcode(Value value) {
    return kChangeTaggedToCompressed <= value &&
           value <= kChangeTaggedSignedToCompressedSigned;
  }

951
  static bool IsContextChainExtendingOpcode(Value value) {
952
    return kJSCreateFunctionContext <= value && value <= kJSCreateBlockContext;
953
  }
954 955
};

956
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, IrOpcode::Value);
957

958 959 960 961 962
}  // namespace compiler
}  // namespace internal
}  // namespace v8

#endif  // V8_COMPILER_OPCODES_H_