NVPTXMachineFunctionInfo.h revision 274955
1//===-- NVPTXMachineFunctionInfo.h - NVPTX-specific Function Info --------===// 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 class is attached to a MachineFunction instance and tracks target- 11// dependent information 12// 13//===----------------------------------------------------------------------===// 14 15#include "llvm/CodeGen/MachineFunction.h" 16 17namespace llvm { 18class NVPTXMachineFunctionInfo : public MachineFunctionInfo { 19private: 20 /// Stores a mapping from index to symbol name for removing image handles 21 /// on Fermi. 22 SmallVector<std::string, 8> ImageHandleList; 23 24public: 25 NVPTXMachineFunctionInfo(MachineFunction &MF) {} 26 27 /// Returns the index for the symbol \p Symbol. If the symbol was previously, 28 /// added, the same index is returned. Otherwise, the symbol is added and the 29 /// new index is returned. 30 unsigned getImageHandleSymbolIndex(const char *Symbol) { 31 // Is the symbol already present? 32 for (unsigned i = 0, e = ImageHandleList.size(); i != e; ++i) 33 if (ImageHandleList[i] == std::string(Symbol)) 34 return i; 35 // Nope, insert it 36 ImageHandleList.push_back(Symbol); 37 return ImageHandleList.size()-1; 38 } 39 40 /// Returns the symbol name at the given index. 41 const char *getImageHandleSymbol(unsigned Idx) const { 42 assert(ImageHandleList.size() > Idx && "Bad index"); 43 return ImageHandleList[Idx].c_str(); 44 } 45}; 46} 47