LLVM API Documentation
00001 //===- MCSymbol.h - Machine Code Symbols ------------------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file contains the declaration of the MCSymbol class. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_MC_MCSYMBOL_H 00015 #define LLVM_MC_MCSYMBOL_H 00016 00017 #include <string> 00018 #include "llvm/ADT/StringRef.h" 00019 00020 namespace llvm { 00021 class MCSection; 00022 class MCContext; 00023 class raw_ostream; 00024 00025 /// MCSymbol - Instances of this class represent a symbol name in the MC file, 00026 /// and MCSymbols are created and unique'd by the MCContext class. 00027 /// 00028 /// If the symbol is defined/emitted into the current translation unit, the 00029 /// Section member is set to indicate what section it lives in. Otherwise, if 00030 /// it is a reference to an external entity, it has a null section. 00031 /// 00032 class MCSymbol { 00033 /// Name - The name of the symbol. 00034 std::string Name; 00035 /// Section - The section the symbol is defined in, or null if the symbol 00036 /// has not been defined in the associated translation unit. 00037 const MCSection *Section; 00038 00039 /// IsTemporary - True if this is an assembler temporary label, which 00040 /// typically does not survive in the .o file's symbol table. Usually 00041 /// "Lfoo" or ".foo". 00042 unsigned IsTemporary : 1; 00043 00044 /// IsExternal - True if this symbol has been implicitly defined as an 00045 /// external, for example by using it in an expression without ever emitting 00046 /// it as a label. The @var Section for an external symbol is always null. 00047 unsigned IsExternal : 1; 00048 00049 private: // MCContext creates and uniques these. 00050 friend class MCContext; 00051 MCSymbol(const StringRef &_Name, bool _IsTemporary) 00052 : Name(_Name), Section(0), IsTemporary(_IsTemporary), IsExternal(false) {} 00053 00054 MCSymbol(const MCSymbol&); // DO NOT IMPLEMENT 00055 void operator=(const MCSymbol&); // DO NOT IMPLEMENT 00056 public: 00057 00058 const MCSection *getSection() const { return Section; } 00059 void setSection(const MCSection *S) { Section = S; } 00060 00061 bool isExternal() const { return IsExternal; } 00062 void setExternal(bool Value) { IsExternal = Value; } 00063 00064 const std::string &getName() const { return Name; } 00065 00066 /// print - Print the value to the stream \arg OS. 00067 void print(raw_ostream &OS) const; 00068 00069 /// dump - Print the value to stderr. 00070 void dump() const; 00071 }; 00072 00073 } // end namespace llvm 00074 00075 #endif