change AsmPrinter to switch sections using AsmStreamer instead of
[oota-llvm.git] / include / llvm / MC / MCSymbol.h
1 //===- MCSymbol.h - Machine Code Symbols ------------------------*- 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 MCSymbol class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_MC_MCSYMBOL_H
15 #define LLVM_MC_MCSYMBOL_H
16
17 #include <string>
18 #include "llvm/ADT/StringRef.h"
19
20 namespace llvm {
21   class MCSection;
22   class MCContext;
23   class raw_ostream;
24
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.
27   ///
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.  
31   /// 
32   class MCSymbol {
33     /// Name - The name of the symbol.
34     std::string Name;
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;
38     
39     /// IsTemporary - True if this is an assembler temporary label, which
40     /// typically does not survive in the .o file's symbol table.  Usually
41     /// "Lfoo" or ".foo".
42     unsigned IsTemporary : 1;
43     
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;
48
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) {}
53     
54     MCSymbol(const MCSymbol&);       // DO NOT IMPLEMENT
55     void operator=(const MCSymbol&); // DO NOT IMPLEMENT
56   public:
57     
58     const MCSection *getSection() const { return Section; }
59     void setSection(const MCSection *S) { Section = S; }
60
61     bool isExternal() const { return IsExternal; }
62     void setExternal(bool Value) { IsExternal = Value; }
63
64     const std::string &getName() const { return Name; }
65
66     /// print - Print the value to the stream \arg OS.
67     void print(raw_ostream &OS) const;
68
69     /// dump - Print the value to stderr.
70     void dump() const;
71   };
72
73 } // end namespace llvm
74
75 #endif