opcodes.h 31.8 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 11
#include "src/globals.h"

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 48 49
  V(HeapConstant)             \
  V(RelocatableInt32Constant) \
  V(RelocatableInt64Constant)
50

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
#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)                     \
77
  V(TypeGuard)
78 79

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

// 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)                  \
108 109
  V(JSModulus)                 \
  V(JSExponentiate)
110 111 112 113

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

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

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

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

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

#define JS_CONTEXT_OP_LIST(V) \
  V(JSLoadContext)            \
  V(JSStoreContext)           \
  V(JSCreateFunctionContext)  \
  V(JSCreateCatchContext)     \
  V(JSCreateWithContext)      \
181
  V(JSCreateBlockContext)
182

183 184 185 186 187 188
#define JS_CALL_OP_LIST(V) \
  V(JSCall)                \
  V(JSCallForwardVarargs)  \
  V(JSCallWithArrayLike)   \
  V(JSCallWithSpread)

189 190 191 192 193 194
#define JS_CONSTRUCT_OP_LIST(V) \
  V(JSConstructForwardVarargs)  \
  V(JSConstruct)                \
  V(JSConstructWithArrayLike)   \
  V(JSConstructWithSpread)

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

#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)

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

#define SIMPLIFIED_CHECKED_OP_LIST(V) \
  V(CheckedInt32Add)                  \
  V(CheckedInt32Sub)                  \
257 258
  V(CheckedInt32Div)                  \
  V(CheckedInt32Mod)                  \
259 260
  V(CheckedUint32Div)                 \
  V(CheckedUint32Mod)                 \
261
  V(CheckedInt32Mul)                  \
262
  V(CheckedInt32ToTaggedSigned)       \
263 264
  V(CheckedInt64ToInt32)              \
  V(CheckedInt64ToTaggedSigned)       \
265
  V(CheckedUint32Bounds)              \
266
  V(CheckedUint32ToInt32)             \
267
  V(CheckedUint32ToTaggedSigned)      \
268
  V(CheckedUint64Bounds)              \
269 270
  V(CheckedUint64ToInt32)             \
  V(CheckedUint64ToTaggedSigned)      \
271
  V(CheckedFloat64ToInt32)            \
272
  V(CheckedFloat64ToInt64)            \
273
  V(CheckedTaggedSignedToInt32)       \
274
  V(CheckedTaggedToInt32)             \
275
  V(CheckedTruncateTaggedToWord32)    \
276
  V(CheckedTaggedToFloat64)           \
277
  V(CheckedTaggedToInt64)             \
278
  V(CheckedTaggedToTaggedSigned)      \
279
  V(CheckedTaggedToTaggedPointer)
280

281 282 283 284
#define SIMPLIFIED_COMPARE_BINOP_LIST(V) \
  V(NumberEqual)                         \
  V(NumberLessThan)                      \
  V(NumberLessThanOrEqual)               \
285 286 287
  V(SpeculativeNumberEqual)              \
  V(SpeculativeNumberLessThan)           \
  V(SpeculativeNumberLessThanOrEqual)    \
288
  V(ReferenceEqual)                      \
289
  V(SameValue)                           \
290 291 292 293
  V(StringEqual)                         \
  V(StringLessThan)                      \
  V(StringLessThanOrEqual)

294
#define SIMPLIFIED_NUMBER_BINOP_LIST(V) \
295 296 297 298 299 300 301 302 303
  V(NumberAdd)                          \
  V(NumberSubtract)                     \
  V(NumberMultiply)                     \
  V(NumberDivide)                       \
  V(NumberModulus)                      \
  V(NumberBitwiseOr)                    \
  V(NumberBitwiseXor)                   \
  V(NumberBitwiseAnd)                   \
  V(NumberShiftLeft)                    \
304 305
  V(NumberShiftRight)                   \
  V(NumberShiftRightLogical)            \
306
  V(NumberAtan2)                        \
307
  V(NumberImul)                         \
308 309
  V(NumberMax)                          \
  V(NumberMin)                          \
310 311 312 313 314 315 316 317 318 319 320 321 322
  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)                    \
323 324 325
  V(SpeculativeNumberShiftRightLogical)             \
  V(SpeculativeSafeIntegerAdd)                      \
  V(SpeculativeSafeIntegerSubtract)
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355

#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)                       \
356
  V(NumberToBoolean)                   \
357
  V(NumberToInt32)                     \
358
  V(NumberToString)                    \
359
  V(NumberToUint32)                    \
360
  V(NumberToUint8Clamped)              \
361 362
  V(NumberSilenceNaN)

363 364
#define SIMPLIFIED_SPECULATIVE_NUMBER_UNOP_LIST(V) V(SpeculativeToNumber)

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

457 458 459 460 461 462 463
#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)              \
464
  SIMPLIFIED_SPECULATIVE_NUMBER_UNOP_LIST(V)  \
465 466
  SIMPLIFIED_OTHER_OP_LIST(V)

