mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-18 18:42:46 +02:00
constify the Function parameter to the TTI creation callback and
propagate to all callers/users/etc. llvm-svn: 247864
This commit is contained in:
parent
59dba79fe0
commit
a096f8ec12
@ -861,7 +861,7 @@ public:
|
||||
///
|
||||
/// The callback will be called with a particular function for which the TTI
|
||||
/// is needed and must return a TTI object for that function.
|
||||
TargetIRAnalysis(std::function<Result(Function &)> TTICallback);
|
||||
TargetIRAnalysis(std::function<Result(const Function &)> TTICallback);
|
||||
|
||||
// Value semantics. We spell out the constructors for MSVC.
|
||||
TargetIRAnalysis(const TargetIRAnalysis &Arg)
|
||||
@ -877,7 +877,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
Result run(Function &F);
|
||||
Result run(const Function &F);
|
||||
|
||||
private:
|
||||
static char PassID;
|
||||
@ -892,10 +892,10 @@ private:
|
||||
/// the analysis and thus use a function_ref which would be lighter weight.
|
||||
/// This may also be less error prone as the callback is likely to reference
|
||||
/// the external TargetMachine, and that reference needs to never dangle.
|
||||
std::function<Result(Function &)> TTICallback;
|
||||
std::function<Result(const Function &)> TTICallback;
|
||||
|
||||
/// \brief Helper function used as the callback in the default constructor.
|
||||
static Result getDefaultTTI(Function &F);
|
||||
static Result getDefaultTTI(const Function &F);
|
||||
};
|
||||
|
||||
/// \brief Wrapper pass for TargetTransformInfo.
|
||||
@ -919,7 +919,7 @@ public:
|
||||
|
||||
explicit TargetTransformInfoWrapperPass(TargetIRAnalysis TIRA);
|
||||
|
||||
TargetTransformInfo &getTTI(Function &F);
|
||||
TargetTransformInfo &getTTI(const Function &F);
|
||||
};
|
||||
|
||||
/// \brief Create an analysis pass wrapper around a TTI object.
|
||||
|
@ -808,7 +808,7 @@ class BasicTTIImpl : public BasicTTIImplBase<BasicTTIImpl> {
|
||||
const TargetLoweringBase *getTLI() const { return TLI; }
|
||||
|
||||
public:
|
||||
explicit BasicTTIImpl(const TargetMachine *ST, Function &F);
|
||||
explicit BasicTTIImpl(const TargetMachine *ST, const Function &F);
|
||||
|
||||
// Provide value semantics. MSVC requires that we spell all of these out.
|
||||
BasicTTIImpl(const BasicTTIImpl &Arg)
|
||||
|
@ -344,16 +344,16 @@ TargetTransformInfo::Concept::~Concept() {}
|
||||
TargetIRAnalysis::TargetIRAnalysis() : TTICallback(&getDefaultTTI) {}
|
||||
|
||||
TargetIRAnalysis::TargetIRAnalysis(
|
||||
std::function<Result(Function &)> TTICallback)
|
||||
std::function<Result(const Function &)> TTICallback)
|
||||
: TTICallback(TTICallback) {}
|
||||
|
||||
TargetIRAnalysis::Result TargetIRAnalysis::run(Function &F) {
|
||||
TargetIRAnalysis::Result TargetIRAnalysis::run(const Function &F) {
|
||||
return TTICallback(F);
|
||||
}
|
||||
|
||||
char TargetIRAnalysis::PassID;
|
||||
|
||||
TargetIRAnalysis::Result TargetIRAnalysis::getDefaultTTI(Function &F) {
|
||||
TargetIRAnalysis::Result TargetIRAnalysis::getDefaultTTI(const Function &F) {
|
||||
return Result(F.getParent()->getDataLayout());
|
||||
}
|
||||
|
||||
@ -377,7 +377,7 @@ TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass(
|
||||
*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
TargetTransformInfo &TargetTransformInfoWrapperPass::getTTI(Function &F) {
|
||||
TargetTransformInfo &TargetTransformInfoWrapperPass::getTTI(const Function &F) {
|
||||
TTI = TIRA.run(F);
|
||||
return *TTI;
|
||||
}
|
||||
|
@ -33,6 +33,6 @@ cl::opt<unsigned>
|
||||
cl::desc("Threshold for partial unrolling"),
|
||||
cl::Hidden);
|
||||
|
||||
BasicTTIImpl::BasicTTIImpl(const TargetMachine *TM, Function &F)
|
||||
BasicTTIImpl::BasicTTIImpl(const TargetMachine *TM, const Function &F)
|
||||
: BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
|
||||
TLI(ST->getTargetLowering()) {}
|
||||
|
@ -82,7 +82,7 @@ LLVMTargetMachine::LLVMTargetMachine(const Target &T,
|
||||
}
|
||||
|
||||
TargetIRAnalysis LLVMTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](Function &F) {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(BasicTTIImpl(this, F));
|
||||
});
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ public:
|
||||
} // namespace
|
||||
|
||||
TargetIRAnalysis AArch64TargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](Function &F) {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(AArch64TTIImpl(this, F));
|
||||
});
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
|
||||
};
|
||||
|
||||
public:
|
||||
explicit AArch64TTIImpl(const AArch64TargetMachine *TM, Function &F)
|
||||
explicit AArch64TTIImpl(const AArch64TargetMachine *TM, const Function &F)
|
||||
: BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
|
||||
TLI(ST->getTargetLowering()) {}
|
||||
|
||||
|
@ -156,7 +156,7 @@ public:
|
||||
} // End of anonymous namespace
|
||||
|
||||
TargetIRAnalysis AMDGPUTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](Function &F) {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(
|
||||
AMDGPUTTIImpl(this, F.getParent()->getDataLayout()));
|
||||
});
|
||||
|
@ -225,8 +225,9 @@ ARMBaseTargetMachine::getSubtargetImpl(const Function &F) const {
|
||||
}
|
||||
|
||||
TargetIRAnalysis ARMBaseTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis(
|
||||
[this](Function &F) { return TargetTransformInfo(ARMTTIImpl(this, F)); });
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(ARMTTIImpl(this, F));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,7 +41,7 @@ class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
|
||||
const ARMTargetLowering *getTLI() const { return TLI; }
|
||||
|
||||
public:
|
||||
explicit ARMTTIImpl(const ARMBaseTargetMachine *TM, Function &F)
|
||||
explicit ARMTTIImpl(const ARMBaseTargetMachine *TM, const Function &F)
|
||||
: BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
|
||||
TLI(ST->getTargetLowering()) {}
|
||||
|
||||
|
@ -138,7 +138,7 @@ HexagonTargetMachine::getSubtargetImpl(const Function &F) const {
|
||||
}
|
||||
|
||||
TargetIRAnalysis HexagonTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](Function &F) {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(HexagonTTIImpl(this, F));
|
||||
});
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class HexagonTTIImpl : public BasicTTIImplBase<HexagonTTIImpl> {
|
||||
const HexagonTargetLowering *getTLI() const { return TLI; }
|
||||
|
||||
public:
|
||||
explicit HexagonTTIImpl(const HexagonTargetMachine *TM, Function &F)
|
||||
explicit HexagonTTIImpl(const HexagonTargetMachine *TM, const Function &F)
|
||||
: BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
|
||||
TLI(ST->getTargetLowering()) {}
|
||||
|
||||
|
@ -233,7 +233,7 @@ void MipsPassConfig::addPreRegAlloc() {
|
||||
}
|
||||
|
||||
TargetIRAnalysis MipsTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](Function &F) {
|
||||
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.
|
||||
|
@ -154,7 +154,7 @@ TargetPassConfig *NVPTXTargetMachine::createPassConfig(PassManagerBase &PM) {
|
||||
}
|
||||
|
||||
TargetIRAnalysis NVPTXTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](Function &F) {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(NVPTXTTIImpl(this, F));
|
||||
});
|
||||
}
|
||||
|
@ -373,6 +373,7 @@ void PPCPassConfig::addPreEmitPass() {
|
||||
}
|
||||
|
||||
TargetIRAnalysis PPCTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis(
|
||||
[this](Function &F) { return TargetTransformInfo(PPCTTIImpl(this, F)); });
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(PPCTTIImpl(this, F));
|
||||
});
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class PPCTTIImpl : public BasicTTIImplBase<PPCTTIImpl> {
|
||||
const PPCTargetLowering *getTLI() const { return TLI; }
|
||||
|
||||
public:
|
||||
explicit PPCTTIImpl(const PPCTargetMachine *TM, Function &F)
|
||||
explicit PPCTTIImpl(const PPCTargetMachine *TM, const Function &F)
|
||||
: BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
|
||||
TLI(ST->getTargetLowering()) {}
|
||||
|
||||
|
@ -165,7 +165,7 @@ TargetPassConfig *SystemZTargetMachine::createPassConfig(PassManagerBase &PM) {
|
||||
}
|
||||
|
||||
TargetIRAnalysis SystemZTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](Function &F) {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(SystemZTTIImpl(this, F));
|
||||
});
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class SystemZTTIImpl : public BasicTTIImplBase<SystemZTTIImpl> {
|
||||
const SystemZTargetLowering *getTLI() const { return TLI; }
|
||||
|
||||
public:
|
||||
explicit SystemZTTIImpl(const SystemZTargetMachine *TM, Function &F)
|
||||
explicit SystemZTTIImpl(const SystemZTargetMachine *TM, const Function &F)
|
||||
: BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
|
||||
TLI(ST->getTargetLowering()) {}
|
||||
|
||||
|
@ -150,7 +150,7 @@ void TargetMachine::setOptLevel(CodeGenOpt::Level Level) const {
|
||||
}
|
||||
|
||||
TargetIRAnalysis TargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](Function &F) {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(F.getParent()->getDataLayout());
|
||||
});
|
||||
}
|
||||
|
@ -182,8 +182,9 @@ UseVZeroUpper("x86-use-vzeroupper", cl::Hidden,
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
TargetIRAnalysis X86TargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis(
|
||||
[this](Function &F) { return TargetTransformInfo(X86TTIImpl(this, F)); });
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(X86TTIImpl(this, F));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,7 +39,7 @@ class X86TTIImpl : public BasicTTIImplBase<X86TTIImpl> {
|
||||
const X86TargetLowering *getTLI() const { return TLI; }
|
||||
|
||||
public:
|
||||
explicit X86TTIImpl(const X86TargetMachine *TM, Function &F)
|
||||
explicit X86TTIImpl(const X86TargetMachine *TM, const Function &F)
|
||||
: BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
|
||||
TLI(ST->getTargetLowering()) {}
|
||||
|
||||
|
@ -85,7 +85,7 @@ extern "C" void LLVMInitializeXCoreTarget() {
|
||||
}
|
||||
|
||||
TargetIRAnalysis XCoreTargetMachine::getTargetIRAnalysis() {
|
||||
return TargetIRAnalysis([this](Function &F) {
|
||||
return TargetIRAnalysis([this](const Function &F) {
|
||||
return TargetTransformInfo(XCoreTTIImpl(this, F));
|
||||
});
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class XCoreTTIImpl : public BasicTTIImplBase<XCoreTTIImpl> {
|
||||
const XCoreTargetLowering *getTLI() const { return TLI; }
|
||||
|
||||
public:
|
||||
explicit XCoreTTIImpl(const XCoreTargetMachine *TM, Function &F)
|
||||
explicit XCoreTTIImpl(const XCoreTargetMachine *TM, const Function &F)
|
||||
: BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl()),
|
||||
TLI(ST->getTargetLowering()) {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user