MC: Allow modifiers in MCSymbolRefExpr, and eliminate X86MCTargetExpr.
[oota-llvm.git] / include / llvm / MC / MCContext.h
index 28436f052d9b1527c8d51989e92bab357db30ce8..85114e30995e933308bd2fcf74d02e80f1a5853d 100644 (file)
 #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.
@@ -27,63 +29,64 @@ 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;
 
-    /// 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();
     
-    /// 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);
+    const MCAsmInfo &getAsmInfo() const { return MAI; }
+
+    /// @name Symbol Managment
+    /// @{
+    
+    /// 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.
-    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;
-
-    /// ClearSymbolValue - Erase a value binding for @arg Symbol, if one exists.
-    void ClearSymbolValue(const MCSymbol *Symbol);
+    MCSymbol *GetOrCreateTemporarySymbol(StringRef Name = "");
+    MCSymbol *GetOrCreateTemporarySymbol(const Twine &Name);
 
-    /// SetSymbolValue - Set the value binding for @arg Symbol to @arg Value.
-    void SetSymbolValue(const MCSymbol *Symbol, const MCValue &Value);
+    /// LookupSymbol - Get the symbol for \p Name, or null.
+    MCSymbol *LookupSymbol(StringRef Name) const;
 
-    /// GetSymbolValue - Return the current value for @arg Symbol, or null if
-    /// none exists.
-    const MCValue *GetSymbolValue(const MCSymbol *Symbol) const;
+    /// @}
 
     void *Allocate(unsigned Size, unsigned Align = 8) {
       return Allocator.Allocate(Size, Align);
     }
-    void Deallocate(void *Ptr) { 
+    void Deallocate(void *Ptr) {
     }
   };