[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp PPCTargetAsmInfo.cpp

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



Changes in directory llvm/lib/Target/PowerPC:

PPCAsmPrinter.cpp updated: 1.235 -> 1.236
PPCTargetAsmInfo.cpp updated: 1.18 -> 1.19
---
Log message:

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

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

 PPCAsmPrinter.cpp    |   26 ++++++++++++++++++++++++--
 PPCTargetAsmInfo.cpp |    3 +++
 2 files changed, 27 insertions(+), 2 deletions(-)


Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.235 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.236
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.235	Fri Mar  2 23:29:51 2007
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp	Wed Mar  7 19:25:25 2007
@@ -893,7 +893,8 @@
         O << Directive << name << "\n";
     
     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 (C->isNullValue() && /* FIXME: Verify correct */
@@ -937,7 +938,28 @@
           }
         }
 
-        SwitchToDataSection("\t.data", I);
+        if (!I->isConstant())
+          SwitchToDataSection(TAI->getDataSection(), I);
+        else {
+          // Read-only data.
+          bool isIntFPLiteral = Type->isInteger()  || Type->isFloatingPoint();
+          if (C->ContainsRelocations() &&
+              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;
       default:
         cerr << "Unknown linkage type!";


Index: llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp
diff -u llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp:1.18 llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp:1.19
--- llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp:1.18	Wed Feb 21 16:43:40 2007
+++ llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp	Wed Mar  7 19:25:25 2007
@@ -57,6 +57,9 @@
   JumpTableDataSection = ".const";
   GlobalDirective = "\t.globl\t";
   CStringSection = "\t.cstring";
+  FourByteConstantSection = "\t.literal4\n";
+  EightByteConstantSection = "\t.literal8\n";
+  ReadOnlySection = "\t.const\n";
   if (TM.getRelocationModel() == Reloc::Static) {
     StaticCtorsSection = ".constructor";
     StaticDtorsSection = ".destructor";






More information about the llvm-commits mailing list