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 inserts ENDBR instructions before indirect jump/call
53 /// destinations as part of CET IBT mechanism.
54 FunctionPass
*createX86IndirectBranchTrackingPass();
56 /// Return a pass that pads short functions with NOOPs.
57 /// This will prevent a stall when returning on the Atom.
58 FunctionPass
*createX86PadShortFunctions();
60 /// Return a pass that selectively replaces certain instructions (like add,
61 /// sub, inc, dec, some shifts, and some multiplies) by equivalent LEA
62 /// instructions, in order to eliminate execution delays in some processors.
63 FunctionPass
*createX86FixupLEAs();
65 /// Return a pass that removes redundant LEA instructions and redundant address
67 FunctionPass
*createX86OptimizeLEAs();
69 /// Return a pass that transforms setcc + movzx pairs into xor + setcc.
70 FunctionPass
*createX86FixupSetCC();
72 /// Return a pass that folds conditional branch jumps.
73 FunctionPass
*createX86CondBrFolding();
75 /// Return a pass that avoids creating store forward block issues in the hardware.
76 FunctionPass
*createX86AvoidStoreForwardingBlocks();
78 /// Return a pass that lowers EFLAGS copy pseudo instructions.
79 FunctionPass
*createX86FlagsCopyLoweringPass();
81 /// Return a pass that expands WinAlloca pseudo-instructions.
82 FunctionPass
*createX86WinAllocaExpander();
84 /// Return a pass that inserts int3 at the end of the function if it ends with a
85 /// CALL instruction. The pass does the same for each funclet as well. This
86 /// ensures that the open interval of function start and end PCs contains all
87 /// return addresses for the benefit of the Windows x64 unwinder.
88 FunctionPass
*createX86AvoidTrailingCallPass();
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 initializeFPSPass(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 initializeX86ExpandPseudoPass(PassRegistry
&);
150 void initializeX86FlagsCopyLoweringPassPass(PassRegistry
&);
151 void initializeX86OptimizeLEAPassPass(PassRegistry
&);
152 void initializeX86SpeculativeLoadHardeningPassPass(PassRegistry
&);
153 } // End llvm namespace