From a1cb09e4b9d3b5a80a20d881b3d6d5c60d15f0d5 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 13 Sep 2009 19:44:38 +0000 Subject: [PATCH] make intel asmprinter use TRI::getAsmName instead of TRI::getName like all the other targets. Add support for weak/linkonce linkage so it doesn't crash on basically all nontrivial testcases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81704 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../X86/AsmPrinter/X86ATTInstPrinter.cpp | 4 +-- .../X86/AsmPrinter/X86IntelAsmPrinter.cpp | 32 ++++++++++++------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp index c37b656e47b..d989f60a595 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp @@ -70,9 +70,7 @@ void X86ATTInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, const MCOperand &Op = MI->getOperand(OpNo); if (Op.isReg()) { - O << '%'; - unsigned Reg = Op.getReg(); - O << TRI->getAsmName(Reg); + O << '%' << TRI->getAsmName(Op.getReg()); return; } else if (Op.isImm()) { O << '$' << Op.getImm(); diff --git a/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp index a3e5286d8ee..484b5e91cdb 100644 --- a/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp @@ -149,6 +149,11 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) { switch (F->getLinkage()) { default: llvm_unreachable("Unsupported linkage type!"); + case Function::LinkOnceAnyLinkage: + case Function::LinkOnceODRLinkage: + case Function::WeakAnyLinkage: + case Function::WeakODRLinkage: + case Function::PrivateLinkage: case Function::LinkerPrivateLinkage: case Function::InternalLinkage: @@ -204,21 +209,24 @@ void X86IntelAsmPrinter::printSSECC(const MachineInstr *MI, unsigned Op) { } } +static void PrintRegName(raw_ostream &O, StringRef RegName) { + for (unsigned i = 0, e = RegName.size(); i != e; ++i) + O << (char)toupper(RegName[i]); +} + void X86IntelAsmPrinter::printOp(const MachineOperand &MO, const char *Modifier) { switch (MO.getType()) { case MachineOperand::MO_Register: { - if (TargetRegisterInfo::isPhysicalRegister(MO.getReg())) { - unsigned Reg = MO.getReg(); - if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) { - EVT VT = (strcmp(Modifier,"subreg64") == 0) ? - MVT::i64 : ((strcmp(Modifier, "subreg32") == 0) ? MVT::i32 : - ((strcmp(Modifier,"subreg16") == 0) ? MVT::i16 :MVT::i8)); - Reg = getX86SubSuperRegister(Reg, VT); - } - O << TRI->getName(Reg); - } else - O << "reg" << MO.getReg(); + assert(TargetRegisterInfo::isPhysicalRegister(MO.getReg())); + unsigned Reg = MO.getReg(); + if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) { + EVT VT = (strcmp(Modifier,"subreg64") == 0) ? + MVT::i64 : ((strcmp(Modifier, "subreg32") == 0) ? MVT::i32 : + ((strcmp(Modifier,"subreg16") == 0) ? MVT::i16 :MVT::i8)); + Reg = getX86SubSuperRegister(Reg, VT); + } + PrintRegName(O, TRI->getAsmName(Reg)); return; } case MachineOperand::MO_Immediate: @@ -391,7 +399,7 @@ bool X86IntelAsmPrinter::printAsmMRegister(const MachineOperand &MO, break; } - O << TRI->getName(Reg); + PrintRegName(O, TRI->getAsmName(Reg)); return false; }