Implement unique sections with an unique ID.
[oota-llvm.git] / include / llvm / MC / MCContext.h
index ca4eae53a887bf11faf049662a926ccdec01a3bf..e06886445755080ca8b8f88b2879c577788924e8 100644 (file)
@@ -164,19 +164,24 @@ namespace llvm {
 
     struct ELFSectionKey {
       std::string SectionName;
-      std::string GroupName;
-      ELFSectionKey(StringRef SectionName, StringRef GroupName)
-          : SectionName(SectionName), GroupName(GroupName) {}
+      StringRef GroupName;
+      unsigned UniqueID;
+      ELFSectionKey(StringRef SectionName, StringRef GroupName,
+                    unsigned UniqueID)
+          : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {
+      }
       bool operator<(const ELFSectionKey &Other) const {
         if (SectionName != Other.SectionName)
           return SectionName < Other.SectionName;
-        return GroupName < Other.GroupName;
+        if (GroupName != Other.GroupName)
+          return GroupName < Other.GroupName;
+        return UniqueID < Other.UniqueID;
       }
     };
 
     struct COFFSectionKey {
       std::string SectionName;
-      std::string GroupName;
+      StringRef GroupName;
       int SelectionKey;
       COFFSectionKey(StringRef SectionName, StringRef GroupName,
                      int SelectionKey)
@@ -194,6 +199,7 @@ namespace llvm {
     StringMap<const MCSectionMachO*> MachOUniquingMap;
     std::map<ELFSectionKey, const MCSectionELF *> ELFUniquingMap;
     std::map<COFFSectionKey, const MCSectionCOFF *> COFFUniquingMap;
+    StringMap<bool> ELFRelSecNames;
 
     /// Do automatic reset in destructor
     bool AutoReset;
@@ -258,6 +264,7 @@ namespace llvm {
     MCSymbol *getOrCreateSectionSymbol(const MCSectionELF &Section);
 
     MCSymbol *getOrCreateFrameAllocSymbol(StringRef FuncName, unsigned Idx);
+    MCSymbol *getOrCreateParentFrameOffsetSymbol(StringRef FuncName);
 
     /// Get the symbol for \p Name, or null.
     MCSymbol *LookupSymbol(const Twine &Name) const;
@@ -301,9 +308,13 @@ namespace llvm {
 
     const MCSectionELF *getELFSection(StringRef Section, unsigned Type,
                                       unsigned Flags, unsigned EntrySize,
-                                      StringRef Group, bool Unique,
+                                      StringRef Group, unsigned UniqueID,
                                       const char *BeginSymName = nullptr);
 
+    const MCSectionELF *createELFRelSection(StringRef Name, unsigned Type,
+                                            unsigned Flags, unsigned EntrySize,
+                                            const MCSymbol *Group);
+
     void renameELFSection(const MCSectionELF *Section, StringRef Name);
 
     const MCSectionELF *CreateELFGroupSection();