2009-06-23 22:01:43 +00:00
|
|
|
//===- MCSymbol.h - Machine Code Symbols ------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2009-07-01 06:21:53 +00:00
|
|
|
//
|
|
|
|
// This file contains the declaration of the MCSymbol class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2009-06-23 22:01:43 +00:00
|
|
|
|
|
|
|
#ifndef LLVM_MC_MCSYMBOL_H
|
|
|
|
#define LLVM_MC_MCSYMBOL_H
|
|
|
|
|
|
|
|
#include <string>
|
2009-07-27 21:22:30 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2009-08-22 07:22:36 +00:00
|
|
|
#include "llvm/Support/DataTypes.h"
|
2009-06-23 22:01:43 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
2009-09-03 05:46:51 +00:00
|
|
|
class MCAsmInfo;
|
2009-06-30 01:49:52 +00:00
|
|
|
class MCSection;
|
2009-07-01 06:21:53 +00:00
|
|
|
class MCContext;
|
2009-08-14 03:41:23 +00:00
|
|
|
class raw_ostream;
|
2009-07-01 06:21:53 +00:00
|
|
|
|
|
|
|
/// MCSymbol - Instances of this class represent a symbol name in the MC file,
|
|
|
|
/// and MCSymbols are created and unique'd by the MCContext class.
|
|
|
|
///
|
|
|
|
/// If the symbol is defined/emitted into the current translation unit, the
|
|
|
|
/// Section member is set to indicate what section it lives in. Otherwise, if
|
|
|
|
/// it is a reference to an external entity, it has a null section.
|
|
|
|
///
|
2009-06-23 22:01:43 +00:00
|
|
|
class MCSymbol {
|
2009-08-22 07:22:36 +00:00
|
|
|
// Special sentinal value for the absolute pseudo section.
|
|
|
|
//
|
|
|
|
// FIXME: Use a PointerInt wrapper for this?
|
|
|
|
static const MCSection *AbsolutePseudoSection;
|
|
|
|
|
2009-07-01 06:21:53 +00:00
|
|
|
/// Name - The name of the symbol.
|
2009-06-23 22:01:43 +00:00
|
|
|
std::string Name;
|
2009-08-22 07:22:36 +00:00
|
|
|
|
|
|
|
/// Section - The section the symbol is defined in. This is null for
|
|
|
|
/// undefined symbols, and the special AbsolutePseudoSection value for
|
|
|
|
/// absolute symbols.
|
2009-08-17 05:49:08 +00:00
|
|
|
const MCSection *Section;
|
2009-08-22 11:41:10 +00:00
|
|
|
|
2009-07-01 06:21:53 +00:00
|
|
|
/// IsTemporary - True if this is an assembler temporary label, which
|
|
|
|
/// typically does not survive in the .o file's symbol table. Usually
|
|
|
|
/// "Lfoo" or ".foo".
|
2009-06-23 22:01:43 +00:00
|
|
|
unsigned IsTemporary : 1;
|
|
|
|
|
2009-07-01 06:21:53 +00:00
|
|
|
private: // MCContext creates and uniques these.
|
|
|
|
friend class MCContext;
|
2009-07-27 21:22:30 +00:00
|
|
|
MCSymbol(const StringRef &_Name, bool _IsTemporary)
|
2009-08-22 11:41:10 +00:00
|
|
|
: Name(_Name), Section(0), IsTemporary(_IsTemporary) {}
|
2009-07-01 06:23:14 +00:00
|
|
|
|
|
|
|
MCSymbol(const MCSymbol&); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const MCSymbol&); // DO NOT IMPLEMENT
|
2009-07-01 06:21:53 +00:00
|
|
|
public:
|
2009-08-22 07:22:36 +00:00
|
|
|
/// getName - Get the symbol name.
|
|
|
|
const std::string &getName() const { return Name; }
|
2009-06-24 01:03:06 +00:00
|
|
|
|
2009-08-22 11:41:10 +00:00
|
|
|
/// @name Symbol Type
|
2009-08-22 07:22:36 +00:00
|
|
|
/// @{
|
2009-06-29 23:43:14 +00:00
|
|
|
|
2009-08-26 22:13:22 +00:00
|
|
|
/// isTemporary - Check if this is an assembler temporary symbol.
|
|
|
|
bool isTemporary() const {
|
|
|
|
return IsTemporary;
|
|
|
|
}
|
|
|
|
|
2009-08-26 00:10:55 +00:00
|
|
|
/// isDefined - Check if this symbol is defined (i.e., it has an address).
|
|
|
|
///
|
|
|
|
/// Defined symbols are either absolute or in some section.
|
|
|
|
bool isDefined() const {
|
|
|
|
return Section != 0;
|
|
|
|
}
|
|
|
|
|
2009-08-22 07:22:36 +00:00
|
|
|
/// isUndefined - Check if this symbol undefined (i.e., implicitly defined).
|
|
|
|
bool isUndefined() const {
|
2009-08-26 00:10:55 +00:00
|
|
|
return !isDefined();
|
2009-08-22 07:22:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// isAbsolute - Check if this this is an absolute symbol.
|
|
|
|
bool isAbsolute() const {
|
|
|
|
return Section == AbsolutePseudoSection;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getSection - Get the section associated with a defined, non-absolute
|
|
|
|
/// symbol.
|
|
|
|
const MCSection &getSection() const {
|
|
|
|
assert(!isUndefined() && !isAbsolute() && "Invalid accessor!");
|
|
|
|
return *Section;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// setSection - Mark the symbol as defined in the section \arg S.
|
|
|
|
void setSection(const MCSection &S) { Section = &S; }
|
|
|
|
|
|
|
|
/// setUndefined - Mark the symbol as undefined.
|
|
|
|
void setUndefined() {
|
|
|
|
Section = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// setAbsolute - Mark the symbol as absolute.
|
|
|
|
void setAbsolute() { Section = AbsolutePseudoSection; }
|
|
|
|
|
|
|
|
/// @}
|
2009-08-14 03:41:23 +00:00
|
|
|
|
|
|
|
/// print - Print the value to the stream \arg OS.
|
2009-09-03 05:46:51 +00:00
|
|
|
void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
|
2009-08-14 03:41:23 +00:00
|
|
|
|
|
|
|
/// dump - Print the value to stderr.
|
|
|
|
void dump() const;
|
2009-06-23 22:01:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|