LLVM API Documentation

NVPTXMachineFunctionInfo.h
Go to the documentation of this file.
00001 //===-- NVPTXMachineFunctionInfo.h - NVPTX-specific Function Info  --------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source 
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This class is attached to a MachineFunction instance and tracks target-
00011 // dependent information
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H
00016 #define LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H
00017 
00018 #include "llvm/CodeGen/MachineFunction.h"
00019 
00020 namespace llvm {
00021 class NVPTXMachineFunctionInfo : public MachineFunctionInfo {
00022 private:
00023   /// Stores a mapping from index to symbol name for removing image handles
00024   /// on Fermi.
00025   SmallVector<std::string, 8> ImageHandleList;
00026 
00027 public:
00028   NVPTXMachineFunctionInfo(MachineFunction &MF) {}
00029 
00030   /// Returns the index for the symbol \p Symbol. If the symbol was previously,
00031   /// added, the same index is returned. Otherwise, the symbol is added and the
00032   /// new index is returned.
00033   unsigned getImageHandleSymbolIndex(const char *Symbol) {
00034     // Is the symbol already present?
00035     for (unsigned i = 0, e = ImageHandleList.size(); i != e; ++i)
00036       if (ImageHandleList[i] == std::string(Symbol))
00037         return i;
00038     // Nope, insert it
00039     ImageHandleList.push_back(Symbol);
00040     return ImageHandleList.size()-1;
00041   }
00042 
00043   /// Returns the symbol name at the given index.
00044   const char *getImageHandleSymbol(unsigned Idx) const {
00045     assert(ImageHandleList.size() > Idx && "Bad index");
00046     return ImageHandleList[Idx].c_str();
00047   }
00048 };
00049 }
00050 
00051 #endif