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. */
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[] =
{
}
/* 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. */
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;
}
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)
{
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;
{
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
{
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;
{
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;
check_literals (csky_insn.opcode->transfer, csky_insn.max);
}
+ csky_insn.last_isize = csky_insn.isize;
insn_reloc = BFD_RELOC_NONE;
}
/* 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;
{
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)
{
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;
{
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)
{
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,
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;