aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/TargetTransformInfo.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2015-02-01 10:11:22 +0000
committerChandler Carruth <chandlerc@gmail.com>2015-02-01 10:11:22 +0000
commite038552c8ae99abe129837255273a992f72c6d9c (patch)
tree391c11977c8ac0b7230a1a747c4dc8d74d0f210a /llvm/lib/Analysis/TargetTransformInfo.cpp
parent2844ca7319bab9dacceb499227c15391ce97fb87 (diff)
downloadllvm-e038552c8ae99abe129837255273a992f72c6d9c.zip
llvm-e038552c8ae99abe129837255273a992f72c6d9c.tar.gz
llvm-e038552c8ae99abe129837255273a992f72c6d9c.tar.bz2
[PM] Port TTI to the new pass manager, introducing a TargetIRAnalysis to
produce it. This adds a function to the TargetMachine that produces this analysis via a callback for each function. This in turn faves the way to produce a *different* TTI per-function with the correct subtarget cached. I've also done the necessary wiring in the opt tool to thread the target machine down and make it available to the pass registry so that we can construct this analysis from a target machine when available. llvm-svn: 227721
Diffstat (limited to 'llvm/lib/Analysis/TargetTransformInfo.cpp')
-rw-r--r--llvm/lib/Analysis/TargetTransformInfo.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp
index a78d1db..6bd79f6 100644
--- a/llvm/lib/Analysis/TargetTransformInfo.cpp
+++ b/llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -14,6 +14,7 @@
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
+#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/Support/ErrorHandling.h"
@@ -255,6 +256,22 @@ Value *TargetTransformInfo::getOrCreateResultFromMemIntrinsic(
TargetTransformInfo::Concept::~Concept() {}
+TargetIRAnalysis::TargetIRAnalysis() : TTICallback(&getDefaultTTI) {}
+
+TargetIRAnalysis::TargetIRAnalysis(
+ std::function<Result(Function &)> TTICallback)
+ : TTICallback(TTICallback) {}
+
+TargetIRAnalysis::Result TargetIRAnalysis::run(Function &F) {
+ return TTICallback(F);
+}
+
+char TargetIRAnalysis::PassID;
+
+TargetIRAnalysis::Result TargetIRAnalysis::getDefaultTTI(Function &F) {
+ return Result(F.getParent()->getDataLayout());
+}
+
// Register the basic pass.
INITIALIZE_PASS(TargetTransformInfoWrapperPass, "tti",
"Target Transform Information", false, true)