MC: Allow modifiers in MCSymbolRefExpr, and eliminate X86MCTargetExpr.
[oota-llvm.git] / include / llvm / MC / MCContext.h
index fa20f4506465750cb53a8c352debb14e6407bd21..85114e30995e933308bd2fcf74d02e80f1a5853d 100644 (file)
@@ -15,6 +15,7 @@
 #include "llvm/Support/Allocator.h"
 
 namespace llvm {
+  class MCAsmInfo;
   class MCExpr;
   class MCSection;
   class MCSymbol;
@@ -28,49 +29,57 @@ namespace llvm {
     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;
 
+    /// 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);
-    MCSymbol *GetOrCreateSymbol(const Twine &Name);
+    MCSymbol *GetOrCreateSymbol(StringRef Name, bool isTemporary = false);
+    MCSymbol *GetOrCreateSymbol(const Twine &Name, bool isTemporary = false);
 
-    /// CreateTemporarySymbol - Create a new temporary symbol with the specified
-    /// @param Name.
+    /// 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 = "");
+    MCSymbol *GetOrCreateTemporarySymbol(StringRef Name = "");
+    MCSymbol *GetOrCreateTemporarySymbol(const Twine &Name);
 
-    /// LookupSymbol - Get the symbol for @param Name, or null.
-    MCSymbol *LookupSymbol(const StringRef &Name) const;
+    /// LookupSymbol - Get the symbol for \p Name, or null.
+    MCSymbol *LookupSymbol(StringRef Name) const;
 
     /// @}