[llvm-commits] CVS: llvm/lib/Target/ARM/ARMAsmPrinter.cpp ARMTargetAsmInfo.cpp

Evan Cheng evan.cheng at apple.com
Wed Mar 7 17:25:47 PST 2007



Changes in directory llvm/lib/Target/ARM:

ARMAsmPrinter.cpp updated: 1.58 -> 1.59
ARMTargetAsmInfo.cpp updated: 1.12 -> 1.13
---
Log message:

For Darwin, put constant data into .const, .const_data, .literal{4|8|16}
sections.

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

 ARMAsmPrinter.cpp    |   25 +++++++++++++++++++++++--
 ARMTargetAsmInfo.cpp |    3 +++
 2 files changed, 26 insertions(+), 2 deletions(-)


Index: llvm/lib/Target/ARM/ARMAsmPrinter.cpp
diff -u llvm/lib/Target/ARM/ARMAsmPrinter.cpp:1.58 llvm/lib/Target/ARM/ARMAsmPrinter.cpp:1.59
--- llvm/lib/Target/ARM/ARMAsmPrinter.cpp:1.58	Thu Mar  1 00:05:39 2007
+++ llvm/lib/Target/ARM/ARMAsmPrinter.cpp	Wed Mar  7 19:25:25 2007
@@ -743,7 +743,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())
@@ -829,8 +830,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/ARM/ARMTargetAsmInfo.cpp
diff -u llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp:1.12 llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp:1.13
--- llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp:1.12	Mon Mar  5 11:59:58 2007
+++ llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp	Wed Mar  7 19:25:25 2007
@@ -27,6 +27,9 @@
     HiddenDirective = "\t.private_extern\t";
     JumpTableDataSection = ".const";
     CStringSection = "\t.cstring";
+    FourByteConstantSection = "\t.literal4\n";
+    EightByteConstantSection = "\t.literal8\n";
+    ReadOnlySection = "\t.const\n";
     HasDotTypeDotSizeDirective = false;
     if (TM.getRelocationModel() == Reloc::Static) {
       StaticCtorsSection = ".constructor";






More information about the llvm-commits mailing list