blob: 10f1135ad84106be120dbcd02ec997d81141523b [file] [log] [blame]
Justin Holewinski30d56a72014-04-09 15:39:15 +00001//===-- 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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000015#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H
16#define LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H
17
Justin Holewinski30d56a72014-04-09 15:39:15 +000018#include "llvm/CodeGen/MachineFunction.h"
19
20namespace llvm {
21class NVPTXMachineFunctionInfo : public MachineFunctionInfo {
22private:
23 /// Stores a mapping from index to symbol name for removing image handles
24 /// on Fermi.
25 SmallVector<std::string, 8> ImageHandleList;
26
27public:
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.
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.
44 const char *getImageHandleSymbol(unsigned Idx) const {
45 assert(ImageHandleList.size() > Idx && "Bad index");
46 return ImageHandleList[Idx].c_str();
47 }
48};
Alexander Kornienkof00654e2015-06-23 09:49:53 +000049}
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000050
51#endif