1274955Ssvnmir//===-- NVPTXMachineFunctionInfo.h - NVPTX-specific Function Info --------===// 2274955Ssvnmir// 3274955Ssvnmir// The LLVM Compiler Infrastructure 4274955Ssvnmir// 5274955Ssvnmir// This file is distributed under the University of Illinois Open Source 6274955Ssvnmir// License. See LICENSE.TXT for details. 7274955Ssvnmir// 8274955Ssvnmir//===----------------------------------------------------------------------===// 9274955Ssvnmir// 10274955Ssvnmir// This class is attached to a MachineFunction instance and tracks target- 11274955Ssvnmir// dependent information 12274955Ssvnmir// 13274955Ssvnmir//===----------------------------------------------------------------------===// 14274955Ssvnmir 15280031Sdim#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H 16280031Sdim#define LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H 17280031Sdim 18274955Ssvnmir#include "llvm/CodeGen/MachineFunction.h" 19274955Ssvnmir 20274955Ssvnmirnamespace llvm { 21274955Ssvnmirclass NVPTXMachineFunctionInfo : public MachineFunctionInfo { 22274955Ssvnmirprivate: 23274955Ssvnmir /// Stores a mapping from index to symbol name for removing image handles 24274955Ssvnmir /// on Fermi. 25274955Ssvnmir SmallVector<std::string, 8> ImageHandleList; 26274955Ssvnmir 27274955Ssvnmirpublic: 28274955Ssvnmir NVPTXMachineFunctionInfo(MachineFunction &MF) {} 29274955Ssvnmir 30274955Ssvnmir /// Returns the index for the symbol \p Symbol. If the symbol was previously, 31274955Ssvnmir /// added, the same index is returned. Otherwise, the symbol is added and the 32274955Ssvnmir /// new index is returned. 33274955Ssvnmir unsigned getImageHandleSymbolIndex(const char *Symbol) { 34274955Ssvnmir // Is the symbol already present? 35274955Ssvnmir for (unsigned i = 0, e = ImageHandleList.size(); i != e; ++i) 36274955Ssvnmir if (ImageHandleList[i] == std::string(Symbol)) 37274955Ssvnmir return i; 38274955Ssvnmir // Nope, insert it 39274955Ssvnmir ImageHandleList.push_back(Symbol); 40274955Ssvnmir return ImageHandleList.size()-1; 41274955Ssvnmir } 42274955Ssvnmir 43274955Ssvnmir /// Returns the symbol name at the given index. 44274955Ssvnmir const char *getImageHandleSymbol(unsigned Idx) const { 45274955Ssvnmir assert(ImageHandleList.size() > Idx && "Bad index"); 46274955Ssvnmir return ImageHandleList[Idx].c_str(); 47274955Ssvnmir } 48274955Ssvnmir}; 49274955Ssvnmir} 50280031Sdim 51280031Sdim#endif 52