diff mbox series

avoid line breaks in -fverbose-asm tree exprs

Message ID ory2oxyvbu.fsf@livre.home
State New
Headers show
Series avoid line breaks in -fverbose-asm tree exprs | expand

Commit Message

Alexandre Oliva June 8, 2020, 11:46 p.m. UTC
An asm operand with a "VIEW_CONVERT_EXPR<struct {
  [...]
}>" will output the definition of the struct as asm code.  Oops.

I hoped setting print_rtx_head would affect print_mem_expr, just
because it's in print-rtl rather than tree-pretty-print, but it didn't
help.  I've thus arranged for print_mem_expr to "obey" print_rtx_head
by enabling TDF_SLIM.

Regstrapped on x86_64-linux-gnu.  Ok to install?


Another alternative that occurred to me was to get print_rtx_head
printed by e.g. pp_newline, or otherwise get print-rtl and
pretty-print infrastructure to both use the same line-leading
infrastructure.  I think that would be a much bigger undertaking, so I
figured I'd ask whether that would be desirable, before taking it up.
Thoughts?


for  gcc/ChangeLog

	* final.c (output_asm_operand_names): Set print_rtx_head
	around print_mem_expr.
	* print-rtl.c (print_mem_expr): Enable TDF_SLIM in dump_flags
	when print_rtx_head is nonempty.
---
 final.c     |    3 +++
 print-rtl.c |    4 ++++
 2 files changed, 7 insertions(+)

Comments

Richard Biener June 9, 2020, 7:46 a.m. UTC | #1
On Tue, Jun 9, 2020 at 1:47 AM Alexandre Oliva <oliva@adacore.com> wrote:
>
>
> An asm operand with a "VIEW_CONVERT_EXPR<struct {
>   [...]
> }>" will output the definition of the struct as asm code.  Oops.
>
> I hoped setting print_rtx_head would affect print_mem_expr, just
> because it's in print-rtl rather than tree-pretty-print, but it didn't
> help.  I've thus arranged for print_mem_expr to "obey" print_rtx_head
> by enabling TDF_SLIM.
>
> Regstrapped on x86_64-linux-gnu.  Ok to install?
>
>
> Another alternative that occurred to me was to get print_rtx_head
> printed by e.g. pp_newline, or otherwise get print-rtl and
> pretty-print infrastructure to both use the same line-leading
> infrastructure.  I think that would be a much bigger undertaking, so I
> figured I'd ask whether that would be desirable, before taking it up.
> Thoughts?
>
>
> for  gcc/ChangeLog
>
>         * final.c (output_asm_operand_names): Set print_rtx_head
>         around print_mem_expr.
>         * print-rtl.c (print_mem_expr): Enable TDF_SLIM in dump_flags
>         when print_rtx_head is nonempty.
> ---
>  final.c     |    3 +++
>  print-rtl.c |    4 ++++
>  2 files changed, 7 insertions(+)
>
> diff --git gcc/final.c gcc/final.c
> index a360196..482801db 100644
> --- gcc/final.c
> +++ gcc/final.c
> @@ -3706,9 +3706,12 @@ output_asm_operand_names (rtx *operands, int *oporder, int nops)
>        wrote = 1;
>        if (expr)
>         {
> +         const char *saved_print_rtx_head = print_rtx_head;
>           fprintf (asm_out_file, "%s",
>                    addressp ? "*" : "");
> +         print_rtx_head = ASM_COMMENT_START;
>           print_mem_expr (asm_out_file, expr);
> +         print_rtx_head = saved_print_rtx_head;
>           wrote = 1;
>         }
>        else if (REG_P (op) && ORIGINAL_REGNO (op)
> diff --git gcc/print-rtl.c gcc/print-rtl.c
> index 611ea07..0563540 100644
> --- gcc/print-rtl.c
> +++ gcc/print-rtl.c
> @@ -182,8 +182,12 @@ rtx_reuse_manager::set_seen_def (int reuse_id)
>  void
>  print_mem_expr (FILE *outfile, const_tree expr)
>  {
> +  dump_flags_t save_dump_flags = dump_flags;
> +  if (*print_rtx_head)
> +    dump_flags |= TDF_SLIM;
>    fputc (' ', outfile);
>    print_generic_expr (outfile, CONST_CAST_TREE (expr), dump_flags);

How about simply unconditionally doing dump_flags | TDF_SLIM here
to have the whole mem_expr on one line.

OK with that change.

Richard.

> +  dump_flags = save_dump_flags;
>  }
>  #endif
>
>
> --
> Alexandre Oliva, freedom fighter    he/him    https://FSFLA.org/blogs/lxo/
> Free Software Evangelist              Stallman was right, but he's left :(
> GNU Toolchain Engineer           Live long and free, and prosper ethically
Alexandre Oliva June 11, 2020, 2:21 a.m. UTC | #2
On Jun  9, 2020, Richard Biener <richard.guenther@gmail.com> wrote:

> How about simply unconditionally doing dump_flags | TDF_SLIM here
> to have the whole mem_expr on one line.

SGTM

> OK with that change.

Thanks, here's what I'm installing.


slim up mem exprs to avoid line breaks in -fverbose-asm

From: Alexandre Oliva <oliva@adacore.com>

An asm operand with a "VIEW_CONVERT_EXPR<struct {
  [...]
}>" will output the definition of the struct as asm code.  Oops.

Enable TDF_SLIM in print_mem_expr to avoid such line breaks.


for  gcc/ChangeLog

	* print-rtl.c (print_mem_expr): Enable TDF_SLIM in dump_flags.
---
 print-rtl.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git gcc/print-rtl.c gcc/print-rtl.c
index 611ea07..25265ef 100644
--- gcc/print-rtl.c
+++ gcc/print-rtl.c
@@ -183,7 +183,8 @@ void
 print_mem_expr (FILE *outfile, const_tree expr)
 {
   fputc (' ', outfile);
-  print_generic_expr (outfile, CONST_CAST_TREE (expr), dump_flags);
+  print_generic_expr (outfile, CONST_CAST_TREE (expr),
+		      dump_flags | TDF_SLIM);
 }
 #endif
diff mbox series

Patch

diff --git gcc/final.c gcc/final.c
index a360196..482801db 100644
--- gcc/final.c
+++ gcc/final.c
@@ -3706,9 +3706,12 @@  output_asm_operand_names (rtx *operands, int *oporder, int nops)
       wrote = 1;
       if (expr)
 	{
+	  const char *saved_print_rtx_head = print_rtx_head;
 	  fprintf (asm_out_file, "%s",
 		   addressp ? "*" : "");
+	  print_rtx_head = ASM_COMMENT_START;
 	  print_mem_expr (asm_out_file, expr);
+	  print_rtx_head = saved_print_rtx_head;
 	  wrote = 1;
 	}
       else if (REG_P (op) && ORIGINAL_REGNO (op)
diff --git gcc/print-rtl.c gcc/print-rtl.c
index 611ea07..0563540 100644
--- gcc/print-rtl.c
+++ gcc/print-rtl.c
@@ -182,8 +182,12 @@  rtx_reuse_manager::set_seen_def (int reuse_id)
 void
 print_mem_expr (FILE *outfile, const_tree expr)
 {
+  dump_flags_t save_dump_flags = dump_flags;
+  if (*print_rtx_head)
+    dump_flags |= TDF_SLIM;
   fputc (' ', outfile);
   print_generic_expr (outfile, CONST_CAST_TREE (expr), dump_flags);
+  dump_flags = save_dump_flags;
 }
 #endif