blob: 0b8afac8f7548d8272b2a696b5ab54c92a7f3e7f [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- MCLabel.h - Machine Code Directional Local Labels --------*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the declaration of the MCLabel class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_MC_MCLABEL_H
14#define LLVM_MC_MCLABEL_H
15
16namespace llvm {
17
18class raw_ostream;
19
Andrew Scullcdfcccc2018-10-05 20:58:37 +010020/// Instances of this class represent a label name in the MC file,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010021/// and MCLabel are created and uniqued by the MCContext class. MCLabel
22/// should only be constructed for valid instances in the object file.
23class MCLabel {
Andrew Scullcdfcccc2018-10-05 20:58:37 +010024 // The instance number of this Directional Local Label.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010025 unsigned Instance;
26
27private: // MCContext creates and uniques these.
28 friend class MCContext;
29
30 MCLabel(unsigned instance) : Instance(instance) {}
31
32public:
33 MCLabel(const MCLabel &) = delete;
34 MCLabel &operator=(const MCLabel &) = delete;
35
Andrew Scullcdfcccc2018-10-05 20:58:37 +010036 /// Get the current instance of this Directional Local Label.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010037 unsigned getInstance() const { return Instance; }
38
Andrew Scullcdfcccc2018-10-05 20:58:37 +010039 /// Increment the current instance of this Directional Local Label.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010040 unsigned incInstance() { return ++Instance; }
41
Andrew Scullcdfcccc2018-10-05 20:58:37 +010042 /// Print the value to the stream \p OS.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010043 void print(raw_ostream &OS) const;
44
Andrew Scullcdfcccc2018-10-05 20:58:37 +010045 /// Print the value to stderr.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010046 void dump() const;
47};
48
49inline raw_ostream &operator<<(raw_ostream &OS, const MCLabel &Label) {
50 Label.print(OS);
51 return OS;
52}
53
54} // end namespace llvm
55
56#endif // LLVM_MC_MCLABEL_H