467
// Opcodes for Machine-level operators.
468 469 470 471 472 473 474 475 476 477
#define MACHINE_COMPARE_BINOP_LIST(V) \
  V(Word32Equal)                      \
  V(Word64Equal)                      \
  V(Int32LessThan)                    \
  V(Int32LessThanOrEqual)             \
  V(Uint32LessThan)                   \
  V(Uint32LessThanOrEqual)            \
  V(Int64LessThan)                    \
  V(Int64LessThanOrEqual)             \
  V(Uint64LessThan)                   \
478
  V(Uint64LessThanOrEqual)            \
479 480 481
  V(Float32Equal)                     \
  V(Float32LessThan)                  \
  V(Float32LessThanOrEqual)           \
482 483 484 485
  V(Float64Equal)                     \
  V(Float64LessThan)                  \
  V(Float64LessThanOrEqual)

486 487 488
#define MACHINE_UNOP_32_LIST(V) \
  V(Word32Clz)                  \
  V(Word32Ctz)                  \
489
  V(Int32AbsWithOverflow)       \
490 491 492 493 494 495 496 497 498 499 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
  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)

589 590 591 592 593 594 595 596 597
#define MACHINE_WORD64_ATOMIC_OP_LIST(V) \
  V(Word64AtomicLoad)                    \
  V(Word64AtomicStore)                   \
  V(Word64AtomicAdd)                     \
  V(Word64AtomicSub)                     \
  V(Word64AtomicAnd)                     \
  V(Word64AtomicOr)                      \
  V(Word64AtomicXor)                     \
  V(Word64AtomicExchange)                \
598
  V(Word64AtomicCompareExchange)
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629

#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)            \
630
  V(ChangeFloat64ToInt64)            \
631 632 633
  V(ChangeFloat64ToUint32)           \
  V(ChangeFloat64ToUint64)           \
  V(Float64SilenceNaN)               \
634
  V(TruncateFloat64ToInt64)          \
635 636 637 638 639 640 641 642 643
  V(TruncateFloat64ToUint32)         \
  V(TruncateFloat32ToInt32)          \
  V(TruncateFloat32ToUint32)         \
  V(TryTruncateFloat32ToInt64)       \
  V(TryTruncateFloat64ToInt64)       \
  V(TryTruncateFloat32ToUint64)      \
  V(TryTruncateFloat64ToUint64)      \
  V(ChangeInt32ToFloat64)            \
  V(ChangeInt32ToInt64)              \
644
  V(ChangeInt64ToFloat64)            \
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
  V(ChangeUint32ToFloat64)           \
  V(ChangeUint32ToUint64)            \
  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)                 \
689 690
  V(Word32AtomicPairLoad)            \
  V(Word32AtomicPairStore)           \
691 692 693 694 695 696 697 698 699 700 701 702 703
  V(Word32AtomicPairAdd)             \
  V(Word32AtomicPairSub)             \
  V(Word32AtomicPairAnd)             \
  V(Word32AtomicPairOr)              \
  V(Word32AtomicPairXor)             \
  V(Word32AtomicPairExchange)        \
  V(Word32AtomicPairCompareExchange) \
  V(SpeculationFence)                \
  V(SignExtendWord8ToInt32)          \
  V(SignExtendWord16ToInt32)         \
  V(SignExtendWord8ToInt64)          \
  V(SignExtendWord16ToInt64)         \
  V(SignExtendWord32ToInt64)         \
704
  V(UnsafePointerAdd)
705

706 707 708 709 710 711 712 713 714 715 716
#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)                   \
717
  V(F32x4AddHoriz)              \
718 719 720 721 722 723 724 725 726 727 728 729 730 731
  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)         \
732 733
  V(I32x4SConvertI16x8Low)      \
  V(I32x4SConvertI16x8High)     \
734 735 736 737
  V(I32x4Neg)                   \
  V(I32x4Shl)                   \
  V(I32x4ShrS)                  \
  V(I32x4Add)                   \
738
  V(I32x4AddHoriz)              \
739 740 741 742 743 744 745 746 747 748 749
  V(I32x4Sub)                   \
  V(I32x4Mul)                   \
  V(I32x4MinS)                  \
  V(I32x4MaxS)                  \
  V(I32x4Eq)                    \
  V(I32x4Ne)                    \
  V(I32x4LtS)                   \
  V(I32x4LeS)                   \
  V(I32x4GtS)                   \
  V(I32x4GeS)                   \
  V(I32x4UConvertF32x4)         \
750 751
  V(I32x4UConvertI16x8Low)      \
  V(I32x4UConvertI16x8High)     \
752 753 754 755 756 757 758 759 760 761
  V(I32x4ShrU)                  \
  V(I32x4MinU)                  \
  V(I32x4MaxU)                  \
  V(I32x4LtU)                   \
  V(I32x4LeU)                   \
  V(I32x4GtU)                   \
  V(I32x4GeU)                   \
  V(I16x8Splat)                 \
  V(I16x8ExtractLane)           \
  V(I16x8ReplaceLane)           \
762 763
  V(I16x8SConvertI8x16Low)      \
  V(I16x8SConvertI8x16High)     \
