1 //===-- X86.h - Top-level interface for X86 representation ------*- C++ -*-===//
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 contains the entry points for global functions defined in the x86
10 // target library, as used by the LLVM JIT.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_X86_X86_H
15 #define LLVM_LIB_TARGET_X86_X86_H
17 #include "llvm/Support/CodeGen.h"
23 class InstructionSelector
;
26 class X86RegisterBankInfo
;
28 class X86TargetMachine
;
30 /// This pass converts a legalized DAG into a X86-specific DAG, ready for
31 /// instruction scheduling.
32 FunctionPass
*createX86ISelDag(X86TargetMachine
&TM
,
33 CodeGenOpt::Level OptLevel
);
35 /// This pass initializes a global base register for PIC on x86-32.
36 FunctionPass
*createX86GlobalBaseRegPass();
38 /// This pass combines multiple accesses to local-dynamic TLS variables so that
39 /// the TLS base address for the module is only fetched once per execution path
40 /// through the function.
41 FunctionPass
*createCleanupLocalDynamicTLSPass();
43 /// This function returns a pass which converts floating-point register
44 /// references and pseudo instructions into floating-point stack references and
45 /// physical instructions.
46 FunctionPass
*createX86FloatingPointStackifierPass();
48 /// This pass inserts AVX vzeroupper instructions before each call to avoid
49 /// transition penalty between functions encoded with AVX and SSE.
50 FunctionPass
*createX86IssueVZeroUpperPass();
52 /// This pass instruments the function prolog to save the return address to a
53 /// 'shadow call stack' and the function epilog to check that the return address
54 /// did not change during function execution.
55 FunctionPass
*createShadowCallStackPass();
57 /// This pass inserts ENDBR instructions before indirect jump/call
58 /// destinations as part of CET IBT mechanism.
59 FunctionPass
*createX86IndirectBranchTrackingPass();
61 /// Return a pass that pads short functions with NOOPs.
62 /// This will prevent a stall when returning on the Atom.
63 FunctionPass
*createX86PadShortFunctions();
65 /// Return a pass that selectively replaces certain instructions (like add,
66 /// sub, inc, dec, some shifts, and some multiplies) by equivalent LEA
67 /// instructions, in order to eliminate execution delays in some processors.
68 FunctionPass
*createX86FixupLEAs();
70 /// Return a pass that removes redundant LEA instructions and redundant address
72 FunctionPass
*createX86OptimizeLEAs();
74 /// Return a pass that transforms setcc + movzx pairs into xor + setcc.
75 FunctionPass
*createX86FixupSetCC();
77 /// Return a pass that folds conditional branch jumps.
78 FunctionPass
*createX86CondBrFolding();
80 /// Return a pass that avoids creating store forward block issues in the hardware.
81 FunctionPass
*createX86AvoidStoreForwardingBlocks();
83 /// Return a pass that lowers EFLAGS copy pseudo instructions.
84 FunctionPass
*createX86FlagsCopyLoweringPass();
86 /// Return a pass that expands WinAlloca pseudo-instructions.
87 FunctionPass
*createX86WinAllocaExpander();
89 /// Return a pass that optimizes the code-size of x86 call sequences. This is
90 /// done by replacing esp-relative movs with pushes.
91 FunctionPass
*createX86CallFrameOptimization();
93 /// Return an IR pass that inserts EH registration stack objects and explicit
94 /// EH state updates. This pass must run after EH preparation, which does
95 /// Windows-specific but architecture-neutral preparation.
96 FunctionPass
*createX86WinEHStatePass();
98 /// Return a Machine IR pass that expands X86-specific pseudo
99 /// instructions into a sequence of actual instructions. This pass
100 /// must run after prologue/epilogue insertion and before lowering
101 /// the MachineInstr to MC.
102 FunctionPass
*createX86ExpandPseudoPass();
104 /// This pass converts X86 cmov instructions into branch when profitable.
105 FunctionPass
*createX86CmovConverterPass();
107 /// Return a Machine IR pass that selectively replaces
108 /// certain byte and word instructions by equivalent 32 bit instructions,
109 /// in order to eliminate partial register usage, false dependences on
110 /// the upper portions of registers, and to save code size.
111 FunctionPass
*createX86FixupBWInsts();
113 /// Return a Machine IR pass that reassigns instruction chains from one domain
114 /// to another, when profitable.
115 FunctionPass
*createX86DomainReassignmentPass();
117 /// This pass replaces EVEX encoded of AVX-512 instructiosn by VEX
118 /// encoding when possible in order to reduce code size.
119 FunctionPass
*createX86EvexToVexInsts();
121 /// This pass creates the thunks for the retpoline feature.
122 FunctionPass
*createX86RetpolineThunksPass();
124 /// This pass ensures instructions featuring a memory operand
125 /// have distinctive <LineNumber, Discriminator> (with respect to eachother)
126 FunctionPass
*createX86DiscriminateMemOpsPass();
128 /// This pass applies profiling information to insert cache prefetches.
129 FunctionPass
*createX86InsertPrefetchPass();
131 InstructionSelector
*createX86InstructionSelector(const X86TargetMachine
&TM
,
133 X86RegisterBankInfo
&);
135 FunctionPass
*createX86SpeculativeLoadHardeningPass();
137 void initializeEvexToVexInstPassPass(PassRegistry
&);
138 void initializeFixupBWInstPassPass(PassRegistry
&);
139 void initializeFixupLEAPassPass(PassRegistry
&);
140 void initializeShadowCallStackPass(PassRegistry
&);
141 void initializeWinEHStatePassPass(PassRegistry
&);
142 void initializeX86AvoidSFBPassPass(PassRegistry
&);
143 void initializeX86CallFrameOptimizationPass(PassRegistry
&);
144 void initializeX86CmovConverterPassPass(PassRegistry
&);
145 void initializeX86CondBrFoldingPassPass(PassRegistry
&);
146 void initializeX86DomainReassignmentPass(PassRegistry
&);
147 void initializeX86ExecutionDomainFixPass(PassRegistry
&);
148 void initializeX86FlagsCopyLoweringPassPass(PassRegistry
&);
149 void initializeX86SpeculativeLoadHardeningPassPass(PassRegistry
&);
151 } // End llvm namespace