[llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp MachineFunction.cpp

Evan Cheng evan.cheng at apple.com
Tue Jan 31 14:21:49 PST 2006



Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.42 -> 1.43
MachineFunction.cpp updated: 1.83 -> 1.84
---
Log message:

Allow the specification of explicit alignments for constant pool entries.


---
Diffs of the changes:  (+14 -7)

 AsmPrinter.cpp      |   14 +++++++++-----
 MachineFunction.cpp |    7 +++++--
 2 files changed, 14 insertions(+), 7 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.42 llvm/lib/CodeGen/AsmPrinter.cpp:1.43
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.42	Mon Jan 30 17:00:08 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp	Tue Jan 31 16:21:33 2006
@@ -103,7 +103,7 @@
 /// the code generator.
 ///
 void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
-  const std::vector<Constant*> &CP = MCP->getConstants();
+  const std::vector<std::pair<Constant*, unsigned> > &CP = MCP->getConstants();
   if (CP.empty()) return;
   const TargetData &TD = TM.getTargetData();
   
@@ -111,13 +111,17 @@
   for (unsigned i = 0, e = CP.size(); i != e; ++i) {
     // FIXME: force doubles to be naturally aligned.  We should handle this
     // more correctly in the future.
-    unsigned Alignment = TD.getTypeAlignmentShift(CP[i]->getType());
-    if (CP[i]->getType() == Type::DoubleTy && Alignment < 3) Alignment = 3;
+    unsigned Alignment = CP[i].second;
+    if (Alignment == 0) {
+      Alignment = TD.getTypeAlignmentShift(CP[i].first->getType());
+      if (CP[i].first->getType() == Type::DoubleTy && Alignment < 3)
+        Alignment = 3;
+    }
     
     EmitAlignment(Alignment);
     O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << '_' << i
-      << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n';
-    EmitGlobalConstant(CP[i]);
+      << ":\t\t\t\t\t" << CommentString << *CP[i].first << '\n';
+    EmitGlobalConstant(CP[i].first);
   }
 }
 


Index: llvm/lib/CodeGen/MachineFunction.cpp
diff -u llvm/lib/CodeGen/MachineFunction.cpp:1.83 llvm/lib/CodeGen/MachineFunction.cpp:1.84
--- llvm/lib/CodeGen/MachineFunction.cpp:1.83	Wed Jan  4 07:43:56 2006
+++ llvm/lib/CodeGen/MachineFunction.cpp	Tue Jan 31 16:21:33 2006
@@ -346,8 +346,11 @@
 //===----------------------------------------------------------------------===//
 
 void MachineConstantPool::print(std::ostream &OS) const {
-  for (unsigned i = 0, e = Constants.size(); i != e; ++i)
-    OS << "  <cp #" << i << "> is" << *(Value*)Constants[i] << "\n";
+  for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
+    OS << "  <cp #" << i << "> is" << *(Value*)Constants[i].first;
+    if (Constants[i].second != 0) OS << " , align=" << Constants[i].second;
+    OS << "\n";
+  }
 }
 
 void MachineConstantPool::dump() const { print(std::cerr); }






More information about the llvm-commits mailing list