2012-02-18 20:03:15 +08:00
|
|
|
//===-- HexagonTargetMachine.cpp - Define TargetMachine for Hexagon -------===//
|
2011-12-13 05:14:40 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2012-02-18 20:03:15 +08:00
|
|
|
// Implements the info about Hexagon target spec.
|
2011-12-13 05:14:40 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "HexagonTargetMachine.h"
|
|
|
|
#include "Hexagon.h"
|
|
|
|
#include "HexagonISelLowering.h"
|
2012-09-04 22:49:56 +08:00
|
|
|
#include "HexagonMachineScheduler.h"
|
2013-05-08 03:53:00 +08:00
|
|
|
#include "HexagonTargetObjectFile.h"
|
2015-08-06 02:35:37 +08:00
|
|
|
#include "HexagonTargetTransformInfo.h"
|
2011-12-13 05:14:40 +08:00
|
|
|
#include "llvm/CodeGen/Passes.h"
|
2016-05-10 11:21:59 +08:00
|
|
|
#include "llvm/CodeGen/TargetPassConfig.h"
|
2015-02-13 18:01:29 +08:00
|
|
|
#include "llvm/IR/LegacyPassManager.h"
|
2013-01-02 19:36:10 +08:00
|
|
|
#include "llvm/IR/Module.h"
|
2012-02-06 18:19:29 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2011-12-13 05:14:40 +08:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/Transforms/Scalar.h"
|
2011-12-13 05:14:40 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2016-01-13 03:09:01 +08:00
|
|
|
|
|
|
|
static cl::opt<bool> EnableRDFOpt("rdf-opt", cl::Hidden, cl::ZeroOrMore,
|
|
|
|
cl::init(true), cl::desc("Enable RDF-based optimizations"));
|
|
|
|
|
|
|
|
static cl::opt<bool> DisableHardwareLoops("disable-hexagon-hwloops",
|
2015-03-31 21:35:12 +08:00
|
|
|
cl::Hidden, cl::desc("Disable Hardware Loops for Hexagon target"));
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2016-04-29 23:49:13 +08:00
|
|
|
static cl::opt<bool> DisableAModeOpt("disable-hexagon-amodeopt",
|
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::init(false),
|
|
|
|
cl::desc("Disable Hexagon Addressing Mode Optimization"));
|
|
|
|
|
2013-03-27 19:14:24 +08:00
|
|
|
static cl::opt<bool> DisableHexagonCFGOpt("disable-hexagon-cfgopt",
|
2015-03-31 21:35:12 +08:00
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::init(false),
|
|
|
|
cl::desc("Disable Hexagon CFG Optimization"));
|
|
|
|
|
2016-07-29 04:01:59 +08:00
|
|
|
static cl::opt<bool> DisableHCP("disable-hcp", cl::init(false), cl::Hidden,
|
|
|
|
cl::ZeroOrMore, cl::desc("Disable Hexagon constant propagation"));
|
|
|
|
|
2015-10-17 03:43:56 +08:00
|
|
|
static cl::opt<bool> DisableStoreWidening("disable-store-widen",
|
|
|
|
cl::Hidden, cl::init(false), cl::desc("Disable store widening"));
|
|
|
|
|
2015-03-31 21:35:12 +08:00
|
|
|
static cl::opt<bool> EnableExpandCondsets("hexagon-expand-condsets",
|
|
|
|
cl::init(true), cl::Hidden, cl::ZeroOrMore,
|
|
|
|
cl::desc("Early expansion of MUX"));
|
2013-05-07 05:25:45 +08:00
|
|
|
|
2015-10-06 23:49:14 +08:00
|
|
|
static cl::opt<bool> EnableEarlyIf("hexagon-eif", cl::init(true), cl::Hidden,
|
|
|
|
cl::ZeroOrMore, cl::desc("Enable early if-conversion"));
|
|
|
|
|
2015-07-08 22:47:34 +08:00
|
|
|
static cl::opt<bool> EnableGenInsert("hexagon-insert", cl::init(true),
|
|
|
|
cl::Hidden, cl::desc("Generate \"insert\" instructions"));
|
2013-03-27 19:14:24 +08:00
|
|
|
|
2015-07-09 03:22:28 +08:00
|
|
|
static cl::opt<bool> EnableCommGEP("hexagon-commgep", cl::init(true),
|
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::desc("Enable commoning of GEP instructions"));
|
|
|
|
|
2015-07-15 01:07:24 +08:00
|
|
|
static cl::opt<bool> EnableGenExtract("hexagon-extract", cl::init(true),
|
|
|
|
cl::Hidden, cl::desc("Generate \"extract\" instructions"));
|
2015-07-09 03:22:28 +08:00
|
|
|
|
2015-07-21 05:23:25 +08:00
|
|
|
static cl::opt<bool> EnableGenMux("hexagon-mux", cl::init(true), cl::Hidden,
|
|
|
|
cl::desc("Enable converting conditional transfers into MUX instructions"));
|
|
|
|
|
2015-07-15 03:30:21 +08:00
|
|
|
static cl::opt<bool> EnableGenPred("hexagon-gen-pred", cl::init(true),
|
|
|
|
cl::Hidden, cl::desc("Enable conversion of arithmetic operations to "
|
|
|
|
"predicate instructions"));
|
|
|
|
|
2016-07-22 22:22:43 +08:00
|
|
|
static cl::opt<bool> EnableLoopPrefetch("hexagon-loop-prefetch",
|
|
|
|
cl::init(false), cl::Hidden, cl::ZeroOrMore,
|
|
|
|
cl::desc("Enable loop data prefetch on Hexagon"));
|
|
|
|
|
2015-10-17 04:38:54 +08:00
|
|
|
static cl::opt<bool> DisableHSDR("disable-hsdr", cl::init(false), cl::Hidden,
|
|
|
|
cl::desc("Disable splitting double registers"));
|
|
|
|
|
2015-10-21 06:57:13 +08:00
|
|
|
static cl::opt<bool> EnableBitSimplify("hexagon-bit", cl::init(true),
|
|
|
|
cl::Hidden, cl::desc("Bit simplification"));
|
|
|
|
|
|
|
|
static cl::opt<bool> EnableLoopResched("hexagon-loop-resched", cl::init(true),
|
|
|
|
cl::Hidden, cl::desc("Loop rescheduling"));
|
|
|
|
|
2016-05-11 23:01:30 +08:00
|
|
|
static cl::opt<bool> HexagonNoOpt("hexagon-noopt", cl::init(false),
|
|
|
|
cl::Hidden, cl::desc("Disable backend optimizations"));
|
|
|
|
|
2011-12-13 05:14:40 +08:00
|
|
|
/// HexagonTargetMachineModule - Note that this is used on hosts that
|
|
|
|
/// cannot link in a library unless there are references into the
|
|
|
|
/// library. In particular, it seems that it is not possible to get
|
|
|
|
/// things to work on Win32 without this. Though it is unused, do not
|
|
|
|
/// remove it.
|
|
|
|
extern "C" int HexagonTargetMachineModule;
|
|
|
|
int HexagonTargetMachineModule = 0;
|
|
|
|
|
|
|
|
extern "C" void LLVMInitializeHexagonTarget() {
|
|
|
|
// Register the target.
|
|
|
|
RegisterTargetMachine<HexagonTargetMachine> X(TheHexagonTarget);
|
|
|
|
}
|
|
|
|
|
2012-09-04 22:49:56 +08:00
|
|
|
static ScheduleDAGInstrs *createVLIWMachineSched(MachineSchedContext *C) {
|
2014-04-22 04:32:32 +08:00
|
|
|
return new VLIWMachineScheduler(C, make_unique<ConvergingVLIWScheduler>());
|
2012-09-04 22:49:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static MachineSchedRegistry
|
|
|
|
SchedCustomRegistry("hexagon", "Run Hexagon's custom scheduler",
|
|
|
|
createVLIWMachineSched);
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2015-03-31 21:35:12 +08:00
|
|
|
namespace llvm {
|
2015-10-21 06:57:13 +08:00
|
|
|
FunctionPass *createHexagonBitSimplify();
|
2016-04-20 02:30:18 +08:00
|
|
|
FunctionPass *createHexagonBranchRelaxation();
|
2015-10-20 01:46:01 +08:00
|
|
|
FunctionPass *createHexagonCallFrameInformation();
|
2015-07-15 01:07:24 +08:00
|
|
|
FunctionPass *createHexagonCFGOptimizer();
|
2015-07-09 03:22:28 +08:00
|
|
|
FunctionPass *createHexagonCommonGEP();
|
2016-07-29 04:01:59 +08:00
|
|
|
FunctionPass *createHexagonConstPropagationPass();
|
2015-07-15 01:07:24 +08:00
|
|
|
FunctionPass *createHexagonCopyToCombine();
|
2015-10-06 23:49:14 +08:00
|
|
|
FunctionPass *createHexagonEarlyIfConversion();
|
2015-03-31 21:35:12 +08:00
|
|
|
FunctionPass *createHexagonExpandCondsets();
|
2015-07-15 01:07:24 +08:00
|
|
|
FunctionPass *createHexagonFixupHwLoops();
|
|
|
|
FunctionPass *createHexagonGenExtract();
|
2015-07-08 22:47:34 +08:00
|
|
|
FunctionPass *createHexagonGenInsert();
|
2015-07-21 05:23:25 +08:00
|
|
|
FunctionPass *createHexagonGenMux();
|
2015-07-15 03:30:21 +08:00
|
|
|
FunctionPass *createHexagonGenPredicate();
|
2015-06-16 03:05:35 +08:00
|
|
|
FunctionPass *createHexagonHardwareLoops();
|
2015-07-15 01:07:24 +08:00
|
|
|
FunctionPass *createHexagonISelDag(HexagonTargetMachine &TM,
|
|
|
|
CodeGenOpt::Level OptLevel);
|
2015-10-21 06:57:13 +08:00
|
|
|
FunctionPass *createHexagonLoopRescheduling();
|
2015-06-16 03:05:35 +08:00
|
|
|
FunctionPass *createHexagonNewValueJump();
|
2015-10-20 03:10:48 +08:00
|
|
|
FunctionPass *createHexagonOptimizeSZextends();
|
2016-04-29 23:49:13 +08:00
|
|
|
FunctionPass *createHexagonOptAddrMode();
|
2015-06-16 03:05:35 +08:00
|
|
|
FunctionPass *createHexagonPacketizer();
|
2015-07-15 01:07:24 +08:00
|
|
|
FunctionPass *createHexagonPeephole();
|
2016-01-13 03:09:01 +08:00
|
|
|
FunctionPass *createHexagonRDFOpt();
|
2015-07-15 01:07:24 +08:00
|
|
|
FunctionPass *createHexagonSplitConst32AndConst64();
|
2015-10-17 04:38:54 +08:00
|
|
|
FunctionPass *createHexagonSplitDoubleRegs();
|
2015-10-17 03:43:56 +08:00
|
|
|
FunctionPass *createHexagonStoreWidening();
|
2015-06-23 17:49:53 +08:00
|
|
|
} // end namespace llvm;
|
2015-03-31 21:35:12 +08:00
|
|
|
|
2016-05-19 06:04:49 +08:00
|
|
|
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
|
|
|
|
if (!RM.hasValue())
|
|
|
|
return Reloc::Static;
|
|
|
|
return *RM;
|
|
|
|
}
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2015-06-12 03:41:26 +08:00
|
|
|
HexagonTargetMachine::HexagonTargetMachine(const Target &T, const Triple &TT,
|
2011-12-13 05:14:40 +08:00
|
|
|
StringRef CPU, StringRef FS,
|
2012-03-17 17:24:09 +08:00
|
|
|
const TargetOptions &Options,
|
2016-05-19 06:04:49 +08:00
|
|
|
Optional<Reloc::Model> RM,
|
|
|
|
CodeModel::Model CM,
|
2011-12-13 05:14:40 +08:00
|
|
|
CodeGenOpt::Level OL)
|
2016-02-12 22:47:38 +08:00
|
|
|
// Specify the vector alignment explicitly. For v512x1, the calculated
|
|
|
|
// alignment would be 512*alignment(i1), which is 512 bytes, instead of
|
|
|
|
// the required minimum of 64 bytes.
|
2016-05-19 06:04:49 +08:00
|
|
|
: LLVMTargetMachine(
|
|
|
|
T, "e-m:e-p:32:32:32-a:0-n16:32-"
|
|
|
|
"i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-"
|
|
|
|
"v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048",
|
|
|
|
TT, CPU, FS, Options, getEffectiveRelocModel(RM), CM,
|
|
|
|
(HexagonNoOpt ? CodeGenOpt::None : OL)),
|
2015-08-06 02:35:37 +08:00
|
|
|
TLOF(make_unique<HexagonTargetObjectFile>()) {
|
|
|
|
initAsmInfo();
|
2011-12-13 05:14:40 +08:00
|
|
|
}
|
|
|
|
|
2015-08-06 02:35:37 +08:00
|
|
|
const HexagonSubtarget *
|
|
|
|
HexagonTargetMachine::getSubtargetImpl(const Function &F) const {
|
|
|
|
AttributeSet FnAttrs = F.getAttributes();
|
|
|
|
Attribute CPUAttr =
|
|
|
|
FnAttrs.getAttribute(AttributeSet::FunctionIndex, "target-cpu");
|
|
|
|
Attribute FSAttr =
|
|
|
|
FnAttrs.getAttribute(AttributeSet::FunctionIndex, "target-features");
|
|
|
|
|
|
|
|
std::string CPU = !CPUAttr.hasAttribute(Attribute::None)
|
|
|
|
? CPUAttr.getValueAsString().str()
|
|
|
|
: TargetCPU;
|
|
|
|
std::string FS = !FSAttr.hasAttribute(Attribute::None)
|
|
|
|
? FSAttr.getValueAsString().str()
|
|
|
|
: TargetFS;
|
|
|
|
|
|
|
|
auto &I = SubtargetMap[CPU + FS];
|
|
|
|
if (!I) {
|
|
|
|
// This needs to be done before we create a new subtarget since any
|
|
|
|
// creation will depend on the TM and the code generation flags on the
|
|
|
|
// function that reside in TargetOptions.
|
|
|
|
resetTargetOptions(F);
|
|
|
|
I = llvm::make_unique<HexagonSubtarget>(TargetTriple, CPU, FS, *this);
|
|
|
|
}
|
|
|
|
return I.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
TargetIRAnalysis HexagonTargetMachine::getTargetIRAnalysis() {
|
2015-09-17 07:38:13 +08:00
|
|
|
return TargetIRAnalysis([this](const Function &F) {
|
2015-08-06 02:35:37 +08:00
|
|
|
return TargetTransformInfo(HexagonTTIImpl(this, F));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-21 07:37:18 +08:00
|
|
|
HexagonTargetMachine::~HexagonTargetMachine() {}
|
|
|
|
|
2012-02-03 13:12:41 +08:00
|
|
|
namespace {
|
|
|
|
/// Hexagon Code Generator Pass Configuration Options.
|
|
|
|
class HexagonPassConfig : public TargetPassConfig {
|
|
|
|
public:
|
2012-02-04 10:56:59 +08:00
|
|
|
HexagonPassConfig(HexagonTargetMachine *TM, PassManagerBase &PM)
|
2016-05-28 04:48:39 +08:00
|
|
|
: TargetPassConfig(TM, PM) {}
|
2012-02-03 13:12:41 +08:00
|
|
|
|
|
|
|
HexagonTargetMachine &getHexagonTargetMachine() const {
|
|
|
|
return getTM<HexagonTargetMachine>();
|
|
|
|
}
|
|
|
|
|
2014-04-29 15:58:16 +08:00
|
|
|
ScheduleDAGInstrs *
|
|
|
|
createMachineScheduler(MachineSchedContext *C) const override {
|
2013-09-20 13:14:41 +08:00
|
|
|
return createVLIWMachineSched(C);
|
|
|
|
}
|
|
|
|
|
2015-07-09 03:22:28 +08:00
|
|
|
void addIRPasses() override;
|
2014-04-29 15:58:16 +08:00
|
|
|
bool addInstSelector() override;
|
2014-12-12 05:26:47 +08:00
|
|
|
void addPreRegAlloc() override;
|
|
|
|
void addPostRegAlloc() override;
|
|
|
|
void addPreSched2() override;
|
|
|
|
void addPreEmitPass() override;
|
2012-02-03 13:12:41 +08:00
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
2012-02-04 10:56:59 +08:00
|
|
|
TargetPassConfig *HexagonTargetMachine::createPassConfig(PassManagerBase &PM) {
|
|
|
|
return new HexagonPassConfig(this, PM);
|
2012-02-03 13:12:41 +08:00
|
|
|
}
|
|
|
|
|
2015-07-09 03:22:28 +08:00
|
|
|
void HexagonPassConfig::addIRPasses() {
|
|
|
|
TargetPassConfig::addIRPasses();
|
|
|
|
bool NoOpt = (getOptLevel() == CodeGenOpt::None);
|
2015-07-09 22:51:21 +08:00
|
|
|
|
|
|
|
addPass(createAtomicExpandPass(TM));
|
2015-07-15 01:07:24 +08:00
|
|
|
if (!NoOpt) {
|
2016-07-22 22:22:43 +08:00
|
|
|
if (EnableLoopPrefetch)
|
|
|
|
addPass(createLoopDataPrefetchPass());
|
2015-07-15 01:07:24 +08:00
|
|
|
if (EnableCommGEP)
|
|
|
|
addPass(createHexagonCommonGEP());
|
|
|
|
// Replace certain combinations of shifts and ands with extracts.
|
|
|
|
if (EnableGenExtract)
|
|
|
|
addPass(createHexagonGenExtract());
|
|
|
|
}
|
2015-07-09 03:22:28 +08:00
|
|
|
}
|
|
|
|
|
2012-02-03 13:12:41 +08:00
|
|
|
bool HexagonPassConfig::addInstSelector() {
|
2013-06-20 05:36:55 +08:00
|
|
|
HexagonTargetMachine &TM = getHexagonTargetMachine();
|
2013-05-07 05:25:45 +08:00
|
|
|
bool NoOpt = (getOptLevel() == CodeGenOpt::None);
|
2013-03-27 19:14:24 +08:00
|
|
|
|
2015-10-20 03:10:48 +08:00
|
|
|
if (!NoOpt)
|
|
|
|
addPass(createHexagonOptimizeSZextends());
|
|
|
|
|
2013-05-07 05:25:45 +08:00
|
|
|
addPass(createHexagonISelDag(TM, getOptLevel()));
|
2013-03-27 19:14:24 +08:00
|
|
|
|
2013-05-07 05:25:45 +08:00
|
|
|
if (!NoOpt) {
|
2015-07-15 03:30:21 +08:00
|
|
|
// Create logical operations on predicate registers.
|
|
|
|
if (EnableGenPred)
|
|
|
|
addPass(createHexagonGenPredicate(), false);
|
2015-10-21 06:57:13 +08:00
|
|
|
// Rotate loops to expose bit-simplification opportunities.
|
|
|
|
if (EnableLoopResched)
|
|
|
|
addPass(createHexagonLoopRescheduling(), false);
|
2015-10-17 04:38:54 +08:00
|
|
|
// Split double registers.
|
|
|
|
if (!DisableHSDR)
|
|
|
|
addPass(createHexagonSplitDoubleRegs());
|
2015-10-21 06:57:13 +08:00
|
|
|
// Bit simplification.
|
|
|
|
if (EnableBitSimplify)
|
|
|
|
addPass(createHexagonBitSimplify(), false);
|
2013-03-27 19:14:24 +08:00
|
|
|
addPass(createHexagonPeephole());
|
2013-05-07 05:25:45 +08:00
|
|
|
printAndVerify("After hexagon peephole pass");
|
2016-07-29 04:01:59 +08:00
|
|
|
// Constant propagation.
|
|
|
|
if (!DisableHCP) {
|
|
|
|
addPass(createHexagonConstPropagationPass(), false);
|
|
|
|
addPass(&UnreachableMachineBlockElimID, false);
|
|
|
|
}
|
2015-07-08 22:47:34 +08:00
|
|
|
if (EnableGenInsert)
|
|
|
|
addPass(createHexagonGenInsert(), false);
|
2015-10-06 23:49:14 +08:00
|
|
|
if (EnableEarlyIf)
|
|
|
|
addPass(createHexagonEarlyIfConversion(), false);
|
2013-05-07 05:25:45 +08:00
|
|
|
}
|
2013-03-27 19:14:24 +08:00
|
|
|
|
2011-12-13 05:14:40 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-12-12 05:26:47 +08:00
|
|
|
void HexagonPassConfig::addPreRegAlloc() {
|
2015-10-17 03:43:56 +08:00
|
|
|
if (getOptLevel() != CodeGenOpt::None) {
|
2016-05-28 04:48:39 +08:00
|
|
|
if (EnableExpandCondsets) {
|
|
|
|
Pass *Exp = createHexagonExpandCondsets();
|
|
|
|
insertPass(&RegisterCoalescerID, IdentifyingPassPtr(Exp));
|
|
|
|
}
|
2015-10-17 03:43:56 +08:00
|
|
|
if (!DisableStoreWidening)
|
|
|
|
addPass(createHexagonStoreWidening(), false);
|
2013-05-07 05:25:45 +08:00
|
|
|
if (!DisableHardwareLoops)
|
2014-12-12 05:26:47 +08:00
|
|
|
addPass(createHexagonHardwareLoops(), false);
|
2015-10-17 03:43:56 +08:00
|
|
|
}
|
2011-12-13 05:14:40 +08:00
|
|
|
}
|
|
|
|
|
2014-12-12 05:26:47 +08:00
|
|
|
void HexagonPassConfig::addPostRegAlloc() {
|
2016-01-13 03:09:01 +08:00
|
|
|
if (getOptLevel() != CodeGenOpt::None) {
|
|
|
|
if (EnableRDFOpt)
|
|
|
|
addPass(createHexagonRDFOpt());
|
2013-05-07 05:25:45 +08:00
|
|
|
if (!DisableHexagonCFGOpt)
|
2015-02-03 02:46:27 +08:00
|
|
|
addPass(createHexagonCFGOptimizer(), false);
|
2016-04-29 23:49:13 +08:00
|
|
|
if (!DisableAModeOpt)
|
|
|
|
addPass(createHexagonOptAddrMode(), false);
|
2016-01-13 03:09:01 +08:00
|
|
|
}
|
2011-12-13 05:14:40 +08:00
|
|
|
}
|
|
|
|
|
2014-12-12 05:26:47 +08:00
|
|
|
void HexagonPassConfig::addPreSched2() {
|
|
|
|
addPass(createHexagonCopyToCombine(), false);
|
2013-05-08 03:53:00 +08:00
|
|
|
if (getOptLevel() != CodeGenOpt::None)
|
2014-12-12 05:26:47 +08:00
|
|
|
addPass(&IfConverterID, false);
|
2015-02-03 06:11:43 +08:00
|
|
|
addPass(createHexagonSplitConst32AndConst64());
|
2011-12-13 05:14:40 +08:00
|
|
|
}
|
|
|
|
|
2014-12-12 05:26:47 +08:00
|
|
|
void HexagonPassConfig::addPreEmitPass() {
|
2013-05-07 05:25:45 +08:00
|
|
|
bool NoOpt = (getOptLevel() == CodeGenOpt::None);
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2013-05-07 05:25:45 +08:00
|
|
|
if (!NoOpt)
|
2014-12-12 05:26:47 +08:00
|
|
|
addPass(createHexagonNewValueJump(), false);
|
2012-05-12 13:10:30 +08:00
|
|
|
|
2016-04-20 02:30:18 +08:00
|
|
|
addPass(createHexagonBranchRelaxation(), false);
|
|
|
|
|
2012-05-04 05:52:53 +08:00
|
|
|
// Create Packets.
|
2013-05-07 05:25:45 +08:00
|
|
|
if (!NoOpt) {
|
|
|
|
if (!DisableHardwareLoops)
|
2014-12-12 05:26:47 +08:00
|
|
|
addPass(createHexagonFixupHwLoops(), false);
|
2015-07-21 05:23:25 +08:00
|
|
|
// Generate MUX from pairs of conditional transfers.
|
|
|
|
if (EnableGenMux)
|
|
|
|
addPass(createHexagonGenMux(), false);
|
|
|
|
|
2014-12-12 05:26:47 +08:00
|
|
|
addPass(createHexagonPacketizer(), false);
|
2013-05-07 05:25:45 +08:00
|
|
|
}
|
2015-10-20 01:46:01 +08:00
|
|
|
|
|
|
|
// Add CFI instructions if necessary.
|
|
|
|
addPass(createHexagonCallFrameInformation(), false);
|
2011-12-13 05:14:40 +08:00
|
|
|
}
|