gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / opcodes / sparc-dis.c
index bdf018d8952df62f7f6ebbbd2e5f01f15a4040c5..c9667f172b40226905a9642508611e4701a75809 100644 (file)
@@ -1,5 +1,5 @@
 /* Print SPARC instructions.
-   Copyright (C) 1989-2019 Free Software Foundation, Inc.
+   Copyright (C) 1989-2020 Free Software Foundation, Inc.
 
    This file is part of the GNU opcodes library.
 
@@ -63,8 +63,8 @@ static sparc_opcode_hash *opcode_hash_table[HASH_SIZE];
 
 /* Sign-extend a value which is N bits long.  */
 #define        SEX(value, bits) \
-       ((((int)(value)) << ((8 * sizeof (int)) - bits))        \
-                        >> ((8 * sizeof (int)) - bits) )
+  ((int) (((value & ((1u << (bits - 1) << 1) - 1))     \
+          ^ (1u << (bits - 1))) - (1u << (bits - 1))))
 
 static  char *reg_names[] =
 { "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
@@ -325,7 +325,7 @@ compare_opcodes (const void * a, const void * b)
      another, it is important to order the opcodes in the right order.  */
   for (i = 0; i < 32; ++i)
     {
-      unsigned long int x = 1 << i;
+      unsigned long int x = 1ul << i;
       int x0 = (match0 & x) != 0;
       int x1 = (match1 & x) != 0;
 
@@ -335,7 +335,7 @@ compare_opcodes (const void * a, const void * b)
 
   for (i = 0; i < 32; ++i)
     {
-      unsigned long int x = 1 << i;
+      unsigned long int x = 1ul << i;
       int x0 = (lose0 & x) != 0;
       int x1 = (lose1 & x) != 0;
 
@@ -441,8 +441,7 @@ build_hash_table (const sparc_opcode **opcode_table,
 
   memset (hash_table, 0, HASH_SIZE * sizeof (hash_table[0]));
   memset (hash_count, 0, HASH_SIZE * sizeof (hash_count[0]));
-  if (hash_buf != NULL)
-    free (hash_buf);
+  free (hash_buf);
   hash_buf = xmalloc (sizeof (* hash_buf) * num_opcodes);
   for (i = num_opcodes - 1; i >= 0; --i)
     {
@@ -712,8 +711,7 @@ print_insn_sparc (bfd_vma memaddr, disassemble_info *info)
 
                  case 'h':
                    (*info->fprintf_func) (stream, "%%hi(%#x)",
-                                          ((unsigned) 0xFFFFFFFF
-                                           & ((int) X_IMM22 (insn) << 10)));
+                                          (unsigned) X_IMM22 (insn) << 10);
                    break;
 
                  case 'i':     /* 13 bit immediate.  */
@@ -1062,9 +1060,7 @@ print_insn_sparc (bfd_vma memaddr, disassemble_info *info)
                      && X_RD (prev_insn) == X_RS1 (insn))
                    {
                      (*info->fprintf_func) (stream, "\t! ");
-                     info->target =
-                       ((unsigned) 0xFFFFFFFF
-                        & ((int) X_IMM22 (prev_insn) << 10));
+                     info->target = (unsigned) X_IMM22 (prev_insn) << 10;
                      if (imm_added_to_rs1)
                        info->target += X_SIMM (insn, 13);
                      else
This page took 0.037849 seconds and 4 git commands to generate.