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"
15#include "ARMMachineFunctionInfo.h"
16#include "ARMMacroFusion.h"
17#include "ARMSubtarget.h"
18#include "ARMTargetObjectFile.h"
19#include "ARMTargetTransformInfo.h"
20#include "MCTargetDesc/ARMMCTargetDesc.h"
21#include "TargetInfo/ARMTargetInfo.h"
22#include "llvm/ADT/StringRef.h"
23#include "llvm/Analysis/TargetTransformInfo.h"
24#include "llvm/CodeGen/ExecutionDomainFix.h"
25#include "llvm/CodeGen/GlobalISel/CSEInfo.h"
26#include "llvm/CodeGen/GlobalISel/CallLowering.h"
27#include "llvm/CodeGen/GlobalISel/IRTranslator.h"
28#include "llvm/CodeGen/GlobalISel/InstructionSelect.h"
29#include "llvm/CodeGen/GlobalISel/Legalizer.h"
30#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
31#include "llvm/CodeGen/GlobalISel/RegBankSelect.h"
32#include "llvm/CodeGen/MIRParser/MIParser.h"
33#include "llvm/CodeGen/MachineFunction.h"
34#include "llvm/CodeGen/MachineScheduler.h"
35#include "llvm/CodeGen/Passes.h"
36#include "llvm/CodeGen/TargetPassConfig.h"
37#include "llvm/IR/Attributes.h"
38#include "llvm/IR/DataLayout.h"
39#include "llvm/IR/Function.h"
40#include "llvm/MC/TargetRegistry.h"
41#include "llvm/Pass.h"
42#include "llvm/Passes/PassBuilder.h"
43#include "llvm/Support/CodeGen.h"
44#include "llvm/Support/CommandLine.h"
45#include "llvm/Support/Compiler.h"
46#include "llvm/Support/ErrorHandling.h"
47#include "llvm/Target/TargetLoweringObjectFile.h"
48#include "llvm/Target/TargetOptions.h"
49#include "llvm/TargetParser/ARMTargetParser.h"
50#include "llvm/TargetParser/TargetParser.h"
51#include "llvm/TargetParser/Triple.h"
52#include "llvm/Transforms/CFGuard.h"
53#include "llvm/Transforms/IPO.h"
54#include "llvm/Transforms/Scalar.h"
55#include <cassert>
56#include <memory>
57#include <optional>
58#include <string>
59
60using namespace llvm;
61
62static cl::opt<bool>
63DisableA15SDOptimization("disable-a15-sd-optimization", cl::Hidden,
64 cl::desc("Inhibit optimization of S->D register accesses on A15"),
65 cl::init(Val: false));
66
67static cl::opt<bool>
68EnableAtomicTidy("arm-atomic-cfg-tidy", cl::Hidden,
69 cl::desc("Run SimplifyCFG after expanding atomic operations"
70 " to make use of cmpxchg flow-based information"),
71 cl::init(Val: true));
72
73static cl::opt<bool>
74EnableARMLoadStoreOpt("arm-load-store-opt", cl::Hidden,
75 cl::desc("Enable ARM load/store optimization pass"),
76 cl::init(Val: true));
77
78// FIXME: Unify control over GlobalMerge.
79static cl::opt<cl::boolOrDefault>
80EnableGlobalMerge("arm-global-merge", cl::Hidden,
81 cl::desc("Enable the global merge pass"));
82
83namespace llvm {
84 void initializeARMExecutionDomainFixPass(PassRegistry&);
85}
86
87extern "C" LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARMTarget() {
88 // Register the target.
89 RegisterTargetMachine<ARMLETargetMachine> X(getTheARMLETarget());
90 RegisterTargetMachine<ARMLETargetMachine> A(getTheThumbLETarget());
91 RegisterTargetMachine<ARMBETargetMachine> Y(getTheARMBETarget());
92 RegisterTargetMachine<ARMBETargetMachine> B(getTheThumbBETarget());
93
94 PassRegistry &Registry = *PassRegistry::getPassRegistry();
95 initializeGlobalISel(Registry);
96 initializeARMAsmPrinterPass(Registry);
97 initializeARMLoadStoreOptLegacyPass(Registry);
98 initializeARMPreAllocLoadStoreOptLegacyPass(Registry);
99 initializeARMParallelDSPPass(Registry);
100 initializeARMBranchTargetsPass(Registry);
101 initializeARMConstantIslandsPass(Registry);
102 initializeARMExecutionDomainFixPass(Registry);
103 initializeARMExpandPseudoPass(Registry);
104 initializeThumb2SizeReducePass(Registry);
105 initializeMVEVPTBlockPass(Registry);
106 initializeMVETPAndVPTOptimisationsPass(Registry);
107 initializeMVETailPredicationPass(Registry);
108 initializeARMLowOverheadLoopsPass(Registry);
109 initializeARMBlockPlacementPass(Registry);
110 initializeMVEGatherScatterLoweringPass(Registry);
111 initializeARMSLSHardeningPass(Registry);
112 initializeMVELaneInterleavingPass(Registry);
113 initializeARMFixCortexA57AES1742098Pass(Registry);
114 initializeARMDAGToDAGISelLegacyPass(Registry);
115 initializeMachineKCFILegacyPass(Registry);
116}
117
118static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
119 if (TT.isOSBinFormatMachO())
120 return std::make_unique<TargetLoweringObjectFileMachO>();
121 if (TT.isOSWindows())
122 return std::make_unique<TargetLoweringObjectFileCOFF>();
123 return std::make_unique<ARMElfTargetObjectFile>();
124}
125
126static Reloc::Model getEffectiveRelocModel(const Triple &TT,
127 std::optional<Reloc::Model> RM) {
128 if (!RM)
129 // Default relocation model on Darwin is PIC.
130 return TT.isOSBinFormatMachO() ? Reloc::PIC_ : Reloc::Static;
131
132 if (*RM == Reloc::ROPI || *RM == Reloc::RWPI || *RM == Reloc::ROPI_RWPI)
133 assert(TT.isOSBinFormatELF() &&
134 "ROPI/RWPI currently only supported for ELF");
135
136 // DynamicNoPIC is only used on darwin.
137 if (*RM == Reloc::DynamicNoPIC && !TT.isOSDarwin())
138 return Reloc::Static;
139
140 return *RM;
141}
142
143/// Create an ARM architecture model.
144///
145ARMBaseTargetMachine::ARMBaseTargetMachine(const Target &T, const Triple &TT,
146 StringRef CPU, StringRef FS,
147 const TargetOptions &Options,
148 std::optional<Reloc::Model> RM,
149 std::optional<CodeModel::Model> CM,
150 CodeGenOptLevel OL)
151 : CodeGenTargetMachineImpl(
152 T, TT.computeDataLayout(ABIName: Options.MCOptions.ABIName), TT, CPU, FS,
153 Options, getEffectiveRelocModel(TT, RM),
154 getEffectiveCodeModel(CM, Default: CodeModel::Small), OL),
155 TargetABI(ARM::computeTargetABI(TT, ABIName: Options.MCOptions.ABIName)),
156 TLOF(createTLOF(TT: getTargetTriple())), isLittle(TT.isLittleEndian()) {
157
158 // Default to triple-appropriate float ABI
159 if (Options.FloatABIType == FloatABI::Default) {
160 if (isTargetHardFloat())
161 this->Options.FloatABIType = FloatABI::Hard;
162 else
163 this->Options.FloatABIType = FloatABI::Soft;
164 }
165
166 // Default to triple-appropriate EABI
167 if (Options.EABIVersion == EABI::Default ||
168 Options.EABIVersion == EABI::Unknown) {
169 // musl is compatible with glibc with regard to EABI version
170 if ((TargetTriple.getEnvironment() == Triple::GNUEABI ||
171 TargetTriple.getEnvironment() == Triple::GNUEABIT64 ||
172 TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
173 TargetTriple.getEnvironment() == Triple::GNUEABIHFT64 ||
174 TargetTriple.getEnvironment() == Triple::MuslEABI ||
175 TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
176 TargetTriple.getEnvironment() == Triple::OpenHOS) &&
177 !(TargetTriple.isOSWindows() || TargetTriple.isOSDarwin()))
178 this->Options.EABIVersion = EABI::GNU;
179 else
180 this->Options.EABIVersion = EABI::EABI5;
181 }
182
183 if (TT.isOSBinFormatMachO()) {
184 this->Options.TrapUnreachable = true;
185 this->Options.NoTrapAfterNoreturn = true;
186 }
187
188 // ARM supports the debug entry values.
189 setSupportsDebugEntryValues(true);
190
191 initAsmInfo();
192
193 // ARM supports the MachineOutliner.
194 setMachineOutliner(true);
195 setSupportsDefaultOutlining(true);
196}
197
198ARMBaseTargetMachine::~ARMBaseTargetMachine() = default;
199
200MachineFunctionInfo *ARMBaseTargetMachine::createMachineFunctionInfo(
201 BumpPtrAllocator &Allocator, const Function &F,
202 const TargetSubtargetInfo *STI) const {
203 return ARMFunctionInfo::create<ARMFunctionInfo>(
204 Allocator, F, STI: static_cast<const ARMSubtarget *>(STI));
205}
206
207const ARMSubtarget *
208ARMBaseTargetMachine::getSubtargetImpl(const Function &F) const {
209 Attribute CPUAttr = F.getFnAttribute(Kind: "target-cpu");
210 Attribute FSAttr = F.getFnAttribute(Kind: "target-features");
211
212 std::string CPU =
213 CPUAttr.isValid() ? CPUAttr.getValueAsString().str() : TargetCPU;
214 std::string FS =
215 FSAttr.isValid() ? FSAttr.getValueAsString().str() : TargetFS;
216
217 // FIXME: This is related to the code below to reset the target options,
218 // we need to know whether or not the soft float flag is set on the
219 // function before we can generate a subtarget. We also need to use
220 // it as a key for the subtarget since that can be the only difference
221 // between two functions.
222 bool SoftFloat = F.getFnAttribute(Kind: "use-soft-float").getValueAsBool();
223 // If the soft float attribute is set on the function turn on the soft float
224 // subtarget feature.
225 if (SoftFloat)
226 FS += FS.empty() ? "+soft-float" : ",+soft-float";
227
228 // Use the optminsize to identify the subtarget, but don't use it in the
229 // feature string.
230 std::string Key = CPU + FS;
231 if (F.hasMinSize())
232 Key += "+minsize";
233
234 DenormalMode DM = F.getDenormalFPEnv().DefaultMode;
235 if (DM != DenormalMode::getIEEE())
236 Key += "denormal-fp-math=" + DM.str();
237
238 auto &I = SubtargetMap[Key];
239 if (!I) {
240 I = std::make_unique<ARMSubtarget>(args: TargetTriple, args&: CPU, args&: FS, args: *this, args: isLittle,
241 args: F.hasMinSize(), args&: DM);
242
243 if (!I->isThumb() && !I->hasARMOps())
244 F.getContext().emitError(ErrorStr: "Function '" + F.getName() + "' uses ARM "
245 "instructions, but the target does not support ARM mode execution.");
246 }
247
248 return I.get();
249}
250
251TargetTransformInfo
252ARMBaseTargetMachine::getTargetTransformInfo(const Function &F) const {
253 return TargetTransformInfo(std::make_unique<ARMTTIImpl>(args: this, args: F));
254}
255
256ScheduleDAGInstrs *
257ARMBaseTargetMachine::createMachineScheduler(MachineSchedContext *C) const {
258 ScheduleDAGMILive *DAG = createSchedLive(C);
259 // add DAG Mutations here.
260 const ARMSubtarget &ST = C->MF->getSubtarget<ARMSubtarget>();
261 if (ST.hasFusion())
262 DAG->addMutation(Mutation: createARMMacroFusionDAGMutation());
263 return DAG;
264}
265
266ScheduleDAGInstrs *
267ARMBaseTargetMachine::createPostMachineScheduler(MachineSchedContext *C) const {
268 ScheduleDAGMI *DAG = createSchedPostRA(C);
269 // add DAG Mutations here.
270 const ARMSubtarget &ST = C->MF->getSubtarget<ARMSubtarget>();
271 if (ST.hasFusion())
272 DAG->addMutation(Mutation: createARMMacroFusionDAGMutation());
273 if (auto Mutation = createARMLatencyMutations(ST, AA: C->AA))
274 DAG->addMutation(Mutation: std::move(Mutation));
275 return DAG;
276}
277
278ARMLETargetMachine::ARMLETargetMachine(const Target &T, const Triple &TT,
279 StringRef CPU, StringRef FS,
280 const TargetOptions &Options,
281 std::optional<Reloc::Model> RM,
282 std::optional<CodeModel::Model> CM,
283 CodeGenOptLevel OL, bool JIT)
284 : ARMBaseTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL) {}
285
286ARMBETargetMachine::ARMBETargetMachine(const Target &T, const Triple &TT,
287 StringRef CPU, StringRef FS,
288 const TargetOptions &Options,
289 std::optional<Reloc::Model> RM,
290 std::optional<CodeModel::Model> CM,
291 CodeGenOptLevel OL, bool JIT)
292 : ARMBaseTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL) {}
293
294namespace {
295
296/// ARM Code Generator Pass Configuration Options.
297class ARMPassConfig : public TargetPassConfig {
298public:
299 ARMPassConfig(ARMBaseTargetMachine &TM, PassManagerBase &PM)
300 : TargetPassConfig(TM, PM) {}
301
302 ARMBaseTargetMachine &getARMTargetMachine() const {
303 return getTM<ARMBaseTargetMachine>();
304 }
305
306 void addIRPasses() override;
307 void addCodeGenPrepare() override;
308 bool addPreISel() override;
309 bool addInstSelector() override;
310 bool addIRTranslator() override;
311 bool addLegalizeMachineIR() override;
312 bool addRegBankSelect() override;
313 bool addGlobalInstructionSelect() override;
314 void addPreRegAlloc() override;
315 void addPreSched2() override;
316 void addPreEmitPass() override;
317 void addPreEmitPass2() override;
318
319 std::unique_ptr<CSEConfigBase> getCSEConfig() const override;
320};
321
322class ARMExecutionDomainFix : public ExecutionDomainFix {
323public:
324 static char ID;
325 ARMExecutionDomainFix() : ExecutionDomainFix(ID, ARM::DPRRegClass) {}
326 StringRef getPassName() const override {
327 return "ARM Execution Domain Fix";
328 }
329};
330char ARMExecutionDomainFix::ID;
331
332} // end anonymous namespace
333
334INITIALIZE_PASS_BEGIN(ARMExecutionDomainFix, "arm-execution-domain-fix",
335 "ARM Execution Domain Fix", false, false)
336INITIALIZE_PASS_DEPENDENCY(ReachingDefInfoWrapperPass)
337INITIALIZE_PASS_END(ARMExecutionDomainFix, "arm-execution-domain-fix",
338 "ARM Execution Domain Fix", false, false)
339
340void ARMBaseTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
341#define GET_PASS_REGISTRY "ARMPassRegistry.def"
342#include "llvm/Passes/TargetPassRegistry.inc"
343}
344
345TargetPassConfig *ARMBaseTargetMachine::createPassConfig(PassManagerBase &PM) {
346 return new ARMPassConfig(*this, PM);
347}
348
349std::unique_ptr<CSEConfigBase> ARMPassConfig::getCSEConfig() const {
350 return getStandardCSEConfigForOpt(Level: TM->getOptLevel());
351}
352
353void ARMPassConfig::addIRPasses() {
354 if (TM->Options.ThreadModel == ThreadModel::Single)
355 addPass(P: createLowerAtomicPass());
356 else
357 addPass(P: createAtomicExpandLegacyPass());
358
359 // Cmpxchg instructions are often used with a subsequent comparison to
360 // determine whether it succeeded. We can exploit existing control-flow in
361 // ldrex/strex loops to simplify this, but it needs tidying up.
362 if (TM->getOptLevel() != CodeGenOptLevel::None && EnableAtomicTidy)
363 addPass(P: createCFGSimplificationPass(
364 Options: SimplifyCFGOptions().hoistCommonInsts(B: true).sinkCommonInsts(B: true),
365 Ftor: [this](const Function &F) {
366 const auto &ST = this->TM->getSubtarget<ARMSubtarget>(F);
367 return ST.hasAnyDataBarrier() && !ST.isThumb1Only();
368 }));
369
370 addPass(P: createMVEGatherScatterLoweringPass());
371 addPass(P: createMVELaneInterleavingPass());
372
373 TargetPassConfig::addIRPasses();
374
375 // Run the parallel DSP pass.
376 if (getOptLevel() == CodeGenOptLevel::Aggressive)
377 addPass(P: createARMParallelDSPPass());
378
379 // Match complex arithmetic patterns
380 if (TM->getOptLevel() >= CodeGenOptLevel::Default)
381 addPass(P: createComplexDeinterleavingPass(TM));
382
383 // Match interleaved memory accesses to ldN/stN intrinsics.
384 if (TM->getOptLevel() != CodeGenOptLevel::None)
385 addPass(P: createInterleavedAccessPass());
386
387 // Add Control Flow Guard checks.
388 if (TM->getTargetTriple().isOSWindows())
389 addPass(P: createCFGuardPass());
390
391 if (TM->Options.JMCInstrument)
392 addPass(P: createJMCInstrumenterPass());
393}
394
395void ARMPassConfig::addCodeGenPrepare() {
396 if (getOptLevel() != CodeGenOptLevel::None)
397 addPass(P: createTypePromotionLegacyPass());
398 TargetPassConfig::addCodeGenPrepare();
399}
400
401bool ARMPassConfig::addPreISel() {
402 if ((TM->getOptLevel() != CodeGenOptLevel::None &&
403 EnableGlobalMerge == cl::boolOrDefault::BOU_UNSET) ||
404 EnableGlobalMerge == cl::boolOrDefault::BOU_TRUE) {
405 // FIXME: This is using the thumb1 only constant value for
406 // maximal global offset for merging globals. We may want
407 // to look into using the old value for non-thumb1 code of
408 // 4095 based on the TargetMachine, but this starts to become
409 // tricky when doing code gen per function.
410 bool OnlyOptimizeForSize =
411 (TM->getOptLevel() < CodeGenOptLevel::Aggressive) &&
412 (EnableGlobalMerge == cl::boolOrDefault::BOU_UNSET);
413 // Merging of extern globals is enabled by default on non-Mach-O as we
414 // expect it to be generally either beneficial or harmless. On Mach-O it
415 // is disabled as we emit the .subsections_via_symbols directive which
416 // means that merging extern globals is not safe.
417 bool MergeExternalByDefault = !TM->getTargetTriple().isOSBinFormatMachO();
418 addPass(P: createGlobalMergePass(TM, MaximalOffset: 127, OnlyOptimizeForSize,
419 MergeExternalByDefault));
420 }
421
422 if (TM->getOptLevel() != CodeGenOptLevel::None) {
423 addPass(P: createHardwareLoopsLegacyPass());
424 addPass(P: createMVETailPredicationPass());
425 // FIXME: IR passes can delete address-taken basic blocks, deleting
426 // corresponding blockaddresses. ARMConstantPoolConstant holds references to
427 // address-taken basic blocks which can be invalidated if the function
428 // containing the blockaddress has already been codegen'd and the basic
429 // block is removed. Work around this by forcing all IR passes to run before
430 // any ISel takes place. We should have a more principled way of handling
431 // this. See D99707 for more details.
432 addPass(P: createBarrierNoopPass());
433 }
434
435 return false;
436}
437
438bool ARMPassConfig::addInstSelector() {
439 addPass(P: createARMISelDag(TM&: getARMTargetMachine(), OptLevel: getOptLevel()));
440 return false;
441}
442
443bool ARMPassConfig::addIRTranslator() {
444 addPass(P: new IRTranslator(getOptLevel()));
445 return false;
446}
447
448bool ARMPassConfig::addLegalizeMachineIR() {
449 addPass(P: new Legalizer());
450 return false;
451}
452
453bool ARMPassConfig::addRegBankSelect() {
454 addPass(P: new RegBankSelect());
455 return false;
456}
457
458bool ARMPassConfig::addGlobalInstructionSelect() {
459 addPass(P: new InstructionSelect(getOptLevel()));
460 return false;
461}
462
463void ARMPassConfig::addPreRegAlloc() {
464 if (getOptLevel() != CodeGenOptLevel::None) {
465 if (getOptLevel() == CodeGenOptLevel::Aggressive)
466 addPass(PassID: &MachinePipelinerID);
467
468 addPass(P: createMVETPAndVPTOptimisationsPass());
469
470 addPass(P: createMLxExpansionPass());
471
472 if (EnableARMLoadStoreOpt)
473 addPass(P: createARMLoadStoreOptLegacyPass(/* pre-register alloc */ PreAlloc: true));
474
475 if (!DisableA15SDOptimization)
476 addPass(P: createA15SDOptimizerPass());
477 }
478}
479
480void ARMPassConfig::addPreSched2() {
481 if (getOptLevel() != CodeGenOptLevel::None) {
482 if (EnableARMLoadStoreOpt)
483 addPass(P: createARMLoadStoreOptLegacyPass());
484
485 addPass(P: new ARMExecutionDomainFix());
486 addPass(P: createBreakFalseDepsLegacyPass());
487 }
488
489 // Expand some pseudo instructions into multiple instructions to allow
490 // proper scheduling.
491 addPass(P: createARMExpandPseudoPass());
492
493 // Emit KCFI checks for indirect calls.
494 addPass(P: createKCFIPass());
495
496 if (getOptLevel() != CodeGenOptLevel::None) {
497 // When optimising for size, always run the Thumb2SizeReduction pass before
498 // IfConversion. Otherwise, check whether IT blocks are restricted
499 // (e.g. in v8, IfConversion depends on Thumb instruction widths)
500 addPass(P: createThumb2SizeReductionPass(Ftor: [this](const Function &F) {
501 return this->TM->getSubtarget<ARMSubtarget>(F).hasMinSize() ||
502 this->TM->getSubtarget<ARMSubtarget>(F).restrictIT();
503 }));
504
505 addPass(P: createIfConverter(Ftor: [](const MachineFunction &MF) {
506 return !MF.getSubtarget<ARMSubtarget>().isThumb1Only();
507 }));
508 }
509 addPass(P: createThumb2ITBlockPass());
510
511 // Add both scheduling passes to give the subtarget an opportunity to pick
512 // between them.
513 if (getOptLevel() != CodeGenOptLevel::None) {
514 addPass(PassID: &PostMachineSchedulerID);
515 addPass(PassID: &PostRASchedulerID);
516 }
517
518 addPass(P: createMVEVPTBlockPass());
519 addPass(P: createARMIndirectThunks());
520 addPass(P: createARMSLSHardeningPass());
521}
522
523void ARMPassConfig::addPreEmitPass() {
524 addPass(P: createThumb2SizeReductionPass());
525
526 // Unpack bundles for:
527 // - Thumb2: Constant island pass requires unbundled instructions
528 // - KCFI: KCFI_CHECK pseudo instructions need to be unbundled for AsmPrinter
529 addPass(P: createUnpackMachineBundlesLegacy(Ftor: [](const MachineFunction &MF) {
530 return MF.getSubtarget<ARMSubtarget>().isThumb2() ||
531 MF.getFunction().getParent()->getModuleFlag(Key: "kcfi");
532 }));
533
534 // Don't optimize barriers or block placement at -O0.
535 if (getOptLevel() != CodeGenOptLevel::None) {
536 addPass(P: createARMBlockPlacementPass());
537 addPass(P: createARMOptimizeBarriersPass());
538 }
539}
540
541void ARMPassConfig::addPreEmitPass2() {
542
543 // Inserts fixup instructions before unsafe AES operations. Instructions may
544 // be inserted at the start of blocks and at within blocks so this pass has to
545 // come before those below.
546 addPass(P: createARMFixCortexA57AES1742098Pass());
547 // Inserts BTIs at the start of functions and indirectly-called basic blocks,
548 // so passes cannot add to the start of basic blocks once this has run.
549 addPass(P: createARMBranchTargetsPass());
550 // Inserts Constant Islands. Block sizes cannot be increased after this point,
551 // as this may push the branch ranges and load offsets of accessing constant
552 // pools out of range..
553 addPass(P: createARMConstantIslandPass());
554 // Finalises Low-Overhead Loops. This replaces pseudo instructions with real
555 // instructions, but the pseudos all have conservative sizes so that block
556 // sizes will only be decreased by this pass.
557 addPass(P: createARMLowOverheadLoopsPass());
558
559 if (TM->getTargetTriple().isOSWindows()) {
560 // Identify valid longjmp targets for Windows Control Flow Guard.
561 addPass(P: createCFGuardLongjmpPass());
562 // Identify valid eh continuation targets for Windows EHCont Guard.
563 addPass(P: createEHContGuardTargetsPass());
564 }
565}
566
567yaml::MachineFunctionInfo *
568ARMBaseTargetMachine::createDefaultFuncInfoYAML() const {
569 return new yaml::ARMFunctionInfo();
570}
571
572yaml::MachineFunctionInfo *
573ARMBaseTargetMachine::convertFuncInfoToYAML(const MachineFunction &MF) const {
574 const auto *MFI = MF.getInfo<ARMFunctionInfo>();
575 return new yaml::ARMFunctionInfo(*MFI);
576}
577
578bool ARMBaseTargetMachine::parseMachineFunctionInfo(
579 const yaml::MachineFunctionInfo &MFI, PerFunctionMIParsingState &PFS,
580 SMDiagnostic &Error, SMRange &SourceRange) const {
581 const auto &YamlMFI = static_cast<const yaml::ARMFunctionInfo &>(MFI);
582 MachineFunction &MF = PFS.MF;
583 MF.getInfo<ARMFunctionInfo>()->initializeBaseYamlFields(YamlMFI);
584 return false;
585}
586
587void ARMBaseTargetMachine::reset() { SubtargetMap.clear(); }
588