1 // Copyright 2013 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_COMPILER_OPCODES_H_ 6 #define V8_COMPILER_OPCODES_H_ 7 8 #include <iosfwd> 9 10 #include "src/common/globals.h" 11 12 // Opcodes for control operators. 13 #define CONTROL_OP_LIST(V) \ 14 V(Start) \ 15 V(Loop) \ 16 V(Branch) \ 17 V(Switch) \ 18 V(IfTrue) \ 19 V(IfFalse) \ 20 V(IfSuccess) \ 21 V(IfException) \ 22 V(IfValue) \ 23 V(IfDefault) \ 24 V(Merge) \ 25 V(Deoptimize) \ 26 V(DeoptimizeIf) \ 27 V(DeoptimizeUnless) \ 28 V(TrapIf) \ 29 V(TrapUnless) \ 30 V(Return) \ 31 V(TailCall) \ 32 V(Terminate) \ 33 V(Throw) \ 34 V(End) 35 36 // Opcodes for constant operators. 37 #define CONSTANT_OP_LIST(V) \ 38 V(Int32Constant) \ 39 V(Int64Constant) \ 40 V(TaggedIndexConstant) \ 41 V(Float32Constant) \ 42 V(Float64Constant) \ 43 V(ExternalConstant) \ 44 V(NumberConstant) \ 45 V(PointerConstant) \ 46 V(HeapConstant) \ 47 V(CompressedHeapConstant) \ 48 V(RelocatableInt32Constant) \ 49 V(RelocatableInt64Constant) 50 51 #define INNER_OP_LIST(V) \ 52 V(Select) \ 53 V(Phi) \ 54 V(EffectPhi) \ 55 V(InductionVariablePhi) \ 56 V(Checkpoint) \ 57 V(BeginRegion) \ 58 V(FinishRegion) \ 59 V(FrameState) \ 60 V(StateValues) \ 61 V(TypedStateValues) \ 62 V(ArgumentsElementsState) \ 63 V(ArgumentsLengthState) \ 64 V(ObjectState) \ 65 V(ObjectId) \ 66 V(TypedObjectState) \ 67 V(Call) \ 68 V(Parameter) \ 69 V(OsrValue) \ 70 V(LoopExit) \ 71 V(LoopExitValue) \ 72 V(LoopExitEffect) \ 73 V(Projection) \ 74 V(Retain) \ 75 V(MapGuard) \ 76 V(FoldConstant) \ 77 V(TypeGuard) 78 79 #define COMMON_OP_LIST(V) \ 80 CONSTANT_OP_LIST(V) \ 81 INNER_OP_LIST(V) \ 82 V(Unreachable) \ 83 V(DeadValue) \ 84 V(Dead) \ 85 V(StaticAssert) 86 87 // Opcodes for JavaScript operators. 88 #define JS_COMPARE_BINOP_LIST(V) \ 89 V(JSEqual) \ 90 V(JSStrictEqual) \ 91 V(JSLessThan) \ 92 V(JSGreaterThan) \ 93 V(JSLessThanOrEqual) \ 94 V(JSGreaterThanOrEqual) 95 96 #define JS_BITWISE_BINOP_LIST(V) \ 97 V(JSBitwiseOr) \ 98 V(JSBitwiseXor) \ 99 V(JSBitwiseAnd) \ 100 V(JSShiftLeft) \ 101 V(JSShiftRight) \ 102 V(JSShiftRightLogical) 103 104 #define JS_ARITH_BINOP_LIST(V) \ 105 V(JSAdd) \ 106 V(JSSubtract) \ 107 V(JSMultiply) \ 108 V(JSDivide) \ 109 V(JSModulus) \ 110 V(JSExponentiate) 111 112 #define JS_SIMPLE_BINOP_LIST(V) \ 113 JS_COMPARE_BINOP_LIST(V) \ 114 JS_BITWISE_BINOP_LIST(V) \ 115 JS_ARITH_BINOP_LIST(V) \ 116 V(JSHasInPrototypeChain) \ 117 V(JSInstanceOf) \ 118 V(JSOrdinaryHasInstance) 119 120 #define JS_CONVERSION_UNOP_LIST(V) \ 121 V(JSToLength) \ 122 V(JSToName) \ 123 V(JSToNumber) \ 124 V(JSToNumberConvertBigInt) \ 125 V(JSToNumeric) \ 126 V(JSToObject) \ 127 V(JSToString) \ 128 V(JSParseInt) 129 130 #define JS_SIMPLE_UNOP_LIST(V) \ 131 JS_CONVERSION_UNOP_LIST(V) \ 132 V(JSBitwiseNot) \ 133 V(JSDecrement) \ 134 V(JSIncrement) \ 135 V(JSNegate) 136 137 #define JS_CREATE_OP_LIST(V) \ 138 V(JSCloneObject) \ 139 V(JSCreate) \ 140 V(JSCreateArguments) \ 141 V(JSCreateArray) \ 142 V(JSCreateArrayFromIterable) \ 143 V(JSCreateArrayIterator) \ 144 V(JSCreateAsyncFunctionObject) \ 145 V(JSCreateBoundFunction) \ 146 V(JSCreateClosure) \ 147 V(JSCreateCollectionIterator) \ 148 V(JSCreateEmptyLiteralArray) \ 149 V(JSCreateEmptyLiteralObject) \ 150 V(JSCreateGeneratorObject) \ 151 V(JSCreateIterResultObject) \ 152 V(JSCreateKeyValueArray) \ 153 V(JSCreateLiteralArray) \ 154 V(JSCreateLiteralObject) \ 155 V(JSCreateLiteralRegExp) \ 156 V(JSCreateObject) \ 157 V(JSCreatePromise) \ 158 V(JSCreateStringIterator) \ 159 V(JSCreateTypedArray) \ 160 V(JSGetTemplateObject) 161 162 #define JS_OBJECT_OP_LIST(V) \ 163 JS_CREATE_OP_LIST(V) \ 164 V(JSLoadProperty) \ 165 V(JSLoadNamed) \ 166 V(JSLoadGlobal) \ 167 V(JSStoreProperty) \ 168 V(JSStoreNamed) \ 169 V(JSStoreNamedOwn) \ 170 V(JSStoreGlobal) \ 171 V(JSStoreDataPropertyInLiteral) \ 172 V(JSStoreInArrayLiteral) \ 173 V(JSDeleteProperty) \ 174 V(JSHasProperty) \ 175 V(JSGetSuperConstructor) 176 177 #define JS_CONTEXT_OP_LIST(V) \ 178 V(JSHasContextExtension) \ 179 V(JSLoadContext) \ 180 V(JSStoreContext) \ 181 V(JSCreateFunctionContext) \ 182 V(JSCreateCatchContext) \ 183 V(JSCreateWithContext) \ 184 V(JSCreateBlockContext) 185 186 #define JS_CALL_OP_LIST(V) \ 187 V(JSCall) \ 188 V(JSCallForwardVarargs) \ 189 V(JSCallWithArrayLike) \ 190 V(JSCallWithSpread) 191 192 #define JS_CONSTRUCT_OP_LIST(V) \ 193 V(JSConstructForwardVarargs) \ 194 V(JSConstruct) \ 195 V(JSConstructWithArrayLike) \ 196 V(JSConstructWithSpread) 197 198 #define JS_OTHER_OP_LIST(V) \ 199 JS_CALL_OP_LIST(V) \ 200 JS_CONSTRUCT_OP_LIST(V) \ 201 V(JSAsyncFunctionEnter) \ 202 V(JSAsyncFunctionReject) \ 203 V(JSAsyncFunctionResolve) \ 204 V(JSCallRuntime) \ 205 V(JSForInEnumerate) \ 206 V(JSForInNext) \ 207 V(JSForInPrepare) \ 208 V(JSGetIterator) \ 209 V(JSLoadMessage) \ 210 V(JSStoreMessage) \ 211 V(JSLoadModule) \ 212 V(JSStoreModule) \ 213 V(JSGeneratorStore) \ 214 V(JSGeneratorRestoreContinuation) \ 215 V(JSGeneratorRestoreContext) \ 216 V(JSGeneratorRestoreRegister) \ 217 V(JSGeneratorRestoreInputOrDebugPos) \ 218 V(JSFulfillPromise) \ 219 V(JSPerformPromiseThen) \ 220 V(JSPromiseResolve) \ 221 V(JSRejectPromise) \ 222 V(JSResolvePromise) \ 223 V(JSStackCheck) \ 224 V(JSObjectIsArray) \ 225 V(JSRegExpTest) \ 226 V(JSDebugger) 227 228 #define JS_OP_LIST(V) \ 229 JS_SIMPLE_BINOP_LIST(V) \ 230 JS_SIMPLE_UNOP_LIST(V) \ 231 JS_OBJECT_OP_LIST(V) \ 232 JS_CONTEXT_OP_LIST(V) \ 233 JS_OTHER_OP_LIST(V) 234 235 // Opcodes for VirtuaMachine-level operators. 236 #define SIMPLIFIED_CHANGE_OP_LIST(V) \ 237 V(ChangeTaggedSignedToInt32) \ 238 V(ChangeTaggedSignedToInt64) \ 239 V(ChangeTaggedToInt32) \ 240 V(ChangeTaggedToInt64) \ 241 V(ChangeTaggedToUint32) \ 242 V(ChangeTaggedToFloat64) \ 243 V(ChangeTaggedToTaggedSigned) \ 244 V(ChangeInt31ToTaggedSigned) \ 245 V(ChangeInt32ToTagged) \ 246 V(ChangeInt64ToTagged) \ 247 V(ChangeUint32ToTagged) \ 248 V(ChangeUint64ToTagged) \ 249 V(ChangeFloat64ToTagged) \ 250 V(ChangeFloat64ToTaggedPointer) \ 251 V(ChangeTaggedToBit) \ 252 V(ChangeBitToTagged) \ 253 V(ChangeUint64ToBigInt) \ 254 V(TruncateBigIntToUint64) \ 255 V(TruncateTaggedToWord32) \ 256 V(TruncateTaggedToFloat64) \ 257 V(TruncateTaggedToBit) \ 258 V(TruncateTaggedPointerToBit) 259 260 #define SIMPLIFIED_CHECKED_OP_LIST(V) \ 261 V(CheckedInt32Add) \ 262 V(CheckedInt32Sub) \ 263 V(CheckedInt32Div) \ 264 V(CheckedInt32Mod) \ 265 V(CheckedUint32Div) \ 266 V(CheckedUint32Mod) \ 267 V(CheckedInt32Mul) \ 268 V(CheckedInt32ToTaggedSigned) \ 269 V(CheckedInt64ToInt32) \ 270 V(CheckedInt64ToTaggedSigned) \ 271 V(CheckedUint32Bounds) \ 272 V(CheckedUint32ToInt32) \ 273 V(CheckedUint32ToTaggedSigned) \ 274 V(CheckedUint64Bounds) \ 275 V(CheckedUint64ToInt32) \ 276 V(CheckedUint64ToTaggedSigned) \ 277 V(CheckedFloat64ToInt32) \ 278 V(CheckedFloat64ToInt64) \ 279 V(CheckedTaggedSignedToInt32) \ 280 V(CheckedTaggedToInt32) \ 281 V(CheckedTaggedToArrayIndex) \ 282 V(CheckedTruncateTaggedToWord32) \ 283 V(CheckedTaggedToFloat64) \ 284 V(CheckedTaggedToInt64) \ 285 V(CheckedTaggedToTaggedSigned) \ 286 V(CheckedTaggedToTaggedPointer) 287 288 #define SIMPLIFIED_COMPARE_BINOP_LIST(V) \ 289 V(NumberEqual) \ 290 V(NumberLessThan) \ 291 V(NumberLessThanOrEqual) \ 292 V(SpeculativeNumberEqual) \ 293 V(SpeculativeNumberLessThan) \ 294 V(SpeculativeNumberLessThanOrEqual) \ 295 V(ReferenceEqual) \ 296 V(SameValue) \ 297 V(SameValueNumbersOnly) \ 298 V(NumberSameValue) \ 299 V(StringEqual) \ 300 V(StringLessThan) \ 301 V(StringLessThanOrEqual) 302 303 #define SIMPLIFIED_NUMBER_BINOP_LIST(V) \ 304 V(NumberAdd) \ 305 V(NumberSubtract) \ 306 V(NumberMultiply) \ 307 V(NumberDivide) \ 308 V(NumberModulus) \ 309 V(NumberBitwiseOr) \ 310 V(NumberBitwiseXor) \ 311 V(NumberBitwiseAnd) \ 312 V(NumberShiftLeft) \ 313 V(NumberShiftRight) \ 314 V(NumberShiftRightLogical) \ 315 V(NumberAtan2) \ 316 V(NumberImul) \ 317 V(NumberMax) \ 318 V(NumberMin) \ 319 V(NumberPow) 320 321 #define SIMPLIFIED_BIGINT_BINOP_LIST(V) \ 322 V(BigIntAdd) \ 323 V(BigIntSubtract) 324 325 #define SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(V) \ 326 V(SpeculativeNumberAdd) \ 327 V(SpeculativeNumberSubtract) \ 328 V(SpeculativeNumberMultiply) \ 329 V(SpeculativeNumberDivide) \ 330 V(SpeculativeNumberModulus) \ 331 V(SpeculativeNumberBitwiseAnd) \ 332 V(SpeculativeNumberBitwiseOr) \ 333 V(SpeculativeNumberBitwiseXor) \ 334 V(SpeculativeNumberShiftLeft) \ 335 V(SpeculativeNumberShiftRight) \ 336 V(SpeculativeNumberShiftRightLogical) \ 337 V(SpeculativeSafeIntegerAdd) \ 338 V(SpeculativeSafeIntegerSubtract) 339 340 #define SIMPLIFIED_NUMBER_UNOP_LIST(V) \ 341 V(NumberAbs) \ 342 V(NumberAcos) \ 343 V(NumberAcosh) \ 344 V(NumberAsin) \ 345 V(NumberAsinh) \ 346 V(NumberAtan) \ 347 V(NumberAtanh) \ 348 V(NumberCbrt) \ 349 V(NumberCeil) \ 350 V(NumberClz32) \ 351 V(NumberCos) \ 352 V(NumberCosh) \ 353 V(NumberExp) \ 354 V(NumberExpm1) \ 355 V(NumberFloor) \ 356 V(NumberFround) \ 357 V(NumberLog) \ 358 V(NumberLog1p) \ 359 V(NumberLog2) \ 360 V(NumberLog10) \ 361 V(NumberRound) \ 362 V(NumberSign) \ 363 V(NumberSin) \ 364 V(NumberSinh) \ 365 V(NumberSqrt) \ 366 V(NumberTan) \ 367 V(NumberTanh) \ 368 V(NumberTrunc) \ 369 V(NumberToBoolean) \ 370 V(NumberToInt32) \ 371 V(NumberToString) \ 372 V(NumberToUint32) \ 373 V(NumberToUint8Clamped) \ 374 V(NumberSilenceNaN) 375 376 #define SIMPLIFIED_BIGINT_UNOP_LIST(V) \ 377 V(BigIntAsUintN) \ 378 V(BigIntNegate) \ 379 V(CheckBigInt) 380 381 #define SIMPLIFIED_SPECULATIVE_NUMBER_UNOP_LIST(V) V(SpeculativeToNumber) 382 383 #define SIMPLIFIED_OTHER_OP_LIST(V) \ 384 V(PlainPrimitiveToNumber) \ 385 V(PlainPrimitiveToWord32) \ 386 V(PlainPrimitiveToFloat64) \ 387 V(BooleanNot) \ 388 V(StringConcat) \ 389 V(StringToNumber) \ 390 V(StringCharCodeAt) \ 391 V(StringCodePointAt) \ 392 V(StringFromSingleCharCode) \ 393 V(StringFromSingleCodePoint) \ 394 V(StringFromCodePointAt) \ 395 V(StringIndexOf) \ 396 V(StringLength) \ 397 V(StringToLowerCaseIntl) \ 398 V(StringToUpperCaseIntl) \ 399 V(StringSubstring) \ 400 V(CheckBounds) \ 401 V(CheckIf) \ 402 V(CheckMaps) \ 403 V(CheckNumber) \ 404 V(CheckInternalizedString) \ 405 V(CheckReceiver) \ 406 V(CheckReceiverOrNullOrUndefined) \ 407 V(CheckString) \ 408 V(CheckSymbol) \ 409 V(CheckSmi) \ 410 V(CheckHeapObject) \ 411 V(CheckFloat64Hole) \ 412 V(CheckClosure) \ 413 V(CheckNotTaggedHole) \ 414 V(CheckEqualsInternalizedString) \ 415 V(CheckEqualsSymbol) \ 416 V(CompareMaps) \ 417 V(ConvertReceiver) \ 418 V(ConvertTaggedHoleToUndefined) \ 419 V(TypeOf) \ 420 V(Allocate) \ 421 V(AllocateRaw) \ 422 V(LoadFieldByIndex) \ 423 V(LoadField) \ 424 V(LoadElement) \ 425 V(LoadMessage) \ 426 V(LoadTypedElement) \ 427 V(LoadFromObject) \ 428 V(LoadDataViewElement) \ 429 V(LoadStackArgument) \ 430 V(StoreField) \ 431 V(StoreElement) \ 432 V(StoreMessage) \ 433 V(StoreTypedElement) \ 434 V(StoreToObject) \ 435 V(StoreDataViewElement) \ 436 V(StoreSignedSmallElement) \ 437 V(TransitionAndStoreElement) \ 438 V(TransitionAndStoreNumberElement) \ 439 V(TransitionAndStoreNonNumberElement) \ 440 V(ToBoolean) \ 441 V(NumberIsFloat64Hole) \ 442 V(NumberIsFinite) \ 443 V(ObjectIsFiniteNumber) \ 444 V(NumberIsInteger) \ 445 V(ObjectIsSafeInteger) \ 446 V(NumberIsSafeInteger) \ 447 V(ObjectIsInteger) \ 448 V(ObjectIsArrayBufferView) \ 449 V(ObjectIsBigInt) \ 450 V(ObjectIsCallable) \ 451 V(ObjectIsConstructor) \ 452 V(ObjectIsDetectableCallable) \ 453 V(ObjectIsMinusZero) \ 454 V(NumberIsMinusZero) \ 455 V(ObjectIsNaN) \ 456 V(NumberIsNaN) \ 457 V(ObjectIsNonCallable) \ 458 V(ObjectIsNumber) \ 459 V(ObjectIsReceiver) \ 460 V(ObjectIsSmi) \ 461 V(ObjectIsString) \ 462 V(ObjectIsSymbol) \ 463 V(ObjectIsUndetectable) \ 464 V(ArgumentsFrame) \ 465 V(ArgumentsLength) \ 466 V(NewDoubleElements) \ 467 V(NewSmiOrObjectElements) \ 468 V(NewArgumentsElements) \ 469 V(NewConsString) \ 470 V(DelayedStringConstant) \ 471 V(EnsureWritableFastElements) \ 472 V(MaybeGrowFastElements) \ 473 V(TransitionElementsKind) \ 474 V(FindOrderedHashMapEntry) \ 475 V(FindOrderedHashMapEntryForInt32Key) \ 476 V(PoisonIndex) \ 477 V(RuntimeAbort) \ 478 V(AssertType) \ 479 V(DateNow) \ 480 V(FastApiCall) 481 482 #define SIMPLIFIED_SPECULATIVE_BIGINT_BINOP_LIST(V) \ 483 V(SpeculativeBigIntAdd) \ 484 V(SpeculativeBigIntSubtract) 485 486 #define SIMPLIFIED_SPECULATIVE_BIGINT_UNOP_LIST(V) V(SpeculativeBigIntNegate) 487 488 #define SIMPLIFIED_OP_LIST(V) \ 489 SIMPLIFIED_CHANGE_OP_LIST(V) \ 490 SIMPLIFIED_CHECKED_OP_LIST(V) \ 491 SIMPLIFIED_COMPARE_BINOP_LIST(V) \ 492 SIMPLIFIED_NUMBER_BINOP_LIST(V) \ 493 SIMPLIFIED_BIGINT_BINOP_LIST(V) \ 494 SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(V) \ 495 SIMPLIFIED_NUMBER_UNOP_LIST(V) \ 496 SIMPLIFIED_BIGINT_UNOP_LIST(V) \ 497 SIMPLIFIED_SPECULATIVE_NUMBER_UNOP_LIST(V) \ 498 SIMPLIFIED_SPECULATIVE_BIGINT_UNOP_LIST(V) \ 499 SIMPLIFIED_SPECULATIVE_BIGINT_BINOP_LIST(V) \ 500 SIMPLIFIED_OTHER_OP_LIST(V) 501 502 // Opcodes for Machine-level operators. 503 #define MACHINE_COMPARE_BINOP_LIST(V) \ 504 V(Word32Equal) \ 505 V(Word64Equal) \ 506 V(Int32LessThan) \ 507 V(Int32LessThanOrEqual) \ 508 V(Uint32LessThan) \ 509 V(Uint32LessThanOrEqual) \ 510 V(Int64LessThan) \ 511 V(Int64LessThanOrEqual) \ 512 V(Uint64LessThan) \ 513 V(Uint64LessThanOrEqual) \ 514 V(Float32Equal) \ 515 V(Float32LessThan) \ 516 V(Float32LessThanOrEqual) \ 517 V(Float64Equal) \ 518 V(Float64LessThan) \ 519 V(Float64LessThanOrEqual) 520 521 #define MACHINE_UNOP_32_LIST(V) \ 522 V(Word32Clz) \ 523 V(Word32Ctz) \ 524 V(Int32AbsWithOverflow) \ 525 V(Word32ReverseBits) \ 526 V(Word32ReverseBytes) 527 528 #define MACHINE_BINOP_32_LIST(V) \ 529 V(Word32And) \ 530 V(Word32Or) \ 531 V(Word32Xor) \ 532 V(Word32Shl) \ 533 V(Word32Shr) \ 534 V(Word32Sar) \ 535 V(Word32Ror) \ 536 V(Int32Add) \ 537 V(Int32AddWithOverflow) \ 538 V(Int32Sub) \ 539 V(Int32SubWithOverflow) \ 540 V(Int32Mul) \ 541 V(Int32MulWithOverflow) \ 542 V(Int32MulHigh) \ 543 V(Int32Div) \ 544 V(Int32Mod) \ 545 V(Uint32Div) \ 546 V(Uint32Mod) \ 547 V(Uint32MulHigh) 548 549 #define MACHINE_BINOP_64_LIST(V) \ 550 V(Word64And) \ 551 V(Word64Or) \ 552 V(Word64Xor) \ 553 V(Word64Shl) \ 554 V(Word64Shr) \ 555 V(Word64Sar) \ 556 V(Word64Ror) \ 557 V(Int64Add) \ 558 V(Int64AddWithOverflow) \ 559 V(Int64Sub) \ 560 V(Int64SubWithOverflow) \ 561 V(Int64Mul) \ 562 V(Int64Div) \ 563 V(Int64Mod) \ 564 V(Uint64Div) \ 565 V(Uint64Mod) 566 567 #define MACHINE_FLOAT32_UNOP_LIST(V) \ 568 V(Float32Abs) \ 569 V(Float32Neg) \ 570 V(Float32RoundDown) \ 571 V(Float32RoundTiesEven) \ 572 V(Float32RoundTruncate) \ 573 V(Float32RoundUp) \ 574 V(Float32Sqrt) 575 576 #define MACHINE_FLOAT32_BINOP_LIST(V) \ 577 V(Float32Add) \ 578 V(Float32Sub) \ 579 V(Float32Mul) \ 580 V(Float32Div) \ 581 V(Float32Max) \ 582 V(Float32Min) 583 584 #define MACHINE_FLOAT64_UNOP_LIST(V) \ 585 V(Float64Abs) \ 586 V(Float64Acos) \ 587 V(Float64Acosh) \ 588 V(Float64Asin) \ 589 V(Float64Asinh) \ 590 V(Float64Atan) \ 591 V(Float64Atanh) \ 592 V(Float64Cbrt) \ 593 V(Float64Cos) \ 594 V(Float64Cosh) \ 595 V(Float64Exp) \ 596 V(Float64Expm1) \ 597 V(Float64Log) \ 598 V(Float64Log1p) \ 599 V(Float64Log10) \ 600 V(Float64Log2) \ 601 V(Float64Neg) \ 602 V(Float64RoundDown) \ 603 V(Float64RoundTiesAway) \ 604 V(Float64RoundTiesEven) \ 605 V(Float64RoundTruncate) \ 606 V(Float64RoundUp) \ 607 V(Float64Sin) \ 608 V(Float64Sinh) \ 609 V(Float64Sqrt) \ 610 V(Float64Tan) \ 611 V(Float64Tanh) 612 613 #define MACHINE_FLOAT64_BINOP_LIST(V) \ 614 V(Float64Atan2) \ 615 V(Float64Max) \ 616 V(Float64Min) \ 617 V(Float64Add) \ 618 V(Float64Sub) \ 619 V(Float64Mul) \ 620 V(Float64Div) \ 621 V(Float64Mod) \ 622 V(Float64Pow) 623 624 #define MACHINE_ATOMIC_OP_LIST(V) \ 625 V(Word32AtomicLoad) \ 626 V(Word32AtomicStore) \ 627 V(Word32AtomicExchange) \ 628 V(Word32AtomicCompareExchange) \ 629 V(Word32AtomicAdd) \ 630 V(Word32AtomicSub) \ 631 V(Word32AtomicAnd) \ 632 V(Word32AtomicOr) \ 633 V(Word32AtomicXor) \ 634 V(Word32AtomicPairLoad) \ 635 V(Word32AtomicPairStore) \ 636 V(Word32AtomicPairAdd) \ 637 V(Word32AtomicPairSub) \ 638 V(Word32AtomicPairAnd) \ 639 V(Word32AtomicPairOr) \ 640 V(Word32AtomicPairXor) \ 641 V(Word32AtomicPairExchange) \ 642 V(Word32AtomicPairCompareExchange) \ 643 V(Word64AtomicLoad) \ 644 V(Word64AtomicStore) \ 645 V(Word64AtomicAdd) \ 646 V(Word64AtomicSub) \ 647 V(Word64AtomicAnd) \ 648 V(Word64AtomicOr) \ 649 V(Word64AtomicXor) \ 650 V(Word64AtomicExchange) \ 651 V(Word64AtomicCompareExchange) 652 653 #define MACHINE_OP_LIST(V) \ 654 MACHINE_UNOP_32_LIST(V) \ 655 MACHINE_BINOP_32_LIST(V) \ 656 MACHINE_BINOP_64_LIST(V) \ 657 MACHINE_COMPARE_BINOP_LIST(V) \ 658 MACHINE_FLOAT32_BINOP_LIST(V) \ 659 MACHINE_FLOAT32_UNOP_LIST(V) \ 660 MACHINE_FLOAT64_BINOP_LIST(V) \ 661 MACHINE_FLOAT64_UNOP_LIST(V) \ 662 MACHINE_ATOMIC_OP_LIST(V) \ 663 V(AbortCSAAssert) \ 664 V(DebugBreak) \ 665 V(Comment) \ 666 V(Load) \ 667 V(PoisonedLoad) \ 668 V(Store) \ 669 V(StackSlot) \ 670 V(Word32Popcnt) \ 671 V(Word64Popcnt) \ 672 V(Word64Clz) \ 673 V(Word64Ctz) \ 674 V(Word64ReverseBits) \ 675 V(Word64ReverseBytes) \ 676 V(Simd128ReverseBytes) \ 677 V(Int64AbsWithOverflow) \ 678 V(BitcastTaggedToWord) \ 679 V(BitcastTaggedToWordForTagAndSmiBits) \ 680 V(BitcastWordToTagged) \ 681 V(BitcastWordToTaggedSigned) \ 682 V(TruncateFloat64ToWord32) \ 683 V(ChangeFloat32ToFloat64) \ 684 V(ChangeFloat64ToInt32) \ 685 V(ChangeFloat64ToInt64) \ 686 V(ChangeFloat64ToUint32) \ 687 V(ChangeFloat64ToUint64) \ 688 V(Float64SilenceNaN) \ 689 V(TruncateFloat64ToInt64) \ 690 V(TruncateFloat64ToUint32) \ 691 V(TruncateFloat32ToInt32) \ 692 V(TruncateFloat32ToUint32) \ 693 V(TryTruncateFloat32ToInt64) \ 694 V(TryTruncateFloat64ToInt64) \ 695 V(TryTruncateFloat32ToUint64) \ 696 V(TryTruncateFloat64ToUint64) \ 697 V(ChangeInt32ToFloat64) \ 698 V(BitcastWord32ToWord64) \ 699 V(ChangeInt32ToInt64) \ 700 V(ChangeInt64ToFloat64) \ 701 V(ChangeUint32ToFloat64) \ 702 V(ChangeUint32ToUint64) \ 703 V(TruncateFloat64ToFloat32) \ 704 V(TruncateInt64ToInt32) \ 705 V(RoundFloat64ToInt32) \ 706 V(RoundInt32ToFloat32) \ 707 V(RoundInt64ToFloat32) \ 708 V(RoundInt64ToFloat64) \ 709 V(RoundUint32ToFloat32) \ 710 V(RoundUint64ToFloat32) \ 711 V(RoundUint64ToFloat64) \ 712 V(BitcastFloat32ToInt32) \ 713 V(BitcastFloat64ToInt64) \ 714 V(BitcastInt32ToFloat32) \ 715 V(BitcastInt64ToFloat64) \ 716 V(Float64ExtractLowWord32) \ 717 V(Float64ExtractHighWord32) \ 718 V(Float64InsertLowWord32) \ 719 V(Float64InsertHighWord32) \ 720 V(TaggedPoisonOnSpeculation) \ 721 V(Word32PoisonOnSpeculation) \ 722 V(Word64PoisonOnSpeculation) \ 723 V(LoadStackCheckOffset) \ 724 V(LoadFramePointer) \ 725 V(LoadParentFramePointer) \ 726 V(UnalignedLoad) \ 727 V(UnalignedStore) \ 728 V(Int32PairAdd) \ 729 V(Int32PairSub) \ 730 V(Int32PairMul) \ 731 V(Word32PairShl) \ 732 V(Word32PairShr) \ 733 V(Word32PairSar) \ 734 V(ProtectedLoad) \ 735 V(ProtectedStore) \ 736 V(MemoryBarrier) \ 737 V(SignExtendWord8ToInt32) \ 738 V(SignExtendWord16ToInt32) \ 739 V(SignExtendWord8ToInt64) \ 740 V(SignExtendWord16ToInt64) \ 741 V(SignExtendWord32ToInt64) \ 742 V(UnsafePointerAdd) \ 743 V(StackPointerGreaterThan) 744 745 #define MACHINE_SIMD_OP_LIST(V) \ 746 V(F64x2Splat) \ 747 V(F64x2ExtractLane) \ 748 V(F64x2ReplaceLane) \ 749 V(F64x2Abs) \ 750 V(F64x2Neg) \ 751 V(F64x2Sqrt) \ 752 V(F64x2Add) \ 753 V(F64x2Sub) \ 754 V(F64x2Mul) \ 755 V(F64x2Div) \ 756 V(F64x2Min) \ 757 V(F64x2Max) \ 758 V(F64x2Eq) \ 759 V(F64x2Ne) \ 760 V(F64x2Lt) \ 761 V(F64x2Le) \ 762 V(F64x2Qfma) \ 763 V(F64x2Qfms) \ 764 V(F32x4Splat) \ 765 V(F32x4ExtractLane) \ 766 V(F32x4ReplaceLane) \ 767 V(F32x4SConvertI32x4) \ 768 V(F32x4UConvertI32x4) \ 769 V(F32x4Abs) \ 770 V(F32x4Neg) \ 771 V(F32x4Sqrt) \ 772 V(F32x4RecipApprox) \ 773 V(F32x4RecipSqrtApprox) \ 774 V(F32x4Add) \ 775 V(F32x4AddHoriz) \ 776 V(F32x4Sub) \ 777 V(F32x4Mul) \ 778 V(F32x4Div) \ 779 V(F32x4Min) \ 780 V(F32x4Max) \ 781 V(F32x4Eq) \ 782 V(F32x4Ne) \ 783 V(F32x4Lt) \ 784 V(F32x4Le) \ 785 V(F32x4Gt) \ 786 V(F32x4Ge) \ 787 V(F32x4Qfma) \ 788 V(F32x4Qfms) \ 789 V(I64x2Splat) \ 790 V(I64x2SplatI32Pair) \ 791 V(I64x2ExtractLane) \ 792 V(I64x2ReplaceLane) \ 793 V(I64x2ReplaceLaneI32Pair) \ 794 V(I64x2Neg) \ 795 V(I64x2Shl) \ 796 V(I64x2ShrS) \ 797 V(I64x2Add) \ 798 V(I64x2Sub) \ 799 V(I64x2Mul) \ 800 V(I64x2MinS) \ 801 V(I64x2MaxS) \ 802 V(I64x2Eq) \ 803 V(I64x2Ne) \ 804 V(I64x2GtS) \ 805 V(I64x2GeS) \ 806 V(I64x2ShrU) \ 807 V(I64x2MinU) \ 808 V(I64x2MaxU) \ 809 V(I64x2GtU) \ 810 V(I64x2GeU) \ 811 V(I32x4Splat) \ 812 V(I32x4ExtractLane) \ 813 V(I32x4ReplaceLane) \ 814 V(I32x4SConvertF32x4) \ 815 V(I32x4SConvertI16x8Low) \ 816 V(I32x4SConvertI16x8High) \ 817 V(I32x4Neg) \ 818 V(I32x4Shl) \ 819 V(I32x4ShrS) \ 820 V(I32x4Add) \ 821 V(I32x4AddHoriz) \ 822 V(I32x4Sub) \ 823 V(I32x4Mul) \ 824 V(I32x4MinS) \ 825 V(I32x4MaxS) \ 826 V(I32x4Eq) \ 827 V(I32x4Ne) \ 828 V(I32x4LtS) \ 829 V(I32x4LeS) \ 830 V(I32x4GtS) \ 831 V(I32x4GeS) \ 832 V(I32x4UConvertF32x4) \ 833 V(I32x4UConvertI16x8Low) \ 834 V(I32x4UConvertI16x8High) \ 835 V(I32x4ShrU) \ 836 V(I32x4MinU) \ 837 V(I32x4MaxU) \ 838 V(I32x4LtU) \ 839 V(I32x4LeU) \ 840 V(I32x4GtU) \ 841 V(I32x4GeU) \ 842 V(I32x4Abs) \ 843 V(I32x4BitMask) \ 844 V(I16x8Splat) \ 845 V(I16x8ExtractLaneU) \ 846 V(I16x8ExtractLaneS) \ 847 V(I16x8ReplaceLane) \ 848 V(I16x8SConvertI8x16Low) \ 849 V(I16x8SConvertI8x16High) \ 850 V(I16x8Neg) \ 851 V(I16x8Shl) \ 852 V(I16x8ShrS) \ 853 V(I16x8SConvertI32x4) \ 854 V(I16x8Add) \ 855 V(I16x8AddSaturateS) \ 856 V(I16x8AddHoriz) \ 857 V(I16x8Sub) \ 858 V(I16x8SubSaturateS) \ 859 V(I16x8Mul) \ 860 V(I16x8MinS) \ 861 V(I16x8MaxS) \ 862 V(I16x8Eq) \ 863 V(I16x8Ne) \ 864 V(I16x8LtS) \ 865 V(I16x8LeS) \ 866 V(I16x8GtS) \ 867 V(I16x8GeS) \ 868 V(I16x8UConvertI8x16Low) \ 869 V(I16x8UConvertI8x16High) \ 870 V(I16x8ShrU) \ 871 V(I16x8UConvertI32x4) \ 872 V(I16x8AddSaturateU) \ 873 V(I16x8SubSaturateU) \ 874 V(I16x8MinU) \ 875 V(I16x8MaxU) \ 876 V(I16x8LtU) \ 877 V(I16x8LeU) \ 878 V(I16x8GtU) \ 879 V(I16x8GeU) \ 880 V(I16x8RoundingAverageU) \ 881 V(I16x8Abs) \ 882 V(I16x8BitMask) \ 883 V(I8x16Splat) \ 884 V(I8x16ExtractLaneU) \ 885 V(I8x16ExtractLaneS) \ 886 V(I8x16ReplaceLane) \ 887 V(I8x16SConvertI16x8) \ 888 V(I8x16Neg) \ 889 V(I8x16Shl) \ 890 V(I8x16ShrS) \ 891 V(I8x16Add) \ 892 V(I8x16AddSaturateS) \ 893 V(I8x16Sub) \ 894 V(I8x16SubSaturateS) \ 895 V(I8x16Mul) \ 896 V(I8x16MinS) \ 897 V(I8x16MaxS) \ 898 V(I8x16Eq) \ 899 V(I8x16Ne) \ 900 V(I8x16LtS) \ 901 V(I8x16LeS) \ 902 V(I8x16GtS) \ 903 V(I8x16GeS) \ 904 V(I8x16UConvertI16x8) \ 905 V(I8x16AddSaturateU) \ 906 V(I8x16SubSaturateU) \ 907 V(I8x16ShrU) \ 908 V(I8x16MinU) \ 909 V(I8x16MaxU) \ 910 V(I8x16LtU) \ 911 V(I8x16LeU) \ 912 V(I8x16GtU) \ 913 V(I8x16GeU) \ 914 V(I8x16RoundingAverageU) \ 915 V(I8x16Abs) \ 916 V(I8x16BitMask) \ 917 V(S128Load) \ 918 V(S128Store) \ 919 V(S128Zero) \ 920 V(S128Not) \ 921 V(S128And) \ 922 V(S128Or) \ 923 V(S128Xor) \ 924 V(S128Select) \ 925 V(S128AndNot) \ 926 V(S8x16Swizzle) \ 927 V(S8x16Shuffle) \ 928 V(S1x2AnyTrue) \ 929 V(S1x2AllTrue) \ 930 V(S1x4AnyTrue) \ 931 V(S1x4AllTrue) \ 932 V(S1x8AnyTrue) \ 933 V(S1x8AllTrue) \ 934 V(S1x16AnyTrue) \ 935 V(S1x16AllTrue) \ 936 V(LoadTransform) 937 938 #define VALUE_OP_LIST(V) \ 939 COMMON_OP_LIST(V) \ 940 SIMPLIFIED_OP_LIST(V) \ 941 MACHINE_OP_LIST(V) \ 942 MACHINE_SIMD_OP_LIST(V) \ 943 JS_OP_LIST(V) 944 945 // The combination of all operators at all levels and the common operators. 946 #define ALL_OP_LIST(V) \ 947 CONTROL_OP_LIST(V) \ 948 VALUE_OP_LIST(V) 949 950 namespace v8 { 951 namespace internal { 952 namespace compiler { 953 954 // Declare an enumeration with all the opcodes at all levels so that they 955 // can be globally, uniquely numbered. 956 class V8_EXPORT_PRIVATE IrOpcode { 957 public: 958 enum Value { 959 #define DECLARE_OPCODE(x) k##x, 960 ALL_OP_LIST(DECLARE_OPCODE) 961 #undef DECLARE_OPCODE 962 kLast = -1 963 #define COUNT_OPCODE(x) +1 964 ALL_OP_LIST(COUNT_OPCODE) 965 #undef COUNT_OPCODE 966 }; 967 968 // Returns the mnemonic name of an opcode. 969 static char const* Mnemonic(Value value); 970 971 // Returns true if opcode for common operator. IsCommonOpcode(Value value)972 static bool IsCommonOpcode(Value value) { 973 return kStart <= value && value <= kStaticAssert; 974 } 975 976 // Returns true if opcode for control operator. IsControlOpcode(Value value)977 static bool IsControlOpcode(Value value) { 978 return kStart <= value && value <= kEnd; 979 } 980 981 // Returns true if opcode for JavaScript operator. IsJsOpcode(Value value)982 static bool IsJsOpcode(Value value) { 983 return kJSEqual <= value && value <= kJSDebugger; 984 } 985 986 // Returns true if opcode for constant operator. IsConstantOpcode(Value value)987 static bool IsConstantOpcode(Value value) { 988 return kInt32Constant <= value && value <= kRelocatableInt64Constant; 989 } 990 IsPhiOpcode(Value value)991 static bool IsPhiOpcode(Value value) { 992 return value == kPhi || value == kEffectPhi; 993 } 994 IsMergeOpcode(Value value)995 static bool IsMergeOpcode(Value value) { 996 return value == kMerge || value == kLoop; 997 } 998 IsIfProjectionOpcode(Value value)999 static bool IsIfProjectionOpcode(Value value) { 1000 return kIfTrue <= value && value <= kIfDefault; 1001 } 1002 1003 // Returns true if opcode terminates control flow in a graph (i.e. respective 1004 // nodes are expected to have control uses by the graphs {End} node only). IsGraphTerminator(Value value)1005 static bool IsGraphTerminator(Value value) { 1006 return value == kDeoptimize || value == kReturn || value == kTailCall || 1007 value == kTerminate || value == kThrow; 1008 } 1009 1010 // Returns true if opcode can be inlined. IsInlineeOpcode(Value value)1011 static bool IsInlineeOpcode(Value value) { 1012 return value == kJSConstruct || value == kJSCall; 1013 } 1014 1015 // Returns true if opcode for comparison operator. IsComparisonOpcode(Value value)1016 static bool IsComparisonOpcode(Value value) { 1017 return (kJSEqual <= value && value <= kJSGreaterThanOrEqual) || 1018 (kNumberEqual <= value && value <= kStringLessThanOrEqual) || 1019 (kWord32Equal <= value && value <= kFloat64LessThanOrEqual); 1020 } 1021 IsContextChainExtendingOpcode(Value value)1022 static bool IsContextChainExtendingOpcode(Value value) { 1023 return kJSCreateFunctionContext <= value && value <= kJSCreateBlockContext; 1024 } 1025 }; 1026 1027 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, IrOpcode::Value); 1028 1029 } // namespace compiler 1030 } // namespace internal 1031 } // namespace v8 1032 1033 #endif // V8_COMPILER_OPCODES_H_ 1034