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"
20#include "llvm/PassInfo.h"
23
24namespace llvm {
25
26class FunctionPass;
28class PassRegistry;
30class X86Subtarget;
32
33/// This pass converts a legalized DAG into a X86-specific DAG, ready for
34/// instruction scheduling.
36
37/// This pass initializes a global base register for PIC on x86-32.
39
40/// This pass combines multiple accesses to local-dynamic TLS variables so that
41/// the TLS base address for the module is only fetched once per execution path
42/// through the function.
44
45/// This function returns a pass which converts floating-point register
46/// references and pseudo instructions into floating-point stack references and
47/// physical instructions.
48class X86FPStackifierPass : public PassInfoMixin<X86FPStackifierPass> {
49public:
52};
53
55
56/// This pass inserts AVX vzeroupper instructions before each call to avoid
57/// transition penalty between functions encoded with AVX and SSE.
59
60/// This pass inserts ENDBR instructions before indirect jump/call
61/// destinations as part of CET IBT mechanism.
63
64/// Return a pass that pads short functions with NOOPs.
65/// This will prevent a stall when returning on the Atom.
67
68/// Return a pass that selectively replaces certain instructions (like add,
69/// sub, inc, dec, some shifts, and some multiplies) by equivalent LEA
70/// instructions, in order to eliminate execution delays in some processors.
71class X86FixupLEAsPass : public PassInfoMixin<X86FixupLEAsPass> {
72public:
75};
76
78
79/// Return a pass that replaces equivalent slower instructions with faster
80/// ones.
82
83/// Return a pass that reduces the size of vector constant pool loads.
85
86/// Return a pass that removes redundant LEA instructions and redundant address
87/// recalculations.
88class X86OptimizeLEAsPass : public PassInfoMixin<X86OptimizeLEAsPass> {
89public:
92};
93
95
96/// Return a pass that transforms setcc + movzx pairs into xor + setcc.
98
99/// Return a pass that avoids creating store forward block issues in the
100/// hardware.
102 : public PassInfoMixin<X86AvoidStoreForwardingBlocksPass> {
103public:
106};
107
109
110/// Return a pass that lowers EFLAGS copy pseudo instructions.
112 : public PassInfoMixin<X86FlagsCopyLoweringPass> {
113public:
116};
117
119
120/// Return a pass that expands DynAlloca pseudo-instructions.
122 : public PassInfoMixin<X86DynAllocaExpanderPass> {
123public:
126};
127
129
130/// Return a pass that config the tile registers.
132
133/// Return a pass that preconfig the tile registers before fast reg allocation.
135 : public PassInfoMixin<X86FastPreTileConfigPass> {
136public:
139};
140
142
143/// Return a pass that config the tile registers after fast reg allocation.
144class X86FastTileConfigPass : public PassInfoMixin<X86FastTileConfigPass> {
145public:
148};
149
151
152/// Return a pass that insert pseudo tile config instruction.
154
155/// Return a pass that lower the tile copy instruction.
157
158/// Return a pass that inserts int3 at the end of the function if it ends with a
159/// CALL instruction. The pass does the same for each funclet as well. This
160/// ensures that the open interval of function start and end PCs contains all
161/// return addresses for the benefit of the Windows x64 unwinder.
163 : public PassInfoMixin<X86AvoidTrailingCallPass> {
164public:
167 static bool isRequired() { return true; }
168};
169
171
172/// Return a pass that optimizes the code-size of x86 call sequences. This is
173/// done by replacing esp-relative movs with pushes.
175 : public PassInfoMixin<X86CallFrameOptimizationPass> {
176public:
179};
180
182
183/// Return an IR pass that inserts EH registration stack objects and explicit
184/// EH state updates. This pass must run after EH preparation, which does
185/// Windows-specific but architecture-neutral preparation.
187
188/// Return a Machine IR pass that expands X86-specific pseudo
189/// instructions into a sequence of actual instructions. This pass
190/// must run after prologue/epilogue insertion and before lowering
191/// the MachineInstr to MC.
192class X86ExpandPseudoPass : public PassInfoMixin<X86ExpandPseudoPass> {
193public:
196};
197
199
200/// This pass converts X86 cmov instructions into branch when profitable.
201class X86CmovConversionPass : public PassInfoMixin<X86CmovConversionPass> {
202public:
205};
206
208
209/// Return a Machine IR pass that selectively replaces
210/// certain byte and word instructions by equivalent 32 bit instructions,
211/// in order to eliminate partial register usage, false dependences on
212/// the upper portions of registers, and to save code size.
214
215/// Return a Machine IR pass that reassigns instruction chains from one domain
216/// to another, when profitable.
218 : public PassInfoMixin<X86DomainReassignmentPass> {
219public:
222};
223
225
226/// This pass compress instructions from EVEX space to legacy/VEX/EVEX space when
227/// possible in order to reduce code size or facilitate HW decoding.
228class X86CompressEVEXPass : public PassInfoMixin<X86CompressEVEXPass> {
229public:
232};
233
235
236/// This pass creates the thunks for the retpoline feature.
238
239/// This pass replaces ret instructions with jmp's to __x86_return thunk.
241
242/// This pass insert wait instruction after X87 instructions which could raise
243/// fp exceptions when strict-fp enabled.
245
246/// This pass optimizes arithmetic based on knowledge that is only used by
247/// a reduction sequence and is therefore safe to reassociate in interesting
248/// ways.
249class X86PartialReductionPass : public PassInfoMixin<X86PartialReductionPass> {
250private:
251 const X86TargetMachine *TM;
252
253public:
256};
257
259
260/// // Analyzes and emits pseudos to support Win x64 Unwind V2.
262
263/// The pass transforms load/store <256 x i32> to AMX load/store intrinsics
264/// or split the data to two <128 x i32>.
265class X86LowerAMXTypePass : public PassInfoMixin<X86LowerAMXTypePass> {
266private:
267 const TargetMachine *TM;
268
269public:
270 X86LowerAMXTypePass(const TargetMachine *TM) : TM(TM) {}
272 static bool isRequired() { return true; }
273};
274
275FunctionPass *createX86LowerAMXTypeLegacyPass();
276
277/// The pass transforms amx intrinsics to scalar operation if the function has
278/// optnone attribute or it is O0.
280 : public PassInfoMixin<X86LowerAMXIntrinsicsPass> {
281private:
282 const TargetMachine *TM;
283
284public:
287 static bool isRequired() { return true; }
288};
289
291
292InstructionSelector *createX86InstructionSelector(const X86TargetMachine &TM,
293 const X86Subtarget &,
294 const X86RegisterBankInfo &);
295
296FunctionPass *createX86PreLegalizerCombiner();
303
341
342namespace X86AS {
343enum : unsigned {
344 GS = 256,
345 FS = 257,
346 SS = 258,
349 PTR64 = 272
350};
351} // End X86AS namespace
352
353} // End llvm namespace
354
355#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 avoids creating store forward block issues in the hardware.
Definition X86.h:102
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a pass that inserts int3 at the end of the function if it ends with a CALL instruction.
Definition X86.h:163
static bool isRequired()
Definition X86.h:167
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a pass that optimizes the code-size of x86 call sequences.
Definition X86.h:175
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
This pass converts X86 cmov instructions into branch when profitable.
Definition X86.h:201
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
This pass compress instructions from EVEX space to legacy/VEX/EVEX space when possible in order to re...
Definition X86.h:228
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a Machine IR pass that reassigns instruction chains from one domain to another,...
Definition X86.h:218
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a pass that expands DynAlloca pseudo-instructions.
Definition X86.h:122
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a Machine IR pass that expands X86-specific pseudo instructions into a sequence of actual inst...
Definition X86.h:192
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
This function returns a pass which converts floating-point register references and pseudo instruction...
Definition X86.h:48
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a pass that preconfig the tile registers before fast reg allocation.
Definition X86.h:135
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a pass that config the tile registers after fast reg allocation.
Definition X86.h:144
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a pass that selectively replaces certain instructions (like add, sub, inc, dec,...
Definition X86.h:71
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a pass that lowers EFLAGS copy pseudo instructions.
Definition X86.h:112
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
X86LowerAMXIntrinsicsPass(const TargetMachine *TM)
Definition X86.h:285
static bool isRequired()
Definition X86.h:287
X86LowerAMXTypePass(const TargetMachine *TM)
Definition X86.h:270
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
static bool isRequired()
Definition X86.h:272
Return a pass that removes redundant LEA instructions and redundant address recalculations.
Definition X86.h:88
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
X86PartialReductionPass(const X86TargetMachine *TM)
Definition X86.h:254
This class provides the information for the target register banks.
Pass manager infrastructure for declaring and invalidating analyses.
@ PTR32_UPTR
Definition X86.h:348
@ PTR64
Definition X86.h:349
@ PTR32_SPTR
Definition X86.h:347
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
FunctionPass * createX86WinEHStatePass()
Return an IR pass that inserts EH registration stack objects and explicit EH state updates.
void initializeX86TileConfigPass(PassRegistry &)
FunctionPass * createX86LowerAMXIntrinsicsLegacyPass()
FunctionPass * createX86CompressEVEXLegacyPass()
FunctionPass * createX86FastTileConfigLegacyPass()
void initializeX86PartialReductionLegacyPass(PassRegistry &)
FunctionPass * createX86DomainReassignmentLegacyPass()
FunctionPass * createX86ExpandPseudoLegacyPass()
Returns an instance of the pseudo instruction expansion pass.
FunctionPass * createX86SuppressAPXForRelocationPass()
FunctionPass * createX86OptimizeLEAsLegacyPass()
void initializeCompressEVEXLegacyPass(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 &)
void initializeX86DomainReassignmentLegacyPass(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...
FunctionPass * createX86AvoidStoreForwardingBlocksLegacyPass()
void initializeX86LowerAMXIntrinsicsLegacyPassPass(PassRegistry &)
FunctionPass * createX86LoadValueInjectionRetHardeningPass()
FunctionPass * createX86SpeculativeExecutionSideEffectSuppression()
FunctionPass * createX86PartialReductionLegacyPass()
void initializeX86CmovConversionLegacyPass(PassRegistry &)
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
FunctionPass * createCleanupLocalDynamicTLSPass()
This pass combines multiple accesses to local-dynamic TLS variables so that the TLS base address for ...
void initializeX86DynAllocaExpanderLegacyPass(PassRegistry &)
void initializeX86FastPreTileConfigLegacyPass(PassRegistry &)
FunctionPass * createX86ArgumentStackSlotPass()
void initializeX86PreTileConfigPass(PassRegistry &)
FunctionPass * createX86TileConfigPass()
Return a pass that config the tile registers.
FunctionPass * createX86PadShortFunctions()
Return a pass that pads short functions with NOOPs.
void initializeX86LoadValueInjectionLoadHardeningPassPass(PassRegistry &)
void initializeX86SuppressAPXForRelocationPassPass(PassRegistry &)
FunctionPass * createX86LowerTileCopyPass()
Return a pass that lower the tile copy instruction.
void initializeX86PreLegalizerCombinerPass(PassRegistry &)
void initializeX86FastTileConfigLegacyPass(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 initializeX86ExpandPseudoLegacyPass(PassRegistry &)
void initializeX86FixupSetCCPassPass(PassRegistry &)
FunctionPass * createX86CmovConversionLegacyPass()
void initializeX86FlagsCopyLoweringLegacyPass(PassRegistry &)
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 &)
FunctionPass * createX86FixupLEAsLegacyPass()
FunctionPass * createX86CallFrameOptimizationLegacyPass()
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:82
void initializeX86CallFrameOptimizationLegacyPass(PassRegistry &)
FunctionPass * createX86FlagsCopyLoweringLegacyPass()
void initializeX86FPStackifierLegacyPass(PassRegistry &)
void initializeFixupLEAsLegacyPass(PassRegistry &)
void initializeX86FixupInstTuningPassPass(PassRegistry &)
void initializeX86LowerAMXTypeLegacyPassPass(PassRegistry &)
FunctionPass * createX86FPStackifierLegacyPass()
FunctionPass * createX86FastPreTileConfigLegacyPass()
FunctionPass * createX86WinEHUnwindV2Pass()
// Analyzes and emits pseudos to support Win x64 Unwind V2.
FunctionPass * createX86LowerAMXTypeLegacyPass()
FunctionPass * createX86PreLegalizerCombiner()
void initializeX86SpeculativeExecutionSideEffectSuppressionPass(PassRegistry &)
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.
void initializeX86ReturnThunksPass(PassRegistry &)
void initializeX86DAGToDAGISelLegacyPass(PassRegistry &)
void initializeX86OptimizeLEAsLegacyPass(PassRegistry &)
void initializeX86AvoidSFBLegacyPass(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:70