]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Handle 'NUM' in 'PUSH_INSERT_PASSES_WITHIN'
authorThomas Schwinge <tschwinge@baylibre.com>
Fri, 28 Jun 2024 10:10:12 +0000 (12:10 +0200)
committerThomas Schwinge <tschwinge@baylibre.com>
Thu, 5 Sep 2024 05:17:15 +0000 (07:17 +0200)
..., such that also for repeated 'NEXT_PASS', 'PUSH_INSERT_PASSES_WITHIN' for a
given 'PASS', the 'PUSH_INSERT_PASSES_WITHIN' applies to the preceeding
'NEXT_PASS', and not unconditionally applies to the first 'NEXT_PASS'.

gcc/
* gen-pass-instances.awk: Handle 'PUSH_INSERT_PASSES_WITHIN'.
* pass_manager.h (PUSH_INSERT_PASSES_WITHIN): Adjust.
* passes.cc (PUSH_INSERT_PASSES_WITHIN): Likewise.

gcc/gen-pass-instances.awk
gcc/pass_manager.h
gcc/passes.cc

index 449889663f738cd117c09d8446d737e14ebd418e..871ac0cdb52fa7faf6bc92310df0435da3856e5e 100644 (file)
@@ -16,7 +16,7 @@
 
 # This Awk script takes passes.def and writes pass-instances.def,
 # counting the instances of each kind of pass, adding an instance number
-# to everywhere that NEXT_PASS is used.
+# to everywhere that NEXT_PASS or PUSH_INSERT_PASSES_WITHIN are used.
 # Also handle INSERT_PASS_AFTER, INSERT_PASS_BEFORE and REPLACE_PASS
 # directives.
 #
@@ -222,9 +222,31 @@ END {
          if (with_arg)
            printf ",%s", with_arg;
          printf ")%s\n", postfix;
+
+         continue;
        }
-      else
-       print lines[i];
+
+      ret = parse_line(lines[i], "PUSH_INSERT_PASSES_WITHIN");
+      if (ret)
+       {
+         pass_name = args[1];
+
+         pass_num = pass_final_counts[pass_name];
+         if (!pass_num)
+           {
+             print "ERROR: Can't locate instance of the pass mentioned in " pass_name;
+             exit 1;
+           }
+
+         printf "%s", prefix;
+         printf "PUSH_INSERT_PASSES_WITHIN";
+         printf " (%s, %s", pass_name, pass_num;
+         printf ")%s\n", postfix;
+
+         continue;
+       }
+
+      print lines[i];
     }
 }
 
index be324d5dff794dcf28fa2ececfc7b2a7d648b9d7..edd775e9a9c307293f12bd1067e4a9a78bcf0b0c 100644 (file)
@@ -126,7 +126,7 @@ private:
         opt_pass *pass_copy_prop_8;  */
 
 #define INSERT_PASSES_AFTER(PASS)
-#define PUSH_INSERT_PASSES_WITHIN(PASS)
+#define PUSH_INSERT_PASSES_WITHIN(PASS, NUM)
 #define POP_INSERT_PASSES()
 #define NEXT_PASS(PASS, NUM) opt_pass *PASS ## _ ## NUM
 #define NEXT_PASS_WITH_ARG(PASS, NUM, ARG) NEXT_PASS (PASS, NUM)
index e2a07ebedf5d82191197ca9e3865edefe6a68208..775c3e46302f51d4f784ac9721f026d91a1d7601 100644 (file)
@@ -1585,7 +1585,7 @@ pass_manager::pass_manager (context *ctxt)
 
   /* Zero-initialize pass members.  */
 #define INSERT_PASSES_AFTER(PASS)
-#define PUSH_INSERT_PASSES_WITHIN(PASS)
+#define PUSH_INSERT_PASSES_WITHIN(PASS, NUM)
 #define POP_INSERT_PASSES()
 #define NEXT_PASS(PASS, NUM) PASS ## _ ## NUM = NULL
 #define NEXT_PASS_WITH_ARG(PASS, NUM, ARG) NEXT_PASS (PASS, NUM)
@@ -1615,9 +1615,9 @@ pass_manager::pass_manager (context *ctxt)
     *p = NULL;                                 \
   }
 
-#define PUSH_INSERT_PASSES_WITHIN(PASS) \
+#define PUSH_INSERT_PASSES_WITHIN(PASS, NUM) \
   { \
-    opt_pass **p = &(PASS ## _1)->sub;
+    opt_pass **p = &(PASS ## _ ## NUM)->sub;
 
 #define POP_INSERT_PASSES() \
   }