[Patch opcodes] cleanup redundant code in cr16-dis.c

刘智猷 liuzhiyou.cs@gmail.com
Mon Dec 17 14:04:00 GMT 2012


Hi, all

I am looking into the implement of opcodes and I found

static unsigned long build_mask (void)
and
static int match_opcode (void) in opcodes/cr16-dis.c share same code

  /* Adjust mask for bcond with 32-bit size instruction.  */
  if ((IS_INSN_MNEMONIC("b") && instruction->size == 2))
    mask = 0xff0f0000;

I check around and confirm that the code in matc _opcode could be
safety removed. Patch (generate by git) is as following and it passes
all the testcases.

This is in fact a very simple patch. But I guess cleaning up is always
welcomed, isn't it?

BTW. I am not hanging on maillist a lot so if  anything is wrong
please pointing it out. Thank you!

Regards,
LIU Zhiyou

P.S. This is a resending. My last email (having the same content) does
not show up in the mail list archieve.

$ git diff
diff --git a/opcodes/cr16-dis.c b/opcodes/cr16-dis.c
index f299fef..e520ded 100644
--- a/opcodes/cr16-dis.c
+++ b/opcodes/cr16-dis.c
@@ -331,10 +331,7 @@ match_opcode (void)
   while (instruction >= cr16_instruction)
     {
       mask = build_mask ();
-      /* Adjust mask for bcond with 32-bit size instruction */
-      if ((IS_INSN_MNEMONIC("b") && instruction->size == 2))
-        mask = 0xff0f0000;
-
+
       if ((doubleWord & mask) == BIN (instruction->match,

         instruction->match_bits))
         return 1;



More information about the Binutils mailing list