• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H
16 #define LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H
17 
18 #include "llvm/CodeGen/MachineFunction.h"
19 
20 namespace llvm {
21 class NVPTXMachineFunctionInfo : public MachineFunctionInfo {
22 private:
23   /// Stores a mapping from index to symbol name for removing image handles
24   /// on Fermi.
25   SmallVector<std::string, 8> ImageHandleList;
26 
27 public:
NVPTXMachineFunctionInfo(MachineFunction & MF)28   NVPTXMachineFunctionInfo(MachineFunction &MF) {}
29 
30   /// Returns the index for the symbol \p Symbol. If the symbol was previously,
31   /// added, the same index is returned. Otherwise, the symbol is added and the
32   /// new index is returned.
getImageHandleSymbolIndex(const char * Symbol)33   unsigned getImageHandleSymbolIndex(const char *Symbol) {
34     // Is the symbol already present?
35     for (unsigned i = 0, e = ImageHandleList.size(); i != e; ++i)
36       if (ImageHandleList[i] == std::string(Symbol))
37         return i;
38     // Nope, insert it
39     ImageHandleList.push_back(Symbol);
40     return ImageHandleList.size()-1;
41   }
42 
43   /// Returns the symbol name at the given index.
getImageHandleSymbol(unsigned Idx)44   const char *getImageHandleSymbol(unsigned Idx) const {
45     assert(ImageHandleList.size() > Idx && "Bad index");
46     return ImageHandleList[Idx].c_str();
47   }
48 };
49 }
50 
51 #endif
52