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