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(Plug) \ 86 V(SLVerifierHint) \ 87 V(StaticAssert) 88 89 // Opcodes for JavaScript operators. 90 // Arguments are JSName (the name with a 'JS' prefix), and Name. 91 #define JS_COMPARE_BINOP_LIST(V) \ 92 V(JSEqual, Equal) \ 93 V(JSStrictEqual, StrictEqual) \ 94 V(JSLessThan, LessThan) \ 95 V(JSGreaterThan, GreaterThan) \ 96 V(JSLessThanOrEqual, LessThanOrEqual) \ 97 V(JSGreaterThanOrEqual, GreaterThanOrEqual) 98 99 #define JS_BITWISE_BINOP_LIST(V) \ 100 V(JSBitwiseOr, BitwiseOr) \ 101 V(JSBitwiseXor, BitwiseXor) \ 102 V(JSBitwiseAnd, BitwiseAnd) \ 103 V(JSShiftLeft, ShiftLeft) \ 104 V(JSShiftRight, ShiftRight) \ 105 V(JSShiftRightLogical, ShiftRightLogical) 106 107 #define JS_ARITH_BINOP_LIST(V) \ 108 V(JSAdd, Add) \ 109 V(JSSubtract, Subtract) \ 110 V(JSMultiply, Multiply) \ 111 V(JSDivide, Divide) \ 112 V(JSModulus, Modulus) \ 113 V(JSExponentiate, Exponentiate) 114 115 #define JS_SIMPLE_BINOP_LIST(V) \ 116 JS_COMPARE_BINOP_LIST(V) \ 117 JS_BITWISE_BINOP_LIST(V) \ 118 JS_ARITH_BINOP_LIST(V) \ 119 V(JSHasInPrototypeChain) \ 120 V(JSInstanceOf) \ 121 V(JSOrdinaryHasInstance) 122 123 #define JS_CONVERSION_UNOP_LIST(V) \ 124 V(JSToLength) \ 125 V(JSToName) \ 126 V(JSToNumber) \ 127 V(JSToNumberConvertBigInt) \ 128 V(JSToNumeric) \ 129 V(JSToObject) \ 130 V(JSToString) \ 131 V(JSParseInt) 132 133 #define JS_BITWISE_UNOP_LIST(V) \ 134 V(JSBitwiseNot, BitwiseNot) \ 135 V(JSNegate, Negate) 136 137 #define JS_ARITH_UNOP_LIST(V) \ 138 V(JSDecrement, Decrement) \ 139 V(JSIncrement, Increment) 140 141 #define JS_SIMPLE_UNOP_LIST(V) \ 142 JS_ARITH_UNOP_LIST(V) \ 143 JS_BITWISE_UNOP_LIST(V) \ 144 JS_CONVERSION_UNOP_LIST(V) 145 146 #define JS_CREATE_OP_LIST(V) \ 147 V(JSCloneObject) \ 148 V(JSCreate) \ 149 V(JSCreateArguments) \ 150 V(JSCreateArray) \ 151 V(JSCreateArrayFromIterable) \ 152 V(JSCreateArrayIterator) \ 153 V(JSCreateAsyncFunctionObject) \ 154 V(JSCreateBoundFunction) \ 155 V(JSCreateClosure) \ 156 V(JSCreateCollectionIterator) \ 157 V(JSCreateEmptyLiteralArray) \ 158 V(JSCreateEmptyLiteralObject) \ 159 V(JSCreateGeneratorObject) \ 160 V(JSCreateIterResultObject) \ 161 V(JSCreateKeyValueArray) \ 162 V(JSCreateLiteralArray) \ 163 V(JSCreateLiteralObject) \ 164 V(JSCreateLiteralRegExp) \ 165 V(JSCreateObject) \ 166 V(JSCreatePromise) \ 167 V(JSCreateStringIterator) \ 168 V(JSCreateTypedArray) \ 169 V(JSGetTemplateObject) 170 171 #define JS_OBJECT_OP_LIST(V) \ 172 JS_CREATE_OP_LIST(V) \ 173 V(JSLoadProperty) \ 174 V(JSLoadNamed) \ 175 V(JSLoadNamedFromSuper) \ 176 V(JSLoadGlobal) \ 177 V(JSSetKeyedProperty) \ 178 V(JSDefineKeyedOwnProperty) \ 179 V(JSSetNamedProperty) \ 180 V(JSDefineNamedOwnProperty) \ 181 V(JSStoreGlobal) \ 182 V(JSDefineKeyedOwnPropertyInLiteral) \ 183 V(JSStoreInArrayLiteral) \ 184 V(JSDeleteProperty) \ 185 V(JSHasProperty) \ 186 V(JSGetSuperConstructor) 187 188 #define JS_CONTEXT_OP_LIST(V) \ 189 V(JSHasContextExtension) \ 190 V(JSLoadContext) \ 191 V(JSStoreContext) \ 192 V(JSCreateFunctionContext) \ 193 V(JSCreateCatchContext) \ 194 V(JSCreateWithContext) \ 195 V(JSCreateBlockContext) 196 197 #define JS_CALL_OP_LIST(V) \ 198 V(JSCall) \ 199 V(JSCallForwardVarargs) \ 200 V(JSCallWithArrayLike) \ 201 V(JSCallWithSpread) \ 202 IF_WASM(V, JSWasmCall) 203 204 #define JS_CONSTRUCT_OP_LIST(V) \ 205 V(JSConstructForwardVarargs) \ 206 V(JSConstruct) \ 207 V(JSConstructWithArrayLike) \ 208 V(JSConstructWithSpread) 209 210 #define JS_OTHER_OP_LIST(V) \ 211 JS_CALL_OP_LIST(V) \ 212 JS_CONSTRUCT_OP_LIST(V) \ 213 V(JSAsyncFunctionEnter) \ 214 V(JSAsyncFunctionReject) \ 215 V(JSAsyncFunctionResolve) \ 216 V(JSCallRuntime) \ 217 V(JSForInEnumerate) \ 218 V(JSForInNext) \ 219 V(JSForInPrepare) \ 220 V(JSGetIterator) \ 221 V(JSLoadMessage) \ 222 V(JSStoreMessage) \ 223 V(JSLoadModule) \ 224 V(JSStoreModule) \ 225 V(JSGetImportMeta) \ 226 V(JSGeneratorStore) \ 227 V(JSGeneratorRestoreContinuation) \ 228 V(JSGeneratorRestoreContext) \ 229 V(JSGeneratorRestoreRegister) \ 230 V(JSGeneratorRestoreInputOrDebugPos) \ 231 V(JSFulfillPromise) \ 232 V(JSPerformPromiseThen) \ 233 V(JSPromiseResolve) \ 234 V(JSRejectPromise) \ 235 V(JSResolvePromise) \ 236 V(JSStackCheck) \ 237 V(JSObjectIsArray) \ 238 V(JSRegExpTest) \ 239 V(JSDebugger) 240 241 #define JS_OP_LIST(V) \ 242 JS_SIMPLE_BINOP_LIST(V) \ 243 JS_SIMPLE_UNOP_LIST(V) \ 244 JS_OBJECT_OP_LIST(V) \ 245 JS_CONTEXT_OP_LIST(V) \ 246 JS_OTHER_OP_LIST(V) 247 248 // Opcodes for VirtuaMachine-level operators. 249 #define SIMPLIFIED_CHANGE_OP_LIST(V) \ 250 V(ChangeTaggedSignedToInt32) \ 251 V(ChangeTaggedSignedToInt64) \ 252 V(ChangeTaggedToInt32) \ 253 V(ChangeTaggedToInt64) \ 254 V(ChangeTaggedToUint32) \ 255 V(ChangeTaggedToFloat64) \ 256 V(ChangeTaggedToTaggedSigned) \ 257 V(ChangeInt31ToTaggedSigned) \ 258 V(ChangeInt32ToTagged) \ 259 V(ChangeInt64ToTagged) \ 260 V(ChangeUint32ToTagged) \ 261 V(ChangeUint64ToTagged) \ 262 V(ChangeFloat64ToTagged) \ 263 V(ChangeFloat64ToTaggedPointer) \ 264 V(ChangeTaggedToBit) \ 265 V(ChangeBitToTagged) \ 266 V(ChangeInt64ToBigInt) \ 267 V(ChangeUint64ToBigInt) \ 268 V(TruncateBigIntToWord64) \ 269 V(TruncateTaggedToWord32) \ 270 V(TruncateTaggedToFloat64) \ 271 V(TruncateTaggedToBit) \ 272 V(TruncateTaggedPointerToBit) 273 274 #define SIMPLIFIED_CHECKED_OP_LIST(V) \ 275 V(CheckedInt32Add) \ 276 V(CheckedInt32Sub) \ 277 V(CheckedInt32Div) \ 278 V(CheckedInt32Mod) \ 279 V(CheckedUint32Div) \ 280 V(CheckedUint32Mod) \ 281 V(CheckedInt32Mul) \ 282 V(CheckedInt32ToTaggedSigned) \ 283 V(CheckedInt64ToInt32) \ 284 V(CheckedInt64ToTaggedSigned) \ 285 V(CheckedUint32Bounds) \ 286 V(CheckedUint32ToInt32) \ 287 V(CheckedUint32ToTaggedSigned) \ 288 V(CheckedUint64Bounds) \ 289 V(CheckedUint64ToInt32) \ 290 V(CheckedUint64ToTaggedSigned) \ 291 V(CheckedFloat64ToInt32) \ 292 V(CheckedFloat64ToInt64) \ 293 V(CheckedTaggedSignedToInt32) \ 294 V(CheckedTaggedToInt32) \ 295 V(CheckedTaggedToArrayIndex) \ 296 V(CheckedTruncateTaggedToWord32) \ 297 V(CheckedTaggedToFloat64) \ 298 V(CheckedTaggedToInt64) \ 299 V(CheckedTaggedToTaggedSigned) \ 300 V(CheckedTaggedToTaggedPointer) 301 302 #define SIMPLIFIED_COMPARE_BINOP_LIST(V) \ 303 V(NumberEqual) \ 304 V(NumberLessThan) \ 305 V(NumberLessThanOrEqual) \ 306 V(SpeculativeNumberEqual) \ 307 V(SpeculativeNumberLessThan) \ 308 V(SpeculativeNumberLessThanOrEqual) \ 309 V(ReferenceEqual) \ 310 V(SameValue) \ 311 V(SameValueNumbersOnly) \ 312 V(NumberSameValue) \ 313 V(StringEqual) \ 314 V(StringLessThan) \ 315 V(StringLessThanOrEqual) 316 317 #define SIMPLIFIED_NUMBER_BINOP_LIST(V) \ 318 V(NumberAdd) \ 319 V(NumberSubtract) \ 320 V(NumberMultiply) \ 321 V(NumberDivide) \ 322 V(NumberModulus) \ 323 V(NumberBitwiseOr) \ 324 V(NumberBitwiseXor) \ 325 V(NumberBitwiseAnd) \ 326 V(NumberShiftLeft) \ 327 V(NumberShiftRight) \ 328 V(NumberShiftRightLogical) \ 329 V(NumberAtan2) \ 330 V(NumberImul) \ 331 V(NumberMax) \ 332 V(NumberMin) \ 333 V(NumberPow) 334 335 #define SIMPLIFIED_BIGINT_BINOP_LIST(V) \ 336 V(BigIntAdd) \ 337 V(BigIntSubtract) 338 339 #define SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(V) \ 340 V(SpeculativeNumberAdd) \ 341 V(SpeculativeNumberSubtract) \ 342 V(SpeculativeNumberMultiply) \ 343 V(SpeculativeNumberPow) \ 344 V(SpeculativeNumberDivide) \ 345 V(SpeculativeNumberModulus) \ 346 V(SpeculativeNumberBitwiseAnd) \ 347 V(SpeculativeNumberBitwiseOr) \ 348 V(SpeculativeNumberBitwiseXor) \ 349 V(SpeculativeNumberShiftLeft) \ 350 V(SpeculativeNumberShiftRight) \ 351 V(SpeculativeNumberShiftRightLogical) \ 352 V(SpeculativeSafeIntegerAdd) \ 353 V(SpeculativeSafeIntegerSubtract) 354 355 #define SIMPLIFIED_NUMBER_UNOP_LIST(V) \ 356 V(NumberAbs) \ 357 V(NumberAcos) \ 358 V(NumberAcosh) \ 359 V(NumberAsin) \ 360 V(NumberAsinh) \ 361 V(NumberAtan) \ 362 V(NumberAtanh) \ 363 V(NumberCbrt) \ 364 V(NumberCeil) \ 365 V(NumberClz32) \ 366 V(NumberCos) \ 367 V(NumberCosh) \ 368 V(NumberExp) \ 369 V(NumberExpm1) \ 370 V(NumberFloor) \ 371 V(NumberFround) \ 372 V(NumberLog) \ 373 V(NumberLog1p) \ 374 V(NumberLog2) \ 375 V(NumberLog10) \ 376 V(NumberRound) \ 377 V(NumberSign) \ 378 V(NumberSin) \ 379 V(NumberSinh) \ 380 V(NumberSqrt) \ 381 V(NumberTan) \ 382 V(NumberTanh) \ 383 V(NumberTrunc) \ 384 V(NumberToBoolean) \ 385 V(NumberToInt32) \ 386 V(NumberToString) \ 387 V(NumberToUint32) \ 388 V(NumberToUint8Clamped) \ 389 V(NumberSilenceNaN) 390 391 #define SIMPLIFIED_BIGINT_UNOP_LIST(V) \ 392 V(BigIntNegate) \ 393 V(CheckBigInt) 394 395 #define SIMPLIFIED_SPECULATIVE_NUMBER_UNOP_LIST(V) V(SpeculativeToNumber) 396 397 #define SIMPLIFIED_OTHER_OP_LIST(V) \ 398 V(Allocate) \ 399 V(AllocateRaw) \ 400 V(ArgumentsLength) \ 401 V(AssertType) \ 402 V(BooleanNot) \ 403 V(CheckBounds) \ 404 V(CheckClosure) \ 405 V(CheckEqualsInternalizedString) \ 406 V(CheckEqualsSymbol) \ 407 V(CheckFloat64Hole) \ 408 V(CheckHeapObject) \ 409 V(CheckIf) \ 410 V(CheckInternalizedString) \ 411 V(CheckMaps) \ 412 V(CheckNotTaggedHole) \ 413 V(CheckNumber) \ 414 V(CheckReceiver) \ 415 V(CheckReceiverOrNullOrUndefined) \ 416 V(CheckSmi) \ 417 V(CheckString) \ 418 V(CheckSymbol) \ 419 V(CompareMaps) \ 420 V(ConvertReceiver) \ 421 V(ConvertTaggedHoleToUndefined) \ 422 V(DateNow) \ 423 V(DelayedStringConstant) \ 424 V(EnsureWritableFastElements) \ 425 V(FastApiCall) \ 426 V(FindOrderedHashMapEntry) \ 427 V(FindOrderedHashMapEntryForInt32Key) \ 428 V(InitializeImmutableInObject) \ 429 V(LoadDataViewElement) \ 430 V(LoadElement) \ 431 V(LoadField) \ 432 V(LoadFieldByIndex) \ 433 V(LoadFromObject) \ 434 V(LoadImmutableFromObject) \ 435 V(LoadMessage) \ 436 V(LoadStackArgument) \ 437 V(LoadTypedElement) \ 438 V(MaybeGrowFastElements) \ 439 V(NewArgumentsElements) \ 440 V(NewConsString) \ 441 V(NewDoubleElements) \ 442 V(NewSmiOrObjectElements) \ 443 V(NumberIsFinite) \ 444 V(NumberIsFloat64Hole) \ 445 V(NumberIsInteger) \ 446 V(NumberIsMinusZero) \ 447 V(NumberIsNaN) \ 448 V(NumberIsSafeInteger) \ 449 V(ObjectIsArrayBufferView) \ 450 V(ObjectIsBigInt) \ 451 V(ObjectIsCallable) \ 452 V(ObjectIsConstructor) \ 453 V(ObjectIsDetectableCallable) \ 454 V(ObjectIsFiniteNumber) \ 455 V(ObjectIsInteger) \ 456 V(ObjectIsMinusZero) \ 457 V(ObjectIsNaN) \ 458 V(ObjectIsNonCallable) \ 459 V(ObjectIsNumber) \ 460 V(ObjectIsReceiver) \ 461 V(ObjectIsSafeInteger) \ 462 V(ObjectIsSmi) \ 463 V(ObjectIsString) \ 464 V(ObjectIsSymbol) \ 465 V(ObjectIsUndetectable) \ 466 V(PlainPrimitiveToFloat64) \ 467 V(PlainPrimitiveToNumber) \ 468 V(PlainPrimitiveToWord32) \ 469 V(RestLength) \ 470 V(RuntimeAbort) \ 471 V(StoreDataViewElement) \ 472 V(StoreElement) \ 473 V(StoreField) \ 474 V(StoreMessage) \ 475 V(StoreSignedSmallElement) \ 476 V(StoreToObject) \ 477 V(StoreTypedElement) \ 478 V(StringCharCodeAt) \ 479 V(StringCodePointAt) \ 480 V(StringConcat) \ 481 V(StringFromCodePointAt) \ 482 V(StringFromSingleCharCode) \ 483 V(StringFromSingleCodePoint) \ 484 V(StringIndexOf) \ 485 V(StringLength) \ 486 V(StringSubstring) \ 487 V(StringToLowerCaseIntl) \ 488 V(StringToNumber) \ 489 V(StringToUpperCaseIntl) \ 490 V(ToBoolean) \ 491 V(TransitionAndStoreElement) \ 492 V(TransitionAndStoreNonNumberElement) \ 493 V(TransitionAndStoreNumberElement) \ 494 V(TransitionElementsKind) \ 495 V(TypeOf) \ 496 V(VerifyType) 497 498 #define SIMPLIFIED_SPECULATIVE_BIGINT_BINOP_LIST(V) \ 499 V(SpeculativeBigIntAdd) \ 500 V(SpeculativeBigIntSubtract) 501 502 #define SIMPLIFIED_SPECULATIVE_BIGINT_UNOP_LIST(V) \ 503 V(SpeculativeBigIntAsIntN) \ 504 V(SpeculativeBigIntAsUintN) \ 505 V(SpeculativeBigIntNegate) 506 507 #define SIMPLIFIED_OP_LIST(V) \ 508 SIMPLIFIED_CHANGE_OP_LIST(V) \ 509 SIMPLIFIED_CHECKED_OP_LIST(V) \ 510 SIMPLIFIED_COMPARE_BINOP_LIST(V) \ 511 SIMPLIFIED_NUMBER_BINOP_LIST(V) \ 512 SIMPLIFIED_BIGINT_BINOP_LIST(V) \ 513 SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(V) \ 514 SIMPLIFIED_NUMBER_UNOP_LIST(V) \ 515 SIMPLIFIED_BIGINT_UNOP_LIST(V) \ 516 SIMPLIFIED_SPECULATIVE_NUMBER_UNOP_LIST(V) \ 517 SIMPLIFIED_SPECULATIVE_BIGINT_UNOP_LIST(V) \ 518 SIMPLIFIED_SPECULATIVE_BIGINT_BINOP_LIST(V) \ 519 SIMPLIFIED_OTHER_OP_LIST(V) 520 521 // Opcodes for Machine-level operators. 522 #define MACHINE_COMPARE_BINOP_LIST(V) \ 523 V(Word32Equal) \ 524 V(Word64Equal) \ 525 V(Int32LessThan) \ 526 V(Int32LessThanOrEqual) \ 527 V(Uint32LessThan) \ 528 V(Uint32LessThanOrEqual) \ 529 V(Int64LessThan) \ 530 V(Int64LessThanOrEqual) \ 531 V(Uint64LessThan) \ 532 V(Uint64LessThanOrEqual) \ 533 V(Float32Equal) \ 534 V(Float32LessThan) \ 535 V(Float32LessThanOrEqual) \ 536 V(Float64Equal) \ 537 V(Float64LessThan) \ 538 V(Float64LessThanOrEqual) 539 540 #define MACHINE_UNOP_32_LIST(V) \ 541 V(Word32Clz) \ 542 V(Word32Ctz) \ 543 V(Int32AbsWithOverflow) \ 544 V(Word32ReverseBits) \ 545 V(Word32ReverseBytes) 546 547 #define MACHINE_BINOP_32_LIST(V) \ 548 V(Word32And) \ 549 V(Word32Or) \ 550 V(Word32Xor) \ 551 V(Word32Shl) \ 552 V(Word32Shr) \ 553 V(Word32Sar) \ 554 V(Word32Rol) \ 555 V(Word32Ror) \ 556 V(Int32Add) \ 557 V(Int32AddWithOverflow) \ 558 V(Int32Sub) \ 559 V(Int32SubWithOverflow) \ 560 V(Int32Mul) \ 561 V(Int32MulWithOverflow) \ 562 V(Int32MulHigh) \ 563 V(Int32Div) \ 564 V(Int32Mod) \ 565 V(Uint32Div) \ 566 V(Uint32Mod) \ 567 V(Uint32MulHigh) 568 569 #define MACHINE_BINOP_64_LIST(V) \ 570 V(Word64And) \ 571 V(Word64Or) \ 572 V(Word64Xor) \ 573 V(Word64Shl) \ 574 V(Word64Shr) \ 575 V(Word64Sar) \ 576 V(Word64Rol) \ 577 V(Word64Ror) \ 578 V(Word64RolLowerable) \ 579 V(Word64RorLowerable) \ 580 V(Int64Add) \ 581 V(Int64AddWithOverflow) \ 582 V(Int64Sub) \ 583 V(Int64SubWithOverflow) \ 584 V(Int64Mul) \ 585 V(Int64Div) \ 586 V(Int64Mod) \ 587 V(Uint64Div) \ 588 V(Uint64Mod) 589 590 #define MACHINE_FLOAT32_UNOP_LIST(V) \ 591 V(Float32Abs) \ 592 V(Float32Neg) \ 593 V(Float32RoundDown) \ 594 V(Float32RoundTiesEven) \ 595 V(Float32RoundTruncate) \ 596 V(Float32RoundUp) \ 597 V(Float32Sqrt) 598 599 #define MACHINE_FLOAT32_BINOP_LIST(V) \ 600 V(Float32Add) \ 601 V(Float32Sub) \ 602 V(Float32Mul) \ 603 V(Float32Div) \ 604 V(Float32Max) \ 605 V(Float32Min) 606 607 #define MACHINE_FLOAT64_UNOP_LIST(V) \ 608 V(Float64Abs) \ 609 V(Float64Acos) \ 610 V(Float64Acosh) \ 611 V(Float64Asin) \ 612 V(Float64Asinh) \ 613 V(Float64Atan) \ 614 V(Float64Atanh) \ 615 V(Float64Cbrt) \ 616 V(Float64Cos) \ 617 V(Float64Cosh) \ 618 V(Float64Exp) \ 619 V(Float64Expm1) \ 620 V(Float64Log) \ 621 V(Float64Log1p) \ 622 V(Float64Log10) \ 623 V(Float64Log2) \ 624 V(Float64Neg) \ 625 V(Float64RoundDown) \ 626 V(Float64RoundTiesAway) \ 627 V(Float64RoundTiesEven) \ 628 V(Float64RoundTruncate) \ 629 V(Float64RoundUp) \ 630 V(Float64Sin) \ 631 V(Float64Sinh) \ 632 V(Float64Sqrt) \ 633 V(Float64Tan) \ 634 V(Float64Tanh) 635 636 #define MACHINE_FLOAT64_BINOP_LIST(V) \ 637 V(Float64Atan2) \ 638 V(Float64Max) \ 639 V(Float64Min) \ 640 V(Float64Add) \ 641 V(Float64Sub) \ 642 V(Float64Mul) \ 643 V(Float64Div) \ 644 V(Float64Mod) \ 645 V(Float64Pow) 646 647 #define MACHINE_ATOMIC_OP_LIST(V) \ 648 V(Word32AtomicLoad) \ 649 V(Word32AtomicStore) \ 650 V(Word32AtomicExchange) \ 651 V(Word32AtomicCompareExchange) \ 652 V(Word32AtomicAdd) \ 653 V(Word32AtomicSub) \ 654 V(Word32AtomicAnd) \ 655 V(Word32AtomicOr) \ 656 V(Word32AtomicXor) \ 657 V(Word32AtomicPairLoad) \ 658 V(Word32AtomicPairStore) \ 659 V(Word32AtomicPairAdd) \ 660 V(Word32AtomicPairSub) \ 661 V(Word32AtomicPairAnd) \ 662 V(Word32AtomicPairOr) \ 663 V(Word32AtomicPairXor) \ 664 V(Word32AtomicPairExchange) \ 665 V(Word32AtomicPairCompareExchange) \ 666 V(Word64AtomicLoad) \ 667 V(Word64AtomicStore) \ 668 V(Word64AtomicAdd) \ 669 V(Word64AtomicSub) \ 670 V(Word64AtomicAnd) \ 671 V(Word64AtomicOr) \ 672 V(Word64AtomicXor) \ 673 V(Word64AtomicExchange) \ 674 V(Word64AtomicCompareExchange) 675 676 #define MACHINE_OP_LIST(V) \ 677 MACHINE_UNOP_32_LIST(V) \ 678 MACHINE_BINOP_32_LIST(V) \ 679 MACHINE_BINOP_64_LIST(V) \ 680 MACHINE_COMPARE_BINOP_LIST(V) \ 681 MACHINE_FLOAT32_BINOP_LIST(V) \ 682 MACHINE_FLOAT32_UNOP_LIST(V) \ 683 MACHINE_FLOAT64_BINOP_LIST(V) \ 684 MACHINE_FLOAT64_UNOP_LIST(V) \ 685 MACHINE_ATOMIC_OP_LIST(V) \ 686 V(AbortCSADcheck) \ 687 V(DebugBreak) \ 688 V(Comment) \ 689 V(Load) \ 690 V(LoadImmutable) \ 691 V(Store) \ 692 V(StackSlot) \ 693 V(Word32Popcnt) \ 694 V(Word64Popcnt) \ 695 V(Word64Clz) \ 696 V(Word64Ctz) \ 697 V(Word64ClzLowerable) \ 698 V(Word64CtzLowerable) \ 699 V(Word64ReverseBits) \ 700 V(Word64ReverseBytes) \ 701 V(Simd128ReverseBytes) \ 702 V(Int64AbsWithOverflow) \ 703 V(BitcastTaggedToWord) \ 704 V(BitcastTaggedToWordForTagAndSmiBits) \ 705 V(BitcastWordToTagged) \ 706 V(BitcastWordToTaggedSigned) \ 707 V(TruncateFloat64ToWord32) \ 708 V(ChangeFloat32ToFloat64) \ 709 V(ChangeFloat64ToInt32) \ 710 V(ChangeFloat64ToInt64) \ 711 V(ChangeFloat64ToUint32) \ 712 V(ChangeFloat64ToUint64) \ 713 V(Float64SilenceNaN) \ 714 V(TruncateFloat64ToInt64) \ 715 V(TruncateFloat64ToUint32) \ 716 V(TruncateFloat32ToInt32) \ 717 V(TruncateFloat32ToUint32) \ 718 V(TryTruncateFloat32ToInt64) \ 719 V(TryTruncateFloat64ToInt64) \ 720 V(TryTruncateFloat32ToUint64) \ 721 V(TryTruncateFloat64ToUint64) \ 722 V(ChangeInt32ToFloat64) \ 723 V(BitcastWord32ToWord64) \ 724 V(ChangeInt32ToInt64) \ 725 V(ChangeInt64ToFloat64) \ 726 V(ChangeUint32ToFloat64) \ 727 V(ChangeUint32ToUint64) \ 728 V(TruncateFloat64ToFloat32) \ 729 V(TruncateInt64ToInt32) \ 730 V(RoundFloat64ToInt32) \ 731 V(RoundInt32ToFloat32) \ 732 V(RoundInt64ToFloat32) \ 733 V(RoundInt64ToFloat64) \ 734 V(RoundUint32ToFloat32) \ 735 V(RoundUint64ToFloat32) \ 736 V(RoundUint64ToFloat64) \ 737 V(BitcastFloat32ToInt32) \ 738 V(BitcastFloat64ToInt64) \ 739 V(BitcastInt32ToFloat32) \ 740 V(BitcastInt64ToFloat64) \ 741 V(Float64ExtractLowWord32) \ 742 V(Float64ExtractHighWord32) \ 743 V(Float64InsertLowWord32) \ 744 V(Float64InsertHighWord32) \ 745 V(Word32Select) \ 746 V(Word64Select) \ 747 V(Float32Select) \ 748 V(Float64Select) \ 749 V(LoadStackCheckOffset) \ 750 V(LoadFramePointer) \ 751 V(LoadParentFramePointer) \ 752 V(UnalignedLoad) \ 753 V(UnalignedStore) \ 754 V(Int32PairAdd) \ 755 V(Int32PairSub) \ 756 V(Int32PairMul) \ 757 V(Word32PairShl) \ 758 V(Word32PairShr) \ 759 V(Word32PairSar) \ 760 V(ProtectedLoad) \ 761 V(ProtectedStore) \ 762 V(MemoryBarrier) \ 763 V(SignExtendWord8ToInt32) \ 764 V(SignExtendWord16ToInt32) \ 765 V(SignExtendWord8ToInt64) \ 766 V(SignExtendWord16ToInt64) \ 767 V(SignExtendWord32ToInt64) \ 768 V(UnsafePointerAdd) \ 769 V(StackPointerGreaterThan) 770 771 #define MACHINE_SIMD_OP_LIST(V) \ 772 V(F64x2Splat) \ 773 V(F64x2ExtractLane) \ 774 V(F64x2ReplaceLane) \ 775 V(F64x2Abs) \ 776 V(F64x2Neg) \ 777 V(F64x2Sqrt) \ 778 V(F64x2Add) \ 779 V(F64x2Sub) \ 780 V(F64x2Mul) \ 781 V(F64x2Div) \ 782 V(F64x2Min) \ 783 V(F64x2Max) \ 784 V(F64x2Eq) \ 785 V(F64x2Ne) \ 786 V(F64x2Lt) \ 787 V(F64x2Le) \ 788 V(F64x2Qfma) \ 789 V(F64x2Qfms) \ 790 V(F64x2Pmin) \ 791 V(F64x2Pmax) \ 792 V(F64x2Ceil) \ 793 V(F64x2Floor) \ 794 V(F64x2Trunc) \ 795 V(F64x2NearestInt) \ 796 V(F64x2ConvertLowI32x4S) \ 797 V(F64x2ConvertLowI32x4U) \ 798 V(F64x2PromoteLowF32x4) \ 799 V(F32x4Splat) \ 800 V(F32x4ExtractLane) \ 801 V(F32x4ReplaceLane) \ 802 V(F32x4SConvertI32x4) \ 803 V(F32x4UConvertI32x4) \ 804 V(F32x4Abs) \ 805 V(F32x4Neg) \ 806 V(F32x4Sqrt) \ 807 V(F32x4RecipApprox) \ 808 V(F32x4RecipSqrtApprox) \ 809 V(F32x4Add) \ 810 V(F32x4Sub) \ 811 V(F32x4Mul) \ 812 V(F32x4Div) \ 813 V(F32x4Min) \ 814 V(F32x4Max) \ 815 V(F32x4Eq) \ 816 V(F32x4Ne) \ 817 V(F32x4Lt) \ 818 V(F32x4Le) \ 819 V(F32x4Gt) \ 820 V(F32x4Ge) \ 821 V(F32x4Qfma) \ 822 V(F32x4Qfms) \ 823 V(F32x4Pmin) \ 824 V(F32x4Pmax) \ 825 V(F32x4Ceil) \ 826 V(F32x4Floor) \ 827 V(F32x4Trunc) \ 828 V(F32x4NearestInt) \ 829 V(F32x4DemoteF64x2Zero) \ 830 V(I64x2Splat) \ 831 V(I64x2SplatI32Pair) \ 832 V(I64x2ExtractLane) \ 833 V(I64x2ReplaceLane) \ 834 V(I64x2ReplaceLaneI32Pair) \ 835 V(I64x2Abs) \ 836 V(I64x2Neg) \ 837 V(I64x2SConvertI32x4Low) \ 838 V(I64x2SConvertI32x4High) \ 839 V(I64x2UConvertI32x4Low) \ 840 V(I64x2UConvertI32x4High) \ 841 V(I64x2BitMask) \ 842 V(I64x2Shl) \ 843 V(I64x2ShrS) \ 844 V(I64x2Add) \ 845 V(I64x2Sub) \ 846 V(I64x2Mul) \ 847 V(I64x2Eq) \ 848 V(I64x2Ne) \ 849 V(I64x2GtS) \ 850 V(I64x2GeS) \ 851 V(I64x2ShrU) \ 852 V(I64x2ExtMulLowI32x4S) \ 853 V(I64x2ExtMulHighI32x4S) \ 854 V(I64x2ExtMulLowI32x4U) \ 855 V(I64x2ExtMulHighI32x4U) \ 856 V(I32x4Splat) \ 857 V(I32x4ExtractLane) \ 858 V(I32x4ReplaceLane) \ 859 V(I32x4SConvertF32x4) \ 860 V(I32x4SConvertI16x8Low) \ 861 V(I32x4SConvertI16x8High) \ 862 V(I32x4Neg) \ 863 V(I32x4Shl) \ 864 V(I32x4ShrS) \ 865 V(I32x4Add) \ 866 V(I32x4Sub) \ 867 V(I32x4Mul) \ 868 V(I32x4MinS) \ 869 V(I32x4MaxS) \ 870 V(I32x4Eq) \ 871 V(I32x4Ne) \ 872 V(I32x4LtS) \ 873 V(I32x4LeS) \ 874 V(I32x4GtS) \ 875 V(I32x4GeS) \ 876 V(I32x4UConvertF32x4) \ 877 V(I32x4UConvertI16x8Low) \ 878 V(I32x4UConvertI16x8High) \ 879 V(I32x4ShrU) \ 880 V(I32x4MinU) \ 881 V(I32x4MaxU) \ 882 V(I32x4LtU) \ 883 V(I32x4LeU) \ 884 V(I32x4GtU) \ 885 V(I32x4GeU) \ 886 V(I32x4Abs) \ 887 V(I32x4BitMask) \ 888 V(I32x4DotI16x8S) \ 889 V(I32x4ExtMulLowI16x8S) \ 890 V(I32x4ExtMulHighI16x8S) \ 891 V(I32x4ExtMulLowI16x8U) \ 892 V(I32x4ExtMulHighI16x8U) \ 893 V(I32x4ExtAddPairwiseI16x8S) \ 894 V(I32x4ExtAddPairwiseI16x8U) \ 895 V(I32x4TruncSatF64x2SZero) \ 896 V(I32x4TruncSatF64x2UZero) \ 897 V(I16x8Splat) \ 898 V(I16x8ExtractLaneU) \ 899 V(I16x8ExtractLaneS) \ 900 V(I16x8ReplaceLane) \ 901 V(I16x8SConvertI8x16Low) \ 902 V(I16x8SConvertI8x16High) \ 903 V(I16x8Neg) \ 904 V(I16x8Shl) \ 905 V(I16x8ShrS) \ 906 V(I16x8SConvertI32x4) \ 907 V(I16x8Add) \ 908 V(I16x8AddSatS) \ 909 V(I16x8Sub) \ 910 V(I16x8SubSatS) \ 911 V(I16x8Mul) \ 912 V(I16x8MinS) \ 913 V(I16x8MaxS) \ 914 V(I16x8Eq) \ 915 V(I16x8Ne) \ 916 V(I16x8LtS) \ 917 V(I16x8LeS) \ 918 V(I16x8GtS) \ 919 V(I16x8GeS) \ 920 V(I16x8UConvertI8x16Low) \ 921 V(I16x8UConvertI8x16High) \ 922 V(I16x8ShrU) \ 923 V(I16x8UConvertI32x4) \ 924 V(I16x8AddSatU) \ 925 V(I16x8SubSatU) \ 926 V(I16x8MinU) \ 927 V(I16x8MaxU) \ 928 V(I16x8LtU) \ 929 V(I16x8LeU) \ 930 V(I16x8GtU) \ 931 V(I16x8GeU) \ 932 V(I16x8RoundingAverageU) \ 933 V(I16x8Q15MulRSatS) \ 934 V(I16x8Abs) \ 935 V(I16x8BitMask) \ 936 V(I16x8ExtMulLowI8x16S) \ 937 V(I16x8ExtMulHighI8x16S) \ 938 V(I16x8ExtMulLowI8x16U) \ 939 V(I16x8ExtMulHighI8x16U) \ 940 V(I16x8ExtAddPairwiseI8x16S) \ 941 V(I16x8ExtAddPairwiseI8x16U) \ 942 V(I8x16Splat) \ 943 V(I8x16ExtractLaneU) \ 944 V(I8x16ExtractLaneS) \ 945 V(I8x16ReplaceLane) \ 946 V(I8x16SConvertI16x8) \ 947 V(I8x16Neg) \ 948 V(I8x16Shl) \ 949 V(I8x16ShrS) \ 950 V(I8x16Add) \ 951 V(I8x16AddSatS) \ 952 V(I8x16Sub) \ 953 V(I8x16SubSatS) \ 954 V(I8x16MinS) \ 955 V(I8x16MaxS) \ 956 V(I8x16Eq) \ 957 V(I8x16Ne) \ 958 V(I8x16LtS) \ 959 V(I8x16LeS) \ 960 V(I8x16GtS) \ 961 V(I8x16GeS) \ 962 V(I8x16UConvertI16x8) \ 963 V(I8x16AddSatU) \ 964 V(I8x16SubSatU) \ 965 V(I8x16ShrU) \ 966 V(I8x16MinU) \ 967 V(I8x16MaxU) \ 968 V(I8x16LtU) \ 969 V(I8x16LeU) \ 970 V(I8x16GtU) \ 971 V(I8x16GeU) \ 972 V(I8x16RoundingAverageU) \ 973 V(I8x16Popcnt) \ 974 V(I8x16Abs) \ 975 V(I8x16BitMask) \ 976 V(S128Zero) \ 977 V(S128Const) \ 978 V(S128Not) \ 979 V(S128And) \ 980 V(S128Or) \ 981 V(S128Xor) \ 982 V(S128Select) \ 983 V(S128AndNot) \ 984 V(I8x16Swizzle) \ 985 V(I8x16RelaxedLaneSelect) \ 986 V(I16x8RelaxedLaneSelect) \ 987 V(I32x4RelaxedLaneSelect) \ 988 V(I64x2RelaxedLaneSelect) \ 989 V(F32x4RelaxedMin) \ 990 V(F32x4RelaxedMax) \ 991 V(F64x2RelaxedMin) \ 992 V(F64x2RelaxedMax) \ 993 V(I32x4RelaxedTruncF32x4S) \ 994 V(I32x4RelaxedTruncF32x4U) \ 995 V(I32x4RelaxedTruncF64x2SZero) \ 996 V(I32x4RelaxedTruncF64x2UZero) \ 997 V(I8x16Shuffle) \ 998 V(V128AnyTrue) \ 999 V(I64x2AllTrue) \ 1000 V(I32x4AllTrue) \ 1001 V(I16x8AllTrue) \ 1002 V(I8x16AllTrue) \ 1003 V(LoadTransform) \ 1004 V(LoadLane) \ 1005 V(StoreLane) 1006 1007 #define VALUE_OP_LIST(V) \ 1008 COMMON_OP_LIST(V) \ 1009 SIMPLIFIED_OP_LIST(V) \ 1010 MACHINE_OP_LIST(V) \ 1011 MACHINE_SIMD_OP_LIST(V) \ 1012 JS_OP_LIST(V) 1013 1014 // The combination of all operators at all levels and the common operators. 1015 #define ALL_OP_LIST(V) \ 1016 CONTROL_OP_LIST(V) \ 1017 VALUE_OP_LIST(V) 1018 1019 namespace v8 { 1020 namespace internal { 1021 namespace compiler { 1022 1023 // Declare an enumeration with all the opcodes at all levels so that they 1024 // can be globally, uniquely numbered. 1025 class V8_EXPORT_PRIVATE IrOpcode { 1026 public: 1027 enum Value { 1028 #define DECLARE_OPCODE(x, ...) k##x, 1029 ALL_OP_LIST(DECLARE_OPCODE) 1030 #undef DECLARE_OPCODE 1031 kLast = -1 1032 #define COUNT_OPCODE(...) +1 1033 ALL_OP_LIST(COUNT_OPCODE) 1034 #undef COUNT_OPCODE 1035 }; 1036 1037 // Returns the mnemonic name of an opcode. 1038 static char const* Mnemonic(Value value); 1039 1040 // Returns true if opcode for common operator. IsCommonOpcode(Value value)1041 static bool IsCommonOpcode(Value value) { 1042 return kStart <= value && value <= kStaticAssert; 1043 } 1044 1045 // Returns true if opcode for control operator. IsControlOpcode(Value value)1046 static bool IsControlOpcode(Value value) { 1047 return kStart <= value && value <= kEnd; 1048 } 1049 1050 // Returns true if opcode for JavaScript operator. IsJsOpcode(Value value)1051 static bool IsJsOpcode(Value value) { 1052 return kJSEqual <= value && value <= kJSDebugger; 1053 } 1054 1055 // Returns true if opcode for constant operator. IsConstantOpcode(Value value)1056 static bool IsConstantOpcode(Value value) { 1057 #define CASE(Name) \ 1058 case k##Name: \ 1059 return true; 1060 switch (value) { 1061 CONSTANT_OP_LIST(CASE); 1062 default: 1063 return false; 1064 } 1065 #undef CASE 1066 UNREACHABLE(); 1067 } 1068 IsPhiOpcode(Value value)1069 static bool IsPhiOpcode(Value value) { 1070 return value == kPhi || value == kEffectPhi; 1071 } 1072 IsMergeOpcode(Value value)1073 static bool IsMergeOpcode(Value value) { 1074 return value == kMerge || value == kLoop; 1075 } 1076 IsIfProjectionOpcode(Value value)1077 static bool IsIfProjectionOpcode(Value value) { 1078 return kIfTrue <= value && value <= kIfDefault; 1079 } 1080 1081 // Returns true if opcode terminates control flow in a graph (i.e. 1082 // respective nodes are expected to have control uses by the graphs {End} 1083 // node only). IsGraphTerminator(Value value)1084 static bool IsGraphTerminator(Value value) { 1085 return value == kDeoptimize || value == kReturn || value == kTailCall || 1086 value == kTerminate || value == kThrow; 1087 } 1088 1089 // Returns true if opcode can be inlined. IsInlineeOpcode(Value value)1090 static bool IsInlineeOpcode(Value value) { 1091 return value == kJSConstruct || value == kJSCall; 1092 } 1093 1094 // Returns true if opcode for comparison operator. IsComparisonOpcode(Value value)1095 static bool IsComparisonOpcode(Value value) { 1096 #define CASE(Name, ...) \ 1097 case k##Name: \ 1098 return true; 1099 switch (value) { 1100 JS_COMPARE_BINOP_LIST(CASE); 1101 SIMPLIFIED_COMPARE_BINOP_LIST(CASE); 1102 MACHINE_COMPARE_BINOP_LIST(CASE); 1103 default: 1104 return false; 1105 } 1106 #undef CASE 1107 UNREACHABLE(); 1108 } 1109 IsContextChainExtendingOpcode(Value value)1110 static bool IsContextChainExtendingOpcode(Value value) { 1111 return kJSCreateFunctionContext <= value && value <= kJSCreateBlockContext; 1112 } 1113 1114 // These opcode take the feedback vector as an input, and implement 1115 // feedback-collecting logic in generic lowering. IsFeedbackCollectingOpcode(Value value)1116 static bool IsFeedbackCollectingOpcode(Value value) { 1117 #define CASE(Name, ...) \ 1118 case k##Name: \ 1119 return true; 1120 switch (value) { 1121 JS_ARITH_BINOP_LIST(CASE) 1122 JS_ARITH_UNOP_LIST(CASE) 1123 JS_BITWISE_BINOP_LIST(CASE) 1124 JS_BITWISE_UNOP_LIST(CASE) 1125 JS_COMPARE_BINOP_LIST(CASE) 1126 case kJSCall: 1127 case kJSCallWithArrayLike: 1128 case kJSCallWithSpread: 1129 case kJSCloneObject: 1130 case kJSConstruct: 1131 case kJSConstructWithArrayLike: 1132 case kJSConstructWithSpread: 1133 case kJSCreateEmptyLiteralArray: 1134 case kJSCreateLiteralArray: 1135 case kJSCreateLiteralObject: 1136 case kJSCreateLiteralRegExp: 1137 case kJSDefineKeyedOwnProperty: 1138 case kJSForInNext: 1139 case kJSForInPrepare: 1140 case kJSGetIterator: 1141 case kJSGetTemplateObject: 1142 case kJSHasProperty: 1143 case kJSInstanceOf: 1144 case kJSLoadGlobal: 1145 case kJSLoadNamed: 1146 case kJSLoadNamedFromSuper: 1147 case kJSLoadProperty: 1148 case kJSDefineKeyedOwnPropertyInLiteral: 1149 case kJSStoreGlobal: 1150 case kJSStoreInArrayLiteral: 1151 case kJSSetNamedProperty: 1152 case kJSDefineNamedOwnProperty: 1153 case kJSSetKeyedProperty: 1154 return true; 1155 default: 1156 return false; 1157 } 1158 #undef CASE 1159 UNREACHABLE(); 1160 } 1161 IsFeedbackCollectingOpcode(int16_t value)1162 static bool IsFeedbackCollectingOpcode(int16_t value) { 1163 DCHECK(0 <= value && value <= kLast); 1164 return IsFeedbackCollectingOpcode(static_cast<IrOpcode::Value>(value)); 1165 } 1166 }; 1167 1168 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, IrOpcode::Value); 1169 1170 } // namespace compiler 1171 } // namespace internal 1172 } // namespace v8 1173 1174 #endif // V8_COMPILER_OPCODES_H_ 1175