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"
35#include "llvm/CodeGen/Passes.h"
37#include "llvm/IR/Attributes.h"
38#include "llvm/IR/CallingConv.h"
39#include "llvm/IR/DataLayout.h"
41#include "llvm/IR/Function.h"
43#include "llvm/IR/InstrTypes.h"
44#include "llvm/IR/Module.h"
46#include "llvm/Pass.h"
58#include "llvm/Transforms/IPO.h"
60#include <cassert>
61#include <memory>
62#include <optional>
63#include <string>
64
65using namespace llvm;
66
67static cl::opt<bool>
68DisableA15SDOptimization("disable-a15-sd-optimization", cl::Hidden,
69 cl::desc("Inhibit optimization of S->D register accesses on A15"),
70 cl::init(false));
71
72static cl::opt<bool>
73EnableAtomicTidy("arm-atomic-cfg-tidy", cl::Hidden,
74 cl::desc("Run SimplifyCFG after expanding atomic operations"
75 " to make use of cmpxchg flow-based information"),
76 cl::init(true));
77
78static cl::opt<bool>
79EnableARMLoadStoreOpt("arm-load-store-opt", cl::Hidden,
80 cl::desc("Enable ARM load/store optimization pass"),
81 cl::init(true));
82
83// FIXME: Unify control over GlobalMerge.
85EnableGlobalMerge("arm-global-merge", cl::Hidden,
86 cl::desc("Enable the global merge pass"));
87
88namespace llvm {
90}
91
122
123static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
124 if (TT.isOSBinFormatMachO())
125 return std::make_unique<TargetLoweringObjectFileMachO>();
126 if (TT.isOSWindows())
127 return std::make_unique<TargetLoweringObjectFileCOFF>();
128 return std::make_unique<ARMElfTargetObjectFile>();
129}
130
132 std::optional<Reloc::Model> RM) {
133 if (!RM)
134 // Default relocation model on Darwin is PIC.
135 return TT.isOSBinFormatMachO() ? Reloc::PIC_ : Reloc::Static;
136
137 if (*RM == Reloc::ROPI || *RM == Reloc::RWPI || *RM == Reloc::ROPI_RWPI)
138 assert(TT.isOSBinFormatELF() &&
139 "ROPI/RWPI currently only supported for ELF");
140
141 // DynamicNoPIC is only used on darwin.
142 if (*RM == Reloc::DynamicNoPIC && !TT.isOSDarwin())
143 return Reloc::Static;
144
145 return *RM;
146}
147
148/// Create an ARM architecture model.
149///
151 StringRef CPU, StringRef FS,
152 const TargetOptions &Options,
153 std::optional<Reloc::Model> RM,
154 std::optional<CodeModel::Model> CM,
157 T, TT.computeDataLayout(Options.MCOptions.ABIName), TT, CPU, FS,
159 getEffectiveCodeModel(CM, CodeModel::Small), OL),
160 TargetABI(ARM::computeTargetABI(TT, Options.MCOptions.ABIName)),
162
163 // Default to triple-appropriate float ABI. -target-abi=aapcs16 forces hard
164 // float regardless of the triple default.
165 if (Options.FloatABIType == FloatABI::Default) {
166 if (TargetABI == ARM::ARM_ABI_AAPCS16 ||
167 TT.getDefaultFloatABI() == FloatABI::Hard)
168 this->Options.FloatABIType = FloatABI::Hard;
169 else
170 this->Options.FloatABIType = FloatABI::Soft;
171 }
172
173 // Default to triple-appropriate EABI
174 if (Options.EABIVersion == EABI::Default ||
175 Options.EABIVersion == EABI::Unknown) {
176 // musl is compatible with glibc with regard to EABI version
177 if ((TargetTriple.getEnvironment() == Triple::GNUEABI ||
178 TargetTriple.getEnvironment() == Triple::GNUEABIT64 ||
179 TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
180 TargetTriple.getEnvironment() == Triple::GNUEABIHFT64 ||
181 TargetTriple.getEnvironment() == Triple::MuslEABI ||
182 TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
183 TargetTriple.getEnvironment() == Triple::OpenHOS) &&
184 !(TargetTriple.isOSWindows() || TargetTriple.isOSDarwin()))
185 this->Options.EABIVersion = EABI::GNU;
186 else
187 this->Options.EABIVersion = EABI::EABI5;
188 }
189
190 if (TT.isOSBinFormatMachO()) {
191 this->Options.TrapUnreachable = true;
192 this->Options.NoTrapAfterNoreturn = true;
193 }
194
195 // ARM supports the debug entry values.
197
198 initAsmInfo();
199
200 // ARM supports the MachineOutliner.
201 setMachineOutliner(true);
203}
204
206
208 BumpPtrAllocator &Allocator, const Function &F,
209 const TargetSubtargetInfo *STI) const {
210 const auto *ARMSTI = static_cast<const ARMSubtarget *>(STI);
211 bool FPRegsUnavailable = !ARMSTI->hasFPRegs() || ARMSTI->isThumb1Only();
212 if (FPRegsUnavailable) {
213 const StringRef FPRegsUnavailableMsg =
214 ", but floating-point registers are unavailable";
215 const ARMTargetLowering *TLI = ARMSTI->getTargetLowering();
216
217 if (TLI->getEffectiveCallingConv(F.getCallingConv(), F.isVarArg()) ==
219 F.getContext().diagnose(DiagnosticInfoUnsupported(
220 F, Twine("calling convention is hard-float") + FPRegsUnavailableMsg,
221 DiagnosticLocation(F.getSubprogram())));
222 } else {
223 for (const Instruction &I : instructions(F)) {
224 const auto *CB = dyn_cast<CallBase>(&I);
225 if (!CB || CB->isInlineAsm() ||
226 (CB->getCalledFunction() && CB->getCalledFunction()->isIntrinsic()))
227 continue;
228 if (TLI->getEffectiveCallingConv(CB->getCallingConv(),
229 CB->getFunctionType()->isVarArg()) ==
231 const Function *Callee = CB->getCalledFunction();
232 F.getContext().diagnose(DiagnosticInfoUnsupported(
233 F,
234 (Callee ? Twine("call to '") + Callee->getName() + "'"
235 : Twine("indirect call")) +
236 " expects a hard-float calling convention" +
237 FPRegsUnavailableMsg,
238 CB->getDebugLoc()));
239 }
240 }
241 }
242 }
243 return ARMFunctionInfo::create<ARMFunctionInfo>(Allocator, F, ARMSTI);
244}
245
246const ARMSubtarget *
248 Attribute CPUAttr = F.getFnAttribute("target-cpu");
249 Attribute FSAttr = F.getFnAttribute("target-features");
250
251 std::string CPU =
252 CPUAttr.isValid() ? CPUAttr.getValueAsString().str() : TargetCPU;
253 std::string FS =
254 FSAttr.isValid() ? FSAttr.getValueAsString().str() : TargetFS;
255
256 // FIXME: This is related to the code below to reset the target options,
257 // we need to know whether or not the soft float flag is set on the
258 // function before we can generate a subtarget. We also need to use
259 // it as a key for the subtarget since that can be the only difference
260 // between two functions.
261 bool SoftFloat = F.getFnAttribute("use-soft-float").getValueAsBool();
262 // If the soft float attribute is set on the function turn on the soft float
263 // subtarget feature.
264 if (SoftFloat)
265 FS += FS.empty() ? "+soft-float" : ",+soft-float";
266
267 // Use the optminsize to identify the subtarget, but don't use it in the
268 // feature string.
269 std::string Key = CPU + FS;
270 if (F.hasMinSize())
271 Key += "+minsize";
272
273 DenormalMode DM = F.getDenormalFPEnv().DefaultMode;
274 if (DM != DenormalMode::getIEEE())
275 Key += "denormal-fp-math=" + DM.str();
276
277 // The float ABI comes from the "float-abi" module flag if present, otherwise
278 // from the legacy -float-abi target option (which the constructor seeded from
279 // the target triple).
280 FloatABI::ABIType FloatABI = F.getParent()->getFloatABI();
282 FloatABI = Options.FloatABIType;
284 "expected TargetMachine constructor to overwrite default float abi");
285 }
286
287 // It is legal to have FloatABI::Hard with +soft-float for targets with SIMD
288 // registers, but no floating-point hardware (mve+nofp)
289 Key += FloatABI == FloatABI::Hard ? "+hard-float-abi" : "+soft-float-abi";
290
291 auto &I = SubtargetMap[Key];
292 if (!I) {
293 I = std::make_unique<ARMSubtarget>(TargetTriple, CPU, FS, *this, isLittle,
294 FloatABI, F.hasMinSize(), DM);
295
296 if (!I->isThumb() && !I->hasARMOps())
297 F.getContext().emitError("Function '" + F.getName() + "' uses ARM "
298 "instructions, but the target does not support ARM mode execution.");
299 }
300
301 return I.get();
302}
303
306 return TargetTransformInfo(std::make_unique<ARMTTIImpl>(this, F));
307}
308
312 // add DAG Mutations here.
313 const ARMSubtarget &ST = C->MF->getSubtarget<ARMSubtarget>();
314 if (ST.hasFusion())
316 return DAG;
317}
318
322 // add DAG Mutations here.
323 const ARMSubtarget &ST = C->MF->getSubtarget<ARMSubtarget>();
324 if (ST.hasFusion())
326 if (auto Mutation = createARMLatencyMutations(ST, C->AA))
327 DAG->addMutation(std::move(Mutation));
328 return DAG;
329}
330
332 StringRef CPU, StringRef FS,
333 const TargetOptions &Options,
334 std::optional<Reloc::Model> RM,
335 std::optional<CodeModel::Model> CM,
336 CodeGenOptLevel OL, bool JIT)
337 : ARMBaseTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL) {}
338
340 StringRef CPU, StringRef FS,
341 const TargetOptions &Options,
342 std::optional<Reloc::Model> RM,
343 std::optional<CodeModel::Model> CM,
344 CodeGenOptLevel OL, bool JIT)
345 : ARMBaseTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL) {}
346
347namespace {
348
349/// ARM Code Generator Pass Configuration Options.
350class ARMPassConfig : public TargetPassConfig {
351public:
352 ARMPassConfig(ARMBaseTargetMachine &TM, PassManagerBase &PM)
353 : TargetPassConfig(TM, PM) {}
354
355 ARMBaseTargetMachine &getARMTargetMachine() const {
357 }
358
359 void addIRPasses() override;
360 void addCodeGenPrepare() override;
361 bool addPreISel() override;
362 bool addInstSelector() override;
363 bool addIRTranslator() override;
364 bool addLegalizeMachineIR() override;
365 bool addRegBankSelect() override;
366 bool addGlobalInstructionSelect() override;
367 void addPreRegAlloc() override;
368 void addPreSched2() override;
369 void addPreEmitPass() override;
370 void addPreEmitPass2() override;
371
372 std::unique_ptr<CSEConfigBase> getCSEConfig() const override;
373};
374
375class ARMExecutionDomainFix : public ExecutionDomainFix {
376public:
377 static char ID;
378 ARMExecutionDomainFix() : ExecutionDomainFix(ID, ARM::DPRRegClass) {}
379 StringRef getPassName() const override {
380 return "ARM Execution Domain Fix";
381 }
382};
383char ARMExecutionDomainFix::ID;
384
385} // end anonymous namespace
386
387INITIALIZE_PASS_BEGIN(ARMExecutionDomainFix, "arm-execution-domain-fix",
388 "ARM Execution Domain Fix", false, false)
390INITIALIZE_PASS_END(ARMExecutionDomainFix, "arm-execution-domain-fix",
391 "ARM Execution Domain Fix", false, false)
392
394#define GET_PASS_REGISTRY "ARMPassRegistry.def"
396}
397
399 return new ARMPassConfig(*this, PM);
400}
401
402std::unique_ptr<CSEConfigBase> ARMPassConfig::getCSEConfig() const {
403 return getStandardCSEConfigForOpt(TM->getOptLevel());
404}
405
406void ARMPassConfig::addIRPasses() {
407 if (TM->Options.ThreadModel == ThreadModel::Single)
408 addPass(createLowerAtomicPass());
409 else
411
412 // Cmpxchg instructions are often used with a subsequent comparison to
413 // determine whether it succeeded. We can exploit existing control-flow in
414 // ldrex/strex loops to simplify this, but it needs tidying up.
415 if (TM->getOptLevel() != CodeGenOptLevel::None && EnableAtomicTidy)
417 SimplifyCFGOptions().hoistCommonInsts(true).sinkCommonInsts(true),
418 [this](const Function &F) {
419 const auto &ST = this->TM->getSubtarget<ARMSubtarget>(F);
420 return ST.hasAnyDataBarrier() && !ST.isThumb1Only();
421 }));
422
425
427
428 // Run the parallel DSP pass.
429 if (getOptLevel() == CodeGenOptLevel::Aggressive)
430 addPass(createARMParallelDSPPass());
431
432 // Match complex arithmetic patterns
433 if (TM->getOptLevel() >= CodeGenOptLevel::Default)
435
436 // Match interleaved memory accesses to ldN/stN intrinsics.
437 if (TM->getOptLevel() != CodeGenOptLevel::None)
439
440 // Add Control Flow Guard checks.
441 if (TM->getTargetTriple().isOSWindows())
442 addPass(createCFGuardPass());
443
444 if (TM->Options.JMCInstrument)
445 addPass(createJMCInstrumenterPass());
446}
447
448void ARMPassConfig::addCodeGenPrepare() {
449 if (getOptLevel() != CodeGenOptLevel::None)
452}
453
454bool ARMPassConfig::addPreISel() {
455 if ((TM->getOptLevel() != CodeGenOptLevel::None &&
458 // FIXME: This is using the thumb1 only constant value for
459 // maximal global offset for merging globals. We may want
460 // to look into using the old value for non-thumb1 code of
461 // 4095 based on the TargetMachine, but this starts to become
462 // tricky when doing code gen per function.
463 bool OnlyOptimizeForSize =
464 (TM->getOptLevel() < CodeGenOptLevel::Aggressive) &&
466 // Merging of extern globals is enabled by default on non-Mach-O as we
467 // expect it to be generally either beneficial or harmless. On Mach-O it
468 // is disabled as we emit the .subsections_via_symbols directive which
469 // means that merging extern globals is not safe.
470 bool MergeExternalByDefault = !TM->getTargetTriple().isOSBinFormatMachO();
471 addPass(createGlobalMergePass(TM, 127, OnlyOptimizeForSize,
472 MergeExternalByDefault));
473 }
474
475 if (TM->getOptLevel() != CodeGenOptLevel::None) {
478 // FIXME: IR passes can delete address-taken basic blocks, deleting
479 // corresponding blockaddresses. ARMConstantPoolConstant holds references to
480 // address-taken basic blocks which can be invalidated if the function
481 // containing the blockaddress has already been codegen'd and the basic
482 // block is removed. Work around this by forcing all IR passes to run before
483 // any ISel takes place. We should have a more principled way of handling
484 // this. See D99707 for more details.
485 addPass(createBarrierNoopPass());
486 }
487
488 return false;
489}
490
491bool ARMPassConfig::addInstSelector() {
492 addPass(createARMISelDag(getARMTargetMachine(), getOptLevel()));
493 return false;
494}
495
496bool ARMPassConfig::addIRTranslator() {
497 addPass(new IRTranslator(getOptLevel()));
498 return false;
499}
500
501bool ARMPassConfig::addLegalizeMachineIR() {
502 addPass(new Legalizer());
503 return false;
504}
505
506bool ARMPassConfig::addRegBankSelect() {
507 addPass(new RegBankSelect());
508 return false;
509}
510
511bool ARMPassConfig::addGlobalInstructionSelect() {
512 addPass(new InstructionSelect(getOptLevel()));
513 return false;
514}
515
516void ARMPassConfig::addPreRegAlloc() {
517 if (getOptLevel() != CodeGenOptLevel::None) {
518 if (getOptLevel() == CodeGenOptLevel::Aggressive)
519 addPass(&MachinePipelinerID);
520
522
523 addPass(createMLxExpansionPass());
524
526 addPass(createARMLoadStoreOptLegacyPass(/* pre-register alloc */ true));
527
529 addPass(createA15SDOptimizerPass());
530 }
531}
532
533void ARMPassConfig::addPreSched2() {
534 if (getOptLevel() != CodeGenOptLevel::None) {
537
538 addPass(new ARMExecutionDomainFix());
540 }
541
542 // Expand some pseudo instructions into multiple instructions to allow
543 // proper scheduling.
544 addPass(createARMExpandPseudoPass());
545
546 // Emit KCFI checks for indirect calls.
547 addPass(createKCFIPass());
548
549 if (getOptLevel() != CodeGenOptLevel::None) {
550 // When optimising for size, always run the Thumb2SizeReduction pass before
551 // IfConversion. Otherwise, check whether IT blocks are restricted
552 // (e.g. in v8, IfConversion depends on Thumb instruction widths)
553 addPass(createThumb2SizeReductionPass([this](const Function &F) {
554 return this->TM->getSubtarget<ARMSubtarget>(F).hasMinSize() ||
555 this->TM->getSubtarget<ARMSubtarget>(F).restrictIT();
556 }));
557
558 addPass(createIfConverter([](const MachineFunction &MF) {
559 return !MF.getSubtarget<ARMSubtarget>().isThumb1Only();
560 }));
561 }
562 addPass(createThumb2ITBlockPass());
563
564 // Add both scheduling passes to give the subtarget an opportunity to pick
565 // between them.
566 if (getOptLevel() != CodeGenOptLevel::None) {
567 addPass(&PostMachineSchedulerID);
568 addPass(&PostRASchedulerID);
569 }
570
571 addPass(createMVEVPTBlockPass());
572 addPass(createARMIndirectThunks());
573 addPass(createARMSLSHardeningPass());
574}
575
576void ARMPassConfig::addPreEmitPass() {
578
579 // Unpack bundles for:
580 // - Thumb2: Constant island pass requires unbundled instructions
581 // - KCFI: KCFI_CHECK pseudo instructions need to be unbundled for AsmPrinter
583 return MF.getSubtarget<ARMSubtarget>().isThumb2() ||
584 MF.getFunction().getParent()->getModuleFlag("kcfi");
585 }));
586
587 // Don't optimize barriers or block placement at -O0.
588 if (getOptLevel() != CodeGenOptLevel::None) {
591 }
592}
593
594void ARMPassConfig::addPreEmitPass2() {
595
596 // Inserts fixup instructions before unsafe AES operations. Instructions may
597 // be inserted at the start of blocks and at within blocks so this pass has to
598 // come before those below.
600 // Inserts BTIs at the start of functions and indirectly-called basic blocks,
601 // so passes cannot add to the start of basic blocks once this has run.
603 // Inserts Constant Islands. Block sizes cannot be increased after this point,
604 // as this may push the branch ranges and load offsets of accessing constant
605 // pools out of range..
607 // Finalises Low-Overhead Loops. This replaces pseudo instructions with real
608 // instructions, but the pseudos all have conservative sizes so that block
609 // sizes will only be decreased by this pass.
611
612 if (TM->getTargetTriple().isOSWindows()) {
613 // Identify valid longjmp targets for Windows Control Flow Guard.
614 addPass(createCFGuardLongjmpPass());
615 // Identify valid eh continuation targets for Windows EHCont Guard.
617 }
618}
619
624
627 const auto *MFI = MF.getInfo<ARMFunctionInfo>();
628 return new yaml::ARMFunctionInfo(*MFI);
629}
630
633 SMDiagnostic &Error, SMRange &SourceRange) const {
634 const auto &YamlMFI = static_cast<const yaml::ARMFunctionInfo &>(MFI);
635 MachineFunction &MF = PFS.MF;
636 MF.getInfo<ARMFunctionInfo>()->initializeBaseYamlFields(YamlMFI);
637 return false;
638}
639
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static cl::opt< bool > EnableAtomicTidy("aarch64-enable-atomic-cfg-tidy", cl::Hidden, cl::desc("Run SimplifyCFG after expanding atomic operations" " to make use of cmpxchg flow-based information"), cl::init(true))
static std::unique_ptr< TargetLoweringObjectFile > createTLOF(const Triple &TT)
static Reloc::Model getEffectiveRelocModel()
static cl::opt< bool > DisableA15SDOptimization("disable-a15-sd-optimization", cl::Hidden, cl::desc("Inhibit optimization of S->D register accesses on A15"), cl::init(false))
static cl::opt< cl::boolOrDefault > EnableGlobalMerge("arm-global-merge", cl::Hidden, cl::desc("Enable the global merge pass"))
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARMTarget()
static cl::opt< bool > EnableARMLoadStoreOpt("arm-load-store-opt", cl::Hidden, cl::desc("Enable ARM load/store optimization pass"), cl::init(true))
static cl::opt< bool > EnableAtomicTidy("arm-atomic-cfg-tidy", cl::Hidden, cl::desc("Run SimplifyCFG after expanding atomic operations" " to make use of cmpxchg flow-based information"), cl::init(true))
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:856
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:215
#define LLVM_EXTERNAL_VISIBILITY
Definition Compiler.h:132
DXIL Legalizer
static RegisterPass< DebugifyModulePass > DM("debugify", "Attach debug info to everything")
static cl::opt< bool > EnableGlobalMerge("enable-global-merge", cl::Hidden, cl::desc("Enable the global merge pass"), cl::init(true))
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
static PPCTargetMachine::PPCABI computeTargetABI(const Triple &TT, const TargetOptions &Options)
PowerPC VSX FMA Mutation
if(PassOpts->AAPipeline)
PassBuilder PB(Machine, PassOpts->PTO, std::nullopt, &PIC)
#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)
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)
bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange) const override
Parse out the target's MachineFunctionInfo from the YAML reprsentation.
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
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
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
void registerPassBuilderCallbacks(PassBuilder &PB) override
Allow the target to modify the pass pipeline.
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)
bool isThumb1Only() const
CallingConv::ID getEffectiveCallingConv(CallingConv::ID CC, bool isVarArg) const
getEffectiveCallingConv - Get the effective calling convention, taking into account presence of float...
Functions, function parameters, and return types can have attributes to indicate how they should be t...
Definition Attributes.h:105
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:261
CodeGenTargetMachineImpl(const Target &T, StringRef DataLayoutString, 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.
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...
Metadata * getModuleFlag(StringRef Key) const
Return the corresponding value if Key appears in module flags, otherwise return null.
Definition Module.cpp:358
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:308
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
std::string str() const
Get the contents as an std::string.
Definition StringRef.h:222
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)
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 ...
Interfaces for registering analysis passes, producing common pass manager configurations,...
Define some predicates that are used for node matching.
Definition ARMEHABI.h:25
@ ARM_AAPCS_VFP
Same as ARM_AAPCS, but uses hard floating point ABI.
@ DynamicNoPIC
Definition CodeGen.h:26
@ ARM
Windows AXP64.
Definition MCAsmInfo.h:50
initializer< Ty > init(const Ty &Val)
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 * createIfConverter(std::function< bool(const MachineFunction &)> Ftor)
LLVM_ABI FunctionPass * createTypePromotionLegacyPass()
Create IR Type Promotion pass.
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 initializeMVELaneInterleavingPass(PassRegistry &)
Pass * createMVEGatherScatterLoweringPass()
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 char & PostRASchedulerID
PostRAScheduler - This pass performs post register allocation scheduling.
LLVM_ABI Pass * createLowerAtomicPass()
FunctionPass * createARMISelDag(ARMBaseTargetMachine &TM, CodeGenOptLevel OptLevel)
createARMISelDag - This pass converts a legalized DAG into a ARM-specific DAG, ready for instruction ...
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()
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 &)
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:149
@ Default
-O2, -Os, -Oz
Definition CodeGen.h:152
FunctionPass * createARMLoadStoreOptLegacyPass(bool PreAlloc=false)
Returns an instance of the load / store optimization pass.
LLVM_ABI FunctionPass * createCFGuardLongjmpPass()
Creates CFGuard longjmp target identification pass.
void initializeARMExpandPseudoPass(PassRegistry &)
FunctionPass * createA15SDOptimizerPass()
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
void initializeARMSLSHardeningPass(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:316
void initializeARMLoadStoreOptLegacyPass(PassRegistry &)
LLVM_ABI char & MachinePipelinerID
This pass performs software pipelining on machine instructions.
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 initializeARMExecutionDomainFixPass(PassRegistry &)
LLVM_ABI FunctionPass * createEHContGuardTargetsPass()
Creates Windows EH Continuation Guard target identification pass.
void initializeThumb2SizeReducePass(PassRegistry &)
FunctionPass * createThumb2ITBlockPass()
createThumb2ITBlockPass - Returns an instance of the Thumb2 IT blocks insertion pass.
void initializeMVEGatherScatterLoweringPass(PassRegistry &)
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:390
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.
Target & getTheARMBETarget()
Target & getTheThumbLETarget()
FunctionPass * createMVEVPTBlockPass()
createMVEVPTBlock - Returns an instance of the MVE VPT block insertion pass.
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.