mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-26 13:56:22 +08:00
opcodes/arc: Implement style support in the disassembler
Update the ARC disassembler to supply style information to the disassembler output. The output formatting remains unchanged. opcodes/ChangeLog: * disassemble.c (disassemble_init_for_target): Set created_styled_output for ARC based targets. * arc-dis.c (find_format_from_table): Use fprintf_styled_ftype instead of fprintf_ftype throughout. (find_format): Likewise. (print_flags): Likewise. (print_insn_arc): Likewise. Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
This commit is contained in:
@ -1,3 +1,13 @@
|
|||||||
|
2022-07-18 Claudiu Zissulescu <claziss@synopsys.com>
|
||||||
|
|
||||||
|
* disassemble.c (disassemble_init_for_target): Set
|
||||||
|
created_styled_output for ARC based targets.
|
||||||
|
* arc-dis.c (find_format_from_table): Use fprintf_styled_ftype
|
||||||
|
instead of fprintf_ftype throughout.
|
||||||
|
(find_format): Likewise.
|
||||||
|
(print_flags): Likewise.
|
||||||
|
(print_insn_arc): Likewise.
|
||||||
|
|
||||||
2022-07-08 Nick Clifton <nickc@redhat.com>
|
2022-07-08 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
* 2.39 branch created.
|
* 2.39 branch created.
|
||||||
|
@ -375,7 +375,8 @@ find_format_from_table (struct disassemble_info *info,
|
|||||||
|
|
||||||
if (warn_p)
|
if (warn_p)
|
||||||
{
|
{
|
||||||
info->fprintf_func (info->stream,
|
info->fprintf_styled_func
|
||||||
|
(info->stream, dis_style_text,
|
||||||
_("\nWarning: disassembly may be wrong due to "
|
_("\nWarning: disassembly may be wrong due to "
|
||||||
"guessed opcode class choice.\n"
|
"guessed opcode class choice.\n"
|
||||||
"Use -M<class[,class]> to select the correct "
|
"Use -M<class[,class]> to select the correct "
|
||||||
@ -436,9 +437,10 @@ find_format (bfd_vma memaddr,
|
|||||||
opcode = arcExtMap_genOpcode (i, isa_mask, &errmsg);
|
opcode = arcExtMap_genOpcode (i, isa_mask, &errmsg);
|
||||||
if (opcode == NULL)
|
if (opcode == NULL)
|
||||||
{
|
{
|
||||||
(*info->fprintf_func) (info->stream,
|
(*info->fprintf_styled_func)
|
||||||
_("An error occurred while generating the "
|
(info->stream, dis_style_text,
|
||||||
"extension instruction operations"));
|
_("An error occurred while generating "
|
||||||
|
"the extension instruction operations"));
|
||||||
*opcode_result = NULL;
|
*opcode_result = NULL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -514,7 +516,8 @@ print_flags (const struct arc_opcode *opcode,
|
|||||||
name = arcExtMap_condCodeName (value);
|
name = arcExtMap_condCodeName (value);
|
||||||
if (name)
|
if (name)
|
||||||
{
|
{
|
||||||
(*info->fprintf_func) (info->stream, ".%s", name);
|
(*info->fprintf_styled_func) (info->stream, dis_style_mnemonic,
|
||||||
|
".%s", name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -545,7 +548,8 @@ print_flags (const struct arc_opcode *opcode,
|
|||||||
{
|
{
|
||||||
/* FIXME!: print correctly nt/t flag. */
|
/* FIXME!: print correctly nt/t flag. */
|
||||||
if (!special_flag_p (opcode->name, flg_operand->name))
|
if (!special_flag_p (opcode->name, flg_operand->name))
|
||||||
(*info->fprintf_func) (info->stream, ".");
|
(*info->fprintf_styled_func) (info->stream,
|
||||||
|
dis_style_mnemonic, ".");
|
||||||
else if (info->insn_type == dis_dref)
|
else if (info->insn_type == dis_dref)
|
||||||
{
|
{
|
||||||
switch (flg_operand->name[0])
|
switch (flg_operand->name[0])
|
||||||
@ -580,7 +584,8 @@ print_flags (const struct arc_opcode *opcode,
|
|||||||
if (cl_flags->flag_class & F_CLASS_WB)
|
if (cl_flags->flag_class & F_CLASS_WB)
|
||||||
arc_infop->writeback_mode = flg_operand->code;
|
arc_infop->writeback_mode = flg_operand->code;
|
||||||
|
|
||||||
(*info->fprintf_func) (info->stream, "%s", flg_operand->name);
|
(*info->fprintf_styled_func) (info->stream, dis_style_mnemonic,
|
||||||
|
"%s", flg_operand->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1061,13 +1066,28 @@ print_insn_arc (bfd_vma memaddr,
|
|||||||
switch (size)
|
switch (size)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
(*info->fprintf_func) (info->stream, ".byte\t0x%02lx", data);
|
(*info->fprintf_styled_func) (info->stream,
|
||||||
|
dis_style_assembler_directive,
|
||||||
|
".byte");
|
||||||
|
(*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
|
||||||
|
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
|
||||||
|
"0x%02lx", data);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
(*info->fprintf_func) (info->stream, ".short\t0x%04lx", data);
|
(*info->fprintf_styled_func) (info->stream,
|
||||||
|
dis_style_assembler_directive,
|
||||||
|
".short");
|
||||||
|
(*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
|
||||||
|
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
|
||||||
|
"0x%04lx", data);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
(*info->fprintf_func) (info->stream, ".word\t0x%08lx", data);
|
(*info->fprintf_styled_func) (info->stream,
|
||||||
|
dis_style_assembler_directive,
|
||||||
|
".word");
|
||||||
|
(*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
|
||||||
|
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
|
||||||
|
"0x%08lx", data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
@ -1157,27 +1177,45 @@ print_insn_arc (bfd_vma memaddr,
|
|||||||
switch (insn_len)
|
switch (insn_len)
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
(*info->fprintf_func) (info->stream, ".shor\t%#04llx",
|
(*info->fprintf_styled_func) (info->stream,
|
||||||
insn & 0xffff);
|
dis_style_assembler_directive,
|
||||||
|
".short");
|
||||||
|
(*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
|
||||||
|
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
|
||||||
|
"0x%04llx", insn & 0xffff);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
(*info->fprintf_func) (info->stream, ".word\t%#08llx",
|
(*info->fprintf_styled_func) (info->stream,
|
||||||
insn & 0xffffffff);
|
dis_style_assembler_directive,
|
||||||
|
".word");
|
||||||
|
(*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
|
||||||
|
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
|
||||||
|
"0x%08llx", insn & 0xffffffff);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
(*info->fprintf_func) (info->stream, ".long\t%#08llx",
|
(*info->fprintf_styled_func) (info->stream,
|
||||||
insn & 0xffffffff);
|
dis_style_assembler_directive,
|
||||||
(*info->fprintf_func) (info->stream, ".long\t%#04llx",
|
".long");
|
||||||
(insn >> 32) & 0xffff);
|
(*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
|
||||||
|
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
|
||||||
|
"0x%08llx", insn & 0xffffffff);
|
||||||
|
(*info->fprintf_styled_func) (info->stream, dis_style_text, " ");
|
||||||
|
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
|
||||||
|
"0x%04llx", (insn >> 32) & 0xffff);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
(*info->fprintf_func) (info->stream, ".long\t%#08llx",
|
(*info->fprintf_styled_func) (info->stream,
|
||||||
insn & 0xffffffff);
|
dis_style_assembler_directive,
|
||||||
(*info->fprintf_func) (info->stream, ".long\t%#08llx",
|
".long");
|
||||||
insn >> 32);
|
(*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
|
||||||
|
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
|
||||||
|
"0x%08llx", insn & 0xffffffff);
|
||||||
|
(*info->fprintf_styled_func) (info->stream, dis_style_text, " ");
|
||||||
|
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
|
||||||
|
"0x%08llx", (insn >> 32));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1189,7 +1227,8 @@ print_insn_arc (bfd_vma memaddr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Print the mnemonic. */
|
/* Print the mnemonic. */
|
||||||
(*info->fprintf_func) (info->stream, "%s", opcode->name);
|
(*info->fprintf_styled_func) (info->stream, dis_style_mnemonic,
|
||||||
|
"%s", opcode->name);
|
||||||
|
|
||||||
/* Preselect the insn class. */
|
/* Preselect the insn class. */
|
||||||
info->insn_type = arc_opcode_to_insn_type (opcode);
|
info->insn_type = arc_opcode_to_insn_type (opcode);
|
||||||
@ -1199,7 +1238,7 @@ print_insn_arc (bfd_vma memaddr,
|
|||||||
print_flags (opcode, &insn, info);
|
print_flags (opcode, &insn, info);
|
||||||
|
|
||||||
if (opcode->operands[0] != 0)
|
if (opcode->operands[0] != 0)
|
||||||
(*info->fprintf_func) (info->stream, "\t");
|
(*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
|
||||||
|
|
||||||
need_comma = false;
|
need_comma = false;
|
||||||
open_braket = false;
|
open_braket = false;
|
||||||
@ -1212,7 +1251,7 @@ print_insn_arc (bfd_vma memaddr,
|
|||||||
{
|
{
|
||||||
if (open_braket && (operand->flags & ARC_OPERAND_BRAKET))
|
if (open_braket && (operand->flags & ARC_OPERAND_BRAKET))
|
||||||
{
|
{
|
||||||
(*info->fprintf_func) (info->stream, "]");
|
(*info->fprintf_styled_func) (info->stream, dis_style_text, "]");
|
||||||
open_braket = false;
|
open_braket = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1228,16 +1267,16 @@ print_insn_arc (bfd_vma memaddr,
|
|||||||
|
|
||||||
if (operand->flags & ARC_OPERAND_COLON)
|
if (operand->flags & ARC_OPERAND_COLON)
|
||||||
{
|
{
|
||||||
(*info->fprintf_func) (info->stream, ":");
|
(*info->fprintf_styled_func) (info->stream, dis_style_text, ":");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (need_comma)
|
if (need_comma)
|
||||||
(*info->fprintf_func) (info->stream, ",");
|
(*info->fprintf_styled_func) (info->stream, dis_style_text,",");
|
||||||
|
|
||||||
if (!open_braket && (operand->flags & ARC_OPERAND_BRAKET))
|
if (!open_braket && (operand->flags & ARC_OPERAND_BRAKET))
|
||||||
{
|
{
|
||||||
(*info->fprintf_func) (info->stream, "[");
|
(*info->fprintf_styled_func) (info->stream, dis_style_text, "[");
|
||||||
open_braket = true;
|
open_braket = true;
|
||||||
need_comma = false;
|
need_comma = false;
|
||||||
continue;
|
continue;
|
||||||
@ -1268,7 +1307,8 @@ print_insn_arc (bfd_vma memaddr,
|
|||||||
rname = arcExtMap_coreRegName (value);
|
rname = arcExtMap_coreRegName (value);
|
||||||
if (!rname)
|
if (!rname)
|
||||||
rname = regnames[value];
|
rname = regnames[value];
|
||||||
(*info->fprintf_func) (info->stream, "%s", rname);
|
(*info->fprintf_styled_func) (info->stream, dis_style_register,
|
||||||
|
"%s", rname);
|
||||||
|
|
||||||
/* Check if we have a double register to print. */
|
/* Check if we have a double register to print. */
|
||||||
if (operand->flags & ARC_OPERAND_TRUNCATE)
|
if (operand->flags & ARC_OPERAND_TRUNCATE)
|
||||||
@ -1282,7 +1322,8 @@ print_insn_arc (bfd_vma memaddr,
|
|||||||
else
|
else
|
||||||
rname = _("\nWarning: illegal use of double register "
|
rname = _("\nWarning: illegal use of double register "
|
||||||
"pair.\n");
|
"pair.\n");
|
||||||
(*info->fprintf_func) (info->stream, "%s", rname);
|
(*info->fprintf_styled_func) (info->stream, dis_style_register,
|
||||||
|
"%s", rname);
|
||||||
}
|
}
|
||||||
if (value == 63)
|
if (value == 63)
|
||||||
rpcl = true;
|
rpcl = true;
|
||||||
@ -1294,10 +1335,12 @@ print_insn_arc (bfd_vma memaddr,
|
|||||||
const char *rname = get_auxreg (opcode, value, isa_mask);
|
const char *rname = get_auxreg (opcode, value, isa_mask);
|
||||||
|
|
||||||
if (rname && open_braket)
|
if (rname && open_braket)
|
||||||
(*info->fprintf_func) (info->stream, "%s", rname);
|
(*info->fprintf_styled_func) (info->stream, dis_style_register,
|
||||||
|
"%s", rname);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
(*info->fprintf_func) (info->stream, "%#x", value);
|
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
|
||||||
|
"%#x", value);
|
||||||
if (info->insn_type == dis_branch
|
if (info->insn_type == dis_branch
|
||||||
|| info->insn_type == dis_jsr)
|
|| info->insn_type == dis_jsr)
|
||||||
info->target = (bfd_vma) value;
|
info->target = (bfd_vma) value;
|
||||||
@ -1307,19 +1350,23 @@ print_insn_arc (bfd_vma memaddr,
|
|||||||
{
|
{
|
||||||
const char *rname = get_auxreg (opcode, value, isa_mask);
|
const char *rname = get_auxreg (opcode, value, isa_mask);
|
||||||
if (rname && open_braket)
|
if (rname && open_braket)
|
||||||
(*info->fprintf_func) (info->stream, "%s", rname);
|
(*info->fprintf_styled_func) (info->stream, dis_style_register,
|
||||||
|
"%s", rname);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (print_hex)
|
if (print_hex)
|
||||||
(*info->fprintf_func) (info->stream, "%#x", value);
|
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
|
||||||
|
"%#x", value);
|
||||||
else
|
else
|
||||||
(*info->fprintf_func) (info->stream, "%d", value);
|
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
|
||||||
|
"%d", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (operand->flags & ARC_OPERAND_ADDRTYPE)
|
else if (operand->flags & ARC_OPERAND_ADDRTYPE)
|
||||||
{
|
{
|
||||||
const char *addrtype = get_addrtype (value);
|
const char *addrtype = get_addrtype (value);
|
||||||
(*info->fprintf_func) (info->stream, "%s", addrtype);
|
(*info->fprintf_styled_func) (info->stream, dis_style_address,
|
||||||
|
"%s", addrtype);
|
||||||
/* A colon follow an address type. */
|
/* A colon follow an address type. */
|
||||||
need_comma = false;
|
need_comma = false;
|
||||||
}
|
}
|
||||||
@ -1337,10 +1384,16 @@ print_insn_arc (bfd_vma memaddr,
|
|||||||
need_comma = false;
|
need_comma = false;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
(*info->fprintf_func) (info->stream, "r13");
|
(*info->fprintf_styled_func) (info->stream,
|
||||||
|
dis_style_register, "r13");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
(*info->fprintf_func) (info->stream, "r13-%s",
|
(*info->fprintf_styled_func) (info->stream,
|
||||||
|
dis_style_register, "r13");
|
||||||
|
(*info->fprintf_styled_func) (info->stream,
|
||||||
|
dis_style_text, "-");
|
||||||
|
(*info->fprintf_styled_func) (info->stream,
|
||||||
|
dis_style_register, "%s",
|
||||||
regnames[13 + value - 1]);
|
regnames[13 + value - 1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1351,9 +1404,11 @@ print_insn_arc (bfd_vma memaddr,
|
|||||||
{
|
{
|
||||||
const char *rname = get_auxreg (opcode, value, isa_mask);
|
const char *rname = get_auxreg (opcode, value, isa_mask);
|
||||||
if (rname && open_braket)
|
if (rname && open_braket)
|
||||||
(*info->fprintf_func) (info->stream, "%s", rname);
|
(*info->fprintf_styled_func) (info->stream, dis_style_register,
|
||||||
|
"%s", rname);
|
||||||
else
|
else
|
||||||
(*info->fprintf_func) (info->stream, "%#x", value);
|
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
|
||||||
|
"%" PRIx32, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1387,7 +1442,8 @@ print_insn_arc (bfd_vma memaddr,
|
|||||||
the addend is not currently pc-relative. */
|
the addend is not currently pc-relative. */
|
||||||
memaddr = 0;
|
memaddr = 0;
|
||||||
|
|
||||||
(*info->fprintf_func) (info->stream, "\t;");
|
(*info->fprintf_styled_func) (info->stream,
|
||||||
|
dis_style_comment_start, "\t;");
|
||||||
(*info->print_address_func) ((memaddr & ~3) + vpcl, info);
|
(*info->print_address_func) ((memaddr & ~3) + vpcl, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,6 +612,11 @@ disassemble_init_for_target (struct disassemble_info * info)
|
|||||||
info->disassembler_needs_relocs = true;
|
info->disassembler_needs_relocs = true;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ARCH_arc
|
||||||
|
case bfd_arch_arc:
|
||||||
|
info->created_styled_output = true;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
#ifdef ARCH_arm
|
#ifdef ARCH_arm
|
||||||
case bfd_arch_arm:
|
case bfd_arch_arm:
|
||||||
info->symbol_is_valid = arm_symbol_is_valid;
|
info->symbol_is_valid = arm_symbol_is_valid;
|
||||||
|
Reference in New Issue
Block a user