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
This commit is contained in:
Chris Lattner 2009-09-13 19:44:38 +00:00
parent cae05cb324
commit a1cb09e4b9
2 changed files with 21 additions and 15 deletions

View File

@ -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();

View File

@ -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,11 +209,16 @@ 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())) {
assert(TargetRegisterInfo::isPhysicalRegister(MO.getReg()));
unsigned Reg = MO.getReg();
if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
EVT VT = (strcmp(Modifier,"subreg64") == 0) ?
@ -216,9 +226,7 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
((strcmp(Modifier,"subreg16") == 0) ? MVT::i16 :MVT::i8));
Reg = getX86SubSuperRegister(Reg, VT);
}
O << TRI->getName(Reg);
} else
O << "reg" << MO.getReg();
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;
}