From efa236f40db2231bc20a5ed964292326c7a05797 Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Wed, 21 Oct 2009 00:12:27 +0000 Subject: [PATCH] Add a workaround for different memops prefixes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84707 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp b/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp index 84a2e023c4e..8760ed5602b 100644 --- a/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp +++ b/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp @@ -36,8 +36,6 @@ void MSP430InstPrinter::printInst(const MCInst *MI) { void MSP430InstPrinter::printOperand(const MCInst *MI, unsigned OpNo, const char *Modifier) { - assert((Modifier == 0 || Modifier[0] == 0) && "Cannot print modifiers"); - const MCOperand &Op = MI->getOperand(OpNo); if (Op.isReg()) { O << getRegisterName(Op.getReg()); @@ -45,6 +43,8 @@ void MSP430InstPrinter::printOperand(const MCInst *MI, unsigned OpNo, O << '#' << Op.getImm(); } else { assert(Op.isExpr() && "unknown operand kind in printOperand"); + bool isMemOp = Modifier && !strcmp(Modifier, "mem"); + O << (isMemOp ? '&' : '#'); Op.getExpr()->print(O, &MAI); } } @@ -54,7 +54,10 @@ void MSP430InstPrinter::printSrcMemOperand(const MCInst *MI, unsigned OpNo, const MCOperand &Base = MI->getOperand(OpNo); const MCOperand &Disp = MI->getOperand(OpNo+1); - if (Disp.isImm() && !Base.isReg()) + // FIXME: move global to displacement field! + if (Base.isExpr()) + printOperand(MI, OpNo, "mem"); + else if (Disp.isImm() && !Base.isReg()) printOperand(MI, OpNo); else if (Base.isReg()) { if (Disp.getImm()) {