]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gas/config/tc-sh.c
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / gas / config / tc-sh.c
index c57f0661344baeee6b1efd3bbf78e663c908a072..78c3fca955a939b52ecf22edd89877fb5c7d46fe 100644 (file)
@@ -1,5 +1,5 @@
 /* tc-sh.c -- Assemble code for the Renesas / SuperH SH
-   Copyright (C) 1993-2019 Free Software Foundation, Inc.
+   Copyright (C) 1993-2024 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -240,7 +240,7 @@ const relax_typeS md_relax_table[C (END, 0)] = {
 
 #undef EMPTY
 
-static struct hash_control *opcode_hash_control;       /* Opcode mnemonics */
+static htab_t opcode_hash_control;     /* Opcode mnemonics */
 
 \f
 #ifdef OBJ_ELF
@@ -461,7 +461,7 @@ sh_elf_cons (int nbytes)
 /* The regular frag_offset_fixed_p doesn't work for rs_align_test
    frags.  */
 
-static bfd_boolean
+static bool
 align_test_frag_offset_fixed_p (const fragS *frag1, const fragS *frag2,
                                bfd_vma *offset)
 {
@@ -474,7 +474,7 @@ align_test_frag_offset_fixed_p (const fragS *frag1, const fragS *frag2,
   if (frag1 == frag2)
     {
       *offset = off;
-      return TRUE;
+      return true;
     }
 
   /* Maybe frag2 is after frag1.  */
@@ -492,7 +492,7 @@ align_test_frag_offset_fixed_p (const fragS *frag1, const fragS *frag2,
       if (frag == frag2)
        {
          *offset = off;
-         return TRUE;
+         return true;
        }
     }
 
@@ -512,11 +512,11 @@ align_test_frag_offset_fixed_p (const fragS *frag1, const fragS *frag2,
       if (frag == frag1)
        {
          *offset = off;
-         return TRUE;
+         return true;
        }
     }
 
-  return FALSE;
+  return false;
 }
 
 /* Optimize a difference of symbols which have rs_align_test frag if
@@ -564,7 +564,7 @@ md_begin (void)
     = preset_target_arch ? preset_target_arch : arch_sh_up & ~arch_sh_has_dsp;
   valid_arch = target_arch;
 
-  opcode_hash_control = hash_new ();
+  opcode_hash_control = str_htab_create ();
 
   /* Insert unique names into hash table.  */
   for (opcode = sh_table; opcode->name; opcode++)
@@ -574,7 +574,7 @@ md_begin (void)
          if (!SH_MERGE_ARCH_SET_VALID (opcode->arch, target_arch))
            continue;
          prev_name = opcode->name;
-         hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
+         str_hash_insert (opcode_hash_control, opcode->name, opcode, 0);
        }
     }
 }
