diff options
-rw-r--r-- | lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp | 3 | ||||
-rw-r--r-- | lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp | 22 | ||||
-rw-r--r-- | lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.h | 3 | ||||
-rw-r--r-- | lib/Target/MSP430/MSP430InstrInfo.td | 4 |
4 files changed, 23 insertions, 9 deletions
diff --git a/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp b/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp index 73368803c0..4f5879a347 100644 --- a/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp +++ b/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp @@ -65,6 +65,9 @@ namespace { } void printOperand(const MachineInstr *MI, int OpNum, const char* Modifier = 0); + void printPCRelImmOperand(const MachineInstr *MI, int OpNum) { + printOperand(MI, OpNum); + } void printSrcMemOperand(const MachineInstr *MI, int OpNum, const char* Modifier = 0); void printCCOperand(const MachineInstr *MI, int OpNum); diff --git a/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp b/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp index 8fcbab58c9..59b448aa87 100644 --- a/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp +++ b/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp @@ -35,6 +35,16 @@ void MSP430InstPrinter::printInst(const MCInst *MI) { printInstruction(MI); } +void MSP430InstPrinter::printPCRelImmOperand(const MCInst *MI, unsigned OpNo) { + const MCOperand &Op = MI->getOperand(OpNo); + if (Op.isImm()) + O << Op.getImm(); + else { + assert(Op.isExpr() && "unknown pcrel immediate operand"); + Op.getExpr()->print(O, &MAI); + } +} + void MSP430InstPrinter::printOperand(const MCInst *MI, unsigned OpNo, const char *Modifier) { const MCOperand &Op = MI->getOperand(OpNo); @@ -44,8 +54,7 @@ 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 ? '&' : '#'); + O << '#'; Op.getExpr()->print(O, &MAI); } } @@ -56,9 +65,10 @@ void MSP430InstPrinter::printSrcMemOperand(const MCInst *MI, unsigned OpNo, const MCOperand &Disp = MI->getOperand(OpNo+1); // FIXME: move global to displacement field! - if (Base.isExpr()) - printOperand(MI, OpNo, "mem"); - else if (Disp.isImm() && !Base.isReg()) + if (Base.isExpr()) { + O << '&'; + Base.getExpr()->print(O, &MAI); + } else if (Disp.isImm() && !Base.isReg()) printOperand(MI, OpNo); else if (Base.isReg()) { if (Disp.getImm()) { @@ -74,8 +84,8 @@ void MSP430InstPrinter::printSrcMemOperand(const MCInst *MI, unsigned OpNo, Disp.dump(); llvm_unreachable("Unsupported memory operand"); } - } + void MSP430InstPrinter::printCCOperand(const MCInst *MI, unsigned OpNo) { unsigned CC = MI->getOperand(OpNo).getImm(); diff --git a/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.h b/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.h index 3d4b931cdb..2fac800fcd 100644 --- a/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.h +++ b/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.h @@ -35,10 +35,9 @@ namespace llvm void printOperand(const MCInst *MI, unsigned OpNo, const char *Modifier = 0); - + void printPCRelImmOperand(const MCInst *MI, unsigned OpNo); void printSrcMemOperand(const MCInst *MI, unsigned OpNo, const char *Modifier = 0); - void printCCOperand(const MCInst *MI, unsigned OpNo); }; diff --git a/lib/Target/MSP430/MSP430InstrInfo.td b/lib/Target/MSP430/MSP430InstrInfo.td index f7e0d2bad6..e202175561 100644 --- a/lib/Target/MSP430/MSP430InstrInfo.td +++ b/lib/Target/MSP430/MSP430InstrInfo.td @@ -71,7 +71,9 @@ def memdst : Operand<i16> { } // Branch targets have OtherVT type. -def brtarget : Operand<OtherVT>; +def brtarget : Operand<OtherVT> { + let PrintMethod = "printPCRelImmOperand"; +} // Operand for printing out a condition code. def cc : Operand<i8> { |