LLVM 23.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.
81class X86FixupInstTuningPass : public PassInfoMixin<X86FixupInstTuningPass> {
82public:
85};
86
88
89/// Return a pass that reduces the size of vector constant pool loads.
91 : public PassInfoMixin<X86FixupInstTuningPass> {
92public:
95};
96
98
99/// Return a pass that removes redundant LEA instructions and redundant address
100/// recalculations.
101class X86OptimizeLEAsPass : public PassInfoMixin<X86OptimizeLEAsPass> {
102public:
105};
106
108
109/// Return a pass that transforms setcc + movzx pairs into xor + setcc.
110class X86FixupSetCCPass : public PassInfoMixin<X86FixupSetCCPass> {
111public:
114};
115
117
118/// Return a pass that avoids creating store forward block issues in the
119/// hardware.
121 : public PassInfoMixin<X86AvoidStoreForwardingBlocksPass> {
122public:
125};
126
128
129/// Return a pass that lowers EFLAGS copy pseudo instructions.
131 : public PassInfoMixin<X86FlagsCopyLoweringPass> {
132public:
135};
136
138
139/// Return a pass that expands DynAlloca pseudo-instructions.
141 : public PassInfoMixin<X86DynAllocaExpanderPass> {
142public:
145};
146
148
149/// Return a pass that config the tile registers.
150class X86TileConfigPass : public PassInfoMixin<X86TileConfigPass> {
151public:
154};
155
157
158/// Return a pass that preconfig the tile registers before fast reg allocation.
160 : public PassInfoMixin<X86FastPreTileConfigPass> {
161public:
164};
165
167
168/// Return a pass that config the tile registers after fast reg allocation.
169class X86FastTileConfigPass : public PassInfoMixin<X86FastTileConfigPass> {
170public:
173};
174
176
177/// Return a pass that insert pseudo tile config instruction.
178class X86PreTileConfigPass : public PassInfoMixin<X86PreTileConfigPass> {
179public:
182};
183
185
186/// Return a pass that lower the tile copy instruction.
187class X86LowerTileCopyPass : public PassInfoMixin<X86LowerTileCopyPass> {
188public:
191};
192
194
195/// Return a pass that inserts int3 at the end of the function if it ends with a
196/// CALL instruction. The pass does the same for each funclet as well. This
197/// ensures that the open interval of function start and end PCs contains all
198/// return addresses for the benefit of the Windows x64 unwinder.
200 : public PassInfoMixin<X86AvoidTrailingCallPass> {
201public:
204 static bool isRequired() { return true; }
205};
206
208
209/// Return a pass that optimizes the code-size of x86 call sequences. This is
210/// done by replacing esp-relative movs with pushes.
212 : public PassInfoMixin<X86CallFrameOptimizationPass> {
213public:
216};
217
219
220/// Return an IR pass that inserts EH registration stack objects and explicit
221/// EH state updates. This pass must run after EH preparation, which does
222/// Windows-specific but architecture-neutral preparation.
224
225/// Return a Machine IR pass that expands X86-specific pseudo
226/// instructions into a sequence of actual instructions. This pass
227/// must run after prologue/epilogue insertion and before lowering
228/// the MachineInstr to MC.
229class X86ExpandPseudoPass : public PassInfoMixin<X86ExpandPseudoPass> {
230public:
233};
234
236
237/// This pass converts X86 cmov instructions into branch when profitable.
238class X86CmovConversionPass : public PassInfoMixin<X86CmovConversionPass> {
239public:
242};
243
245
246/// Return a Machine IR pass that selectively replaces
247/// certain byte and word instructions by equivalent 32 bit instructions,
248/// in order to eliminate partial register usage, false dependences on
249/// the upper portions of registers, and to save code size.
250class X86FixupBWInstsPass : public PassInfoMixin<X86FixupBWInstsPass> {
251public:
254};
255
257
258/// Return a Machine IR pass that reassigns instruction chains from one domain
259/// to another, when profitable.
261 : public PassInfoMixin<X86DomainReassignmentPass> {
262public:
265};
266
268
269/// This pass compress instructions from EVEX space to legacy/VEX/EVEX space when
270/// possible in order to reduce code size or facilitate HW decoding.
271class X86CompressEVEXPass : public PassInfoMixin<X86CompressEVEXPass> {
272public:
275};
276
278
279/// This pass creates the thunks for the retpoline feature.
281
282/// This pass replaces ret instructions with jmp's to __x86_return thunk.
284
285/// This pass insert wait instruction after X87 instructions which could raise
286/// fp exceptions when strict-fp enabled.
288
289/// This pass optimizes arithmetic based on knowledge that is only used by
290/// a reduction sequence and is therefore safe to reassociate in interesting
291/// ways.
292class X86PartialReductionPass : public PassInfoMixin<X86PartialReductionPass> {
293private:
294 const X86TargetMachine *TM;
295
296public:
299};
300
302
303/// // Analyzes and emits pseudos to support Win x64 Unwind V2.
305
306/// The pass transforms load/store <256 x i32> to AMX load/store intrinsics
307/// or split the data to two <128 x i32>.
308class X86LowerAMXTypePass : public PassInfoMixin<X86LowerAMXTypePass> {
309private:
310 const TargetMachine *TM;
311
312public:
313 X86LowerAMXTypePass(const TargetMachine *TM) : TM(TM) {}
315 static bool isRequired() { return true; }
316};
317
318FunctionPass *createX86LowerAMXTypeLegacyPass();
319
320// Suppresses APX features for relocations for supporting older linkers.
322 : public PassInfoMixin<X86SuppressAPXForRelocationPass> {
323public:
326};
327
329
330/// The pass transforms amx intrinsics to scalar operation if the function has
331/// optnone attribute or it is O0.
333 : public PassInfoMixin<X86LowerAMXIntrinsicsPass> {
334private:
335 const TargetMachine *TM;
336
337public:
340 static bool isRequired() { return true; }
341};
342
344
345InstructionSelector *createX86InstructionSelector(const X86TargetMachine &TM,
346 const X86Subtarget &,
347 const X86RegisterBankInfo &);
348
349FunctionPass *createX86PreLegalizerCombiner();
355
393
394namespace X86AS {
395enum : unsigned {
396 GS = 256,
397 FS = 257,
398 SS = 258,
401 PTR64 = 272
402};
403} // End X86AS namespace
404
405} // End llvm namespace
406
407#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:121
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:200
static bool isRequired()
Definition X86.h:204
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a pass that optimizes the code-size of x86 call sequences.
Definition X86.h:212
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
This pass converts X86 cmov instructions into branch when profitable.
Definition X86.h:238
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:271
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a Machine IR pass that reassigns instruction chains from one domain to another,...
Definition X86.h:261
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a pass that expands DynAlloca pseudo-instructions.
Definition X86.h:141
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:229
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:160
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a pass that config the tile registers after fast reg allocation.
Definition X86.h:169
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a Machine IR pass that selectively replaces certain byte and word instructions by equivalent 3...
Definition X86.h:250
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a pass that replaces equivalent slower instructions with faster ones.
Definition X86.h:81
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 transforms setcc + movzx pairs into xor + setcc.
Definition X86.h:110
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a pass that reduces the size of vector constant pool loads.
Definition X86.h:91
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a pass that lowers EFLAGS copy pseudo instructions.
Definition X86.h:131
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
X86LowerAMXIntrinsicsPass(const TargetMachine *TM)
Definition X86.h:338
static bool isRequired()
Definition X86.h:340
X86LowerAMXTypePass(const TargetMachine *TM)
Definition X86.h:313
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
static bool isRequired()
Definition X86.h:315
Return a pass that lower the tile copy instruction.
Definition X86.h:187
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a pass that removes redundant LEA instructions and redundant address recalculations.
Definition X86.h:101
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
X86PartialReductionPass(const X86TargetMachine *TM)
Definition X86.h:297
Return a pass that insert pseudo tile config instruction.
Definition X86.h:178
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
This class provides the information for the target register banks.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Return a pass that config the tile registers.
Definition X86.h:150
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Pass manager infrastructure for declaring and invalidating analyses.
@ PTR32_UPTR
Definition X86.h:400
@ PTR64
Definition X86.h:401
@ PTR32_SPTR
Definition X86.h:399
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.
FunctionPass * createX86LowerAMXIntrinsicsLegacyPass()
FunctionPass * createX86CompressEVEXLegacyPass()
FunctionPass * createX86FastTileConfigLegacyPass()
void initializeX86PartialReductionLegacyPass(PassRegistry &)
FunctionPass * createX86DomainReassignmentLegacyPass()
FunctionPass * createX86ExpandPseudoLegacyPass()
Returns an instance of the pseudo instruction expansion pass.
FunctionPass * createX86OptimizeLEAsLegacyPass()
void initializeCompressEVEXLegacyPass(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 * createX86TileConfigLegacyPass()
FunctionPass * createX86GlobalBaseRegPass()
This pass initializes a global base register for PIC on x86-32.
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 &)
FunctionPass * createX86FixupSetCCLegacyPass()
void initializeX86FastPreTileConfigLegacyPass(PassRegistry &)
FunctionPass * createX86ArgumentStackSlotPass()
FunctionPass * createX86PadShortFunctions()
Return a pass that pads short functions with NOOPs.
void initializeX86LoadValueInjectionLoadHardeningPassPass(PassRegistry &)
void initializeX86PreLegalizerCombinerPass(PassRegistry &)
void initializeX86FastTileConfigLegacyPass(PassRegistry &)
void initializeX86FixupVectorConstantsLegacyPass(PassRegistry &)
FunctionPass * createX86SpeculativeLoadHardeningPass()
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-...
FunctionPass * createX86LowerTileCopyLegacyPass()
void initializeX86ExpandPseudoLegacyPass(PassRegistry &)
FunctionPass * createX86CmovConversionLegacyPass()
void initializeX86FixupInstTuningLegacyPass(PassRegistry &)
void initializeX86FlagsCopyLoweringLegacyPass(PassRegistry &)
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.
FunctionPass * createX86FixupLEAsLegacyPass()
FunctionPass * createX86CallFrameOptimizationLegacyPass()
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:82
void initializeX86CallFrameOptimizationLegacyPass(PassRegistry &)
FunctionPass * createX86FlagsCopyLoweringLegacyPass()
void initializeX86FixupBWInstLegacyPass(PassRegistry &)
void initializeX86FPStackifierLegacyPass(PassRegistry &)
void initializeX86LowerTileCopyLegacyPass(PassRegistry &)
void initializeX86TileConfigLegacyPass(PassRegistry &)
void initializeFixupLEAsLegacyPass(PassRegistry &)
FunctionPass * createX86PreTileConfigLegacyPass()
void initializeX86LowerAMXTypeLegacyPassPass(PassRegistry &)
FunctionPass * createX86FixupBWInstsLegacyPass()
FunctionPass * createX86FPStackifierLegacyPass()
void initializeX86PreTileConfigLegacyPass(PassRegistry &)
FunctionPass * createX86SuppressAPXForRelocationLegacyPass()
FunctionPass * createX86FastPreTileConfigLegacyPass()
FunctionPass * createX86WinEHUnwindV2Pass()
// Analyzes and emits pseudos to support Win x64 Unwind V2.
FunctionPass * createX86LowerAMXTypeLegacyPass()
FunctionPass * createX86PreLegalizerCombiner()
void initializeX86SpeculativeExecutionSideEffectSuppressionPass(PassRegistry &)
void initializeX86SuppressAPXForRelocationLegacyPass(PassRegistry &)
FunctionPass * createX86FixupVectorConstantsLegacyPass()
void initializeX86FixupSetCCLegacyPass(PassRegistry &)
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
FunctionPass * createX86IndirectThunksPass()
This pass creates the thunks for the retpoline feature.
FunctionPass * createX86FixupInstTuningLegacyPass()
void initializeX86ExecutionDomainFixPass(PassRegistry &)
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