opcodes.h 22.1 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
// Opcodes for control operators.
11 12
#define CONTROL_OP_LIST(V) \
  V(Start)                 \
13 14 15 16 17 18 19 20 21 22 23
  V(Loop)                  \
  V(Branch)                \
  V(Switch)                \
  V(IfTrue)                \
  V(IfFalse)               \
  V(IfSuccess)             \
  V(IfException)           \
  V(IfValue)               \
  V(IfDefault)             \
  V(Merge)                 \
  V(Deoptimize)            \
24 25
  V(DeoptimizeIf)          \
  V(DeoptimizeUnless)      \
26
  V(Return)                \
27
  V(TailCall)              \
28
  V(Terminate)             \
29 30 31
  V(OsrNormalEntry)        \
  V(OsrLoopEntry)          \
  V(Throw)                 \
32 33
  V(End)

34
// Opcodes for constant operators.
35 36 37 38 39 40 41 42 43 44
#define CONSTANT_OP_LIST(V)   \
  V(Int32Constant)            \
  V(Int64Constant)            \
  V(Float32Constant)          \
  V(Float64Constant)          \
  V(ExternalConstant)         \
  V(NumberConstant)           \
  V(HeapConstant)             \
  V(RelocatableInt32Constant) \
  V(RelocatableInt64Constant)
45 46

#define INNER_OP_LIST(V) \
47
  V(Select)              \
48 49
  V(Phi)                 \
  V(EffectPhi)           \
50
  V(Checkpoint)          \
51 52
  V(BeginRegion)         \
  V(FinishRegion)        \
53
  V(FrameState)          \
54
  V(StateValues)         \
55
  V(TypedStateValues)    \
56
  V(ObjectState)         \
57
  V(Call)                \
58
  V(Parameter)           \
59
  V(OsrValue)            \
60 61 62
  V(Projection)

#define COMMON_OP_LIST(V) \
63
  CONSTANT_OP_LIST(V)     \
64
  INNER_OP_LIST(V)        \
65
  V(Dead)
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

// Opcodes for JavaScript operators.
#define JS_COMPARE_BINOP_LIST(V) \
  V(JSEqual)                     \
  V(JSNotEqual)                  \
  V(JSStrictEqual)               \
  V(JSStrictNotEqual)            \
  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)                  \
  V(JSModulus)

#define JS_SIMPLE_BINOP_LIST(V) \
  JS_COMPARE_BINOP_LIST(V)      \
  JS_BITWISE_BINOP_LIST(V)      \
  JS_ARITH_BINOP_LIST(V)

#define JS_CONVERSION_UNOP_LIST(V) \
  V(JSToBoolean)                   \
100 101
  V(JSToInteger)                   \
  V(JSToLength)                    \
102
  V(JSToName)                      \
103 104 105
  V(JSToNumber)                    \
  V(JSToObject)                    \
  V(JSToString)
106

107 108
#define JS_OTHER_UNOP_LIST(V) \
  V(JSTypeOf)
109 110 111 112 113

#define JS_SIMPLE_UNOP_LIST(V) \
  JS_CONVERSION_UNOP_LIST(V)   \
  JS_OTHER_UNOP_LIST(V)

114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
#define JS_OBJECT_OP_LIST(V)  \
  V(JSCreate)                 \
  V(JSCreateArguments)        \
  V(JSCreateArray)            \
  V(JSCreateClosure)          \
  V(JSCreateIterResultObject) \
  V(JSCreateLiteralArray)     \
  V(JSCreateLiteralObject)    \
  V(JSCreateLiteralRegExp)    \
  V(JSLoadProperty)           \
  V(JSLoadNamed)              \
  V(JSLoadGlobal)             \
  V(JSStoreProperty)          \
  V(JSStoreNamed)             \
  V(JSStoreGlobal)            \
  V(JSDeleteProperty)         \
  V(JSHasProperty)            \
131 132 133 134 135 136 137 138 139 140
  V(JSInstanceOf)

#define JS_CONTEXT_OP_LIST(V) \
  V(JSLoadContext)            \
  V(JSStoreContext)           \
  V(JSCreateFunctionContext)  \
  V(JSCreateCatchContext)     \
  V(JSCreateWithContext)      \
  V(JSCreateBlockContext)     \
  V(JSCreateModuleContext)    \
