diff --git a/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp b/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp index f2ef0b2ad77..768ed20f4db 100644 --- a/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp +++ b/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp @@ -195,7 +195,7 @@ void MipsInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, } if (Op.isImm()) { - O << Op.getImm(); + O << formatImm(Op.getImm()); return; } @@ -211,7 +211,7 @@ void MipsInstPrinter::printUImm(const MCInst *MI, int opNum, raw_ostream &O) { Imm -= Offset; Imm &= (1 << Bits) - 1; Imm += Offset; - O << Imm; + O << formatImm(Imm); return; } diff --git a/test/MC/Mips/hex-immediates.s b/test/MC/Mips/hex-immediates.s new file mode 100644 index 00000000000..7bf6f71266e --- /dev/null +++ b/test/MC/Mips/hex-immediates.s @@ -0,0 +1,11 @@ +# RUN: llvm-mc -filetype=obj %s -triple=mips-unknown-linux \ +# RUN: | llvm-objdump -d --print-imm-hex - | FileCheck %s + +# CHECK: jal 0x20 +# CHECK: addiu $sp, $sp, -0x20 +# CHECK: sw $2, 0x10($fp) + +jal 32 +addiu $sp, $sp, -32 +sw $2, 16($fp) +lui $2, 2