Rearrange symbol_create parameters
[deliverable/binutils-gdb.git] / gas / config / tc-csky.c
index e90ebc2d88d3ab49dc5e69ddf9a5d63b44c43852..ec1ea944a0fb4d0fe907b8a0c37f0475a58aa97b 100644 (file)
@@ -272,6 +272,7 @@ struct csky_insn_info
   struct csky_macro_info *macro;
   /* Insn size for check_literal.  */
   unsigned int isize;
+  unsigned int last_isize;
   /* Max size of insn for relax frag_var.  */
   unsigned int max;
   /* Indicates which element is in csky_opcode_info op[] array.  */
@@ -754,8 +755,8 @@ size_t md_longopts_size = sizeof (md_longopts);
 
 static struct csky_insn_info csky_insn;
 
-static struct hash_control *csky_opcodes_hash;
-static struct hash_control *csky_macros_hash;
+static htab_t csky_opcodes_hash;
+static htab_t csky_macros_hash;
 
 static struct csky_macro_info v1_macros_table[] =
 {
@@ -1356,16 +1357,16 @@ md_begin (void)
     }
 
   /* Establish hash table for opcodes and macros.  */
-  csky_macros_hash = hash_new ();
-  csky_opcodes_hash = hash_new ();
+  csky_macros_hash = str_htab_create ();
+  csky_opcodes_hash = str_htab_create ();
   for ( ; opcode->mnemonic != NULL; opcode++)
     if ((isa_flag & (opcode->isa_flag16 | opcode->isa_flag32)) != 0)
-      hash_insert (csky_opcodes_hash, opcode->mnemonic, (char *)opcode);
+      str_hash_insert (csky_opcodes_hash, opcode->mnemonic, (char *)opcode);
   for ( ; macro->name != NULL; macro++)
     if ((isa_flag & macro->isa_flag) != 0)
-      hash_insert (csky_macros_hash, macro->name, (char *)macro);
+      str_hash_insert (csky_macros_hash, macro->name, (char *)macro);
   if (do_nolrw && (isa_flag & CSKYV2_ISA_1E2) != 0)
-    hash_insert (csky_macros_hash,
+    str_hash_insert (csky_macros_hash,
                 v2_lrw_macro_opcode.name,
                 (char *)&v2_lrw_macro_opcode);
   /* Set e_flag to ELF Head.  */
@@ -1398,7 +1399,7 @@ make_mapping_symbol (map_state state, valueT value, fragS *frag)
       abort ();
     }
 
-  symbolP = symbol_new (symname, now_seg, value, frag);
+  symbolP = symbol_new (symname, now_seg, frag, value);
   symbol_get_bfdsym (symbolP)->flags |= type | BSF_LOCAL;
 }
 
@@ -2933,9 +2934,9 @@ parse_opcode (char *str)
   csky_insn.number = csky_count_operands (opcode_end);
 
   /* Find hash by name in csky_macros_hash and csky_opcodes_hash.  */