141
  V(JSCreateScriptContext)
142

143 144 145 146 147 148 149 150 151 152 153 154 155 156
#define JS_OTHER_OP_LIST(V)         \
  V(JSCallConstruct)                \
  V(JSCallFunction)                 \
  V(JSCallRuntime)                  \
  V(JSConvertReceiver)              \
  V(JSForInDone)                    \
  V(JSForInNext)                    \
  V(JSForInPrepare)                 \
  V(JSForInStep)                    \
  V(JSLoadMessage)                  \
  V(JSStoreMessage)                 \
  V(JSGeneratorStore)               \
  V(JSGeneratorRestoreContinuation) \
  V(JSGeneratorRestoreRegister)     \
157
  V(JSStackCheck)
158 159 160 161 162 163 164 165

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

166
// Opcodes for VirtuaMachine-level operators.
167 168 169 170 171 172 173 174 175 176 177 178 179
#define SIMPLIFIED_COMPARE_BINOP_LIST(V) \
  V(NumberEqual)                         \
  V(NumberLessThan)                      \
  V(NumberLessThanOrEqual)               \
  V(ReferenceEqual)                      \
  V(StringEqual)                         \
  V(StringLessThan)                      \
  V(StringLessThanOrEqual)

#define SIMPLIFIED_OP_LIST(V)      \
  SIMPLIFIED_COMPARE_BINOP_LIST(V) \
  V(BooleanNot)                    \
  V(BooleanToNumber)               \
180 181
  V(SpeculativeNumberAdd)          \
  V(SpeculativeNumberSubtract)     \
182 183 184 185 186
  V(NumberAdd)                     \
  V(NumberSubtract)                \
  V(NumberMultiply)                \
  V(NumberDivide)                  \
  V(NumberModulus)                 \
187 188 189
  V(NumberBitwiseOr)               \
  V(NumberBitwiseXor)              \
  V(NumberBitwiseAnd)              \
190 191 192
  V(NumberShiftLeft)               \
  V(NumberShiftRight)              \
  V(NumberShiftRightLogical)       \
193
  V(NumberImul)                    \
194
  V(NumberClz32)                   \
195
  V(NumberCeil)                    \
196
  V(NumberFloor)                   \
197
  V(NumberLog)                     \
198 199
  V(NumberRound)                   \
  V(NumberTrunc)                   \
200 201
  V(NumberToInt32)                 \
  V(NumberToUint32)                \
202
  V(NumberIsHoleNaN)               \
203
  V(StringFromCharCode)            \
204
  V(StringToNumber)                \
205
  V(ChangeTaggedSignedToInt32)     \
206 207 208
  V(ChangeTaggedToInt32)           \
  V(ChangeTaggedToUint32)          \
  V(ChangeTaggedToFloat64)         \
209
  V(ChangeInt31ToTaggedSigned)     \
210 211 212
  V(ChangeInt32ToTagged)           \
  V(ChangeUint32ToTagged)          \
  V(ChangeFloat64ToTagged)         \
213 214
  V(ChangeTaggedToBit)             \
  V(ChangeBitToTagged)             \
215 216 217 218
  V(CheckedUint32ToInt32)          \
  V(CheckedFloat64ToInt32)         \
  V(CheckedTaggedToInt32)          \
  V(CheckedTaggedToFloat64)        \
219
  V(CheckIf)                       \
220
  V(TruncateTaggedToWord32)        \
221
  V(TruncateTaggedToFloat64)       \
222
  V(Allocate)                      \
223 224 225 226 227 228
  V(LoadField)                     \
  V(LoadBuffer)                    \
  V(LoadElement)                   \
  V(StoreField)                    \
  V(StoreBuffer)                   \
  V(StoreElement)                  \
229
  V(ObjectIsCallable)              \
230
  V(ObjectIsNumber)                \
231
  V(ObjectIsReceiver)              \
232
  V(ObjectIsSmi)                   \
233
  V(ObjectIsString)                \
234 235
  V(ObjectIsUndetectable)          \
  V(TypeGuard)
236 237

