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