MCLabel.h 1.6 KB

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