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