diff mbox series

Rewrite usage comment at the top of 'gcc/passes.def' (was: [PATCH 02/11] Generate pass-instances.def)

Message ID 87jzi9tgcw.fsf@euler.schwinge.ddns.net
State New
Headers show
Series Rewrite usage comment at the top of 'gcc/passes.def' (was: [PATCH 02/11] Generate pass-instances.def) | expand

Commit Message

Thomas Schwinge June 28, 2024, 12:13 p.m. UTC
Hi!

On 2013-07-26T11:04:32-0400, David Malcolm <dmalcolm@redhat.com> wrote:
> Introduce a new gen-pass-instances.awk script, and use it at build time
> to make a pass-instances.def from passes.def.

(The script has later been rewritten and extended, but the issue I'm
discussing is relevant already in its original version.)

> The generated pass-instances.def contains similar content to passes.def,
> but the pass instances within it are explicitly numbered, so that e.g.
> the third instance of:
>
>   NEXT_PASS (pass_copy_prop)
>
> becomes:
>
>   NEXT_PASS (pass_copy_prop, 3)

> --- a/gcc/passes.c
> +++ b/gcc/passes.c
> @@ -1315,12 +1315,12 @@ pipeline::pipeline (context *ctxt)
>  #define POP_INSERT_PASSES() \
>    }
>  
> -#define NEXT_PASS(PASS)  (p = next_pass_1 (p, &((PASS).pass)))
> +#define NEXT_PASS(PASS, NUM)  (p = next_pass_1 (p, &((PASS).pass)))
>  
>  #define TERMINATE_PASS_LIST() \
>    *p = NULL;
>  
> -#include "passes.def"
> +#include "pass-instances.def"

Given this, the usage comment at the top of 'gcc/passes.def' (see below)
no longer is accurate (even if that latter file does continue to use the
'NEXT_PASS' form without 'NUM') -- and, worse, the 'NEXT_PASS' etc. in
that usage comment are processed by the 'gcc/gen-pass-instances.awk'
script:

    --- source-gcc/gcc/passes.def   2024-06-24 18:55:15.132561641 +0200
    +++ build-gcc/gcc/pass-instances.def    2024-06-24 18:55:27.768562714 +0200
    [...]
    @@ -20,546 +22,578 @@
     /*
      Macros that should be defined when using this file:
        INSERT_PASSES_AFTER (PASS)
        PUSH_INSERT_PASSES_WITHIN (PASS)
        POP_INSERT_PASSES ()
    -   NEXT_PASS (PASS)
    +   NEXT_PASS (PASS, 1)
        TERMINATE_PASS_LIST (PASS)
      */
    [...]

(That is, this is 'NEXT_PASS' for the first instance of pass 'PASS'.)
That's benign so far, but with another thing that I'll be extending, I'd
then run into an error while the script handles this comment block.  ;-\

OK to push "Rewrite usage comment at the top of 'gcc/passes.def'", see
attached?


Grüße
 Thomas

Comments

