106 if (TT.isOSBinFormatMachO()) {
108 return std::make_unique<X86_64MachoTargetObjectFile>();
109 return std::make_unique<TargetLoweringObjectFileMachO>();
112 if (TT.isOSBinFormatCOFF())
113 return std::make_unique<TargetLoweringObjectFileCOFF>();
116 return std::make_unique<X86_64ELFTargetObjectFile>();
117 return std::make_unique<X86ELFTargetObjectFile>();
121 std::optional<Reloc::Model> RM) {
132 if (TT.isOSDarwin()) {
137 if (TT.isOSWindows() &&
is64Bit)
149 if (!TT.isOSDarwin())
164 bool Is64Bit = TT.isX86_64();
180 std::optional<Reloc::Model>
RM,
181 std::optional<CodeModel::Model> CM,
186 CLOpts(
cl::LibraryOptionsContext::
get<X86Options>(
187 Options.MCOptions.LibraryOptions)),
194 if (TT.isPS() || TT.isOSBinFormatMachO()) {
195 this->Options.TrapUnreachable = true;
196 this->Options.NoTrapAfterNoreturn = TT.isOSBinFormatMachO();
211 Attribute CPUAttr =
F.getFnAttribute(
"target-cpu");
212 Attribute TuneAttr =
F.getFnAttribute(
"tune-cpu");
213 Attribute FSAttr =
F.getFnAttribute(
"target-features");
221 : CPU ==
"x86-64" ?
"generic"
233 unsigned PreferVectorWidthOverride = 0;
234 Attribute PreferVecWidthAttr =
F.getFnAttribute(
"prefer-vector-width");
235 if (PreferVecWidthAttr.
isValid()) {
241 PreferVectorWidthOverride = Width;
246 unsigned RequiredVectorWidth = UINT32_MAX;
247 Attribute MinLegalVecWidthAttr =
F.getFnAttribute(
"min-legal-vector-width");
248 if (MinLegalVecWidthAttr.
isValid()) {
254 RequiredVectorWidth = Width;
265 unsigned FSStart =
Key.size();
272 bool SoftFloat =
F.getFnAttribute(
"use-soft-float").getValueAsBool();
276 Key += FS.empty() ?
"+soft-float" :
"+soft-float,";
282 FS =
Key.substr(FSStart);
284 auto &
I = SubtargetMap[
Key];
286 I = std::make_unique<X86Subtarget>(
288 MaybeAlign(
F.getParent()->getOverrideStackAlignment()),
289 PreferVectorWidthOverride, RequiredVectorWidth);
313 unsigned DestAS)
const {
314 assert(SrcAS != DestAS &&
"Expected different address spaces!");
315 if (
DL.getPointerSize(SrcAS) !=
DL.getPointerSize(DestAS))
317 return SrcAS < 256 && DestAS < 256;
361 void addIRPasses()
override;
362 bool addInstSelector()
override;
363 bool addIRTranslator()
override;
364 bool addLegalizeMachineIR()
override;
365 void addPreRegBankSelect()
override;
366 bool addRegBankSelect()
override;
367 bool addGlobalInstructionSelect()
override;
368 void addPreLegalizeMachineIR()
override;
369 bool addILPOpts()
override;
370 bool addPreISel()
override;
371 void addMachineSSAOptimization()
override;
372 void addPreRegAlloc()
override;
373 bool addRegAssignAndRewriteFast()
override;
374 void addPostRegAlloc()
override;
375 void addPreEmitPass()
override;
376 void addPreEmitPass2()
override;
377 void addPreSched2()
override;
378 bool addRegAssignAndRewriteOptimized()
override;
380 std::unique_ptr<CSEConfigBase> getCSEConfig()
const override;
386 return new X86PassConfig(*
this, PM);
396void X86PassConfig::addIRPasses() {
417 const Triple &TT = TM->getTargetTriple();
418 if (TT.isOSWindows()) {
422 if (TM->Options.JMCInstrument)
428bool X86PassConfig::addInstSelector() {
433 if (TM->getTargetTriple().isOSBinFormatELF() &&
442bool X86PassConfig::addIRTranslator() {
447void X86PassConfig::addPreRegBankSelect() {
453bool X86PassConfig::addLegalizeMachineIR() {
458bool X86PassConfig::addRegBankSelect() {
463bool X86PassConfig::addGlobalInstructionSelect() {
466 if (isGlobalISelAbortEnabled())
471void X86PassConfig::addPreLegalizeMachineIR() {
477bool X86PassConfig::addILPOpts() {
479 if (getX86TargetMachine().
getCLOpts().machine_combiner)
485bool X86PassConfig::addPreISel() {
487 const Triple &
TT = TM->getTargetTriple();
488 if (
TT.isOSWindows() &&
TT.isX86_32())
493void X86PassConfig::addPreRegAlloc() {
514bool X86PassConfig::addRegAssignAndRewriteFast() {
520void X86PassConfig::addMachineSSAOptimization() {
525void X86PassConfig::addPostRegAlloc() {
536void X86PassConfig::addPreSched2() {
541void X86PassConfig::addPreEmitPass() {
561 if (TM->getTargetTriple().isLFI())
565void X86PassConfig::addPreEmitPass2() {
566 const Triple &
TT = TM->getTargetTriple();
583 if (
TT.isOSWindows() &&
TT.isX86_64())
590 if (!
TT.isOSDarwin())
593 if (
TT.isOSWindows()) {
611 return M->getModuleFlag(
"kcfi") ||
613 (
M->getFunction(
"objc_retainAutoreleasedReturnValue") ||
614 M->getFunction(
"objc_unsafeClaimAutoreleasedReturnValue")));
619 if (
TT.isOSWindows() &&
TT.isX86_64()) {
625std::unique_ptr<CSEConfigBase> X86PassConfig::getCSEConfig()
const {
636bool X86PassConfig::addRegAssignAndRewriteOptimized() {
638 if (!isCustomizedRegAlloc() && getX86TargetMachine().
getCLOpts().tile_ra) {
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...
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.
Register const TargetRegisterInfo * TRI
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.
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...
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()
Functions, function parameters, and return types can have attributes to indicate how they should be t...
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.
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.
Lightweight error class with error context and mandatory checking.
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.
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.
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Represents a range in source code.
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...
Represent a constant reference to a string, i.e.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
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
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.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
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.
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
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.
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)
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.
LLVM_ABI FunctionPass * createExecutionDomainFixLegacyPass()
Minimizes execution domain crossings for specific register classes.
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)
void initializeX86FastPreTileConfigLegacyPass(PassRegistry &)
FunctionPass * createX86IndirectThunksLegacyPass()
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.
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.
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.
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 &)
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.
Target & getTheX86_64Target()
FunctionPass * createX86FixupInstTuningLegacyPass()
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
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
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.
RegisterTargetMachine - Helper template for registering a target machine implementation,...
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.