// Opcodes for Machine-level operators.
238 239 240 241 242 243 244 245 246 247
#define MACHINE_COMPARE_BINOP_LIST(V) \
  V(Word32Equal)                      \
  V(Word64Equal)                      \
  V(Int32LessThan)                    \
  V(Int32LessThanOrEqual)             \
  V(Uint32LessThan)                   \
  V(Uint32LessThanOrEqual)            \
  V(Int64LessThan)                    \
  V(Int64LessThanOrEqual)             \
  V(Uint64LessThan)                   \
248
  V(Uint64LessThanOrEqual)            \
249 250 251
  V(Float32Equal)                     \
  V(Float32LessThan)                  \
  V(Float32LessThanOrEqual)           \
252 253 254 255 256 257
  V(Float64Equal)                     \
  V(Float64LessThan)                  \
  V(Float64LessThanOrEqual)

#define MACHINE_OP_LIST(V)      \
  MACHINE_COMPARE_BINOP_LIST(V) \
258
  V(DebugBreak)                 \
259
  V(Comment)                    \
260 261
  V(Load)                       \
  V(Store)                      \
262
  V(StackSlot)                  \
263 264 265 266 267 268 269
  V(Word32And)                  \
  V(Word32Or)                   \
  V(Word32Xor)                  \
  V(Word32Shl)                  \
  V(Word32Shr)                  \
  V(Word32Sar)                  \
  V(Word32Ror)                  \
270
  V(Word32Clz)                  \
271
  V(Word32Ctz)                  \
272
  V(Word32ReverseBits)          \
273
  V(Word32Popcnt)               \
274
  V(Word64Popcnt)               \
275 276 277 278 279 280 281
  V(Word64And)                  \
  V(Word64Or)                   \
  V(Word64Xor)                  \
  V(Word64Shl)                  \
  V(Word64Shr)                  \
  V(Word64Sar)                  \
  V(Word64Ror)                  \
282
  V(Word64Clz)                  \
283
  V(Word64Ctz)                  \
284
  V(Word64ReverseBits)          \
285 286 287 288 289 290 291 292 293 294 295 296
  V(Int32Add)                   \
  V(Int32AddWithOverflow)       \
  V(Int32Sub)                   \
  V(Int32SubWithOverflow)       \
  V(Int32Mul)                   \
  V(Int32MulHigh)               \
  V(Int32Div)                   \
  V(Int32Mod)                   \
  V(Uint32Div)                  \
  V(Uint32Mod)                  \
  V(Uint32MulHigh)              \
  V(Int64Add)                   \
297
  V(Int64AddWithOverflow)       \
298
  V(Int64Sub)                   \
299
  V(Int64SubWithOverflow)       \
300 301 302 303 304
  V(Int64Mul)                   \
  V(Int64Div)                   \
  V(Int64Mod)                   \
  V(Uint64Div)                  \
  V(Uint64Mod)                  \
305
  V(BitcastWordToTagged)        \
306
  V(TruncateFloat64ToWord32)    \
307 308 309
  V(ChangeFloat32ToFloat64)     \
  V(ChangeFloat64ToInt32)       \
  V(ChangeFloat64ToUint32)      \
310
  V(TruncateFloat64ToUint32)    \
311
  V(TruncateFloat32ToInt32)     \
312
  V(TruncateFloat32ToUint32)    \
313
  V(TryTruncateFloat32ToInt64)  \
314
  V(TryTruncateFloat64ToInt64)  \
315
  V(TryTruncateFloat32ToUint64) \
316
  V(TryTruncateFloat64ToUint64) \
317 318 319 320 321 322
  V(ChangeInt32ToFloat64)       \
  V(ChangeInt32ToInt64)         \
  V(ChangeUint32ToFloat64)      \
  V(ChangeUint32ToUint64)       \
  V(TruncateFloat64ToFloat32)   \
  V(TruncateInt64ToInt32)       \
323
  V(RoundFloat64ToInt32)        \
324
  V(RoundInt32ToFloat32)        \
325
  V(RoundInt64ToFloat32)        \
326
  V(RoundInt64ToFloat64)        \
327
  V(RoundUint32ToFloat32)       \
328
  V(RoundUint64ToFloat32)       \
329
  V(RoundUint64ToFloat64)       \
330 331 332 333
  V(BitcastFloat32ToInt32)      \
  V(BitcastFloat64ToInt64)      \
  V(BitcastInt32ToFloat32)      \
  V(BitcastInt64ToFloat64)      \