Richard Biener June 28, 2024, 12:57 p.m. UTC | #1
On Fri, Jun 28, 2024 at 2:14 PM Thomas Schwinge <tschwinge@baylibre.com> wrote:
>
> Hi!
>
> On 2013-07-26T11:04:32-0400, David Malcolm <dmalcolm@redhat.com> wrote:
> > Introduce a new gen-pass-instances.awk script, and use it at build time
> > to make a pass-instances.def from passes.def.
>
> (The script has later been rewritten and extended, but the issue I'm
> discussing is relevant already in its original version.)
>
> > The generated pass-instances.def contains similar content to passes.def,
> > but the pass instances within it are explicitly numbered, so that e.g.
> > the third instance of:
> >
> >   NEXT_PASS (pass_copy_prop)
> >
> > becomes:
> >
> >   NEXT_PASS (pass_copy_prop, 3)
>
> > --- a/gcc/passes.c
> > +++ b/gcc/passes.c
> > @@ -1315,12 +1315,12 @@ pipeline::pipeline (context *ctxt)
> >  #define POP_INSERT_PASSES() \
> >    }
> >
> > -#define NEXT_PASS(PASS)  (p = next_pass_1 (p, &((PASS).pass)))
> > +#define NEXT_PASS(PASS, NUM)  (p = next_pass_1 (p, &((PASS).pass)))
> >
> >  #define TERMINATE_PASS_LIST() \
> >    *p = NULL;
> >
> > -#include "passes.def"
> > +#include "pass-instances.def"
>
> Given this, the usage comment at the top of 'gcc/passes.def' (see below)
> no longer is accurate (even if that latter file does continue to use the
> 'NEXT_PASS' form without 'NUM') -- and, worse, the 'NEXT_PASS' etc. in
> that usage comment are processed by the 'gcc/gen-pass-instances.awk'
> script:
>
>     --- source-gcc/gcc/passes.def   2024-06-24 18:55:15.132561641 +0200
>     +++ build-gcc/gcc/pass-instances.def    2024-06-24 18:55:27.768562714 +0200
>     [...]
>     @@ -20,546 +22,578 @@
>      /*
>       Macros that should be defined when using this file:
>         INSERT_PASSES_AFTER (PASS)
>         PUSH_INSERT_PASSES_WITHIN (PASS)
>         POP_INSERT_PASSES ()
>     -   NEXT_PASS (PASS)
>     +   NEXT_PASS (PASS, 1)
>         TERMINATE_PASS_LIST (PASS)
>       */
>     [...]
>
> (That is, this is 'NEXT_PASS' for the first instance of pass 'PASS'.)
> That's benign so far, but with another thing that I'll be extending, I'd
> then run into an error while the script handles this comment block.  ;-\
>
> OK to push "Rewrite usage comment at the top of 'gcc/passes.def'", see
> attached?

OK

>
> Grüße
>  Thomas
>
>
diff mbox series

Patch

From 072cdf7d9cf86fb2b0553b93365648e153b4376b Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tschwinge@baylibre.com>
Date: Fri, 28 Jun 2024 14:05:04 +0200
Subject: [PATCH] Rewrite usage comment at the top of 'gcc/passes.def'

Since Subversion r201359 (Git commit a167b052dfe9a8509bb23c374ffaeee953df0917)
"Introduce gen-pass-instances.awk and pass-instances.def", the usage comment at
the top of 'gcc/passes.def' no longer is accurate (even if that latter file
does continue to use the 'NEXT_PASS' form without 'NUM') -- and, worse, the
'NEXT_PASS' etc. in that usage comment are processed by the
'gcc/gen-pass-instances.awk' script:

    --- source-gcc/gcc/passes.def   2024-06-24 18:55:15.132561641 +0200
    +++ build-gcc/gcc/pass-instances.def    2024-06-24 18:55:27.768562714 +0200
    [...]
    @@ -20,546 +22,578 @@
     /*
      Macros that should be defined when using this file:
        INSERT_PASSES_AFTER (PASS)
        PUSH_INSERT_PASSES_WITHIN (PASS)
        POP_INSERT_PASSES ()
    -   NEXT_PASS (PASS)
    +   NEXT_PASS (PASS, 1)
        TERMINATE_PASS_LIST (PASS)
      */
    [...]

(That is, this is 'NEXT_PASS' for the first instance of pass 'PASS'.)
That's benign so far, but with another thing that I'll be extending, I'd
then run into an error while the script handles this comment block.  ;-\

	gcc/
	* passes.def: Rewrite usage comment at the top.
---
 gcc/passes.def | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/gcc/passes.def b/gcc/passes.def
index 1f222729d39..3f65fcf71d6 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -17,14 +17,11 @@  You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-/*
- Macros that should be defined when using this file:
-   INSERT_PASSES_AFTER (PASS)
-   PUSH_INSERT_PASSES_WITHIN (PASS)
-   POP_INSERT_PASSES ()
-   NEXT_PASS (PASS)
-   TERMINATE_PASS_LIST (PASS)
- */
+/* Note that this file is processed by a simple parser:
+   'gen-pass-instances.awk', so carefully verify the generated
+   'pass-instances.def' if you deviate from the syntax otherwise used in
+   here.  */
+
 
  /* All passes needed to lower the function into shape optimizers can
     operate on.  These passes are always run first on the function, but
-- 
2.34.1