re PR other/29442 (insn-attrtab has grown too large)

PR other/29442
	* read-md.c (fprint_md_ptr_loc, fprint_c_condition): New functions.
	(print_md_ptr_loc, print_c_condition): Use them.
	* read-md.h (fprint_md_ptr_loc, fprint_c_condition): New prototypes.
	* genattrtab.c (attr_file_name, dfa_file_name, latency_file_name,
	attr_file, dfa_file, latency_file): New global variables.
	(write_attr_valueq, write_attr_set, write_attr_case, write_attr_value,
	write_upcase, write_indent, write_length_unit_log, write_test_expr,
	write_attr_get, write_insn_cases, write_eligible_delay,
	write_const_num_delay_slots): Accept FILE pointer and toss it around.
	Update all callers.
	(write_header, open_outfile, handle_arg): New funcions.
	(make_automaton_attrs): Write prototypes as extern to the output
	files.
	(main): Use init_rtx_reader_args_cb with handle_arg to take 3 file
	names from the command line.  Open the output files and write out
	internal functions for DFA functions to dfa_file_name, insn latency
	functions to latency_file_name, and everything else to attr_file.
	* Makefile.in (OBJS): Add insn-dfatab.o and insn-latencytab.o.
	(BACKEND): Build libbackend first.
	(MOSTLYCLEANFILES): Add insn-dfatab.c and insn-latencytab.c.
	(.PRECIOUS): Likewise.
	(insn-dfatab.o): New rule.
	(insn-latencytab.o): New rule.
	(simple_rtl_generated_c): Do not include insn-attrtab.c.
	(s-attrtab): New rule.

From-SVN: r187181
This commit is contained in:
Steven Bosscher 2012-05-04 20:04:47 +00:00
parent 81e7aa8e7a
commit 417232534c
5 changed files with 476 additions and 299 deletions

View File

@ -1,3 +1,32 @@
2012-05-04 Steven Bosscher <steven@gcc.gnu.org>
PR other/29442
* read-md.c (fprint_md_ptr_loc, fprint_c_condition): New functions.
(print_md_ptr_loc, print_c_condition): Use them.
* read-md.h (fprint_md_ptr_loc, fprint_c_condition): New prototypes.
* genattrtab.c (attr_file_name, dfa_file_name, latency_file_name,
attr_file, dfa_file, latency_file): New global variables.
(write_attr_valueq, write_attr_set, write_attr_case, write_attr_value,
write_upcase, write_indent, write_length_unit_log, write_test_expr,
write_attr_get, write_insn_cases, write_eligible_delay,
write_const_num_delay_slots): Accept FILE pointer and toss it around.
Update all callers.
(write_header, open_outfile, handle_arg): New funcions.
(make_automaton_attrs): Write prototypes as extern to the output
files.
(main): Use init_rtx_reader_args_cb with handle_arg to take 3 file
names from the command line. Open the output files and write out
internal functions for DFA functions to dfa_file_name, insn latency
functions to latency_file_name, and everything else to attr_file.
* Makefile.in (OBJS): Add insn-dfatab.o and insn-latencytab.o.
(BACKEND): Build libbackend first.
(MOSTLYCLEANFILES): Add insn-dfatab.c and insn-latencytab.c.
(.PRECIOUS): Likewise.
(insn-dfatab.o): New rule.
(insn-latencytab.o): New rule.
(simple_rtl_generated_c): Do not include insn-attrtab.c.
(s-attrtab): New rule.
2012-05-04 Steven Bosscher <steven@gcc.gnu.org>
* rtl.def (ATTR_FLAG): Remove probability indicating flags.

View File