334 335
  V(Float32Add)                 \
  V(Float32Sub)                 \
336
  V(Float32SubPreserveNan)      \
337
  V(Float32Neg)                 \
338 339 340 341
  V(Float32Mul)                 \
  V(Float32Div)                 \
  V(Float32Max)                 \
  V(Float32Min)                 \
342
  V(Float32Abs)                 \
343
  V(Float32Sqrt)                \
344
  V(Float32RoundDown)           \
345 346
  V(Float64Add)                 \
  V(Float64Sub)                 \
347
  V(Float64SubPreserveNan)      \
348
  V(Float64Neg)                 \
349 350 351
  V(Float64Mul)                 \
  V(Float64Div)                 \
  V(Float64Mod)                 \
352 353
  V(Float64Max)                 \
  V(Float64Min)                 \
354
  V(Float64Abs)                 \
355
  V(Float64Log)                 \
356
  V(Float64Sqrt)                \
357
  V(Float64RoundDown)           \
358
  V(Float32RoundUp)             \
359
  V(Float64RoundUp)             \
360
  V(Float32RoundTruncate)       \
361 362
  V(Float64RoundTruncate)       \
  V(Float64RoundTiesAway)       \
363
  V(Float32RoundTiesEven)       \
364
  V(Float64RoundTiesEven)       \
365 366 367 368
  V(Float64ExtractLowWord32)    \
  V(Float64ExtractHighWord32)   \
  V(Float64InsertLowWord32)     \
  V(Float64InsertHighWord32)    \
369
  V(LoadStackPointer)           \
370
  V(LoadFramePointer)           \
371
  V(LoadParentFramePointer)     \
372
  V(CheckedLoad)                \
373
  V(CheckedStore)               \
374
  V(Int32PairAdd)               \
375
  V(Int32PairSub)               \
376
  V(Int32PairMul)               \
377 378
  V(Word32PairShl)              \
  V(Word32PairShr)              \
379
  V(Word32PairSar)              \
380 381
  V(AtomicLoad)                 \
  V(AtomicStore)
382

