From e368ccba93f5bbaee882076c80849adb55a68fa0 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tschwinge@baylibre.com>
Date: Fri, 28 Jun 2024 12:10:12 +0200
Subject: [PATCH] Handle 'NUM' in 'PUSH_INSERT_PASSES_WITHIN'
..., 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 | 28 +++++++++++++++++++++++++---
gcc/pass_manager.h | 2 +-
gcc/passes.cc | 6 +++---
3 files changed, 29 insertions(+), 7 deletions(-)
@@ -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];
}
}
@@ -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)
@@ -1574,7 +1574,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)
@@ -1604,9 +1604,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() \
}
--
2.34.1