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"
19 #include "llvm/Support/DataTypes.h"
26 /// MCSymbol - Instances of this class represent a symbol name in the MC file,
27 /// and MCSymbols are created and unique'd by the MCContext class.
29 /// If the symbol is defined/emitted into the current translation unit, the
30 /// Section member is set to indicate what section it lives in. Otherwise, if
31 /// it is a reference to an external entity, it has a null section.
34 // Special sentinal value for the absolute pseudo section.
36 // FIXME: Use a PointerInt wrapper for this?
37 static const MCSection *AbsolutePseudoSection;
39 /// Name - The name of the symbol.
42 /// Section - The section the symbol is defined in. This is null for
43 /// undefined symbols, and the special AbsolutePseudoSection value for
45 const MCSection *Section;
47 /// IsTemporary - True if this is an assembler temporary label, which
48 /// typically does not survive in the .o file's symbol table. Usually
50 unsigned IsTemporary : 1;
52 private: // MCContext creates and uniques these.
53 friend class MCContext;
54 MCSymbol(const StringRef &_Name, bool _IsTemporary)
55 : Name(_Name), Section(0), IsTemporary(_IsTemporary) {}
57 MCSymbol(const MCSymbol&); // DO NOT IMPLEMENT
58 void operator=(const MCSymbol&); // DO NOT IMPLEMENT
60 /// getName - Get the symbol name.
61 const std::string &getName() const { return Name; }
66 /// isDefined - Check if this symbol is defined (i.e., it has an address).
68 /// Defined symbols are either absolute or in some section.
69 bool isDefined() const {
73 /// isUndefined - Check if this symbol undefined (i.e., implicitly defined).
74 bool isUndefined() const {
78 /// isAbsolute - Check if this this is an absolute symbol.
79 bool isAbsolute() const {
80 return Section == AbsolutePseudoSection;
83 /// getSection - Get the section associated with a defined, non-absolute
85 const MCSection &getSection() const {
86 assert(!isUndefined() && !isAbsolute() && "Invalid accessor!");
90 /// setSection - Mark the symbol as defined in the section \arg S.
91 void setSection(const MCSection &S) { Section = &S; }
93 /// setUndefined - Mark the symbol as undefined.
98 /// setAbsolute - Mark the symbol as absolute.
99 void setAbsolute() { Section = AbsolutePseudoSection; }
103 /// print - Print the value to the stream \arg OS.
104 void print(raw_ostream &OS) const;
106 /// dump - Print the value to stderr.
110 } // end namespace llvm