1*9880d681SAndroid Build Coastguard Worker //===-- HexagonTargetMachine.cpp - Define TargetMachine for Hexagon -------===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker // Implements the info about Hexagon target spec.
11*9880d681SAndroid Build Coastguard Worker //
12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Worker #include "HexagonTargetMachine.h"
15*9880d681SAndroid Build Coastguard Worker #include "Hexagon.h"
16*9880d681SAndroid Build Coastguard Worker #include "HexagonISelLowering.h"
17*9880d681SAndroid Build Coastguard Worker #include "HexagonMachineScheduler.h"
18*9880d681SAndroid Build Coastguard Worker #include "HexagonTargetObjectFile.h"
19*9880d681SAndroid Build Coastguard Worker #include "HexagonTargetTransformInfo.h"
20*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/Passes.h"
21*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/TargetPassConfig.h"
22*9880d681SAndroid Build Coastguard Worker #include "llvm/IR/LegacyPassManager.h"
23*9880d681SAndroid Build Coastguard Worker #include "llvm/IR/Module.h"
24*9880d681SAndroid Build Coastguard Worker #include "llvm/Support/CommandLine.h"
25*9880d681SAndroid Build Coastguard Worker #include "llvm/Support/TargetRegistry.h"
26*9880d681SAndroid Build Coastguard Worker #include "llvm/Transforms/Scalar.h"
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Worker using namespace llvm;
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Worker static cl::opt<bool> EnableRDFOpt("rdf-opt", cl::Hidden, cl::ZeroOrMore,
31*9880d681SAndroid Build Coastguard Worker cl::init(true), cl::desc("Enable RDF-based optimizations"));
32*9880d681SAndroid Build Coastguard Worker
33*9880d681SAndroid Build Coastguard Worker static cl::opt<bool> DisableHardwareLoops("disable-hexagon-hwloops",
34*9880d681SAndroid Build Coastguard Worker cl::Hidden, cl::desc("Disable Hardware Loops for Hexagon target"));
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Worker static cl::opt<bool> DisableAModeOpt("disable-hexagon-amodeopt",
37*9880d681SAndroid Build Coastguard Worker cl::Hidden, cl::ZeroOrMore, cl::init(false),
38*9880d681SAndroid Build Coastguard Worker cl::desc("Disable Hexagon Addressing Mode Optimization"));
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Worker static cl::opt<bool> DisableHexagonCFGOpt("disable-hexagon-cfgopt",
41*9880d681SAndroid Build Coastguard Worker cl::Hidden, cl::ZeroOrMore, cl::init(false),
42*9880d681SAndroid Build Coastguard Worker cl::desc("Disable Hexagon CFG Optimization"));
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Worker static cl::opt<bool> DisableStoreWidening("disable-store-widen",
45*9880d681SAndroid Build Coastguard Worker cl::Hidden, cl::init(false), cl::desc("Disable store widening"));
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Worker static cl::opt<bool> EnableExpandCondsets("hexagon-expand-condsets",
48*9880d681SAndroid Build Coastguard Worker cl::init(true), cl::Hidden, cl::ZeroOrMore,
49*9880d681SAndroid Build Coastguard Worker cl::desc("Early expansion of MUX"));
50*9880d681SAndroid Build Coastguard Worker
51*9880d681SAndroid Build Coastguard Worker static cl::opt<bool> EnableEarlyIf("hexagon-eif", cl::init(true), cl::Hidden,
52*9880d681SAndroid Build Coastguard Worker cl::ZeroOrMore, cl::desc("Enable early if-conversion"));
53*9880d681SAndroid Build Coastguard Worker
54*9880d681SAndroid Build Coastguard Worker static cl::opt<bool> EnableGenInsert("hexagon-insert", cl::init(true),
55*9880d681SAndroid Build Coastguard Worker cl::Hidden, cl::desc("Generate \"insert\" instructions"));
56*9880d681SAndroid Build Coastguard Worker
57*9880d681SAndroid Build Coastguard Worker static cl::opt<bool> EnableCommGEP("hexagon-commgep", cl::init(true),
58*9880d681SAndroid Build Coastguard Worker cl::Hidden, cl::ZeroOrMore, cl::desc("Enable commoning of GEP instructions"));
59*9880d681SAndroid Build Coastguard Worker
60*9880d681SAndroid Build Coastguard Worker static cl::opt<bool> EnableGenExtract("hexagon-extract", cl::init(true),
61*9880d681SAndroid Build Coastguard Worker cl::Hidden, cl::desc("Generate \"extract\" instructions"));
62*9880d681SAndroid Build Coastguard Worker
63*9880d681SAndroid Build Coastguard Worker static cl::opt<bool> EnableGenMux("hexagon-mux", cl::init(true), cl::Hidden,
64*9880d681SAndroid Build Coastguard Worker cl::desc("Enable converting conditional transfers into MUX instructions"));
65*9880d681SAndroid Build Coastguard Worker
66*9880d681SAndroid Build Coastguard Worker static cl::opt<bool> EnableGenPred("hexagon-gen-pred", cl::init(true),
67*9880d681SAndroid Build Coastguard Worker cl::Hidden, cl::desc("Enable conversion of arithmetic operations to "
68*9880d681SAndroid Build Coastguard Worker "predicate instructions"));
69*9880d681SAndroid Build Coastguard Worker
70*9880d681SAndroid Build Coastguard Worker static cl::opt<bool> DisableHSDR("disable-hsdr", cl::init(false), cl::Hidden,
71*9880d681SAndroid Build Coastguard Worker cl::desc("Disable splitting double registers"));
72*9880d681SAndroid Build Coastguard Worker
73*9880d681SAndroid Build Coastguard Worker static cl::opt<bool> EnableBitSimplify("hexagon-bit", cl::init(true),
74*9880d681SAndroid Build Coastguard Worker cl::Hidden, cl::desc("Bit simplification"));
75*9880d681SAndroid Build Coastguard Worker
76*9880d681SAndroid Build Coastguard Worker static cl::opt<bool> EnableLoopResched("hexagon-loop-resched", cl::init(true),
77*9880d681SAndroid Build Coastguard Worker cl::Hidden, cl::desc("Loop rescheduling"));
78*9880d681SAndroid Build Coastguard Worker
79*9880d681SAndroid Build Coastguard Worker static cl::opt<bool> HexagonNoOpt("hexagon-noopt", cl::init(false),
80*9880d681SAndroid Build Coastguard Worker cl::Hidden, cl::desc("Disable backend optimizations"));
81*9880d681SAndroid Build Coastguard Worker
82*9880d681SAndroid Build Coastguard Worker /// HexagonTargetMachineModule - Note that this is used on hosts that
83*9880d681SAndroid Build Coastguard Worker /// cannot link in a library unless there are references into the
84*9880d681SAndroid Build Coastguard Worker /// library. In particular, it seems that it is not possible to get
85*9880d681SAndroid Build Coastguard Worker /// things to work on Win32 without this. Though it is unused, do not
86*9880d681SAndroid Build Coastguard Worker /// remove it.
87*9880d681SAndroid Build Coastguard Worker extern "C" int HexagonTargetMachineModule;
88*9880d681SAndroid Build Coastguard Worker int HexagonTargetMachineModule = 0;
89*9880d681SAndroid Build Coastguard Worker
LLVMInitializeHexagonTarget()90*9880d681SAndroid Build Coastguard Worker extern "C" void LLVMInitializeHexagonTarget() {
91*9880d681SAndroid Build Coastguard Worker // Register the target.
92*9880d681SAndroid Build Coastguard Worker RegisterTargetMachine<HexagonTargetMachine> X(TheHexagonTarget);
93*9880d681SAndroid Build Coastguard Worker }
94*9880d681SAndroid Build Coastguard Worker
createVLIWMachineSched(MachineSchedContext * C)95*9880d681SAndroid Build Coastguard Worker static ScheduleDAGInstrs *createVLIWMachineSched(MachineSchedContext *C) {
96*9880d681SAndroid Build Coastguard Worker return new VLIWMachineScheduler(C, make_unique<ConvergingVLIWScheduler>());
97*9880d681SAndroid Build Coastguard Worker }
98*9880d681SAndroid Build Coastguard Worker
99*9880d681SAndroid Build Coastguard Worker static MachineSchedRegistry
100*9880d681SAndroid Build Coastguard Worker SchedCustomRegistry("hexagon", "Run Hexagon's custom scheduler",
101*9880d681SAndroid Build Coastguard Worker createVLIWMachineSched);
102*9880d681SAndroid Build Coastguard Worker
103*9880d681SAndroid Build Coastguard Worker namespace llvm {
104*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonBitSimplify();
105*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonBranchRelaxation();
106*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonCallFrameInformation();
107*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonCFGOptimizer();
108*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonCommonGEP();
109*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonCopyToCombine();
110*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonEarlyIfConversion();
111*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonExpandCondsets();
112*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonFixupHwLoops();
113*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonGenExtract();
114*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonGenInsert();
115*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonGenMux();
116*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonGenPredicate();
117*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonHardwareLoops();
118*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonISelDag(HexagonTargetMachine &TM,
119*9880d681SAndroid Build Coastguard Worker CodeGenOpt::Level OptLevel);
120*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonLoopRescheduling();
121*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonNewValueJump();
122*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonOptimizeSZextends();
123*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonOptAddrMode();
124*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonPacketizer();
125*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonPeephole();
126*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonRDFOpt();
127*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonSplitConst32AndConst64();
128*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonSplitDoubleRegs();
129*9880d681SAndroid Build Coastguard Worker FunctionPass *createHexagonStoreWidening();
130*9880d681SAndroid Build Coastguard Worker } // end namespace llvm;
131*9880d681SAndroid Build Coastguard Worker
getEffectiveRelocModel(Optional<Reloc::Model> RM)132*9880d681SAndroid Build Coastguard Worker static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
133*9880d681SAndroid Build Coastguard Worker if (!RM.hasValue())
134*9880d681SAndroid Build Coastguard Worker return Reloc::Static;
135*9880d681SAndroid Build Coastguard Worker return *RM;
136*9880d681SAndroid Build Coastguard Worker }
137*9880d681SAndroid Build Coastguard Worker
HexagonTargetMachine(const Target & T,const Triple & TT,StringRef CPU,StringRef FS,const TargetOptions & Options,Optional<Reloc::Model> RM,CodeModel::Model CM,CodeGenOpt::Level OL)138*9880d681SAndroid Build Coastguard Worker HexagonTargetMachine::HexagonTargetMachine(const Target &T, const Triple &TT,
139*9880d681SAndroid Build Coastguard Worker StringRef CPU, StringRef FS,
140*9880d681SAndroid Build Coastguard Worker const TargetOptions &Options,
141*9880d681SAndroid Build Coastguard Worker Optional<Reloc::Model> RM,
142*9880d681SAndroid Build Coastguard Worker CodeModel::Model CM,
143*9880d681SAndroid Build Coastguard Worker CodeGenOpt::Level OL)
144*9880d681SAndroid Build Coastguard Worker // Specify the vector alignment explicitly. For v512x1, the calculated
145*9880d681SAndroid Build Coastguard Worker // alignment would be 512*alignment(i1), which is 512 bytes, instead of
146*9880d681SAndroid Build Coastguard Worker // the required minimum of 64 bytes.
147*9880d681SAndroid Build Coastguard Worker : LLVMTargetMachine(
148*9880d681SAndroid Build Coastguard Worker T, "e-m:e-p:32:32:32-a:0-n16:32-"
149*9880d681SAndroid Build Coastguard Worker "i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-"
150*9880d681SAndroid Build Coastguard Worker "v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048",
151*9880d681SAndroid Build Coastguard Worker TT, CPU, FS, Options, getEffectiveRelocModel(RM), CM,
152*9880d681SAndroid Build Coastguard Worker (HexagonNoOpt ? CodeGenOpt::None : OL)),
153*9880d681SAndroid Build Coastguard Worker TLOF(make_unique<HexagonTargetObjectFile>()) {
154*9880d681SAndroid Build Coastguard Worker initAsmInfo();
155*9880d681SAndroid Build Coastguard Worker }
156*9880d681SAndroid Build Coastguard Worker
157*9880d681SAndroid Build Coastguard Worker const HexagonSubtarget *
getSubtargetImpl(const Function & F) const158*9880d681SAndroid Build Coastguard Worker HexagonTargetMachine::getSubtargetImpl(const Function &F) const {
159*9880d681SAndroid Build Coastguard Worker AttributeSet FnAttrs = F.getAttributes();
160*9880d681SAndroid Build Coastguard Worker Attribute CPUAttr =
161*9880d681SAndroid Build Coastguard Worker FnAttrs.getAttribute(AttributeSet::FunctionIndex, "target-cpu");
162*9880d681SAndroid Build Coastguard Worker Attribute FSAttr =
163*9880d681SAndroid Build Coastguard Worker FnAttrs.getAttribute(AttributeSet::FunctionIndex, "target-features");
164*9880d681SAndroid Build Coastguard Worker
165*9880d681SAndroid Build Coastguard Worker std::string CPU = !CPUAttr.hasAttribute(Attribute::None)
166*9880d681SAndroid Build Coastguard Worker ? CPUAttr.getValueAsString().str()
167*9880d681SAndroid Build Coastguard Worker : TargetCPU;
168*9880d681SAndroid Build Coastguard Worker std::string FS = !FSAttr.hasAttribute(Attribute::None)
169*9880d681SAndroid Build Coastguard Worker ? FSAttr.getValueAsString().str()
170*9880d681SAndroid Build Coastguard Worker : TargetFS;
171*9880d681SAndroid Build Coastguard Worker
172*9880d681SAndroid Build Coastguard Worker auto &I = SubtargetMap[CPU + FS];
173*9880d681SAndroid Build Coastguard Worker if (!I) {
174*9880d681SAndroid Build Coastguard Worker // This needs to be done before we create a new subtarget since any
175*9880d681SAndroid Build Coastguard Worker // creation will depend on the TM and the code generation flags on the
176*9880d681SAndroid Build Coastguard Worker // function that reside in TargetOptions.
177*9880d681SAndroid Build Coastguard Worker resetTargetOptions(F);
178*9880d681SAndroid Build Coastguard Worker I = llvm::make_unique<HexagonSubtarget>(TargetTriple, CPU, FS, *this);
179*9880d681SAndroid Build Coastguard Worker }
180*9880d681SAndroid Build Coastguard Worker return I.get();
181*9880d681SAndroid Build Coastguard Worker }
182*9880d681SAndroid Build Coastguard Worker
getTargetIRAnalysis()183*9880d681SAndroid Build Coastguard Worker TargetIRAnalysis HexagonTargetMachine::getTargetIRAnalysis() {
184*9880d681SAndroid Build Coastguard Worker return TargetIRAnalysis([this](const Function &F) {
185*9880d681SAndroid Build Coastguard Worker return TargetTransformInfo(HexagonTTIImpl(this, F));
186*9880d681SAndroid Build Coastguard Worker });
187*9880d681SAndroid Build Coastguard Worker }
188*9880d681SAndroid Build Coastguard Worker
189*9880d681SAndroid Build Coastguard Worker
~HexagonTargetMachine()190*9880d681SAndroid Build Coastguard Worker HexagonTargetMachine::~HexagonTargetMachine() {}
191*9880d681SAndroid Build Coastguard Worker
192*9880d681SAndroid Build Coastguard Worker namespace {
193*9880d681SAndroid Build Coastguard Worker /// Hexagon Code Generator Pass Configuration Options.
194*9880d681SAndroid Build Coastguard Worker class HexagonPassConfig : public TargetPassConfig {
195*9880d681SAndroid Build Coastguard Worker public:
HexagonPassConfig(HexagonTargetMachine * TM,PassManagerBase & PM)196*9880d681SAndroid Build Coastguard Worker HexagonPassConfig(HexagonTargetMachine *TM, PassManagerBase &PM)
197*9880d681SAndroid Build Coastguard Worker : TargetPassConfig(TM, PM) {}
198*9880d681SAndroid Build Coastguard Worker
getHexagonTargetMachine() const199*9880d681SAndroid Build Coastguard Worker HexagonTargetMachine &getHexagonTargetMachine() const {
200*9880d681SAndroid Build Coastguard Worker return getTM<HexagonTargetMachine>();
201*9880d681SAndroid Build Coastguard Worker }
202*9880d681SAndroid Build Coastguard Worker
203*9880d681SAndroid Build Coastguard Worker ScheduleDAGInstrs *
createMachineScheduler(MachineSchedContext * C) const204*9880d681SAndroid Build Coastguard Worker createMachineScheduler(MachineSchedContext *C) const override {
205*9880d681SAndroid Build Coastguard Worker return createVLIWMachineSched(C);
206*9880d681SAndroid Build Coastguard Worker }
207*9880d681SAndroid Build Coastguard Worker
208*9880d681SAndroid Build Coastguard Worker void addIRPasses() override;
209*9880d681SAndroid Build Coastguard Worker bool addInstSelector() override;
210*9880d681SAndroid Build Coastguard Worker void addPreRegAlloc() override;
211*9880d681SAndroid Build Coastguard Worker void addPostRegAlloc() override;
212*9880d681SAndroid Build Coastguard Worker void addPreSched2() override;
213*9880d681SAndroid Build Coastguard Worker void addPreEmitPass() override;
214*9880d681SAndroid Build Coastguard Worker };
215*9880d681SAndroid Build Coastguard Worker } // namespace
216*9880d681SAndroid Build Coastguard Worker
createPassConfig(PassManagerBase & PM)217*9880d681SAndroid Build Coastguard Worker TargetPassConfig *HexagonTargetMachine::createPassConfig(PassManagerBase &PM) {
218*9880d681SAndroid Build Coastguard Worker return new HexagonPassConfig(this, PM);
219*9880d681SAndroid Build Coastguard Worker }
220*9880d681SAndroid Build Coastguard Worker
addIRPasses()221*9880d681SAndroid Build Coastguard Worker void HexagonPassConfig::addIRPasses() {
222*9880d681SAndroid Build Coastguard Worker TargetPassConfig::addIRPasses();
223*9880d681SAndroid Build Coastguard Worker bool NoOpt = (getOptLevel() == CodeGenOpt::None);
224*9880d681SAndroid Build Coastguard Worker
225*9880d681SAndroid Build Coastguard Worker addPass(createAtomicExpandPass(TM));
226*9880d681SAndroid Build Coastguard Worker if (!NoOpt) {
227*9880d681SAndroid Build Coastguard Worker if (EnableCommGEP)
228*9880d681SAndroid Build Coastguard Worker addPass(createHexagonCommonGEP());
229*9880d681SAndroid Build Coastguard Worker // Replace certain combinations of shifts and ands with extracts.
230*9880d681SAndroid Build Coastguard Worker if (EnableGenExtract)
231*9880d681SAndroid Build Coastguard Worker addPass(createHexagonGenExtract());
232*9880d681SAndroid Build Coastguard Worker }
233*9880d681SAndroid Build Coastguard Worker }
234*9880d681SAndroid Build Coastguard Worker
addInstSelector()235*9880d681SAndroid Build Coastguard Worker bool HexagonPassConfig::addInstSelector() {
236*9880d681SAndroid Build Coastguard Worker HexagonTargetMachine &TM = getHexagonTargetMachine();
237*9880d681SAndroid Build Coastguard Worker bool NoOpt = (getOptLevel() == CodeGenOpt::None);
238*9880d681SAndroid Build Coastguard Worker
239*9880d681SAndroid Build Coastguard Worker if (!NoOpt)
240*9880d681SAndroid Build Coastguard Worker addPass(createHexagonOptimizeSZextends());
241*9880d681SAndroid Build Coastguard Worker
242*9880d681SAndroid Build Coastguard Worker addPass(createHexagonISelDag(TM, getOptLevel()));
243*9880d681SAndroid Build Coastguard Worker
244*9880d681SAndroid Build Coastguard Worker if (!NoOpt) {
245*9880d681SAndroid Build Coastguard Worker // Create logical operations on predicate registers.
246*9880d681SAndroid Build Coastguard Worker if (EnableGenPred)
247*9880d681SAndroid Build Coastguard Worker addPass(createHexagonGenPredicate(), false);
248*9880d681SAndroid Build Coastguard Worker // Rotate loops to expose bit-simplification opportunities.
249*9880d681SAndroid Build Coastguard Worker if (EnableLoopResched)
250*9880d681SAndroid Build Coastguard Worker addPass(createHexagonLoopRescheduling(), false);
251*9880d681SAndroid Build Coastguard Worker // Split double registers.
252*9880d681SAndroid Build Coastguard Worker if (!DisableHSDR)
253*9880d681SAndroid Build Coastguard Worker addPass(createHexagonSplitDoubleRegs());
254*9880d681SAndroid Build Coastguard Worker // Bit simplification.
255*9880d681SAndroid Build Coastguard Worker if (EnableBitSimplify)
256*9880d681SAndroid Build Coastguard Worker addPass(createHexagonBitSimplify(), false);
257*9880d681SAndroid Build Coastguard Worker addPass(createHexagonPeephole());
258*9880d681SAndroid Build Coastguard Worker printAndVerify("After hexagon peephole pass");
259*9880d681SAndroid Build Coastguard Worker if (EnableGenInsert)
260*9880d681SAndroid Build Coastguard Worker addPass(createHexagonGenInsert(), false);
261*9880d681SAndroid Build Coastguard Worker if (EnableEarlyIf)
262*9880d681SAndroid Build Coastguard Worker addPass(createHexagonEarlyIfConversion(), false);
263*9880d681SAndroid Build Coastguard Worker }
264*9880d681SAndroid Build Coastguard Worker
265*9880d681SAndroid Build Coastguard Worker return false;
266*9880d681SAndroid Build Coastguard Worker }
267*9880d681SAndroid Build Coastguard Worker
addPreRegAlloc()268*9880d681SAndroid Build Coastguard Worker void HexagonPassConfig::addPreRegAlloc() {
269*9880d681SAndroid Build Coastguard Worker if (getOptLevel() != CodeGenOpt::None) {
270*9880d681SAndroid Build Coastguard Worker if (EnableExpandCondsets) {
271*9880d681SAndroid Build Coastguard Worker Pass *Exp = createHexagonExpandCondsets();
272*9880d681SAndroid Build Coastguard Worker insertPass(&RegisterCoalescerID, IdentifyingPassPtr(Exp));
273*9880d681SAndroid Build Coastguard Worker }
274*9880d681SAndroid Build Coastguard Worker if (!DisableStoreWidening)
275*9880d681SAndroid Build Coastguard Worker addPass(createHexagonStoreWidening(), false);
276*9880d681SAndroid Build Coastguard Worker if (!DisableHardwareLoops)
277*9880d681SAndroid Build Coastguard Worker addPass(createHexagonHardwareLoops(), false);
278*9880d681SAndroid Build Coastguard Worker }
279*9880d681SAndroid Build Coastguard Worker if (TM->getOptLevel() >= CodeGenOpt::Default)
280*9880d681SAndroid Build Coastguard Worker addPass(&MachinePipelinerID);
281*9880d681SAndroid Build Coastguard Worker }
282*9880d681SAndroid Build Coastguard Worker
addPostRegAlloc()283*9880d681SAndroid Build Coastguard Worker void HexagonPassConfig::addPostRegAlloc() {
284*9880d681SAndroid Build Coastguard Worker if (getOptLevel() != CodeGenOpt::None) {
285*9880d681SAndroid Build Coastguard Worker if (EnableRDFOpt)
286*9880d681SAndroid Build Coastguard Worker addPass(createHexagonRDFOpt());
287*9880d681SAndroid Build Coastguard Worker if (!DisableHexagonCFGOpt)
288*9880d681SAndroid Build Coastguard Worker addPass(createHexagonCFGOptimizer(), false);
289*9880d681SAndroid Build Coastguard Worker if (!DisableAModeOpt)
290*9880d681SAndroid Build Coastguard Worker addPass(createHexagonOptAddrMode(), false);
291*9880d681SAndroid Build Coastguard Worker }
292*9880d681SAndroid Build Coastguard Worker }
293*9880d681SAndroid Build Coastguard Worker
addPreSched2()294*9880d681SAndroid Build Coastguard Worker void HexagonPassConfig::addPreSched2() {
295*9880d681SAndroid Build Coastguard Worker addPass(createHexagonCopyToCombine(), false);
296*9880d681SAndroid Build Coastguard Worker if (getOptLevel() != CodeGenOpt::None)
297*9880d681SAndroid Build Coastguard Worker addPass(&IfConverterID, false);
298*9880d681SAndroid Build Coastguard Worker addPass(createHexagonSplitConst32AndConst64());
299*9880d681SAndroid Build Coastguard Worker }
300*9880d681SAndroid Build Coastguard Worker
addPreEmitPass()301*9880d681SAndroid Build Coastguard Worker void HexagonPassConfig::addPreEmitPass() {
302*9880d681SAndroid Build Coastguard Worker bool NoOpt = (getOptLevel() == CodeGenOpt::None);
303*9880d681SAndroid Build Coastguard Worker
304*9880d681SAndroid Build Coastguard Worker if (!NoOpt)
305*9880d681SAndroid Build Coastguard Worker addPass(createHexagonNewValueJump(), false);
306*9880d681SAndroid Build Coastguard Worker
307*9880d681SAndroid Build Coastguard Worker addPass(createHexagonBranchRelaxation(), false);
308*9880d681SAndroid Build Coastguard Worker
309*9880d681SAndroid Build Coastguard Worker // Create Packets.
310*9880d681SAndroid Build Coastguard Worker if (!NoOpt) {
311*9880d681SAndroid Build Coastguard Worker if (!DisableHardwareLoops)
312*9880d681SAndroid Build Coastguard Worker addPass(createHexagonFixupHwLoops(), false);
313*9880d681SAndroid Build Coastguard Worker // Generate MUX from pairs of conditional transfers.
314*9880d681SAndroid Build Coastguard Worker if (EnableGenMux)
315*9880d681SAndroid Build Coastguard Worker addPass(createHexagonGenMux(), false);
316*9880d681SAndroid Build Coastguard Worker
317*9880d681SAndroid Build Coastguard Worker addPass(createHexagonPacketizer(), false);
318*9880d681SAndroid Build Coastguard Worker }
319*9880d681SAndroid Build Coastguard Worker
320*9880d681SAndroid Build Coastguard Worker // Add CFI instructions if necessary.
321*9880d681SAndroid Build Coastguard Worker addPass(createHexagonCallFrameInformation(), false);
322*9880d681SAndroid Build Coastguard Worker }
323