383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 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
#define MACHINE_SIMD_RETURN_SIMD_OP_LIST(V) \
  V(CreateFloat32x4)                        \
  V(Float32x4ReplaceLane)                   \
  V(Float32x4Abs)                           \
  V(Float32x4Neg)                           \
  V(Float32x4Sqrt)                          \
  V(Float32x4RecipApprox)                   \
  V(Float32x4RecipSqrtApprox)               \
  V(Float32x4Add)                           \
  V(Float32x4Sub)                           \
  V(Float32x4Mul)                           \
  V(Float32x4Div)                           \
  V(Float32x4Min)                           \
  V(Float32x4Max)                           \
  V(Float32x4MinNum)                        \
  V(Float32x4MaxNum)                        \
  V(Float32x4Equal)                         \
  V(Float32x4NotEqual)                      \
  V(Float32x4LessThan)                      \
  V(Float32x4LessThanOrEqual)               \
  V(Float32x4GreaterThan)                   \
  V(Float32x4GreaterThanOrEqual)            \
  V(Float32x4Select)                        \
  V(Float32x4Swizzle)                       \
  V(Float32x4Shuffle)                       \
  V(Float32x4FromInt32x4)                   \
  V(Float32x4FromUint32x4)                  \
  V(CreateInt32x4)                          \
  V(Int32x4ReplaceLane)                     \
  V(Int32x4Neg)                             \
  V(Int32x4Add)                             \
  V(Int32x4Sub)                             \
  V(Int32x4Mul)                             \
  V(Int32x4Min)                             \
  V(Int32x4Max)                             \
  V(Int32x4ShiftLeftByScalar)               \
  V(Int32x4ShiftRightByScalar)              \
  V(Int32x4Equal)                           \
  V(Int32x4NotEqual)                        \
  V(Int32x4LessThan)                        \
  V(Int32x4LessThanOrEqual)                 \
  V(Int32x4GreaterThan)                     \
  V(Int32x4GreaterThanOrEqual)              \
  V(Int32x4Select)                          \
  V(Int32x4Swizzle)                         \
  V(Int32x4Shuffle)                         \
  V(Int32x4FromFloat32x4)                   \
  V(Uint32x4Min)                            \
  V(Uint32x4Max)                            \
  V(Uint32x4ShiftLeftByScalar)              \
  V(Uint32x4ShiftRightByScalar)             \
  V(Uint32x4LessThan)                       \
  V(Uint32x4LessThanOrEqual)                \
  V(Uint32x4GreaterThan)                    \
  V(Uint32x4GreaterThanOrEqual)             \
  V(Uint32x4FromFloat32x4)                  \
  V(CreateBool32x4)                         \
  V(Bool32x4ReplaceLane)                    \
  V(Bool32x4And)                            \
  V(Bool32x4Or)                             \
  V(Bool32x4Xor)                            \
  V(Bool32x4Not)                            \
  V(Bool32x4Swizzle)                        \
  V(Bool32x4Shuffle)                        \
  V(Bool32x4Equal)                          \
  V(Bool32x4NotEqual)                       \
  V(CreateInt16x8)                          \
  V(Int16x8ReplaceLane)                     \
  V(Int16x8Neg)                             \
  V(Int16x8Add)                             \
  V(Int16x8AddSaturate)                     \
  V(Int16x8Sub)                             \
  V(Int16x8SubSaturate)                     \
  V(Int16x8Mul)                             \
  V(Int16x8Min)                             \
  V(Int16x8Max)                             \
  V(Int16x8ShiftLeftByScalar)               \
  V(Int16x8ShiftRightByScalar)              \
  V(Int16x8Equal)                           \
  V(Int16x8NotEqual)                        \
  V(Int16x8LessThan)                        \
  V(Int16x8LessThanOrEqual)                 \
  V(Int16x8GreaterThan)                     \
  V(Int16x8GreaterThanOrEqual)              \
  V(Int16x8Select)                          \
  V(Int16x8Swizzle)                         \
  V(Int16x8Shuffle)                         \
  V(Uint16x8AddSaturate)                    \
  V(Uint16x8SubSaturate)                    \
  V(Uint16x8Min)                            \
  V(Uint16x8Max)                            \
  V(Uint16x8ShiftLeftByScalar)              \
  V(Uint16x8ShiftRightByScalar)             \
  V(Uint16x8LessThan)                       \
  V(Uint16x8LessThanOrEqual)                \
  V(Uint16x8GreaterThan)                    \
  V(Uint16x8GreaterThanOrEqual)             \
  V(CreateBool16x8)                         \
  V(Bool16x8ReplaceLane)                    \
  V(Bool16x8And)                            \
  V(Bool16x8Or)                             \
  V(Bool16x8Xor)                            \
  V(Bool16x8Not)                            \
  V(Bool16x8Swizzle)                        \
  V(Bool16x8Shuffle)                        \
  V(Bool16x8Equal)                          \
  V(Bool16x8NotEqual)                       \
  V(CreateInt8x16)                          \
  V(Int8x16ReplaceLane)                     \
  V(Int8x16Neg)                             \
  V(Int8x16Add)                             \
  V(Int8x16AddSaturate)                     \
  V(Int8x16Sub)                             \
  V(Int8x16SubSaturate)                     \
  V(Int8x16Mul)                             \
  V(Int8x16Min)                             \
  V(Int8x16Max)                             \
  V(Int8x16ShiftLeftByScalar)               \
  V(Int8x16ShiftRightByScalar)              \
  V(Int8x16Equal)                           \
  V(Int8x16NotEqual)                        \
  V(Int8x16LessThan)                        \
  V(Int8x16LessThanOrEqual)                 \
  V(Int8x16GreaterThan)                     \
  V(Int8x16GreaterThanOrEqual)              \
  V(Int8x16Select)                          \
  V(Int8x16Swizzle)                         \
  V(Int8x16Shuffle)                         \
  V(Uint8x16AddSaturate)                    \
  V(Uint8x16SubSaturate)                    \
  V(Uint8x16Min)                            \
  V(Uint8x16Max)                            \
  V(Uint8x16ShiftLeftByScalar)              \
  V(Uint8x16ShiftRightByScalar)             \
  V(Uint8x16LessThan)                       \
  V(Uint8x16LessThanOrEqual)                \
  V(Uint8x16GreaterThan)                    \
  V(Uint8x16GreaterThanOrEqual)             \
  V(CreateBool8x16)                         \
  V(Bool8x16ReplaceLane)                    \
  V(Bool8x16And)                            \
  V(Bool8x16Or)                             \
  V(Bool8x16Xor)                            \
  V(Bool8x16Not)                            \
  V(Bool8x16Swizzle)                        \
  V(Bool8x16Shuffle)                        \
  V(Bool8x16Equal)                          \
