/* 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.
#undef EMPTY
-static struct hash_control *opcode_hash_control; /* Opcode mnemonics */
+static htab_t opcode_hash_control; /* Opcode mnemonics */
\f
#ifdef OBJ_ELF
/* 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)
{
if (frag1 == frag2)
{
*offset = off;
- return TRUE;
+ return true;
}
/* Maybe frag2 is after frag1. */
if (frag == frag2)
{
*offset = off;
- return TRUE;
+ return true;
}
}
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
= 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++)
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);
}
}
}
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 '@'
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
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;
}
/* 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);
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:
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. */
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 (;;)
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;
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))
if (strncasecmp (op->name, name, name_length) == 0
&& op->name[name_length] == '\0')
{
- found = TRUE;
+ found = true;
break;
}
}
#ifdef OBJ_ELF
case OPTION_FDPIC:
- sh_fdpic = TRUE;
+ sh_fdpic = true;
break;
#endif /* OBJ_ELF */
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);
/* See whether the relocation should be resolved locally. */
-static bfd_boolean
+static bool
sh_local_pcrel (fixS *fix)
{
return (! sh_relax
}
#ifdef OBJ_ELF
-bfd_boolean
+bool
sh_fix_adjustable (fixS *fixP)
{
if (fixP->fx_r_type == BFD_RELOC_32_PLT_PCREL