blob: aaf70691fc01aae0649f6d36851caf9b3a6a371e [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- 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
14#ifndef LLVM_MC_MCLABEL_H
15#define LLVM_MC_MCLABEL_H
16
17namespace llvm {
18
19class raw_ostream;
20
Andrew Scullcdfcccc2018-10-05 20:58:37 +010021/// Instances of this class represent a label name in the MC file,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010022/// and MCLabel are created and uniqued by the MCContext class. MCLabel
23/// should only be constructed for valid instances in the object file.
24class MCLabel {
Andrew Scullcdfcccc2018-10-05 20:58:37 +010025 // The instance number of this Directional Local Label.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010026 unsigned Instance;
27
28private: // MCContext creates and uniques these.
29 friend class MCContext;
30
31 MCLabel(unsigned instance) : Instance(instance) {}
32
33public:
34 MCLabel(const MCLabel &) = delete;
35 MCLabel &operator=(const MCLabel &) = delete;
36
Andrew Scullcdfcccc2018-10-05 20:58:37 +010037 /// Get the current instance of this Directional Local Label.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010038 unsigned getInstance() const { return Instance; }
39
Andrew Scullcdfcccc2018-10-05 20:58:37 +010040 /// Increment the current instance of this Directional Local Label.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010041 unsigned incInstance() { return ++Instance; }
42
Andrew Scullcdfcccc2018-10-05 20:58:37 +010043 /// Print the value to the stream \p OS.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010044 void print(raw_ostream &OS) const;
45
Andrew Scullcdfcccc2018-10-05 20:58:37 +010046 /// Print the value to stderr.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010047 void dump() const;
48};
49
50inline raw_ostream &operator<<(raw_ostream &OS, const MCLabel &Label) {
51 Label.print(OS);
52 return OS;
53}
54
55} // end namespace llvm
56
57#endif // LLVM_MC_MCLABEL_H