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