add support for .zerofill, patch by Kevin Enderby!
[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
19 namespace llvm {
20   class MCSection;
21   class MCContext;
22
23   /// MCSymbol - Instances of this class represent a symbol name in the MC file,
24   /// and MCSymbols are created and unique'd by the MCContext class.
25   ///
26   /// If the symbol is defined/emitted into the current translation unit, the
27   /// Section member is set to indicate what section it lives in.  Otherwise, if
28   /// it is a reference to an external entity, it has a null section.  
29   /// 
30   class MCSymbol {
31     /// Name - The name of the symbol.
32     std::string Name;
33     /// Section - The section the symbol is defined in, or null if the symbol
34     /// has not been defined in the associated translation unit.
35     MCSection *Section;
36     
37     /// IsTemporary - True if this is an assembler temporary label, which
38     /// typically does not survive in the .o file's symbol table.  Usually
39     /// "Lfoo" or ".foo".
40     unsigned IsTemporary : 1;
41     
42     /// IsExternal - True if this symbol has been implicitly defined as an
43     /// external, for example by using it in an expression without ever emitting
44     /// it as a label. The @var Section for an external symbol is always null.
45     unsigned IsExternal : 1;
46
47   private:  // MCContext creates and uniques these.
48     friend class MCContext;
49     MCSymbol(const char *_Name, bool _IsTemporary) 
50       : Name(_Name), Section(0), IsTemporary(_IsTemporary), IsExternal(false) {}
51     
52     MCSymbol(const MCSymbol&);       // DO NOT IMPLEMENT
53     void operator=(const MCSymbol&); // DO NOT IMPLEMENT
54   public:
55     
56     MCSection *getSection() const { return Section; }
57     void setSection(MCSection *Value) { Section = Value; }
58
59     bool isExternal() const { return IsExternal; }
60     void setExternal(bool Value) { IsExternal = Value; }
61
62     const std::string &getName() const { return Name; }
63   };
64
65 } // end namespace llvm
66
67 #endif