LLVM 24.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"
44#include "llvm/Pass.h"
51#include <memory>
52#include <optional>
53
54using namespace llvm;
55
57 // Register the target.
61
105}
106
107static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
108 if (TT.isOSBinFormatMachO()) {
109 if (TT.isX86_64())
110 return std::make_unique<X86_64MachoTargetObjectFile>();
111 return std::make_unique<TargetLoweringObjectFileMachO>();
112 }
113
114 if (TT.isOSBinFormatCOFF())
115 return std::make_unique<TargetLoweringObjectFileCOFF>();
116
117 if (TT.isX86_64())
118 return std::make_unique<X86_64ELFTargetObjectFile>();
119 return std::make_unique<X86ELFTargetObjectFile>();
120}
121
122static Reloc::Model getEffectiveRelocModel(const Triple &TT, bool JIT,
123 std::optional<Reloc::Model> RM) {
124 bool is64Bit = TT.isX86_64();
125 if (!RM) {
126 // JIT codegen should use static relocations by default, since it's
127 // typically executed in process and not relocatable.
128 if (JIT)
129 return Reloc::Static;
130
131 // Darwin defaults to PIC in 64 bit mode and dynamic-no-pic in 32 bit mode.
132 // Win64 requires rip-rel addressing, thus we force it to PIC. Otherwise we
133 // use static relocation model by default.
134 if (TT.isOSDarwin()) {
135 if (is64Bit)
136 return Reloc::PIC_;
137 return Reloc::DynamicNoPIC;
138 }
139 if (TT.isOSWindows() && is64Bit)
140 return Reloc::PIC_;
141 return Reloc::Static;
142 }
143
144 // ELF and X86-64 don't have a distinct DynamicNoPIC model. DynamicNoPIC
145 // is defined as a model for code which may be used in static or dynamic
146 // executables but not necessarily a shared library. On X86-32 we just
147 // compile in -static mode, in x86-64 we use PIC.
148 if (*RM == Reloc::DynamicNoPIC) {
149 if (is64Bit)
150 return Reloc::PIC_;
151 if (!TT.isOSDarwin())
152 return Reloc::Static;
153 }
154
155 // If we are on Darwin, disallow static relocation model in X86-64 mode, since
156 // the Mach-O file format doesn't support it.
157 if (*RM == Reloc::Static && TT.isOSDarwin() && is64Bit)
158 return Reloc::PIC_;
159
160 return *RM;
161}
162
163static CodeModel::Model
164getEffectiveX86CodeModel(const Triple &TT, std::optional<CodeModel::Model> CM,
165 bool JIT) {
166 bool Is64Bit = TT.isX86_64();
167 if (CM) {
168 if (*CM == CodeModel::Tiny)
169 reportFatalUsageError("target does not support the tiny CodeModel");
170 return *CM;
171 }
172 if (JIT)
173 return Is64Bit ? CodeModel::Large : CodeModel::Small;
174 return CodeModel::Small;
175}
176
177/// Create an X86 target.
178///
180 StringRef CPU, StringRef FS,
181 const TargetOptions &Options,
182 std::optional<Reloc::Model> RM,
183 std::optional<CodeModel::Model> CM,
184 CodeGenOptLevel OL, bool JIT)
185 : CodeGenTargetMachineImpl(T, TT, CPU, FS, Options,
186 getEffectiveRelocModel(TT, JIT, RM),
187 getEffectiveX86CodeModel(TT, CM, JIT), OL),
188 CLOpts(cl::LibraryOptionsContext::get<X86Options>(
189 Options.MCOptions.LibraryOptions)),
190 TLOF(createTLOF(getTargetTriple())), IsJIT(JIT) {
191 // On PS4/PS5, the "return address" of a 'noreturn' call must still be within
192 // the calling function. Note that this also includes __stack_chk_fail,
193 // so there was some target-specific logic in the instruction selectors
194 // to handle that. That code has since been generalized, so the only thing
195 // needed is to set TrapUnreachable here.
196 if (TT.isPS() || TT.isOSBinFormatMachO()) {
197 this->Options.TrapUnreachable = true;
198 this->Options.NoTrapAfterNoreturn = TT.isOSBinFormatMachO();
199 }
200
201 setMachineOutliner(true);
202
203 // x86 supports the debug entry values.
205
206 initAsmInfo();
207}
208
210
211const X86Subtarget *
213 Attribute CPUAttr = F.getFnAttribute("target-cpu");
214 Attribute TuneAttr = F.getFnAttribute("tune-cpu");
215 Attribute FSAttr = F.getFnAttribute("target-features");
216
217 StringRef CPU =
218 CPUAttr.isValid() ? CPUAttr.getValueAsString() : (StringRef)TargetCPU;
219 // "x86-64" is a default target setting for many front ends. In these cases,
220 // they actually request for "generic" tuning unless the "tune-cpu" was
221 // specified.
222 StringRef TuneCPU = TuneAttr.isValid() ? TuneAttr.getValueAsString()
223 : CPU == "x86-64" ? "generic"
224 : (StringRef)CPU;
225 StringRef FS =
226 FSAttr.isValid() ? FSAttr.getValueAsString() : (StringRef)TargetFS;
227
229 // The additions here are ordered so that the definitely short strings are
230 // added first so we won't exceed the small size. We append the
231 // much longer FS string at the end so that we only heap allocate at most
232 // one time.
233
234 // Extract prefer-vector-width attribute.
235 unsigned PreferVectorWidthOverride = 0;
236 Attribute PreferVecWidthAttr = F.getFnAttribute("prefer-vector-width");
237 if (PreferVecWidthAttr.isValid()) {
238 StringRef Val = PreferVecWidthAttr.getValueAsString();
239 unsigned Width;
240 if (!Val.getAsInteger(0, Width)) {
241 Key += 'p';
242 Key += Val;
243 PreferVectorWidthOverride = Width;
244 }
245 }
246
247 // Extract min-legal-vector-width attribute.
248 unsigned RequiredVectorWidth = UINT32_MAX;
249 Attribute MinLegalVecWidthAttr = F.getFnAttribute("min-legal-vector-width");
250 if (MinLegalVecWidthAttr.isValid()) {
251 StringRef Val = MinLegalVecWidthAttr.getValueAsString();
252 unsigned Width;
253 if (!Val.getAsInteger(0, Width)) {
254 Key += 'm';
255 Key += Val;
256 RequiredVectorWidth = Width;
257 }
258 }
259
260 // Add CPU to the Key.
261 Key += CPU;
262
263 // Add tune CPU to the Key.
264 Key += TuneCPU;
265
266 // Keep track of the start of the feature portion of the string.
267 unsigned FSStart = Key.size();
268
269 // FIXME: This is related to the code below to reset the target options,
270 // we need to know whether or not the soft float flag is set on the
271 // function before we can generate a subtarget. We also need to use
272 // it as a key for the subtarget since that can be the only difference
273 // between two functions.
274 bool SoftFloat = F.getFnAttribute("use-soft-float").getValueAsBool();
275 // If the soft float attribute is set on the function turn on the soft float
276 // subtarget feature.
277 if (SoftFloat)
278 Key += FS.empty() ? "+soft-float" : "+soft-float,";
279
280 Key += FS;
281
282 // We may have added +soft-float to the features so move the StringRef to
283 // point to the full string in the Key.
284 FS = Key.substr(FSStart);
285
286 auto &I = SubtargetMap[Key];
287 if (!I) {
288 I = std::make_unique<X86Subtarget>(
289 TargetTriple, CPU, TuneCPU, FS, *this,
290 MaybeAlign(F.getParent()->getOverrideStackAlignment()),
291 PreferVectorWidthOverride, RequiredVectorWidth);
292 }
293 return I.get();
294}
295
299
302 const auto *MFI = MF.getInfo<X86MachineFunctionInfo>();
303 return new yaml::X86MachineFunctionInfo(*MFI);
304}
305
308 SMDiagnostic &Error, SMRange &SourceRange) const {
309 const auto &YamlMFI = static_cast<const yaml::X86MachineFunctionInfo &>(MFI);
310 PFS.MF.getInfo<X86MachineFunctionInfo>()->initializeBaseYamlFields(YamlMFI);
311 return false;
312}
313
315 unsigned DestAS) const {
316 assert(SrcAS != DestAS && "Expected different address spaces!");
317 if (DL.getPointerSize(SrcAS) != DL.getPointerSize(DestAS))
318 return false;
319 return SrcAS < 256 && DestAS < 256;
320}
321
322void X86TargetMachine::reset() { SubtargetMap.clear(); }
323
330
337
338//===----------------------------------------------------------------------===//
339// X86 TTI query.
340//===----------------------------------------------------------------------===//
341
344 return TargetTransformInfo(std::make_unique<X86TTIImpl>(this, F));
345}
346
347//===----------------------------------------------------------------------===//
348// Pass Pipeline Configuration
349//===----------------------------------------------------------------------===//
350
351namespace {
352
353/// X86 Code Generator Pass Configuration Options.
354class X86PassConfig : public TargetPassConfig {
355public:
356 X86PassConfig(X86TargetMachine &TM, PassManagerBase &PM)
357 : TargetPassConfig(TM, PM) {}
358
359 X86TargetMachine &getX86TargetMachine() const {
361 }
362
363 void addIRPasses() override;
364 bool addInstSelector() override;
365 bool addIRTranslator() override;
366 bool addLegalizeMachineIR() override;
367 void addPreRegBankSelect() override;
368 bool addRegBankSelect() override;
369 bool addGlobalInstructionSelect() override;
370 void addPreLegalizeMachineIR() override;
371 bool addILPOpts() override;
372 bool addPreISel() override;
373 void addMachineSSAOptimization() override;
374 void addPreRegAlloc() override;
375 bool addRegAssignAndRewriteFast() override;
376 void addPostRegAlloc() override;
377 void addPreEmitPass() override;
378 void addPreEmitPass2() override;
379 void addPreSched2() override;
380 bool addRegAssignAndRewriteOptimized() override;
381
382 std::unique_ptr<CSEConfigBase> getCSEConfig() const override;
383};
384
385class X86ExecutionDomainFix : public ExecutionDomainFix {
386public:
387 static char ID;
388 X86ExecutionDomainFix() : ExecutionDomainFix(ID, X86::VR128XRegClass) {}
389 StringRef getPassName() const override {
390 return "X86 Execution Dependency Fix";
391 }
392};
393char X86ExecutionDomainFix::ID;
394
395} // end anonymous namespace
396
397INITIALIZE_PASS_BEGIN(X86ExecutionDomainFix, "x86-execution-domain-fix",
398 "X86 Execution Domain Fix", false, false)
400INITIALIZE_PASS_END(X86ExecutionDomainFix, "x86-execution-domain-fix",
401 "X86 Execution Domain Fix", false, false)
402
404 return new X86PassConfig(*this, PM);
405}
406
413
414void X86PassConfig::addIRPasses() {
416
417 // We add both pass anyway and when these two passes run, we skip the pass
418 // based on the option level and option attribute.
421
423
424 if (TM->getOptLevel() != CodeGenOptLevel::None) {
427 }
428
429 // Add passes that handle indirect branch removal and insertion of a retpoline
430 // thunk. These will be a no-op unless a function subtarget has the retpoline
431 // feature enabled.
432 addPass(createIndirectBrExpandPass(getOptLevel()));
433
434 // Add Control Flow Guard checks.
435 const Triple &TT = TM->getTargetTriple();
436 if (TT.isOSWindows()) {
437 addPass(createCFGuardPass());
438 }
439
440 if (TM->Options.JMCInstrument)
441 addPass(createJMCInstrumenterPass());
442
444}
445
446bool X86PassConfig::addInstSelector() {
447 // Install an instruction selector.
448 addPass(createX86ISelDag(getX86TargetMachine(), getOptLevel()));
449
450 // For ELF, cleanup any local-dynamic TLS accesses.
451 if (TM->getTargetTriple().isOSBinFormatELF() &&
452 getOptLevel() != CodeGenOptLevel::None)
454
457 return false;
458}
459
460bool X86PassConfig::addIRTranslator() {
461 addPass(new IRTranslatorLegacy(getOptLevel()));
462 return false;
463}
464
465void X86PassConfig::addPreRegBankSelect() {
466 bool IsOptNone = getOptLevel() == CodeGenOptLevel::None;
467 if (!IsOptNone) {
469 }
470}
471bool X86PassConfig::addLegalizeMachineIR() {
472 addPass(new LegalizerLegacy());
473 return false;
474}
475
476bool X86PassConfig::addRegBankSelect() {
477 addPass(new RegBankSelectLegacy());
478 return false;
479}
480
481bool X86PassConfig::addGlobalInstructionSelect() {
482 addPass(new InstructionSelectLegacy(getOptLevel()));
483 // Add GlobalBaseReg in case there is no SelectionDAG passes afterwards
484 if (isGlobalISelAbortEnabled())
486 return false;
487}
488
489void X86PassConfig::addPreLegalizeMachineIR() {
490 if (getOptLevel() != CodeGenOptLevel::None) {
492 }
493}
494
495bool X86PassConfig::addILPOpts() {
496 addPass(&EarlyIfConverterLegacyID);
497 if (getX86TargetMachine().getCLOpts().machine_combiner)
498 addPass(&MachineCombinerID);
500 return true;
501}
502
503bool X86PassConfig::addPreISel() {
504 // Only add this pass for 32-bit x86 Windows.
505 const Triple &TT = TM->getTargetTriple();
506 if (TT.isOSWindows() && TT.isX86_32())
508 return true;
509}
510
511void X86PassConfig::addPreRegAlloc() {
512 if (getOptLevel() != CodeGenOptLevel::None) {
513 addPass(&LiveRangeShrinkID);
518 }
519
521
525
526 if (getOptLevel() != CodeGenOptLevel::None)
528 else
530}
531
532bool X86PassConfig::addRegAssignAndRewriteFast() {
535 return ToReturn;
536}
537
538void X86PassConfig::addMachineSSAOptimization() {
541}
542
543void X86PassConfig::addPostRegAlloc() {
546 // When -O0 is enabled, the Load Value Injection Hardening pass will fall back
547 // to using the Speculative Execution Side Effect Suppression pass for
548 // mitigation. This is to prevent slow downs due to
549 // analyses needed by the LVIHardening pass when compiling at -O0.
550 if (getOptLevel() != CodeGenOptLevel::None)
552}
553
554void X86PassConfig::addPreSched2() {
556 addPass(createKCFIPass());
557}
558
559void X86PassConfig::addPreEmitPass() {
560 if (getOptLevel() != CodeGenOptLevel::None) {
561 addPass(new X86ExecutionDomainFix());
563 }
564
566
568
569 if (getOptLevel() != CodeGenOptLevel::None) {
575 }
578
579 if (TM->getTargetTriple().isLFI())
580 addPass(createX86LFIRewritePass());
581}
582
583void X86PassConfig::addPreEmitPass2() {
584 const Triple &TT = TM->getTargetTriple();
585
586 // The X86 Speculative Execution Pass must run after all control
587 // flow graph modifying passes. As a result it was listed to run right before
588 // the X86 Retpoline Thunks pass. The reason it must run after control flow
589 // graph modifications is that the model of LFENCE in LLVM has to be updated
590 // (FIXME: https://bugs.llvm.org/show_bug.cgi?id=45167). Currently the
591 // placement of this pass was hand checked to ensure that the subsequent
592 // passes don't move the code around the LFENCEs in a way that will hurt the
593 // correctness of this pass. This placement has been shown to work based on
594 // hand inspection of the codegen output.
598
599 // Insert extra int3 instructions after trailing call instructions to avoid
600 // issues in the unwinder.
601 if (TT.isOSWindows() && TT.isX86_64())
603
604 // Verify basic block incoming and outgoing cfa offset and register values and
605 // correct CFA calculation rule where needed by inserting appropriate CFI
606 // instructions. CFIInstrInserter self-skips targets that do not use DWARF
607 // CFI.
608 if (!TT.isOSDarwin())
610
611 if (TT.isOSWindows()) {
612 // Identify valid longjmp targets for Windows Control Flow Guard.
614 // Identify valid eh continuation targets for Windows EHCont Guard.
616 }
618
619 // Insert pseudo probe annotation for callsite profiling
621
622 // KCFI indirect call checks are lowered to a bundle, and on Darwin platforms,
623 // also CALL_RVMARKER.
624 addPass(createUnpackMachineBundlesLegacy([&TT](const MachineFunction &MF) {
625 // Only run bundle expansion if the module uses kcfi, or there are relevant
626 // ObjC runtime functions present in the module.
627 const Function &F = MF.getFunction();
628 const Module *M = F.getParent();
629 return M->getModuleFlag("kcfi") ||
630 (TT.isOSDarwin() &&
631 (M->getFunction("objc_retainAutoreleasedReturnValue") ||
632 M->getFunction("objc_unsafeClaimAutoreleasedReturnValue")));
633 }));
634
635 // Analyzes and emits pseudos to support Win x64 Unwind V2. This pass must run
636 // after all real instructions have been added to the epilog.
637 if (TT.isOSWindows() && TT.isX86_64()) {
640 }
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() && getX86TargetMachine().getCLOpts().tile_ra) {
657 // Allocate tile register first.
660 }
662}
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...
#define X(NUM, ENUM, NAME)
Definition ELF.h:665
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
Provides analysis for continuously CSEing during GISel passes.
This file describes how to lower LLVM calls to machine code calls.
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
MachineRegisterInfo & MRI
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")
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
static bool is64Bit(const char *name)
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()
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:106
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:262
CodeGenTargetMachineImpl(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOptLevel OL)
virtual void reset()
Reset internal state.
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
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.
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:68
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:307
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
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
Definition StringRef.h:490
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)
const DataLayout DL
DataLayout for the target: keep ABI type size and alignment.
std::unique_ptr< const MCSubtargetInfo > STI
TargetOptions Options
Target-Independent Code Generator Pass Configuration Options.
virtual bool addRegAssignAndRewriteFast()
Add core register allocator passes which do the actual register assignment and rewriting.
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:48
X86MachineFunctionInfo - This class is derived from MachineFunction and contains private X86 target-s...
bool isNoopAddrSpaceCast(const DataLayout &DL, 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 ...
Registers T::Global with cl::ParseCommandLineOptions.
const AArch64MCOptions & getCLOpts(const MCTargetOptions &Options)
@ DynamicNoPIC
Definition CodeGen.h:26
@ X86
Windows x64, Windows Itanium (IA-64)
Definition MCAsmInfo.h:53
This namespace contains all of the command line option processing machinery.
This is an optimization pass for GlobalISel generic memory operations.
ScheduleDAGMILive * createSchedLive(MachineSchedContext *C)
Create the standard converging machine scheduler.
FunctionPass * createX86WinEHUnwindV3Pass()
Capacity check and sub-fragment splitting for Win x64 Unwind V3.
void initializeX86LoadValueInjectionLoadHardeningLegacyPass(PassRegistry &)
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 &)
LLVM_ABI FunctionPass * createGreedyRegisterAllocator()
Greedy register allocation pass - This pass implements a global register allocator for optimized buil...
void initializeX86PostLegalizerCombinerLegacyPass(PassRegistry &)
FunctionPass * createX86DynAllocaExpanderLegacyPass()
void initializeX86DomainReassignmentLegacyPass(PassRegistry &)
LLVM_ABI FunctionPass * createEHContGuardTargetsLegacy()
Creates Windows EH Continuation Guard target identification pass.
FunctionPass * createX86TileConfigLegacyPass()
Target & getTheX86_32Target()
FunctionPass * createX86AvoidStoreForwardingBlocksLegacyPass()
void initializeX86LowerAMXIntrinsicsLegacyPassPass(PassRegistry &)
FunctionPass * createX86InsertX87WaitLegacyPass()
FunctionPass * createX86PartialReductionLegacyPass()
void initializeX86CmovConversionLegacyPass(PassRegistry &)
void initializeX86DynAllocaExpanderLegacyPass(PassRegistry &)
FunctionPass * createX86FixupSetCCLegacyPass()
FunctionPass * createX86FenceNonTemporalStoresLegacyPass()
LLVM_ABI FunctionPass * createPseudoProbeInserterLegacyPass()
This pass inserts pseudo probe annotation for callsite profiling.
LLVM_ABI FunctionPass * createCFGuardLongjmpLegacyPass()
Creates CFGuard longjmp target identification pass.
LLVM_ABI std::unique_ptr< CSEConfigBase > getStandardCSEConfigForOpt(CodeGenOptLevel Level)
Definition CSEInfo.cpp:85
void initializeX86FastPreTileConfigLegacyPass(PassRegistry &)
FunctionPass * createX86SpeculativeExecutionSideEffectSuppressionLegacyPass()
LLVM_ABI char & EarlyIfConverterLegacyID
EarlyIfConverter - This pass performs if-conversion on SSA form by inserting cmov instructions.
LLVM_ABI FunctionPass * createCFIInstrInserterLegacy()
Creates CFI Instruction Inserter pass.
FunctionPass * createX86LoadValueInjectionLoadHardeningLegacyPass()
LLVM_ABI FunctionPass * createIndirectBrExpandPass(CodeGenOptLevel OptLevel)
std::unique_ptr< ScheduleDAGMutation > createX86MacroFusionDAGMutation()
Note that you have to add: DAG.addMutation(createX86MacroFusionDAGMutation()); to X86TargetMachine::c...
LLVM_ABI void initializeMachineKCFILegacyPass(PassRegistry &)
LLVM_ABI char & MachineCombinerID
This pass performs instruction combining using trace metrics to estimate critical-path and resource d...
LLVM_ABI FunctionPass * createUnpackMachineBundlesLegacy(std::function< bool(const MachineFunction &)> Ftor)
static Reloc::Model getEffectiveRelocModel(std::optional< Reloc::Model > RM)
void initializeX86FastTileConfigLegacyPass(PassRegistry &)
void initializeX86FixupVectorConstantsLegacyPass(PassRegistry &)
FunctionPass * createX86IndirectBranchTrackingLegacyPass()
void initializeX86AsmPrinterPass(PassRegistry &)
FunctionPass * createX86LowerTileCopyLegacyPass()
void initializeX86ExpandPseudoLegacyPass(PassRegistry &)
ScheduleDAGMI * createSchedPostRA(MachineSchedContext *C)
Create a generic scheduler with no vreg liveness or DAG mutation passes.
FunctionPass * createX86CmovConversionLegacyPass()
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
FunctionPass * createX86ArgumentStackSlotLegacyPass()
LLVM_ABI FunctionPass * createKCFIPass()
Lowers KCFI operand bundles for indirect calls.
Definition KCFI.cpp:75
void initializeX86SpeculativeExecutionSideEffectSuppressionLegacyPass(PassRegistry &)
FunctionPass * createX86PadShortFunctionsLegacyPass()
void initializeX86FixupInstTuningLegacyPass(PassRegistry &)
LLVM_ABI char & LiveRangeShrinkID
LiveRangeShrink pass.
void initializeX86FlagsCopyLoweringLegacyPass(PassRegistry &)
FunctionPass * createX86PostLegalizerCombinerLegacy()
void initializeX86AvoidTrailingCallLegacyPassPass(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 * createX86LFIRewritePass()
FunctionPass * createX86CallFrameOptimizationLegacyPass()
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:280
void initializeX86CallFrameOptimizationLegacyPass(PassRegistry &)
FunctionPass * createX86FlagsCopyLoweringLegacyPass()
FunctionPass * createCleanupLocalDynamicTLSLegacyPass()
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 &)
FunctionPass * createX86PreTileConfigLegacyPass()
FunctionPass * createX86InsertVZeroUpperLegacyPass()
FunctionPass * createX86SpeculativeLoadHardeningLegacyPass()
void initializeX86LowerAMXTypeLegacyPassPass(PassRegistry &)
FunctionPass * createX86ReturnThunksLegacyPass()
void initializeX86ArgumentStackSlotLegacyPass(PassRegistry &)
LLVM_ABI FunctionPass * createCFGuardPass()
Insert Control Flow Guard checks on indirect function calls.
Definition CFGuard.cpp:315
FunctionPass * createX86FixupBWInstsLegacyPass()
FunctionPass * createX86PreLegalizerCombinerLegacy()
FunctionPass * createX86FPStackifierLegacyPass()
void initializeX86PreTileConfigLegacyPass(PassRegistry &)
FunctionPass * createX86SuppressAPXForRelocationLegacyPass()
FunctionPass * createX86FastPreTileConfigLegacyPass()
FunctionPass * createX86LoadValueInjectionRetHardeningLegacyPass()
FunctionPass * createX86LowerAMXTypeLegacyPass()
void initializeX86WinEHUnwindV3Pass(PassRegistry &)
void initializeX86ReturnThunksLegacyPass(PassRegistry &)
void initializeX86PreLegalizerCombinerLegacyPass(PassRegistry &)
void initializeX86SuppressAPXForRelocationLegacyPass(PassRegistry &)
FunctionPass * createX86WinEHStateLegacyPass()
void initializeX86FenceNonTemporalStoresLegacyPass(PassRegistry &)
FunctionPass * createX86FixupVectorConstantsLegacyPass()
void initializeX86FixupSetCCLegacyPass(PassRegistry &)
void initializeWinEHStateLegacyPass(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,...
FunctionPass * createX86WinEHUnwindV2LegacyPass()
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:391
Target & getTheX86_64Target()
FunctionPass * createX86FixupInstTuningLegacyPass()
void initializeX86ExecutionDomainFixPass(PassRegistry &)
LLVM_ABI FunctionPass * createBreakFalseDepsLegacyPass()
Creates Break False Dependencies pass.
void initializeX86DAGToDAGISelLegacyPass(PassRegistry &)
void initializeX86OptimizeLEAsLegacyPass(PassRegistry &)
void initializeX86AvoidSFBLegacyPass(PassRegistry &)
void initializeX86WinEHUnwindV2LegacyPass(PassRegistry &)
FunctionPass * createX86AvoidTrailingCallLegacyPass()
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
Definition Error.cpp:177
FunctionPass * createX86GlobalBaseRegLegacyPass()
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:111
RegisterTargetMachine - Helper template for registering a target machine implementation,...
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.