@ -1143,8 +1143,10 @@ C_OBJS = c-lang.o c-family/stub-objc.o $(C_AND_OBJC_OBJS)
OBJS = \
insn-attrtab.o \
insn-automata.o \
insn-dfatab.o \
insn-emit.o \
insn-extract.o \
insn-latencytab.o \
insn-modes.o \
insn-opinit.o \
insn-output.o \
@ -1469,13 +1471,13 @@ ALL_HOST_BACKEND_OBJS = $(GCC_OBJS) $(OBJS) $(OBJS-libcommon) \
# compilation or not.
ALL_HOST_OBJS = $(ALL_HOST_FRONTEND_OBJS) $(ALL_HOST_BACKEND_OBJS)
BACKEND = main.o @TREEBROWSER@ libbackend.a libcommon-target.a libcommon.a \
BACKEND = libbackend.a main.o @TREEBROWSER@ libcommon-target.a libcommon.a \
$(CPPLIB) $(LIBDECNUMBER)
MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \
insn-output.c insn-recog.c insn-emit.c insn-extract.c insn-peep.c \
insn-attr.h insn-attr-common.h insn-attrtab.c insn-opinit.c \
insn-preds.c insn-constants.h \
insn-attr.h insn-attr-common.h insn-attrtab.c insn-dfatab.c \
insn-latencytab.c insn-opinit.c insn-preds.c insn-constants.h \
tm-preds.h tm-constrs.h checksum-options \
tree-check.h min-insn-modes.c insn-modes.c insn-modes.h \
genrtl.h gt-*.h gtype-*.h gtype-desc.c gtyp-input.list \
@ -3460,7 +3462,8 @@ $(common_out_object_file): $(common_out_file) $(CONFIG_H) $(SYSTEM_H) \
.PRECIOUS: insn-config.h insn-flags.h insn-codes.h insn-constants.h \
insn-emit.c insn-recog.c insn-extract.c insn-output.c insn-peep.c \
insn-attr.h insn-attr-common.h insn-attrtab.c insn-preds.c
insn-attr.h insn-attr-common.h insn-attrtab.c insn-dfatab.c \
insn-latencytab.c insn-preds.c
# Dependencies for the md file. The first time through, we just assume
# the md file itself and the generated dependency file (in order to get
@ -3479,7 +3482,11 @@ insn-attrtab.o : insn-attrtab.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
insn-config.h $(DIAGNOSTIC_CORE_H) $(RECOG_H) $(TM_P_H) $(FLAGS_H)
insn-automata.o : insn-automata.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(RTL_H) $(REGS_H) output.h $(INSN_ATTR_H) \
insn-config.h toplev.h $(DIAGNOSTIC_CORE_H) $(RECOG_H) $(TM_P_H) $(FLAGS_H) $(EMIT_RTL_H)
insn-config.h toplev.h $(DIAGNOSTIC_CORE_H) $(RECOG_H) \
$(TM_P_H) $(FLAGS_H) $(EMIT_RTL_H)
insn-dfatab.o : insn-dfatab.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(RTL_H) $(REGS_H) output.h $(INSN_ATTR_H) \
insn-config.h $(DIAGNOSTIC_CORE_H) $(RECOG_H) $(TM_P_H) $(FLAGS_H)
insn-emit.o : insn-emit.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(RTL_H) $(TM_P_H) $(FUNCTION_H) $(EXPR_H) $(OPTABS_H) \
dfp.h $(FLAGS_H) output.h insn-config.h hard-reg-set.h $(RECOG_H) \
@ -3488,6 +3495,9 @@ insn-emit.o : insn-emit.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
insn-enums.o : insn-enums.c $(CONFIG_H) $(SYSTEM_H) insn-constants.h
insn-extract.o : insn-extract.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(RTL_H) $(DIAGNOSTIC_CORE_H) insn-config.h $(RECOG_H)
insn-latencytab.o : insn-latencytab.c $(CONFIG_H) $(SYSTEM_H) \
coretypes.h $(TM_H) $(RTL_H) $(REGS_H) output.h $(INSN_ATTR_H) \
insn-config.h $(DIAGNOSTIC_CORE_H) $(RECOG_H) $(TM_P_H) $(FLAGS_H)
insn-modes.o : insn-modes.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(MACHMODE_H)
insn-opinit.o : insn-opinit.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
@ -3520,7 +3530,7 @@ insn-recog.o : insn-recog.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
simple_rtl_generated_h = insn-attr.h insn-attr-common.h insn-codes.h \
insn-config.h insn-flags.h
simple_rtl_generated_c = insn-attrtab.c insn-automata.c insn-emit.c \
simple_rtl_generated_c = insn-automata.c insn-emit.c \
insn-extract.c insn-opinit.c insn-output.c \
insn-peep.c insn-recog.c
@ -3557,6 +3567,17 @@ s-check : build/gencheck$(build_exeext)
$(SHELL) $(srcdir)/../move-if-change tmp-check.h tree-check.h
$(STAMP) s-check
# genattrtab produces three files: tmp-{attrtab.c,dfatab.c,latencytab.c}
insn-attrtab.c insn-dfatab.c insn-latencytab.c: s-attrtab ; @true
s-attrtab : $(MD_DEPS) build/genattrtab$(build_exeext) \
insn-conditions.md
$(RUN_GEN) build/genattrtab$(build_exeext) $(md_file) insn-conditions.md \
-Atmp-attrtab.c -Dtmp-dfatab.c -Ltmp-latencytab.c
$(SHELL) $(srcdir)/../move-if-change tmp-attrtab.c insn-attrtab.c
$(SHELL) $(srcdir)/../move-if-change tmp-dfatab.c insn-dfatab.c
$(SHELL) $(srcdir)/../move-if-change tmp-latencytab.c insn-latencytab.c
$(STAMP) s-attrtab
# gencondmd doesn't use the standard naming convention.
build/gencondmd.c: s-conditions; @true
s-conditions: $(MD_DEPS) build/genconditions$(build_exeext)

