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 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H
16 #define LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H
18 #include "llvm/CodeGen/MachineFunction.h"
21 class NVPTXMachineFunctionInfo
: public MachineFunctionInfo
{
23 /// Stores a mapping from index to symbol name for removing image handles
25 SmallVector
<std::string
, 8> ImageHandleList
;
28 NVPTXMachineFunctionInfo(MachineFunction
&MF
) {}
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.
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
))
39 ImageHandleList
.push_back(Symbol
);
40 return ImageHandleList
.size()-1;
43 /// Returns the symbol name at the given index.
44 const char *getImageHandleSymbol(unsigned Idx
) const {
45 assert(ImageHandleList
.size() > Idx
&& "Bad index");
46 return ImageHandleList
[Idx
].c_str();