Fix to operand name writing
Richard Kenner
kenner@vlsi1.ultra.nyu.edu
Sat Oct 20 04:32:00 GMT 2001
This fixes the bug when operand numbers are duplicated. It also cleans up
the code and allows operand to be written for each line of asm output.
Tested on alphaev56-dec-osf4.0c.
Sat Oct 20 07:27:14 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* final.c (output_asm_operand_names): New fcn, from output_asm_insn.
(output_asm_insn): Call it for each line output.
Don't record an operand more than once.
*** final.c 2001/10/19 19:22:20 1.211
--- final.c 2001/10/20 11:03:15
*************** static rtx walk_alter_subreg PARAMS ((rt
*** 246,249 ****
--- 246,250 ----
static void output_asm_name PARAMS ((void));
static tree get_decl_from_op PARAMS ((rtx, int *));
+ static void output_asm_operand_names PARAMS ((rtx *, int *, int));
static void output_operand PARAMS ((rtx, int));
#ifdef LEAF_REGISTERS
*************** get_decl_from_op (op, paddressp)
*** 3333,3336 ****
--- 3334,3365 ----
}
+ /* Output operand names for assembler instructions. OPERANDS is the
+ operand vector, OPORDER is the order to write the operands, and NOPS
+ is the number of operands to write. */
+
+ static void
+ output_asm_operand_names (operands, oporder, nops)
+ rtx *operands;
+ int *oporder;
+ int nops;
+ {
+ int wrote = 0;
+ int i;
+
+ for (i = 0; i < nops; i++)
+ {
+ int addressp;
+ tree decl = get_decl_from_op (operands[oporder[i]], &addressp);
+
+ if (decl && DECL_NAME (decl))
+ {
+ fprintf (asm_out_file, "%s %s%s",
+ wrote ? "," : ASM_COMMENT_START, addressp ? "*" : "",
+ IDENTIFIER_POINTER (DECL_NAME (decl)));
+ wrote = 1;
+ }
+ }
+ }
+
/* Output text from TEMPLATE to the assembler output file,
obeying %-directions to substitute operands taken from
*************** output_asm_insn (template, operands)
*** 3360,3363 ****
--- 3389,3393 ----
#endif
int oporder[MAX_RECOG_OPERANDS];
+ char opoutput[MAX_RECOG_OPERANDS];
int ops = 0;
*************** output_asm_insn (template, operands)
*** 3367,3370 ****
--- 3397,3401 ----
return;
+ memset (opoutput, 0, sizeof opoutput);
p = template;
putc ('\t', asm_out_file);
*************** output_asm_insn (template, operands)
*** 3378,3384 ****
--- 3409,3420 ----
{
case '\n':
+ if (flag_verbose_asm)
+ output_asm_operand_names (operands, oporder, ops);
if (flag_print_asm_name)
output_asm_name ();
+ ops = 0;
+ memset (opoutput, 0, sizeof opoutput);
+
putc (c, asm_out_file);
#ifdef ASM_OUTPUT_OPCODE
*************** output_asm_insn (template, operands)
*** 3500,3504 ****
output_operand (operands[c], letter);
! oporder[ops++] = c;
while ((c = *p) >= '0' && c <= '9')
--- 3536,3542 ----
output_operand (operands[c], letter);
! if (!opoutput[c])
! oporder[ops++] = c;
! opoutput[c] = 1;
while ((c = *p) >= '0' && c <= '9')
*************** output_asm_insn (template, operands)
*** 3514,3519 ****
else
output_operand (operands[c], 0);
- oporder[ops++] = c;
while ((c = *p) >= '0' && c <= '9')
p++;
--- 3552,3560 ----
else
output_operand (operands[c], 0);
+
+ if (!opoutput[c])
+ oporder[ops++] = c;
+ opoutput[c] = 1;
while ((c = *p) >= '0' && c <= '9')
p++;
*************** output_asm_insn (template, operands)
*** 3536,3559 ****
/* Write out the variable names for operands, if we know them. */
if (flag_verbose_asm)
! {
! int wrote = 0;
! int i;
!
! for (i = 0; i < ops; i++)
! {
! int addressp;
! tree decl = get_decl_from_op (operands[oporder[i]], &addressp);
!
! if (decl && DECL_NAME (decl))
! {
! fprintf (asm_out_file, "%s %s%s",
! wrote ? "," : ASM_COMMENT_START,
! addressp ? "*" : "",
! IDENTIFIER_POINTER (DECL_NAME (decl)));
! wrote = 1;
! }
! }
! }
!
if (flag_print_asm_name)
output_asm_name ();
--- 3577,3581 ----
/* Write out the variable names for operands, if we know them. */
if (flag_verbose_asm)
! output_asm_operand_names (operands, oporder, ops);
if (flag_print_asm_name)
output_asm_name ();
More information about the Gcc-patches
mailing list