[llvm-commits] CVS: llvm/lib/Target/X86/X86AsmPrinter.cpp X86TargetAsmInfo.cpp

Evan Cheng evan.cheng at apple.com
Wed Mar 7 17:07:24 PST 2007



Changes in directory llvm/lib/Target/X86:

X86AsmPrinter.cpp updated: 1.235 -> 1.236
X86TargetAsmInfo.cpp updated: 1.33 -> 1.34
---
Log message:

Put constant data to .const, .const_data, .literal{4|8|16} sections.

---
Diffs of the changes:  (+25 -2)

 X86AsmPrinter.cpp    |   25 +++++++++++++++++++++++--
 X86TargetAsmInfo.cpp |    2 ++
 2 files changed, 25 insertions(+), 2 deletions(-)


Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.235 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.236
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.235	Thu Mar  1 10:29:22 2007
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp	Wed Mar  7 19:07:07 2007
@@ -145,7 +145,8 @@
     
     std::string name = Mang->getValueName(I);
     Constant *C = I->getInitializer();
-    unsigned Size = TD->getTypeSize(C->getType());
+    const Type *Type = C->getType();
+    unsigned Size = TD->getTypeSize(Type);
     unsigned Align = TD->getPreferredAlignmentLog(I);
 
     if (I->hasHiddenVisibility())
@@ -250,8 +251,28 @@
       } else {
         if (C->isNullValue() && !NoZerosInBSS && TAI->getBSSSection())
           SwitchToDataSection(TAI->getBSSSection(), I);
-        else
+        else if (!I->isConstant())
           SwitchToDataSection(TAI->getDataSection(), I);
+        else {
+          // Read-only data.
+          bool isIntFPLiteral = Type->isInteger()  || Type->isFloatingPoint();
+          if (C->ContainsRelocations() && Subtarget->isTargetDarwin() &&
+              TM.getRelocationModel() != Reloc::Static)
+            SwitchToDataSection("\t.const_data\n");
+          else if (isIntFPLiteral && Size == 4 &&
+                   TAI->getFourByteConstantSection())
+            SwitchToDataSection(TAI->getFourByteConstantSection(), I);
+          else if (isIntFPLiteral && Size == 8 &&
+                   TAI->getEightByteConstantSection())
+            SwitchToDataSection(TAI->getEightByteConstantSection(), I);
+          else if (isIntFPLiteral && Size == 16 &&
+                   TAI->getSixteenByteConstantSection())
+            SwitchToDataSection(TAI->getSixteenByteConstantSection(), I);
+          else if (TAI->getReadOnlySection())
+            SwitchToDataSection(TAI->getReadOnlySection(), I);
+          else
+            SwitchToDataSection(TAI->getDataSection(), I);
+        }
       }
       
       break;


Index: llvm/lib/Target/X86/X86TargetAsmInfo.cpp
diff -u llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.33 llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.34
--- llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.33	Tue Mar  6 20:47:57 2007
+++ llvm/lib/Target/X86/X86TargetAsmInfo.cpp	Wed Mar  7 19:07:07 2007
@@ -56,6 +56,7 @@
     EightByteConstantSection = "\t.literal8\n";
     if (Subtarget->is64Bit())
       SixteenByteConstantSection = "\t.literal16\n";
+    ReadOnlySection = "\t.const\n";
     LCOMMDirective = "\t.lcomm\t";
     COMMDirectiveTakesAlignment = false;
     HasDotTypeDotSizeDirective = false;
@@ -103,6 +104,7 @@
     // bool HasDotLoc; // Defaults to false.
     // HasDotFile - True if target asm supports .file directives.
     // bool HasDotFile; // Defaults to false.
+    ReadOnlySection = "\t.section\t.rodata\n";
     PrivateGlobalPrefix = ".L";
     WeakRefDirective = "\t.weak\t";
     DwarfRequiresFrameSection = false;






More information about the llvm-commits mailing list