aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew Pinski <quic_apinski@quicinc.com>2024-10-13 11:09:14 -0700
committerAndrew Pinski <quic_apinski@quicinc.com>2024-10-14 07:32:34 -0700
commit0110a381de6b843c0d7dcb7fcd563a678a763ddb (patch)
tree89a321672e9aaa0519560516a5bbc6a09bf3f68a /gcc
parent56efa627cb435a7a2a18f1a86c89621001cc7e56 (diff)
downloadgcc-0110a381de6b843c0d7dcb7fcd563a678a763ddb.zip
gcc-0110a381de6b843c0d7dcb7fcd563a678a763ddb.tar.gz
gcc-0110a381de6b843c0d7dcb7fcd563a678a763ddb.tar.bz2
passes: Allow for second param for NEXT_PASS
Right now we currently only support 1 parameter for each pass in NEXT_PASS. We also don't error out if someone tries to use more than 1. This adds support for more than one but only to a max of max_number_args (which is currently 2). In the next patch, this will be used for DCE, adding a new parameter. Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: * gen-pass-instances.awk (END): Handle processing of multiple arguments to NEXT_PASS. Also error out if using more than max_number_args (2). * pass_manager.h (NEXT_PASS_WITH_ARG2): New define. * passes.cc (NEXT_PASS_WITH_ARG2): New define. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gen-pass-instances.awk24
-rw-r--r--gcc/pass_manager.h1
-rw-r--r--gcc/passes.cc8
3 files changed, 28 insertions, 5 deletions
diff --git a/gcc/gen-pass-instances.awk b/gcc/gen-pass-instances.awk
index f56b807..def0934 100644
--- a/gcc/gen-pass-instances.awk
+++ b/gcc/gen-pass-instances.awk
@@ -195,6 +195,7 @@ function replace_pass(line, fnname, num, i)
}
END {
+ max_number_args = 2;
for (i = 1; i < lineno; i++)
{
ret = parse_line(lines[i], "NEXT_PASS");
@@ -202,7 +203,9 @@ END {
{
# Set pass_name argument, an optional with_arg argument
pass_name = args[1];
- with_arg = args[2];
+ num_args = 0;
+ while (args[num_args + 2])
+ num_args++;
# Set pass_final_counts
if (pass_name in pass_final_counts)
@@ -214,13 +217,22 @@ END {
# Print call expression with extra pass_num argument
printf "%s", prefix;
- if (with_arg)
- printf "NEXT_PASS_WITH_ARG";
+ if (num_args > 0)
+ {
+ printf "NEXT_PASS_WITH_ARG";
+ if (num_args > max_number_args)
+ {
+ print "ERROR: Only supports up to " max_number_args " args to NEXT_PASS";
+ exit 1;
+ }
+ if (num_args != 1)
+ printf num_args;
+ }
else
printf "NEXT_PASS";
printf " (%s, %s", pass_name, pass_num;
- if (with_arg)
- printf ",%s", with_arg;
+ for (j = 0; j < num_args; j++)
+ printf ",%s", args[j+2];
printf ")%s\n", postfix;
continue;
@@ -254,6 +266,8 @@ END {
print "#undef POP_INSERT_PASSES"
print "#undef NEXT_PASS"
print "#undef NEXT_PASS_WITH_ARG"
+ for (i = 2; i <= max_number_args; i++)
+ print "#undef NEXT_PASS_WITH_ARG" i
print "#undef TERMINATE_PASS_LIST"
}
diff --git a/gcc/pass_manager.h b/gcc/pass_manager.h
index 5a78d3f..f18ae02 100644
--- a/gcc/pass_manager.h
+++ b/gcc/pass_manager.h
@@ -130,6 +130,7 @@ private:
#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)
+#define NEXT_PASS_WITH_ARG2(PASS, NUM, ARG0, ARG1) NEXT_PASS (PASS, NUM)
#define TERMINATE_PASS_LIST(PASS)
#include "pass-instances.def"
diff --git a/gcc/passes.cc b/gcc/passes.cc
index 3abae97..b5475fc 100644
--- a/gcc/passes.cc
+++ b/gcc/passes.cc
@@ -1589,6 +1589,7 @@ pass_manager::pass_manager (context *ctxt)
#define POP_INSERT_PASSES()
#define NEXT_PASS(PASS, NUM) PASS ## _ ## NUM = NULL
#define NEXT_PASS_WITH_ARG(PASS, NUM, ARG) NEXT_PASS (PASS, NUM)
+#define NEXT_PASS_WITH_ARG2(PASS, NUM, ARG0, ARG1) NEXT_PASS (PASS, NUM)
#define TERMINATE_PASS_LIST(PASS)
#include "pass-instances.def"
@@ -1635,6 +1636,13 @@ pass_manager::pass_manager (context *ctxt)
PASS ## _ ## NUM->set_pass_param (0, ARG); \
} while (0)
+#define NEXT_PASS_WITH_ARG2(PASS, NUM, ARG0, ARG1) \
+ do { \
+ NEXT_PASS (PASS, NUM); \
+ PASS ## _ ## NUM->set_pass_param (0, ARG0); \
+ PASS ## _ ## NUM->set_pass_param (1, ARG1); \
+ } while (0)
+
#include "pass-instances.def"
/* Register the passes with the tree dump code. */