1 //===- MCSymbol.h - Machine Code Symbols ------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the declaration of the MCSymbol class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_MC_MCSYMBOL_H
15 #define LLVM_MC_MCSYMBOL_H
18 #include "llvm/ADT/StringRef.h"
25 /// MCSymbol - Instances of this class represent a symbol name in the MC file,
26 /// and MCSymbols are created and unique'd by the MCContext class.
28 /// If the symbol is defined/emitted into the current translation unit, the
29 /// Section member is set to indicate what section it lives in. Otherwise, if
30 /// it is a reference to an external entity, it has a null section.
33 /// Name - The name of the symbol.
35 /// Section - The section the symbol is defined in, or null if the symbol
36 /// has not been defined in the associated translation unit.
37 const MCSection *Section;
39 /// IsTemporary - True if this is an assembler temporary label, which
40 /// typically does not survive in the .o file's symbol table. Usually
42 unsigned IsTemporary : 1;
44 /// IsExternal - True if this symbol has been implicitly defined as an
45 /// external, for example by using it in an expression without ever emitting
46 /// it as a label. The @var Section for an external symbol is always null.
47 unsigned IsExternal : 1;
49 private: // MCContext creates and uniques these.
50 friend class MCContext;
51 MCSymbol(const StringRef &_Name, bool _IsTemporary)
52 : Name(_Name), Section(0), IsTemporary(_IsTemporary), IsExternal(false) {}
54 MCSymbol(const MCSymbol&); // DO NOT IMPLEMENT
55 void operator=(const MCSymbol&); // DO NOT IMPLEMENT
58 const MCSection *getSection() const { return Section; }
59 void setSection(const MCSection *S) { Section = S; }
61 bool isExternal() const { return IsExternal; }
62 void setExternal(bool Value) { IsExternal = Value; }
64 const std::string &getName() const { return Name; }
66 /// print - Print the value to the stream \arg OS.
67 void print(raw_ostream &OS) const;
69 /// dump - Print the value to stderr.
73 } // end namespace llvm