764 765 766
  V(I16x8Neg)                   \
  V(I16x8Shl)                   \
  V(I16x8ShrS)                  \
767
  V(I16x8SConvertI32x4)         \
768 769
  V(I16x8Add)                   \
  V(I16x8AddSaturateS)          \
770
  V(I16x8AddHoriz)              \
771 772 773 774 775 776 777 778 779 780 781
  V(I16x8Sub)                   \
  V(I16x8SubSaturateS)          \
  V(I16x8Mul)                   \
  V(I16x8MinS)                  \
  V(I16x8MaxS)                  \
  V(I16x8Eq)                    \
  V(I16x8Ne)                    \
  V(I16x8LtS)                   \
  V(I16x8LeS)                   \
  V(I16x8GtS)                   \
  V(I16x8GeS)                   \
782 783 784 785
  V(I16x8UConvertI8x16Low)      \
  V(I16x8UConvertI8x16High)     \
  V(I16x8ShrU)                  \
  V(I16x8UConvertI32x4)         \
786 787 788 789 790 791 792 793 794 795 796
  V(I16x8AddSaturateU)          \
  V(I16x8SubSaturateU)          \
  V(I16x8MinU)                  \
  V(I16x8MaxU)                  \
  V(I16x8LtU)                   \
  V(I16x8LeU)                   \
  V(I16x8GtU)                   \
  V(I16x8GeU)                   \
  V(I8x16Splat)                 \
  V(I8x16ExtractLane)           \
  V(I8x16ReplaceLane)           \
797
  V(I8x16SConvertI16x8)         \
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813
  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)                   \
814
  V(I8x16UConvertI16x8)         \
815 816 817 818 819 820 821 822 823 824 825 826
  V(I8x16AddSaturateU)          \
  V(I8x16SubSaturateU)          \
  V(I8x16ShrU)                  \
  V(I8x16MinU)                  \
  V(I8x16MaxU)                  \
  V(I8x16LtU)                   \
  V(I8x16LeU)                   \
  V(I8x16GtU)                   \
  V(I8x16GeU)                   \
  V(S128Load)                   \
  V(S128Store)                  \
  V(S128Zero)                   \
827
  V(S128Not)                    \
828 829 830
  V(S128And)                    \
  V(S128Or)                     \
  V(S128Xor)                    \
831
  V(S128Select)                 \
832
  V(S8x16Shuffle)               \
833 834 835 836 837 838
  V(S1x4AnyTrue)                \
  V(S1x4AllTrue)                \
  V(S1x8AnyTrue)                \
  V(S1x8AllTrue)                \
  V(S1x16AnyTrue)               \
  V(S1x16AllTrue)
839 840 841 842 843 844

#define VALUE_OP_LIST(V)  \
  COMMON_OP_LIST(V)       \
  SIMPLIFIED_OP_LIST(V)   \
  MACHINE_OP_LIST(V)      \
  MACHINE_SIMD_OP_LIST(V) \
845 846 847 848 849 850 851 852 853 854 855 856 857
  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.
858
class V8_EXPORT_PRIVATE IrOpcode {
859 860 861 862 863 864 865 866 867 868 869 870
 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.
871
  static char const* Mnemonic(Value value);
872

873 874
  // Returns true if opcode for common operator.
  static bool IsCommonOpcode(Value value) {
875
    return kStart <= value && value <= kDead;
876 877
  }

878 879
  // Returns true if opcode for control operator.
  static bool IsControlOpcode(Value value) {
880
    return kStart <= value && value <= kEnd;
881 882
  }

883 884
  // Returns true if opcode for JavaScript operator.
  static bool IsJsOpcode(Value value) {
885
    return kJSEqual <= value && value <= kJSDebugger;
886 887
  }

888 889
  // Returns true if opcode for constant operator.
  static bool IsConstantOpcode(Value value) {
890
    return kInt32Constant <= value && value <= kRelocatableInt64Constant;
891
  }
892

893 894 895 896 897 898
  static bool IsPhiOpcode(Value value) {
    return value == kPhi || value == kEffectPhi;
  }

  static bool IsMergeOpcode(Value value) {
    return value == kMerge || value == kLoop;
899
  }
900

901 902 903 904
  static bool IsIfProjectionOpcode(Value value) {
    return kIfTrue <= value && value <= kIfDefault;
  }

905 906 907 908 909 910 911
  // 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;
  }

912 913
  // Returns true if opcode can be inlined.
  static bool IsInlineeOpcode(Value value) {
914
    return value == kJSConstruct || value == kJSCall;
915 916
  }

917 918 919 920 921 922
  // 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);
  }
923 924

  static bool IsContextChainExtendingOpcode(Value value) {
925
    return kJSCreateFunctionContext <= value && value <= kJSCreateBlockContext;
926
  }
927 928
};

929
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, IrOpcode::Value);
930

931 932 933 934 935
}  // namespace compiler
}  // namespace internal
}  // namespace v8

#endif  // V8_COMPILER_OPCODES_H_