LLVM 23.0.0git
X86TargetMachine.cpp
Go to the documentation of this file.
1//===-- X86TargetMachine.cpp - Define TargetMachine for the X86 -----------===//
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 defines the X86 specific subclass of TargetMachine.
10//
11//===----------------------------------------------------------------------===//
12
13#include "X86TargetMachine.h"
16#include "X86.h"
18#include "X86MacroFusion.h"
19#include "X86Subtarget.h"
20#include "X86TargetObjectFile.h"
22#include "llvm-c/Visibility.h"
24#include "llvm/ADT/StringRef.h"
36#include "llvm/CodeGen/Passes.h"
38#include "llvm/IR/Attributes.h"
39#include "llvm/IR/DataLayout.h"
40#include "llvm/IR/Function.h"
41#include "llvm/MC/MCAsmInfo.h"
43#include "llvm/Pass.h"
51#include <memory>
52#include <optional>
53
54using namespace llvm;
55
57 X86EnableMachineCombinerPass("x86-machine-combiner",
58 cl::desc("Enable the machine combiner pass"),
59 cl::init(true), cl::Hidden);
60
61static cl::opt<bool>
62 EnableTileRAPass("x86-tile-ra",
63 cl::desc("Enable the tile register allocation pass"),
64 cl::init(true), cl::Hidden);
65
67 // Register the target.
70
112}
113
114static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
115 if (TT.isOSBinFormatMachO()) {
116 if (TT.isX86_64())
117 return std::make_unique<X86_64MachoTargetObjectFile>();
118 return std::make_unique<TargetLoweringObjectFileMachO>();
119 }
120
121 if (TT.isOSBinFormatCOFF())
122 return std::make_unique<TargetLoweringObjectFileCOFF>();
123
124 if (TT.isX86_64())
125 return std::make_unique<X86_64ELFTargetObjectFile>();
126 return std::make_unique<X86ELFTargetObjectFile>();
127}
128
129static Reloc::Model getEffectiveRelocModel(const Triple &TT, bool JIT,
130 std::optional<Reloc::Model> RM) {
131 bool is64Bit = TT.isX86_64();
132 if (!RM) {
133 // JIT codegen should use static relocations by default, since it's
134 // typically executed in process and not relocatable.
135 if (JIT)
136 return Reloc::Static;
137
138 // Darwin defaults to PIC in 64 bit mode and dynamic-no-pic in 32 bit mode.
139 // Win64 requires rip-rel addressing, thus we force it to PIC. Otherwise we
140 // use static relocation model by default.
141 if (TT.isOSDarwin()) {
142 if (is64Bit)
143 return Reloc::PIC_;
144 return Reloc::DynamicNoPIC;
145 }
146 if (TT.isOSWindows() && is64Bit)
147 return Reloc::PIC_;
148 return Reloc::Static;
149 }
150
151 // ELF and X86-64 don't have a distinct DynamicNoPIC model. DynamicNoPIC
152 // is defined as a model for code which may be used in static or dynamic
153 // executables but not necessarily a shared library. On X86-32 we just
154 // compile in -static mode, in x86-64 we use PIC.
155 if (*RM == Reloc::DynamicNoPIC) {
156 if (is64Bit)
157 return Reloc::PIC_;
158 if (!TT.isOSDarwin())
159 return Reloc::Static;
160 }
161
162 // If we are on Darwin, disallow static relocation model in X86-64 mode, since
163 // the Mach-O file format doesn't support it.
164 if (*RM == Reloc::Static && TT.isOSDarwin() && is64Bit)
165 return Reloc::PIC_;
166
167 return *RM;
168}
169
170static CodeModel::Model
171getEffectiveX86CodeModel(const Triple &TT, std::optional<CodeModel::Model> CM,
172 bool JIT) {
173 bool Is64Bit = TT.isX86_64();
174 if (CM) {
175 if (*CM == CodeModel::Tiny)
176 reportFatalUsageError("target does not support the tiny CodeModel");
177 return *CM;
178 }
179 if (JIT)
180 return Is64Bit ? CodeModel::Large : CodeModel::Small;
181 return CodeModel::Small;
182}
183
184/// Create an X86 target.
185///
187 StringRef CPU, StringRef FS,
188 const TargetOptions &Options,
189 std::optional<Reloc::Model> RM,
190 std::optional<CodeModel::Model> CM,
191 CodeGenOptLevel OL, bool JIT)
192 : CodeGenTargetMachineImpl(T, TT.computeDataLayout(), TT, CPU, FS, Options,
193 getEffectiveRelocModel(TT, JIT, RM),
194 getEffectiveX86CodeModel(TT, CM, JIT), OL),
195 TLOF(createTLOF(getTargetTriple())), IsJIT(JIT) {
196 // On PS4/PS5, the "return address" of a 'noreturn' call must still be within
197 // the calling function. Note that this also includes __stack_chk_fail,
198 // so there was some target-specific logic in the instruction selectors
199 // to handle that. That code has since been generalized, so the only thing
200 // needed is to set TrapUnreachable here.
201 if (TT.isPS() || TT.isOSBinFormatMachO()) {
202 this->Options.TrapUnreachable = true;
203 this->Options.NoTrapAfterNoreturn = TT.isOSBinFormatMachO();
204 }
205
206 setMachineOutliner(true);
207
208 // x86 supports the debug entry values.
210
211 initAsmInfo();
212}
213
215
216const X86Subtarget *
218 Attribute CPUAttr = F.getFnAttribute("target-cpu");
219 Attribute TuneAttr = F.getFnAttribute("tune-cpu");
220 Attribute FSAttr = F.getFnAttribute("target-features");
221
222 StringRef CPU =
223 CPUAttr.isValid() ? CPUAttr.getValueAsString() : (StringRef)TargetCPU;
224 // "x86-64" is a default target setting for many front ends. In these cases,
225 // they actually request for "generic" tuning unless the "tune-cpu" was
226 // specified.
227 StringRef TuneCPU = TuneAttr.isValid() ? TuneAttr.getValueAsString()
228 : CPU == "x86-64" ? "generic"
229 : (StringRef)CPU;
230 StringRef FS =
231 FSAttr.isValid() ? FSAttr.getValueAsString() : (StringRef)TargetFS;
232
234 // The additions here are ordered so that the definitely short strings are
235 // added first so we won't exceed the small size. We append the
236 // much longer FS string at the end so that we only heap allocate at most
237 // one time.
238
239 // Extract prefer-vector-width attribute.
240 unsigned PreferVectorWidthOverride = 0;
241 Attribute PreferVecWidthAttr = F.getFnAttribute("prefer-vector-width");
242 if (PreferVecWidthAttr.isValid()) {
243 StringRef Val = PreferVecWidthAttr.getValueAsString();
244 unsigned Width;
245 if (!Val.getAsInteger(0, Width)) {
246 Key += 'p';
247 Key += Val;
248 PreferVectorWidthOverride = Width;
249 }
250 }
251
252 // Extract min-legal-vector-width attribute.
253 unsigned RequiredVectorWidth = UINT32_MAX;
254 Attribute MinLegalVecWidthAttr = F.getFnAttribute("min-legal-vector-width");
255 if (MinLegalVecWidthAttr.isValid()) {
256 StringRef Val = MinLegalVecWidthAttr.getValueAsString();
257 unsigned Width;
258 if (!Val.getAsInteger(0, Width)) {
259 Key += 'm';
260 Key += Val;
261 RequiredVectorWidth = Width;
262 }
263 }
264
265 // Add CPU to the Key.
266 Key += CPU;
267
268 // Add tune CPU to the Key.
269 Key += TuneCPU;
270
271 // Keep track of the start of the feature portion of the string.
272 unsigned FSStart = Key.size();
273
274 // FIXME: This is related to the code below to reset the target options,
275 // we need to know whether or not the soft float flag is set on the
276 // function before we can generate a subtarget. We also need to use
277 // it as a key for the subtarget since that can be the only difference
278 // between two functions.
279 bool SoftFloat = F.getFnAttribute("use-soft-float").getValueAsBool();
280 // If the soft float attribute is set on the function turn on the soft float
281 // subtarget feature.
282 if (SoftFloat)
283 Key += FS.empty() ? "+soft-float" : "+soft-float,";
284
285 Key += FS;
286
287 // We may have added +soft-float to the features so move the StringRef to
288 // point to the full string in the Key.
289 FS = Key.substr(FSStart);
290
291 auto &I = SubtargetMap[Key];
292 if (!I) {
293 // This needs to be done before we create a new subtarget since any
294 // creation will depend on the TM and the code generation flags on the
295 // function that reside in TargetOptions.
297 I = std::make_unique<X86Subtarget>(
298 TargetTriple, CPU, TuneCPU, FS, *this,
299 MaybeAlign(F.getParent()->getOverrideStackAlignment()),
300 PreferVectorWidthOverride, RequiredVectorWidth);
301 }
302 return I.get();
303}
304
308
311 const auto *MFI = MF.getInfo<X86MachineFunctionInfo>();
312 return new yaml::X86MachineFunctionInfo(*MFI);
313}
314
317 SMDiagnostic &Error, SMRange &SourceRange) const {
318 const auto &YamlMFI = static_cast<const yaml::X86MachineFunctionInfo &>(MFI);
319 PFS.MF.getInfo<X86MachineFunctionInfo>()->initializeBaseYamlFields(YamlMFI);
320 return false;
321}
322
324 unsigned DestAS) const {
325 assert(SrcAS != DestAS && "Expected different address spaces!");
326 if (getPointerSize(SrcAS) != getPointerSize(DestAS))
327 return false;
328 return SrcAS < 256 && DestAS < 256;
329}
330
331void X86TargetMachine::reset() { SubtargetMap.clear(); }
332
339
346
347//===----------------------------------------------------------------------===//
348// X86 TTI query.
349//===----------------------------------------------------------------------===//
350
353 return TargetTransformInfo(std::make_unique<X86TTIImpl>(this, F));
354}
355
356//===----------------------------------------------------------------------===//
357// Pass Pipeline Configuration
358//===----------------------------------------------------------------------===//
359
360namespace {
361
362/// X86 Code Generator Pass Configuration Options.
363class X86PassConfig : public TargetPassConfig {
364public:
365 X86PassConfig(X86TargetMachine &TM, PassManagerBase &PM)
366 : TargetPassConfig(TM, PM) {}
367
368 X86TargetMachine &getX86TargetMachine() const {
370 }
371
372 void addIRPasses() override;
373 bool addInstSelector() override;
374 bool addIRTranslator() override;
375 bool addLegalizeMachineIR() override;
376 bool addRegBankSelect() override;
377 bool addGlobalInstructionSelect() override;
378 void addPreLegalizeMachineIR() override;
379 bool addILPOpts() override;
380 bool addPreISel() override;
381 void addMachineSSAOptimization() override;
382 void addPreRegAlloc() override;
383 bool addPostFastRegAllocRewrite() override;
384 void addPostRegAlloc() override;
385 void addPreEmitPass() override;
386 void addPreEmitPass2() override;
387 void addPreSched2() override;
388 bool addRegAssignAndRewriteOptimized() override;
389
390 std::unique_ptr<CSEConfigBase> getCSEConfig() const override;
391};
392
393class X86ExecutionDomainFix : public ExecutionDomainFix {
394public:
395 static char ID;
396 X86ExecutionDomainFix() : ExecutionDomainFix(ID, X86::VR128XRegClass) {}
397 StringRef getPassName() const override {
398 return "X86 Execution Dependency Fix";
399 }
400};
401char X86ExecutionDomainFix::ID;
402
403} // end anonymous namespace
404
405INITIALIZE_PASS_BEGIN(X86ExecutionDomainFix, "x86-execution-domain-fix",
406 "X86 Execution Domain Fix", false, false)
408INITIALIZE_PASS_END(X86ExecutionDomainFix, "x86-execution-domain-fix",
409 "X86 Execution Domain Fix", false, false)
410
412 return new X86PassConfig(*this, PM);
413}
414
421
422void X86PassConfig::addIRPasses() {
424
425 // We add both pass anyway and when these two passes run, we skip the pass
426 // based on the option level and option attribute.
429
431
432 if (TM->getOptLevel() != CodeGenOptLevel::None) {
435 }
436
437 // Add passes that handle indirect branch removal and insertion of a retpoline
438 // thunk. These will be a no-op unless a function subtarget has the retpoline
439 // feature enabled.
441
442 // Add Control Flow Guard checks.
443 const Triple &TT = TM->getTargetTriple();
444 if (TT.isOSWindows()) {
445 if (TT.isX86_64()) {
446 addPass(createCFGuardDispatchPass());
447 } else {
448 addPass(createCFGuardCheckPass());
449 }
450 }
451
452 if (TM->Options.JMCInstrument)
453 addPass(createJMCInstrumenterPass());
454}
455
456bool X86PassConfig::addInstSelector() {
457 // Install an instruction selector.
458 addPass(createX86ISelDag(getX86TargetMachine(), getOptLevel()));
459
460 // For ELF, cleanup any local-dynamic TLS accesses.
461 if (TM->getTargetTriple().isOSBinFormatELF() &&
462 getOptLevel() != CodeGenOptLevel::None)
464
467 return false;
468}
469
470bool X86PassConfig::addIRTranslator() {
471 addPass(new IRTranslator(getOptLevel()));
472 return false;
473}
474
475bool X86PassConfig::addLegalizeMachineIR() {
476 addPass(new Legalizer());
477 return false;
478}
479
480bool X86PassConfig::addRegBankSelect() {
481 addPass(new RegBankSelect());
482 return false;
483}
484
485bool X86PassConfig::addGlobalInstructionSelect() {
486 addPass(new InstructionSelect(getOptLevel()));
487 // Add GlobalBaseReg in case there is no SelectionDAG passes afterwards
488 if (isGlobalISelAbortEnabled())
490 return false;
491}
492
493void X86PassConfig::addPreLegalizeMachineIR() {
494 if (getOptLevel() != CodeGenOptLevel::None) {
496 }
497}
498
499bool X86PassConfig::addILPOpts() {
500 addPass(&EarlyIfConverterLegacyID);
502 addPass(&MachineCombinerID);
504 return true;
505}
506
507bool X86PassConfig::addPreISel() {
508 // Only add this pass for 32-bit x86 Windows.
509 const Triple &TT = TM->getTargetTriple();
510 if (TT.isOSWindows() && TT.isX86_32())
511 addPass(createX86WinEHStatePass());
512 return true;
513}
514
515void X86PassConfig::addPreRegAlloc() {
516 if (getOptLevel() != CodeGenOptLevel::None) {
517 addPass(&LiveRangeShrinkID);
522 }
523
525
529
530 if (getOptLevel() != CodeGenOptLevel::None)
532 else
534}
535
536void X86PassConfig::addMachineSSAOptimization() {
539}
540
541void X86PassConfig::addPostRegAlloc() {
544 // When -O0 is enabled, the Load Value Injection Hardening pass will fall back
545 // to using the Speculative Execution Side Effect Suppression pass for
546 // mitigation. This is to prevent slow downs due to
547 // analyses needed by the LVIHardening pass when compiling at -O0.
548 if (getOptLevel() != CodeGenOptLevel::None)
550}
551
552void X86PassConfig::addPreSched2() {
554 addPass(createKCFIPass());
555}
556
557void X86PassConfig::addPreEmitPass() {
558 if (getOptLevel() != CodeGenOptLevel::None) {
559 addPass(new X86ExecutionDomainFix());
560 addPass(createBreakFalseDeps());
561 }
562
564
566
567 if (getOptLevel() != CodeGenOptLevel::None) {
573 }
576}
577
578void X86PassConfig::addPreEmitPass2() {
579 const Triple &TT = TM->getTargetTriple();
580 const MCAsmInfo *MAI = TM->getMCAsmInfo();
581
582 // The X86 Speculative Execution Pass must run after all control
583 // flow graph modifying passes. As a result it was listed to run right before
584 // the X86 Retpoline Thunks pass. The reason it must run after control flow
585 // graph modifications is that the model of LFENCE in LLVM has to be updated
586 // (FIXME: https://bugs.llvm.org/show_bug.cgi?id=45167). Currently the
587 // placement of this pass was hand checked to ensure that the subsequent
588 // passes don't move the code around the LFENCEs in a way that will hurt the
589 // correctness of this pass. This placement has been shown to work based on
590 // hand inspection of the codegen output.
594
595 // Insert extra int3 instructions after trailing call instructions to avoid
596 // issues in the unwinder.
597 if (TT.isOSWindows() && TT.isX86_64())
599
600 // Verify basic block incoming and outgoing cfa offset and register values and
601 // correct CFA calculation rule where needed by inserting appropriate CFI
602 // instructions.
603 if (!TT.isOSDarwin() &&
604 (!TT.isOSWindows() ||
606 addPass(createCFIInstrInserter());
607
608 if (TT.isOSWindows()) {
609 // Identify valid longjmp targets for Windows Control Flow Guard.
610 addPass(createCFGuardLongjmpPass());
611 // Identify valid eh continuation targets for Windows EHCont Guard.
613 }
615
616 // Insert pseudo probe annotation for callsite profiling
617 addPass(createPseudoProbeInserter());
618
619 // KCFI indirect call checks are lowered to a bundle, and on Darwin platforms,
620 // also CALL_RVMARKER.
621 addPass(createUnpackMachineBundles([&TT](const MachineFunction &MF) {
622 // Only run bundle expansion if the module uses kcfi, or there are relevant
623 // ObjC runtime functions present in the module.
624 const Function &F = MF.getFunction();
625 const Module *M = F.getParent();
626 return M->getModuleFlag("kcfi") ||
627 (TT.isOSDarwin() &&
628 (M->getFunction("objc_retainAutoreleasedReturnValue") ||
629 M->getFunction("objc_unsafeClaimAutoreleasedReturnValue")));
630 }));
631
632 // Analyzes and emits pseudos to support Win x64 Unwind V2. This pass must run
633 // after all real instructions have been added to the epilog.
634 if (TT.isOSWindows() && TT.isX86_64())
636}
637
638bool X86PassConfig::addPostFastRegAllocRewrite() {
640 return true;
641}
642
643std::unique_ptr<CSEConfigBase> X86PassConfig::getCSEConfig() const {
644 return getStandardCSEConfigForOpt(TM->getOptLevel());
645}
646
649 const Register Reg) {
650 const TargetRegisterClass *RC = MRI.getRegClass(Reg);
651 return static_cast<const X86RegisterInfo &>(TRI).isTileRegisterClass(RC);
652}
653
654bool X86PassConfig::addRegAssignAndRewriteOptimized() {
655 // Don't support tile RA when RA is specified by command line "-regalloc".
656 if (!isCustomizedRegAlloc() && EnableTileRAPass) {
657 // Allocate tile register first.
660 }
662}
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static std::unique_ptr< TargetLoweringObjectFile > createTLOF(const Triple &TT)
static Reloc::Model getEffectiveRelocModel()
This file contains the simple types necessary to represent the attributes associated with functions a...
Provides analysis for continuously CSEing during GISel passes.
This file describes how to lower LLVM calls to machine code calls.
DXIL Legalizer
This file declares the IRTranslator pass.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
Register Reg
Register const TargetRegisterInfo * TRI
#define T
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition PassSupport.h:42
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition PassSupport.h:44
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition PassSupport.h:39
This file describes the interface of the MachineFunctionPass responsible for assigning the generic vi...
const GCNTargetMachine & getTM(const GCNSubtarget *STI)
This file defines the SmallString class.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
Target-Independent Code Generator Pass Configuration Options pass.
This pass exposes codegen information to IR-level passes.
static std::unique_ptr< TargetLoweringObjectFile > createTLOF()
#define LLVM_C_ABI
LLVM_C_ABI is the export/visibility macro used to mark symbols declared in llvm-c as exported when bu...
Definition Visibility.h:40
cl::opt< bool > X86EnableMachineCombinerPass
static bool is64Bit(const char *name)
static cl::opt< bool > EnableTileRAPass("x86-tile-ra", cl::desc("Enable the tile register allocation pass"), cl::init(true), cl::Hidden)
static CodeModel::Model getEffectiveX86CodeModel(const Triple &TT, std::optional< CodeModel::Model > CM, bool JIT)
static bool onlyAllocateTileRegisters(const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI, const Register Reg)
LLVM_C_ABI void LLVMInitializeX86Target()
cl::opt< bool > X86EnableMachineCombinerPass("x86-machine-combiner", cl::desc("Enable the machine combiner pass"), cl::init(true), cl::Hidden)
This file a TargetTransformInfoImplBase conforming object specific to the X86 target machine.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
Definition Attributes.h:69
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
bool isValid() const
Return true if the attribute is any kind of attribute.
Definition Attributes.h:223
CodeGenTargetMachineImpl(const Target &T, StringRef DataLayoutString, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOptLevel OL)
virtual void reset()
Reset internal state.
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
This pass is responsible for selecting generic machine instructions to target-specific instructions.
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:64
ExceptionHandling getExceptionHandlingType() const
Definition MCAsmInfo.h:633
Function & getFunction()
Return the LLVM function that this machine code represents.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This pass implements the reg bank selector pass used in the GlobalISel pipeline.
Wrapper class representing virtual and physical registers.
Definition Register.h:20
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition SourceMgr.h:297
Represents a range in source code.
Definition SMLoc.h:47
A ScheduleDAG for scheduling lists of MachineInstr.
ScheduleDAGMILive is an implementation of ScheduleDAGInstrs that schedules machine instructions while...
ScheduleDAGMI is an implementation of ScheduleDAGInstrs that simply schedules machine instructions ac...
void addMutation(std::unique_ptr< ScheduleDAGMutation > Mutation)
Add a postprocessing step to the DAG builder.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:26
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
Definition StringRef.h:472
void setSupportsDebugEntryValues(bool Enable)
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with.
const Triple & getTargetTriple() const
void setMachineOutliner(bool Enable)
unsigned getPointerSize(unsigned AS) const
Get the pointer size for this target.
std::unique_ptr< const MCSubtargetInfo > STI
TargetOptions Options
void resetTargetOptions(const Function &F) const
Reset the target options based on the function's attributes.
Target-Independent Code Generator Pass Configuration Options.
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
virtual void addMachineSSAOptimization()
addMachineSSAOptimization - Add standard passes that optimize machine instructions in SSA form.
virtual bool addRegAssignAndRewriteOptimized()
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
TargetSubtargetInfo - Generic base class for all target subtargets.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
X86MachineFunctionInfo - This class is derived from MachineFunction and contains private X86 target-s...
bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override
Returns true if a cast between SrcAS and DestAS is a noop.
MachineFunctionInfo * createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, const TargetSubtargetInfo *STI) const override
Create the target's instance of MachineFunctionInfo.
yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const override
Allocate and initialize an instance of the YAML representation of the MachineFunctionInfo.
const X86Subtarget * getSubtargetImpl() const =delete
ScheduleDAGInstrs * createMachineScheduler(MachineSchedContext *C) const override
Create an instance of ScheduleDAGInstrs to be run within the standard MachineScheduler pass for this ...
ScheduleDAGInstrs * createPostMachineScheduler(MachineSchedContext *C) const override
Similar to createMachineScheduler but used when postRA machine scheduling is enabled.
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange) const override
Parse out the target's MachineFunctionInfo from the YAML reprsentation.
~X86TargetMachine() override
TargetTransformInfo getTargetTransformInfo(const Function &F) const override
Get a TargetTransformInfo implementation for the target.
yaml::MachineFunctionInfo * createDefaultFuncInfoYAML() const override
Allocate and return a default initialized instance of the YAML representation for the MachineFunction...
X86TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM, CodeGenOptLevel OL, bool JIT)
Create an X86 target.
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
@ DynamicNoPIC
Definition CodeGen.h:25
@ X86
Windows x64, Windows Itanium (IA-64)
Definition MCAsmInfo.h:50
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
ScheduleDAGMILive * createSchedLive(MachineSchedContext *C)
Create the standard converging machine scheduler.
LLVM_ABI FunctionPass * createIndirectBrExpandPass()
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.
LLVM_ABI ModulePass * createJMCInstrumenterPass()
JMC instrument pass.
FunctionPass * createX86OptimizeLEAsLegacyPass()
void initializeCompressEVEXLegacyPass(PassRegistry &)
FunctionPass * createX86LoadValueInjectionLoadHardeningPass()
FunctionPass * createX86IssueVZeroUpperPass()
This pass inserts AVX vzeroupper instructions before each call to avoid transition penalty between fu...
LLVM_ABI FunctionPass * createGreedyRegisterAllocator()
Greedy register allocation pass - This pass implements a global register allocator for optimized buil...
FunctionPass * createX86DynAllocaExpanderLegacyPass()
void initializeWinEHStatePassPass(PassRegistry &)
void initializeX86DomainReassignmentLegacyPass(PassRegistry &)
@ DwarfCFI
DWARF-like instruction based exceptions.
Definition CodeGen.h:55
FunctionPass * createX86TileConfigLegacyPass()
LLVM_ABI FunctionPass * createPseudoProbeInserter()
This pass inserts pseudo probe annotation for callsite profiling.
Target & getTheX86_32Target()
FunctionPass * createX86GlobalBaseRegPass()
This pass initializes a global base register for PIC on x86-32.
FunctionPass * createX86AvoidStoreForwardingBlocksLegacyPass()
void initializeX86LowerAMXIntrinsicsLegacyPassPass(PassRegistry &)
FunctionPass * createX86PartialReductionLegacyPass()
void initializeX86CmovConversionLegacyPass(PassRegistry &)
FunctionPass * createCleanupLocalDynamicTLSPass()
This pass combines multiple accesses to local-dynamic TLS variables so that the TLS base address for ...
void initializeX86DynAllocaExpanderLegacyPass(PassRegistry &)
FunctionPass * createX86FixupSetCCLegacyPass()
LLVM_ABI FunctionPass * createCFGuardDispatchPass()
Insert Control FLow Guard dispatches on indirect function calls.
Definition CFGuard.cpp:310
LLVM_ABI std::unique_ptr< CSEConfigBase > getStandardCSEConfigForOpt(CodeGenOptLevel Level)
Definition CSEInfo.cpp:89
void initializeX86FastPreTileConfigLegacyPass(PassRegistry &)
FunctionPass * createX86SpeculativeExecutionSideEffectSuppressionLegacyPass()
LLVM_ABI char & EarlyIfConverterLegacyID
EarlyIfConverter - This pass performs if-conversion on SSA form by inserting cmov instructions.
FunctionPass * createX86PadShortFunctions()
Return a pass that pads short functions with NOOPs.
void initializeX86LoadValueInjectionLoadHardeningPassPass(PassRegistry &)
std::unique_ptr< ScheduleDAGMutation > createX86MacroFusionDAGMutation()
Note that you have to add: DAG.addMutation(createX86MacroFusionDAGMutation()); to X86TargetMachine::c...
LLVM_ABI char & MachineCombinerID
This pass performs instruction combining using trace metrics to estimate critical-path and resource d...
void initializeX86PreLegalizerCombinerPass(PassRegistry &)
static Reloc::Model getEffectiveRelocModel(std::optional< Reloc::Model > RM)
void initializeX86FastTileConfigLegacyPass(PassRegistry &)
void initializeX86FixupVectorConstantsLegacyPass(PassRegistry &)
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 &)
ScheduleDAGMI * createSchedPostRA(MachineSchedContext *C)
Create a generic scheduler with no vreg liveness or DAG mutation passes.
FunctionPass * createX86CmovConversionLegacyPass()
FunctionPass * createX86ArgumentStackSlotLegacyPass()
LLVM_ABI FunctionPass * createKCFIPass()
Lowers KCFI operand bundles for indirect calls.
Definition KCFI.cpp:61
void initializeX86SpeculativeExecutionSideEffectSuppressionLegacyPass(PassRegistry &)
void initializeX86FixupInstTuningLegacyPass(PassRegistry &)
LLVM_ABI char & LiveRangeShrinkID
LiveRangeShrink pass.
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.
LLVM_ABI void initializePseudoProbeInserterPass(PassRegistry &)
FunctionPass * createX86FixupLEAsLegacyPass()
FunctionPass * createX86CallFrameOptimizationLegacyPass()
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:82
void initializeX86CallFrameOptimizationLegacyPass(PassRegistry &)
LLVM_ABI FunctionPass * createCFGuardLongjmpPass()
Creates CFGuard longjmp target identification pass.
FunctionPass * createX86FlagsCopyLoweringLegacyPass()
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
void initializeX86FixupBWInstLegacyPass(PassRegistry &)
void initializeX86LoadValueInjectionRetHardeningLegacyPass(PassRegistry &)
void initializeX86FPStackifierLegacyPass(PassRegistry &)
void initializeX86LowerTileCopyLegacyPass(PassRegistry &)
LLVM_ABI FunctionPass * createInterleavedAccessPass()
InterleavedAccess Pass - This pass identifies and matches interleaved memory accesses to target speci...
void initializeX86SpeculativeLoadHardeningLegacyPass(PassRegistry &)
void initializeX86TileConfigLegacyPass(PassRegistry &)
LLVM_ABI void initializeGlobalISel(PassRegistry &)
Initialize all passes linked into the GlobalISel library.
void initializeFixupLEAsLegacyPass(PassRegistry &)
LLVM_ABI void initializeKCFIPass(PassRegistry &)
FunctionPass * createX86PreTileConfigLegacyPass()
FunctionPass * createX86SpeculativeLoadHardeningLegacyPass()
void initializeX86LowerAMXTypeLegacyPassPass(PassRegistry &)
FunctionPass * createX86ReturnThunksLegacyPass()
void initializeX86ArgumentStackSlotLegacyPass(PassRegistry &)
LLVM_ABI FunctionPass * createBreakFalseDeps()
Creates Break False Dependencies pass.
FunctionPass * createX86FixupBWInstsLegacyPass()
FunctionPass * createX86FPStackifierLegacyPass()
void initializeX86PreTileConfigLegacyPass(PassRegistry &)
FunctionPass * createX86SuppressAPXForRelocationLegacyPass()
FunctionPass * createX86FastPreTileConfigLegacyPass()
LLVM_ABI FunctionPass * createUnpackMachineBundles(std::function< bool(const MachineFunction &)> Ftor)
FunctionPass * createX86LoadValueInjectionRetHardeningLegacyPass()
FunctionPass * createX86WinEHUnwindV2Pass()
// Analyzes and emits pseudos to support Win x64 Unwind V2.
FunctionPass * createX86LowerAMXTypeLegacyPass()
FunctionPass * createX86PreLegalizerCombiner()
LLVM_ABI FunctionPass * createCFGuardCheckPass()
Insert Control FLow Guard checks on indirect function calls.
Definition CFGuard.cpp:306
LLVM_ABI FunctionPass * createEHContGuardTargetsPass()
Creates Windows EH Continuation Guard target identification pass.
void initializeX86ReturnThunksLegacyPass(PassRegistry &)
void initializeX86SuppressAPXForRelocationLegacyPass(PassRegistry &)
FunctionPass * createX86FixupVectorConstantsLegacyPass()
void initializeX86FixupSetCCLegacyPass(PassRegistry &)
FunctionPass * createX86IndirectThunksPass()
This pass creates the thunks for the retpoline feature.
LLVM_ABI FunctionPass * createAtomicExpandLegacyPass()
AtomicExpandPass - At IR level this pass replace atomic instructions with __atomic_* library calls,...
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:383
Target & getTheX86_64Target()
FunctionPass * createX86FixupInstTuningLegacyPass()
LLVM_ABI FunctionPass * createCFIInstrInserter()
Creates CFI Instruction Inserter pass.
void initializeX86ExecutionDomainFixPass(PassRegistry &)
void initializeX86DAGToDAGISelLegacyPass(PassRegistry &)
void initializeX86OptimizeLEAsLegacyPass(PassRegistry &)
void initializeX86AvoidSFBLegacyPass(PassRegistry &)
FunctionPass * createX86AvoidTrailingCallLegacyPass()
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
Definition Error.cpp:177
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
static FuncInfoTy * create(BumpPtrAllocator &Allocator, const Function &F, const SubtargetTy *STI)
Factory function: default behavior is to call new using the supplied allocator.
MachineSchedContext provides enough context from the MachineScheduler pass for the target to instanti...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition Alignment.h:106
RegisterTargetMachine - Helper template for registering a target machine implementation,...
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.