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>
}
END {
+ max_number_args = 2;
for (i = 1; i < lineno; i++)
{
ret = parse_line(lines[i], "NEXT_PASS");
{
# 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)
# 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;
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"
}
#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"
#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"
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. */