1 //===-- X86.h - Top-level interface for X86 representation ------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the entry points for global functions defined in the x86
11 // target library, as used by the LLVM JIT.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LIB_TARGET_X86_X86_H
16 #define LLVM_LIB_TARGET_X86_X86_H
18 #include "llvm/Support/CodeGen.h"
24 class InstructionSelector;
27 class X86RegisterBankInfo;
29 class X86TargetMachine;
31 /// This pass converts a legalized DAG into a X86-specific DAG, ready for
32 /// instruction scheduling.
33 FunctionPass *createX86ISelDag(X86TargetMachine &TM,
34 CodeGenOpt::Level OptLevel);
36 /// This pass initializes a global base register for PIC on x86-32.
37 FunctionPass *createX86GlobalBaseRegPass();
39 /// This pass combines multiple accesses to local-dynamic TLS variables so that
40 /// the TLS base address for the module is only fetched once per execution path
41 /// through the function.
42 FunctionPass *createCleanupLocalDynamicTLSPass();
44 /// This function returns a pass which converts floating-point register
45 /// references and pseudo instructions into floating-point stack references and
46 /// physical instructions.
47 FunctionPass *createX86FloatingPointStackifierPass();
49 /// This pass inserts AVX vzeroupper instructions before each call to avoid
50 /// transition penalty between functions encoded with AVX and SSE.
51 FunctionPass *createX86IssueVZeroUpperPass();
53 /// This pass instruments the function prolog to save the return address to a
54 /// 'shadow call stack' and the function epilog to check that the return address
55 /// did not change during function execution.
56 FunctionPass *createShadowCallStackPass();
58 /// This pass inserts ENDBR instructions before indirect jump/call
59 /// destinations as part of CET IBT mechanism.
60 FunctionPass *createX86IndirectBranchTrackingPass();
62 /// Return a pass that pads short functions with NOOPs.
63 /// This will prevent a stall when returning on the Atom.
64 FunctionPass *createX86PadShortFunctions();
66 /// Return a pass that selectively replaces certain instructions (like add,
67 /// sub, inc, dec, some shifts, and some multiplies) by equivalent LEA
68 /// instructions, in order to eliminate execution delays in some processors.
69 FunctionPass *createX86FixupLEAs();
71 /// Return a pass that removes redundant LEA instructions and redundant address
73 FunctionPass *createX86OptimizeLEAs();
75 /// Return a pass that transforms setcc + movzx pairs into xor + setcc.
76 FunctionPass *createX86FixupSetCC();
78 /// Return a pass that folds conditional branch jumps.
79 FunctionPass *createX86CondBrFolding();
81 /// Return a pass that avoids creating store forward block issues in the hardware.
82 FunctionPass *createX86AvoidStoreForwardingBlocks();
84 /// Return a pass that lowers EFLAGS copy pseudo instructions.
85 FunctionPass *createX86FlagsCopyLoweringPass();
87 /// Return a pass that expands WinAlloca pseudo-instructions.
88 FunctionPass *createX86WinAllocaExpander();
90 /// Return a pass that optimizes the code-size of x86 call sequences. This is
91 /// done by replacing esp-relative movs with pushes.
92 FunctionPass *createX86CallFrameOptimization();
94 /// Return an IR pass that inserts EH registration stack objects and explicit
95 /// EH state updates. This pass must run after EH preparation, which does
96 /// Windows-specific but architecture-neutral preparation.
97 FunctionPass *createX86WinEHStatePass();
99 /// Return a Machine IR pass that expands X86-specific pseudo
100 /// instructions into a sequence of actual instructions. This pass
101 /// must run after prologue/epilogue insertion and before lowering
102 /// the MachineInstr to MC.
103 FunctionPass *createX86ExpandPseudoPass();
105 /// This pass converts X86 cmov instructions into branch when profitable.
106 FunctionPass *createX86CmovConverterPass();
108 /// Return a Machine IR pass that selectively replaces
109 /// certain byte and word instructions by equivalent 32 bit instructions,
110 /// in order to eliminate partial register usage, false dependences on
111 /// the upper portions of registers, and to save code size.
112 FunctionPass *createX86FixupBWInsts();
114 /// Return a Machine IR pass that reassigns instruction chains from one domain
115 /// to another, when profitable.
116 FunctionPass *createX86DomainReassignmentPass();
118 /// This pass replaces EVEX encoded of AVX-512 instructiosn by VEX
119 /// encoding when possible in order to reduce code size.
120 FunctionPass *createX86EvexToVexInsts();
122 /// This pass creates the thunks for the retpoline feature.
123 FunctionPass *createX86RetpolineThunksPass();
125 /// This pass ensures instructions featuring a memory operand
126 /// have distinctive <LineNumber, Discriminator> (with respect to eachother)
127 FunctionPass *createX86DiscriminateMemOpsPass();
129 /// This pass applies profiling information to insert cache prefetches.
130 FunctionPass *createX86InsertPrefetchPass();
132 InstructionSelector *createX86InstructionSelector(const X86TargetMachine &TM,
134 X86RegisterBankInfo &);
136 FunctionPass *createX86SpeculativeLoadHardeningPass();
138 void initializeEvexToVexInstPassPass(PassRegistry &);
139 void initializeFixupBWInstPassPass(PassRegistry &);
140 void initializeFixupLEAPassPass(PassRegistry &);
141 void initializeShadowCallStackPass(PassRegistry &);
142 void initializeWinEHStatePassPass(PassRegistry &);
143 void initializeX86AvoidSFBPassPass(PassRegistry &);
144 void initializeX86CallFrameOptimizationPass(PassRegistry &);
145 void initializeX86CmovConverterPassPass(PassRegistry &);
146 void initializeX86CondBrFoldingPassPass(PassRegistry &);
147 void initializeX86DomainReassignmentPass(PassRegistry &);
148 void initializeX86ExecutionDomainFixPass(PassRegistry &);
149 void initializeX86FlagsCopyLoweringPassPass(PassRegistry &);
150 void initializeX86SpeculativeLoadHardeningPassPass(PassRegistry &);
152 } // End llvm namespace