Changes in directory llvm/lib/Target/X86:
X86AsmPrinter.cpp updated: 1.184 -> 1.185 X86AsmPrinter.h updated: 1.19 -> 1.20 --- Log message: Darwin puts float and double literal constants into literal4 and literal8 sections. --- Diffs of the changes: (+58 -0) X86AsmPrinter.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ X86AsmPrinter.h | 6 ++++++ 2 files changed, 58 insertions(+) Index: llvm/lib/Target/X86/X86AsmPrinter.cpp diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.184 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.185 --- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.184 Sun Jun 4 02:24:07 2006 +++ llvm/lib/Target/X86/X86AsmPrinter.cpp Wed Jun 28 02:35:41 2006 @@ -222,6 +222,58 @@ return false; // success } +void X86SharedAsmPrinter::EmitConstantPool(MachineConstantPool *MCP) { + if (!Subtarget->TargetType == X86Subtarget::isDarwin) { + AsmPrinter::EmitConstantPool(MCP); + return; + } + + const std::vector<MachineConstantPoolEntry> &CP = MCP->getConstants(); + if (CP.empty()) return; + + std::vector<MachineConstantPoolEntry> FloatCPs; + std::vector<MachineConstantPoolEntry> DoubleCPs; + std::vector<MachineConstantPoolEntry> OtherCPs; + // const TargetData *TD = TM.getTargetData(); + // unsigned Align = MCP->getConstantPoolAlignment(); + for (unsigned i = 0, e = CP.size(); i != e; ++i) { + MachineConstantPoolEntry CPE = CP[i]; + const Constant *CV = CPE.Val; + const Type *Ty = CV->getType(); + if (Ty->getTypeID() == Type::FloatTyID) + FloatCPs.push_back(CPE); + else if (Ty->getTypeID() == Type::DoubleTyID) + DoubleCPs.push_back(CPE); + else + OtherCPs.push_back(CPE); + } + EmitConstantPool(MCP, FloatCPs, "\t.literal4"); + EmitConstantPool(MCP, DoubleCPs, "\t.literal8"); + EmitConstantPool(MCP, OtherCPs, ConstantPoolSection); +} + +void +X86SharedAsmPrinter::EmitConstantPool(MachineConstantPool *MCP, + std::vector<MachineConstantPoolEntry> &CP, + const char *Section) { + if (CP.empty()) return; + + SwitchToDataSection(Section, 0); + EmitAlignment(MCP->getConstantPoolAlignment()); + for (unsigned i = 0, e = CP.size(); i != e; ++i) { + O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << '_' << i + << ":\t\t\t\t\t" << CommentString << " "; + WriteTypeSymbolic(O, CP[i].Val->getType(), 0) << '\n'; + EmitGlobalConstant(CP[i].Val); + if (i != e-1) { + unsigned EntSize = TM.getTargetData()->getTypeSize(CP[i].Val->getType()); + unsigned ValEnd = CP[i].Offset + EntSize; + // Emit inter-object padding for alignment. + EmitZeros(CP[i+1].Offset-ValEnd); + } + } +} + /// createX86CodePrinterPass - Returns a pass that prints the X86 assembly code /// for a MachineFunction to the given output stream, using the given target /// machine description. Index: llvm/lib/Target/X86/X86AsmPrinter.h diff -u llvm/lib/Target/X86/X86AsmPrinter.h:1.19 llvm/lib/Target/X86/X86AsmPrinter.h:1.20 --- llvm/lib/Target/X86/X86AsmPrinter.h:1.19 Thu May 25 16:59:08 2006 +++ llvm/lib/Target/X86/X86AsmPrinter.h Wed Jun 28 02:35:41 2006 @@ -20,6 +20,7 @@ #include "X86TargetMachine.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/DwarfWriter.h" +#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineDebugInfo.h" #include "llvm/ADT/Statistic.h" #include <set> @@ -92,6 +93,11 @@ MI->getOperand(Op+3).isGlobalAddress() || MI->getOperand(Op+3).isConstantPoolIndex()); } + + virtual void EmitConstantPool(MachineConstantPool *MCP); + void EmitConstantPool(MachineConstantPool *MCP, + std::vector<MachineConstantPoolEntry> &CP, + const char *Section); }; } // end namespace llvm _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits