X86SchedPredicates.td 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. //===-- X86SchedPredicates.td - X86 Scheduling Predicates --*- tablegen -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file defines scheduling predicate definitions that are common to
  10. // all X86 subtargets.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. // A predicate used to identify dependency-breaking instructions that clear the
  14. // content of the destination register. Note that this predicate only checks if
  15. // input registers are the same. This predicate doesn't make any assumptions on
  16. // the expected instruction opcodes, because different processors may implement
  17. // different zero-idioms.
  18. def ZeroIdiomPredicate : CheckSameRegOperand<1, 2>;
  19. // A predicate used to identify VPERM that have bits 3 and 7 of their mask set.
  20. // On some processors, these VPERM instructions are zero-idioms.
  21. def ZeroIdiomVPERMPredicate : CheckAll<[
  22. ZeroIdiomPredicate,
  23. CheckImmOperand<3, 0x88>
  24. ]>;
  25. // A predicate used to check if a LEA instruction uses all three source
  26. // operands: base, index, and offset.
  27. def IsThreeOperandsLEAPredicate: CheckAll<[
  28. // isRegOperand(Base)
  29. CheckIsRegOperand<1>,
  30. CheckNot<CheckInvalidRegOperand<1>>,
  31. // isRegOperand(Index)
  32. CheckIsRegOperand<3>,
  33. CheckNot<CheckInvalidRegOperand<3>>,
  34. // hasLEAOffset(Offset)
  35. CheckAny<[
  36. CheckAll<[
  37. CheckIsImmOperand<4>,
  38. CheckNot<CheckZeroOperand<4>>
  39. ]>,
  40. CheckNonPortable<"MI.getOperand(4).isGlobal()">
  41. ]>
  42. ]>;
  43. def LEACases : MCOpcodeSwitchCase<
  44. [LEA32r, LEA64r, LEA64_32r, LEA16r],
  45. MCReturnStatement<IsThreeOperandsLEAPredicate>
  46. >;
  47. // Used to generate the body of a TII member function.
  48. def IsThreeOperandsLEABody :
  49. MCOpcodeSwitchStatement<[LEACases], MCReturnStatement<FalsePred>>;
  50. // This predicate evaluates to true only if the input machine instruction is a
  51. // 3-operands LEA. Tablegen automatically generates a new method for it in
  52. // X86GenInstrInfo.
  53. def IsThreeOperandsLEAFn :
  54. TIIPredicate<"isThreeOperandsLEA", IsThreeOperandsLEABody>;
  55. // A predicate to check for COND_A and COND_BE CMOVs which have an extra uop
  56. // on recent Intel CPUs.
  57. def IsCMOVArr_Or_CMOVBErr : CheckAny<[
  58. CheckImmOperand_s<3, "X86::COND_A">,
  59. CheckImmOperand_s<3, "X86::COND_BE">
  60. ]>;
  61. def IsCMOVArm_Or_CMOVBErm : CheckAny<[
  62. CheckImmOperand_s<7, "X86::COND_A">,
  63. CheckImmOperand_s<7, "X86::COND_BE">
  64. ]>;
  65. // A predicate to check for COND_A and COND_BE SETCCs which have an extra uop
  66. // on recent Intel CPUs.
  67. def IsSETAr_Or_SETBEr : CheckAny<[
  68. CheckImmOperand_s<1, "X86::COND_A">,
  69. CheckImmOperand_s<1, "X86::COND_BE">
  70. ]>;
  71. def IsSETAm_Or_SETBEm : CheckAny<[
  72. CheckImmOperand_s<5, "X86::COND_A">,
  73. CheckImmOperand_s<5, "X86::COND_BE">
  74. ]>;
  75. // A predicate used to check if an instruction has a LOCK prefix.
  76. def CheckLockPrefix : CheckFunctionPredicate<
  77. "X86_MC::hasLockPrefix",
  78. "X86InstrInfo::hasLockPrefix"
  79. >;
  80. def IsRegRegCompareAndSwap_8 : CheckOpcode<[ CMPXCHG8rr ]>;
  81. def IsRegMemCompareAndSwap_8 : CheckOpcode<[
  82. LCMPXCHG8, CMPXCHG8rm
  83. ]>;
  84. def IsRegRegCompareAndSwap_16_32_64 : CheckOpcode<[
  85. CMPXCHG16rr, CMPXCHG32rr, CMPXCHG64rr
  86. ]>;
  87. def IsRegMemCompareAndSwap_16_32_64 : CheckOpcode<[
  88. CMPXCHG16rm, CMPXCHG32rm, CMPXCHG64rm,
  89. LCMPXCHG16, LCMPXCHG32, LCMPXCHG64,
  90. LCMPXCHG8B, LCMPXCHG16B
  91. ]>;
  92. def IsCompareAndSwap8B : CheckOpcode<[ CMPXCHG8B, LCMPXCHG8B ]>;
  93. def IsCompareAndSwap16B : CheckOpcode<[ CMPXCHG16B, LCMPXCHG16B ]>;
  94. def IsRegMemCompareAndSwap : CheckOpcode<
  95. !listconcat(
  96. IsRegMemCompareAndSwap_8.ValidOpcodes,
  97. IsRegMemCompareAndSwap_16_32_64.ValidOpcodes
  98. )>;
  99. def IsRegRegCompareAndSwap : CheckOpcode<
  100. !listconcat(
  101. IsRegRegCompareAndSwap_8.ValidOpcodes,
  102. IsRegRegCompareAndSwap_16_32_64.ValidOpcodes
  103. )>;
  104. def IsAtomicCompareAndSwap_8 : CheckAll<[
  105. CheckLockPrefix,
  106. IsRegMemCompareAndSwap_8
  107. ]>;
  108. def IsAtomicCompareAndSwap : CheckAll<[
  109. CheckLockPrefix,
  110. IsRegMemCompareAndSwap
  111. ]>;
  112. def IsAtomicCompareAndSwap8B : CheckAll<[
  113. CheckLockPrefix,
  114. IsCompareAndSwap8B
  115. ]>;
  116. def IsAtomicCompareAndSwap16B : CheckAll<[
  117. CheckLockPrefix,
  118. IsCompareAndSwap16B
  119. ]>;