LLVM  10.0.0
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"
14 #include "AArch64MacroFusion.h"
15 #include "AArch64Subtarget.h"
20 #include "llvm/ADT/STLExtras.h"
21 #include "llvm/ADT/Triple.h"
30 #include "llvm/CodeGen/Passes.h"
32 #include "llvm/IR/Attributes.h"
33 #include "llvm/IR/Function.h"
34 #include "llvm/InitializePasses.h"
35 #include "llvm/MC/MCAsmInfo.h"
37 #include "llvm/Pass.h"
38 #include "llvm/Support/CodeGen.h"
44 #include "llvm/Transforms/Scalar.h"
45 #include <memory>
46 #include <string>
47 
48 using namespace llvm;
49 
50 static cl::opt<bool> EnableCCMP("aarch64-enable-ccmp",
51  cl::desc("Enable the CCMP formation pass"),
52  cl::init(true), cl::Hidden);
53 
54 static cl::opt<bool>
55  EnableCondBrTuning("aarch64-enable-cond-br-tune",
56  cl::desc("Enable the conditional branch tuning pass"),
57  cl::init(true), cl::Hidden);
58 
59 static cl::opt<bool> EnableMCR("aarch64-enable-mcr",
60  cl::desc("Enable the machine combiner pass"),
61  cl::init(true), cl::Hidden);
62 
63 static cl::opt<bool> EnableStPairSuppress("aarch64-enable-stp-suppress",
64  cl::desc("Suppress STP for AArch64"),
65  cl::init(true), cl::Hidden);
66 
68  "aarch64-enable-simd-scalar",
69  cl::desc("Enable use of AdvSIMD scalar integer instructions"),
70  cl::init(false), cl::Hidden);
71 
72 static cl::opt<bool>
73  EnablePromoteConstant("aarch64-enable-promote-const",
74  cl::desc("Enable the promote constant pass"),
75  cl::init(true), cl::Hidden);
76 
78  "aarch64-enable-collect-loh",
79  cl::desc("Enable the pass that emits the linker optimization hints (LOH)"),
80  cl::init(true), cl::Hidden);
81 
82 static cl::opt<bool>
83  EnableDeadRegisterElimination("aarch64-enable-dead-defs", cl::Hidden,
84  cl::desc("Enable the pass that removes dead"
85  " definitons and replaces stores to"
86  " them with stores to the zero"
87  " register"),
88  cl::init(true));
89 
91  "aarch64-enable-copyelim",
92  cl::desc("Enable the redundant copy elimination pass"), cl::init(true),
93  cl::Hidden);
94 
95 static cl::opt<bool> EnableLoadStoreOpt("aarch64-enable-ldst-opt",
96  cl::desc("Enable the load/store pair"
97  " optimization pass"),
98  cl::init(true), cl::Hidden);
99 
101  "aarch64-enable-atomic-cfg-tidy", cl::Hidden,
102  cl::desc("Run SimplifyCFG after expanding atomic operations"
103  " to make use of cmpxchg flow-based information"),
104  cl::init(true));
105 
106 static cl::opt<bool>
107 EnableEarlyIfConversion("aarch64-enable-early-ifcvt", cl::Hidden,
108  cl::desc("Run early if-conversion"),
109  cl::init(true));
110 
111 static cl::opt<bool>
112  EnableCondOpt("aarch64-enable-condopt",
113  cl::desc("Enable the condition optimizer pass"),
114  cl::init(true), cl::Hidden);
115 
116 static cl::opt<bool>
117 EnableA53Fix835769("aarch64-fix-cortex-a53-835769", cl::Hidden,
118  cl::desc("Work around Cortex-A53 erratum 835769"),
119  cl::init(false));
120 
121 static cl::opt<bool>
122  EnableGEPOpt("aarch64-enable-gep-opt", cl::Hidden,
123  cl::desc("Enable optimizations on complex GEPs"),
124  cl::init(false));
125 
126 static cl::opt<bool>
127  BranchRelaxation("aarch64-enable-branch-relax", cl::Hidden, cl::init(true),
128  cl::desc("Relax out of range conditional branches"));
129 
131  "aarch64-enable-compress-jump-tables", cl::Hidden, cl::init(true),
132  cl::desc("Use smallest entry possible for jump tables"));
133 
134 // FIXME: Unify control over GlobalMerge.
136  EnableGlobalMerge("aarch64-enable-global-merge", cl::Hidden,
137  cl::desc("Enable the global merge pass"));
138 
139 static cl::opt<bool>
140  EnableLoopDataPrefetch("aarch64-enable-loop-data-prefetch", cl::Hidden,
141  cl::desc("Enable the loop data prefetch pass"),
142  cl::init(true));
143 
145  "aarch64-enable-global-isel-at-O", cl::Hidden,
146  cl::desc("Enable GlobalISel at or below an opt level (-1 to disable)"),
147  cl::init(0));
148 
149 static cl::opt<bool> EnableFalkorHWPFFix("aarch64-enable-falkor-hwpf-fix",
150  cl::init(true), cl::Hidden);
151 
152 static cl::opt<bool>
153  EnableBranchTargets("aarch64-enable-branch-targets", cl::Hidden,
154  cl::desc("Enable the AAcrh64 branch target pass"),
155  cl::init(true));
156 
158  // Register the target.
164  auto PR = PassRegistry::getPassRegistry();
188 }
189 
190 //===----------------------------------------------------------------------===//
191 // AArch64 Lowering public interface.
192 //===----------------------------------------------------------------------===//
193 static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
194  if (TT.isOSBinFormatMachO())
195  return std::make_unique<AArch64_MachoTargetObjectFile>();
196  if (TT.isOSBinFormatCOFF())
197  return std::make_unique<AArch64_COFFTargetObjectFile>();
198 
199  return std::make_unique<AArch64_ELFTargetObjectFile>();
200 }
201 
202 // Helper function to build a DataLayout string
203 static std::string computeDataLayout(const Triple &TT,
204  const MCTargetOptions &Options,
205  bool LittleEndian) {
206  if (Options.getABIName() == "ilp32")
207  return "e-m:e-p:32:32-i8:8-i16:16-i64:64-S128";
208  if (TT.isOSBinFormatMachO()) {
209  if (TT.getArch() == Triple::aarch64_32)
210  return "e-m:o-p:32:32-i64:64-i128:128-n32:64-S128";
211  return "e-m:o-i64:64-i128:128-n32:64-S128";
212  }
213  if (TT.isOSBinFormatCOFF())
214  return "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128";
215  if (LittleEndian)
216  return "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128";
217  return "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128";
218 }
219 
222  // AArch64 Darwin and Windows are always PIC.
223  if (TT.isOSDarwin() || TT.isOSWindows())
224  return Reloc::PIC_;
225  // On ELF platforms the default static relocation model has a smart enough
226  // linker to cope with referencing external symbols defined in a shared
227  // library. Hence DynamicNoPIC doesn't need to be promoted to PIC.
228  if (!RM.hasValue() || *RM == Reloc::DynamicNoPIC)
229  return Reloc::Static;
230  return *RM;
231 }
232 
233 static CodeModel::Model
235  bool JIT) {
236  if (CM) {
237  if (*CM != CodeModel::Small && *CM != CodeModel::Tiny &&
238  *CM != CodeModel::Large) {
239  if (!TT.isOSFuchsia())
241  "Only small, tiny and large code models are allowed on AArch64");
242  else if (*CM != CodeModel::Kernel)
243  report_fatal_error("Only small, tiny, kernel, and large code models "
244  "are allowed on AArch64");
245  } else if (*CM == CodeModel::Tiny && !TT.isOSBinFormatELF())
246  report_fatal_error("tiny code model is only supported on ELF");
247  return *CM;
248  }
249  // The default MCJIT memory managers make no guarantees about where they can
250  // find an executable page; JITed code needs to be able to refer to globals
251  // no matter how far away they are.
252  // We should set the CodeModel::Small for Windows ARM64 in JIT mode,
253  // since with large code model LLVM generating 4 MOV instructions, and
254  // Windows doesn't support relocating these long branch (4 MOVs).
255  if (JIT && !TT.isOSWindows())
256  return CodeModel::Large;
257  return CodeModel::Small;
258 }
259 
260 /// Create an AArch64 architecture model.
261 ///
263  StringRef CPU, StringRef FS,
264  const TargetOptions &Options,
267  CodeGenOpt::Level OL, bool JIT,
268  bool LittleEndian)
269  : LLVMTargetMachine(T,
270  computeDataLayout(TT, Options.MCOptions, LittleEndian),
271  TT, CPU, FS, Options, getEffectiveRelocModel(TT, RM),
272  getEffectiveAArch64CodeModel(TT, CM, JIT), OL),
273  TLOF(createTLOF(getTargetTriple())), isLittle(LittleEndian) {
274  initAsmInfo();
275 
276  if (TT.isOSBinFormatMachO()) {
277  this->Options.TrapUnreachable = true;
278  this->Options.NoTrapAfterNoreturn = true;
279  }
280 
281  if (getMCAsmInfo()->usesWindowsCFI()) {
282  // Unwinding can get confused if the last instruction in an
283  // exception-handling region (function, funclet, try block, etc.)
284  // is a call.
285  //
286  // FIXME: We could elide the trap if the next instruction would be in
287  // the same region anyway.
288  this->Options.TrapUnreachable = true;
289  }
290 
291  if (this->Options.TLSSize == 0) // default
292  this->Options.TLSSize = 24;
293  if ((getCodeModel() == CodeModel::Small ||
295  this->Options.TLSSize > 32)
296  // for the small (and kernel) code model, the maximum TLS size is 4GiB
297  this->Options.TLSSize = 32;
298  else if (getCodeModel() == CodeModel::Tiny && this->Options.TLSSize > 24)
299  // for the tiny code model, the maximum TLS size is 1MiB (< 16MiB)
300  this->Options.TLSSize = 24;
301 
302  // Enable GlobalISel at or below EnableGlobalISelAt0, unless this is
303  // MachO/CodeModel::Large, which GlobalISel does not support.
305  TT.getArch() != Triple::aarch64_32 &&
307  setGlobalISel(true);
309  }
310 
311  // AArch64 supports the MachineOutliner.
312  setMachineOutliner(true);
313 
314  // AArch64 supports default outlining behaviour.
316 }
317 
319 
320 const AArch64Subtarget *
322  Attribute CPUAttr = F.getFnAttribute("target-cpu");
323  Attribute FSAttr = F.getFnAttribute("target-features");
324 
325  std::string CPU = !CPUAttr.hasAttribute(Attribute::None)
326  ? CPUAttr.getValueAsString().str()
327  : TargetCPU;
328  std::string FS = !FSAttr.hasAttribute(Attribute::None)
329  ? FSAttr.getValueAsString().str()
330  : TargetFS;
331 
332  auto &I = SubtargetMap[CPU + FS];
333  if (!I) {
334  // This needs to be done before we create a new subtarget since any
335  // creation will depend on the TM and the code generation flags on the
336  // function that reside in TargetOptions.
338  I = std::make_unique<AArch64Subtarget>(TargetTriple, CPU, FS, *this,
339  isLittle);
340  }
341  return I.get();
342 }
343 
344 void AArch64leTargetMachine::anchor() { }
345 
347  const Target &T, const Triple &TT, StringRef CPU, StringRef FS,
350  : AArch64TargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, true) {}
351 
352 void AArch64beTargetMachine::anchor() { }
353 
355  const Target &T, const Triple &TT, StringRef CPU, StringRef FS,
358  : AArch64TargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, false) {}
359 
360 namespace {
361 
362 /// AArch64 Code Generator Pass Configuration Options.
363 class AArch64PassConfig : public TargetPassConfig {
364 public:
365  AArch64PassConfig(AArch64TargetMachine &TM, PassManagerBase &PM)
366  : TargetPassConfig(TM, PM) {
367  if (TM.getOptLevel() != CodeGenOpt::None)
368  substitutePass(&PostRASchedulerID, &PostMachineSchedulerID);
369  }
370 
371  AArch64TargetMachine &getAArch64TargetMachine() const {
372  return getTM<AArch64TargetMachine>();
373  }
374 
376  createMachineScheduler(MachineSchedContext *C) const override {
379  DAG->addMutation(createLoadClusterDAGMutation(DAG->TII, DAG->TRI));
380  DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
381  if (ST.hasFusion())
382  DAG->addMutation(createAArch64MacroFusionDAGMutation());
383  return DAG;
384  }
385 
387  createPostMachineScheduler(MachineSchedContext *C) const override {
389  if (ST.hasFusion()) {
390  // Run the Macro Fusion after RA again since literals are expanded from
391  // pseudos then (v. addPreSched2()).
394  return DAG;
395  }
396 
397  return nullptr;
398  }
399 
400  void addIRPasses() override;
401  bool addPreISel() override;
402  bool addInstSelector() override;
403  bool addIRTranslator() override;
404  void addPreLegalizeMachineIR() override;
405  bool addLegalizeMachineIR() override;
406  bool addRegBankSelect() override;
407  void addPreGlobalInstructionSelect() override;
408  bool addGlobalInstructionSelect() override;
409  bool addILPOpts() override;
410  void addPreRegAlloc() override;
411  void addPostRegAlloc() override;
412  void addPreSched2() override;
413  void addPreEmitPass() override;
414 
415  std::unique_ptr<CSEConfigBase> getCSEConfig() const override;
416 };
417 
418 } // end anonymous namespace
419 
422  return TargetTransformInfo(AArch64TTIImpl(this, F));
423 }
424 
426  return new AArch64PassConfig(*this, PM);
427 }
428 
429 std::unique_ptr<CSEConfigBase> AArch64PassConfig::getCSEConfig() const {
430  return getStandardCSEConfigForOpt(TM->getOptLevel());
431 }
432 
433 void AArch64PassConfig::addIRPasses() {
434  // Always expand atomic operations, we don't deal with atomicrmw or cmpxchg
435  // ourselves.
436  addPass(createAtomicExpandPass());
437 
438  // Cmpxchg instructions are often used with a subsequent comparison to
439  // determine whether it succeeded. We can exploit existing control-flow in
440  // ldrex/strex loops to simplify this, but it needs tidying up.
441  if (TM->getOptLevel() != CodeGenOpt::None && EnableAtomicTidy)
442  addPass(createCFGSimplificationPass(1, true, true, false, true));
443 
444  // Run LoopDataPrefetch
445  //
446  // Run this before LSR to remove the multiplies involved in computing the
447  // pointer values N iterations ahead.
448  if (TM->getOptLevel() != CodeGenOpt::None) {
450  addPass(createLoopDataPrefetchPass());
453  }
454 
456 
457  // Match interleaved memory accesses to ldN/stN intrinsics.
458  if (TM->getOptLevel() != CodeGenOpt::None) {
460  addPass(createInterleavedAccessPass());
461  }
462 
463  if (TM->getOptLevel() == CodeGenOpt::Aggressive && EnableGEPOpt) {
464  // Call SeparateConstOffsetFromGEP pass to extract constants within indices
465  // and lower a GEP with multiple indices to either arithmetic operations or
466  // multiple GEPs with single index.
468  // Call EarlyCSE pass to find and remove subexpressions in the lowered
469  // result.
470  addPass(createEarlyCSEPass());
471  // Do loop invariant code motion in case part of the lowered result is
472  // invariant.
473  addPass(createLICMPass());
474  }
475 
476  addPass(createAArch64StackTaggingPass(/* MergeInit = */ TM->getOptLevel() !=
478 
479  // Add Control Flow Guard checks.
480  if (TM->getTargetTriple().isOSWindows())
481  addPass(createCFGuardCheckPass());
482 }
483 
484 // Pass Pipeline Configuration
485 bool AArch64PassConfig::addPreISel() {
486  // Run promote constant before global merge, so that the promoted constants
487  // get a chance to be merged
488  if (TM->getOptLevel() != CodeGenOpt::None && EnablePromoteConstant)
490  // FIXME: On AArch64, this depends on the type.
491  // Basically, the addressable offsets are up to 4095 * Ty.getSizeInBytes().
492  // and the offset has to be a multiple of the related size in bytes.
493  if ((TM->getOptLevel() != CodeGenOpt::None &&
495  EnableGlobalMerge == cl::BOU_TRUE) {
496  bool OnlyOptimizeForSize = (TM->getOptLevel() < CodeGenOpt::Aggressive) &&
497  (EnableGlobalMerge == cl::BOU_UNSET);
498 
499  // Merging of extern globals is enabled by default on non-Mach-O as we
500  // expect it to be generally either beneficial or harmless. On Mach-O it
501  // is disabled as we emit the .subsections_via_symbols directive which
502  // means that merging extern globals is not safe.
503  bool MergeExternalByDefault = !TM->getTargetTriple().isOSBinFormatMachO();
504 
505  // FIXME: extern global merging is only enabled when we optimise for size
506  // because there are some regressions with it also enabled for performance.
507  if (!OnlyOptimizeForSize)
508  MergeExternalByDefault = false;
509 
510  addPass(createGlobalMergePass(TM, 4095, OnlyOptimizeForSize,
511  MergeExternalByDefault));
512  }
513 
514  return false;
515 }
516 
517 bool AArch64PassConfig::addInstSelector() {
518  addPass(createAArch64ISelDag(getAArch64TargetMachine(), getOptLevel()));
519 
520  // For ELF, cleanup any local-dynamic TLS accesses (i.e. combine as many
521  // references to _TLS_MODULE_BASE_ as possible.
522  if (TM->getTargetTriple().isOSBinFormatELF() &&
525 
526  return false;
527 }
528 
529 bool AArch64PassConfig::addIRTranslator() {
530  addPass(new IRTranslator());
531  return false;
532 }
533 
534 void AArch64PassConfig::addPreLegalizeMachineIR() {
535  bool IsOptNone = getOptLevel() == CodeGenOpt::None;
536  addPass(createAArch64PreLegalizeCombiner(IsOptNone));
537 }
538 
539 bool AArch64PassConfig::addLegalizeMachineIR() {
540  addPass(new Legalizer());
541  return false;
542 }
543 
544 bool AArch64PassConfig::addRegBankSelect() {
545  addPass(new RegBankSelect());
546  return false;
547 }
548 
549 void AArch64PassConfig::addPreGlobalInstructionSelect() {
550  addPass(new Localizer());
551 }
552 
553 bool AArch64PassConfig::addGlobalInstructionSelect() {
554  addPass(new InstructionSelect());
555  return false;
556 }
557 
558 bool AArch64PassConfig::addILPOpts() {
559  if (EnableCondOpt)
561  if (EnableCCMP)
563  if (EnableMCR)
564  addPass(&MachineCombinerID);
565  if (EnableCondBrTuning)
566  addPass(createAArch64CondBrTuning());
568  addPass(&EarlyIfConverterID);
572  if (TM->getOptLevel() != CodeGenOpt::None)
574  return true;
575 }
576 
577 void AArch64PassConfig::addPreRegAlloc() {
578  // Change dead register definitions to refer to the zero register.
579  if (TM->getOptLevel() != CodeGenOpt::None && EnableDeadRegisterElimination)
581 
582  // Use AdvSIMD scalar instructions whenever profitable.
583  if (TM->getOptLevel() != CodeGenOpt::None && EnableAdvSIMDScalar) {
584  addPass(createAArch64AdvSIMDScalar());
585  // The AdvSIMD pass may produce copies that can be rewritten to
586  // be register coalescer friendly.
587  addPass(&PeepholeOptimizerID);
588  }
589 }
590 
591 void AArch64PassConfig::addPostRegAlloc() {
592  // Remove redundant copy instructions.
593  if (TM->getOptLevel() != CodeGenOpt::None && EnableRedundantCopyElimination)
595 
596  if (TM->getOptLevel() != CodeGenOpt::None && usingDefaultRegAlloc())
597  // Improve performance for some FP/SIMD code for A57.
599 }
600 
601 void AArch64PassConfig::addPreSched2() {
602  // Expand some pseudo instructions to allow proper scheduling.
604  // Use load/store pair instructions when possible.
605  if (TM->getOptLevel() != CodeGenOpt::None) {
606  if (EnableLoadStoreOpt)
608  }
609 
610  // The AArch64SpeculationHardeningPass destroys dominator tree and natural
611  // loop info, which is needed for the FalkorHWPFFixPass and also later on.
612  // Therefore, run the AArch64SpeculationHardeningPass before the
613  // FalkorHWPFFixPass to avoid recomputing dominator tree and natural loop
614  // info.
616 
617  if (TM->getOptLevel() != CodeGenOpt::None) {
619  addPass(createFalkorHWPFFixPass());
620  }
621 }
622 
623 void AArch64PassConfig::addPreEmitPass() {
624  // Machine Block Placement might have created new opportunities when run
625  // at O3, where the Tail Duplication Threshold is set to 4 instructions.
626  // Run the load/store optimizer once more.
627  if (TM->getOptLevel() >= CodeGenOpt::Aggressive && EnableLoadStoreOpt)
629 
630  if (EnableA53Fix835769)
631  addPass(createAArch64A53Fix835769());
632 
635 
636  // Relax conditional branch instructions if they're otherwise out of
637  // range of their destination.
638  if (BranchRelaxation)
639  addPass(&BranchRelaxationPassID);
640 
641  // Identify valid longjmp targets for Windows Control Flow Guard.
642  if (TM->getTargetTriple().isOSWindows())
643  addPass(createCFGuardLongjmpPass());
644 
645  if (TM->getOptLevel() != CodeGenOpt::None && EnableCompressJumpTables)
647 
648  if (TM->getOptLevel() != CodeGenOpt::None && EnableCollectLOH &&
649  TM->getTargetTriple().isOSBinFormatMachO())
650  addPass(createAArch64CollectLOHPass());
651 }
uint64_t CallInst * C
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (macOS, iOS, tvOS or watchOS).
Definition: Triple.h:482
char & MachineCombinerID
This pass performs instruction combining using trace metrics to estimate critical-path and resource d...
bool usesWindowsCFI() const
Definition: MCAsmInfo.h:616
Target & getTheAArch64beTarget()
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
FunctionPass * createCFGuardCheckPass()
Insert Control FLow Guard checks on indirect function calls.
Definition: CFGuard.cpp:299
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:239
void initializeAArch64A53Fix835769Pass(PassRegistry &)
AArch64beTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM, CodeGenOpt::Level OL, bool JIT)
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:140
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Target & getTheARM64_32Target()
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
FunctionPass * createFalkorMarkStridedAccessesPass()
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:624
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with...
Definition: TargetMachine.h:84
void initializeAArch64LoadStoreOptPass(PassRegistry &)
Target & getTheAArch64leTarget()
This pass implements the localization mechanism described at the top of this file.
Definition: Localizer.h:40
static cl::opt< bool > EnableCompressJumpTables("aarch64-enable-compress-jump-tables", cl::Hidden, cl::init(true), cl::desc("Use smallest entry possible for jump tables"))
char & EarlyIfConverterID
EarlyIfConverter - This pass performs if-conversion on SSA form by inserting cmov instructions...
ScheduleDAGMI * createGenericSchedPostRA(MachineSchedContext *C)
Create a generic scheduler with no vreg liveness or DAG mutation passes.
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...
char & BranchRelaxationPassID
BranchRelaxation - This pass replaces branches that need to jump further than is supported by a branc...
F(f)
bool isOSFuchsia() const
Definition: Triple.h:506
block Block Frequency true
FunctionPass * createAArch64ConditionalCompares()
void initializeAArch64RedundantCopyEliminationPass(PassRegistry &)
void setGlobalISelAbort(GlobalISelAbortMode Mode)
ScheduleDAGMI is an implementation of ScheduleDAGInstrs that simply schedules machine instructions ac...
unsigned NoTrapAfterNoreturn
Do not emit a trap instruction for &#39;unreachable&#39; IR instructions behind noreturn calls, even if TrapUnreachable is true.
ModulePass * createAArch64PromoteConstantPass()
ScheduleDAGMILive is an implementation of ScheduleDAGInstrs that schedules machine instructions while...
static CodeModel::Model getEffectiveAArch64CodeModel(const Triple &TT, Optional< CodeModel::Model > CM, bool JIT)
FunctionPass * createLoopDataPrefetchPass()
FunctionPass * createCFGuardLongjmpPass()
Creates CFGuard longjmp target identification pass.
FunctionPass * createAArch64CollectLOHPass()
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
FunctionPass * createCFGSimplificationPass(unsigned Threshold=1, bool ForwardSwitchCond=false, bool ConvertSwitch=false, bool KeepLoops=true, bool SinkCommon=false, std::function< bool(const Function &)> Ftor=nullptr)
bool hasFusion() const
Return true if the CPU supports any kind of instruction fusion.
static cl::opt< bool > EnableEarlyIfConversion("aarch64-enable-early-ifcvt", cl::Hidden, cl::desc("Run early if-conversion"), cl::init(true))
void resetTargetOptions(const Function &F) const
Reset the target options based on the function&#39;s attributes.
static cl::opt< bool > EnableMCR("aarch64-enable-mcr", cl::desc("Enable the machine combiner pass"), cl::init(true), cl::Hidden)
static cl::opt< bool > EnableLoopDataPrefetch("aarch64-enable-loop-data-prefetch", cl::Hidden, cl::desc("Enable the loop data prefetch pass"), cl::init(true))
void initializeLDTLSCleanupPass(PassRegistry &)
FunctionPass * createAArch64StackTaggingPass(bool MergeInit)
static cl::opt< bool > EnablePromoteConstant("aarch64-enable-promote-const", cl::desc("Enable the promote constant pass"), cl::init(true), cl::Hidden)
This file contains the simple types necessary to represent the attributes associated with functions a...
No attributes have been set.
Definition: Attributes.h:72
FunctionPass * createAArch64RedundantCopyEliminationPass()
Target & getTheARM64Target()
void initializeAArch64CollectLOHPass(PassRegistry &)
Target-Independent Code Generator Pass Configuration Options.
void initializeAArch64StackTaggingPreRAPass(PassRegistry &)
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
FunctionPass * createAArch64PreLegalizeCombiner(bool IsOptNone)
FunctionPass * createAArch64A57FPLoadBalancing()
static cl::opt< bool > EnableLoadStoreOpt("aarch64-enable-ldst-opt", cl::desc("Enable the load/store pair" " optimization pass"), cl::init(true), cl::Hidden)
RegisterTargetMachine - Helper template for registering a target machine implementation, for use in the target machine initialization function.
static cl::opt< bool > EnableCondBrTuning("aarch64-enable-cond-br-tune", cl::desc("Enable the conditional branch tuning pass"), cl::init(true), cl::Hidden)
FunctionPass * createInterleavedLoadCombinePass()
InterleavedLoadCombines Pass - This pass identifies interleaved loads and combines them into wide loa...
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:297
static cl::opt< cl::boolOrDefault > EnableGlobalMerge("aarch64-enable-global-merge", cl::Hidden, cl::desc("Enable the global merge pass"))
FunctionPass * createAArch64CleanupLocalDynamicTLSPass()
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)
void initializeAArch64SpeculationHardeningPass(PassRegistry &)
ScheduleDAGMILive * createGenericSchedLive(MachineSchedContext *C)
Create the standard converging machine scheduler.
static cl::opt< bool > EnableAdvSIMDScalar("aarch64-enable-simd-scalar", cl::desc("Enable use of AdvSIMD scalar integer instructions"), cl::init(false), cl::Hidden)
FunctionPass * createAArch64LoadStoreOptimizationPass()
createAArch64LoadStoreOptimizationPass - returns an instance of the load / store optimization pass...
AArch64TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM, CodeGenOpt::Level OL, bool JIT, bool IsLittleEndian)
Create an AArch64 architecture model.
bool isOSWindows() const
Tests whether the OS is Windows.
Definition: Triple.h:539
void initializeAArch64A57FPLoadBalancingPass(PassRegistry &)
std::unique_ptr< CSEConfigBase > getStandardCSEConfigForOpt(CodeGenOpt::Level Level)
Definition: CSEInfo.cpp:71
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:435
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
Definition: Attributes.cpp:235
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
void initializeAArch64PromoteConstantPass(PassRegistry &)
void initializeAArch64ExpandPseudoPass(PassRegistry &)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static Reloc::Model getEffectiveRelocModel(Optional< Reloc::Model > RM)
This pass implements the reg bank selector pass used in the GlobalISel pipeline.
Definition: RegBankSelect.h:90
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition: Triple.h:629
Target & getTheAArch64_32Target()
unsigned TLSSize
Bit size of immediate TLS offsets (0 == use the default).
FunctionPass * createInterleavedAccessPass()
InterleavedAccess Pass - This pass identifies and matches interleaved memory accesses to target speci...
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
static cl::opt< bool > EnableBranchTargets("aarch64-enable-branch-targets", cl::Hidden, cl::desc("Enable the AAcrh64 branch target pass"), cl::init(true))
Pass * createLICMPass()
Definition: LICM.cpp:316
FunctionPass * createAArch64AdvSIMDScalar()
const AArch64Subtarget * getSubtargetImpl() const =delete
This class describes a target machine that is implemented with the LLVM target-independent code gener...
FunctionPass * createAArch64StackTaggingPreRAPass()
std::unique_ptr< ScheduleDAGMutation > createAArch64MacroFusionDAGMutation()
Note that you have to add: DAG.addMutation(createAArch64MacroFusionDAGMutation()); to AArch64PassConf...
void setMachineOutliner(bool Enable)
std::unique_ptr< ScheduleDAGMutation > createStoreClusterDAGMutation(const TargetInstrInfo *TII, const TargetRegisterInfo *TRI)
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition: Triple.h:634
This file a TargetTransformInfo::Concept conforming object specific to the AArch64 target machine...
void setSupportsDefaultOutlining(bool Enable)
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
static cl::opt< bool > EnableRedundantCopyElimination("aarch64-enable-copyelim", cl::desc("Enable the redundant copy elimination pass"), cl::init(true), cl::Hidden)
void initializeFalkorMarkStridedAccessesLegacyPass(PassRegistry &)
char & PostRASchedulerID
createPostRAScheduler - This pass performs post register allocation scheduling.
static cl::opt< bool > EnableA53Fix835769("aarch64-fix-cortex-a53-835769", cl::Hidden, cl::desc("Work around Cortex-A53 erratum 835769"), cl::init(false))
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))
std::unique_ptr< ScheduleDAGMutation > createLoadClusterDAGMutation(const TargetInstrInfo *TII, const TargetRegisterInfo *TRI)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAArch64Target()
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
static cl::opt< bool > EnableGEPOpt("aarch64-enable-gep-opt", cl::Hidden, cl::desc("Enable optimizations on complex GEPs"), cl::init(false))
AArch64leTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM, CodeGenOpt::Level OL, bool JIT)
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
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))
FunctionPass * createAArch64ExpandPseudoPass()
Returns an instance of the pseudo instruction expansion pass.
FunctionPass * createAArch64SpeculationHardeningPass()
Returns an instance of the pseudo instruction expansion pass.
static cl::opt< bool > EnableCondOpt("aarch64-enable-condopt", cl::desc("Enable the condition optimizer pass"), cl::init(true), cl::Hidden)
void initializeFalkorHWPFFixPass(PassRegistry &)
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:130
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))
FunctionPass * createAArch64A53Fix835769()
This pass is responsible for selecting generic machine instructions to target-specific instructions...
void initializeAArch64StackTaggingPass(PassRegistry &)
FunctionPass * createSeparateConstOffsetFromGEPPass(bool LowerGEP=false)
static std::unique_ptr< TargetLoweringObjectFile > createTLOF(const Triple &TT)
Target - Wrapper for Target specific information.
CodeModel::Model getCodeModel() const
Returns the code model.
void initializeAArch64PreLegalizerCombinerPass(PassRegistry &)
char & PeepholeOptimizerID
PeepholeOptimizer - This pass performs peephole optimizations - like extension and comparison elimina...
static cl::opt< bool > EnableFalkorHWPFFix("aarch64-enable-falkor-hwpf-fix", cl::init(true), cl::Hidden)
FunctionPass * createAArch64ConditionOptimizerPass()
void initializeAArch64BranchTargetsPass(PassRegistry &)
std::string TargetCPU
Definition: TargetMachine.h:85
FunctionPass * createAArch64ISelDag(AArch64TargetMachine &TM, CodeGenOpt::Level OptLevel)
createAArch64ISelDag - This pass converts a legalized DAG into a AArch64-specific DAG...
A ScheduleDAG for scheduling lists of MachineInstr.
static std::string computeDataLayout(const Triple &TT, const MCTargetOptions &Options, bool LittleEndian)
bool hasValue() const
Definition: Optional.h:259
void initializeAArch64ConditionOptimizerPass(PassRegistry &)
StringRef getABIName() const
getABIName - If this returns a non-empty string this represents the textual name of the ABI that we w...
char & PostMachineSchedulerID
PostMachineScheduler - This pass schedules machine instructions postRA.
StringMap< std::unique_ptr< AArch64Subtarget > > SubtargetMap
StringRef getValueAsString() const
Return the attribute&#39;s value as a string.
Definition: Attributes.cpp:220
FunctionPass * createAArch64StorePairSuppressPass()
FunctionPass * createAArch64CondBrTuning()
TargetOptions Options
MachineSchedContext provides enough context from the MachineScheduler pass for the target to instanti...
#define I(x, y, z)
Definition: MD5.cpp:58
void setGlobalISel(bool Enable)
FunctionPass * createFalkorHWPFFixPass()
FunctionPass * createAArch64BranchTargetsPass()
static cl::opt< bool > EnableCCMP("aarch64-enable-ccmp", cl::desc("Enable the CCMP formation pass"), cl::init(true), cl::Hidden)
void initializeAArch64ConditionalComparesPass(PassRegistry &)
std::string TargetFS
Definition: TargetMachine.h:86
void initializeAArch64CompressJumpTablesPass(PassRegistry &)
This file declares the IRTranslator pass.
FunctionPass * createAArch64SIMDInstrOptPass()
Returns an instance of the high cost ASIMD instruction replacement optimization pass.
void initializeAArch64DeadRegisterDefinitionsPass(PassRegistry &)
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
Definition: Function.h:333
FunctionPass * createEarlyCSEPass(bool UseMemorySSA=false)
Definition: EarlyCSE.cpp:1449
FunctionPass * createAArch64DeadRegisterDefinitions()
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:54
unsigned TrapUnreachable
Emit target-specific trap instruction for &#39;unreachable&#39; IR instructions.
This pass exposes codegen information to IR-level passes.
TargetTransformInfo getTargetTransformInfo(const Function &F) override
Get a TargetTransformInfo implementation for the target.
static cl::opt< bool > BranchRelaxation("aarch64-enable-branch-relax", cl::Hidden, cl::init(true), cl::desc("Relax out of range conditional branches"))
FunctionPass * createAtomicExpandPass()
static cl::opt< bool > EnableStPairSuppress("aarch64-enable-stp-suppress", cl::desc("Suppress STP for AArch64"), cl::init(true), cl::Hidden)
void initializeGlobalISel(PassRegistry &)
Initialize all passes linked into the GlobalISel library.
Definition: GlobalISel.cpp:18
void initializeAArch64SIMDInstrOptPass(PassRegistry &)
void initializeAArch64AdvSIMDScalarPass(PassRegistry &)
FunctionPass * createAArch64CompressJumpTablesPass()
void addMutation(std::unique_ptr< ScheduleDAGMutation > Mutation)
Add a postprocessing step to the DAG builder.
void initializeAArch64StorePairSuppressPass(PassRegistry &)