LLVM 22.0.0git
X86.h
Go to the documentation of this file.
1//===-- X86.h - Top-level interface for X86 representation ------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the entry points for global functions defined in the x86
10// target library, as used by the LLVM JIT.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_X86_X86_H
15#define LLVM_LIB_TARGET_X86_X86_H
16
18#include "llvm/IR/Analysis.h"
19#include "llvm/IR/PassManager.h"
22
23namespace llvm {
24
25class FunctionPass;
27class PassRegistry;
29class X86Subtarget;
31
32/// This pass converts a legalized DAG into a X86-specific DAG, ready for
33/// instruction scheduling.
35
36/// This pass initializes a global base register for PIC on x86-32.
38
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.
43
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.
47class X86FPStackifierPass : public PassInfoMixin<X86FPStackifierPass> {
48public:
51};
52
54
55/// This pass inserts AVX vzeroupper instructions before each call to avoid
56/// transition penalty between functions encoded with AVX and SSE.
58
59/// This pass inserts ENDBR instructions before indirect jump/call
60/// destinations as part of CET IBT mechanism.
62
63/// Return a pass that pads short functions with NOOPs.
64/// This will prevent a stall when returning on the Atom.
66
67/// Return a pass that selectively replaces certain instructions (like add,
68/// sub, inc, dec, some shifts, and some multiplies) by equivalent LEA
69/// instructions, in order to eliminate execution delays in some processors.
71
72/// Return a pass that replaces equivalent slower instructions with faster
73/// ones.
75
76/// Return a pass that reduces the size of vector constant pool loads.
78
79/// Return a pass that removes redundant LEA instructions and redundant address
80/// recalculations.
82
83/// Return a pass that transforms setcc + movzx pairs into xor + setcc.
85
86/// Return a pass that avoids creating store forward block issues in the hardware.
88
89/// Return a pass that lowers EFLAGS copy pseudo instructions.
91
92/// Return a pass that expands DynAlloca pseudo-instructions.
94 : public PassInfoMixin<X86DynAllocaExpanderPass> {
95public:
98};
99
101
102/// Return a pass that config the tile registers.
104
105/// Return a pass that preconfig the tile registers before fast reg allocation.
107
108/// Return a pass that config the tile registers after fast reg allocation.
110
111/// Return a pass that insert pseudo tile config instruction.
113
114/// Return a pass that lower the tile copy instruction.
116
117/// Return a pass that inserts int3 at the end of the function if it ends with a
118/// CALL instruction. The pass does the same for each funclet as well. This
119/// ensures that the open interval of function start and end PCs contains all
120/// return addresses for the benefit of the Windows x64 unwinder.
122 : public PassInfoMixin<X86AvoidTrailingCallPass> {
123public:
126 static bool isRequired() { return true; }
127};
128
130
131/// Return a pass that optimizes the code-size of x86 call sequences. This is
132/// done by replacing esp-relative movs with pushes.
133FunctionPass *createX86CallFrameOptimization();
134
135/// Return an IR pass that inserts EH registration stack objects and explicit
136/// EH state updates. This pass must run after EH preparation, which does
137/// Windows-specific but architecture-neutral preparation.
138FunctionPass *createX86WinEHStatePass();
139
140/// Return a Machine IR pass that expands X86-specific pseudo
141/// instructions into a sequence of actual instructions. This pass
142/// must run after prologue/epilogue insertion and before lowering
143/// the MachineInstr to MC.
144FunctionPass *createX86ExpandPseudoPass();
145
146/// This pass converts X86 cmov instructions into branch when profitable.
147FunctionPass *createX86CmovConverterPass();
148
149/// Return a Machine IR pass that selectively replaces
150/// certain byte and word instructions by equivalent 32 bit instructions,
151/// in order to eliminate partial register usage, false dependences on
152/// the upper portions of registers, and to save code size.
153FunctionPass *createX86FixupBWInsts();
154
155/// Return a Machine IR pass that reassigns instruction chains from one domain
156/// to another, when profitable.
158
159/// This pass compress instructions from EVEX space to legacy/VEX/EVEX space when
160/// possible in order to reduce code size or facilitate HW decoding.
162
163/// This pass creates the thunks for the retpoline feature.
165
166/// This pass replaces ret instructions with jmp's to __x86_return thunk.
168
169/// This pass insert wait instruction after X87 instructions which could raise
170/// fp exceptions when strict-fp enabled.
172
173/// This pass optimizes arithmetic based on knowledge that is only used by
174/// a reduction sequence and is therefore safe to reassociate in interesting
175/// ways.
176class X86PartialReductionPass : public PassInfoMixin<X86PartialReductionPass> {
177private:
178 const X86TargetMachine *TM;
179
180public:
183};
184
186
187/// // Analyzes and emits pseudos to support Win x64 Unwind V2.
189
190/// The pass transforms load/store <256 x i32> to AMX load/store intrinsics
191/// or split the data to two <128 x i32>.
192class X86LowerAMXTypePass : public PassInfoMixin<X86LowerAMXTypePass> {
193private:
194 const TargetMachine *TM;
195
196public:
197 X86LowerAMXTypePass(const TargetMachine *TM) : TM(TM) {}
199 static bool isRequired() { return true; }
200};
201
202FunctionPass *createX86LowerAMXTypeLegacyPass();
203
204/// The pass transforms amx intrinsics to scalar operation if the function has
205/// optnone attribute or it is O0.
207 : public PassInfoMixin<X86LowerAMXIntrinsicsPass> {
208private:
209 const TargetMachine *TM;
210
211public:
214 static bool isRequired() { return true; }
215};
216
218
219InstructionSelector *createX86InstructionSelector(const X86TargetMachine &TM,
220 const X86Subtarget &,
221 const X86RegisterBankInfo &);
222
229
266
267namespace X86AS {
268enum : unsigned {
269 GS = 256,
270 FS = 257,
271 SS = 258,
274 PTR64 = 272
275};
276} // End X86AS namespace
277
278} // End llvm namespace
279
280#endif
This header defines various interfaces for pass management in LLVM.
#define F(x, y, z)
Definition MD5.cpp:54
FunctionAnalysisManager FAM
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:314
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
Primary interface to the complete machine description for the target machine.
Return a pass that inserts int3 at the end of the function if it ends with a CALL instruction.
Definition X86.h:122
static bool isRequired()
Definition X86.h:126
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a pass that expands DynAlloca pseudo-instructions.
Definition X86.h:94
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
This function returns a pass which converts floating-point register references and pseudo instruction...
Definition X86.h:47
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
X86LowerAMXIntrinsicsPass(const TargetMachine *TM)
Definition X86.h:212
static bool isRequired()
Definition X86.h:214
X86LowerAMXTypePass(const TargetMachine *TM)
Definition X86.h:197
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
static bool isRequired()
Definition X86.h:199
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
X86PartialReductionPass(const X86TargetMachine *TM)
Definition X86.h:181
This class provides the information for the target register banks.
Pass manager infrastructure for declaring and invalidating analyses.
@ PTR32_UPTR
Definition X86.h:273
@ PTR64
Definition X86.h:274
@ PTR32_SPTR
Definition X86.h:272
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createX86WinEHStatePass()
Return an IR pass that inserts EH registration stack objects and explicit EH state updates.
void initializeX86TileConfigPass(PassRegistry &)
FunctionPass * createX86LowerAMXIntrinsicsLegacyPass()
void initializeX86PartialReductionLegacyPass(PassRegistry &)
FunctionPass * createX86SuppressAPXForRelocationPass()
void initializeX86CallFrameOptimizationPass(PassRegistry &)
void initializeFixupBWInstPassPass(PassRegistry &)
void initializeX86LoadValueInjectionRetHardeningPassPass(PassRegistry &)
FunctionPass * createX86LoadValueInjectionLoadHardeningPass()
FunctionPass * createX86IssueVZeroUpperPass()
This pass inserts AVX vzeroupper instructions before each call to avoid transition penalty between fu...
void initializeX86ArgumentStackSlotPassPass(PassRegistry &)
void initializeX86SpeculativeLoadHardeningPassPass(PassRegistry &)
FunctionPass * createX86DynAllocaExpanderLegacyPass()
void initializeWinEHStatePassPass(PassRegistry &)
FunctionPass * createX86GlobalBaseRegPass()
This pass initializes a global base register for PIC on x86-32.
FunctionPass * createX86FixupBWInsts()
Return a Machine IR pass that selectively replaces certain byte and word instructions by equivalent 3...
void initializeX86LowerAMXIntrinsicsLegacyPassPass(PassRegistry &)
FunctionPass * createX86DomainReassignmentPass()
Return a Machine IR pass that reassigns instruction chains from one domain to another,...
FunctionPass * createX86LoadValueInjectionRetHardeningPass()
FunctionPass * createX86SpeculativeExecutionSideEffectSuppression()
FunctionPass * createX86PartialReductionLegacyPass()
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
FunctionPass * createCleanupLocalDynamicTLSPass()
This pass combines multiple accesses to local-dynamic TLS variables so that the TLS base address for ...
FunctionPass * createX86FlagsCopyLoweringPass()
Return a pass that lowers EFLAGS copy pseudo instructions.
void initializeX86DynAllocaExpanderLegacyPass(PassRegistry &)
void initializeX86FastTileConfigPass(PassRegistry &)
FunctionPass * createX86CompressEVEXPass()
This pass compress instructions from EVEX space to legacy/VEX/EVEX space when possible in order to re...
void initializeX86ExpandPseudoPass(PassRegistry &)
FunctionPass * createX86ArgumentStackSlotPass()
void initializeX86PreTileConfigPass(PassRegistry &)
FunctionPass * createX86CmovConverterPass()
This pass converts X86 cmov instructions into branch when profitable.
FunctionPass * createX86TileConfigPass()
Return a pass that config the tile registers.
FunctionPass * createX86PadShortFunctions()
Return a pass that pads short functions with NOOPs.
void initializeX86DomainReassignmentPass(PassRegistry &)
void initializeX86LoadValueInjectionLoadHardeningPassPass(PassRegistry &)
void initializeX86SuppressAPXForRelocationPassPass(PassRegistry &)
FunctionPass * createX86FastPreTileConfigPass()
Return a pass that preconfig the tile registers before fast reg allocation.
void initializeX86AvoidSFBPassPass(PassRegistry &)
FunctionPass * createX86LowerTileCopyPass()
Return a pass that lower the tile copy instruction.
void initializeX86FastPreTileConfigPass(PassRegistry &)
FunctionPass * createX86SpeculativeLoadHardeningPass()
FunctionPass * createX86FixupSetCC()
Return a pass that transforms setcc + movzx pairs into xor + setcc.
FunctionPass * createX86IndirectBranchTrackingPass()
This pass inserts ENDBR instructions before indirect jump/call destinations as part of CET IBT mechan...
void initializeX86AsmPrinterPass(PassRegistry &)
FunctionPass * createX86InsertX87waitPass()
This pass insert wait instruction after X87 instructions which could raise fp exceptions when strict-...
void initializeX86FixupSetCCPassPass(PassRegistry &)
FunctionPass * createX86ExpandPseudoPass()
Return a Machine IR pass that expands X86-specific pseudo instructions into a sequence of actual inst...
FunctionPass * createX86FixupInstTuning()
Return a pass that replaces equivalent slower instructions with faster ones.
void initializeX86AvoidTrailingCallLegacyPassPass(PassRegistry &)
void initializeX86WinEHUnwindV2Pass(PassRegistry &)
FunctionPass * createX86ISelDag(X86TargetMachine &TM, CodeGenOptLevel OptLevel)
This pass converts a legalized DAG into a X86-specific DAG, ready for instruction scheduling.
void initializeX86LowerTileCopyPass(PassRegistry &)
void initializeX86OptimizeLEAPassPass(PassRegistry &)
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:82
FunctionPass * createX86FastTileConfigPass()
Return a pass that config the tile registers after fast reg allocation.
void initializeX86FPStackifierLegacyPass(PassRegistry &)
FunctionPass * createX86FixupLEAs()
Return a pass that selectively replaces certain instructions (like add, sub, inc, dec,...
void initializeX86FixupInstTuningPassPass(PassRegistry &)
void initializeX86LowerAMXTypeLegacyPassPass(PassRegistry &)
void initializeX86CmovConverterPassPass(PassRegistry &)
FunctionPass * createX86CallFrameOptimization()
Return a pass that optimizes the code-size of x86 call sequences.
FunctionPass * createX86FPStackifierLegacyPass()
void initializeX86FlagsCopyLoweringPassPass(PassRegistry &)
FunctionPass * createX86WinEHUnwindV2Pass()
// Analyzes and emits pseudos to support Win x64 Unwind V2.
FunctionPass * createX86LowerAMXTypeLegacyPass()
void initializeX86SpeculativeExecutionSideEffectSuppressionPass(PassRegistry &)
void initializeCompressEVEXPassPass(PassRegistry &)
FunctionPass * createX86OptimizeLEAs()
Return a pass that removes redundant LEA instructions and redundant address recalculations.
void initializeX86FixupVectorConstantsPassPass(PassRegistry &)
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
FunctionPass * createX86IndirectThunksPass()
This pass creates the thunks for the retpoline feature.
FunctionPass * createX86FixupVectorConstants()
Return a pass that reduces the size of vector constant pool loads.
void initializeX86ExecutionDomainFixPass(PassRegistry &)
FunctionPass * createX86PreTileConfigPass()
Return a pass that insert pseudo tile config instruction.
FunctionPass * createX86ReturnThunksPass()
This pass replaces ret instructions with jmp's to __x86_return thunk.
FunctionPass * createX86AvoidStoreForwardingBlocks()
Return a pass that avoids creating store forward block issues in the hardware.
void initializeX86ReturnThunksPass(PassRegistry &)
void initializeX86DAGToDAGISelLegacyPass(PassRegistry &)
void initializeFixupLEAPassPass(PassRegistry &)
FunctionPass * createX86AvoidTrailingCallLegacyPass()
InstructionSelector * createX86InstructionSelector(const X86TargetMachine &TM, const X86Subtarget &, const X86RegisterBankInfo &)
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition PassManager.h:69