a686bec4e73fc82d3498f34ac0526784d17dc3c6
[oota-llvm.git] / lib / Analysis / FunctionTargetTransformInfo.cpp
1 //===- llvm/Analysis/FunctionTargetTransformInfo.h --------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This pass wraps a TargetTransformInfo in a FunctionPass so that it can
11 // forward along the current Function so that we can make target specific
12 // decisions based on the particular subtarget specified for each Function.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #include "llvm/InitializePasses.h"
17 #include "llvm/Analysis/FunctionTargetTransformInfo.h"
18
19 using namespace llvm;
20
21 #define DEBUG_TYPE "function-tti"
22 static const char ftti_name[] = "Function TargetTransformInfo";
23 INITIALIZE_PASS_BEGIN(FunctionTargetTransformInfo, "function_tti", ftti_name, false, true)
24 INITIALIZE_AG_DEPENDENCY(TargetTransformInfo)
25 INITIALIZE_PASS_END(FunctionTargetTransformInfo, "function_tti", ftti_name, false, true)
26 char FunctionTargetTransformInfo::ID = 0;
27
28 namespace llvm {
29 FunctionPass *createFunctionTargetTransformInfoPass() {
30   return new FunctionTargetTransformInfo();
31 }
32 }
33
34 FunctionTargetTransformInfo::FunctionTargetTransformInfo()
35   : FunctionPass(ID), Fn(nullptr), TTI(nullptr) {
36   initializeFunctionTargetTransformInfoPass(*PassRegistry::getPassRegistry());
37 }
38
39 void FunctionTargetTransformInfo::getAnalysisUsage(AnalysisUsage &AU) const {
40   AU.setPreservesAll();
41   AU.addRequired<TargetTransformInfo>();
42 }
43
44 void FunctionTargetTransformInfo::releaseMemory() {}
45
46 bool FunctionTargetTransformInfo::runOnFunction(Function &F) {
47   Fn = &F;
48   TTI = &getAnalysis<TargetTransformInfo>();
49   return false;
50 }