[PATCH] [mips][microMIPS] Implement disassembler support for 16-bit instructions LBU16, LHU16, LW16, SB16, SH16 and SW16

Sasa Stankovic Sasa.Stankovic at imgtec.com
Wed Nov 26 08:27:28 PST 2014


================
Comment at: lib/Target/Mips/Disassembler/MipsDisassembler.cpp:1127
@@ +1126,3 @@
+    case Mips::LBU16_MM:
+    case Mips::SB16_MM:
+      Inst.addOperand(MCOperand::CreateImm(Offset));
----------------
lbu16 is wrongly disassembled when encoded immediate is 0xf. The decoded immediate should be -1 in that case. For the following instruction

lbu16 $3, -1($16)

if it is assembled with llvm-mc (or gcc) and then disassembled with llvm-objdump, the result is

lbu16 $3, 15($16)

Please include this instruction in both assemble and disassemble tests.

================
Comment at: lib/Target/Mips/Disassembler/MipsDisassembler.cpp:1134
@@ +1133,3 @@
+      break;
+    case Mips::LW16_MM:
+      Inst.addOperand(MCOperand::CreateImm(SignExtend32<4>(Offset) * 4));
----------------
It's not clear whether you need SignExtend here. Instruction reference document says that offset is sign-extended. But gcc treats the offset as zero-extended, and will only assemble lw16 if offset is [0, 4, ..., 60].

http://reviews.llvm.org/D6405






More information about the llvm-commits mailing list