File diff suppressed because it is too large Load Diff

View File

@ -167,14 +167,21 @@ copy_md_ptr_loc (const void *new_ptr, const void *old_ptr)
}
/* If PTR is associated with a known file position, print a #line
directive for it. */
directive for it to OUTF. */
void
print_md_ptr_loc (const void *ptr)
fprint_md_ptr_loc (FILE *outf, const void *ptr)
{
const struct ptr_loc *loc = get_md_ptr_loc (ptr);
if (loc != 0)
printf ("#line %d \"%s\"\n", loc->lineno, loc->filename);
fprintf (outf, "#line %d \"%s\"\n", loc->lineno, loc->filename);
}
/* Special fprint_md_ptr_loc for writing to STDOUT. */
void
print_md_ptr_loc (const void *ptr)
{
fprint_md_ptr_loc (stdout, ptr);
}
/* Return a condition that satisfies both COND1 and COND2. Either string
@ -204,31 +211,39 @@ join_c_conditions (const char *cond1, const char *cond2)
return result;
}
/* Print condition COND, wrapped in brackets. If COND was created by
join_c_conditions, recursively invoke this function for the original
/* Print condition COND to OUTF, wrapped in brackets. If COND was created
by join_c_conditions, recursively invoke this function for the original
conditions and join the result with "&&". Otherwise print a #line
directive for COND if its original file position is known. */
void
print_c_condition (const char *cond)
fprint_c_condition (FILE *outf, const char *cond)
{
const char **halves = (const char **) htab_find (joined_conditions, &cond);
if (halves != 0)
{
printf ("(");
print_c_condition (halves[1]);
printf (" && ");
print_c_condition (halves[2]);
printf (")");
fprintf (outf, "(");
fprint_c_condition (outf, halves[1]);
fprintf (outf, " && ");
fprint_c_condition (outf, halves[2]);
fprintf (outf, ")");
}
else
{
putc ('\n', stdout);
print_md_ptr_loc (cond);
printf ("(%s)", cond);
fputc ('\n', outf);
fprint_md_ptr_loc (outf, cond);
fprintf (outf, "(%s)", cond);
}
}
/* Special fprint_c_condition for writing to STDOUT. */
void
print_c_condition (const char *cond)
{
fprint_c_condition (stdout, cond);
}
/* A vfprintf-like function for reporting an error against line LINENO
of the current MD file. */

View File

@ -118,8 +118,10 @@ extern hashval_t leading_string_hash (const void *);
extern int leading_string_eq_p (const void *, const void *);
extern void copy_md_ptr_loc (const void *, const void *);
extern void print_md_ptr_loc (const void *);
extern void fprint_md_ptr_loc (FILE *, const void *);
extern const char *join_c_conditions (const char *, const char *);
extern void print_c_condition (const char *);
extern void fprint_c_condition (FILE *, const char *);
extern void message_with_line (int, const char *, ...) ATTRIBUTE_PRINTF_2;
extern void error_with_line (int, const char *, ...) ATTRIBUTE_PRINTF_2;
extern void fatal_with_file_and_line (const char *, ...)