1 //===-- NVPTXMachineFunctionInfo.h - NVPTX-specific Function Info --------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This class is attached to a MachineFunction instance and tracks target-
11 // dependent information
13 //===----------------------------------------------------------------------===//
15 #include "llvm/CodeGen/MachineFunction.h"
18 class NVPTXMachineFunctionInfo : public MachineFunctionInfo {
20 /// Stores a mapping from index to symbol name for removing image handles
22 SmallVector<std::string, 8> ImageHandleList;
25 NVPTXMachineFunctionInfo(MachineFunction &MF) {}
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))
36 ImageHandleList.push_back(Symbol);
37 return ImageHandleList.size()-1;
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();