MCLabel.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- MCLabel.h - Machine Code Directional Local Labels --------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file contains the declaration of the MCLabel class.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_MC_MCLABEL_H
  18. #define LLVM_MC_MCLABEL_H
  19. namespace llvm {
  20. class raw_ostream;
  21. /// Instances of this class represent a label name in the MC file,
  22. /// and MCLabel are created and uniqued by the MCContext class. MCLabel
  23. /// should only be constructed for valid instances in the object file.
  24. class MCLabel {
  25. // The instance number of this Directional Local Label.
  26. unsigned Instance;
  27. private: // MCContext creates and uniques these.
  28. friend class MCContext;
  29. MCLabel(unsigned instance) : Instance(instance) {}
  30. public:
  31. MCLabel(const MCLabel &) = delete;
  32. MCLabel &operator=(const MCLabel &) = delete;
  33. /// Get the current instance of this Directional Local Label.
  34. unsigned getInstance() const { return Instance; }
  35. /// Increment the current instance of this Directional Local Label.
  36. unsigned incInstance() { return ++Instance; }
  37. /// Print the value to the stream \p OS.
  38. void print(raw_ostream &OS) const;
  39. /// Print the value to stderr.
  40. void dump() const;
  41. };
  42. inline raw_ostream &operator<<(raw_ostream &OS, const MCLabel &Label) {
  43. Label.print(OS);
  44. return OS;
  45. }
  46. } // end namespace llvm
  47. #endif // LLVM_MC_MCLABEL_H
  48. #ifdef __GNUC__
  49. #pragma GCC diagnostic pop
  50. #endif