-  csky_insn.macro = (struct csky_macro_info *) hash_find (csky_macros_hash,
+  csky_insn.macro = (struct csky_macro_info *) str_hash_find (csky_macros_hash,
                                                          macro_name);
-  csky_insn.opcode = (struct csky_opcode *) hash_find (csky_opcodes_hash,
+  csky_insn.opcode = (struct csky_opcode *) str_hash_find (csky_opcodes_hash,
                                                        name);
 
   if (csky_insn.macro == NULL && csky_insn.opcode == NULL)
@@ -3157,7 +3158,7 @@ get_operand_value (struct csky_opcode_info *op,
            {
              const char *name = "movi";
              csky_insn.opcode = (struct csky_opcode *)
-               hash_find (csky_opcodes_hash, name);
+               str_hash_find (csky_opcodes_hash, name);
              csky_insn.val[csky_insn.idx - 1] = 1 << val;
            }
          return TRUE;
@@ -3191,7 +3192,7 @@ get_operand_value (struct csky_opcode_info *op,
              {
                const char *name = "movi";
                csky_insn.opcode = (struct csky_opcode *)
-                 hash_find (csky_opcodes_hash, name);
+                 str_hash_find (csky_opcodes_hash, name);
                as_warn (_("translating mgeni to movi"));
              }
            else
@@ -3225,7 +3226,7 @@ get_operand_value (struct csky_opcode_info *op,
            {
              const char *op_movi = "movi";
              csky_insn.opcode = (struct csky_opcode *)
-               hash_find (csky_opcodes_hash, op_movi);
+               str_hash_find (csky_opcodes_hash, op_movi);
              if (csky_insn.opcode == NULL)
                return FALSE;
              csky_insn.val[csky_insn.idx - 1] = (1 << mask_val) - 1;
@@ -3275,7 +3276,7 @@ get_operand_value (struct csky_opcode_info *op,
            {
              const char *op_movi = "movi";
              csky_insn.opcode = (struct csky_opcode *)
-               hash_find (csky_opcodes_hash, op_movi);
+               str_hash_find (csky_opcodes_hash, op_movi);
              if (csky_insn.opcode == NULL)
                return FALSE;
              csky_insn.val[csky_insn.idx - 1] = (1 << (mask_val + 1)) - 1;
@@ -4145,6 +4146,7 @@ md_assemble (char *str)
        check_literals (csky_insn.opcode->transfer, csky_insn.max);
     }
 
+  csky_insn.last_isize = csky_insn.isize;
   insn_reloc = BFD_RELOC_NONE;
 }
 
@@ -5955,7 +5957,7 @@ v1_work_jbsr (void)
       /* Using jsri instruction.  */
       const char *name = "jsri";
       csky_insn.opcode = (struct csky_opcode *)
-       hash_find (csky_opcodes_hash, name);
+       str_hash_find (csky_opcodes_hash, name);
       csky_insn.opcode_idx = 0;
       csky_insn.isize = 2;
 
@@ -6293,7 +6295,7 @@ v2_work_rotlc (void)
 {
   const char *name = "addc";
   csky_insn.opcode
-    = (struct csky_opcode *) hash_find (csky_opcodes_hash, name);
+    = (struct csky_opcode *) str_hash_find (csky_opcodes_hash, name);
   csky_insn.opcode_idx = 0;
   if (csky_insn.isize == 2)
     {
@@ -6331,7 +6333,7 @@ v2_work_bgeni (void)
       val >>= 16;
     }
   csky_insn.opcode
-    = (struct csky_opcode *) hash_find (csky_opcodes_hash, name);
+    = (struct csky_opcode *) str_hash_find (csky_opcodes_hash, name);
   csky_insn.opcode_idx = 0;
   csky_insn.val[1] = val;
 
@@ -6349,7 +6351,7 @@ v2_work_not (void)
 {
   const char *name = "nor";
   csky_insn.opcode
-    = (struct csky_opcode *) hash_find (csky_opcodes_hash, name);
+    = (struct csky_opcode *) str_hash_find (csky_opcodes_hash, name);
   csky_insn.opcode_idx = 0;
   if (csky_insn.number == 1)
     {
@@ -6900,7 +6902,8 @@ dsp_work_bloop (void)
   csky_insn.inst = csky_insn.opcode->op32[0].opcode | (reg << 16);
   csky_insn.isize = 4;
 
-  if (csky_insn.e1.X_op == O_symbol
+  if (csky_insn.number == 3
+      && csky_insn.e1.X_op == O_symbol
       && csky_insn.e2.X_op == O_symbol)
     {
        fix_new_exp (frag_now, csky_insn.output - frag_now->fr_literal,
@@ -6910,6 +6913,23 @@ dsp_work_bloop (void)
                     4, &csky_insn.e2, 1,
                     BFD_RELOC_CKCORE_PCREL_BLOOP_IMM4BY4);
     }
+  else if (csky_insn.number == 2
+          && csky_insn.e1.X_op == O_symbol)
+    {
+      fix_new_exp (frag_now, csky_insn.output-frag_now->fr_literal,
+                  4, &csky_insn.e1, 1,
+                  BFD_RELOC_CKCORE_PCREL_BLOOP_IMM12BY4);
+      if (csky_insn.last_isize == 2)
+       csky_insn.inst |= (0xf << 12);
+      else if (csky_insn.last_isize != 0)
+       csky_insn.inst |= (0xe << 12);
+      else
+       {
+         void *arg = (void *)"bloop can not be the first instruction"\
+                     "when the end label is not specified.\n";
+         csky_show_error (ERROR_UNDEFINE, 0, arg, NULL);
+       }
+    }
 
   csky_write_insn (csky_insn.output, csky_insn.inst, csky_insn.isize);
   return TRUE;
This page took 0.02689 seconds and 4 git commands to generate.