NVPTXMachineFunctionInfo.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //===-- NVPTXMachineFunctionInfo.h - NVPTX-specific Function Info --------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This class is attached to a MachineFunction instance and tracks target-
  10. // dependent information
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H
  14. #define LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H
  15. #include "llvm/CodeGen/MachineFunction.h"
  16. namespace llvm {
  17. class NVPTXMachineFunctionInfo : public MachineFunctionInfo {
  18. private:
  19. /// Stores a mapping from index to symbol name for removing image handles
  20. /// on Fermi.
  21. SmallVector<std::string, 8> ImageHandleList;
  22. public:
  23. NVPTXMachineFunctionInfo(MachineFunction &MF) {}
  24. /// Returns the index for the symbol \p Symbol. If the symbol was previously,
  25. /// added, the same index is returned. Otherwise, the symbol is added and the
  26. /// new index is returned.
  27. unsigned getImageHandleSymbolIndex(const char *Symbol) {
  28. // Is the symbol already present?
  29. for (unsigned i = 0, e = ImageHandleList.size(); i != e; ++i)
  30. if (ImageHandleList[i] == std::string(Symbol))
  31. return i;
  32. // Nope, insert it
  33. ImageHandleList.push_back(Symbol);
  34. return ImageHandleList.size()-1;
  35. }
  36. /// Returns the symbol name at the given index.
  37. const char *getImageHandleSymbol(unsigned Idx) const {
  38. assert(ImageHandleList.size() > Idx && "Bad index");
  39. return ImageHandleList[Idx].c_str();
  40. }
  41. };
  42. }
  43. #endif