@@ -1222,6 +1222,10 @@ static char *
 get_operands (sh_opcode_info *info, char *args, sh_operand_info *operand)
 {
   char *ptr = args;
+
+  operand[0].type = 0;
+  operand[1].type = 0;
+  operand[2].type = 0;
   if (info->arg[0])
     {
       /* The pre-processor will eliminate whitespace in front of '@'
@@ -1234,9 +1238,7 @@ get_operands (sh_opcode_info *info, char *args, sh_operand_info *operand)
       if (info->arg[1])
        {
          if (*ptr == ',')
-           {
-             ptr++;
-           }
+           ptr++;
          get_operand (&ptr, operand + 1);
          /* ??? Hack: psha/pshl have a varying operand number depending on
             the type of the first operand.  We handle this by having the
@@ -1247,28 +1249,11 @@ get_operands (sh_opcode_info *info, char *args, sh_operand_info *operand)
          if (info->arg[2] && operand[0].type != A_IMM)
            {
              if (*ptr == ',')
-               {
-                 ptr++;
-               }
+               ptr++;
              get_operand (&ptr, operand + 2);
            }
-         else
-           {
-             operand[2].type = 0;
-           }
-       }
-      else
-       {
-         operand[1].type = 0;
-         operand[2].type = 0;
        }
     }
-  else
-    {
-      operand[0].type = 0;
-      operand[1].type = 0;
-      operand[2].type = 0;
-    }
   return ptr;
 }
 
@@ -1920,7 +1905,7 @@ insert_loop_bounds (char *output, sh_operand_info *operand)
       /* A REPEAT takes 6 bytes.  The SH has a 32 bit address space.
         Hence a 9 digit number should be enough to count all REPEATs.  */
       sprintf (name, "_R%x", count++ & 0x3fffffff);
-      end_sym = symbol_new (name, undefined_section, 0, &zero_address_frag);
+      end_sym = symbol_new (name, undefined_section, &zero_address_frag, 0);
       /* Make this a local symbol.  */
 #ifdef OBJ_COFF
       SF_SET_LOCAL (end_sym);
@@ -2091,7 +2076,8 @@ build_Mytes (sh_opcode_info *opcode, sh_operand_info *operand)
            case IMM0_8BY2:
              insert (output + low_byte, BFD_RELOC_SH_IMM8BY2, 0, operand);
              break;
-           case IMM0_8:
+           case IMM0_8U:
+           case IMM0_8S:
              insert (output + low_byte, BFD_RELOC_SH_IMM8, 0, operand);
              break;
            case IMM1_8BY4:
@@ -2195,7 +2181,7 @@ find_cooked_opcode (char **str_p)
   if (nlen == 0)
     as_bad (_("can't find opcode "));
 
-  return (sh_opcode_info *) hash_find (opcode_hash_control, name);
+  return (sh_opcode_info *) str_hash_find (opcode_hash_control, name);
 }
 
 /* Assemble a parallel processing insn.  */
@@ -2204,12 +2190,12 @@ find_cooked_opcode (char **str_p)
 static unsigned int
 assemble_ppi (char *op_end, sh_opcode_info *opcode)
 {
-  int movx = 0;
-  int movy = 0;
-  int cond = 0;
-  int field_b = 0;
+  unsigned int movx = 0;
+  unsigned int movy = 0;
+  unsigned int cond = 0;
+  unsigned int field_b = 0;
   char *output;
-  int move_code;
+  unsigned int move_code;
   unsigned int size;
 
   for (;;)
@@ -2463,7 +2449,7 @@ assemble_ppi (char *op_end, sh_opcode_info *opcode)
   if (field_b)
     {
       /* Parallel processing insn.  */
-      unsigned long ppi_code = (movx | movy | 0xf800) << 16 | field_b;
+      unsigned int ppi_code = (movx | movy | 0xf800) << 16 | field_b;
 
       output = frag_more (4);
       size = 4;
@@ -2525,7 +2511,7 @@ md_assemble (char *str)
       char *name = initial_str;
       int name_length = 0;
       const sh_opcode_info *op;
-      bfd_boolean found = FALSE;
+      bool found = false;
 
       /* Identify opcode in string.  */
       while (ISSPACE (*name))
@@ -2540,7 +2526,7 @@ md_assemble (char *str)
          if (strncasecmp (op->name, name, name_length) == 0
              && op->name[name_length] == '\0')
            {
-             found = TRUE;
+             found = true;
              break;
            }
        }
@@ -2823,7 +2809,7 @@ md_parse_option (int c, const char *arg ATTRIBUTE_UNUSED)
 
 #ifdef OBJ_ELF
     case OPTION_FDPIC:
-      sh_fdpic = TRUE;
+      sh_fdpic = true;
       break;
 #endif /* OBJ_ELF */
 
@@ -3080,7 +3066,7 @@ md_convert_frag (bfd *headers ATTRIBUTE_UNUSED, segT seg, fragS *fragP)
         differently from ones without delay slots.  */
       {
        unsigned char *buffer =
-         (unsigned char *) (fragP->fr_fix + fragP->fr_literal);
+         (unsigned char *) (fragP->fr_fix + &fragP->fr_literal[0]);
        int highbyte = target_big_endian ? 0 : 1;
        int lowbyte = target_big_endian ? 1 : 0;
        int delay = fragP->fr_subtype == C (COND_JUMP_DELAY, COND12);
@@ -3277,7 +3263,7 @@ sh_handle_align (fragS *frag)
 
 /* See whether the relocation should be resolved locally.  */
 
-static bfd_boolean
+static bool
 sh_local_pcrel (fixS *fix)
 {
   return (! sh_relax
@@ -3326,7 +3312,7 @@ sh_force_relocation (fixS *fix)
 }
 
 #ifdef OBJ_ELF
-bfd_boolean
+bool
 sh_fix_adjustable (fixS *fixP)
 {
   if (fixP->fx_r_type == BFD_RELOC_32_PLT_PCREL