1 //===-- X86SchedPredicates.td - X86 Scheduling Predicates --*- tablegen -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file defines scheduling predicate definitions that are common to
10 // all X86 subtargets.
12 //===----------------------------------------------------------------------===//
14 // A predicate used to identify dependency-breaking instructions that clear the
15 // content of the destination register. Note that this predicate only checks if
16 // input registers are the same. This predicate doesn't make any assumptions on
17 // the expected instruction opcodes, because different processors may implement
18 // different zero-idioms.
19 def ZeroIdiomPredicate : CheckSameRegOperand<1, 2>;
21 // A predicate used to identify VPERM that have bits 3 and 7 of their mask set.
22 // On some processors, these VPERM instructions are zero-idioms.
23 def ZeroIdiomVPERMPredicate : CheckAll<[
25 CheckImmOperand<3, 0x88>
28 // A predicate used to check if a LEA instruction uses all three source
29 // operands: base, index, and offset.
30 def IsThreeOperandsLEAPredicate: CheckAll<[
33 CheckNot<CheckInvalidRegOperand<1>>,
35 // isRegOperand(Index)
37 CheckNot<CheckInvalidRegOperand<3>>,
39 // hasLEAOffset(Offset)
43 CheckNot<CheckZeroOperand<4>>
45 CheckNonPortable<"MI.getOperand(4).isGlobal()">
49 def LEACases : MCOpcodeSwitchCase<
50 [LEA32r, LEA64r, LEA64_32r, LEA16r],
51 MCReturnStatement<IsThreeOperandsLEAPredicate>
54 // Used to generate the body of a TII member function.
55 def IsThreeOperandsLEABody :
56 MCOpcodeSwitchStatement<[LEACases], MCReturnStatement<FalsePred>>;
58 // This predicate evaluates to true only if the input machine instruction is a
59 // 3-operands LEA. Tablegen automatically generates a new method for it in
61 def IsThreeOperandsLEAFn :
62 TIIPredicate<"isThreeOperandsLEA", IsThreeOperandsLEABody>;
64 // A predicate to check for COND_A and COND_BE CMOVs which have an extra uop
65 // on recent Intel CPUs.
66 def IsCMOVArr_Or_CMOVBErr : CheckAny<[
67 CheckImmOperand_s<3, "X86::COND_A">,
68 CheckImmOperand_s<3, "X86::COND_BE">
71 def IsCMOVArm_Or_CMOVBErm : CheckAny<[
72 CheckImmOperand_s<7, "X86::COND_A">,
73 CheckImmOperand_s<7, "X86::COND_BE">
76 // A predicate to check for COND_A and COND_BE SETCCs which have an extra uop
77 // on recent Intel CPUs.
78 def IsSETAr_Or_SETBEr : CheckAny<[
79 CheckImmOperand_s<1, "X86::COND_A">,
80 CheckImmOperand_s<1, "X86::COND_BE">
83 def IsSETAm_Or_SETBEm : CheckAny<[
84 CheckImmOperand_s<5, "X86::COND_A">,
85 CheckImmOperand_s<5, "X86::COND_BE">
88 // A predicate used to check if an instruction has a LOCK prefix.
89 def CheckLockPrefix : CheckFunctionPredicate<
90 "X86_MC::hasLockPrefix",
91 "X86InstrInfo::hasLockPrefix"
94 def IsRegRegCompareAndSwap_8 : CheckOpcode<[ CMPXCHG8rr ]>;
96 def IsRegMemCompareAndSwap_8 : CheckOpcode<[
100 def IsRegRegCompareAndSwap_16_32_64 : CheckOpcode<[
101 CMPXCHG16rr, CMPXCHG32rr, CMPXCHG64rr
104 def IsRegMemCompareAndSwap_16_32_64 : CheckOpcode<[
105 CMPXCHG16rm, CMPXCHG32rm, CMPXCHG64rm,
106 LCMPXCHG16, LCMPXCHG32, LCMPXCHG64,
107 LCMPXCHG8B, LCMPXCHG16B
110 def IsCompareAndSwap8B : CheckOpcode<[ CMPXCHG8B, LCMPXCHG8B ]>;
111 def IsCompareAndSwap16B : CheckOpcode<[ CMPXCHG16B, LCMPXCHG16B ]>;
113 def IsRegMemCompareAndSwap : CheckOpcode<
115 IsRegMemCompareAndSwap_8.ValidOpcodes,
116 IsRegMemCompareAndSwap_16_32_64.ValidOpcodes
119 def IsRegRegCompareAndSwap : CheckOpcode<
121 IsRegRegCompareAndSwap_8.ValidOpcodes,
122 IsRegRegCompareAndSwap_16_32_64.ValidOpcodes
125 def IsAtomicCompareAndSwap_8 : CheckAll<[
127 IsRegMemCompareAndSwap_8
130 def IsAtomicCompareAndSwap : CheckAll<[
132 IsRegMemCompareAndSwap
135 def IsAtomicCompareAndSwap8B : CheckAll<[
140 def IsAtomicCompareAndSwap16B : CheckAll<[