Print entity size for mergeable sections
authorAnton Korobeynikov <asl@math.spbu.ru>
Wed, 9 Jul 2008 13:22:17 +0000 (13:22 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Wed, 9 Jul 2008 13:22:17 +0000 (13:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53303 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetAsmInfo.h
lib/Target/X86/X86TargetAsmInfo.cpp

index 0cd7f8d7a5ebb03a185a6a5b30d97dcac6143978..4e7d23d500105b314214fdc1e0c4ff3c8a296cba 100644 (file)
@@ -45,15 +45,25 @@ namespace llvm {
   namespace SectionFlags {
     enum Flags {
       None       = 0,
-      Code       = 1 << 0, ///< Section contains code
-      Writeable  = 1 << 1, ///< Section is writeable
-      BSS        = 1 << 2, ///< Section contains only zeroes
-      Mergeable  = 1 << 3, ///< Section contains mergeable data
-      Strings    = 1 << 4, ///< Section contains null-terminated strings
-      TLS        = 1 << 5, ///< Section contains thread-local data
-      Debug      = 1 << 6, ///< Section contains debug data
-      Linkonce   = 1 << 7  ///< Section is linkonce
+      Code       = 1 << 0,    ///< Section contains code
+      Writeable  = 1 << 1,    ///< Section is writeable
+      BSS        = 1 << 2,    ///< Section contains only zeroes
+      Mergeable  = 1 << 3,    ///< Section contains mergeable data
+      Strings    = 1 << 4,    ///< Section contains null-terminated strings
+      TLS        = 1 << 5,    ///< Section contains thread-local data
+      Debug      = 1 << 6,    ///< Section contains debug data
+      Linkonce   = 1 << 7,    ///< Section is linkonce
+      // Some gap for future flags
+      EntitySize = 0xFF << 24 ///< Entity size for mergeable sections
     };
+
+    static inline unsigned getEntitySize(unsigned flags) {
+      return (flags >> 24) & 0xFF;
+    }
+
+    static inline unsigned setEntitySize(unsigned flags, unsigned size) {
+      return ((flags & ~EntitySize) | ((size & 0xFF) << 24));
+    }
   }
 
   class TargetMachine;
index c900ac9e77c1ed59ea74e71ba989c6ef321b40e1..b0c6f1cb533b54d98fe78168a1176aec281882c6 100644 (file)
@@ -337,7 +337,8 @@ std::string X86ELFTargetAsmInfo::PrintSectionFlags(unsigned flags) const {
   else
     Flags += ",@progbits";
 
-  // FIXME: entity size for mergeable sections
+  if (unsigned entitySize = SectionFlags::getEntitySize(flags))
+    Flags += "," + utostr(entitySize);
 
   return Flags;
 }