summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/FunctionTargetTransformInfo.cpp
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2014-09-18 00:34:14 +0000
committerEric Christopher <echristo@gmail.com>2014-09-18 00:34:14 +0000
commitd85ffb1fc01281f0a3a3928a7207ddda991500c2 (patch)
tree724681bb44c4de046085bf677c1480db0700ba53 /llvm/lib/Analysis/FunctionTargetTransformInfo.cpp
parent3ab9ada59c45ef2b75b9bfb4f1c859f54055a3d0 (diff)
downloadbcm5719-llvm-d85ffb1fc01281f0a3a3928a7207ddda991500c2.tar.gz
bcm5719-llvm-d85ffb1fc01281f0a3a3928a7207ddda991500c2.zip
Add a new pass FunctionTargetTransformInfo. This pass serves as a
shim between the TargetTransformInfo immutable pass and the Subtarget via the TargetMachine and Function. Migrate a single call from BasicTargetTransformInfo as an example and provide shims where TargetMachine begins taking a Function to determine the subtarget. No functional change. llvm-svn: 218004
Diffstat (limited to 'llvm/lib/Analysis/FunctionTargetTransformInfo.cpp')
-rw-r--r--llvm/lib/Analysis/FunctionTargetTransformInfo.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/FunctionTargetTransformInfo.cpp b/llvm/lib/Analysis/FunctionTargetTransformInfo.cpp
new file mode 100644
index 00000000000..a686bec4e73
--- /dev/null
+++ b/llvm/lib/Analysis/FunctionTargetTransformInfo.cpp
@@ -0,0 +1,50 @@
+//===- llvm/Analysis/FunctionTargetTransformInfo.h --------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This pass wraps a TargetTransformInfo in a FunctionPass so that it can
+// forward along the current Function so that we can make target specific
+// decisions based on the particular subtarget specified for each Function.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/InitializePasses.h"
+#include "llvm/Analysis/FunctionTargetTransformInfo.h"
+
+using namespace llvm;
+
+#define DEBUG_TYPE "function-tti"
+static const char ftti_name[] = "Function TargetTransformInfo";
+INITIALIZE_PASS_BEGIN(FunctionTargetTransformInfo, "function_tti", ftti_name, false, true)
+INITIALIZE_AG_DEPENDENCY(TargetTransformInfo)
+INITIALIZE_PASS_END(FunctionTargetTransformInfo, "function_tti", ftti_name, false, true)
+char FunctionTargetTransformInfo::ID = 0;
+
+namespace llvm {
+FunctionPass *createFunctionTargetTransformInfoPass() {
+ return new FunctionTargetTransformInfo();
+}
+}
+
+FunctionTargetTransformInfo::FunctionTargetTransformInfo()
+ : FunctionPass(ID), Fn(nullptr), TTI(nullptr) {
+ initializeFunctionTargetTransformInfoPass(*PassRegistry::getPassRegistry());
+}
+
+void FunctionTargetTransformInfo::getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+ AU.addRequired<TargetTransformInfo>();
+}
+
+void FunctionTargetTransformInfo::releaseMemory() {}
+
+bool FunctionTargetTransformInfo::runOnFunction(Function &F) {
+ Fn = &F;
+ TTI = &getAnalysis<TargetTransformInfo>();
+ return false;
+}
OpenPOWER on IntegriCloud