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"
27 /// MCSymbol - Instances of this class represent a symbol name in the MC file,
28 /// and MCSymbols are created and unique'd by the MCContext class.
30 /// If the symbol is defined/emitted into the current translation unit, the
31 /// Section member is set to indicate what section it lives in. Otherwise, if
32 /// it is a reference to an external entity, it has a null section.
35 // Special sentinal value for the absolute pseudo section.
37 // FIXME: Use a PointerInt wrapper for this?
38 static const MCSection *AbsolutePseudoSection;
40 /// Name - The name of the symbol.
43 /// Section - The section the symbol is defined in. This is null for
44 /// undefined symbols, and the special AbsolutePseudoSection value for
46 const MCSection *Section;
48 /// IsTemporary - True if this is an assembler temporary label, which
49 /// typically does not survive in the .o file's symbol table. Usually
51 unsigned IsTemporary : 1;
53 private: // MCContext creates and uniques these.
54 friend class MCContext;
55 MCSymbol(const StringRef &_Name, bool _IsTemporary)
56 : Name(_Name), Section(0), IsTemporary(_IsTemporary) {}
58 MCSymbol(const MCSymbol&); // DO NOT IMPLEMENT
59 void operator=(const MCSymbol&); // DO NOT IMPLEMENT
61 /// getName - Get the symbol name.
62 const std::string &getName() const { return Name; }
67 /// isTemporary - Check if this is an assembler temporary symbol.
68 bool isTemporary() const {
72 /// isDefined - Check if this symbol is defined (i.e., it has an address).
74 /// Defined symbols are either absolute or in some section.
75 bool isDefined() const {
79 /// isUndefined - Check if this symbol undefined (i.e., implicitly defined).
80 bool isUndefined() const {
84 /// isAbsolute - Check if this this is an absolute symbol.
85 bool isAbsolute() const {
86 return Section == AbsolutePseudoSection;
89 /// getSection - Get the section associated with a defined, non-absolute
91 const MCSection &getSection() const {
92 assert(!isUndefined() && !isAbsolute() && "Invalid accessor!");
96 /// setSection - Mark the symbol as defined in the section \arg S.
97 void setSection(const MCSection &S) { Section = &S; }
99 /// setUndefined - Mark the symbol as undefined.
100 void setUndefined() {
104 /// setAbsolute - Mark the symbol as absolute.
105 void setAbsolute() { Section = AbsolutePseudoSection; }
109 /// print - Print the value to the stream \arg OS.
110 void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
112 /// dump - Print the value to stderr.
116 } // end namespace llvm