LLVM 24.0.0git
ARMTargetMachine.cpp
Go to the documentation of this file.
1//===-- ARMTargetMachine.cpp - Define TargetMachine for ARM ---------------===//
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//
10//===----------------------------------------------------------------------===//
11
12#include "ARMTargetMachine.h"
13#include "ARM.h"
14#include "ARMLatencyMutations.h"
16#include "ARMMacroFusion.h"
17#include "ARMSubtarget.h"
18#include "ARMTargetObjectFile.h"
22#include "llvm/ADT/StringRef.h"
34#include "llvm/CodeGen/Passes.h"
36#include "llvm/IR/Attributes.h"
37#include "llvm/IR/CallingConv.h"
38#include "llvm/IR/DataLayout.h"
40#include "llvm/IR/Function.h"
42#include "llvm/IR/InstrTypes.h"
43#include "llvm/IR/Module.h"
46#include "llvm/Pass.h"
56#include "llvm/Transforms/IPO.h"
58#include <cassert>
59#include <memory>
60#include <optional>
61#include <string>
62
63using namespace llvm;
64
66 // Register the target.
72
96}
97
98static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
99 if (TT.isOSBinFormatMachO())
100 return std::make_unique<TargetLoweringObjectFileMachO>();
101 if (TT.isOSWindows())
102 return std::make_unique<TargetLoweringObjectFileCOFF>();
103 return std::make_unique<ARMElfTargetObjectFile>();
104}
105
107 std::optional<Reloc::Model> RM) {
108 if (!RM)
109 // Default relocation model on Darwin is PIC.
110 return TT.isOSBinFormatMachO() ? Reloc::PIC_ : Reloc::Static;
111
112 if (*RM == Reloc::ROPI || *RM == Reloc::RWPI || *RM == Reloc::ROPI_RWPI)
113 assert(TT.isOSBinFormatELF() &&
114 "ROPI/RWPI currently only supported for ELF");
115
116 // DynamicNoPIC is only used on darwin.
117 if (*RM == Reloc::DynamicNoPIC && !TT.isOSDarwin())
118 return Reloc::Static;
119
120 return *RM;
121}
122
123/// Create an ARM architecture model.
124///
126 StringRef CPU, StringRef FS,
127 const TargetOptions &Options,
128 std::optional<Reloc::Model> RM,
129 std::optional<CodeModel::Model> CM,
131 : CodeGenTargetMachineImpl(T, TT, CPU, FS, Options,
133 getEffectiveCodeModel(CM, CodeModel::Small), OL),
134 CLOpts(cl::LibraryOptionsContext::get<ARMOptions>(
135 Options.MCOptions.LibraryOptions)),
137
138 if (TT.isOSBinFormatMachO()) {
139 this->Options.TrapUnreachable = true;
140 this->Options.NoTrapAfterNoreturn = true;
141 }
142
143 // ARM supports the debug entry values.
145
146 initAsmInfo();
147
149
150 // ARM supports the MachineOutliner.
151 setMachineOutliner(true);
153}
154
156
158 BumpPtrAllocator &Allocator, const Function &F,
159 const TargetSubtargetInfo *STI) const {
160 const auto *ARMSTI = static_cast<const ARMSubtarget *>(STI);
161 if (!ARMSTI->hasFPRegs() || ARMSTI->isThumb1Only() ||
162 ARMSTI->useSoftFloat()) {
163 const StringRef FPRegsUnavailableMsg =
164 ", but floating-point registers are unavailable";
165 const ARMTargetLowering *TLI = ARMSTI->getTargetLowering();
166
167 if (TLI->getEffectiveCallingConv(F.getCallingConv(), F.isVarArg()) ==
169 F.getContext().diagnose(DiagnosticInfoUnsupported(
170 F, Twine("calling convention is hard-float") + FPRegsUnavailableMsg,
171 DiagnosticLocation(F.getSubprogram())));
172 } else {
173 for (const Instruction &I : instructions(F)) {
174 const auto *CB = dyn_cast<CallBase>(&I);
175 if (!CB || CB->isInlineAsm() ||
176 (CB->getCalledFunction() && CB->getCalledFunction()->isIntrinsic()))
177 continue;
178 if (TLI->getEffectiveCallingConv(CB->getCallingConv(),
179 CB->getFunctionType()->isVarArg()) ==
181 const Function *Callee = CB->getCalledFunction();
182 F.getContext().diagnose(DiagnosticInfoUnsupported(
183 F,
184 (Callee ? Twine("'") + F.getName() + "' calls '" +
185 Callee->getName() + "', which"
186 : Twine("'") + F.getName() +
187 "' makes an indirect call that") +
188 " expects a hard-float calling convention" +
189 FPRegsUnavailableMsg,
190 CB->getDebugLoc()));
191 }
192 }
193 }
194 }
195 return ARMFunctionInfo::create<ARMFunctionInfo>(Allocator, F, ARMSTI);
196}
197
199 // An explicit "float-abi" module flag always wins, even for AAPCS16.
200 if (auto *Val = dyn_cast_or_null<MDString>(M.getModuleFlag("float-abi")))
201 return *FloatABI::parseABIType(Val->getString());
202 return M.getTargetTriple().getDefaultFloatABI(getTargetABIName(M));
203}
204
206 // Consistency of "target-abi" and -target-abi is validated elsewhere.
207 if (const auto *MD = cast_or_null<MDString>(M.getModuleFlag("target-abi")))
208 return ARM::computeTargetABI(TargetTriple, MD->getString());
209 return ARM::computeTargetABI(TargetTriple, Options.MCOptions.getABIName());
210}
211
212const ARMSubtarget *
214 AttributeSet FnAttrs = F.getAttributes().getFnAttrs();
215 const Module *M = F.getParent();
216 if (const ARMSubtarget *ST = LastSubtarget.lookup(FnAttrs, M))
217 return ST;
218
219 SubtargetAttrs Attrs;
220 Attrs.CPU = FnAttrs.getAttribute("target-cpu");
221 Attrs.FS = FnAttrs.getAttribute("target-features");
222 Attrs.SoftFloat = FnAttrs.getAttribute("use-soft-float");
223 Attrs.MinSize = FnAttrs.getAttribute(Attribute::MinSize);
224 Attrs.DenormalFPEnv = FnAttrs.getAttribute(Attribute::DenormalFPEnv);
225 Attrs.FloatABI = getFloatABI(*M);
226 Attrs.ABI = getEffectiveABI(*M);
227
228 if (const ARMSubtarget *ST = LastSubtarget.lookup(FnAttrs, M, Attrs))
229 return ST;
230
231 std::string CPU =
232 Attrs.CPU.isValid() ? Attrs.CPU.getValueAsString().str() : TargetCPU;
233 std::string FS =
234 Attrs.FS.isValid() ? Attrs.FS.getValueAsString().str() : TargetFS;
235
236 // FIXME: This is related to the code below to reset the target options,
237 // we need to know whether or not the soft float flag is set on the
238 // function before we can generate a subtarget. We also need to use
239 // it as a key for the subtarget since that can be the only difference
240 // between two functions.
241 bool SoftFloat = Attrs.SoftFloat.getValueAsBool();
242 // If the soft float attribute is set on the function turn on the soft float
243 // subtarget feature.
244 if (SoftFloat)
245 FS += FS.empty() ? "+soft-float" : ",+soft-float";
246
247 // Use the optminsize to identify the subtarget, but don't use it in the
248 // feature string.
249 std::string Key = CPU + FS;
250 if (Attrs.MinSize.isValid())
251 Key += "+minsize";
252
253 DenormalMode DM = F.getDenormalFPEnv().DefaultMode;
254 if (DM != DenormalMode::getIEEE())
255 Key += "denormal-fp-math=" + DM.str();
256
257 // It is legal to have FloatABI::Hard for targets with SIMD registers
258 // but no floating-point hardware (mve+nofp).
259 Key +=
260 Attrs.FloatABI == FloatABI::Hard ? "+hard-float-abi" : "+soft-float-abi";
261
262 Key += "+abi=" + std::to_string((int)Attrs.ABI);
263
264 auto &I = SubtargetMap[Key];
265 if (!I) {
266 I = std::make_unique<ARMSubtarget>(TargetTriple, CPU, FS, *this, isLittle,
267 Attrs.FloatABI, Attrs.ABI,
268 Attrs.MinSize.isValid(), DM);
269
270 if (!I->isThumb() && !I->hasARMOps())
271 F.getContext().emitError("Function '" + F.getName() + "' uses ARM "
272 "instructions, but the target does not support ARM mode execution.");
273 }
274
275 LastSubtarget.set(FnAttrs, M, Attrs, I.get());
276 return I.get();
277}
278
281 return TargetTransformInfo(std::make_unique<ARMTTIImpl>(this, F));
282}
283
287 // add DAG Mutations here.
288 const ARMSubtarget &ST = C->MF->getSubtarget<ARMSubtarget>();
289 if (ST.hasFusion())
291 return DAG;
292}
293
297 // add DAG Mutations here.
298 const ARMSubtarget &ST = C->MF->getSubtarget<ARMSubtarget>();
299 if (ST.hasFusion())
301 if (auto Mutation = createARMLatencyMutations(ST, C->AA))
302 DAG->addMutation(std::move(Mutation));
303 return DAG;
304}
305
307 StringRef CPU, StringRef FS,
308 const TargetOptions &Options,
309 std::optional<Reloc::Model> RM,
310 std::optional<CodeModel::Model> CM,
311 CodeGenOptLevel OL, bool JIT)
312 : ARMBaseTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL) {}
313
315 StringRef CPU, StringRef FS,
316 const TargetOptions &Options,
317 std::optional<Reloc::Model> RM,
318 std::optional<CodeModel::Model> CM,
319 CodeGenOptLevel OL, bool JIT)
320 : ARMBaseTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL) {}
321
322namespace {
323
324/// ARM Code Generator Pass Configuration Options.
325class ARMPassConfig : public TargetPassConfig {
326 const ARMOptions &CLOpts;
327
328public:
329 ARMPassConfig(ARMBaseTargetMachine &TM, PassManagerBase &PM)
330 : TargetPassConfig(TM, PM), CLOpts(TM.getCLOpts()) {}
331
332 ARMBaseTargetMachine &getARMTargetMachine() const {
334 }
335
336 void addIRPasses() override;
337 void addCodeGenPrepare() override;
338 bool addPreISel() override;
339 bool addInstSelector() override;
340 bool addIRTranslator() override;
341 bool addLegalizeMachineIR() override;
342 bool addRegBankSelect() override;
343 bool addGlobalInstructionSelect() override;
344 void addPreRegAlloc() override;
345 bool isMachinePipelinerEnabled() const override {
346 return getOptLevel() == CodeGenOptLevel::Aggressive;
347 }
348 void addPreSched2() override;
349 void addPreEmitPass() override;
350 void addPreEmitPass2() override;
351
352 std::unique_ptr<CSEConfigBase> getCSEConfig() const override;
353};
354
355} // end anonymous namespace
356
358#define GET_PASS_REGISTRY "ARMPassRegistry.def"
360}
361
363 return new ARMPassConfig(*this, PM);
364}
365
366std::unique_ptr<CSEConfigBase> ARMPassConfig::getCSEConfig() const {
367 return getStandardCSEConfigForOpt(TM->getOptLevel());
368}
369
370void ARMPassConfig::addIRPasses() {
372
373 // Cmpxchg instructions are often used with a subsequent comparison to
374 // determine whether it succeeded. We can exploit existing control-flow in
375 // ldrex/strex loops to simplify this, but it needs tidying up.
376 if (TM->getOptLevel() != CodeGenOptLevel::None && CLOpts.atomic_cfg_tidy)
378 SimplifyCFGOptions().hoistCommonInsts(true).sinkCommonInsts(true),
379 [this](const Function &F) {
380 const auto &ST = this->TM->getSubtarget<ARMSubtarget>(F);
381 return ST.hasAnyDataBarrier() && !ST.isThumb1Only();
382 }));
383
386
388
389 // Run the parallel DSP pass.
390 if (getOptLevel() == CodeGenOptLevel::Aggressive)
391 addPass(createARMParallelDSPPass());
392
393 // Match complex arithmetic patterns
394 if (TM->getOptLevel() >= CodeGenOptLevel::Default)
396
397 // Match interleaved memory accesses to ldN/stN intrinsics.
398 if (TM->getOptLevel() != CodeGenOptLevel::None)
400
401 // Add Control Flow Guard checks.
402 if (TM->getTargetTriple().isOSWindows())
403 addPass(createCFGuardPass());
404
405 if (TM->Options.JMCInstrument)
406 addPass(createJMCInstrumenterPass());
407}
408
409void ARMPassConfig::addCodeGenPrepare() {
410 if (getOptLevel() != CodeGenOptLevel::None)
413}
414
415bool ARMPassConfig::addPreISel() {
416 if (valueOr(CLOpts.global_merge,
417 TM->getOptLevel() != CodeGenOptLevel::None)) {
418 // FIXME: This is using the thumb1 only constant value for
419 // maximal global offset for merging globals. We may want
420 // to look into using the old value for non-thumb1 code of
421 // 4095 based on the TargetMachine, but this starts to become
422 // tricky when doing code gen per function.
423 bool OnlyOptimizeForSize =
424 (TM->getOptLevel() < CodeGenOptLevel::Aggressive) &&
425 (CLOpts.global_merge == BoolOrDefault::Default);
426 // Merging of extern globals is enabled by default on non-Mach-O as we
427 // expect it to be generally either beneficial or harmless. On Mach-O it
428 // is disabled as we emit the .subsections_via_symbols directive which
429 // means that merging extern globals is not safe.
430 bool MergeExternalByDefault = !TM->getTargetTriple().isOSBinFormatMachO();
431 addPass(createGlobalMergePass(TM, 127, OnlyOptimizeForSize,
432 MergeExternalByDefault));
433 }
434
435 if (TM->getOptLevel() != CodeGenOptLevel::None) {
438 // FIXME: IR passes can delete address-taken basic blocks, deleting
439 // corresponding blockaddresses. ARMConstantPoolConstant holds references to
440 // address-taken basic blocks which can be invalidated if the function
441 // containing the blockaddress has already been codegen'd and the basic
442 // block is removed. Work around this by forcing all IR passes to run before
443 // any ISel takes place. We should have a more principled way of handling
444 // this. See D99707 for more details.
445 addPass(createBarrierNoopPass());
446 }
447
448 return false;
449}
450
451bool ARMPassConfig::addInstSelector() {
452 addPass(createARMISelDag(getARMTargetMachine(), getOptLevel()));
453 return false;
454}
455
456bool ARMPassConfig::addIRTranslator() {
457 addPass(new IRTranslatorLegacy(getOptLevel()));
458 return false;
459}
460
461bool ARMPassConfig::addLegalizeMachineIR() {
462 addPass(new LegalizerLegacy());
463 return false;
464}
465
466bool ARMPassConfig::addRegBankSelect() {
467 addPass(new RegBankSelectLegacy());
468 return false;
469}
470
471bool ARMPassConfig::addGlobalInstructionSelect() {
472 addPass(new InstructionSelectLegacy(getOptLevel()));
473 return false;
474}
475
476void ARMPassConfig::addPreRegAlloc() {
477 if (getOptLevel() != CodeGenOptLevel::None) {
479
480 addPass(createMLxExpansionPass());
481
482 if (CLOpts.load_store_opt)
483 addPass(createARMLoadStoreOptLegacyPass(/* pre-register alloc */ true));
484
485 if (CLOpts.a15_sd_optimization)
486 addPass(createA15SDOptimizerPass());
487 }
488}
489
490void ARMPassConfig::addPreSched2() {
491 if (getOptLevel() != CodeGenOptLevel::None) {
492 if (CLOpts.load_store_opt)
494
497 }
498
499 // Expand some pseudo instructions into multiple instructions to allow
500 // proper scheduling.
501 addPass(createARMExpandPseudoPass());
502
503 // Emit KCFI checks for indirect calls.
504 addPass(createKCFIPass());
505
506 if (getOptLevel() != CodeGenOptLevel::None) {
507 // When optimising for size, always run the Thumb2SizeReduction pass before
508 // IfConversion. Otherwise, check whether IT blocks are restricted
509 // (e.g. in v8, IfConversion depends on Thumb instruction widths)
510 addPass(createThumb2SizeReductionPass([this](const Function &F) {
511 return this->TM->getSubtarget<ARMSubtarget>(F).hasMinSize() ||
512 this->TM->getSubtarget<ARMSubtarget>(F).restrictIT();
513 }));
514
515 addPass(createIfConverterLegacyPass([](const MachineFunction &MF) {
516 return !MF.getSubtarget<ARMSubtarget>().isThumb1Only();
517 }));
518 }
519 addPass(createThumb2ITBlockPass());
520
521 // Add both scheduling passes to give the subtarget an opportunity to pick
522 // between them.
523 if (getOptLevel() != CodeGenOptLevel::None) {
524 addPass(&PostMachineSchedulerID);
525 addPass(&PostRASchedulerID);
526 }
527
528 addPass(createMVEVPTBlockPass());
529 addPass(createARMIndirectThunks());
530 addPass(createARMSLSHardeningPass());
531}
532
533void ARMPassConfig::addPreEmitPass() {
535
536 // Unpack bundles for:
537 // - Thumb2: Constant island pass requires unbundled instructions
538 // - KCFI: KCFI_CHECK pseudo instructions need to be unbundled for AsmPrinter
540 return MF.getSubtarget<ARMSubtarget>().isThumb2() ||
541 MF.getFunction().getParent()->getModuleFlag("kcfi");
542 }));
543
544 // Don't optimize barriers or block placement at -O0.
545 if (getOptLevel() != CodeGenOptLevel::None) {
548 }
549}
550
551void ARMPassConfig::addPreEmitPass2() {
552
553 // Inserts fixup instructions before unsafe AES operations. Instructions may
554 // be inserted at the start of blocks and at within blocks so this pass has to
555 // come before those below.
557 // Inserts BTIs at the start of functions and indirectly-called basic blocks,
558 // so passes cannot add to the start of basic blocks once this has run.
560 // Inserts traps after calls that end a function or funclet, so it has to
561 // come before ARMConstantIslands.
562 if (TM->getTargetTriple().isOSWindows())
564 // Inserts Constant Islands. Block sizes cannot be increased after this point,
565 // as this may push the branch ranges and load offsets of accessing constant
566 // pools out of range..
568 // Finalises Low-Overhead Loops. This replaces pseudo instructions with real
569 // instructions, but the pseudos all have conservative sizes so that block
570 // sizes will only be decreased by this pass.
572
573 if (TM->getTargetTriple().isOSWindows()) {
574 // Identify valid longjmp targets for Windows Control Flow Guard.
576 // Identify valid eh continuation targets for Windows EHCont Guard.
578 }
579}
580
585
588 const auto *MFI = MF.getInfo<ARMFunctionInfo>();
589 return new yaml::ARMFunctionInfo(*MFI);
590}
591
594 SMDiagnostic &Error, SMRange &SourceRange) const {
595 const auto &YamlMFI = static_cast<const yaml::ARMFunctionInfo &>(MFI);
596 MachineFunction &MF = PFS.MF;
597 MF.getInfo<ARMFunctionInfo>()->initializeBaseYamlFields(YamlMFI);
598 return false;
599}
600
602 SubtargetMap.clear();
603 LastSubtarget.clear();
604}
const TargetLowering & TLI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static std::unique_ptr< TargetLoweringObjectFile > createTLOF(const Triple &TT)
static Reloc::Model getEffectiveRelocModel()
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARMTarget()
This file a TargetTransformInfoImplBase conforming object specific to the ARM target machine.
Expand Atomic instructions
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")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Provides analysis for continuously CSEing during GISel passes.
This file describes how to lower LLVM calls to machine code calls.
#define LLVM_ABI
Definition Compiler.h:211
#define LLVM_EXTERNAL_VISIBILITY
Definition Compiler.h:132
static RegisterPass< DebugifyModulePass > DM("debugify", "Attach debug info to everything")
This file declares the IRTranslator pass.
Module.h This file contains the declarations for the Module class.
Interface for Targets to specify which operations they can successfully select and how the others sho...
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
#define T
PowerPC VSX FMA Mutation
PassBuilder PB(Mod->getContext(), Machine, PassOpts->PTO, std::nullopt, &PIC)
This file describes the interface of the MachineFunctionPass responsible for assigning the generic vi...
const GCNTargetMachine & getTM(const GCNSubtarget *STI)
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()
ARMBETargetMachine(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)
LastSubtargetCache< ARMSubtarget, SubtargetAttrs > LastSubtarget
bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange) const override
Parse out the target's MachineFunctionInfo from the YAML reprsentation.
void registerPassBuilderCallbacks(PassBuilder &PB) override
Allow the target to modify the pass pipeline.
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
std::unique_ptr< TargetLoweringObjectFile > TLOF
ARM::ARMABI getEffectiveABI(const Module &M) const
Returns the ABI in effect for M: the "target-abi" module flag if present, otherwise the legacy -targe...
void reset() override
Reset internal state.
ARMBaseTargetMachine(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)
Create an ARM architecture model.
MachineFunctionInfo * createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, const TargetSubtargetInfo *STI) const override
Create the target's instance of MachineFunctionInfo.
yaml::MachineFunctionInfo * createDefaultFuncInfoYAML() const override
Allocate and return a default initialized instance of the YAML representation for the MachineFunction...
const ARMSubtarget * getSubtargetImpl() const =delete
FloatABI::ABIType getFloatABI(const Module &M) const
Returns the floating-point ABI in effect for M: the "float-abi" module flag if present,...
ScheduleDAGInstrs * createMachineScheduler(MachineSchedContext *C) const override
Create an instance of ScheduleDAGInstrs to be run within the standard MachineScheduler pass for this ...
StringMap< std::unique_ptr< ARMSubtarget > > SubtargetMap
TargetTransformInfo getTargetTransformInfo(const Function &F) const override
Return a TargetTransformInfo for a given function.
ScheduleDAGInstrs * createPostMachineScheduler(MachineSchedContext *C) const override
Similar to createMachineScheduler but used when postRA machine scheduling is enabled.
yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const override
Allocate and initialize an instance of the YAML representation of the MachineFunctionInfo.
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
ARMLETargetMachine(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)
This class holds the attributes for a particular argument, parameter, function, or return value.
Definition Attributes.h:445
LLVM_ABI Attribute getAttribute(Attribute::AttrKind Kind) const
Return the attribute object.
CodeGenTargetMachineImpl(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOptLevel OL)
Diagnostic information for unsupported feature in backend.
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Module * getParent()
Get the module that this global value is contained inside of...
This pass is responsible for selecting generic machine instructions to target-specific instructions.
static void setUseExtended(bool Enable)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
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...
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
Metadata * getModuleFlag(StringRef Key) const
Return the corresponding value if Key appears in module flags, otherwise return null.
Definition Module.cpp:377
This class provides access to building LLVM's passes.
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.
A global registry used in conjunction with static constructors to make pluggable components (like tar...
Definition Registry.h:116
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.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
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)
void setSupportsDefaultOutlining(bool Enable)
StringRef getTargetABIName(const Module &M) const
Returns the effective target ABI name: the "target-abi" module flag if present, otherwise the -target...
std::unique_ptr< const MCSubtargetInfo > STI
TargetOptions Options
Target-Independent Code Generator Pass Configuration Options.
virtual void addCodeGenPrepare()
Add pass to prepare the LLVM IR for code generation.
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
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
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
Registers T with cl::parseCommandLineOptions.
Interfaces for registering analysis passes, producing common pass manager configurations,...
LLVM_ABI LLVM_READONLY ARMABI computeTargetABI(const Triple &TT, StringRef ABIName="")
@ ARM_AAPCS_VFP
Same as ARM_AAPCS, but uses hard floating point ABI.
std::optional< ABIType > parseABIType(StringRef S)
Parse the string spelling used by the "float-abi" IR module flag into an ABIType.
Definition CodeGen.h:167
@ DynamicNoPIC
Definition CodeGen.h:26
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.
void initializeARMConstantIslandsPass(PassRegistry &)
LLVM_ABI FunctionPass * createCFGSimplificationPass(SimplifyCFGOptions Options=SimplifyCFGOptions(), std::function< bool(const Function &)> Ftor=nullptr)
FunctionPass * createMVETPAndVPTOptimisationsPass()
createMVETPAndVPTOptimisationsPass
Pass * createMVELaneInterleavingPass()
LLVM_ABI ModulePass * createJMCInstrumenterPass()
JMC instrument pass.
FunctionPass * createARMOptimizeBarriersPass()
createARMOptimizeBarriersPass - Returns an instance of the remove double barriers pass.
LLVM_ABI FunctionPass * createTypePromotionLegacyPass()
Create IR Type Promotion pass.
LLVM_ABI FunctionPass * createIfConverterLegacyPass(std::function< bool(const MachineFunction &)> Ftor)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
void initializeMVETailPredicationPass(PassRegistry &)
void initializeARMAvoidTrailingCallPass(PassRegistry &)
void initializeMVELaneInterleavingPass(PassRegistry &)
Pass * createMVEGatherScatterLoweringPass()
LLVM_ABI FunctionPass * createEHContGuardTargetsLegacy()
Creates Windows EH Continuation Guard target identification pass.
Target & getTheThumbBETarget()
LLVM_ABI Pass * createGlobalMergePass(const TargetMachine *TM, unsigned MaximalOffset, bool OnlyOptimizeForSize=false, bool MergeExternalByDefault=false, bool MergeConstantByDefault=false, bool MergeConstAggressiveByDefault=false)
GlobalMerge - This pass merges internal (by default) globals into structs to enable reuse of a base p...
LLVM_ABI FunctionPass * createExecutionDomainFixLegacyPass()
Minimizes execution domain crossings for specific register classes.
auto cast_or_null(const Y &Val)
Definition Casting.h:714
LLVM_ABI char & PostRASchedulerID
PostRAScheduler - This pass performs post register allocation scheduling.
FunctionPass * createARMISelDag(ARMBaseTargetMachine &TM, CodeGenOptLevel OptLevel)
createARMISelDag - This pass converts a legalized DAG into a ARM-specific DAG, ready for instruction ...
LLVM_ABI FunctionPass * createCFGuardLongjmpLegacyPass()
Creates CFGuard longjmp target identification pass.
LLVM_ABI std::unique_ptr< CSEConfigBase > getStandardCSEConfigForOpt(CodeGenOptLevel Level)
Definition CSEInfo.cpp:85
FunctionPass * createARMLowOverheadLoopsPass()
LLVM_ABI char & PostMachineSchedulerID
PostMachineScheduler - This pass schedules machine instructions postRA.
void initializeARMPreAllocLoadStoreOptLegacyPass(PassRegistry &)
FunctionPass * createARMBranchTargetsPass()
auto dyn_cast_or_null(const Y &Val)
Definition Casting.h:753
LLVM_ABI void initializeMachineKCFILegacyPass(PassRegistry &)
LLVM_ABI FunctionPass * createUnpackMachineBundlesLegacy(std::function< bool(const MachineFunction &)> Ftor)
static Reloc::Model getEffectiveRelocModel(std::optional< Reloc::Model > RM)
std::unique_ptr< ScheduleDAGMutation > createARMLatencyMutations(const ARMSubtarget &ST, AAResults *AA)
CodeModel::Model getEffectiveCodeModel(std::optional< CodeModel::Model > CM, CodeModel::Model Default)
Helper method for getting the code model, returning Default if CM does not have a value.
ScheduleDAGMI * createSchedPostRA(MachineSchedContext *C)
Create a generic scheduler with no vreg liveness or DAG mutation passes.
void initializeARMBranchTargetsPass(PassRegistry &)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
Pass * createMVETailPredicationPass()
LLVM_ABI FunctionPass * createKCFIPass()
Lowers KCFI operand bundles for indirect calls.
Definition KCFI.cpp:75
LLVM_ABI FunctionPass * createComplexDeinterleavingPass(const TargetMachine *TM)
This pass implements generation of target-specific intrinsics to support handling of complex number a...
FunctionPass * createARMBlockPlacementPass()
std::unique_ptr< ScheduleDAGMutation > createARMMacroFusionDAGMutation()
Note that you have to add: DAG.addMutation(createARMMacroFusionDAGMutation()); to ARMTargetMachine::c...
void initializeARMParallelDSPPass(PassRegistry &)
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:280
@ Default
-O2, -Os, -Oz
Definition CodeGen.h:283
FunctionPass * createARMLoadStoreOptLegacyPass(bool PreAlloc=false)
Returns an instance of the load / store optimization pass.
void initializeARMExpandPseudoPass(PassRegistry &)
FunctionPass * createA15SDOptimizerPass()
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
void initializeARMSLSHardeningPass(PassRegistry &)
void initializeThumb2ITBlockPass(PassRegistry &)
LLVM_ABI FunctionPass * createInterleavedAccessPass()
InterleavedAccess Pass - This pass identifies and matches interleaved memory accesses to target speci...
LLVM_ABI void initializeGlobalISel(PassRegistry &)
Initialize all passes linked into the GlobalISel library.
void initializeARMAsmPrinterPass(PassRegistry &)
LLVM_ABI FunctionPass * createCFGuardPass()
Insert Control Flow Guard checks on indirect function calls.
Definition CFGuard.cpp:314
void initializeARMLoadStoreOptLegacyPass(PassRegistry &)
LLVM_ABI ModulePass * createBarrierNoopPass()
createBarrierNoopPass - This pass is purely a module pass barrier in a pass manager.
FunctionPass * createARMSLSHardeningPass()
FunctionPass * createARMConstantIslandPass()
createARMConstantIslandPass - returns an instance of the constpool island pass.
void initializeARMLowOverheadLoopsPass(PassRegistry &)
void initializeMVETPAndVPTOptimisationsPass(PassRegistry &)
void initializeThumb2SizeReducePass(PassRegistry &)
FunctionPass * createThumb2ITBlockPass()
createThumb2ITBlockPass - Returns an instance of the Thumb2 IT blocks insertion pass.
void initializeMVEGatherScatterLoweringPass(PassRegistry &)
constexpr bool valueOr(BoolOrDefault X, bool Default)
FunctionPass * createARMExpandPseudoPass()
createARMExpandPseudoPass - returns an instance of the pseudo instruction expansion pass.
FunctionPass * createARMIndirectThunks()
void initializeARMFixCortexA57AES1742098Pass(PassRegistry &)
FunctionPass * createARMFixCortexA57AES1742098Pass()
Pass * createARMParallelDSPPass()
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:391
FunctionPass * createThumb2SizeReductionPass(std::function< bool(const Function &)> Ftor=nullptr)
createThumb2SizeReductionPass - Returns an instance of the Thumb2 size reduction pass.
Target & getTheARMLETarget()
LLVM_ABI FunctionPass * createBreakFalseDepsLegacyPass()
Creates Break False Dependencies pass.
void initializeMVEVPTBlockPass(PassRegistry &)
void initializeARMDAGToDAGISelLegacyPass(PassRegistry &)
FunctionPass * createMLxExpansionPass()
void initializeARMBlockPlacementPass(PassRegistry &)
LLVM_ABI FunctionPass * createHardwareLoopsLegacyPass()
Create Hardware Loop pass.
FunctionPass * createARMAvoidTrailingCallPass()
Target & getTheARMBETarget()
Target & getTheThumbLETarget()
FunctionPass * createMVEVPTBlockPass()
createMVEVPTBlock - Returns an instance of the MVE VPT block insertion pass.
The attributes that select a subtarget.
Represent subnormal handling kind for floating point instruction inputs and outputs.
static constexpr DenormalMode getIEEE()
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...
RegisterTargetMachine - Helper template for registering a target machine implementation,...
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.