mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
(Re-landing) Expose a TargetMachine::getTargetTransformInfo function
Re-land r321234. It had to be reverted because it broke the shared library build. The shared library build broke because there was a missing LLVMBuild dependency from lib/Passes (which calls TargetMachine::getTargetIRAnalysis) to lib/Target. As far as I can tell, this problem was always there but was somehow masked before (perhaps because TargetMachine::getTargetIRAnalysis was a virtual function). Original commit message: This makes the TargetMachine interface a bit simpler. We still need the std::function in TargetIRAnalysis to avoid having to add a dependency from Analysis to Target. See discussion: http://lists.llvm.org/pipermail/llvm-dev/2017-December/119749.html I avoided adding all of the backend owners to this review since the change is simple, but let me know if you feel differently about this. Reviewers: echristo, MatzeB, hfinkel Reviewed By: hfinkel Subscribers: jholewinski, jfb, arsenm, dschuff, mcrosier, sdardis, nemanjai, nhaehnle, javed.absar, sbc100, jgravelle-google, aheejin, kbarton, llvm-commits Differential Revision: https://reviews.llvm.org/D41464 llvm-svn: 321375
This commit is contained in:
parent
db06df90f8
commit
df40ece177
@ -24,6 +24,7 @@
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class Function;
|
||||
class GlobalValue;
|
||||
class MachineModuleInfo;
|
||||
class Mangler;
|
||||
@ -38,6 +39,7 @@ class PassManagerBuilder;
|
||||
class Target;
|
||||
class TargetIntrinsicInfo;
|
||||
class TargetIRAnalysis;
|
||||
class TargetTransformInfo;
|
||||
class TargetLoweringObjectFile;
|
||||
class TargetPassConfig;
|
||||
class TargetSubtargetInfo;
|
||||
@ -204,7 +206,13 @@ public:
|
||||
/// This is used to construct the new pass manager's target IR analysis pass,
|
||||
/// set up appropriately for this target machine. Even the old pass manager
|
||||
/// uses this to answer queries about the IR.
|
||||
virtual TargetIRAnalysis getTargetIRAnalysis();
|
||||
TargetIRAnalysis getTargetIRAnalysis();
|
||||
|
||||
/// \brief Return a TargetTransformInfo for a given function.
|
||||
///
|
||||
/// The returned TargetTransformInfo is specialized to the subtarget
|
||||
/// corresponding to \p F.
|
||||
virtual TargetTransformInfo getTargetTransformInfo(const Function &F);
|
||||
|
||||
/// Allow the target to modify the pass manager, e.g. by calling
|
||||
/// PassManagerBuilder::addExtension.
|
||||
@ -280,11 +288,11 @@ protected: // Can only create subclasses.
|
||||
void initAsmInfo();
|
||||
|
||||
public:
|
||||
/// \brief Get a TargetIRAnalysis implementation for the target.
|
||||
/// \brief Get a TargetTransformInfo implementation for the target.
|
||||
///
|
||||
/// This analysis will produce a TTI result which uses the common code
|
||||
/// generator to answer queries about the IR.
|
||||
TargetIRAnalysis getTargetIRAnalysis() override;
|
||||
/// The TTI returned uses the common code generator to answer queries about
|
||||
/// the IR.
|
||||
TargetTransformInfo getTargetTransformInfo(const Function &F) override;
|
||||
|
||||
/// Create a pass configuration object to be used by addPassToEmitX methods
|
||||
/// for generating a pipeline of CodeGen passes.
|
||||
|
@ -81,10 +81,9 @@ LLVMTargetMachine::LLVMTargetMachine(const Target &T,
|
||||
this->OptLevel = OL;
|
||||
}
|
||||
|
||||
TargetIRAnalysis LLVMTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(BasicTTIImpl(this, F));
|
||||
});
|
||||
TargetTransformInfo
|
||||
LLVMTargetMachine::getTargetTransformInfo(const Function &F) {
|
||||
return TargetTransformInfo(BasicTTIImpl(this, F));
|
||||
}
|
||||
|
||||
/// addPassesToX helper drives creation and initialization of TargetPassConfig.
|
||||
|
@ -19,4 +19,4 @@
|
||||
type = Library
|
||||
name = Passes
|
||||
parent = Libraries
|
||||
required_libraries = Analysis CodeGen Core IPO InstCombine Scalar Support TransformUtils Vectorize Instrumentation
|
||||
required_libraries = Analysis CodeGen Core IPO InstCombine Scalar Support Target TransformUtils Vectorize Instrumentation
|
||||
|
@ -346,10 +346,9 @@ public:
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
TargetIRAnalysis AArch64TargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(AArch64TTIImpl(this, F));
|
||||
});
|
||||
TargetTransformInfo
|
||||
AArch64TargetMachine::getTargetTransformInfo(const Function &F) {
|
||||
return TargetTransformInfo(AArch64TTIImpl(this, F));
|
||||
}
|
||||
|
||||
TargetPassConfig *AArch64TargetMachine::createPassConfig(PassManagerBase &PM) {
|
||||
|
@ -44,8 +44,7 @@ public:
|
||||
// Pass Pipeline Configuration
|
||||
TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
|
||||
|
||||
/// \brief Get the TargetIRAnalysis for this target.
|
||||
TargetIRAnalysis getTargetIRAnalysis() override;
|
||||
TargetTransformInfo getTargetTransformInfo(const Function &F) override;
|
||||
|
||||
TargetLoweringObjectFile* getObjFileLowering() const override {
|
||||
return TLOF.get();
|
||||
|
@ -571,10 +571,9 @@ public:
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
TargetIRAnalysis AMDGPUTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(AMDGPUTTIImpl(this, F));
|
||||
});
|
||||
TargetTransformInfo
|
||||
AMDGPUTargetMachine::getTargetTransformInfo(const Function &F) {
|
||||
return TargetTransformInfo(AMDGPUTTIImpl(this, F));
|
||||
}
|
||||
|
||||
void AMDGPUPassConfig::addEarlyCSEOrGVNPass() {
|
||||
@ -898,4 +897,3 @@ void GCNPassConfig::addPreEmitPass() {
|
||||
TargetPassConfig *GCNTargetMachine::createPassConfig(PassManagerBase &PM) {
|
||||
return new GCNPassConfig(*this, PM);
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
const AMDGPUIntrinsicInfo *getIntrinsicInfo() const override {
|
||||
return &IntrinsicInfo;
|
||||
}
|
||||
TargetIRAnalysis getTargetIRAnalysis() override;
|
||||
TargetTransformInfo getTargetTransformInfo(const Function &F) override;
|
||||
|
||||
TargetLoweringObjectFile *getObjFileLowering() const override {
|
||||
return TLOF.get();
|
||||
|
@ -88,8 +88,7 @@ extern "C" void LLVMInitializeARCTarget() {
|
||||
RegisterTargetMachine<ARCTargetMachine> X(getTheARCTarget());
|
||||
}
|
||||
|
||||
TargetIRAnalysis ARCTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(ARCTTIImpl(this, F));
|
||||
});
|
||||
TargetTransformInfo
|
||||
ARCTargetMachine::getTargetTransformInfo(const Function &F) {
|
||||
return TargetTransformInfo(ARCTTIImpl(this, F));
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
// Pass Pipeline Configuration
|
||||
TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
|
||||
|
||||
TargetIRAnalysis getTargetIRAnalysis() override;
|
||||
TargetTransformInfo getTargetTransformInfo(const Function &F) override;
|
||||
TargetLoweringObjectFile *getObjFileLowering() const override {
|
||||
return TLOF.get();
|
||||
}
|
||||
|
@ -283,10 +283,9 @@ ARMBaseTargetMachine::getSubtargetImpl(const Function &F) const {
|
||||
return I.get();
|
||||
}
|
||||
|
||||
TargetIRAnalysis ARMBaseTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(ARMTTIImpl(this, F));
|
||||
});
|
||||
TargetTransformInfo
|
||||
ARMBaseTargetMachine::getTargetTransformInfo(const Function &F) {
|
||||
return TargetTransformInfo(ARMTTIImpl(this, F));
|
||||
}
|
||||
|
||||
ARMLETargetMachine::ARMLETargetMachine(const Target &T, const Triple &TT,
|
||||
|
@ -53,8 +53,7 @@ public:
|
||||
const ARMSubtarget *getSubtargetImpl() const = delete;
|
||||
bool isLittleEndian() const { return isLittle; }
|
||||
|
||||
/// \brief Get the TargetIRAnalysis for this target.
|
||||
TargetIRAnalysis getTargetIRAnalysis() override;
|
||||
TargetTransformInfo getTargetTransformInfo(const Function &F) override;
|
||||
|
||||
// Pass Pipeline Configuration
|
||||
TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
|
||||
|
@ -258,10 +258,9 @@ void HexagonTargetMachine::adjustPassManager(PassManagerBuilder &PMB) {
|
||||
});
|
||||
}
|
||||
|
||||
TargetIRAnalysis HexagonTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(HexagonTTIImpl(this, F));
|
||||
});
|
||||
TargetTransformInfo
|
||||
HexagonTargetMachine::getTargetTransformInfo(const Function &F) {
|
||||
return TargetTransformInfo(HexagonTTIImpl(this, F));
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
|
||||
void adjustPassManager(PassManagerBuilder &PMB) override;
|
||||
TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
|
||||
TargetIRAnalysis getTargetIRAnalysis() override;
|
||||
TargetTransformInfo getTargetTransformInfo(const Function &F) override;
|
||||
|
||||
HexagonTargetObjectFile *getObjFileLowering() const override {
|
||||
return static_cast<HexagonTargetObjectFile*>(TLOF.get());
|
||||
|
@ -74,10 +74,9 @@ LanaiTargetMachine::LanaiTargetMachine(const Target &T, const Triple &TT,
|
||||
initAsmInfo();
|
||||
}
|
||||
|
||||
TargetIRAnalysis LanaiTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(LanaiTTIImpl(this, F));
|
||||
});
|
||||
TargetTransformInfo
|
||||
LanaiTargetMachine::getTargetTransformInfo(const Function &F) {
|
||||
return TargetTransformInfo(LanaiTTIImpl(this, F));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
return &Subtarget;
|
||||
}
|
||||
|
||||
TargetIRAnalysis getTargetIRAnalysis() override;
|
||||
TargetTransformInfo getTargetTransformInfo(const Function &F) override;
|
||||
|
||||
// Pass Pipeline Configuration
|
||||
TargetPassConfig *createPassConfig(PassManagerBase &pass_manager) override;
|
||||
|
@ -259,17 +259,16 @@ void MipsPassConfig::addPreRegAlloc() {
|
||||
addPass(createMipsOptimizePICCallPass());
|
||||
}
|
||||
|
||||
TargetIRAnalysis MipsTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
if (Subtarget->allowMixed16_32()) {
|
||||
DEBUG(errs() << "No Target Transform Info Pass Added\n");
|
||||
// FIXME: This is no longer necessary as the TTI returned is per-function.
|
||||
return TargetTransformInfo(F.getParent()->getDataLayout());
|
||||
}
|
||||
TargetTransformInfo
|
||||
MipsTargetMachine::getTargetTransformInfo(const Function &F) {
|
||||
if (Subtarget->allowMixed16_32()) {
|
||||
DEBUG(errs() << "No Target Transform Info Pass Added\n");
|
||||
// FIXME: This is no longer necessary as the TTI returned is per-function.
|
||||
return TargetTransformInfo(F.getParent()->getDataLayout());
|
||||
}
|
||||
|
||||
DEBUG(errs() << "Target Transform Info Pass Added\n");
|
||||
return TargetTransformInfo(BasicTTIImpl(this, F));
|
||||
});
|
||||
DEBUG(errs() << "Target Transform Info Pass Added\n");
|
||||
return TargetTransformInfo(BasicTTIImpl(this, F));
|
||||
}
|
||||
|
||||
// Implemented by targets that want to run passes immediately before
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
CodeGenOpt::Level OL, bool JIT, bool isLittle);
|
||||
~MipsTargetMachine() override;
|
||||
|
||||
TargetIRAnalysis getTargetIRAnalysis() override;
|
||||
TargetTransformInfo getTargetTransformInfo(const Function &F) override;
|
||||
|
||||
const MipsSubtarget *getSubtargetImpl() const {
|
||||
if (Subtarget)
|
||||
|
@ -180,10 +180,9 @@ void NVPTXTargetMachine::adjustPassManager(PassManagerBuilder &Builder) {
|
||||
});
|
||||
}
|
||||
|
||||
TargetIRAnalysis NVPTXTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(NVPTXTTIImpl(this, F));
|
||||
});
|
||||
TargetTransformInfo
|
||||
NVPTXTargetMachine::getTargetTransformInfo(const Function &F) {
|
||||
return TargetTransformInfo(NVPTXTTIImpl(this, F));
|
||||
}
|
||||
|
||||
void NVPTXPassConfig::addEarlyCSEOrGVNPass() {
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
|
||||
void adjustPassManager(PassManagerBuilder &) override;
|
||||
|
||||
TargetIRAnalysis getTargetIRAnalysis() override;
|
||||
TargetTransformInfo getTargetTransformInfo(const Function &F) override;
|
||||
|
||||
bool isMachineVerifierClean() const override {
|
||||
return false;
|
||||
|
@ -451,8 +451,7 @@ void PPCPassConfig::addPreEmitPass() {
|
||||
addPass(createPPCBranchSelectionPass(), false);
|
||||
}
|
||||
|
||||
TargetIRAnalysis PPCTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(PPCTTIImpl(this, F));
|
||||
});
|
||||
TargetTransformInfo
|
||||
PPCTargetMachine::getTargetTransformInfo(const Function &F) {
|
||||
return TargetTransformInfo(PPCTTIImpl(this, F));
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
// Pass Pipeline Configuration
|
||||
TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
|
||||
|
||||
TargetIRAnalysis getTargetIRAnalysis() override;
|
||||
TargetTransformInfo getTargetTransformInfo(const Function &F) override;
|
||||
|
||||
TargetLoweringObjectFile *getObjFileLowering() const override {
|
||||
return TLOF.get();
|
||||
|
@ -257,8 +257,7 @@ TargetPassConfig *SystemZTargetMachine::createPassConfig(PassManagerBase &PM) {
|
||||
return new SystemZPassConfig(*this, PM);
|
||||
}
|
||||
|
||||
TargetIRAnalysis SystemZTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(SystemZTTIImpl(this, F));
|
||||
});
|
||||
TargetTransformInfo
|
||||
SystemZTargetMachine::getTargetTransformInfo(const Function &F) {
|
||||
return TargetTransformInfo(SystemZTTIImpl(this, F));
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
|
||||
// Override LLVMTargetMachine
|
||||
TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
|
||||
TargetIRAnalysis getTargetIRAnalysis() override;
|
||||
TargetTransformInfo getTargetTransformInfo(const Function &F) override;
|
||||
|
||||
TargetLoweringObjectFile *getObjFileLowering() const override {
|
||||
return TLOF.get();
|
||||
|
@ -219,10 +219,8 @@ CodeGenOpt::Level TargetMachine::getOptLevel() const { return OptLevel; }
|
||||
|
||||
void TargetMachine::setOptLevel(CodeGenOpt::Level Level) { OptLevel = Level; }
|
||||
|
||||
TargetIRAnalysis TargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([](const Function &F) {
|
||||
return TargetTransformInfo(F.getParent()->getDataLayout());
|
||||
});
|
||||
TargetTransformInfo TargetMachine::getTargetTransformInfo(const Function &F) {
|
||||
return TargetTransformInfo(F.getParent()->getDataLayout());
|
||||
}
|
||||
|
||||
void TargetMachine::getNameWithPrefix(SmallVectorImpl<char> &Name,
|
||||
@ -244,3 +242,10 @@ MCSymbol *TargetMachine::getSymbol(const GlobalValue *GV) const {
|
||||
getNameWithPrefix(NameStr, GV, TLOF->getMangler());
|
||||
return TLOF->getContext().getOrCreateSymbol(NameStr);
|
||||
}
|
||||
|
||||
TargetIRAnalysis TargetMachine::getTargetIRAnalysis() {
|
||||
// Since Analysis can't depend on Target, use a std::function to invert the
|
||||
// dependency.
|
||||
return TargetIRAnalysis(
|
||||
[this](const Function &F) { return this->getTargetTransformInfo(F); });
|
||||
}
|
||||
|
@ -146,10 +146,9 @@ public:
|
||||
};
|
||||
} // end anonymous namespace
|
||||
|
||||
TargetIRAnalysis WebAssemblyTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(WebAssemblyTTIImpl(this, F));
|
||||
});
|
||||
TargetTransformInfo
|
||||
WebAssemblyTargetMachine::getTargetTransformInfo(const Function &F) {
|
||||
return TargetTransformInfo(WebAssemblyTTIImpl(this, F));
|
||||
}
|
||||
|
||||
TargetPassConfig *
|
||||
|
@ -43,8 +43,7 @@ public:
|
||||
return TLOF.get();
|
||||
}
|
||||
|
||||
/// \brief Get the TargetIRAnalysis for this target.
|
||||
TargetIRAnalysis getTargetIRAnalysis() override;
|
||||
TargetTransformInfo getTargetTransformInfo(const Function &F) override;
|
||||
|
||||
bool usesPhysRegsForPEI() const override { return false; }
|
||||
};
|
||||
|
@ -281,10 +281,9 @@ UseVZeroUpper("x86-use-vzeroupper", cl::Hidden,
|
||||
// X86 TTI query.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
TargetIRAnalysis X86TargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(X86TTIImpl(this, F));
|
||||
});
|
||||
TargetTransformInfo
|
||||
X86TargetMachine::getTargetTransformInfo(const Function &F) {
|
||||
return TargetTransformInfo(X86TTIImpl(this, F));
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
// attributes of each function.
|
||||
const X86Subtarget *getSubtargetImpl() const = delete;
|
||||
|
||||
TargetIRAnalysis getTargetIRAnalysis() override;
|
||||
TargetTransformInfo getTargetTransformInfo(const Function &F) override;
|
||||
|
||||
// Set up the pass pipeline.
|
||||
TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
|
||||
|
@ -108,8 +108,7 @@ extern "C" void LLVMInitializeXCoreTarget() {
|
||||
RegisterTargetMachine<XCoreTargetMachine> X(getTheXCoreTarget());
|
||||
}
|
||||
|
||||
TargetIRAnalysis XCoreTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(XCoreTTIImpl(this, F));
|
||||
});
|
||||
TargetTransformInfo
|
||||
XCoreTargetMachine::getTargetTransformInfo(const Function &F) {
|
||||
return TargetTransformInfo(XCoreTTIImpl(this, F));
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
// Pass Pipeline Configuration
|
||||
TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
|
||||
|
||||
TargetIRAnalysis getTargetIRAnalysis() override;
|
||||
TargetTransformInfo getTargetTransformInfo(const Function &F) override;
|
||||
|
||||
TargetLoweringObjectFile *getObjFileLowering() const override {
|
||||
return TLOF.get();
|
||||
|
Loading…
Reference in New Issue
Block a user