genrecog: Split into separate partitions [PR111600].

Hi,

this patch makes genrecog split its output into separate files (10 by
default) in the same vein genemit does.  The changes are mostly
mechanical again, changing printfs and puts to fprintf.
As insn-recog.cc relies on being able to call other recog functions a
header insn-recog.h is introduced that pre declares all of those.

For simplicity the number of files is determined by (re-using)
--with-insnemit-partitions.  Naming suggestions welcome :)

Bootstrapped and regtested on x86 and power10, regtested on riscv.
aarch64 bootstrap is currently blocked because of the
"maybe uninitialized" issue discussed on IRC.

Regards
 Robin

	PR target/111600

gcc/ChangeLog:

	* Makefile.in:  Add insn-recog split.
	* configure: Regenerate.
	* configure.ac: Document that the number of insnemit partitions is
	used for insn-recog as well.
	* genconditions.cc (write_one_condition): Use fprintf.
	* genpreds.cc (write_predicate_expr): Ditto.
	(write_init_reg_class_start_regs): Ditto.
	* genrecog.cc (write_header): Add header file to includes.
	(printf_indent): Use fprintf.
	(change_state): Ditto.
	(print_code): Ditto.
	(print_host_wide_int): Ditto.
	(print_parameter_value): Ditto.
	(print_test_rtx): Ditto.
	(print_nonbool_test): Ditto.
	(print_label_value): Ditto.
	(print_test): Ditto.
	(print_decision): Ditto.
	(print_state): Ditto.
	(print_subroutine_call): Ditto.
	(print_acceptance): Ditto.
	(print_subroutine_start): Ditto.
	(print_pattern): Ditto.
	(print_subroutine): Ditto.
	(print_subroutine_group): Ditto.
	(handle_arg): Add -O and -H for output and header file handling.
	(main): Use callback.
	* gentarget-def.cc (def_target_insn): Use fprintf.
	* read-md.cc (md_reader::print_c_condition): Ditto.
	* read-md.h (class md_reader): Ditto.
This commit is contained in:
Robin Dapp
2024-11-26 14:44:17 +01:00
parent 959a80a46d
commit 6dcfe87431
9 changed files with 359 additions and 244 deletions

View File

@@ -239,6 +239,12 @@ INSNEMIT_SEQ_SRC = $(patsubst %, insn-emit-%.cc, $(INSNEMIT_SPLITS_SEQ))
INSNEMIT_SEQ_TMP = $(patsubst %, tmp-emit-%.cc, $(INSNEMIT_SPLITS_SEQ))
INSNEMIT_SEQ_O = $(patsubst %, insn-emit-%.o, $(INSNEMIT_SPLITS_SEQ))
# Re-use the split number for insn-recog as well.
INSNRECOG_SPLITS_SEQ = $(wordlist 1,$(NUM_INSNEMIT_SPLITS),$(one_to_9999))
INSNRECOG_SEQ_SRC = $(patsubst %, insn-recog-%.cc, $(INSNRECOG_SPLITS_SEQ))
INSNRECOG_SEQ_TMP = $(patsubst %, tmp-recog-%.cc, $(INSNRECOG_SPLITS_SEQ))
INSNRECOG_SEQ_O = $(patsubst %, insn-recog-%.o, $(INSNRECOG_SPLITS_SEQ))
# These files are to have specific diagnostics suppressed, or are not to
# be subject to -Werror:
# flex output may yield harmless "no previous prototype" warnings
@@ -1385,7 +1391,7 @@ OBJS = \
insn-output.o \
insn-peep.o \
insn-preds.o \
insn-recog.o \
$(INSNRECOG_SEQ_O) \
insn-enums.o \
ggc-page.o \
adjust-alignment.o \
@@ -1909,8 +1915,8 @@ TREECHECKING = @TREECHECKING@
FULL_DRIVER_NAME=$(target_noncanonical)-gcc-$(version)$(exeext)
MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \
insn-output.cc insn-recog.cc $(INSNEMIT_SEQ_SRC) \
insn-extract.cc insn-peep.cc \
insn-output.cc $(INSNRECOG_SEQ_SRC) insn-recog.h \
$(INSNEMIT_SEQ_SRC) insn-extract.cc insn-peep.cc \
insn-attr.h insn-attr-common.h insn-attrtab.cc insn-dfatab.cc \
insn-latencytab.cc insn-opinit.cc insn-opinit.h insn-preds.cc insn-constants.h \
tm-preds.h tm-constrs.h checksum-options $(GIMPLE_MATCH_PD_SEQ_SRC) \
@@ -2677,7 +2683,8 @@ $(common_out_object_file): $(common_out_file)
# and compile them.
.PRECIOUS: insn-config.h insn-flags.h insn-codes.h insn-constants.h \
$(INSNEMIT_SEQ_SRC) insn-recog.cc insn-extract.cc insn-output.cc \
$(INSNEMIT_SEQ_SRC) insn-recog.h $(INSNRECOG_SEQ_SRC) \
insn-extract.cc insn-output.cc \
insn-peep.cc insn-attr.h insn-attr-common.h insn-attrtab.cc \
insn-dfatab.cc insn-latencytab.cc insn-preds.cc \
$(GIMPLE_MATCH_PD_SEQ_SRC) $(GENERIC_MATCH_PD_SEQ_SRC) \
@@ -2706,7 +2713,7 @@ simple_rtl_generated_h = insn-attr.h insn-attr-common.h insn-codes.h \
simple_rtl_generated_c = insn-automata.cc \
insn-extract.cc insn-output.cc \
insn-peep.cc insn-recog.cc
insn-peep.cc
simple_generated_h = $(simple_rtl_generated_h) insn-constants.h
@@ -2744,6 +2751,18 @@ s-tmp-emit: build/genemit$(build_exeext) $(MD_DEPS) insn-conditions.md
insn-emit-$(id).cc;)
$(STAMP) s-tmp-emit
# Same for genrecog.
$(INSNRECOG_SEQ_SRC): s-tmp-recog; @true
insn-recog.h: s-tmp-recog; @true
s-tmp-recog: build/genrecog$(build_exeext) $(MD_DEPS) insn-conditions.md
$(RUN_GEN) build/genrecog$(build_exeext) $(md_file) insn-conditions.md \
-Hinsn-recog.h \
$(addprefix -O,${INSNRECOG_SEQ_TMP})
$(foreach id, $(INSNRECOG_SPLITS_SEQ), \
$(SHELL) $(srcdir)/../move-if-change tmp-recog-$(id).cc \
insn-recog-$(id).cc;)
$(STAMP) s-tmp-recog
# gencheck doesn't read the machine description, and the file produced
# doesn't use the insn-* convention.

