[PATCH] [mips][microMIPSr6] Implement disassembler support

Jozef Kolek jozef.kolek at rt-rk.com
Fri Mar 20 13:01:51 PDT 2015


Hi zoran.jovanovic, dsanders,

This patch implements disassembler support for microMIPS32r6.

http://reviews.llvm.org/D8490

Files:
  lib/Target/Mips/Disassembler/MipsDisassembler.cpp
  lib/Target/Mips/MicroMipsR6InstrInfo.td

Index: lib/Target/Mips/Disassembler/MipsDisassembler.cpp
===================================================================
--- lib/Target/Mips/Disassembler/MipsDisassembler.cpp
+++ lib/Target/Mips/Disassembler/MipsDisassembler.cpp
@@ -32,11 +32,13 @@
 
 class MipsDisassembler : public MCDisassembler {
   bool IsMicroMips;
+  bool IsMicroMips32r6;
   bool IsBigEndian;
 public:
   MipsDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx, bool IsBigEndian)
       : MCDisassembler(STI, Ctx),
         IsMicroMips(STI.getFeatureBits() & Mips::FeatureMicroMips),
+        IsMicroMips32r6(STI.getFeatureBits() & Mips::FeatureMicroMipsR6),
         IsBigEndian(IsBigEndian) {}
 
   bool hasMips3() const { return STI.getFeatureBits() & Mips::FeatureMips3; }
@@ -821,7 +823,7 @@
   uint32_t Insn;
   DecodeStatus Result;
 
-  if (IsMicroMips) {
+  if (IsMicroMips || IsMicroMips32r6) {
     Result = readInstruction16(Bytes, Address, Size, Insn, IsBigEndian);
 
     DEBUG(dbgs() << "Trying MicroMips16 table (16-bit instructions):\n");
@@ -837,10 +839,17 @@
     if (Result == MCDisassembler::Fail)
       return MCDisassembler::Fail;
 
-    DEBUG(dbgs() << "Trying MicroMips32 table (32-bit instructions):\n");
-    // Calling the auto-generated decoder function.
-    Result = decodeInstruction(DecoderTableMicroMips32, Instr, Insn, Address,
-                               this, STI);
+    if (IsMicroMips) {
+      DEBUG(dbgs() << "Trying MicroMips32 table (32-bit instructions):\n");
+      // Calling the auto-generated decoder function.
+      Result = decodeInstruction(DecoderTableMicroMips32, Instr, Insn, Address,
+                                 this, STI);
+    } else {
+      DEBUG(dbgs() << "Trying MicroMips32r632 table (32-bit instructions):\n");
+      // Calling the auto-generated decoder function.
+      Result = decodeInstruction(DecoderTableMicroMips32r632, Instr, Insn, Address,
+                                 this, STI);
+    }
     if (Result != MCDisassembler::Fail) {
       Size = 4;
       return Result;
Index: lib/Target/Mips/MicroMipsR6InstrInfo.td
===================================================================
--- lib/Target/Mips/MicroMipsR6InstrInfo.td
+++ lib/Target/Mips/MicroMipsR6InstrInfo.td
@@ -96,11 +96,13 @@
 //
 //===----------------------------------------------------------------------===//
 
+let DecoderNamespace = "MicroMips32r6" in {
 def ALUIPC_MMR6 : MMR6Rel, ALUIPC_MMR6_ENC, ALUIPC_MMR6_DESC, ISA_MICROMIPSR6;
 def AUIPC_MMR6 : MMR6Rel, AUIPC_MMR6_ENC, AUIPC_MMR6_DESC, ISA_MICROMIPSR6;
 def ADDIUPC_MMR6 : MMR6Rel, ADDIUPC_MMR6_ENC, ADDIUPC_MMR6_DESC, ISA_MICROMIPSR6;
 def BALC_MMR6 : MMR6Rel, BALC_MMR6_ENC, BALC_MMR6_DESC, ISA_MICROMIPSR6;
 def BC_MMR6 : MMR6Rel, BC_MMR6_ENC, BC_MMR6_DESC, ISA_MICROMIPSR6;
 def JIALC_MMR6 : MMR6Rel, JIALC_MMR6_ENC, JIALC_MMR6_DESC, ISA_MICROMIPSR6;
 def JIC_MMR6 : MMR6Rel, JIC_MMR6_ENC, JIC_MMR6_DESC, ISA_MICROMIPSR6;
 def LWPC_MMR6 : MMR6Rel, LWPC_MMR6_ENC, LWPC_MMR6_DESC, ISA_MICROMIPSR6;
+}

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8490.22369.patch
Type: text/x-patch
Size: 3006 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150320/05a1dcc1/attachment.bin>


More information about the llvm-commits mailing list