gdeepti's avatar
gdeepti committed
530
  V(Bool8x16NotEqual)
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548

#define MACHINE_SIMD_RETURN_NUM_OP_LIST(V) \
  V(Float32x4ExtractLane)                  \
  V(Int32x4ExtractLane)                    \
  V(Int16x8ExtractLane)                    \
  V(Int8x16ExtractLane)

#define MACHINE_SIMD_RETURN_BOOL_OP_LIST(V) \
  V(Bool32x4ExtractLane)                    \
  V(Bool32x4AnyTrue)                        \
  V(Bool32x4AllTrue)                        \
  V(Bool16x8ExtractLane)                    \
  V(Bool16x8AnyTrue)                        \
  V(Bool16x8AllTrue)                        \
  V(Bool8x16ExtractLane)                    \
  V(Bool8x16AnyTrue)                        \
  V(Bool8x16AllTrue)

gdeepti's avatar
gdeepti committed
549 550 551 552 553 554 555 556 557 558 559 560 561 562
#define MACHINE_SIMD_GENERIC_OP_LIST(V) \
  V(Simd128Load)                        \
  V(Simd128Load1)                       \
  V(Simd128Load2)                       \
  V(Simd128Load3)                       \
  V(Simd128Store)                       \
  V(Simd128Store1)                      \
  V(Simd128Store2)                      \
  V(Simd128Store3)                      \
  V(Simd128And)                         \
  V(Simd128Or)                          \
  V(Simd128Xor)                         \
  V(Simd128Not)

563 564 565
#define MACHINE_SIMD_OP_LIST(V)       \
  MACHINE_SIMD_RETURN_SIMD_OP_LIST(V) \
  MACHINE_SIMD_RETURN_NUM_OP_LIST(V)  \
gdeepti's avatar
gdeepti committed
566 567
  MACHINE_SIMD_RETURN_BOOL_OP_LIST(V) \
  MACHINE_SIMD_GENERIC_OP_LIST(V)
568 569 570 571 572 573

#define VALUE_OP_LIST(V)  \
  COMMON_OP_LIST(V)       \
  SIMPLIFIED_OP_LIST(V)   \
  MACHINE_OP_LIST(V)      \
  MACHINE_SIMD_OP_LIST(V) \
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 599
  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.
class IrOpcode {
 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.
600
  static char const* Mnemonic(Value value);
601

602 603
  // Returns true if opcode for common operator.
  static bool IsCommonOpcode(Value value) {
604
    return kStart <= value && value <= kDead;
605 606
  }

607 608
  // Returns true if opcode for control operator.
  static bool IsControlOpcode(Value value) {
609
    return kStart <= value && value <= kEnd;
610 611
  }

612 613
  // Returns true if opcode for JavaScript operator.
  static bool IsJsOpcode(Value value) {
614
    return kJSEqual <= value && value <= kJSStackCheck;
615 616
  }

617 618
  // Returns true if opcode for constant operator.
  static bool IsConstantOpcode(Value value) {
619
    return kInt32Constant <= value && value <= kRelocatableInt64Constant;
620
  }
621

622 623 624 625 626 627
  static bool IsPhiOpcode(Value value) {
    return value == kPhi || value == kEffectPhi;
  }

  static bool IsMergeOpcode(Value value) {
    return value == kMerge || value == kLoop;
628
  }
629

630 631 632 633
  static bool IsIfProjectionOpcode(Value value) {
    return kIfTrue <= value && value <= kIfDefault;
  }

634 635 636 637 638
  // Returns true if opcode can be inlined.
  static bool IsInlineeOpcode(Value value) {
    return value == kJSCallConstruct || value == kJSCallFunction;
  }

639 640 641 642 643 644
  // 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);
  }
645 646
};

647 648
std::ostream& operator<<(std::ostream&, IrOpcode::Value);

649 650 651 652 653
}  // namespace compiler
}  // namespace internal
}  // namespace v8

#endif  // V8_COMPILER_OPCODES_H_