2012-02-18 13:03:15 +01:00
|
|
|
//===-- HexagonTargetMachine.cpp - Define TargetMachine for Hexagon -------===//
|
2011-12-12 22:14:40 +01: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 13:03:15 +01:00
|
|
|
// Implements the info about Hexagon target spec.
|
2011-12-12 22:14:40 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "HexagonTargetMachine.h"
|
|
|
|
#include "Hexagon.h"
|
|
|
|
#include "HexagonISelLowering.h"
|
2012-09-04 16:49:56 +02:00
|
|
|
#include "HexagonMachineScheduler.h"
|
2013-05-07 21:53:00 +02:00
|
|
|
#include "HexagonTargetObjectFile.h"
|
2015-08-05 20:35:37 +02:00
|
|
|
#include "HexagonTargetTransformInfo.h"
|
2011-12-12 22:14:40 +01:00
|
|
|
#include "llvm/CodeGen/Passes.h"
|
2016-05-10 05:21:59 +02:00
|
|
|
#include "llvm/CodeGen/TargetPassConfig.h"
|
2015-02-13 11:01:29 +01:00
|
|
|
#include "llvm/IR/LegacyPassManager.h"
|
2013-01-02 12:36:10 +01:00
|
|
|
#include "llvm/IR/Module.h"
|
2012-02-06 11:19:29 +01:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2011-12-12 22:14:40 +01:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
2012-12-03 17:50:05 +01:00
|
|
|
#include "llvm/Transforms/Scalar.h"
|
2017-01-26 22:41:10 +01:00
|
|
|
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
|
2011-12-12 22:14:40 +01:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2016-01-12 20:09:01 +01: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 15:35:12 +02:00
|
|
|
cl::Hidden, cl::desc("Disable Hardware Loops for Hexagon target"));
|
2011-12-12 22:14:40 +01:00
|
|
|
|
2016-04-29 17:49:13 +02: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 12:14:24 +01:00
|
|
|
static cl::opt<bool> DisableHexagonCFGOpt("disable-hexagon-cfgopt",
|
2015-03-31 15:35:12 +02:00
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::init(false),
|
|
|
|
cl::desc("Disable Hexagon CFG Optimization"));
|
|
|
|
|
2016-07-28 22:01:59 +02:00
|
|
|
static cl::opt<bool> DisableHCP("disable-hcp", cl::init(false), cl::Hidden,
|
|
|
|
cl::ZeroOrMore, cl::desc("Disable Hexagon constant propagation"));
|
|
|
|
|
2015-10-16 21:43:56 +02:00
|
|
|
static cl::opt<bool> DisableStoreWidening("disable-store-widen",
|
|
|
|
cl::Hidden, cl::init(false), cl::desc("Disable store widening"));
|
|
|
|
|
2015-03-31 15:35:12 +02:00
|
|
|
static cl::opt<bool> EnableExpandCondsets("hexagon-expand-condsets",
|
|
|
|
cl::init(true), cl::Hidden, cl::ZeroOrMore,
|
|
|
|
cl::desc("Early expansion of MUX"));
|
2013-05-06 23:25:45 +02:00
|
|
|
|
2015-10-06 17:49:14 +02:00
|
|
|
static cl::opt<bool> EnableEarlyIf("hexagon-eif", cl::init(true), cl::Hidden,
|
|
|
|
cl::ZeroOrMore, cl::desc("Enable early if-conversion"));
|
|
|
|
|
2015-07-08 16:47:34 +02:00
|
|
|
static cl::opt<bool> EnableGenInsert("hexagon-insert", cl::init(true),
|
|
|
|
cl::Hidden, cl::desc("Generate \"insert\" instructions"));
|
2013-03-27 12:14:24 +01:00
|
|
|
|
2015-07-08 21:22:28 +02:00
|
|
|
static cl::opt<bool> EnableCommGEP("hexagon-commgep", cl::init(true),
|
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::desc("Enable commoning of GEP instructions"));
|
|
|
|
|
2015-07-14 19:07:24 +02:00
|
|
|
static cl::opt<bool> EnableGenExtract("hexagon-extract", cl::init(true),
|
|
|
|
cl::Hidden, cl::desc("Generate \"extract\" instructions"));
|
2015-07-08 21:22:28 +02:00
|
|
|
|
2015-07-20 23:23:25 +02:00
|
|
|
static cl::opt<bool> EnableGenMux("hexagon-mux", cl::init(true), cl::Hidden,
|
|
|
|
cl::desc("Enable converting conditional transfers into MUX instructions"));
|
|
|
|
|
2015-07-14 21:30:21 +02: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 16:22:43 +02: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-16 22:38:54 +02:00
|
|
|
static cl::opt<bool> DisableHSDR("disable-hsdr", cl::init(false), cl::Hidden,
|
|
|
|
cl::desc("Disable splitting double registers"));
|
|
|
|
|
2015-10-21 00:57:13 +02: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 17:01:30 +02:00
|
|
|
static cl::opt<bool> HexagonNoOpt("hexagon-noopt", cl::init(false),
|
|
|
|
cl::Hidden, cl::desc("Disable backend optimizations"));
|
|
|
|
|
2016-08-01 21:36:39 +02:00
|
|
|
static cl::opt<bool> EnableVectorPrint("enable-hexagon-vector-print",
|
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::init(false),
|
|
|
|
cl::desc("Enable Hexagon Vector print instr pass"));
|
|
|
|
|
2011-12-12 22:14:40 +01: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;
|
|
|
|
|
2012-09-04 16:49:56 +02:00
|
|
|
static ScheduleDAGInstrs *createVLIWMachineSched(MachineSchedContext *C) {
|
2014-04-21 22:32:32 +02:00
|
|
|
return new VLIWMachineScheduler(C, make_unique<ConvergingVLIWScheduler>());
|
2012-09-04 16:49:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static MachineSchedRegistry
|
|
|
|
SchedCustomRegistry("hexagon", "Run Hexagon's custom scheduler",
|
|
|
|
createVLIWMachineSched);
|
2011-12-12 22:14:40 +01:00
|
|
|
|
2015-03-31 15:35:12 +02:00
|
|
|
namespace llvm {
|
2016-08-25 00:27:36 +02:00
|
|
|
extern char &HexagonExpandCondsetsID;
|
|
|
|
void initializeHexagonExpandCondsetsPass(PassRegistry&);
|
2017-01-26 22:41:10 +01:00
|
|
|
void initializeHexagonLoopIdiomRecognizePass(PassRegistry&);
|
2017-04-19 17:15:51 +02:00
|
|
|
void initializeHexagonOptAddrModePass(PassRegistry&);
|
2017-01-26 22:41:10 +01:00
|
|
|
Pass *createHexagonLoopIdiomPass();
|
2016-08-25 00:27:36 +02:00
|
|
|
|
2015-10-21 00:57:13 +02:00
|
|
|
FunctionPass *createHexagonBitSimplify();
|
2016-04-19 20:30:18 +02:00
|
|
|
FunctionPass *createHexagonBranchRelaxation();
|
2015-10-19 19:46:01 +02:00
|
|
|
FunctionPass *createHexagonCallFrameInformation();
|
2015-07-14 19:07:24 +02:00
|
|
|
FunctionPass *createHexagonCFGOptimizer();
|
2015-07-08 21:22:28 +02:00
|
|
|
FunctionPass *createHexagonCommonGEP();
|
2016-07-28 22:01:59 +02:00
|
|
|
FunctionPass *createHexagonConstPropagationPass();
|
2015-07-14 19:07:24 +02:00
|
|
|
FunctionPass *createHexagonCopyToCombine();
|
2015-10-06 17:49:14 +02:00
|
|
|
FunctionPass *createHexagonEarlyIfConversion();
|
2015-07-14 19:07:24 +02:00
|
|
|
FunctionPass *createHexagonFixupHwLoops();
|
|
|
|
FunctionPass *createHexagonGenExtract();
|
2015-07-08 16:47:34 +02:00
|
|
|
FunctionPass *createHexagonGenInsert();
|
2015-07-20 23:23:25 +02:00
|
|
|
FunctionPass *createHexagonGenMux();
|
2015-07-14 21:30:21 +02:00
|
|
|
FunctionPass *createHexagonGenPredicate();
|
2015-06-15 21:05:35 +02:00
|
|
|
FunctionPass *createHexagonHardwareLoops();
|
2015-07-14 19:07:24 +02:00
|
|
|
FunctionPass *createHexagonISelDag(HexagonTargetMachine &TM,
|
|
|
|
CodeGenOpt::Level OptLevel);
|
2015-10-21 00:57:13 +02:00
|
|
|
FunctionPass *createHexagonLoopRescheduling();
|
2015-06-15 21:05:35 +02:00
|
|
|
FunctionPass *createHexagonNewValueJump();
|
2015-10-19 21:10:48 +02:00
|
|
|
FunctionPass *createHexagonOptimizeSZextends();
|
2016-04-29 17:49:13 +02:00
|
|
|
FunctionPass *createHexagonOptAddrMode();
|
2015-06-15 21:05:35 +02:00
|
|
|
FunctionPass *createHexagonPacketizer();
|
2015-07-14 19:07:24 +02:00
|
|
|
FunctionPass *createHexagonPeephole();
|
2016-01-12 20:09:01 +01:00
|
|
|
FunctionPass *createHexagonRDFOpt();
|
2015-07-14 19:07:24 +02:00
|
|
|
FunctionPass *createHexagonSplitConst32AndConst64();
|
2015-10-16 22:38:54 +02:00
|
|
|
FunctionPass *createHexagonSplitDoubleRegs();
|
2015-10-16 21:43:56 +02:00
|
|
|
FunctionPass *createHexagonStoreWidening();
|
2016-08-01 21:36:39 +02:00
|
|
|
FunctionPass *createHexagonVectorPrint();
|
2015-06-23 11:49:53 +02:00
|
|
|
} // end namespace llvm;
|
2015-03-31 15:35:12 +02:00
|
|
|
|
2016-05-19 00:04:49 +02:00
|
|
|
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
|
|
|
|
if (!RM.hasValue())
|
|
|
|
return Reloc::Static;
|
|
|
|
return *RM;
|
|
|
|
}
|
2011-12-12 22:14:40 +01:00
|
|
|
|
2017-01-26 22:41:10 +01:00
|
|
|
extern "C" void LLVMInitializeHexagonTarget() {
|
|
|
|
// Register the target.
|
|
|
|
RegisterTargetMachine<HexagonTargetMachine> X(getTheHexagonTarget());
|
|
|
|
initializeHexagonLoopIdiomRecognizePass(*PassRegistry::getPassRegistry());
|
2017-04-19 17:15:51 +02:00
|
|
|
initializeHexagonOptAddrModePass(*PassRegistry::getPassRegistry());
|
2017-01-26 22:41:10 +01:00
|
|
|
}
|
|
|
|
|
2015-06-11 21:41:26 +02:00
|
|
|
HexagonTargetMachine::HexagonTargetMachine(const Target &T, const Triple &TT,
|
2011-12-12 22:14:40 +01:00
|
|
|
StringRef CPU, StringRef FS,
|
2012-03-17 10:24:09 +01:00
|
|
|
const TargetOptions &Options,
|
2016-05-19 00:04:49 +02:00
|
|
|
Optional<Reloc::Model> RM,
|
|
|
|
CodeModel::Model CM,
|
2011-12-12 22:14:40 +01:00
|
|
|
CodeGenOpt::Level OL)
|
2016-02-12 15:47:38 +01: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 00:04:49 +02: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-05 20:35:37 +02:00
|
|
|
TLOF(make_unique<HexagonTargetObjectFile>()) {
|
2016-08-25 00:27:36 +02:00
|
|
|
initializeHexagonExpandCondsetsPass(*PassRegistry::getPassRegistry());
|
2015-08-05 20:35:37 +02:00
|
|
|
initAsmInfo();
|
2011-12-12 22:14:40 +01:00
|
|
|
}
|
|
|
|
|
2015-08-05 20:35:37 +02:00
|
|
|
const HexagonSubtarget *
|
|
|
|
HexagonTargetMachine::getSubtargetImpl(const Function &F) const {
|
Rename AttributeSet to AttributeList
Summary:
This class is a list of AttributeSetNodes corresponding the function
prototype of a call or function declaration. This class used to be
called ParamAttrListPtr, then AttrListPtr, then AttributeSet. It is
typically accessed by parameter and return value index, so
"AttributeList" seems like a more intuitive name.
Rename AttributeSetImpl to AttributeListImpl to follow suit.
It's useful to rename this class so that we can rename AttributeSetNode
to AttributeSet later. AttributeSet is the set of attributes that apply
to a single function, argument, or return value.
Reviewers: sanjoy, javed.absar, chandlerc, pete
Reviewed By: pete
Subscribers: pete, jholewinski, arsenm, dschuff, mehdi_amini, jfb, nhaehnle, sbc100, void, llvm-commits
Differential Revision: https://reviews.llvm.org/D31102
llvm-svn: 298393
2017-03-21 17:57:19 +01:00
|
|
|
AttributeList FnAttrs = F.getAttributes();
|
2015-08-05 20:35:37 +02:00
|
|
|
Attribute CPUAttr =
|
Rename AttributeSet to AttributeList
Summary:
This class is a list of AttributeSetNodes corresponding the function
prototype of a call or function declaration. This class used to be
called ParamAttrListPtr, then AttrListPtr, then AttributeSet. It is
typically accessed by parameter and return value index, so
"AttributeList" seems like a more intuitive name.
Rename AttributeSetImpl to AttributeListImpl to follow suit.
It's useful to rename this class so that we can rename AttributeSetNode
to AttributeSet later. AttributeSet is the set of attributes that apply
to a single function, argument, or return value.
Reviewers: sanjoy, javed.absar, chandlerc, pete
Reviewed By: pete
Subscribers: pete, jholewinski, arsenm, dschuff, mehdi_amini, jfb, nhaehnle, sbc100, void, llvm-commits
Differential Revision: https://reviews.llvm.org/D31102
llvm-svn: 298393
2017-03-21 17:57:19 +01:00
|
|
|
FnAttrs.getAttribute(AttributeList::FunctionIndex, "target-cpu");
|
2015-08-05 20:35:37 +02:00
|
|
|
Attribute FSAttr =
|
Rename AttributeSet to AttributeList
Summary:
This class is a list of AttributeSetNodes corresponding the function
prototype of a call or function declaration. This class used to be
called ParamAttrListPtr, then AttrListPtr, then AttributeSet. It is
typically accessed by parameter and return value index, so
"AttributeList" seems like a more intuitive name.
Rename AttributeSetImpl to AttributeListImpl to follow suit.
It's useful to rename this class so that we can rename AttributeSetNode
to AttributeSet later. AttributeSet is the set of attributes that apply
to a single function, argument, or return value.
Reviewers: sanjoy, javed.absar, chandlerc, pete
Reviewed By: pete
Subscribers: pete, jholewinski, arsenm, dschuff, mehdi_amini, jfb, nhaehnle, sbc100, void, llvm-commits
Differential Revision: https://reviews.llvm.org/D31102
llvm-svn: 298393
2017-03-21 17:57:19 +01:00
|
|
|
FnAttrs.getAttribute(AttributeList::FunctionIndex, "target-features");
|
2015-08-05 20:35:37 +02:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2017-01-26 22:41:10 +01:00
|
|
|
void HexagonTargetMachine::adjustPassManager(PassManagerBuilder &PMB) {
|
|
|
|
PMB.addExtension(
|
|
|
|
PassManagerBuilder::EP_LateLoopOptimizations,
|
|
|
|
[&](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
|
|
|
|
PM.add(createHexagonLoopIdiomPass());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-08-05 20:35:37 +02:00
|
|
|
TargetIRAnalysis HexagonTargetMachine::getTargetIRAnalysis() {
|
2015-09-17 01:38:13 +02:00
|
|
|
return TargetIRAnalysis([this](const Function &F) {
|
2015-08-05 20:35:37 +02:00
|
|
|
return TargetTransformInfo(HexagonTTIImpl(this, F));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-21 00:37:18 +01:00
|
|
|
HexagonTargetMachine::~HexagonTargetMachine() {}
|
|
|
|
|
2012-02-03 06:12:41 +01:00
|
|
|
namespace {
|
|
|
|
/// Hexagon Code Generator Pass Configuration Options.
|
|
|
|
class HexagonPassConfig : public TargetPassConfig {
|
|
|
|
public:
|
2017-05-30 23:36:41 +02:00
|
|
|
HexagonPassConfig(HexagonTargetMachine &TM, PassManagerBase &PM)
|
2016-05-27 22:48:39 +02:00
|
|
|
: TargetPassConfig(TM, PM) {}
|
2012-02-03 06:12:41 +01:00
|
|
|
|
|
|
|
HexagonTargetMachine &getHexagonTargetMachine() const {
|
|
|
|
return getTM<HexagonTargetMachine>();
|
|
|
|
}
|
|
|
|
|
2014-04-29 09:58:16 +02:00
|
|
|
ScheduleDAGInstrs *
|
|
|
|
createMachineScheduler(MachineSchedContext *C) const override {
|
2013-09-20 07:14:41 +02:00
|
|
|
return createVLIWMachineSched(C);
|
|
|
|
}
|
|
|
|
|
2015-07-08 21:22:28 +02:00
|
|
|
void addIRPasses() override;
|
2014-04-29 09:58:16 +02:00
|
|
|
bool addInstSelector() override;
|
2014-12-11 22:26:47 +01:00
|
|
|
void addPreRegAlloc() override;
|
|
|
|
void addPostRegAlloc() override;
|
|
|
|
void addPreSched2() override;
|
|
|
|
void addPreEmitPass() override;
|
2012-02-03 06:12:41 +01:00
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
2012-02-04 03:56:59 +01:00
|
|
|
TargetPassConfig *HexagonTargetMachine::createPassConfig(PassManagerBase &PM) {
|
2017-05-30 23:36:41 +02:00
|
|
|
return new HexagonPassConfig(*this, PM);
|
2012-02-03 06:12:41 +01:00
|
|
|
}
|
|
|
|
|
2015-07-08 21:22:28 +02:00
|
|
|
void HexagonPassConfig::addIRPasses() {
|
|
|
|
TargetPassConfig::addIRPasses();
|
|
|
|
bool NoOpt = (getOptLevel() == CodeGenOpt::None);
|
2015-07-09 16:51:21 +02:00
|
|
|
|
2017-05-18 19:21:13 +02:00
|
|
|
addPass(createAtomicExpandPass());
|
2015-07-14 19:07:24 +02:00
|
|
|
if (!NoOpt) {
|
2016-07-22 16:22:43 +02:00
|
|
|
if (EnableLoopPrefetch)
|
|
|
|
addPass(createLoopDataPrefetchPass());
|
2015-07-14 19:07:24 +02:00
|
|
|
if (EnableCommGEP)
|
|
|
|
addPass(createHexagonCommonGEP());
|
|
|
|
// Replace certain combinations of shifts and ands with extracts.
|
|
|
|
if (EnableGenExtract)
|
|
|
|
addPass(createHexagonGenExtract());
|
|
|
|
}
|
2015-07-08 21:22:28 +02:00
|
|
|
}
|
|
|
|
|
2012-02-03 06:12:41 +01:00
|
|
|
bool HexagonPassConfig::addInstSelector() {
|
2013-06-19 23:36:55 +02:00
|
|
|
HexagonTargetMachine &TM = getHexagonTargetMachine();
|
2013-05-06 23:25:45 +02:00
|
|
|
bool NoOpt = (getOptLevel() == CodeGenOpt::None);
|
2013-03-27 12:14:24 +01:00
|
|
|
|
2015-10-19 21:10:48 +02:00
|
|
|
if (!NoOpt)
|
|
|
|
addPass(createHexagonOptimizeSZextends());
|
|
|
|
|
2013-05-06 23:25:45 +02:00
|
|
|
addPass(createHexagonISelDag(TM, getOptLevel()));
|
2013-03-27 12:14:24 +01:00
|
|
|
|
2013-05-06 23:25:45 +02:00
|
|
|
if (!NoOpt) {
|
2015-07-14 21:30:21 +02:00
|
|
|
// Create logical operations on predicate registers.
|
|
|
|
if (EnableGenPred)
|
|
|
|
addPass(createHexagonGenPredicate(), false);
|
2015-10-21 00:57:13 +02:00
|
|
|
// Rotate loops to expose bit-simplification opportunities.
|
|
|
|
if (EnableLoopResched)
|
|
|
|
addPass(createHexagonLoopRescheduling(), false);
|
2015-10-16 22:38:54 +02:00
|
|
|
// Split double registers.
|
|
|
|
if (!DisableHSDR)
|
|
|
|
addPass(createHexagonSplitDoubleRegs());
|
2015-10-21 00:57:13 +02:00
|
|
|
// Bit simplification.
|
|
|
|
if (EnableBitSimplify)
|
|
|
|
addPass(createHexagonBitSimplify(), false);
|
2013-03-27 12:14:24 +01:00
|
|
|
addPass(createHexagonPeephole());
|
2013-05-06 23:25:45 +02:00
|
|
|
printAndVerify("After hexagon peephole pass");
|
2016-07-28 22:01:59 +02:00
|
|
|
// Constant propagation.
|
|
|
|
if (!DisableHCP) {
|
|
|
|
addPass(createHexagonConstPropagationPass(), false);
|
|
|
|
addPass(&UnreachableMachineBlockElimID, false);
|
|
|
|
}
|
2015-07-08 16:47:34 +02:00
|
|
|
if (EnableGenInsert)
|
|
|
|
addPass(createHexagonGenInsert(), false);
|
2015-10-06 17:49:14 +02:00
|
|
|
if (EnableEarlyIf)
|
|
|
|
addPass(createHexagonEarlyIfConversion(), false);
|
2013-05-06 23:25:45 +02:00
|
|
|
}
|
2013-03-27 12:14:24 +01:00
|
|
|
|
2011-12-12 22:14:40 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-12-11 22:26:47 +01:00
|
|
|
void HexagonPassConfig::addPreRegAlloc() {
|
2015-10-16 21:43:56 +02:00
|
|
|
if (getOptLevel() != CodeGenOpt::None) {
|
2016-08-25 00:27:36 +02:00
|
|
|
if (EnableExpandCondsets)
|
|
|
|
insertPass(&RegisterCoalescerID, &HexagonExpandCondsetsID);
|
2015-10-16 21:43:56 +02:00
|
|
|
if (!DisableStoreWidening)
|
|
|
|
addPass(createHexagonStoreWidening(), false);
|
2013-05-06 23:25:45 +02:00
|
|
|
if (!DisableHardwareLoops)
|
2014-12-11 22:26:47 +01:00
|
|
|
addPass(createHexagonHardwareLoops(), false);
|
2015-10-16 21:43:56 +02:00
|
|
|
}
|
2016-07-29 18:44:44 +02:00
|
|
|
if (TM->getOptLevel() >= CodeGenOpt::Default)
|
|
|
|
addPass(&MachinePipelinerID);
|
2011-12-12 22:14:40 +01:00
|
|
|
}
|
|
|
|
|
2014-12-11 22:26:47 +01:00
|
|
|
void HexagonPassConfig::addPostRegAlloc() {
|
2016-01-12 20:09:01 +01:00
|
|
|
if (getOptLevel() != CodeGenOpt::None) {
|
|
|
|
if (EnableRDFOpt)
|
|
|
|
addPass(createHexagonRDFOpt());
|
2013-05-06 23:25:45 +02:00
|
|
|
if (!DisableHexagonCFGOpt)
|
2015-02-02 19:46:27 +01:00
|
|
|
addPass(createHexagonCFGOptimizer(), false);
|
2016-04-29 17:49:13 +02:00
|
|
|
if (!DisableAModeOpt)
|
|
|
|
addPass(createHexagonOptAddrMode(), false);
|
2016-01-12 20:09:01 +01:00
|
|
|
}
|
2011-12-12 22:14:40 +01:00
|
|
|
}
|
|
|
|
|
2014-12-11 22:26:47 +01:00
|
|
|
void HexagonPassConfig::addPreSched2() {
|
|
|
|
addPass(createHexagonCopyToCombine(), false);
|
2013-05-07 21:53:00 +02:00
|
|
|
if (getOptLevel() != CodeGenOpt::None)
|
2014-12-11 22:26:47 +01:00
|
|
|
addPass(&IfConverterID, false);
|
2015-02-02 23:11:43 +01:00
|
|
|
addPass(createHexagonSplitConst32AndConst64());
|
2011-12-12 22:14:40 +01:00
|
|
|
}
|
|
|
|
|
2014-12-11 22:26:47 +01:00
|
|
|
void HexagonPassConfig::addPreEmitPass() {
|
2013-05-06 23:25:45 +02:00
|
|
|
bool NoOpt = (getOptLevel() == CodeGenOpt::None);
|
2011-12-12 22:14:40 +01:00
|
|
|
|
2013-05-06 23:25:45 +02:00
|
|
|
if (!NoOpt)
|
2014-12-11 22:26:47 +01:00
|
|
|
addPass(createHexagonNewValueJump(), false);
|
2012-05-12 07:10:30 +02:00
|
|
|
|
2016-04-19 20:30:18 +02:00
|
|
|
addPass(createHexagonBranchRelaxation(), false);
|
|
|
|
|
2012-05-03 23:52:53 +02:00
|
|
|
// Create Packets.
|
2013-05-06 23:25:45 +02:00
|
|
|
if (!NoOpt) {
|
|
|
|
if (!DisableHardwareLoops)
|
2014-12-11 22:26:47 +01:00
|
|
|
addPass(createHexagonFixupHwLoops(), false);
|
2015-07-20 23:23:25 +02:00
|
|
|
// Generate MUX from pairs of conditional transfers.
|
|
|
|
if (EnableGenMux)
|
|
|
|
addPass(createHexagonGenMux(), false);
|
|
|
|
|
2014-12-11 22:26:47 +01:00
|
|
|
addPass(createHexagonPacketizer(), false);
|
2013-05-06 23:25:45 +02:00
|
|
|
}
|
2016-08-01 21:36:39 +02:00
|
|
|
if (EnableVectorPrint)
|
|
|
|
addPass(createHexagonVectorPrint(), false);
|
2015-10-19 19:46:01 +02:00
|
|
|
|
|
|
|
// Add CFI instructions if necessary.
|
|
|
|
addPass(createHexagonCallFrameInformation(), false);
|
2011-12-12 22:14:40 +01:00
|
|
|
}
|