Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 1 | //===-- AArch64TargetMachine.cpp - Define TargetMachine for AArch64 -------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "AArch64.h" |
Quentin Colombet | c17f744 | 2016-04-06 17:26:03 +0000 | [diff] [blame] | 14 | #include "AArch64CallLowering.h" |
Ahmed Bougacha | 6756a2c | 2016-07-27 14:31:55 +0000 | [diff] [blame] | 15 | #include "AArch64InstructionSelector.h" |
Tim Northover | 69fa84a | 2016-10-14 22:18:18 +0000 | [diff] [blame] | 16 | #include "AArch64LegalizerInfo.h" |
Evandro Menezes | 94edf02 | 2017-02-01 02:54:34 +0000 | [diff] [blame] | 17 | #include "AArch64MacroFusion.h" |
Daniel Sanders | d64d5024 | 2017-01-19 11:15:55 +0000 | [diff] [blame] | 18 | #ifdef LLVM_BUILD_GLOBAL_ISEL |
Quentin Colombet | c17f744 | 2016-04-06 17:26:03 +0000 | [diff] [blame] | 19 | #include "AArch64RegisterBankInfo.h" |
Daniel Sanders | d64d5024 | 2017-01-19 11:15:55 +0000 | [diff] [blame] | 20 | #endif |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 21 | #include "AArch64Subtarget.h" |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 22 | #include "AArch64TargetMachine.h" |
Aditya Nandakumar | a271932 | 2014-11-13 09:26:31 +0000 | [diff] [blame] | 23 | #include "AArch64TargetObjectFile.h" |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 24 | #include "AArch64TargetTransformInfo.h" |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 25 | #include "MCTargetDesc/AArch64MCTargetDesc.h" |
| 26 | #include "llvm/ADT/STLExtras.h" |
| 27 | #include "llvm/ADT/Triple.h" |
| 28 | #include "llvm/Analysis/TargetTransformInfo.h" |
| 29 | #include "llvm/CodeGen/GlobalISel/GISelAccessor.h" |
Quentin Colombet | 846219a | 2016-04-07 21:24:40 +0000 | [diff] [blame] | 30 | #include "llvm/CodeGen/GlobalISel/IRTranslator.h" |
Ahmed Bougacha | 6756a2c | 2016-07-27 14:31:55 +0000 | [diff] [blame] | 31 | #include "llvm/CodeGen/GlobalISel/InstructionSelect.h" |
Tim Northover | 69fa84a | 2016-10-14 22:18:18 +0000 | [diff] [blame] | 32 | #include "llvm/CodeGen/GlobalISel/Legalizer.h" |
Quentin Colombet | d413181 | 2016-04-07 20:27:33 +0000 | [diff] [blame] | 33 | #include "llvm/CodeGen/GlobalISel/RegBankSelect.h" |
Matthias Braun | 115efcd | 2016-11-28 20:11:54 +0000 | [diff] [blame] | 34 | #include "llvm/CodeGen/MachineScheduler.h" |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 35 | #include "llvm/CodeGen/Passes.h" |
Matthias Braun | 31d19d4 | 2016-05-10 03:21:59 +0000 | [diff] [blame] | 36 | #include "llvm/CodeGen/TargetPassConfig.h" |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 37 | #include "llvm/IR/Attributes.h" |
Eric Christopher | 3faf2f1 | 2014-10-06 06:45:36 +0000 | [diff] [blame] | 38 | #include "llvm/IR/Function.h" |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 39 | #include "llvm/MC/MCTargetOptions.h" |
| 40 | #include "llvm/Pass.h" |
| 41 | #include "llvm/Support/CodeGen.h" |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 42 | #include "llvm/Support/CommandLine.h" |
| 43 | #include "llvm/Support/TargetRegistry.h" |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 44 | #include "llvm/Target/TargetLoweringObjectFile.h" |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 45 | #include "llvm/Target/TargetOptions.h" |
| 46 | #include "llvm/Transforms/Scalar.h" |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 47 | #include <memory> |
| 48 | #include <string> |
| 49 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 50 | using namespace llvm; |
| 51 | |
Diana Picus | 850043b | 2016-08-01 05:56:57 +0000 | [diff] [blame] | 52 | static cl::opt<bool> EnableCCMP("aarch64-enable-ccmp", |
| 53 | cl::desc("Enable the CCMP formation pass"), |
| 54 | cl::init(true), cl::Hidden); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 55 | |
Diana Picus | 850043b | 2016-08-01 05:56:57 +0000 | [diff] [blame] | 56 | static cl::opt<bool> EnableMCR("aarch64-enable-mcr", |
Gerolf Hoflehner | 97c383b | 2014-08-07 21:40:58 +0000 | [diff] [blame] | 57 | cl::desc("Enable the machine combiner pass"), |
| 58 | cl::init(true), cl::Hidden); |
| 59 | |
Diana Picus | 850043b | 2016-08-01 05:56:57 +0000 | [diff] [blame] | 60 | static cl::opt<bool> EnableStPairSuppress("aarch64-enable-stp-suppress", |
| 61 | cl::desc("Suppress STP for AArch64"), |
| 62 | cl::init(true), cl::Hidden); |
| 63 | |
| 64 | static cl::opt<bool> EnableAdvSIMDScalar( |
| 65 | "aarch64-enable-simd-scalar", |
| 66 | cl::desc("Enable use of AdvSIMD scalar integer instructions"), |
| 67 | cl::init(false), cl::Hidden); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 68 | |
| 69 | static cl::opt<bool> |
Diana Picus | 850043b | 2016-08-01 05:56:57 +0000 | [diff] [blame] | 70 | EnablePromoteConstant("aarch64-enable-promote-const", |
| 71 | cl::desc("Enable the promote constant pass"), |
| 72 | cl::init(true), cl::Hidden); |
| 73 | |
| 74 | static cl::opt<bool> EnableCollectLOH( |
| 75 | "aarch64-enable-collect-loh", |
| 76 | cl::desc("Enable the pass that emits the linker optimization hints (LOH)"), |
| 77 | cl::init(true), cl::Hidden); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 78 | |
| 79 | static cl::opt<bool> |
Diana Picus | 850043b | 2016-08-01 05:56:57 +0000 | [diff] [blame] | 80 | EnableDeadRegisterElimination("aarch64-enable-dead-defs", cl::Hidden, |
| 81 | cl::desc("Enable the pass that removes dead" |
| 82 | " definitons and replaces stores to" |
| 83 | " them with stores to the zero" |
| 84 | " register"), |
| 85 | cl::init(true)); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 86 | |
Diana Picus | 850043b | 2016-08-01 05:56:57 +0000 | [diff] [blame] | 87 | static cl::opt<bool> EnableRedundantCopyElimination( |
| 88 | "aarch64-enable-copyelim", |
| 89 | cl::desc("Enable the redundant copy elimination pass"), cl::init(true), |
| 90 | cl::Hidden); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 91 | |
Diana Picus | 850043b | 2016-08-01 05:56:57 +0000 | [diff] [blame] | 92 | static cl::opt<bool> EnableLoadStoreOpt("aarch64-enable-ldst-opt", |
| 93 | cl::desc("Enable the load/store pair" |
| 94 | " optimization pass"), |
| 95 | cl::init(true), cl::Hidden); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 96 | |
Diana Picus | 850043b | 2016-08-01 05:56:57 +0000 | [diff] [blame] | 97 | static cl::opt<bool> EnableAtomicTidy( |
| 98 | "aarch64-enable-atomic-cfg-tidy", cl::Hidden, |
| 99 | cl::desc("Run SimplifyCFG after expanding atomic operations" |
| 100 | " to make use of cmpxchg flow-based information"), |
| 101 | cl::init(true)); |
Tim Northover | b4ddc08 | 2014-05-30 10:09:59 +0000 | [diff] [blame] | 102 | |
James Molloy | 9991794 | 2014-08-06 13:31:32 +0000 | [diff] [blame] | 103 | static cl::opt<bool> |
| 104 | EnableEarlyIfConversion("aarch64-enable-early-ifcvt", cl::Hidden, |
| 105 | cl::desc("Run early if-conversion"), |
| 106 | cl::init(true)); |
| 107 | |
Jiangning Liu | 1a486da | 2014-09-05 02:55:24 +0000 | [diff] [blame] | 108 | static cl::opt<bool> |
Diana Picus | 850043b | 2016-08-01 05:56:57 +0000 | [diff] [blame] | 109 | EnableCondOpt("aarch64-enable-condopt", |
| 110 | cl::desc("Enable the condition optimizer pass"), |
| 111 | cl::init(true), cl::Hidden); |
Jiangning Liu | 1a486da | 2014-09-05 02:55:24 +0000 | [diff] [blame] | 112 | |
Arnaud A. de Grandmaison | c75dbbb | 2014-09-10 14:06:10 +0000 | [diff] [blame] | 113 | static cl::opt<bool> |
Bradley Smith | f2a801d | 2014-10-13 10:12:35 +0000 | [diff] [blame] | 114 | EnableA53Fix835769("aarch64-fix-cortex-a53-835769", cl::Hidden, |
| 115 | cl::desc("Work around Cortex-A53 erratum 835769"), |
| 116 | cl::init(false)); |
| 117 | |
Hao Liu | fd46bea | 2014-11-19 06:39:53 +0000 | [diff] [blame] | 118 | static cl::opt<bool> |
Diana Picus | 850043b | 2016-08-01 05:56:57 +0000 | [diff] [blame] | 119 | EnableAddressTypePromotion("aarch64-enable-type-promotion", cl::Hidden, |
| 120 | cl::desc("Enable the type promotion pass"), |
| 121 | cl::init(true)); |
| 122 | |
| 123 | static cl::opt<bool> |
| 124 | EnableGEPOpt("aarch64-enable-gep-opt", cl::Hidden, |
| 125 | cl::desc("Enable optimizations on complex GEPs"), |
| 126 | cl::init(false)); |
| 127 | |
| 128 | static cl::opt<bool> |
| 129 | BranchRelaxation("aarch64-enable-branch-relax", cl::Hidden, cl::init(true), |
| 130 | cl::desc("Relax out of range conditional branches")); |
Hao Liu | fd46bea | 2014-11-19 06:39:53 +0000 | [diff] [blame] | 131 | |
Ahmed Bougacha | b96444e | 2015-04-11 00:06:36 +0000 | [diff] [blame] | 132 | // FIXME: Unify control over GlobalMerge. |
| 133 | static cl::opt<cl::boolOrDefault> |
Diana Picus | 850043b | 2016-08-01 05:56:57 +0000 | [diff] [blame] | 134 | EnableGlobalMerge("aarch64-enable-global-merge", cl::Hidden, |
| 135 | cl::desc("Enable the global merge pass")); |
Ahmed Bougacha | b96444e | 2015-04-11 00:06:36 +0000 | [diff] [blame] | 136 | |
Adam Nemet | 53e758f | 2016-03-18 00:27:29 +0000 | [diff] [blame] | 137 | static cl::opt<bool> |
Diana Picus | 850043b | 2016-08-01 05:56:57 +0000 | [diff] [blame] | 138 | EnableLoopDataPrefetch("aarch64-enable-loop-data-prefetch", cl::Hidden, |
Adam Nemet | 53e758f | 2016-03-18 00:27:29 +0000 | [diff] [blame] | 139 | cl::desc("Enable the loop data prefetch pass"), |
Adam Nemet | fb8fbba5 | 2016-03-30 00:21:29 +0000 | [diff] [blame] | 140 | cl::init(true)); |
Adam Nemet | 53e758f | 2016-03-18 00:27:29 +0000 | [diff] [blame] | 141 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 142 | extern "C" void LLVMInitializeAArch64Target() { |
| 143 | // Register the target. |
Mehdi Amini | f42454b | 2016-10-09 23:00:34 +0000 | [diff] [blame] | 144 | RegisterTargetMachine<AArch64leTargetMachine> X(getTheAArch64leTarget()); |
| 145 | RegisterTargetMachine<AArch64beTargetMachine> Y(getTheAArch64beTarget()); |
| 146 | RegisterTargetMachine<AArch64leTargetMachine> Z(getTheARM64Target()); |
Tim Northover | 5dad9df | 2016-04-01 23:14:52 +0000 | [diff] [blame] | 147 | auto PR = PassRegistry::getPassRegistry(); |
| 148 | initializeGlobalISel(*PR); |
Diana Picus | 850043b | 2016-08-01 05:56:57 +0000 | [diff] [blame] | 149 | initializeAArch64A53Fix835769Pass(*PR); |
| 150 | initializeAArch64A57FPLoadBalancingPass(*PR); |
| 151 | initializeAArch64AddressTypePromotionPass(*PR); |
| 152 | initializeAArch64AdvSIMDScalarPass(*PR); |
Diana Picus | 850043b | 2016-08-01 05:56:57 +0000 | [diff] [blame] | 153 | initializeAArch64CollectLOHPass(*PR); |
| 154 | initializeAArch64ConditionalComparesPass(*PR); |
| 155 | initializeAArch64ConditionOptimizerPass(*PR); |
| 156 | initializeAArch64DeadRegisterDefinitionsPass(*PR); |
Tim Northover | 5dad9df | 2016-04-01 23:14:52 +0000 | [diff] [blame] | 157 | initializeAArch64ExpandPseudoPass(*PR); |
Geoff Berry | 24c81e8 | 2016-07-20 21:45:58 +0000 | [diff] [blame] | 158 | initializeAArch64LoadStoreOptPass(*PR); |
Sebastian Pop | eb65d72 | 2016-10-08 12:30:07 +0000 | [diff] [blame] | 159 | initializeAArch64VectorByElementOptPass(*PR); |
Diana Picus | 850043b | 2016-08-01 05:56:57 +0000 | [diff] [blame] | 160 | initializeAArch64PromoteConstantPass(*PR); |
| 161 | initializeAArch64RedundantCopyEliminationPass(*PR); |
| 162 | initializeAArch64StorePairSuppressPass(*PR); |
| 163 | initializeLDTLSCleanupPass(*PR); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 164 | } |
| 165 | |
Aditya Nandakumar | a271932 | 2014-11-13 09:26:31 +0000 | [diff] [blame] | 166 | //===----------------------------------------------------------------------===// |
| 167 | // AArch64 Lowering public interface. |
| 168 | //===----------------------------------------------------------------------===// |
| 169 | static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) { |
| 170 | if (TT.isOSBinFormatMachO()) |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 171 | return llvm::make_unique<AArch64_MachoTargetObjectFile>(); |
Aditya Nandakumar | a271932 | 2014-11-13 09:26:31 +0000 | [diff] [blame] | 172 | |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 173 | return llvm::make_unique<AArch64_ELFTargetObjectFile>(); |
Aditya Nandakumar | a271932 | 2014-11-13 09:26:31 +0000 | [diff] [blame] | 174 | } |
| 175 | |
Mehdi Amini | 93e1ea1 | 2015-03-12 00:07:24 +0000 | [diff] [blame] | 176 | // Helper function to build a DataLayout string |
Joel Jones | 504bf33 | 2016-10-24 13:37:13 +0000 | [diff] [blame] | 177 | static std::string computeDataLayout(const Triple &TT, |
| 178 | const MCTargetOptions &Options, |
| 179 | bool LittleEndian) { |
| 180 | if (Options.getABIName() == "ilp32") |
| 181 | return "e-m:e-p:32:32-i8:8-i16:16-i64:64-S128"; |
Daniel Sanders | ed64d62 | 2015-06-11 15:34:59 +0000 | [diff] [blame] | 182 | if (TT.isOSBinFormatMachO()) |
Mehdi Amini | 93e1ea1 | 2015-03-12 00:07:24 +0000 | [diff] [blame] | 183 | return "e-m:o-i64:64-i128:128-n32:64-S128"; |
| 184 | if (LittleEndian) |
Chad Rosier | 112d0e9 | 2016-07-07 20:02:18 +0000 | [diff] [blame] | 185 | return "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"; |
| 186 | return "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"; |
Mehdi Amini | 93e1ea1 | 2015-03-12 00:07:24 +0000 | [diff] [blame] | 187 | } |
| 188 | |
Rafael Espindola | 8c34dd8 | 2016-05-18 22:04:49 +0000 | [diff] [blame] | 189 | static Reloc::Model getEffectiveRelocModel(const Triple &TT, |
| 190 | Optional<Reloc::Model> RM) { |
| 191 | // AArch64 Darwin is always PIC. |
| 192 | if (TT.isOSDarwin()) |
| 193 | return Reloc::PIC_; |
| 194 | // On ELF platforms the default static relocation model has a smart enough |
| 195 | // linker to cope with referencing external symbols defined in a shared |
| 196 | // library. Hence DynamicNoPIC doesn't need to be promoted to PIC. |
| 197 | if (!RM.hasValue() || *RM == Reloc::DynamicNoPIC) |
| 198 | return Reloc::Static; |
| 199 | return *RM; |
| 200 | } |
| 201 | |
Rafael Espindola | 38af4d6 | 2016-05-18 16:00:24 +0000 | [diff] [blame] | 202 | /// Create an AArch64 architecture model. |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 203 | /// |
Rafael Espindola | 8c34dd8 | 2016-05-18 22:04:49 +0000 | [diff] [blame] | 204 | AArch64TargetMachine::AArch64TargetMachine( |
| 205 | const Target &T, const Triple &TT, StringRef CPU, StringRef FS, |
| 206 | const TargetOptions &Options, Optional<Reloc::Model> RM, |
| 207 | CodeModel::Model CM, CodeGenOpt::Level OL, bool LittleEndian) |
Mehdi Amini | 93e1ea1 | 2015-03-12 00:07:24 +0000 | [diff] [blame] | 208 | // This nested ternary is horrible, but DL needs to be properly |
Eric Christopher | 63ea040 | 2015-03-12 18:23:01 +0000 | [diff] [blame] | 209 | // initialized before TLInfo is constructed. |
Joel Jones | 504bf33 | 2016-10-24 13:37:13 +0000 | [diff] [blame] | 210 | : LLVMTargetMachine(T, computeDataLayout(TT, Options.MCOptions, |
| 211 | LittleEndian), |
| 212 | TT, CPU, FS, Options, |
| 213 | getEffectiveRelocModel(TT, RM), CM, OL), |
Daniel Sanders | c81f450 | 2015-06-16 15:44:21 +0000 | [diff] [blame] | 214 | TLOF(createTLOF(getTargetTriple())), |
Evandro Menezes | ba4926e | 2016-09-20 19:02:06 +0000 | [diff] [blame] | 215 | isLittle(LittleEndian) { |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 216 | initAsmInfo(); |
| 217 | } |
| 218 | |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 219 | AArch64TargetMachine::~AArch64TargetMachine() = default; |
Reid Kleckner | 357600e | 2014-11-20 23:37:18 +0000 | [diff] [blame] | 220 | |
Quentin Colombet | c17f744 | 2016-04-06 17:26:03 +0000 | [diff] [blame] | 221 | #ifdef LLVM_BUILD_GLOBAL_ISEL |
| 222 | namespace { |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 223 | |
Tom Stellard | cef0fe4 | 2016-04-14 17:45:38 +0000 | [diff] [blame] | 224 | struct AArch64GISelActualAccessor : public GISelAccessor { |
Quentin Colombet | c17f744 | 2016-04-06 17:26:03 +0000 | [diff] [blame] | 225 | std::unique_ptr<CallLowering> CallLoweringInfo; |
Ahmed Bougacha | 6756a2c | 2016-07-27 14:31:55 +0000 | [diff] [blame] | 226 | std::unique_ptr<InstructionSelector> InstSelector; |
Tim Northover | 69fa84a | 2016-10-14 22:18:18 +0000 | [diff] [blame] | 227 | std::unique_ptr<LegalizerInfo> Legalizer; |
Quentin Colombet | c17f744 | 2016-04-06 17:26:03 +0000 | [diff] [blame] | 228 | std::unique_ptr<RegisterBankInfo> RegBankInfo; |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 229 | |
Quentin Colombet | c17f744 | 2016-04-06 17:26:03 +0000 | [diff] [blame] | 230 | const CallLowering *getCallLowering() const override { |
| 231 | return CallLoweringInfo.get(); |
| 232 | } |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 233 | |
Ahmed Bougacha | 6756a2c | 2016-07-27 14:31:55 +0000 | [diff] [blame] | 234 | const InstructionSelector *getInstructionSelector() const override { |
| 235 | return InstSelector.get(); |
| 236 | } |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 237 | |
Ahmed Bougacha | 5228603 | 2016-12-15 18:45:30 +0000 | [diff] [blame] | 238 | const LegalizerInfo *getLegalizerInfo() const override { |
Chandler Carruth | 488cb13 | 2016-07-23 07:50:05 +0000 | [diff] [blame] | 239 | return Legalizer.get(); |
Tim Northover | 33b07d6 | 2016-07-22 20:03:43 +0000 | [diff] [blame] | 240 | } |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 241 | |
Quentin Colombet | c17f744 | 2016-04-06 17:26:03 +0000 | [diff] [blame] | 242 | const RegisterBankInfo *getRegBankInfo() const override { |
| 243 | return RegBankInfo.get(); |
| 244 | } |
| 245 | }; |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 246 | |
| 247 | } // end anonymous namespace |
Quentin Colombet | c17f744 | 2016-04-06 17:26:03 +0000 | [diff] [blame] | 248 | #endif |
| 249 | |
Eric Christopher | 3faf2f1 | 2014-10-06 06:45:36 +0000 | [diff] [blame] | 250 | const AArch64Subtarget * |
| 251 | AArch64TargetMachine::getSubtargetImpl(const Function &F) const { |
Duncan P. N. Exon Smith | 003bb7d | 2015-02-14 02:09:06 +0000 | [diff] [blame] | 252 | Attribute CPUAttr = F.getFnAttribute("target-cpu"); |
| 253 | Attribute FSAttr = F.getFnAttribute("target-features"); |
Eric Christopher | 3faf2f1 | 2014-10-06 06:45:36 +0000 | [diff] [blame] | 254 | |
| 255 | std::string CPU = !CPUAttr.hasAttribute(Attribute::None) |
| 256 | ? CPUAttr.getValueAsString().str() |
| 257 | : TargetCPU; |
| 258 | std::string FS = !FSAttr.hasAttribute(Attribute::None) |
| 259 | ? FSAttr.getValueAsString().str() |
| 260 | : TargetFS; |
| 261 | |
| 262 | auto &I = SubtargetMap[CPU + FS]; |
| 263 | if (!I) { |
| 264 | // This needs to be done before we create a new subtarget since any |
| 265 | // creation will depend on the TM and the code generation flags on the |
| 266 | // function that reside in TargetOptions. |
| 267 | resetTargetOptions(F); |
Daniel Sanders | c81f450 | 2015-06-16 15:44:21 +0000 | [diff] [blame] | 268 | I = llvm::make_unique<AArch64Subtarget>(TargetTriple, CPU, FS, *this, |
Evandro Menezes | ba4926e | 2016-09-20 19:02:06 +0000 | [diff] [blame] | 269 | isLittle); |
Quentin Colombet | c17f744 | 2016-04-06 17:26:03 +0000 | [diff] [blame] | 270 | #ifndef LLVM_BUILD_GLOBAL_ISEL |
Diana Picus | bda7276 | 2016-11-14 10:25:43 +0000 | [diff] [blame] | 271 | GISelAccessor *GISel = new GISelAccessor(); |
Quentin Colombet | c17f744 | 2016-04-06 17:26:03 +0000 | [diff] [blame] | 272 | #else |
Tom Stellard | cef0fe4 | 2016-04-14 17:45:38 +0000 | [diff] [blame] | 273 | AArch64GISelActualAccessor *GISel = |
Quentin Colombet | c17f744 | 2016-04-06 17:26:03 +0000 | [diff] [blame] | 274 | new AArch64GISelActualAccessor(); |
Tom Stellard | cef0fe4 | 2016-04-14 17:45:38 +0000 | [diff] [blame] | 275 | GISel->CallLoweringInfo.reset( |
Quentin Colombet | c17f744 | 2016-04-06 17:26:03 +0000 | [diff] [blame] | 276 | new AArch64CallLowering(*I->getTargetLowering())); |
Tim Northover | 69fa84a | 2016-10-14 22:18:18 +0000 | [diff] [blame] | 277 | GISel->Legalizer.reset(new AArch64LegalizerInfo()); |
Ahmed Bougacha | 6756a2c | 2016-07-27 14:31:55 +0000 | [diff] [blame] | 278 | |
| 279 | auto *RBI = new AArch64RegisterBankInfo(*I->getRegisterInfo()); |
| 280 | |
| 281 | // FIXME: At this point, we can't rely on Subtarget having RBI. |
| 282 | // It's awkward to mix passing RBI and the Subtarget; should we pass |
| 283 | // TII/TRI as well? |
Tim Northover | bdf1624 | 2016-10-10 21:50:00 +0000 | [diff] [blame] | 284 | GISel->InstSelector.reset(new AArch64InstructionSelector(*this, *I, *RBI)); |
Ahmed Bougacha | 6756a2c | 2016-07-27 14:31:55 +0000 | [diff] [blame] | 285 | |
| 286 | GISel->RegBankInfo.reset(RBI); |
Quentin Colombet | c17f744 | 2016-04-06 17:26:03 +0000 | [diff] [blame] | 287 | #endif |
Tom Stellard | cef0fe4 | 2016-04-14 17:45:38 +0000 | [diff] [blame] | 288 | I->setGISelAccessor(*GISel); |
Eric Christopher | 3faf2f1 | 2014-10-06 06:45:36 +0000 | [diff] [blame] | 289 | } |
| 290 | return I.get(); |
| 291 | } |
| 292 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 293 | void AArch64leTargetMachine::anchor() { } |
| 294 | |
Daniel Sanders | 3e5de88 | 2015-06-11 19:41:26 +0000 | [diff] [blame] | 295 | AArch64leTargetMachine::AArch64leTargetMachine( |
| 296 | const Target &T, const Triple &TT, StringRef CPU, StringRef FS, |
Rafael Espindola | 8c34dd8 | 2016-05-18 22:04:49 +0000 | [diff] [blame] | 297 | const TargetOptions &Options, Optional<Reloc::Model> RM, |
| 298 | CodeModel::Model CM, CodeGenOpt::Level OL) |
Daniel Sanders | 3e5de88 | 2015-06-11 19:41:26 +0000 | [diff] [blame] | 299 | : AArch64TargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, true) {} |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 300 | |
| 301 | void AArch64beTargetMachine::anchor() { } |
| 302 | |
Daniel Sanders | 3e5de88 | 2015-06-11 19:41:26 +0000 | [diff] [blame] | 303 | AArch64beTargetMachine::AArch64beTargetMachine( |
| 304 | const Target &T, const Triple &TT, StringRef CPU, StringRef FS, |
Rafael Espindola | 8c34dd8 | 2016-05-18 22:04:49 +0000 | [diff] [blame] | 305 | const TargetOptions &Options, Optional<Reloc::Model> RM, |
| 306 | CodeModel::Model CM, CodeGenOpt::Level OL) |
Daniel Sanders | 3e5de88 | 2015-06-11 19:41:26 +0000 | [diff] [blame] | 307 | : AArch64TargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, false) {} |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 308 | |
| 309 | namespace { |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 310 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 311 | /// AArch64 Code Generator Pass Configuration Options. |
| 312 | class AArch64PassConfig : public TargetPassConfig { |
| 313 | public: |
| 314 | AArch64PassConfig(AArch64TargetMachine *TM, PassManagerBase &PM) |
Chad Rosier | 486e087 | 2014-09-12 17:40:39 +0000 | [diff] [blame] | 315 | : TargetPassConfig(TM, PM) { |
Chad Rosier | 347ed4e | 2014-09-12 22:17:28 +0000 | [diff] [blame] | 316 | if (TM->getOptLevel() != CodeGenOpt::None) |
| 317 | substitutePass(&PostRASchedulerID, &PostMachineSchedulerID); |
Chad Rosier | 486e087 | 2014-09-12 17:40:39 +0000 | [diff] [blame] | 318 | } |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 319 | |
| 320 | AArch64TargetMachine &getAArch64TargetMachine() const { |
| 321 | return getTM<AArch64TargetMachine>(); |
| 322 | } |
| 323 | |
Matthias Braun | 115efcd | 2016-11-28 20:11:54 +0000 | [diff] [blame] | 324 | ScheduleDAGInstrs * |
| 325 | createMachineScheduler(MachineSchedContext *C) const override { |
| 326 | ScheduleDAGMILive *DAG = createGenericSchedLive(C); |
| 327 | DAG->addMutation(createLoadClusterDAGMutation(DAG->TII, DAG->TRI)); |
| 328 | DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI)); |
Evandro Menezes | 94edf02 | 2017-02-01 02:54:34 +0000 | [diff] [blame] | 329 | DAG->addMutation(createAArch64MacroFusionDAGMutation()); |
Matthias Braun | 115efcd | 2016-11-28 20:11:54 +0000 | [diff] [blame] | 330 | return DAG; |
| 331 | } |
| 332 | |
Evandro Menezes | 455382e | 2017-02-01 02:54:42 +0000 | [diff] [blame] | 333 | ScheduleDAGInstrs * |
| 334 | createPostMachineScheduler(MachineSchedContext *C) const override { |
| 335 | const AArch64Subtarget &ST = C->MF->getSubtarget<AArch64Subtarget>(); |
| 336 | if (ST.hasFuseLiterals()) { |
| 337 | // Run the Macro Fusion after RA again since literals are expanded from |
| 338 | // pseudos then (v. addPreSched2()). |
| 339 | ScheduleDAGMI *DAG = createGenericSchedPostRA(C); |
| 340 | DAG->addMutation(createAArch64MacroFusionDAGMutation()); |
| 341 | return DAG; |
| 342 | } |
| 343 | |
| 344 | return nullptr; |
| 345 | } |
| 346 | |
Tim Northover | b4ddc08 | 2014-05-30 10:09:59 +0000 | [diff] [blame] | 347 | void addIRPasses() override; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 348 | bool addPreISel() override; |
| 349 | bool addInstSelector() override; |
Quentin Colombet | d96f495 | 2016-02-11 19:35:06 +0000 | [diff] [blame] | 350 | #ifdef LLVM_BUILD_GLOBAL_ISEL |
| 351 | bool addIRTranslator() override; |
Tim Northover | 33b07d6 | 2016-07-22 20:03:43 +0000 | [diff] [blame] | 352 | bool addLegalizeMachineIR() override; |
Quentin Colombet | d413181 | 2016-04-07 20:27:33 +0000 | [diff] [blame] | 353 | bool addRegBankSelect() override; |
Ahmed Bougacha | 6756a2c | 2016-07-27 14:31:55 +0000 | [diff] [blame] | 354 | bool addGlobalInstructionSelect() override; |
Quentin Colombet | d96f495 | 2016-02-11 19:35:06 +0000 | [diff] [blame] | 355 | #endif |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 356 | bool addILPOpts() override; |
Matthias Braun | 7e37a5f | 2014-12-11 21:26:47 +0000 | [diff] [blame] | 357 | void addPreRegAlloc() override; |
| 358 | void addPostRegAlloc() override; |
| 359 | void addPreSched2() override; |
| 360 | void addPreEmitPass() override; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 361 | }; |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 362 | |
| 363 | } // end anonymous namespace |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 364 | |
Chandler Carruth | 8b04c0d | 2015-02-01 13:20:00 +0000 | [diff] [blame] | 365 | TargetIRAnalysis AArch64TargetMachine::getTargetIRAnalysis() { |
Eric Christopher | a4e5d3c | 2015-09-16 23:38:13 +0000 | [diff] [blame] | 366 | return TargetIRAnalysis([this](const Function &F) { |
Chandler Carruth | 8b04c0d | 2015-02-01 13:20:00 +0000 | [diff] [blame] | 367 | return TargetTransformInfo(AArch64TTIImpl(this, F)); |
| 368 | }); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | TargetPassConfig *AArch64TargetMachine::createPassConfig(PassManagerBase &PM) { |
| 372 | return new AArch64PassConfig(this, PM); |
| 373 | } |
| 374 | |
Tim Northover | b4ddc08 | 2014-05-30 10:09:59 +0000 | [diff] [blame] | 375 | void AArch64PassConfig::addIRPasses() { |
| 376 | // Always expand atomic operations, we don't deal with atomicrmw or cmpxchg |
| 377 | // ourselves. |
Robin Morisset | 59c23cd | 2014-08-21 21:50:01 +0000 | [diff] [blame] | 378 | addPass(createAtomicExpandPass(TM)); |
Tim Northover | b4ddc08 | 2014-05-30 10:09:59 +0000 | [diff] [blame] | 379 | |
| 380 | // Cmpxchg instructions are often used with a subsequent comparison to |
| 381 | // determine whether it succeeded. We can exploit existing control-flow in |
| 382 | // ldrex/strex loops to simplify this, but it needs tidying up. |
| 383 | if (TM->getOptLevel() != CodeGenOpt::None && EnableAtomicTidy) |
| 384 | addPass(createCFGSimplificationPass()); |
| 385 | |
Junmo Park | 384d376 | 2016-07-06 23:18:58 +0000 | [diff] [blame] | 386 | // Run LoopDataPrefetch |
Adam Nemet | 53e758f | 2016-03-18 00:27:29 +0000 | [diff] [blame] | 387 | // |
| 388 | // Run this before LSR to remove the multiplies involved in computing the |
| 389 | // pointer values N iterations ahead. |
| 390 | if (TM->getOptLevel() != CodeGenOpt::None && EnableLoopDataPrefetch) |
| 391 | addPass(createLoopDataPrefetchPass()); |
| 392 | |
Tim Northover | b4ddc08 | 2014-05-30 10:09:59 +0000 | [diff] [blame] | 393 | TargetPassConfig::addIRPasses(); |
Hao Liu | fd46bea | 2014-11-19 06:39:53 +0000 | [diff] [blame] | 394 | |
Hao Liu | 7ec8ee3 | 2015-06-26 02:32:07 +0000 | [diff] [blame] | 395 | // Match interleaved memory accesses to ldN/stN intrinsics. |
| 396 | if (TM->getOptLevel() != CodeGenOpt::None) |
| 397 | addPass(createInterleavedAccessPass(TM)); |
| 398 | |
Hao Liu | fd46bea | 2014-11-19 06:39:53 +0000 | [diff] [blame] | 399 | if (TM->getOptLevel() == CodeGenOpt::Aggressive && EnableGEPOpt) { |
| 400 | // Call SeparateConstOffsetFromGEP pass to extract constants within indices |
| 401 | // and lower a GEP with multiple indices to either arithmetic operations or |
| 402 | // multiple GEPs with single index. |
| 403 | addPass(createSeparateConstOffsetFromGEPPass(TM, true)); |
| 404 | // Call EarlyCSE pass to find and remove subexpressions in the lowered |
| 405 | // result. |
| 406 | addPass(createEarlyCSEPass()); |
| 407 | // Do loop invariant code motion in case part of the lowered result is |
| 408 | // invariant. |
| 409 | addPass(createLICMPass()); |
| 410 | } |
Tim Northover | b4ddc08 | 2014-05-30 10:09:59 +0000 | [diff] [blame] | 411 | } |
| 412 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 413 | // Pass Pipeline Configuration |
| 414 | bool AArch64PassConfig::addPreISel() { |
| 415 | // Run promote constant before global merge, so that the promoted constants |
| 416 | // get a chance to be merged |
| 417 | if (TM->getOptLevel() != CodeGenOpt::None && EnablePromoteConstant) |
| 418 | addPass(createAArch64PromoteConstantPass()); |
Eric Christopher | ed47b22 | 2015-02-23 19:28:45 +0000 | [diff] [blame] | 419 | // FIXME: On AArch64, this depends on the type. |
| 420 | // Basically, the addressable offsets are up to 4095 * Ty.getSizeInBytes(). |
| 421 | // and the offset has to be a multiple of the related size in bytes. |
Ahmed Bougacha | 8207641 | 2015-06-04 20:39:23 +0000 | [diff] [blame] | 422 | if ((TM->getOptLevel() != CodeGenOpt::None && |
Ahmed Bougacha | b96444e | 2015-04-11 00:06:36 +0000 | [diff] [blame] | 423 | EnableGlobalMerge == cl::BOU_UNSET) || |
Ahmed Bougacha | 8207641 | 2015-06-04 20:39:23 +0000 | [diff] [blame] | 424 | EnableGlobalMerge == cl::BOU_TRUE) { |
| 425 | bool OnlyOptimizeForSize = (TM->getOptLevel() < CodeGenOpt::Aggressive) && |
| 426 | (EnableGlobalMerge == cl::BOU_UNSET); |
| 427 | addPass(createGlobalMergePass(TM, 4095, OnlyOptimizeForSize)); |
| 428 | } |
| 429 | |
Diana Picus | 850043b | 2016-08-01 05:56:57 +0000 | [diff] [blame] | 430 | if (TM->getOptLevel() != CodeGenOpt::None && EnableAddressTypePromotion) |
Duncan P. N. Exon Smith | de58870 | 2014-07-02 18:17:40 +0000 | [diff] [blame] | 431 | addPass(createAArch64AddressTypePromotionPass()); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 432 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 433 | return false; |
| 434 | } |
| 435 | |
| 436 | bool AArch64PassConfig::addInstSelector() { |
| 437 | addPass(createAArch64ISelDag(getAArch64TargetMachine(), getOptLevel())); |
| 438 | |
| 439 | // For ELF, cleanup any local-dynamic TLS accesses (i.e. combine as many |
| 440 | // references to _TLS_MODULE_BASE_ as possible. |
Daniel Sanders | c81f450 | 2015-06-16 15:44:21 +0000 | [diff] [blame] | 441 | if (TM->getTargetTriple().isOSBinFormatELF() && |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 442 | getOptLevel() != CodeGenOpt::None) |
| 443 | addPass(createAArch64CleanupLocalDynamicTLSPass()); |
| 444 | |
| 445 | return false; |
| 446 | } |
| 447 | |
Quentin Colombet | d96f495 | 2016-02-11 19:35:06 +0000 | [diff] [blame] | 448 | #ifdef LLVM_BUILD_GLOBAL_ISEL |
| 449 | bool AArch64PassConfig::addIRTranslator() { |
| 450 | addPass(new IRTranslator()); |
| 451 | return false; |
| 452 | } |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 453 | |
Tim Northover | 33b07d6 | 2016-07-22 20:03:43 +0000 | [diff] [blame] | 454 | bool AArch64PassConfig::addLegalizeMachineIR() { |
Tim Northover | 69fa84a | 2016-10-14 22:18:18 +0000 | [diff] [blame] | 455 | addPass(new Legalizer()); |
Tim Northover | 33b07d6 | 2016-07-22 20:03:43 +0000 | [diff] [blame] | 456 | return false; |
| 457 | } |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 458 | |
Quentin Colombet | d413181 | 2016-04-07 20:27:33 +0000 | [diff] [blame] | 459 | bool AArch64PassConfig::addRegBankSelect() { |
| 460 | addPass(new RegBankSelect()); |
| 461 | return false; |
| 462 | } |
Eugene Zelenko | 049b017 | 2017-01-06 00:30:53 +0000 | [diff] [blame] | 463 | |
Ahmed Bougacha | 6756a2c | 2016-07-27 14:31:55 +0000 | [diff] [blame] | 464 | bool AArch64PassConfig::addGlobalInstructionSelect() { |
| 465 | addPass(new InstructionSelect()); |
| 466 | return false; |
| 467 | } |
Quentin Colombet | d96f495 | 2016-02-11 19:35:06 +0000 | [diff] [blame] | 468 | #endif |
| 469 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 470 | bool AArch64PassConfig::addILPOpts() { |
Jiangning Liu | 1a486da | 2014-09-05 02:55:24 +0000 | [diff] [blame] | 471 | if (EnableCondOpt) |
| 472 | addPass(createAArch64ConditionOptimizerPass()); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 473 | if (EnableCCMP) |
| 474 | addPass(createAArch64ConditionalCompares()); |
Gerolf Hoflehner | 97c383b | 2014-08-07 21:40:58 +0000 | [diff] [blame] | 475 | if (EnableMCR) |
| 476 | addPass(&MachineCombinerID); |
James Molloy | 9991794 | 2014-08-06 13:31:32 +0000 | [diff] [blame] | 477 | if (EnableEarlyIfConversion) |
| 478 | addPass(&EarlyIfConverterID); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 479 | if (EnableStPairSuppress) |
| 480 | addPass(createAArch64StorePairSuppressPass()); |
Sebastian Pop | eb65d72 | 2016-10-08 12:30:07 +0000 | [diff] [blame] | 481 | addPass(createAArch64VectorByElementOptPass()); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 482 | return true; |
| 483 | } |
| 484 | |
Matthias Braun | 7e37a5f | 2014-12-11 21:26:47 +0000 | [diff] [blame] | 485 | void AArch64PassConfig::addPreRegAlloc() { |
Matthias Braun | 3d51cf0 | 2016-11-16 03:38:27 +0000 | [diff] [blame] | 486 | // Change dead register definitions to refer to the zero register. |
| 487 | if (TM->getOptLevel() != CodeGenOpt::None && EnableDeadRegisterElimination) |
| 488 | addPass(createAArch64DeadRegisterDefinitions()); |
| 489 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 490 | // Use AdvSIMD scalar instructions whenever profitable. |
Quentin Colombet | 0c740d4 | 2014-08-21 18:10:07 +0000 | [diff] [blame] | 491 | if (TM->getOptLevel() != CodeGenOpt::None && EnableAdvSIMDScalar) { |
Matthias Braun | b2f2388 | 2014-12-11 23:18:03 +0000 | [diff] [blame] | 492 | addPass(createAArch64AdvSIMDScalar()); |
Quentin Colombet | 0c740d4 | 2014-08-21 18:10:07 +0000 | [diff] [blame] | 493 | // The AdvSIMD pass may produce copies that can be rewritten to |
| 494 | // be register coaleascer friendly. |
| 495 | addPass(&PeepholeOptimizerID); |
| 496 | } |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 497 | } |
| 498 | |
Matthias Braun | 7e37a5f | 2014-12-11 21:26:47 +0000 | [diff] [blame] | 499 | void AArch64PassConfig::addPostRegAlloc() { |
Jun Bum Lim | b389d9b | 2016-02-16 20:02:39 +0000 | [diff] [blame] | 500 | // Remove redundant copy instructions. |
| 501 | if (TM->getOptLevel() != CodeGenOpt::None && EnableRedundantCopyElimination) |
| 502 | addPass(createAArch64RedundantCopyEliminationPass()); |
| 503 | |
Eric Christopher | 6f1e568 | 2015-03-03 23:22:40 +0000 | [diff] [blame] | 504 | if (TM->getOptLevel() != CodeGenOpt::None && usingDefaultRegAlloc()) |
James Molloy | 3feea9c | 2014-08-08 12:33:21 +0000 | [diff] [blame] | 505 | // Improve performance for some FP/SIMD code for A57. |
| 506 | addPass(createAArch64A57FPLoadBalancing()); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 507 | } |
| 508 | |
Matthias Braun | 7e37a5f | 2014-12-11 21:26:47 +0000 | [diff] [blame] | 509 | void AArch64PassConfig::addPreSched2() { |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 510 | // Expand some pseudo instructions to allow proper scheduling. |
Matthias Braun | b2f2388 | 2014-12-11 23:18:03 +0000 | [diff] [blame] | 511 | addPass(createAArch64ExpandPseudoPass()); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 512 | // Use load/store pair instructions when possible. |
| 513 | if (TM->getOptLevel() != CodeGenOpt::None && EnableLoadStoreOpt) |
| 514 | addPass(createAArch64LoadStoreOptimizationPass()); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 515 | } |
| 516 | |
Matthias Braun | 7e37a5f | 2014-12-11 21:26:47 +0000 | [diff] [blame] | 517 | void AArch64PassConfig::addPreEmitPass() { |
Bradley Smith | f2a801d | 2014-10-13 10:12:35 +0000 | [diff] [blame] | 518 | if (EnableA53Fix835769) |
Matthias Braun | b2f2388 | 2014-12-11 23:18:03 +0000 | [diff] [blame] | 519 | addPass(createAArch64A53Fix835769()); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 520 | // Relax conditional branch instructions if they're otherwise out of |
| 521 | // range of their destination. |
Diana Picus | 850043b | 2016-08-01 05:56:57 +0000 | [diff] [blame] | 522 | if (BranchRelaxation) |
Matt Arsenault | 36919a4 | 2016-10-06 15:38:53 +0000 | [diff] [blame] | 523 | addPass(&BranchRelaxationPassID); |
| 524 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 525 | if (TM->getOptLevel() != CodeGenOpt::None && EnableCollectLOH && |
Daniel Sanders | c81f450 | 2015-06-16 15:44:21 +0000 | [diff] [blame] | 526 | TM->getTargetTriple().isOSBinFormatMachO()) |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 527 | addPass(createAArch64CollectLOHPass()); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 528 | } |