| Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- HexagonTargetMachine.cpp - Define TargetMachine for Hexagon -------===// |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 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 | // |
| Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 10 | // Implements the info about Hexagon target spec. |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 14 | #include "HexagonTargetMachine.h" |
| 15 | #include "Hexagon.h" |
| 16 | #include "HexagonISelLowering.h" |
| Sergei Larin | 4d8986a | 2012-09-04 14:49:56 +0000 | [diff] [blame] | 17 | #include "HexagonMachineScheduler.h" |
| Jyotsna Verma | 5eb5980 | 2013-05-07 19:53:00 +0000 | [diff] [blame] | 18 | #include "HexagonTargetObjectFile.h" |
| Krzysztof Parzyszek | 73e66f3 | 2015-08-05 18:35:37 +0000 | [diff] [blame] | 19 | #include "HexagonTargetTransformInfo.h" |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/Passes.h" |
| Chandler Carruth | 30d69c2 | 2015-02-13 10:01:29 +0000 | [diff] [blame] | 21 | #include "llvm/IR/LegacyPassManager.h" |
| Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 22 | #include "llvm/IR/Module.h" |
| Benjamin Kramer | ae87d7b | 2012-02-06 10:19:29 +0000 | [diff] [blame] | 23 | #include "llvm/Support/CommandLine.h" |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 24 | #include "llvm/Support/TargetRegistry.h" |
| Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 25 | #include "llvm/Transforms/Scalar.h" |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 26 | |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 27 | using namespace llvm; |
| 28 | |
| Krzysztof Parzyszek | 1279881 | 2016-01-12 19:09:01 +0000 | [diff] [blame] | 29 | |
| 30 | static cl::opt<bool> EnableRDFOpt("rdf-opt", cl::Hidden, cl::ZeroOrMore, |
| 31 | cl::init(true), cl::desc("Enable RDF-based optimizations")); |
| 32 | |
| 33 | static cl::opt<bool> DisableHardwareLoops("disable-hexagon-hwloops", |
| Krzysztof Parzyszek | c05dff1 | 2015-03-31 13:35:12 +0000 | [diff] [blame] | 34 | cl::Hidden, cl::desc("Disable Hardware Loops for Hexagon target")); |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 35 | |
| Jyotsna Verma | 653d883 | 2013-03-27 11:14:24 +0000 | [diff] [blame] | 36 | static cl::opt<bool> DisableHexagonCFGOpt("disable-hexagon-cfgopt", |
| Krzysztof Parzyszek | c05dff1 | 2015-03-31 13:35:12 +0000 | [diff] [blame] | 37 | cl::Hidden, cl::ZeroOrMore, cl::init(false), |
| 38 | cl::desc("Disable Hexagon CFG Optimization")); |
| 39 | |
| Krzysztof Parzyszek | 5b7dd0c | 2015-10-16 19:43:56 +0000 | [diff] [blame] | 40 | static cl::opt<bool> DisableStoreWidening("disable-store-widen", |
| 41 | cl::Hidden, cl::init(false), cl::desc("Disable store widening")); |
| 42 | |
| Krzysztof Parzyszek | c05dff1 | 2015-03-31 13:35:12 +0000 | [diff] [blame] | 43 | static cl::opt<bool> EnableExpandCondsets("hexagon-expand-condsets", |
| 44 | cl::init(true), cl::Hidden, cl::ZeroOrMore, |
| 45 | cl::desc("Early expansion of MUX")); |
| Krzysztof Parzyszek | 59df52c | 2013-05-06 21:25:45 +0000 | [diff] [blame] | 46 | |
| Krzysztof Parzyszek | fb33824 | 2015-10-06 15:49:14 +0000 | [diff] [blame] | 47 | static cl::opt<bool> EnableEarlyIf("hexagon-eif", cl::init(true), cl::Hidden, |
| 48 | cl::ZeroOrMore, cl::desc("Enable early if-conversion")); |
| 49 | |
| Krzysztof Parzyszek | 21b53a5 | 2015-07-08 14:47:34 +0000 | [diff] [blame] | 50 | static cl::opt<bool> EnableGenInsert("hexagon-insert", cl::init(true), |
| 51 | cl::Hidden, cl::desc("Generate \"insert\" instructions")); |
| Jyotsna Verma | 653d883 | 2013-03-27 11:14:24 +0000 | [diff] [blame] | 52 | |
| Krzysztof Parzyszek | 79b2433 | 2015-07-08 19:22:28 +0000 | [diff] [blame] | 53 | static cl::opt<bool> EnableCommGEP("hexagon-commgep", cl::init(true), |
| 54 | cl::Hidden, cl::ZeroOrMore, cl::desc("Enable commoning of GEP instructions")); |
| 55 | |
| Krzysztof Parzyszek | a0ecf07 | 2015-07-14 17:07:24 +0000 | [diff] [blame] | 56 | static cl::opt<bool> EnableGenExtract("hexagon-extract", cl::init(true), |
| 57 | cl::Hidden, cl::desc("Generate \"extract\" instructions")); |
| Krzysztof Parzyszek | 79b2433 | 2015-07-08 19:22:28 +0000 | [diff] [blame] | 58 | |
| Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 59 | static cl::opt<bool> EnableGenMux("hexagon-mux", cl::init(true), cl::Hidden, |
| 60 | cl::desc("Enable converting conditional transfers into MUX instructions")); |
| 61 | |
| Krzysztof Parzyszek | 7587447 | 2015-07-14 19:30:21 +0000 | [diff] [blame] | 62 | static cl::opt<bool> EnableGenPred("hexagon-gen-pred", cl::init(true), |
| 63 | cl::Hidden, cl::desc("Enable conversion of arithmetic operations to " |
| 64 | "predicate instructions")); |
| 65 | |
| Krzysztof Parzyszek | a7c5f04 | 2015-10-16 20:38:54 +0000 | [diff] [blame] | 66 | static cl::opt<bool> DisableHSDR("disable-hsdr", cl::init(false), cl::Hidden, |
| 67 | cl::desc("Disable splitting double registers")); |
| 68 | |
| Krzysztof Parzyszek | ced9941 | 2015-10-20 22:57:13 +0000 | [diff] [blame] | 69 | static cl::opt<bool> EnableBitSimplify("hexagon-bit", cl::init(true), |
| 70 | cl::Hidden, cl::desc("Bit simplification")); |
| 71 | |
| 72 | static cl::opt<bool> EnableLoopResched("hexagon-loop-resched", cl::init(true), |
| 73 | cl::Hidden, cl::desc("Loop rescheduling")); |
| 74 | |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 75 | /// HexagonTargetMachineModule - Note that this is used on hosts that |
| 76 | /// cannot link in a library unless there are references into the |
| 77 | /// library. In particular, it seems that it is not possible to get |
| 78 | /// things to work on Win32 without this. Though it is unused, do not |
| 79 | /// remove it. |
| 80 | extern "C" int HexagonTargetMachineModule; |
| 81 | int HexagonTargetMachineModule = 0; |
| 82 | |
| 83 | extern "C" void LLVMInitializeHexagonTarget() { |
| 84 | // Register the target. |
| 85 | RegisterTargetMachine<HexagonTargetMachine> X(TheHexagonTarget); |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 86 | } |
| 87 | |
| Sergei Larin | 4d8986a | 2012-09-04 14:49:56 +0000 | [diff] [blame] | 88 | static ScheduleDAGInstrs *createVLIWMachineSched(MachineSchedContext *C) { |
| David Blaikie | 422b93d | 2014-04-21 20:32:32 +0000 | [diff] [blame] | 89 | return new VLIWMachineScheduler(C, make_unique<ConvergingVLIWScheduler>()); |
| Sergei Larin | 4d8986a | 2012-09-04 14:49:56 +0000 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | static MachineSchedRegistry |
| 93 | SchedCustomRegistry("hexagon", "Run Hexagon's custom scheduler", |
| 94 | createVLIWMachineSched); |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 95 | |
| Krzysztof Parzyszek | c05dff1 | 2015-03-31 13:35:12 +0000 | [diff] [blame] | 96 | namespace llvm { |
| Krzysztof Parzyszek | ced9941 | 2015-10-20 22:57:13 +0000 | [diff] [blame] | 97 | FunctionPass *createHexagonBitSimplify(); |
| Krzysztof Parzyszek | db86770 | 2015-10-19 17:46:01 +0000 | [diff] [blame] | 98 | FunctionPass *createHexagonCallFrameInformation(); |
| Colin LeMahieu | 56efafc | 2015-06-15 19:05:35 +0000 | [diff] [blame] | 99 | FunctionPass *createHexagonCFGOptimizer(); |
| Krzysztof Parzyszek | a0ecf07 | 2015-07-14 17:07:24 +0000 | [diff] [blame] | 100 | FunctionPass *createHexagonCommonGEP(); |
| 101 | FunctionPass *createHexagonCopyToCombine(); |
| Krzysztof Parzyszek | fb33824 | 2015-10-06 15:49:14 +0000 | [diff] [blame] | 102 | FunctionPass *createHexagonEarlyIfConversion(); |
| Krzysztof Parzyszek | a0ecf07 | 2015-07-14 17:07:24 +0000 | [diff] [blame] | 103 | FunctionPass *createHexagonExpandCondsets(); |
| Krzysztof Parzyszek | a0ecf07 | 2015-07-14 17:07:24 +0000 | [diff] [blame] | 104 | FunctionPass *createHexagonFixupHwLoops(); |
| 105 | FunctionPass *createHexagonGenExtract(); |
| Krzysztof Parzyszek | 21b53a5 | 2015-07-08 14:47:34 +0000 | [diff] [blame] | 106 | FunctionPass *createHexagonGenInsert(); |
| Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 107 | FunctionPass *createHexagonGenMux(); |
| Krzysztof Parzyszek | 7587447 | 2015-07-14 19:30:21 +0000 | [diff] [blame] | 108 | FunctionPass *createHexagonGenPredicate(); |
| Colin LeMahieu | 56efafc | 2015-06-15 19:05:35 +0000 | [diff] [blame] | 109 | FunctionPass *createHexagonHardwareLoops(); |
| Krzysztof Parzyszek | a0ecf07 | 2015-07-14 17:07:24 +0000 | [diff] [blame] | 110 | FunctionPass *createHexagonISelDag(HexagonTargetMachine &TM, |
| 111 | CodeGenOpt::Level OptLevel); |
| Krzysztof Parzyszek | ced9941 | 2015-10-20 22:57:13 +0000 | [diff] [blame] | 112 | FunctionPass *createHexagonLoopRescheduling(); |
| Colin LeMahieu | 56efafc | 2015-06-15 19:05:35 +0000 | [diff] [blame] | 113 | FunctionPass *createHexagonNewValueJump(); |
| Krzysztof Parzyszek | 055c5fd | 2015-10-19 19:10:48 +0000 | [diff] [blame] | 114 | FunctionPass *createHexagonOptimizeSZextends(); |
| Colin LeMahieu | 56efafc | 2015-06-15 19:05:35 +0000 | [diff] [blame] | 115 | FunctionPass *createHexagonPacketizer(); |
| Krzysztof Parzyszek | a0ecf07 | 2015-07-14 17:07:24 +0000 | [diff] [blame] | 116 | FunctionPass *createHexagonPeephole(); |
| Krzysztof Parzyszek | 1279881 | 2016-01-12 19:09:01 +0000 | [diff] [blame] | 117 | FunctionPass *createHexagonRDFOpt(); |
| Krzysztof Parzyszek | a0ecf07 | 2015-07-14 17:07:24 +0000 | [diff] [blame] | 118 | FunctionPass *createHexagonSplitConst32AndConst64(); |
| Krzysztof Parzyszek | a7c5f04 | 2015-10-16 20:38:54 +0000 | [diff] [blame] | 119 | FunctionPass *createHexagonSplitDoubleRegs(); |
| Krzysztof Parzyszek | 5b7dd0c | 2015-10-16 19:43:56 +0000 | [diff] [blame] | 120 | FunctionPass *createHexagonStoreWidening(); |
| Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 121 | } // end namespace llvm; |
| Krzysztof Parzyszek | c05dff1 | 2015-03-31 13:35:12 +0000 | [diff] [blame] | 122 | |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 123 | |
| Daniel Sanders | 3e5de88 | 2015-06-11 19:41:26 +0000 | [diff] [blame] | 124 | HexagonTargetMachine::HexagonTargetMachine(const Target &T, const Triple &TT, |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 125 | StringRef CPU, StringRef FS, |
| Craig Topper | b545408 | 2012-03-17 09:24:09 +0000 | [diff] [blame] | 126 | const TargetOptions &Options, |
| Eric Christopher | 0d0b360 | 2014-06-27 00:13:43 +0000 | [diff] [blame] | 127 | Reloc::Model RM, CodeModel::Model CM, |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 128 | CodeGenOpt::Level OL) |
| Krzysztof Parzyszek | e599643 | 2016-02-12 14:47:38 +0000 | [diff] [blame] | 129 | // Specify the vector alignment explicitly. For v512x1, the calculated |
| 130 | // alignment would be 512*alignment(i1), which is 512 bytes, instead of |
| 131 | // the required minimum of 64 bytes. |
| 132 | : LLVMTargetMachine(T, "e-m:e-p:32:32:32-a:0-n16:32-" |
| 133 | "i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-" |
| 134 | "v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048", |
| 135 | TT, CPU, FS, Options, RM, CM, OL), |
| Krzysztof Parzyszek | 73e66f3 | 2015-08-05 18:35:37 +0000 | [diff] [blame] | 136 | TLOF(make_unique<HexagonTargetObjectFile>()) { |
| 137 | initAsmInfo(); |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 138 | } |
| 139 | |
| Krzysztof Parzyszek | 73e66f3 | 2015-08-05 18:35:37 +0000 | [diff] [blame] | 140 | const HexagonSubtarget * |
| 141 | HexagonTargetMachine::getSubtargetImpl(const Function &F) const { |
| 142 | AttributeSet FnAttrs = F.getAttributes(); |
| 143 | Attribute CPUAttr = |
| 144 | FnAttrs.getAttribute(AttributeSet::FunctionIndex, "target-cpu"); |
| 145 | Attribute FSAttr = |
| 146 | FnAttrs.getAttribute(AttributeSet::FunctionIndex, "target-features"); |
| 147 | |
| 148 | std::string CPU = !CPUAttr.hasAttribute(Attribute::None) |
| 149 | ? CPUAttr.getValueAsString().str() |
| 150 | : TargetCPU; |
| 151 | std::string FS = !FSAttr.hasAttribute(Attribute::None) |
| 152 | ? FSAttr.getValueAsString().str() |
| 153 | : TargetFS; |
| 154 | |
| 155 | auto &I = SubtargetMap[CPU + FS]; |
| 156 | if (!I) { |
| 157 | // This needs to be done before we create a new subtarget since any |
| 158 | // creation will depend on the TM and the code generation flags on the |
| 159 | // function that reside in TargetOptions. |
| 160 | resetTargetOptions(F); |
| 161 | I = llvm::make_unique<HexagonSubtarget>(TargetTriple, CPU, FS, *this); |
| 162 | } |
| 163 | return I.get(); |
| 164 | } |
| 165 | |
| 166 | TargetIRAnalysis HexagonTargetMachine::getTargetIRAnalysis() { |
| Eric Christopher | a4e5d3c | 2015-09-16 23:38:13 +0000 | [diff] [blame] | 167 | return TargetIRAnalysis([this](const Function &F) { |
| Krzysztof Parzyszek | 73e66f3 | 2015-08-05 18:35:37 +0000 | [diff] [blame] | 168 | return TargetTransformInfo(HexagonTTIImpl(this, F)); |
| 169 | }); |
| 170 | } |
| 171 | |
| 172 | |
| Reid Kleckner | 357600e | 2014-11-20 23:37:18 +0000 | [diff] [blame] | 173 | HexagonTargetMachine::~HexagonTargetMachine() {} |
| 174 | |
| Andrew Trick | ccb6736 | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 175 | namespace { |
| 176 | /// Hexagon Code Generator Pass Configuration Options. |
| 177 | class HexagonPassConfig : public TargetPassConfig { |
| 178 | public: |
| Andrew Trick | f8ea108 | 2012-02-04 02:56:59 +0000 | [diff] [blame] | 179 | HexagonPassConfig(HexagonTargetMachine *TM, PassManagerBase &PM) |
| Krzysztof Parzyszek | c05dff1 | 2015-03-31 13:35:12 +0000 | [diff] [blame] | 180 | : TargetPassConfig(TM, PM) { |
| 181 | bool NoOpt = (TM->getOptLevel() == CodeGenOpt::None); |
| 182 | if (!NoOpt) { |
| 183 | if (EnableExpandCondsets) { |
| 184 | Pass *Exp = createHexagonExpandCondsets(); |
| 185 | insertPass(&RegisterCoalescerID, IdentifyingPassPtr(Exp)); |
| 186 | } |
| 187 | } |
| 188 | } |
| Andrew Trick | ccb6736 | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 189 | |
| 190 | HexagonTargetMachine &getHexagonTargetMachine() const { |
| 191 | return getTM<HexagonTargetMachine>(); |
| 192 | } |
| 193 | |
| Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 194 | ScheduleDAGInstrs * |
| 195 | createMachineScheduler(MachineSchedContext *C) const override { |
| Andrew Trick | 978674b | 2013-09-20 05:14:41 +0000 | [diff] [blame] | 196 | return createVLIWMachineSched(C); |
| 197 | } |
| 198 | |
| Krzysztof Parzyszek | 79b2433 | 2015-07-08 19:22:28 +0000 | [diff] [blame] | 199 | void addIRPasses() override; |
| Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 200 | bool addInstSelector() override; |
| Matthias Braun | 7e37a5f | 2014-12-11 21:26:47 +0000 | [diff] [blame] | 201 | void addPreRegAlloc() override; |
| 202 | void addPostRegAlloc() override; |
| 203 | void addPreSched2() override; |
| 204 | void addPreEmitPass() override; |
| Andrew Trick | ccb6736 | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 205 | }; |
| 206 | } // namespace |
| 207 | |
| Andrew Trick | f8ea108 | 2012-02-04 02:56:59 +0000 | [diff] [blame] | 208 | TargetPassConfig *HexagonTargetMachine::createPassConfig(PassManagerBase &PM) { |
| 209 | return new HexagonPassConfig(this, PM); |
| Andrew Trick | ccb6736 | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 210 | } |
| 211 | |
| Krzysztof Parzyszek | 79b2433 | 2015-07-08 19:22:28 +0000 | [diff] [blame] | 212 | void HexagonPassConfig::addIRPasses() { |
| 213 | TargetPassConfig::addIRPasses(); |
| Krzysztof Parzyszek | 79b2433 | 2015-07-08 19:22:28 +0000 | [diff] [blame] | 214 | bool NoOpt = (getOptLevel() == CodeGenOpt::None); |
| Krzysztof Parzyszek | feaf7b8 | 2015-07-09 14:51:21 +0000 | [diff] [blame] | 215 | |
| 216 | addPass(createAtomicExpandPass(TM)); |
| Krzysztof Parzyszek | a0ecf07 | 2015-07-14 17:07:24 +0000 | [diff] [blame] | 217 | if (!NoOpt) { |
| 218 | if (EnableCommGEP) |
| 219 | addPass(createHexagonCommonGEP()); |
| 220 | // Replace certain combinations of shifts and ands with extracts. |
| 221 | if (EnableGenExtract) |
| 222 | addPass(createHexagonGenExtract()); |
| 223 | } |
| Krzysztof Parzyszek | 79b2433 | 2015-07-08 19:22:28 +0000 | [diff] [blame] | 224 | } |
| 225 | |
| Andrew Trick | ccb6736 | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 226 | bool HexagonPassConfig::addInstSelector() { |
| Bill Wendling | a3cd350 | 2013-06-19 21:36:55 +0000 | [diff] [blame] | 227 | HexagonTargetMachine &TM = getHexagonTargetMachine(); |
| Krzysztof Parzyszek | 59df52c | 2013-05-06 21:25:45 +0000 | [diff] [blame] | 228 | bool NoOpt = (getOptLevel() == CodeGenOpt::None); |
| Jyotsna Verma | 653d883 | 2013-03-27 11:14:24 +0000 | [diff] [blame] | 229 | |
| Krzysztof Parzyszek | 055c5fd | 2015-10-19 19:10:48 +0000 | [diff] [blame] | 230 | if (!NoOpt) |
| 231 | addPass(createHexagonOptimizeSZextends()); |
| 232 | |
| Krzysztof Parzyszek | 59df52c | 2013-05-06 21:25:45 +0000 | [diff] [blame] | 233 | addPass(createHexagonISelDag(TM, getOptLevel())); |
| Jyotsna Verma | 653d883 | 2013-03-27 11:14:24 +0000 | [diff] [blame] | 234 | |
| Krzysztof Parzyszek | 59df52c | 2013-05-06 21:25:45 +0000 | [diff] [blame] | 235 | if (!NoOpt) { |
| Krzysztof Parzyszek | 7587447 | 2015-07-14 19:30:21 +0000 | [diff] [blame] | 236 | // Create logical operations on predicate registers. |
| 237 | if (EnableGenPred) |
| 238 | addPass(createHexagonGenPredicate(), false); |
| Krzysztof Parzyszek | ced9941 | 2015-10-20 22:57:13 +0000 | [diff] [blame] | 239 | // Rotate loops to expose bit-simplification opportunities. |
| 240 | if (EnableLoopResched) |
| 241 | addPass(createHexagonLoopRescheduling(), false); |
| Krzysztof Parzyszek | a7c5f04 | 2015-10-16 20:38:54 +0000 | [diff] [blame] | 242 | // Split double registers. |
| 243 | if (!DisableHSDR) |
| 244 | addPass(createHexagonSplitDoubleRegs()); |
| Krzysztof Parzyszek | ced9941 | 2015-10-20 22:57:13 +0000 | [diff] [blame] | 245 | // Bit simplification. |
| 246 | if (EnableBitSimplify) |
| 247 | addPass(createHexagonBitSimplify(), false); |
| Jyotsna Verma | 653d883 | 2013-03-27 11:14:24 +0000 | [diff] [blame] | 248 | addPass(createHexagonPeephole()); |
| Krzysztof Parzyszek | 59df52c | 2013-05-06 21:25:45 +0000 | [diff] [blame] | 249 | printAndVerify("After hexagon peephole pass"); |
| Krzysztof Parzyszek | 21b53a5 | 2015-07-08 14:47:34 +0000 | [diff] [blame] | 250 | if (EnableGenInsert) |
| 251 | addPass(createHexagonGenInsert(), false); |
| Krzysztof Parzyszek | fb33824 | 2015-10-06 15:49:14 +0000 | [diff] [blame] | 252 | if (EnableEarlyIf) |
| 253 | addPass(createHexagonEarlyIfConversion(), false); |
| Krzysztof Parzyszek | 59df52c | 2013-05-06 21:25:45 +0000 | [diff] [blame] | 254 | } |
| Jyotsna Verma | 653d883 | 2013-03-27 11:14:24 +0000 | [diff] [blame] | 255 | |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 256 | return false; |
| 257 | } |
| 258 | |
| Matthias Braun | 7e37a5f | 2014-12-11 21:26:47 +0000 | [diff] [blame] | 259 | void HexagonPassConfig::addPreRegAlloc() { |
| Krzysztof Parzyszek | 5b7dd0c | 2015-10-16 19:43:56 +0000 | [diff] [blame] | 260 | if (getOptLevel() != CodeGenOpt::None) { |
| 261 | if (!DisableStoreWidening) |
| 262 | addPass(createHexagonStoreWidening(), false); |
| Krzysztof Parzyszek | 59df52c | 2013-05-06 21:25:45 +0000 | [diff] [blame] | 263 | if (!DisableHardwareLoops) |
| Matthias Braun | 7e37a5f | 2014-12-11 21:26:47 +0000 | [diff] [blame] | 264 | addPass(createHexagonHardwareLoops(), false); |
| Krzysztof Parzyszek | 5b7dd0c | 2015-10-16 19:43:56 +0000 | [diff] [blame] | 265 | } |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 266 | } |
| 267 | |
| Matthias Braun | 7e37a5f | 2014-12-11 21:26:47 +0000 | [diff] [blame] | 268 | void HexagonPassConfig::addPostRegAlloc() { |
| Krzysztof Parzyszek | 1279881 | 2016-01-12 19:09:01 +0000 | [diff] [blame] | 269 | if (getOptLevel() != CodeGenOpt::None) { |
| 270 | if (EnableRDFOpt) |
| 271 | addPass(createHexagonRDFOpt()); |
| Krzysztof Parzyszek | 59df52c | 2013-05-06 21:25:45 +0000 | [diff] [blame] | 272 | if (!DisableHexagonCFGOpt) |
| Eric Christopher | 5c3376a | 2015-02-02 18:46:27 +0000 | [diff] [blame] | 273 | addPass(createHexagonCFGOptimizer(), false); |
| Krzysztof Parzyszek | 1279881 | 2016-01-12 19:09:01 +0000 | [diff] [blame] | 274 | } |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 275 | } |
| 276 | |
| Matthias Braun | 7e37a5f | 2014-12-11 21:26:47 +0000 | [diff] [blame] | 277 | void HexagonPassConfig::addPreSched2() { |
| Matthias Braun | 7e37a5f | 2014-12-11 21:26:47 +0000 | [diff] [blame] | 278 | addPass(createHexagonCopyToCombine(), false); |
| Jyotsna Verma | 5eb5980 | 2013-05-07 19:53:00 +0000 | [diff] [blame] | 279 | if (getOptLevel() != CodeGenOpt::None) |
| Matthias Braun | 7e37a5f | 2014-12-11 21:26:47 +0000 | [diff] [blame] | 280 | addPass(&IfConverterID, false); |
| Eric Christopher | 01f875e | 2015-02-02 22:11:43 +0000 | [diff] [blame] | 281 | addPass(createHexagonSplitConst32AndConst64()); |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 282 | } |
| 283 | |
| Matthias Braun | 7e37a5f | 2014-12-11 21:26:47 +0000 | [diff] [blame] | 284 | void HexagonPassConfig::addPreEmitPass() { |
| Krzysztof Parzyszek | 59df52c | 2013-05-06 21:25:45 +0000 | [diff] [blame] | 285 | bool NoOpt = (getOptLevel() == CodeGenOpt::None); |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 286 | |
| Krzysztof Parzyszek | 59df52c | 2013-05-06 21:25:45 +0000 | [diff] [blame] | 287 | if (!NoOpt) |
| Matthias Braun | 7e37a5f | 2014-12-11 21:26:47 +0000 | [diff] [blame] | 288 | addPass(createHexagonNewValueJump(), false); |
| Sirish Pande | 4bd20c5 | 2012-05-12 05:10:30 +0000 | [diff] [blame] | 289 | |
| Sirish Pande | f8e5e3c | 2012-05-03 21:52:53 +0000 | [diff] [blame] | 290 | // Create Packets. |
| Krzysztof Parzyszek | 59df52c | 2013-05-06 21:25:45 +0000 | [diff] [blame] | 291 | if (!NoOpt) { |
| 292 | if (!DisableHardwareLoops) |
| Matthias Braun | 7e37a5f | 2014-12-11 21:26:47 +0000 | [diff] [blame] | 293 | addPass(createHexagonFixupHwLoops(), false); |
| Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 294 | // Generate MUX from pairs of conditional transfers. |
| 295 | if (EnableGenMux) |
| 296 | addPass(createHexagonGenMux(), false); |
| 297 | |
| Matthias Braun | 7e37a5f | 2014-12-11 21:26:47 +0000 | [diff] [blame] | 298 | addPass(createHexagonPacketizer(), false); |
| Krzysztof Parzyszek | 59df52c | 2013-05-06 21:25:45 +0000 | [diff] [blame] | 299 | } |
| Krzysztof Parzyszek | db86770 | 2015-10-19 17:46:01 +0000 | [diff] [blame] | 300 | |
| 301 | // Add CFI instructions if necessary. |
| 302 | addPass(createHexagonCallFrameInformation(), false); |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 303 | } |