#include "llvm/Support/Allocator.h"
namespace llvm {
- class MCValue;
+ class MCAsmInfo;
+ class MCExpr;
class MCSection;
class MCSymbol;
class StringRef;
+ class Twine;
/// MCContext - Context object for machine code objects. This class owns all
/// of the sections that it creates.
MCContext(const MCContext&); // DO NOT IMPLEMENT
MCContext &operator=(const MCContext&); // DO NOT IMPLEMENT
+ /// The MCAsmInfo for this target.
+ const MCAsmInfo &MAI;
+
/// Sections - Bindings of names to allocated sections.
StringMap<MCSection*> Sections;
/// Symbols - Bindings of names to symbols.
StringMap<MCSymbol*> Symbols;
- /// SymbolValues - Bindings of symbols to values.
- //
- // FIXME: Is there a good reason to not just put this in the MCSymbol?
- DenseMap<const MCSymbol*, MCValue> SymbolValues;
-
+ /// NextUniqueID - The next ID to dole out to an unnamed assembler temporary
+ /// symbol.
+ unsigned NextUniqueID;
+
/// Allocator - Allocator object used for creating machine code objects.
///
/// We use a bump pointer allocator to avoid the need to track all allocated
/// objects.
BumpPtrAllocator Allocator;
public:
- MCContext();
+ explicit MCContext(const MCAsmInfo &MAI);
~MCContext();
+
+ const MCAsmInfo &getAsmInfo() const { return MAI; }
/// @name Symbol Managment
/// @{
-
- /// CreateSymbol - Create a new symbol with the specified @param Name.
- ///
- /// @param Name - The symbol name, which must be unique across all symbols.
- MCSymbol *CreateSymbol(const StringRef &Name);
+
+ /// CreateTempSymbol - Create and return a new assembler temporary symbol
+ /// with a unique but unspecified name.
+ MCSymbol *CreateTempSymbol();
/// GetOrCreateSymbol - Lookup the symbol inside with the specified
- /// @param Name. If it exists, return it. If not, create a forward
+ /// @p Name. If it exists, return it. If not, create a forward
/// reference and return it.
///
/// @param Name - The symbol name, which must be unique across all symbols.
- /// @param IsTemporary - Whether this symbol is an assembler temporary,
- /// which should not survive into the symbol table for the translation unit.
- MCSymbol *GetOrCreateSymbol(const StringRef &Name);
-
- /// CreateTemporarySymbol - Create a new temporary symbol with the specified
- /// @param Name.
+ MCSymbol *GetOrCreateSymbol(StringRef Name, bool isTemporary = false);
+ MCSymbol *GetOrCreateSymbol(const Twine &Name, bool isTemporary = false);
+
+ /// GetOrCreateTemporarySymbol - Create a new assembler temporary symbol
+ /// with the specified @p Name if it doesn't exist or return the existing
+ /// one if it does.
///
/// @param Name - The symbol name, for debugging purposes only, temporary
/// symbols do not surive assembly. If non-empty the name must be unique
/// across all symbols.
- MCSymbol *CreateTemporarySymbol(const StringRef &Name = "");
-
- /// LookupSymbol - Get the symbol for @param Name, or null.
- MCSymbol *LookupSymbol(const StringRef &Name) const;
-
- /// @}
- /// @name Symbol Value Table
- /// @{
-
- /// ClearSymbolValue - Erase a value binding for @arg Symbol, if one exists.
- void ClearSymbolValue(const MCSymbol *Symbol);
-
- /// SetSymbolValue - Set the value binding for @arg Symbol to @arg Value.
- void SetSymbolValue(const MCSymbol *Symbol, const MCValue &Value);
+ MCSymbol *GetOrCreateTemporarySymbol(StringRef Name = "");
+ MCSymbol *GetOrCreateTemporarySymbol(const Twine &Name);
- /// GetSymbolValue - Return the current value for @arg Symbol, or null if
- /// none exists.
- const MCValue *GetSymbolValue(const MCSymbol *Symbol) const;
+ /// LookupSymbol - Get the symbol for \p Name, or null.
+ MCSymbol *LookupSymbol(StringRef Name) const;
/// @}
void *Allocate(unsigned Size, unsigned Align = 8) {
return Allocator.Allocate(Size, Align);
}
- void Deallocate(void *Ptr) {
+ void Deallocate(void *Ptr) {
}
};