DwarfStringPoolEntry.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //===- llvm/CodeGen/DwarfStringPoolEntry.h - String pool entry --*- C++ -*-===//
  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. #ifndef LLVM_CODEGEN_DWARFSTRINGPOOLENTRY_H
  10. #define LLVM_CODEGEN_DWARFSTRINGPOOLENTRY_H
  11. #include "llvm/ADT/StringMap.h"
  12. namespace llvm {
  13. class MCSymbol;
  14. /// Data for a string pool entry.
  15. struct DwarfStringPoolEntry {
  16. MCSymbol *Symbol;
  17. unsigned Offset;
  18. unsigned Index;
  19. };
  20. /// String pool entry reference.
  21. struct DwarfStringPoolEntryRef {
  22. const StringMapEntry<DwarfStringPoolEntry> *I = nullptr;
  23. public:
  24. DwarfStringPoolEntryRef() = default;
  25. explicit DwarfStringPoolEntryRef(
  26. const StringMapEntry<DwarfStringPoolEntry> &I)
  27. : I(&I) {}
  28. explicit operator bool() const { return I; }
  29. MCSymbol *getSymbol() const {
  30. assert(I->second.Symbol && "No symbol available!");
  31. return I->second.Symbol;
  32. }
  33. unsigned getOffset() const { return I->second.Offset; }
  34. unsigned getIndex() const { return I->second.Index; }
  35. StringRef getString() const { return I->first(); }
  36. bool operator==(const DwarfStringPoolEntryRef &X) const { return I == X.I; }
  37. bool operator!=(const DwarfStringPoolEntryRef &X) const { return I != X.I; }
  38. };
  39. } // end namespace llvm
  40. #endif