4
gcc/configure vendored
View File

@@ -1873,7 +1873,7 @@ Optional Packages:
generic when splitting match.pd. [default=10]
--with-insnemit-partitions=num
Set the number of partitions of insn-emit.cc for
genemit to create. [default=10]
genemit and genrecog to create. [default=10]
--with-dwarf2 force the default debug format to be DWARF 2 (or
later)
--with-specs=SPECS add SPECS to driver command-line processing
@@ -7936,7 +7936,7 @@ fi
# Specify the number of splits of insn-emit.cc to generate.
# Specify the number of splits of insn-emit.cc and insn-recog.cc to generate.
# Check whether --with-insnemit-partitions was given.
if test "${with_insnemit_partitions+set}" = set; then :

View File

@@ -929,10 +929,10 @@ fi
AC_SUBST(DEFAULT_MATCHPD_PARTITIONS)
# Specify the number of splits of insn-emit.cc to generate.
# Specify the number of splits of insn-emit.cc and insn-recog.cc to generate.
AC_ARG_WITH(insnemit-partitions,
[AS_HELP_STRING([--with-insnemit-partitions=num],
[Set the number of partitions of insn-emit.cc for genemit to create. [default=10]])],
[Set the number of partitions of insn-emit.cc for genemit and genrecog to create. [default=10]])],
[DEFAULT_INSNEMIT_PARTITIONS="$with_insnemit_partitions"], [DEFAULT_INSNEMIT_PARTITIONS=10])
if (test $DEFAULT_INSNEMIT_PARTITIONS -lt 1); then
AC_MSG_ERROR(m4_normalize([

View File

@@ -141,9 +141,9 @@ write_one_condition (void **slot, void * ARG_UNUSED (dummy))
}
fputs ("\",\n __builtin_constant_p ", stdout);
rtx_reader_ptr->print_c_condition (test->expr);
rtx_reader_ptr->print_c_condition (stdout, test->expr);
fputs ("\n ? (int) ", stdout);
rtx_reader_ptr->print_c_condition (test->expr);
rtx_reader_ptr->print_c_condition (stdout, test->expr);
fputs ("\n : -1 },\n", stdout);
return 1;
}

View File

@@ -538,7 +538,7 @@ write_predicate_expr (rtx exp)
break;
case MATCH_TEST:
rtx_reader_ptr->print_c_condition (XSTR (exp, 0));
rtx_reader_ptr->print_c_condition (stdout, XSTR (exp, 0));
break;
default:
@@ -1344,7 +1344,7 @@ write_init_reg_class_start_regs ()
for (unsigned int i = 0; i < register_filters.length (); ++i)
{
printf (" if (");
rtx_reader_ptr->print_c_condition (register_filters[i]);
rtx_reader_ptr->print_c_condition (stdout, register_filters[i]);
printf (")\n"
" SET_HARD_REG_BIT (%s[%d], regno);\n",
"this_target_constraints->register_filters", i);

File diff suppressed because it is too large Load Diff

View File

@@ -191,7 +191,7 @@ def_target_insn (const char *name, const char *prototype)
printf ("target_have_%s (void)\n", name);
printf ("{\n");
printf (" return ");
rtx_reader_ptr->print_c_condition (test);
rtx_reader_ptr->print_c_condition (stdout, test);
printf (";\n");
printf ("}\n");
}

View File

@@ -192,9 +192,9 @@ md_reader::fprint_c_condition (FILE *outf, const char *cond)
/* Special fprint_c_condition for writing to STDOUT. */
void
md_reader::print_c_condition (const char *cond)
md_reader::print_c_condition (FILE *outf, const char *cond)
{
fprint_c_condition (stdout, cond);
fprint_c_condition (outf, cond);
}
/* A vfprintf-like function for reporting an error against line LINENO

View File

@@ -205,7 +205,7 @@ class md_reader
const char *join_c_conditions (const char *cond1, const char *cond2);
void fprint_c_condition (FILE *outf, const char *cond);
void print_c_condition (const char *cond);
void print_c_condition (FILE *outf, const char *cond);
/* Defined in read-rtl.cc. */
const char *apply_iterator_to_string (const char *string);