From 75b8783aaf208a744577052f5c266bfd5e2d81f3 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Sun, 26 Feb 2006 08:28:12 +0000 Subject: [PATCH] Fixed ConstantPoolIndex operand asm print bug. This fixed 2005-07-17-INT-To-FP and 2005-05-12-Int64ToFP. llvm-svn: 26380 --- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp | 24 ++++++++++++-------- llvm/lib/Target/X86/X86IntelAsmPrinter.cpp | 26 +++++++++++++--------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/llvm/lib/Target/X86/X86ATTAsmPrinter.cpp b/llvm/lib/Target/X86/X86ATTAsmPrinter.cpp index f8f54d434a14..e9da1855ddd5 100755 --- a/llvm/lib/Target/X86/X86ATTAsmPrinter.cpp +++ b/llvm/lib/Target/X86/X86ATTAsmPrinter.cpp @@ -115,6 +115,20 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo, std::cerr << "Shouldn't use addPCDisp() when building X86 MachineInstrs"; abort (); return; + case MachineOperand::MO_ConstantPoolIndex: { + bool isMemOp = Modifier && !strcmp(Modifier, "mem"); + if (!isMemOp) O << '$'; + O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_" + << MO.getConstantPoolIndex(); + if (forDarwin && TM.getRelocationModel() == Reloc::PIC) + O << "-\"L" << getFunctionNumber() << "$pb\""; + int Offset = MO.getOffset(); + if (Offset > 0) + O << "+" << Offset; + else if (Offset < 0) + O << Offset; + return; + } case MachineOperand::MO_GlobalAddress: { bool isCallOp = Modifier && !strcmp(Modifier, "call"); bool isMemOp = Modifier && !strcmp(Modifier, "mem"); @@ -198,16 +212,8 @@ void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){ return; } - if (DispSpec.isGlobalAddress()) { + if (DispSpec.isGlobalAddress() || DispSpec.isConstantPoolIndex()) { printOperand(MI, Op+3, "mem"); - } else if (DispSpec.isConstantPoolIndex()) { - O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_" - << DispSpec.getConstantPoolIndex(); - if (forDarwin && TM.getRelocationModel() == Reloc::PIC) - O << "-\"L" << getFunctionNumber() << "$pb\""; - if (DispSpec.getOffset()) - O << "+" << DispSpec.getOffset(); - return; } else { int DispVal = DispSpec.getImmedValue(); if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg())) diff --git a/llvm/lib/Target/X86/X86IntelAsmPrinter.cpp b/llvm/lib/Target/X86/X86IntelAsmPrinter.cpp index 7f4592bb5b57..ed673df9fe56 100755 --- a/llvm/lib/Target/X86/X86IntelAsmPrinter.cpp +++ b/llvm/lib/Target/X86/X86IntelAsmPrinter.cpp @@ -109,6 +109,21 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO, assert(0 && "Shouldn't use addPCDisp() when building X86 MachineInstrs"); abort (); return; + case MachineOperand::MO_ConstantPoolIndex: { + bool isMemOp = Modifier && !strcmp(Modifier, "mem"); + if (!isMemOp) O << "OFFSET "; + O << "[" << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_" + << MO.getConstantPoolIndex(); + if (forDarwin && TM.getRelocationModel() == Reloc::PIC) + O << "-\"L" << getFunctionNumber() << "$pb\""; + int Offset = MO.getOffset(); + if (Offset > 0) + O << " + " << Offset; + else if (Offset < 0) + O << Offset; + O << "]"; + return; + } case MachineOperand::MO_GlobalAddress: { bool isCallOp = Modifier && !strcmp(Modifier, "call"); bool isMemOp = Modifier && !strcmp(Modifier, "mem"); @@ -192,19 +207,10 @@ void X86IntelAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){ NeedPlus = true; } - if (DispSpec.isGlobalAddress()) { + if (DispSpec.isGlobalAddress() || DispSpec.isConstantPoolIndex()) { if (NeedPlus) O << " + "; printOp(DispSpec, "mem"); - } else if (DispSpec.isConstantPoolIndex()) { - O << "[" << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_" - << DispSpec.getConstantPoolIndex(); - if (forDarwin && TM.getRelocationModel() == Reloc::PIC) - O << "-\"L" << getFunctionNumber() << "$pb\""; - if (DispSpec.getOffset()) - O << " + " << DispSpec.getOffset(); - O << "]"; - return; } else { int DispVal = DispSpec.getImmedValue(); if (DispVal || (!BaseReg.getReg() && !IndexReg.getReg())) {