MCLabel.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //===- MCLabel.h - Machine Code Directional Local Labels --------*- 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. //
  10. // This file contains the declaration of the MCLabel class.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_MC_MCLABEL_H
  14. #define LLVM_MC_MCLABEL_H
  15. #include "llvm/Support/Compiler.h"
  16. namespace llvm {
  17. class MCContext;
  18. class raw_ostream;
  19. /// \brief Instances of this class represent a label name in the MC file,
  20. /// and MCLabel are created and uniqued by the MCContext class. MCLabel
  21. /// should only be constructed for valid instances in the object file.
  22. class MCLabel {
  23. // \brief The instance number of this Directional Local Label.
  24. unsigned Instance;
  25. private: // MCContext creates and uniques these.
  26. friend class MCContext;
  27. MCLabel(unsigned instance) : Instance(instance) {}
  28. MCLabel(const MCLabel &) = delete;
  29. void operator=(const MCLabel &) = delete;
  30. public:
  31. /// \brief Get the current instance of this Directional Local Label.
  32. unsigned getInstance() const { return Instance; }
  33. /// \brief Increment the current instance of this Directional Local Label.
  34. unsigned incInstance() { return ++Instance; }
  35. /// \brief Print the value to the stream \p OS.
  36. void print(raw_ostream &OS) const;
  37. /// \brief Print the value to stderr.
  38. void dump() const;
  39. };
  40. inline raw_ostream &operator<<(raw_ostream &OS, const MCLabel &Label) {
  41. Label.print(OS);
  42. return OS;
  43. }
  44. } // end namespace llvm
  45. #endif