This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]