print_insn_powerpc tidy
* ppc-dis.c (print_insn_powerpc): Use a tiny state machine op_separator to control printing of spaces, comma and parens rather than need_comma, need_paren and spaces vars.
This commit is contained in:
parent
dffaa15c48
commit
e392bad3ec
@ -1,3 +1,9 @@
|
|||||||
|
2019-04-07 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* ppc-dis.c (print_insn_powerpc): Use a tiny state machine
|
||||||
|
op_separator to control printing of spaces, comma and parens
|
||||||
|
rather than need_comma, need_paren and spaces vars.
|
||||||
|
|
||||||
2019-04-07 Alan Modra <amodra@gmail.com>
|
2019-04-07 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
PR 24421
|
PR 24421
|
||||||
|
@ -720,8 +720,17 @@ print_insn_powerpc (bfd_vma memaddr,
|
|||||||
{
|
{
|
||||||
const unsigned char *opindex;
|
const unsigned char *opindex;
|
||||||
const struct powerpc_operand *operand;
|
const struct powerpc_operand *operand;
|
||||||
int need_comma;
|
enum {
|
||||||
int need_paren;
|
need_comma = 0,
|
||||||
|
need_1space = 1,
|
||||||
|
need_2spaces = 2,
|
||||||
|
need_3spaces = 3,
|
||||||
|
need_4spaces = 4,
|
||||||
|
need_5spaces = 5,
|
||||||
|
need_6spaces = 6,
|
||||||
|
need_7spaces = 7,
|
||||||
|
need_paren
|
||||||
|
} op_separator;
|
||||||
int skip_optional;
|
int skip_optional;
|
||||||
int spaces;
|
int spaces;
|
||||||
|
|
||||||
@ -732,8 +741,7 @@ print_insn_powerpc (bfd_vma memaddr,
|
|||||||
spaces = 1;
|
spaces = 1;
|
||||||
|
|
||||||
/* Now extract and print the operands. */
|
/* Now extract and print the operands. */
|
||||||
need_comma = 0;
|
op_separator = spaces;
|
||||||
need_paren = 0;
|
|
||||||
skip_optional = -1;
|
skip_optional = -1;
|
||||||
for (opindex = opcode->operands; *opindex != 0; opindex++)
|
for (opindex = opcode->operands; *opindex != 0; opindex++)
|
||||||
{
|
{
|
||||||
@ -754,16 +762,12 @@ print_insn_powerpc (bfd_vma memaddr,
|
|||||||
|
|
||||||
value = operand_value_powerpc (operand, insn, dialect);
|
value = operand_value_powerpc (operand, insn, dialect);
|
||||||
|
|
||||||
if (spaces)
|
if (op_separator == need_comma)
|
||||||
{
|
(*info->fprintf_func) (info->stream, ",");
|
||||||
(*info->fprintf_func) (info->stream, "%*s", spaces, " ");
|
else if (op_separator == need_paren)
|
||||||
spaces = 0;
|
(*info->fprintf_func) (info->stream, "(");
|
||||||
}
|
else
|
||||||
if (need_comma)
|
(*info->fprintf_func) (info->stream, "%*s", op_separator, " ");
|
||||||
{
|
|
||||||
(*info->fprintf_func) (info->stream, ",");
|
|
||||||
need_comma = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Print the operand as directed by the flags. */
|
/* Print the operand as directed by the flags. */
|
||||||
if ((operand->flags & PPC_OPERAND_GPR) != 0
|
if ((operand->flags & PPC_OPERAND_GPR) != 0
|
||||||
@ -808,19 +812,12 @@ print_insn_powerpc (bfd_vma memaddr,
|
|||||||
else
|
else
|
||||||
(*info->fprintf_func) (info->stream, "%" PRId64, value);
|
(*info->fprintf_func) (info->stream, "%" PRId64, value);
|
||||||
|
|
||||||
if (need_paren)
|
if (op_separator == need_paren)
|
||||||
{
|
(*info->fprintf_func) (info->stream, ")");
|
||||||
(*info->fprintf_func) (info->stream, ")");
|
|
||||||
need_paren = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((operand->flags & PPC_OPERAND_PARENS) == 0)
|
op_separator = need_comma;
|
||||||
need_comma = 1;
|
if ((operand->flags & PPC_OPERAND_PARENS) != 0)
|
||||||
else
|
op_separator = need_paren;
|
||||||
{
|
|
||||||
(*info->fprintf_func) (info->stream, "(");
|
|
||||||
need_paren = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We have found and printed an instruction. */
|
/* We have found and printed an instruction. */
|
||||||
|
Loading…
Reference in New Issue
Block a user