NVPTXMachineFunctionInfo.h revision 274955
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
15274955Ssvnmir#include "llvm/CodeGen/MachineFunction.h"
16274955Ssvnmir
17274955Ssvnmirnamespace llvm {
18274955Ssvnmirclass NVPTXMachineFunctionInfo : public MachineFunctionInfo {
19274955Ssvnmirprivate:
20274955Ssvnmir  /// Stores a mapping from index to symbol name for removing image handles
21274955Ssvnmir  /// on Fermi.
22274955Ssvnmir  SmallVector<std::string, 8> ImageHandleList;
23274955Ssvnmir
24274955Ssvnmirpublic:
25274955Ssvnmir  NVPTXMachineFunctionInfo(MachineFunction &MF) {}
26274955Ssvnmir
27274955Ssvnmir  /// Returns the index for the symbol \p Symbol. If the symbol was previously,
28274955Ssvnmir  /// added, the same index is returned. Otherwise, the symbol is added and the
29274955Ssvnmir  /// new index is returned.
30274955Ssvnmir  unsigned getImageHandleSymbolIndex(const char *Symbol) {
31274955Ssvnmir    // Is the symbol already present?
32274955Ssvnmir    for (unsigned i = 0, e = ImageHandleList.size(); i != e; ++i)
33274955Ssvnmir      if (ImageHandleList[i] == std::string(Symbol))
34274955Ssvnmir        return i;
35274955Ssvnmir    // Nope, insert it
36274955Ssvnmir    ImageHandleList.push_back(Symbol);
37274955Ssvnmir    return ImageHandleList.size()-1;
38274955Ssvnmir  }
39274955Ssvnmir
40274955Ssvnmir  /// Returns the symbol name at the given index.
41274955Ssvnmir  const char *getImageHandleSymbol(unsigned Idx) const {
42274955Ssvnmir    assert(ImageHandleList.size() > Idx && "Bad index");
43274955Ssvnmir    return ImageHandleList[Idx].c_str();
44274955Ssvnmir  }
45274955Ssvnmir};
46274955Ssvnmir}
47