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>
This commit is contained in:
parent
56efa627cb
commit
0110a381de
3 changed files with 28 additions and 5 deletions
|
@ -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"
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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. */
|
||||
|
|
Loading…
Add table
Reference in a new issue