LLVM  16.0.0git
AArch64TargetMachine.cpp
Go to the documentation of this file.
1 //===-- AArch64TargetMachine.cpp - Define TargetMachine for AArch64 -------===//
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 "AArch64TargetMachine.h"
13 #include "AArch64.h"
16 #include "AArch64MacroFusion.h"
17 #include "AArch64Subtarget.h"
22 #include "llvm/ADT/STLExtras.h"
23 #include "llvm/ADT/Triple.h"
25 #include "llvm/CodeGen/CFIFixup.h"
36 #include "llvm/CodeGen/Passes.h"
39 #include "llvm/IR/Attributes.h"
40 #include "llvm/IR/Function.h"
41 #include "llvm/InitializePasses.h"
42 #include "llvm/MC/MCAsmInfo.h"
44 #include "llvm/MC/TargetRegistry.h"
45 #include "llvm/Pass.h"
46 #include "llvm/Support/CodeGen.h"
51 #include "llvm/Transforms/Scalar.h"
52 #include <memory>
53 #include <optional>
54 #include <string>
55 
56 using namespace llvm;
57 
58 static cl::opt<bool> EnableCCMP("aarch64-enable-ccmp",
59  cl::desc("Enable the CCMP formation pass"),
60  cl::init(true), cl::Hidden);
61 
62 static cl::opt<bool>
63  EnableCondBrTuning("aarch64-enable-cond-br-tune",
64  cl::desc("Enable the conditional branch tuning pass"),
65  cl::init(true), cl::Hidden);
66 
68  "aarch64-enable-copy-propagation",
69  cl::desc("Enable the copy propagation with AArch64 copy instr"),
70  cl::init(true), cl::Hidden);
71 
72 static cl::opt<bool> EnableMCR("aarch64-enable-mcr",
73  cl::desc("Enable the machine combiner pass"),
74  cl::init(true), cl::Hidden);
75 
76 static cl::opt<bool> EnableStPairSuppress("aarch64-enable-stp-suppress",
77  cl::desc("Suppress STP for AArch64"),
78  cl::init(true), cl::Hidden);
79 
81  "aarch64-enable-simd-scalar",
82  cl::desc("Enable use of AdvSIMD scalar integer instructions"),
83  cl::init(false), cl::Hidden);
84 
85 static cl::opt<bool>
86  EnablePromoteConstant("aarch64-enable-promote-const",
87  cl::desc("Enable the promote constant pass"),
88  cl::init(true), cl::Hidden);
89 
91  "aarch64-enable-collect-loh",
92  cl::desc("Enable the pass that emits the linker optimization hints (LOH)"),
93  cl::init(true), cl::Hidden);
94 
95 static cl::opt<bool>
96  EnableDeadRegisterElimination("aarch64-enable-dead-defs", cl::Hidden,
97  cl::desc("Enable the pass that removes dead"
98  " definitons and replaces stores to"
99  " them with stores to the zero"
100  " register"),
101  cl::init(true));
102 
104  "aarch64-enable-copyelim",
105  cl::desc("Enable the redundant copy elimination pass"), cl::init(true),
106  cl::Hidden);
107 
108 static cl::opt<bool> EnableLoadStoreOpt("aarch64-enable-ldst-opt",
109  cl::desc("Enable the load/store pair"
110  " optimization pass"),
111  cl::init(true), cl::Hidden);
112 
114  "aarch64-enable-atomic-cfg-tidy", cl::Hidden,
115  cl::desc("Run SimplifyCFG after expanding atomic operations"
116  " to make use of cmpxchg flow-based information"),
117  cl::init(true));
118 
119 static cl::opt<bool>
120 EnableEarlyIfConversion("aarch64-enable-early-ifcvt", cl::Hidden,
121  cl::desc("Run early if-conversion"),
122  cl::init(true));
123 
124 static cl::opt<bool>
125  EnableCondOpt("aarch64-enable-condopt",
126  cl::desc("Enable the condition optimizer pass"),
127  cl::init(true), cl::Hidden);
128 
129 static cl::opt<bool>
130  EnableGEPOpt("aarch64-enable-gep-opt", cl::Hidden,
131  cl::desc("Enable optimizations on complex GEPs"),
132  cl::init(false));
133 
134 static cl::opt<bool>
135  EnableSelectOpt("aarch64-select-opt", cl::Hidden,
136  cl::desc("Enable select to branch optimizations"),
137  cl::init(true));
138 
139 static cl::opt<bool>
140  BranchRelaxation("aarch64-enable-branch-relax", cl::Hidden, cl::init(true),
141  cl::desc("Relax out of range conditional branches"));
142 
144  "aarch64-enable-compress-jump-tables", cl::Hidden, cl::init(true),
145  cl::desc("Use smallest entry possible for jump tables"));
146 
147 // FIXME: Unify control over GlobalMerge.
149  EnableGlobalMerge("aarch64-enable-global-merge", cl::Hidden,
150  cl::desc("Enable the global merge pass"));
151 
152 static cl::opt<bool>
153  EnableLoopDataPrefetch("aarch64-enable-loop-data-prefetch", cl::Hidden,
154  cl::desc("Enable the loop data prefetch pass"),
155  cl::init(true));
156 
158  "aarch64-enable-global-isel-at-O", cl::Hidden,
159  cl::desc("Enable GlobalISel at or below an opt level (-1 to disable)"),
160  cl::init(0));
161 
162 static cl::opt<bool>
163  EnableSVEIntrinsicOpts("aarch64-enable-sve-intrinsic-opts", cl::Hidden,
164  cl::desc("Enable SVE intrinsic opts"),
165  cl::init(true));
166 
167 static cl::opt<bool> EnableFalkorHWPFFix("aarch64-enable-falkor-hwpf-fix",
168  cl::init(true), cl::Hidden);
169 
170 static cl::opt<bool>
171  EnableBranchTargets("aarch64-enable-branch-targets", cl::Hidden,
172  cl::desc("Enable the AArch64 branch target pass"),
173  cl::init(true));
174 
176  "aarch64-sve-vector-bits-max",
177  cl::desc("Assume SVE vector registers are at most this big, "
178  "with zero meaning no maximum size is assumed."),
179  cl::init(0), cl::Hidden);
180 
182  "aarch64-sve-vector-bits-min",
183  cl::desc("Assume SVE vector registers are at least this big, "
184  "with zero meaning no minimum size is assumed."),
185  cl::init(0), cl::Hidden);
186 
188 
190  "aarch64-enable-gisel-ldst-prelegal",
191  cl::desc("Enable GlobalISel's pre-legalizer load/store optimization pass"),
192  cl::init(true), cl::Hidden);
193 
195  "aarch64-enable-gisel-ldst-postlegal",
196  cl::desc("Enable GlobalISel's post-legalizer load/store optimization pass"),
197  cl::init(false), cl::Hidden);
198 
200  // Register the target.
206  auto PR = PassRegistry::getPassRegistry();
240 }
241 
242 //===----------------------------------------------------------------------===//
243 // AArch64 Lowering public interface.
244 //===----------------------------------------------------------------------===//
245 static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
246  if (TT.isOSBinFormatMachO())
247  return std::make_unique<AArch64_MachoTargetObjectFile>();
248  if (TT.isOSBinFormatCOFF())
249  return std::make_unique<AArch64_COFFTargetObjectFile>();
250 
251  return std::make_unique<AArch64_ELFTargetObjectFile>();
252 }
253 
254 // Helper function to build a DataLayout string
255 static std::string computeDataLayout(const Triple &TT,
256  const MCTargetOptions &Options,
257  bool LittleEndian) {
258  if (TT.isOSBinFormatMachO()) {
259  if (TT.getArch() == Triple::aarch64_32)
260  return "e-m:o-p:32:32-i64:64-i128:128-n32:64-S128";
261  return "e-m:o-i64:64-i128:128-n32:64-S128";
262  }
263  if (TT.isOSBinFormatCOFF())
264  return "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128";
265  std::string Endian = LittleEndian ? "e" : "E";
266  std::string Ptr32 = TT.getEnvironment() == Triple::GNUILP32 ? "-p:32:32" : "";
267  return Endian + "-m:e" + Ptr32 +
268  "-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128";
269 }
270 
271 static StringRef computeDefaultCPU(const Triple &TT, StringRef CPU) {
272  if (CPU.empty() && TT.isArm64e())
273  return "apple-a12";
274  return CPU;
275 }
276 
278  std::optional<Reloc::Model> RM) {
279  // AArch64 Darwin and Windows are always PIC.
280  if (TT.isOSDarwin() || TT.isOSWindows())
281  return Reloc::PIC_;
282  // On ELF platforms the default static relocation model has a smart enough
283  // linker to cope with referencing external symbols defined in a shared
284  // library. Hence DynamicNoPIC doesn't need to be promoted to PIC.
285  if (!RM || *RM == Reloc::DynamicNoPIC)
286  return Reloc::Static;
287  return *RM;
288 }
289 
290 static CodeModel::Model
292  std::optional<CodeModel::Model> CM, bool JIT) {
293  if (CM) {
294  if (*CM != CodeModel::Small && *CM != CodeModel::Tiny &&
295  *CM != CodeModel::Large) {
297  "Only small, tiny and large code models are allowed on AArch64");
298  } else if (*CM == CodeModel::Tiny && !TT.isOSBinFormatELF())
299  report_fatal_error("tiny code model is only supported on ELF");
300  return *CM;
301  }
302  // The default MCJIT memory managers make no guarantees about where they can
303  // find an executable page; JITed code needs to be able to refer to globals
304  // no matter how far away they are.
305  // We should set the CodeModel::Small for Windows ARM64 in JIT mode,
306  // since with large code model LLVM generating 4 MOV instructions, and
307  // Windows doesn't support relocating these long branch (4 MOVs).
308  if (JIT && !TT.isOSWindows())
309  return CodeModel::Large;
310  return CodeModel::Small;
311 }
312 
313 /// Create an AArch64 architecture model.
314 ///
316  StringRef CPU, StringRef FS,
317  const TargetOptions &Options,
318  std::optional<Reloc::Model> RM,
319  std::optional<CodeModel::Model> CM,
320  CodeGenOpt::Level OL, bool JIT,
321  bool LittleEndian)
323  computeDataLayout(TT, Options.MCOptions, LittleEndian),
324  TT, computeDefaultCPU(TT, CPU), FS, Options,
326  getEffectiveAArch64CodeModel(TT, CM, JIT), OL),
327  TLOF(createTLOF(getTargetTriple())), isLittle(LittleEndian) {
328  initAsmInfo();
329 
330  if (TT.isOSBinFormatMachO()) {
331  this->Options.TrapUnreachable = true;
332  this->Options.NoTrapAfterNoreturn = true;
333  }
334 
335  if (getMCAsmInfo()->usesWindowsCFI()) {
336  // Unwinding can get confused if the last instruction in an
337  // exception-handling region (function, funclet, try block, etc.)
338  // is a call.
339  //
340  // FIXME: We could elide the trap if the next instruction would be in
341  // the same region anyway.
342  this->Options.TrapUnreachable = true;
343  }
344 
345  if (this->Options.TLSSize == 0) // default
346  this->Options.TLSSize = 24;
347  if ((getCodeModel() == CodeModel::Small ||
349  this->Options.TLSSize > 32)
350  // for the small (and kernel) code model, the maximum TLS size is 4GiB
351  this->Options.TLSSize = 32;
352  else if (getCodeModel() == CodeModel::Tiny && this->Options.TLSSize > 24)
353  // for the tiny code model, the maximum TLS size is 1MiB (< 16MiB)
354  this->Options.TLSSize = 24;
355 
356  // Enable GlobalISel at or below EnableGlobalISelAt0, unless this is
357  // MachO/CodeModel::Large, which GlobalISel does not support.
358  if (getOptLevel() <= EnableGlobalISelAtO &&
359  TT.getArch() != Triple::aarch64_32 &&
360  TT.getEnvironment() != Triple::GNUILP32 &&
361  !(getCodeModel() == CodeModel::Large && TT.isOSBinFormatMachO())) {
362  setGlobalISel(true);
364  }
365 
366  // AArch64 supports the MachineOutliner.
367  setMachineOutliner(true);
368 
369  // AArch64 supports default outlining behaviour.
371 
372  // AArch64 supports the debug entry values.
374 
375  // AArch64 supports fixing up the DWARF unwind information.
376  if (!getMCAsmInfo()->usesWindowsCFI())
377  setCFIFixup(true);
378 }
379 
381 
382 const AArch64Subtarget *
384  Attribute CPUAttr = F.getFnAttribute("target-cpu");
385  Attribute TuneAttr = F.getFnAttribute("tune-cpu");
386  Attribute FSAttr = F.getFnAttribute("target-features");
387 
388  std::string CPU =
389  CPUAttr.isValid() ? CPUAttr.getValueAsString().str() : TargetCPU;
390  std::string TuneCPU =
391  TuneAttr.isValid() ? TuneAttr.getValueAsString().str() : CPU;
392  std::string FS =
393  FSAttr.isValid() ? FSAttr.getValueAsString().str() : TargetFS;
394 
396 
397  bool StreamingSVEModeDisabled =
398  !F.hasFnAttribute("aarch64_pstate_sm_enabled") &&
399  !F.hasFnAttribute("aarch64_pstate_sm_compatible") &&
400  !F.hasFnAttribute("aarch64_pstate_sm_body");
401 
402  unsigned MinSVEVectorSize = 0;
403  unsigned MaxSVEVectorSize = 0;
404  Attribute VScaleRangeAttr = F.getFnAttribute(Attribute::VScaleRange);
405  if (VScaleRangeAttr.isValid()) {
406  std::optional<unsigned> VScaleMax = VScaleRangeAttr.getVScaleRangeMax();
407  MinSVEVectorSize = VScaleRangeAttr.getVScaleRangeMin() * 128;
408  MaxSVEVectorSize = VScaleMax ? *VScaleMax * 128 : 0;
409  } else {
410  MinSVEVectorSize = SVEVectorBitsMinOpt;
411  MaxSVEVectorSize = SVEVectorBitsMaxOpt;
412  }
413 
414  assert(MinSVEVectorSize % 128 == 0 &&
415  "SVE requires vector length in multiples of 128!");
416  assert(MaxSVEVectorSize % 128 == 0 &&
417  "SVE requires vector length in multiples of 128!");
418  assert((MaxSVEVectorSize >= MinSVEVectorSize || MaxSVEVectorSize == 0) &&
419  "Minimum SVE vector size should not be larger than its maximum!");
420 
421  // Sanitize user input in case of no asserts
422  if (MaxSVEVectorSize == 0)
423  MinSVEVectorSize = (MinSVEVectorSize / 128) * 128;
424  else {
425  MinSVEVectorSize =
426  (std::min(MinSVEVectorSize, MaxSVEVectorSize) / 128) * 128;
427  MaxSVEVectorSize =
428  (std::max(MinSVEVectorSize, MaxSVEVectorSize) / 128) * 128;
429  }
430 
431  Key += "SVEMin";
432  Key += std::to_string(MinSVEVectorSize);
433  Key += "SVEMax";
434  Key += std::to_string(MaxSVEVectorSize);
435  Key += "StreamingSVEModeDisabled=" + std::to_string(StreamingSVEModeDisabled);
436  Key += CPU;
437  Key += TuneCPU;
438  Key += FS;
439 
440  auto &I = SubtargetMap[Key];
441  if (!I) {
442  // This needs to be done before we create a new subtarget since any
443  // creation will depend on the TM and the code generation flags on the
444  // function that reside in TargetOptions.
446  I = std::make_unique<AArch64Subtarget>(
447  TargetTriple, CPU, TuneCPU, FS, *this, isLittle, MinSVEVectorSize,
448  MaxSVEVectorSize, StreamingSVEModeDisabled);
449  }
450  return I.get();
451 }
452 
453 void AArch64leTargetMachine::anchor() { }
454 
456  const Target &T, const Triple &TT, StringRef CPU, StringRef FS,
457  const TargetOptions &Options, std::optional<Reloc::Model> RM,
458  std::optional<CodeModel::Model> CM, CodeGenOpt::Level OL, bool JIT)
459  : AArch64TargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, true) {}
460 
461 void AArch64beTargetMachine::anchor() { }
462 
464  const Target &T, const Triple &TT, StringRef CPU, StringRef FS,
465  const TargetOptions &Options, std::optional<Reloc::Model> RM,
466  std::optional<CodeModel::Model> CM, CodeGenOpt::Level OL, bool JIT)
467  : AArch64TargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, false) {}
468 
469 namespace {
470 
471 /// AArch64 Code Generator Pass Configuration Options.
472 class AArch64PassConfig : public TargetPassConfig {
473 public:
474  AArch64PassConfig(AArch64TargetMachine &TM, PassManagerBase &PM)
475  : TargetPassConfig(TM, PM) {
476  if (TM.getOptLevel() != CodeGenOpt::None)
477  substitutePass(&PostRASchedulerID, &PostMachineSchedulerID);
478  }
479 
480  AArch64TargetMachine &getAArch64TargetMachine() const {
481  return getTM<AArch64TargetMachine>();
482  }
483 
485  createMachineScheduler(MachineSchedContext *C) const override {
486  const AArch64Subtarget &ST = C->MF->getSubtarget<AArch64Subtarget>();
488  DAG->addMutation(createLoadClusterDAGMutation(DAG->TII, DAG->TRI));
489  DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
490  if (ST.hasFusion())
491  DAG->addMutation(createAArch64MacroFusionDAGMutation());
492  return DAG;
493  }
494 
496  createPostMachineScheduler(MachineSchedContext *C) const override {
497  const AArch64Subtarget &ST = C->MF->getSubtarget<AArch64Subtarget>();
498  ScheduleDAGMI *DAG =
499  new ScheduleDAGMI(C, std::make_unique<AArch64PostRASchedStrategy>(C),
500  /* RemoveKillFlags=*/true);
501  if (ST.hasFusion()) {
502  // Run the Macro Fusion after RA again since literals are expanded from
503  // pseudos then (v. addPreSched2()).
504  DAG->addMutation(createAArch64MacroFusionDAGMutation());
505  return DAG;
506  }
507 
508  return DAG;
509  }
510 
511  void addIRPasses() override;
512  bool addPreISel() override;
513  void addCodeGenPrepare() override;
514  bool addInstSelector() override;
515  bool addIRTranslator() override;
516  void addPreLegalizeMachineIR() override;
517  bool addLegalizeMachineIR() override;
518  void addPreRegBankSelect() override;
519  bool addRegBankSelect() override;
520  void addPreGlobalInstructionSelect() override;
521  bool addGlobalInstructionSelect() override;
522  void addMachineSSAOptimization() override;
523  bool addILPOpts() override;
524  void addPreRegAlloc() override;
525  void addPostRegAlloc() override;
526  void addPreSched2() override;
527  void addPreEmitPass() override;
528  void addPreEmitPass2() override;
529 
530  std::unique_ptr<CSEConfigBase> getCSEConfig() const override;
531 };
532 
533 } // end anonymous namespace
534 
537  return TargetTransformInfo(AArch64TTIImpl(this, F));
538 }
539 
541  return new AArch64PassConfig(*this, PM);
542 }
543 
544 std::unique_ptr<CSEConfigBase> AArch64PassConfig::getCSEConfig() const {
545  return getStandardCSEConfigForOpt(TM->getOptLevel());
546 }
547 
548 void AArch64PassConfig::addIRPasses() {
549  // Always expand atomic operations, we don't deal with atomicrmw or cmpxchg
550  // ourselves.
551  addPass(createAtomicExpandPass());
552 
553  // Expand any SVE vector library calls that we can't code generate directly.
554  if (EnableSVEIntrinsicOpts && TM->getOptLevel() == CodeGenOpt::Aggressive)
555  addPass(createSVEIntrinsicOptsPass());
556 
557  // Cmpxchg instructions are often used with a subsequent comparison to
558  // determine whether it succeeded. We can exploit existing control-flow in
559  // ldrex/strex loops to simplify this, but it needs tidying up.
560  if (TM->getOptLevel() != CodeGenOpt::None && EnableAtomicTidy)
562  .forwardSwitchCondToPhi(true)
563  .convertSwitchRangeToICmp(true)
564  .convertSwitchToLookupTable(true)
565  .needCanonicalLoops(false)
566  .hoistCommonInsts(true)
567  .sinkCommonInsts(true)));
568 
569  // Run LoopDataPrefetch
570  //
571  // Run this before LSR to remove the multiplies involved in computing the
572  // pointer values N iterations ahead.
573  if (TM->getOptLevel() != CodeGenOpt::None) {
575  addPass(createLoopDataPrefetchPass());
578  }
579 
580  if (TM->getOptLevel() == CodeGenOpt::Aggressive && EnableGEPOpt) {
581  // Call SeparateConstOffsetFromGEP pass to extract constants within indices
582  // and lower a GEP with multiple indices to either arithmetic operations or
583  // multiple GEPs with single index.
585  // Call EarlyCSE pass to find and remove subexpressions in the lowered
586  // result.
587  addPass(createEarlyCSEPass());
588  // Do loop invariant code motion in case part of the lowered result is
589  // invariant.
590  addPass(createLICMPass());
591  }
592 
594 
595  if (getOptLevel() == CodeGenOpt::Aggressive && EnableSelectOpt)
596  addPass(createSelectOptimizePass());
597 
599  /*IsOptNone=*/TM->getOptLevel() == CodeGenOpt::None));
600 
601  // Match complex arithmetic patterns
602  if (TM->getOptLevel() >= CodeGenOpt::Default)
604 
605  // Match interleaved memory accesses to ldN/stN intrinsics.
606  if (TM->getOptLevel() != CodeGenOpt::None) {
608  addPass(createInterleavedAccessPass());
609  }
610 
611  // Expand any functions marked with SME attributes which require special
612  // changes for the calling convention or that require the lazy-saving
613  // mechanism specified in the SME ABI.
614  addPass(createSMEABIPass());
615 
616  // Add Control Flow Guard checks.
617  if (TM->getTargetTriple().isOSWindows())
618  addPass(createCFGuardCheckPass());
619 
620  if (TM->Options.JMCInstrument)
621  addPass(createJMCInstrumenterPass());
622 }
623 
624 // Pass Pipeline Configuration
625 bool AArch64PassConfig::addPreISel() {
626  // Run promote constant before global merge, so that the promoted constants
627  // get a chance to be merged
628  if (TM->getOptLevel() != CodeGenOpt::None && EnablePromoteConstant)
630  // FIXME: On AArch64, this depends on the type.
631  // Basically, the addressable offsets are up to 4095 * Ty.getSizeInBytes().
632  // and the offset has to be a multiple of the related size in bytes.
633  if ((TM->getOptLevel() != CodeGenOpt::None &&
636  bool OnlyOptimizeForSize = (TM->getOptLevel() < CodeGenOpt::Aggressive) &&
638 
639  // Merging of extern globals is enabled by default on non-Mach-O as we
640  // expect it to be generally either beneficial or harmless. On Mach-O it
641  // is disabled as we emit the .subsections_via_symbols directive which
642  // means that merging extern globals is not safe.
643  bool MergeExternalByDefault = !TM->getTargetTriple().isOSBinFormatMachO();
644 
645  // FIXME: extern global merging is only enabled when we optimise for size
646  // because there are some regressions with it also enabled for performance.
647  if (!OnlyOptimizeForSize)
648  MergeExternalByDefault = false;
649 
650  addPass(createGlobalMergePass(TM, 4095, OnlyOptimizeForSize,
651  MergeExternalByDefault));
652  }
653 
654  return false;
655 }
656 
657 void AArch64PassConfig::addCodeGenPrepare() {
658  if (getOptLevel() != CodeGenOpt::None)
659  addPass(createTypePromotionPass());
661 }
662 
663 bool AArch64PassConfig::addInstSelector() {
664  addPass(createAArch64ISelDag(getAArch64TargetMachine(), getOptLevel()));
665 
666  // For ELF, cleanup any local-dynamic TLS accesses (i.e. combine as many
667  // references to _TLS_MODULE_BASE_ as possible.
668  if (TM->getTargetTriple().isOSBinFormatELF() &&
669  getOptLevel() != CodeGenOpt::None)
671 
672  return false;
673 }
674 
675 bool AArch64PassConfig::addIRTranslator() {
676  addPass(new IRTranslator(getOptLevel()));
677  return false;
678 }
679 
680 void AArch64PassConfig::addPreLegalizeMachineIR() {
681  if (getOptLevel() == CodeGenOpt::None)
683  else {
686  addPass(new LoadStoreOpt());
687  }
688 }
689 
690 bool AArch64PassConfig::addLegalizeMachineIR() {
691  addPass(new Legalizer());
692  return false;
693 }
694 
695 void AArch64PassConfig::addPreRegBankSelect() {
696  bool IsOptNone = getOptLevel() == CodeGenOpt::None;
697  if (!IsOptNone) {
698  addPass(createAArch64PostLegalizerCombiner(IsOptNone));
700  addPass(new LoadStoreOpt());
701  }
703 }
704 
705 bool AArch64PassConfig::addRegBankSelect() {
706  addPass(new RegBankSelect());
707  return false;
708 }
709 
710 void AArch64PassConfig::addPreGlobalInstructionSelect() {
711  addPass(new Localizer());
712 }
713 
714 bool AArch64PassConfig::addGlobalInstructionSelect() {
715  addPass(new InstructionSelect(getOptLevel()));
716  if (getOptLevel() != CodeGenOpt::None)
718  return false;
719 }
720 
721 void AArch64PassConfig::addMachineSSAOptimization() {
722  // Run default MachineSSAOptimization first.
724 
725  if (TM->getOptLevel() != CodeGenOpt::None)
727 }
728 
729 bool AArch64PassConfig::addILPOpts() {
730  if (EnableCondOpt)
732  if (EnableCCMP)
734  if (EnableMCR)
735  addPass(&MachineCombinerID);
736  if (EnableCondBrTuning)
737  addPass(createAArch64CondBrTuning());
739  addPass(&EarlyIfConverterID);
743  if (TM->getOptLevel() != CodeGenOpt::None)
745  return true;
746 }
747 
748 void AArch64PassConfig::addPreRegAlloc() {
749  // Change dead register definitions to refer to the zero register.
750  if (TM->getOptLevel() != CodeGenOpt::None && EnableDeadRegisterElimination)
752 
753  // Use AdvSIMD scalar instructions whenever profitable.
754  if (TM->getOptLevel() != CodeGenOpt::None && EnableAdvSIMDScalar) {
755  addPass(createAArch64AdvSIMDScalar());
756  // The AdvSIMD pass may produce copies that can be rewritten to
757  // be register coalescer friendly.
758  addPass(&PeepholeOptimizerID);
759  }
760 }
761 
762 void AArch64PassConfig::addPostRegAlloc() {
763  // Remove redundant copy instructions.
764  if (TM->getOptLevel() != CodeGenOpt::None && EnableRedundantCopyElimination)
766 
767  if (TM->getOptLevel() != CodeGenOpt::None && usingDefaultRegAlloc())
768  // Improve performance for some FP/SIMD code for A57.
770 }
771 
772 void AArch64PassConfig::addPreSched2() {
773  // Lower homogeneous frame instructions
776  // Expand some pseudo instructions to allow proper scheduling.
778  // Use load/store pair instructions when possible.
779  if (TM->getOptLevel() != CodeGenOpt::None) {
780  if (EnableLoadStoreOpt)
782  }
783  // Emit KCFI checks for indirect calls.
784  addPass(createAArch64KCFIPass());
785 
786  // The AArch64SpeculationHardeningPass destroys dominator tree and natural
787  // loop info, which is needed for the FalkorHWPFFixPass and also later on.
788  // Therefore, run the AArch64SpeculationHardeningPass before the
789  // FalkorHWPFFixPass to avoid recomputing dominator tree and natural loop
790  // info.
792 
793  addPass(createAArch64IndirectThunks());
795 
796  if (TM->getOptLevel() != CodeGenOpt::None) {
798  addPass(createFalkorHWPFFixPass());
799  }
800 }
801 
802 void AArch64PassConfig::addPreEmitPass() {
803  // Machine Block Placement might have created new opportunities when run
804  // at O3, where the Tail Duplication Threshold is set to 4 instructions.
805  // Run the load/store optimizer once more.
806  if (TM->getOptLevel() >= CodeGenOpt::Aggressive && EnableLoadStoreOpt)
808 
809  if (TM->getOptLevel() >= CodeGenOpt::Aggressive &&
811  addPass(createMachineCopyPropagationPass(true));
812 
813  addPass(createAArch64A53Fix835769());
814 
817 
818  // Relax conditional branch instructions if they're otherwise out of
819  // range of their destination.
820  if (BranchRelaxation)
821  addPass(&BranchRelaxationPassID);
822 
823  if (TM->getTargetTriple().isOSWindows()) {
824  // Identify valid longjmp targets for Windows Control Flow Guard.
825  addPass(createCFGuardLongjmpPass());
826  // Identify valid eh continuation targets for Windows EHCont Guard.
828  }
829 
830  if (TM->getOptLevel() != CodeGenOpt::None && EnableCompressJumpTables)
832 
833  if (TM->getOptLevel() != CodeGenOpt::None && EnableCollectLOH &&
834  TM->getTargetTriple().isOSBinFormatMachO())
835  addPass(createAArch64CollectLOHPass());
836 }
837 
838 void AArch64PassConfig::addPreEmitPass2() {
839  // SVE bundles move prefixes with destructive operations. BLR_RVMARKER pseudo
840  // instructions are lowered to bundles as well.
841  addPass(createUnpackMachineBundles(nullptr));
842 }
843 
846  return new yaml::AArch64FunctionInfo();
847 }
848 
851  const auto *MFI = MF.getInfo<AArch64FunctionInfo>();
852  return new yaml::AArch64FunctionInfo(*MFI);
853 }
854 
857  SMDiagnostic &Error, SMRange &SourceRange) const {
858  const auto &YamlMFI = static_cast<const yaml::AArch64FunctionInfo &>(MFI);
859  MachineFunction &MF = PFS.MF;
860  MF.getInfo<AArch64FunctionInfo>()->initializeBaseYamlFields(YamlMFI);
861  return false;
862 }
llvm::initializeAArch64A57FPLoadBalancingPass
void initializeAArch64A57FPLoadBalancingPass(PassRegistry &)
llvm::createJMCInstrumenterPass
ModulePass * createJMCInstrumenterPass()
JMC instrument pass.
computeDefaultCPU
static StringRef computeDefaultCPU(const Triple &TT, StringRef CPU)
Definition: AArch64TargetMachine.cpp:271
createTLOF
static std::unique_ptr< TargetLoweringObjectFile > createTLOF(const Triple &TT)
Definition: AArch64TargetMachine.cpp:245
llvm::TargetMachine::getOptLevel
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
Definition: TargetMachine.cpp:182
EnableBranchTargets
static cl::opt< bool > EnableBranchTargets("aarch64-enable-branch-targets", cl::Hidden, cl::desc("Enable the AArch64 branch target pass"), cl::init(true))
EnableStPairSuppress
static cl::opt< bool > EnableStPairSuppress("aarch64-enable-stp-suppress", cl::desc("Suppress STP for AArch64"), cl::init(true), cl::Hidden)
llvm::createAArch64LowerHomogeneousPrologEpilogPass
ModulePass * createAArch64LowerHomogeneousPrologEpilogPass()
Definition: AArch64LowerHomogeneousPrologEpilog.cpp:612
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
AArch64MachineFunctionInfo.h
llvm::Attribute::isValid
bool isValid() const
Return true if the attribute is any kind of attribute.
Definition: Attributes.h:185
llvm::initializeAArch64StackTaggingPass
void initializeAArch64StackTaggingPass(PassRegistry &)
llvm::createMachineCopyPropagationPass
MachineFunctionPass * createMachineCopyPropagationPass(bool UseCopyInstr)
Definition: MachineCopyPropagation.cpp:1030
llvm::createSeparateConstOffsetFromGEPPass
FunctionPass * createSeparateConstOffsetFromGEPPass(bool LowerGEP=false)
Definition: SeparateConstOffsetFromGEP.cpp:498
AArch64.h
llvm::Triple::GNUILP32
@ GNUILP32
Definition: Triple.h:239
llvm::createAArch64KCFIPass
FunctionPass * createAArch64KCFIPass()
Definition: AArch64KCFI.cpp:55
llvm::createAArch64PromoteConstantPass
ModulePass * createAArch64PromoteConstantPass()
Definition: AArch64PromoteConstant.cpp:235
MCTargetOptions.h
llvm::PeepholeOptimizerID
char & PeepholeOptimizerID
PeepholeOptimizer - This pass performs peephole optimizations - like extension and comparison elimina...
Definition: PeepholeOptimizer.cpp:443
llvm::initializeAArch64BranchTargetsPass
void initializeAArch64BranchTargetsPass(PassRegistry &)
llvm::TargetOptions
Definition: TargetOptions.h:124
Scalar.h
T
llvm::initializeAArch64O0PreLegalizerCombinerPass
void initializeAArch64O0PreLegalizerCombinerPass(PassRegistry &)
llvm::Function
Definition: Function.h:60
EnableSelectOpt
static cl::opt< bool > EnableSelectOpt("aarch64-select-opt", cl::Hidden, cl::desc("Enable select to branch optimizations"), cl::init(true))
llvm::Attribute
Definition: Attributes.h:67
Pass.h
llvm::yaml::MachineFunctionInfo
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.
Definition: MIRYamlMapping.h:677
EnableGlobalISelAtO
static cl::opt< int > EnableGlobalISelAtO("aarch64-enable-global-isel-at-O", cl::Hidden, cl::desc("Enable GlobalISel at or below an opt level (-1 to disable)"), cl::init(0))
CSEConfigBase.h
llvm::createAArch64SpeculationHardeningPass
FunctionPass * createAArch64SpeculationHardeningPass()
Returns an instance of the pseudo instruction expansion pass.
Definition: AArch64SpeculationHardening.cpp:700
llvm::createCFGSimplificationPass
FunctionPass * createCFGSimplificationPass(SimplifyCFGOptions Options=SimplifyCFGOptions(), std::function< bool(const Function &)> Ftor=nullptr)
Definition: SimplifyCFGPass.cpp:432
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:149
EnableRedundantCopyElimination
static cl::opt< bool > EnableRedundantCopyElimination("aarch64-enable-copyelim", cl::desc("Enable the redundant copy elimination pass"), cl::init(true), cl::Hidden)
llvm::RISCVFenceField::W
@ W
Definition: RISCVBaseInfo.h:266
EnableCompressJumpTables
static cl::opt< bool > EnableCompressJumpTables("aarch64-enable-compress-jump-tables", cl::Hidden, cl::init(true), cl::desc("Use smallest entry possible for jump tables"))
llvm::TargetTransformInfo
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Definition: TargetTransformInfo.h:173
llvm::initializeAArch64DeadRegisterDefinitionsPass
void initializeAArch64DeadRegisterDefinitionsPass(PassRegistry &)
llvm::createAArch64CondBrTuning
FunctionPass * createAArch64CondBrTuning()
Definition: AArch64CondBrTuning.cpp:323
llvm::getTheAArch64_32Target
Target & getTheAArch64_32Target()
Definition: AArch64TargetInfo.cpp:21
llvm::AArch64leTargetMachine::AArch64leTargetMachine
AArch64leTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM, CodeGenOpt::Level OL, bool JIT)
Definition: AArch64TargetMachine.cpp:455
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
llvm::createEarlyCSEPass
FunctionPass * createEarlyCSEPass(bool UseMemorySSA=false)
Definition: EarlyCSE.cpp:1790
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:139
llvm::createAArch64DeadRegisterDefinitions
FunctionPass * createAArch64DeadRegisterDefinitions()
Definition: AArch64DeadRegisterDefinitionsPass.cpp:201
llvm::initializeAArch64KCFIPass
void initializeAArch64KCFIPass(PassRegistry &)
llvm::createAArch64BranchTargetsPass
FunctionPass * createAArch64BranchTargetsPass()
true
basic Basic Alias true
Definition: BasicAliasAnalysis.cpp:1794
EnableAdvSIMDScalar
static cl::opt< bool > EnableAdvSIMDScalar("aarch64-enable-simd-scalar", cl::desc("Enable use of AdvSIMD scalar integer instructions"), cl::init(false), cl::Hidden)
EnableHomogeneousPrologEpilog
cl::opt< bool > EnableHomogeneousPrologEpilog
llvm::TargetMachine::setSupportsDefaultOutlining
void setSupportsDefaultOutlining(bool Enable)
Definition: TargetMachine.h:255
llvm::AArch64TargetMachine::convertFuncInfoToYAML
yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const override
Allocate and initialize an instance of the YAML representation of the MachineFunctionInfo.
Definition: AArch64TargetMachine.cpp:850
TargetInstrInfo.h
llvm::initializeAArch64CompressJumpTablesPass
void initializeAArch64CompressJumpTablesPass(PassRegistry &)
llvm::TargetOptions::TrapUnreachable
unsigned TrapUnreachable
Emit target-specific trap instruction for 'unreachable' IR instructions.
Definition: TargetOptions.h:280
llvm::initializeAArch64A53Fix835769Pass
void initializeAArch64A53Fix835769Pass(PassRegistry &)
InstructionSelect.h
llvm::createSVEIntrinsicOptsPass
ModulePass * createSVEIntrinsicOptsPass()
Definition: SVEIntrinsicOpts.cpp:80
llvm::initializeGlobalISel
void initializeGlobalISel(PassRegistry &)
Initialize all passes linked into the GlobalISel library.
Definition: GlobalISel.cpp:17
llvm::createAArch64A57FPLoadBalancing
FunctionPass * createAArch64A57FPLoadBalancing()
Definition: AArch64A57FPLoadBalancing.cpp:721
llvm::createAArch64PostSelectOptimize
FunctionPass * createAArch64PostSelectOptimize()
Definition: AArch64PostSelectOptimize.cpp:259
llvm::TargetMachine::setCFIFixup
void setCFIFixup(bool Enable)
Definition: TargetMachine.h:262
llvm::initializeAArch64LowerHomogeneousPrologEpilogPass
void initializeAArch64LowerHomogeneousPrologEpilogPass(PassRegistry &)
llvm::max
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:337
llvm::initializeAArch64SIMDInstrOptPass
void initializeAArch64SIMDInstrOptPass(PassRegistry &)
llvm::createAArch64PreLegalizerCombiner
FunctionPass * createAArch64PreLegalizerCombiner()
Definition: AArch64PreLegalizerCombiner.cpp:489
STLExtras.h
llvm::initializeAArch64PromoteConstantPass
void initializeAArch64PromoteConstantPass(PassRegistry &)
llvm::createAArch64SIMDInstrOptPass
FunctionPass * createAArch64SIMDInstrOptPass()
Returns an instance of the high cost ASIMD instruction replacement optimization pass.
Definition: AArch64SIMDInstrOpt.cpp:738
llvm::CodeModel::Kernel
@ Kernel
Definition: CodeGen.h:28
llvm::Triple::aarch64_32
@ aarch64_32
Definition: Triple.h:53
llvm::createAArch64LoadStoreOptimizationPass
FunctionPass * createAArch64LoadStoreOptimizationPass()
createAArch64LoadStoreOptimizationPass - returns an instance of the load / store optimization pass.
Definition: AArch64LoadStoreOptimizer.cpp:2335
LLVMInitializeAArch64Target
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAArch64Target()
Definition: AArch64TargetMachine.cpp:199
llvm::AArch64TargetMachine::SubtargetMap
StringMap< std::unique_ptr< AArch64Subtarget > > SubtargetMap
Definition: AArch64TargetMachine.h:27
llvm::initializeFalkorHWPFFixPass
void initializeFalkorHWPFFixPass(PassRegistry &)
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::createComplexDeinterleavingPass
FunctionPass * createComplexDeinterleavingPass(const TargetMachine *TM)
This pass implements generation of target-specific intrinsics to support handling of complex number a...
Definition: ComplexDeinterleavingPass.cpp:313
llvm::createAArch64A53Fix835769
FunctionPass * createAArch64A53Fix835769()
Definition: AArch64A53Fix835769.cpp:249
llvm::Reloc::Model
Model
Definition: CodeGen.h:22
CSEInfo.h
BranchRelaxation
static cl::opt< bool > BranchRelaxation("aarch64-enable-branch-relax", cl::Hidden, cl::init(true), cl::desc("Relax out of range conditional branches"))
CommandLine.h
llvm::AArch64beTargetMachine::AArch64beTargetMachine
AArch64beTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM, CodeGenOpt::Level OL, bool JIT)
Definition: AArch64TargetMachine.cpp:463
llvm::createAArch64PostLegalizerLowering
FunctionPass * createAArch64PostLegalizerLowering()
Definition: AArch64PostLegalizerLowering.cpp:1139
AArch64TargetMachine.h
llvm::createEHContGuardCatchretPass
FunctionPass * createEHContGuardCatchretPass()
Creates EHContGuard catchret target identification pass.
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:24
llvm::createAArch64CompressJumpTablesPass
FunctionPass * createAArch64CompressJumpTablesPass()
Definition: AArch64CompressJumpTables.cpp:186
llvm::TargetMachine::setMachineOutliner
void setMachineOutliner(bool Enable)
Definition: TargetMachine.h:252
llvm::initializeAArch64ExpandPseudoPass
void initializeAArch64ExpandPseudoPass(PassRegistry &)
llvm::getTheAArch64leTarget
Target & getTheAArch64leTarget()
Definition: AArch64TargetInfo.cpp:13
EnableAArch64CopyPropagation
static cl::opt< bool > EnableAArch64CopyPropagation("aarch64-enable-copy-propagation", cl::desc("Enable the copy propagation with AArch64 copy instr"), cl::init(true), cl::Hidden)
llvm::MachineFunction::getInfo
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Definition: MachineFunction.h:758
llvm::initializeAArch64StorePairSuppressPass
void initializeAArch64StorePairSuppressPass(PassRegistry &)
llvm::Legalizer
Definition: Legalizer.h:36
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
EnableFalkorHWPFFix
static cl::opt< bool > EnableFalkorHWPFFix("aarch64-enable-falkor-hwpf-fix", cl::init(true), cl::Hidden)
Y
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
llvm::SMDiagnostic
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:281
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:486
llvm::createAArch64StorePairSuppressPass
FunctionPass * createAArch64StorePairSuppressPass()
false
Definition: StackSlotColoring.cpp:141
llvm::Attribute::getVScaleRangeMax
std::optional< unsigned > getVScaleRangeMax() const
Returns the maximum value for the vscale_range attribute or std::nullopt when unknown.
Definition: Attributes.cpp:375
llvm::EarlyIfConverterID
char & EarlyIfConverterID
EarlyIfConverter - This pass performs if-conversion on SSA form by inserting cmov instructions.
Definition: EarlyIfConversion.cpp:782
llvm::CodeModel::Small
@ Small
Definition: CodeGen.h:28
EnableAtomicTidy
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))
llvm::createAtomicExpandPass
FunctionPass * createAtomicExpandPass()
AtomicExpandPass - At IR level this pass replace atomic instructions with __atomic_* library calls,...
llvm::Attribute::getVScaleRangeMin
unsigned getVScaleRangeMin() const
Returns the minimum value for the vscale_range attribute.
Definition: Attributes.cpp:369
llvm::InstructionSelect
This pass is responsible for selecting generic machine instructions to target-specific instructions.
Definition: InstructionSelect.h:33
llvm::RegisterTargetMachine
RegisterTargetMachine - Helper template for registering a target machine implementation,...
Definition: TargetRegistry.h:1354
AArch64TargetObjectFile.h
llvm::AArch64TargetMachine
Definition: AArch64TargetMachine.h:24
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:145
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
llvm::createAArch64ISelDag
FunctionPass * createAArch64ISelDag(AArch64TargetMachine &TM, CodeGenOpt::Level OptLevel)
createAArch64ISelDag - This pass converts a legalized DAG into a AArch64-specific DAG,...
Definition: AArch64ISelDAGToDAG.cpp:5540
EnableCollectLOH
static cl::opt< bool > EnableCollectLOH("aarch64-enable-collect-loh", cl::desc("Enable the pass that emits the linker optimization hints (LOH)"), cl::init(true), cl::Hidden)
llvm::LoadStoreOpt
Definition: LoadStoreOpt.h:62
llvm::initializeAArch64SLSHardeningPass
void initializeAArch64SLSHardeningPass(PassRegistry &)
llvm::TargetMachine::TargetFS
std::string TargetFS
Definition: TargetMachine.h:97
AArch64MachineScheduler.h
llvm::Attribute::getValueAsString
StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:312
llvm::createAArch64IndirectThunks
FunctionPass * createAArch64IndirectThunks()
Definition: AArch64SLSHardening.cpp:434
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
AArch64MacroFusion.h
llvm::TargetMachine::resetTargetOptions
void resetTargetOptions(const Function &F) const
Reset the target options based on the function's attributes.
Definition: TargetMachine.cpp:53
llvm::SmallString
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
llvm::CodeModel::Model
Model
Definition: CodeGen.h:28
Passes.h
llvm::TargetPassConfig
Target-Independent Code Generator Pass Configuration Options.
Definition: TargetPassConfig.h:84
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
llvm::cl::opt< bool >
llvm::createFalkorHWPFFixPass
FunctionPass * createFalkorHWPFFixPass()
Definition: AArch64FalkorHWPFFix.cpp:838
llvm::TargetMachine::TargetTriple
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with.
Definition: TargetMachine.h:95
llvm::CodeGenOpt::Default
@ Default
Definition: CodeGen.h:55
llvm::cl::BOU_UNSET
@ BOU_UNSET
Definition: CommandLine.h:630
llvm::initializeAArch64ConditionalComparesPass
void initializeAArch64ConditionalComparesPass(PassRegistry &)
llvm::initializeAArch64SpeculationHardeningPass
void initializeAArch64SpeculationHardeningPass(PassRegistry &)
llvm::AArch64TTIImpl
Definition: AArch64TargetTransformInfo.h:42
EnableGISelLoadStoreOptPostLegal
static cl::opt< bool > EnableGISelLoadStoreOptPostLegal("aarch64-enable-gisel-ldst-postlegal", cl::desc("Enable GlobalISel's post-legalizer load/store optimization pass"), cl::init(false), cl::Hidden)
llvm::initializeAArch64PostSelectOptimizePass
void initializeAArch64PostSelectOptimizePass(PassRegistry &)
CFGuard.h
llvm::createGenericSchedLive
ScheduleDAGMILive * createGenericSchedLive(MachineSchedContext *C)
Create the standard converging machine scheduler.
Definition: MachineScheduler.cpp:3488
llvm::EngineKind::JIT
@ JIT
Definition: ExecutionEngine.h:524
LLVM_EXTERNAL_VISIBILITY
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:127
llvm::AArch64TargetMachine::AArch64TargetMachine
AArch64TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM, CodeGenOpt::Level OL, bool JIT, bool IsLittleEndian)
Create an AArch64 architecture model.
Definition: AArch64TargetMachine.cpp:315
llvm::ARM_MB::ST
@ ST
Definition: ARMBaseInfo.h:73
EnableGlobalMerge
static cl::opt< cl::boolOrDefault > EnableGlobalMerge("aarch64-enable-global-merge", cl::Hidden, cl::desc("Enable the global merge pass"))
llvm::createAArch64ExpandPseudoPass
FunctionPass * createAArch64ExpandPseudoPass()
Returns an instance of the pseudo instruction expansion pass.
Definition: AArch64ExpandPseudoInsts.cpp:1482
llvm::createAArch64RedundantCopyEliminationPass
FunctionPass * createAArch64RedundantCopyEliminationPass()
Definition: AArch64RedundantCopyElimination.cpp:494
llvm::initializeAArch64CollectLOHPass
void initializeAArch64CollectLOHPass(PassRegistry &)
llvm::initializeAArch64PostLegalizerLoweringPass
void initializeAArch64PostLegalizerLoweringPass(PassRegistry &)
LoadStoreOpt.h
computeDataLayout
static std::string computeDataLayout(const Triple &TT, const MCTargetOptions &Options, bool LittleEndian)
Definition: AArch64TargetMachine.cpp:255
llvm::MachineSchedContext
MachineSchedContext provides enough context from the MachineScheduler pass for the target to instanti...
Definition: MachineScheduler.h:127
EnableMCR
static cl::opt< bool > EnableMCR("aarch64-enable-mcr", cl::desc("Enable the machine combiner pass"), cl::init(true), cl::Hidden)
llvm::AArch64FunctionInfo
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
Definition: AArch64MachineFunctionInfo.h:38
llvm::TargetOptions::NoTrapAfterNoreturn
unsigned NoTrapAfterNoreturn
Do not emit a trap instruction for 'unreachable' IR instructions behind noreturn calls,...
Definition: TargetOptions.h:284
llvm::initializeAArch64AdvSIMDScalarPass
void initializeAArch64AdvSIMDScalarPass(PassRegistry &)
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::TargetPassConfig::addIRPasses
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
Definition: TargetPassConfig.cpp:854
llvm::createUnpackMachineBundles
FunctionPass * createUnpackMachineBundles(std::function< bool(const MachineFunction &)> Ftor)
Definition: MachineInstrBundle.cpp:81
EnableEarlyIfConversion
static cl::opt< bool > EnableEarlyIfConversion("aarch64-enable-early-ifcvt", cl::Hidden, cl::desc("Run early if-conversion"), cl::init(true))
EnableCondBrTuning
static cl::opt< bool > EnableCondBrTuning("aarch64-enable-cond-br-tune", cl::desc("Enable the conditional branch tuning pass"), cl::init(true), cl::Hidden)
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:446
TargetPassConfig.h
Localizer.h
llvm::createAArch64MIPeepholeOptPass
FunctionPass * createAArch64MIPeepholeOptPass()
Definition: AArch64MIPeepholeOpt.cpp:596
llvm::TargetPassConfig::addCodeGenPrepare
virtual void addCodeGenPrepare()
Add pass to prepare the LLVM IR for code generation.
Definition: TargetPassConfig.cpp:996
llvm::initializeAArch64PreLegalizerCombinerPass
void initializeAArch64PreLegalizerCombinerPass(PassRegistry &)
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::createTypePromotionPass
FunctionPass * createTypePromotionPass()
Create IR Type Promotion pass.
Definition: TypePromotion.cpp:1014
llvm::createAArch64PostLegalizerCombiner
FunctionPass * createAArch64PostLegalizerCombiner(bool IsOptNone)
Definition: AArch64PostLegalizerCombiner.cpp:448
llvm::X86AS::FS
@ FS
Definition: X86.h:200
llvm::TargetOptions::TLSSize
unsigned TLSSize
Bit size of immediate TLS offsets (0 == use the default).
Definition: TargetOptions.h:287
llvm::createCFGuardCheckPass
FunctionPass * createCFGuardCheckPass()
Insert Control FLow Guard checks on indirect function calls.
Definition: CFGuard.cpp:307
llvm::initializeLDTLSCleanupPass
void initializeLDTLSCleanupPass(PassRegistry &)
EnableLoadStoreOpt
static cl::opt< bool > EnableLoadStoreOpt("aarch64-enable-ldst-opt", cl::desc("Enable the load/store pair" " optimization pass"), cl::init(true), cl::Hidden)
llvm::ScheduleDAGMI
ScheduleDAGMI is an implementation of ScheduleDAGInstrs that simply schedules machine instructions ac...
Definition: MachineScheduler.h:273
llvm::CodeGenOpt::Aggressive
@ Aggressive
Definition: CodeGen.h:56
llvm::MCTargetOptions
Definition: MCTargetOptions.h:37
llvm::Reloc::DynamicNoPIC
@ DynamicNoPIC
Definition: CodeGen.h:22
llvm::MachineFunction
Definition: MachineFunction.h:257
llvm::getEffectiveRelocModel
static Reloc::Model getEffectiveRelocModel(std::optional< Reloc::Model > RM)
Definition: AVRTargetMachine.cpp:42
Triple.h
llvm::getTheARM64_32Target
Target & getTheARM64_32Target()
Definition: AArch64TargetInfo.cpp:29
llvm::CodeGenOpt::None
@ None
Definition: CodeGen.h:53
TargetOptions.h
llvm::AArch64::RM
@ RM
Definition: AArch64ISelLowering.h:493
EnableGEPOpt
static cl::opt< bool > EnableGEPOpt("aarch64-enable-gep-opt", cl::Hidden, cl::desc("Enable optimizations on complex GEPs"), cl::init(false))
llvm::TargetMachine::getMCAsmInfo
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
Definition: TargetMachine.h:204
llvm::initializeAArch64StackTaggingPreRAPass
void initializeAArch64StackTaggingPreRAPass(PassRegistry &)
llvm::initializeAArch64PostLegalizerCombinerPass
void initializeAArch64PostLegalizerCombinerPass(PassRegistry &)
llvm::min
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:357
MCAsmInfo.h
llvm::Reloc::PIC_
@ PIC_
Definition: CodeGen.h:22
llvm::createAArch64SLSHardeningPass
FunctionPass * createAArch64SLSHardeningPass()
Definition: AArch64SLSHardening.cpp:394
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::createAArch64StackTaggingPreRAPass
FunctionPass * createAArch64StackTaggingPreRAPass()
Definition: AArch64StackTaggingPreRA.cpp:98
TargetLoweringObjectFile.h
llvm::Reloc::Static
@ Static
Definition: CodeGen.h:22
llvm::getStandardCSEConfigForOpt
std::unique_ptr< CSEConfigBase > getStandardCSEConfigForOpt(CodeGenOpt::Level Level)
Definition: CSEInfo.cpp:75
getEffectiveAArch64CodeModel
static CodeModel::Model getEffectiveAArch64CodeModel(const Triple &TT, std::optional< CodeModel::Model > CM, bool JIT)
Definition: AArch64TargetMachine.cpp:291
IRTranslator.h
llvm::CodeGenOpt::Level
Level
Definition: CodeGen.h:52
llvm::CodeModel::Tiny
@ Tiny
Definition: CodeGen.h:28
llvm::LLVMTargetMachine::initAsmInfo
void initAsmInfo()
Definition: LLVMTargetMachine.cpp:40
EnableSVEIntrinsicOpts
static cl::opt< bool > EnableSVEIntrinsicOpts("aarch64-enable-sve-intrinsic-opts", cl::Hidden, cl::desc("Enable SVE intrinsic opts"), cl::init(true))
AArch64TargetTransformInfo.h
llvm::createInterleavedAccessPass
FunctionPass * createInterleavedAccessPass()
InterleavedAccess Pass - This pass identifies and matches interleaved memory accesses to target speci...
Definition: InterleavedAccessPass.cpp:145
llvm::AArch64TargetMachine::parseMachineFunctionInfo
bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange) const override
Parse out the target's MachineFunctionInfo from the YAML reprsentation.
Definition: AArch64TargetMachine.cpp:855
Attributes.h
llvm::PerFunctionMIParsingState
Definition: MIParser.h:162
llvm::initializeAArch64MIPeepholeOptPass
void initializeAArch64MIPeepholeOptPass(PassRegistry &)
llvm::initializeAArch64RedundantCopyEliminationPass
void initializeAArch64RedundantCopyEliminationPass(PassRegistry &)
llvm::initializeFalkorMarkStridedAccessesLegacyPass
void initializeFalkorMarkStridedAccessesLegacyPass(PassRegistry &)
llvm::initializeAArch64LoadStoreOptPass
void initializeAArch64LoadStoreOptPass(PassRegistry &)
llvm::createSelectOptimizePass
FunctionPass * createSelectOptimizePass()
This pass converts conditional moves to conditional jumps when profitable.
Definition: SelectOptimize.cpp:230
llvm::TargetMachine::setGlobalISelAbort
void setGlobalISelAbort(GlobalISelAbortMode Mode)
Definition: TargetMachine.h:249
llvm::TargetPassConfig::addMachineSSAOptimization
virtual void addMachineSSAOptimization()
addMachineSSAOptimization - Add standard passes that optimize machine instructions in SSA form.
Definition: TargetPassConfig.cpp:1310
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::createLoadClusterDAGMutation
std::unique_ptr< ScheduleDAGMutation > createLoadClusterDAGMutation(const TargetInstrInfo *TII, const TargetRegisterInfo *TRI)
Definition: MachineScheduler.cpp:1572
RegBankSelect.h
llvm::createAArch64MacroFusionDAGMutation
std::unique_ptr< ScheduleDAGMutation > createAArch64MacroFusionDAGMutation()
Note that you have to add: DAG.addMutation(createAArch64MacroFusionDAGMutation()); to AArch64PassConf...
Definition: AArch64MacroFusion.cpp:419
EnableCondOpt
static cl::opt< bool > EnableCondOpt("aarch64-enable-condopt", cl::desc("Enable the condition optimizer pass"), cl::init(true), cl::Hidden)
Function.h
llvm::getTheAArch64beTarget
Target & getTheAArch64beTarget()
Definition: AArch64TargetInfo.cpp:17
llvm::ARCCC::Z
@ Z
Definition: ARCInfo.h:41
llvm::createAArch64CollectLOHPass
FunctionPass * createAArch64CollectLOHPass()
Definition: AArch64CollectLOH.cpp:595
llvm::createAArch64O0PreLegalizerCombiner
FunctionPass * createAArch64O0PreLegalizerCombiner()
Definition: AArch64O0PreLegalizerCombiner.cpp:170
llvm::LLVMTargetMachine
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Definition: TargetMachine.h:408
AArch64MCTargetDesc.h
llvm::initializeSVEIntrinsicOptsPass
void initializeSVEIntrinsicOptsPass(PassRegistry &)
llvm::TargetMachine::setGlobalISel
void setGlobalISel(bool Enable)
Definition: TargetMachine.h:248
llvm::PerFunctionMIParsingState::MF
MachineFunction & MF
Definition: MIParser.h:164
llvm::AArch64TargetMachine::createPassConfig
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
Definition: AArch64TargetMachine.cpp:540
CFIFixup.h
llvm::createGlobalMergePass
Pass * createGlobalMergePass(const TargetMachine *TM, unsigned MaximalOffset, bool OnlyOptimizeForSize=false, bool MergeExternalByDefault=false)
GlobalMerge - This pass merges internal (by default) globals into structs to enable reuse of a base p...
Definition: GlobalMerge.cpp:692
llvm::BranchRelaxationPassID
char & BranchRelaxationPassID
BranchRelaxation - This pass replaces branches that need to jump further than is supported by a branc...
Definition: BranchRelaxation.cpp:121
EnableLoopDataPrefetch
static cl::opt< bool > EnableLoopDataPrefetch("aarch64-enable-loop-data-prefetch", cl::Hidden, cl::desc("Enable the loop data prefetch pass"), cl::init(true))
CodeGen.h
llvm::CodeModel::Large
@ Large
Definition: CodeGen.h:28
EnableCCMP
static cl::opt< bool > EnableCCMP("aarch64-enable-ccmp", cl::desc("Enable the CCMP formation pass"), cl::init(true), cl::Hidden)
llvm::cl::BOU_TRUE
@ BOU_TRUE
Definition: CommandLine.h:630
Legalizer.h
llvm::SimplifyCFGOptions
Definition: SimplifyCFGOptions.h:23
llvm::createLICMPass
Pass * createLICMPass()
Definition: LICM.cpp:349
MachineScheduler.h
AArch64Subtarget.h
EnableDeadRegisterElimination
static cl::opt< bool > EnableDeadRegisterElimination("aarch64-enable-dead-defs", cl::Hidden, cl::desc("Enable the pass that removes dead" " definitons and replaces stores to" " them with stores to the zero" " register"), cl::init(true))
llvm::createAArch64AdvSIMDScalar
FunctionPass * createAArch64AdvSIMDScalar()
Definition: AArch64AdvSIMDScalarPass.cpp:409
llvm::PostRASchedulerID
char & PostRASchedulerID
PostRAScheduler - This pass performs post register allocation scheduling.
Definition: PostRASchedulerList.cpp:197
SVEVectorBitsMinOpt
static cl::opt< unsigned > SVEVectorBitsMinOpt("aarch64-sve-vector-bits-min", cl::desc("Assume SVE vector registers are at least this big, " "with zero meaning no minimum size is assumed."), cl::init(0), cl::Hidden)
llvm::createAArch64StackTaggingPass
FunctionPass * createAArch64StackTaggingPass(bool IsOptNone)
Definition: AArch64StackTagging.cpp:349
llvm::SMRange
Represents a range in source code.
Definition: SMLoc.h:48
llvm::getTheARM64Target
Target & getTheARM64Target()
Definition: AArch64TargetInfo.cpp:25
llvm::createAArch64ConditionOptimizerPass
FunctionPass * createAArch64ConditionOptimizerPass()
Definition: AArch64ConditionOptimizer.cpp:133
llvm::AArch64TargetMachine::getTargetTransformInfo
TargetTransformInfo getTargetTransformInfo(const Function &F) const override
Get a TargetTransformInfo implementation for the target.
Definition: AArch64TargetMachine.cpp:536
llvm::to_string
std::string to_string(const T &Value)
Definition: ScopedPrinter.h:85
llvm::MachineCombinerID
char & MachineCombinerID
This pass performs instruction combining using trace metrics to estimate critical-path and resource d...
Definition: MachineCombiner.cpp:131
TargetTransformInfo.h
llvm::createSMEABIPass
FunctionPass * createSMEABIPass()
Definition: SMEABIPass.cpp:53
llvm::legacy::PassManagerBase
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
Definition: LegacyPassManager.h:39
llvm::createStoreClusterDAGMutation
std::unique_ptr< ScheduleDAGMutation > createStoreClusterDAGMutation(const TargetInstrInfo *TII, const TargetRegisterInfo *TRI)
Definition: MachineScheduler.cpp:1579
llvm::IRTranslator
Definition: IRTranslator.h:64
llvm::GlobalISelAbortMode::Disable
@ Disable
EnablePromoteConstant
static cl::opt< bool > EnablePromoteConstant("aarch64-enable-promote-const", cl::desc("Enable the promote constant pass"), cl::init(true), cl::Hidden)
llvm::StringRef::str
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:221
llvm::initializeAArch64ConditionOptimizerPass
void initializeAArch64ConditionOptimizerPass(PassRegistry &)
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
llvm::RegBankSelect
This pass implements the reg bank selector pass used in the GlobalISel pipeline.
Definition: RegBankSelect.h:91
llvm::TargetMachine::getCodeModel
CodeModel::Model getCodeModel() const
Returns the code model.
Definition: TargetMachine.h:224
llvm::createInterleavedLoadCombinePass
FunctionPass * createInterleavedLoadCombinePass()
InterleavedLoadCombines Pass - This pass identifies interleaved loads and combines them into wide loa...
Definition: InterleavedLoadCombinePass.cpp:1358
llvm::TargetMachine::setSupportsDebugEntryValues
void setSupportsDebugEntryValues(bool Enable)
Definition: TargetMachine.h:258
llvm::createAArch64CleanupLocalDynamicTLSPass
FunctionPass * createAArch64CleanupLocalDynamicTLSPass()
llvm::PostMachineSchedulerID
char & PostMachineSchedulerID
PostMachineScheduler - This pass schedules machine instructions postRA.
Definition: MachineScheduler.cpp:243
llvm::initializeSMEABIPass
void initializeSMEABIPass(PassRegistry &)
llvm::cl::desc
Definition: CommandLine.h:412
llvm::ScheduleDAGMILive
ScheduleDAGMILive is an implementation of ScheduleDAGInstrs that schedules machine instructions while...
Definition: MachineScheduler.h:392
llvm::ScheduleDAGInstrs
A ScheduleDAG for scheduling lists of MachineInstr.
Definition: ScheduleDAGInstrs.h:120
llvm::AArch64Subtarget
Definition: AArch64Subtarget.h:38
llvm::createAArch64ConditionalCompares
FunctionPass * createAArch64ConditionalCompares()
Definition: AArch64ConditionalCompares.cpp:804
llvm::createFalkorMarkStridedAccessesPass
FunctionPass * createFalkorMarkStridedAccessesPass()
Definition: AArch64FalkorHWPFFix.cpp:114
TargetRegistry.h
llvm::AArch64TargetMachine::createDefaultFuncInfoYAML
yaml::MachineFunctionInfo * createDefaultFuncInfoYAML() const override
Allocate and return a default initialized instance of the YAML representation for the MachineFunction...
Definition: AArch64TargetMachine.cpp:845
InitializePasses.h
SVEVectorBitsMaxOpt
static cl::opt< unsigned > SVEVectorBitsMaxOpt("aarch64-sve-vector-bits-max", cl::desc("Assume SVE vector registers are at most this big, " "with zero meaning no maximum size is assumed."), cl::init(0), cl::Hidden)
llvm::TargetMachine::TargetCPU
std::string TargetCPU
Definition: TargetMachine.h:96
llvm::yaml::AArch64FunctionInfo
Definition: AArch64MachineFunctionInfo.h:461
EnableGISelLoadStoreOptPreLegal
static cl::opt< bool > EnableGISelLoadStoreOptPreLegal("aarch64-enable-gisel-ldst-prelegal", cl::desc("Enable GlobalISel's pre-legalizer load/store optimization pass"), cl::init(true), cl::Hidden)
llvm::createLoopDataPrefetchPass
FunctionPass * createLoopDataPrefetchPass()
Definition: LoopDataPrefetch.cpp:152
MIParser.h
AArch64TargetInfo.h
llvm::createCFGuardLongjmpPass
FunctionPass * createCFGuardLongjmpPass()
Creates CFGuard longjmp target identification pass.
llvm::AArch64TargetMachine::~AArch64TargetMachine
~AArch64TargetMachine() override
llvm::Localizer
This pass implements the localization mechanism described at the top of this file.
Definition: Localizer.h:43
llvm::AArch64TargetMachine::getSubtargetImpl
const AArch64Subtarget * getSubtargetImpl() const =delete