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 #ifndef LLVM_ANALYSIS_FUNCTIONTARGETTRANSFORMINFO_H 17 #define LLVM_ANALYSIS_FUNCTIONTARGETTRANSFORMINFO_H 18 19 #include "TargetTransformInfo.h" 20 #include "llvm/Pass.h" 21 22 namespace llvm { 23 class FunctionTargetTransformInfo final : public FunctionPass { 24 private: 25 const Function *Fn; 26 const TargetTransformInfo *TTI; 27 28 FunctionTargetTransformInfo(const FunctionTargetTransformInfo &) 29 LLVM_DELETED_FUNCTION; 30 void operator=(const FunctionTargetTransformInfo &) LLVM_DELETED_FUNCTION; 31 32 public: 33 static char ID; 34 FunctionTargetTransformInfo(); 35 36 // Implementation boilerplate. 37 void getAnalysisUsage(AnalysisUsage &AU) const override; 38 void releaseMemory() override; 39 bool runOnFunction(Function &F) override; 40 41 // Shimmed functions from TargetTransformInfo. 42 void getUnrollingPreferences(Loop * L,TargetTransformInfo::UnrollingPreferences & UP)43 getUnrollingPreferences(Loop *L, 44 TargetTransformInfo::UnrollingPreferences &UP) const { 45 TTI->getUnrollingPreferences(Fn, L, UP); 46 } 47 }; 48 } 49 #endif 50