aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2004-12-16 09:31:58 -0800
committerRichard Henderson <rth@gcc.gnu.org>2004-12-16 09:31:58 -0800
commit26be549aac6f1c571da373bf52770b400ca7c210 (patch)
tree67e95850d4cb4c5af97945b9a98964954c1bc606
parentf85d8f699663290de6a00907542994763f610046 (diff)
downloadgcc-26be549aac6f1c571da373bf52770b400ca7c210.zip
gcc-26be549aac6f1c571da373bf52770b400ca7c210.tar.gz
gcc-26be549aac6f1c571da373bf52770b400ca7c210.tar.bz2
Makefile.in (MD_DEPS, s-mddeps): New.
* Makefile.in (MD_DEPS, s-mddeps): New. (s-config, s-conditions, s-flags, s-codes, s-constants, s-emit, s-recog, s-opinit, s-extract, s-peep, s-attr, s-attrtab, s-output, s-preds): Depend on MD_DEPS instead of md_file. (genobjnames): Add genmddeps.o (build/genmddeps, build/genmddeps.o): New. (mostlyclean): Remove mddeps.mk. * genmddeps.c: New file. * gensupport.c (include_callback): New. (process_include): Call it. * gensupport.h (include_callback): Declare. From-SVN: r92269
-rw-r--r--gcc/ChangeLog14
-rw-r--r--gcc/Makefile.in51
-rw-r--r--gcc/genmddeps.c70
-rw-r--r--gcc/gensupport.c7
-rw-r--r--gcc/gensupport.h4
5 files changed, 131 insertions, 15 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 69f6f97..e97ae9c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,17 @@
+2004-12-16 Richard Henderson <rth@redhat.com>
+
+ * Makefile.in (MD_DEPS, s-mddeps): New.
+ (s-config, s-conditions, s-flags, s-codes, s-constants, s-emit,
+ s-recog, s-opinit, s-extract, s-peep, s-attr, s-attrtab, s-output,
+ s-preds): Depend on MD_DEPS instead of md_file.
+ (genobjnames): Add genmddeps.o
+ (build/genmddeps, build/genmddeps.o): New.
+ (mostlyclean): Remove mddeps.mk.
+ * genmddeps.c: New file.
+ * gensupport.c (include_callback): New.
+ (process_include): Call it.
+ * gensupport.h (include_callback): Declare.
+
2004-12-16 Nathan Sidwell <nathan@codesourcery.com>
* local-alloc.c (block_alloc): Replace IN_RANGE with simple
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index b0f779c..b1d22a3 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2216,6 +2216,17 @@ libbackend.o : $(OBJS-common:.o=.c) $(out_file) \
insn-emit.c insn-recog.c insn-extract.c insn-output.c insn-peep.c \
insn-attr.h insn-attrtab.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
+# it built). The second time through we have the dependency file.
+-include mddeps.mk
+MD_DEPS = s-mddeps $(md_file) $(MD_INCLUDES)
+
+s-mddeps: $(md_file) $(MD_INCLUDES) build/genmddeps$(build_exeext)
+ $(RUN_GEN) build/genmddeps$(build_exeext) $(md_file) > tmp-mddeps
+ $(SHELL) $(srcdir)/../move-if-change tmp-mddeps mddeps.mk
+ $(STAMP) s-mddeps
+
# The following pair of rules has this effect:
# genconfig is run only if the md has changed since genconfig was last run;
# but the file insn-config.h is touched only when its contents actually change.
@@ -2236,13 +2247,13 @@ libbackend.o : $(OBJS-common:.o=.c) $(out_file) \
# trailing `;'), we call true for each.
insn-config.h: s-config ; @true
-s-config : $(md_file) build/genconfig$(build_exeext)
+s-config : $(MD_DEPS) build/genconfig$(build_exeext)
$(RUN_GEN) build/genconfig$(build_exeext) $(md_file) > tmp-config.h
$(SHELL) $(srcdir)/../move-if-change tmp-config.h insn-config.h
$(STAMP) s-config
insn-conditions.c: s-conditions ; @true
-s-conditions : $(md_file) build/genconditions$(build_exeext)
+s-conditions : $(MD_DEPS) build/genconditions$(build_exeext)
$(RUN_GEN) build/genconditions$(build_exeext) $(md_file) > tmp-conditions.c
$(SHELL) $(srcdir)/../move-if-change tmp-conditions.c insn-conditions.c
$(STAMP) s-conditions
@@ -2255,19 +2266,19 @@ build/insn-conditions.o : insn-conditions.c $(CONFIG_H) $(SYSTEM_H) \
build/dummy-conditions.o : dummy-conditions.c
insn-flags.h: s-flags ; @true
-s-flags : $(md_file) build/genflags$(build_exeext)
+s-flags : $(MD_DEPS) build/genflags$(build_exeext)
$(RUN_GEN) build/genflags$(build_exeext) $(md_file) > tmp-flags.h
$(SHELL) $(srcdir)/../move-if-change tmp-flags.h insn-flags.h
$(STAMP) s-flags
insn-codes.h: s-codes ; @true
-s-codes : $(md_file) build/gencodes$(build_exeext)
+s-codes : $(MD_DEPS) build/gencodes$(build_exeext)
$(RUN_GEN) build/gencodes$(build_exeext) $(md_file) > tmp-codes.h
$(SHELL) $(srcdir)/../move-if-change tmp-codes.h insn-codes.h
$(STAMP) s-codes
insn-constants.h: s-constants ; @true
-s-constants : $(md_file) build/genconstants$(build_exeext)
+s-constants : $(MD_DEPS) build/genconstants$(build_exeext)
$(RUN_GEN) build/genconstants$(build_exeext) $(md_file) > tmp-constants.h
$(SHELL) $(srcdir)/../move-if-change tmp-constants.h insn-constants.h
$(STAMP) s-constants
@@ -2279,7 +2290,7 @@ insn-emit.o : insn-emit.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(OUTPUT_OPTION)
insn-emit.c: s-emit ; @true
-s-emit : $(md_file) build/genemit$(build_exeext)
+s-emit : $(MD_DEPS) build/genemit$(build_exeext)
$(RUN_GEN) build/genemit$(build_exeext) $(md_file) > tmp-emit.c
$(SHELL) $(srcdir)/../move-if-change tmp-emit.c insn-emit.c
$(STAMP) s-emit
@@ -2291,7 +2302,7 @@ insn-recog.o : insn-recog.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(OUTPUT_OPTION)
insn-recog.c: s-recog ; @true
-s-recog : $(md_file) build/genrecog$(build_exeext)
+s-recog : $(MD_DEPS) build/genrecog$(build_exeext)
$(RUN_GEN) build/genrecog$(build_exeext) $(md_file) > tmp-recog.c
$(SHELL) $(srcdir)/../move-if-change tmp-recog.c insn-recog.c
$(STAMP) s-recog
@@ -2302,7 +2313,7 @@ insn-opinit.o : insn-opinit.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(OUTPUT_OPTION)
insn-opinit.c: s-opinit ; @true
-s-opinit : $(md_file) build/genopinit$(build_exeext)
+s-opinit : $(MD_DEPS) build/genopinit$(build_exeext)
$(RUN_GEN) build/genopinit$(build_exeext) $(md_file) > tmp-opinit.c
$(SHELL) $(srcdir)/../move-if-change tmp-opinit.c insn-opinit.c
$(STAMP) s-opinit
@@ -2313,7 +2324,7 @@ insn-extract.o : insn-extract.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(OUTPUT_OPTION)
insn-extract.c: s-extract ; @true
-s-extract : $(md_file) build/genextract$(build_exeext)
+s-extract : $(MD_DEPS) build/genextract$(build_exeext)
$(RUN_GEN) build/genextract$(build_exeext) $(md_file) > tmp-extract.c
$(SHELL) $(srcdir)/../move-if-change tmp-extract.c insn-extract.c
$(STAMP) s-extract
@@ -2325,7 +2336,7 @@ insn-peep.o : insn-peep.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(OUTPUT_OPTION)
insn-peep.c: s-peep ; @true
-s-peep : $(md_file) build/genpeep$(build_exeext)
+s-peep : $(MD_DEPS) build/genpeep$(build_exeext)
$(RUN_GEN) build/genpeep$(build_exeext) $(md_file) > tmp-peep.c
$(SHELL) $(srcdir)/../move-if-change tmp-peep.c insn-peep.c
$(STAMP) s-peep
@@ -2337,13 +2348,13 @@ insn-attrtab.o : insn-attrtab.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(OUTPUT_OPTION)
insn-attr.h: s-attr ; @true
-s-attr : $(md_file) build/genattr$(build_exeext)
+s-attr : $(MD_DEPS) build/genattr$(build_exeext)
$(RUN_GEN) build/genattr$(build_exeext) $(md_file) > tmp-attr.h
$(SHELL) $(srcdir)/../move-if-change tmp-attr.h insn-attr.h
$(STAMP) s-attr
insn-attrtab.c: s-attrtab ; @true
-s-attrtab : $(md_file) build/genattrtab$(build_exeext)
+s-attrtab : $(MD_DEPS) build/genattrtab$(build_exeext)
$(RUN_GEN) build/genattrtab$(build_exeext) $(md_file) > tmp-attrtab.c
$(SHELL) $(srcdir)/../move-if-change tmp-attrtab.c insn-attrtab.c
$(STAMP) s-attrtab
@@ -2356,7 +2367,7 @@ insn-output.o : insn-output.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(OUTPUT_OPTION)
insn-output.c: s-output ; @true
-s-output : $(md_file) build/genoutput$(build_exeext)
+s-output : $(MD_DEPS) build/genoutput$(build_exeext)
$(RUN_GEN) build/genoutput$(build_exeext) $(md_file) > tmp-output.c
$(SHELL) $(srcdir)/../move-if-change tmp-output.c insn-output.c
$(STAMP) s-output
@@ -2388,7 +2399,7 @@ s-modes: build/genmodes$(build_exeext)
insn-preds.c tm-preds.h: s-preds; @true
-s-preds: $(md_file) build/genpreds$(build_exeext)
+s-preds: $(MD_DEPS) build/genpreds$(build_exeext)
$(RUN_GEN) build/genpreds$(build_exeext) -h $(md_file) > tmp-preds.h
$(SHELL) $(srcdir)/../move-if-change tmp-preds.h tm-preds.h
$(RUN_GEN) build/genpreds$(build_exeext) $(md_file) > tmp-preds.c
@@ -2506,7 +2517,7 @@ genobjnames=$(genprognames:%=%.o) read-rtl.o gensupport.o genattrtab.o \
genconstants.o gen-protos.o scan.o fix-header.o scan-decls.o \
gencheck.o dummy-conditions.o genconditions.o errors.o ggc-none.o \
min-insn-modes.o rtl.o print-rtl.o varray.o gcov-iov.o \
- insn-conditions.o gengtype-lex.o gengtype-yacc.o
+ insn-conditions.o gengtype-lex.o gengtype-yacc.o genmddeps.o
genobjs=$(genobjnames:%=build/%)
@@ -2536,6 +2547,15 @@ build/genflags.o : genflags.c $(RTL_BASE_H) $(OBSTACK_H) $(BCONFIG_H) \
build/gencodes.o : gencodes.c $(RTL_BASE_H) $(BCONFIG_H) \
$(SYSTEM_H) coretypes.h $(GTM_H) errors.h gensupport.h
+build/genmddeps$(build_exeext) : build/genmddeps.o $(BUILD_RTL) \
+ $(BUILD_EARLY_SUPPORT) $(BUILD_ERRORS) $(BUILD_LIBDEPS)
+ $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \
+ build/genmddeps.o $(BUILD_EARLY_SUPPORT) $(BUILD_RTL) \
+ $(BUILD_ERRORS) $(BUILD_LIBS)
+
+build/genmddeps.o: genmddeps.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h \
+ $(GTM_H) $(RTL_BASE_H) errors.h gensupport.h
+
build/genconstants$(build_exeext) : build/genconstants.o $(BUILD_RTL) \
$(BUILD_EARLY_SUPPORT) $(BUILD_ERRORS) $(BUILD_LIBDEPS)
$(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \
@@ -3068,6 +3088,7 @@ mostlyclean: lang.mostlyclean
-rm -rf libgcc
# Delete build programs
-rm -f build/*
+ -rm -f mddeps.mk
# Delete the temp files made in the course of building libgcc.a.
-rm -f xlimits.h
# Delete other built files.
diff --git a/gcc/genmddeps.c b/gcc/genmddeps.c
new file mode 100644
index 0000000..ff9e63d
--- /dev/null
+++ b/gcc/genmddeps.c
@@ -0,0 +1,70 @@
+/* genmddeps.c - creates a makefile dependency fragment for the md file.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bconfig.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "rtl.h"
+#include "gensupport.h"
+#include "errors.h"
+
+
+struct filedep
+{
+ struct filedep *next;
+ const char *pathname;
+};
+
+static struct filedep *deps, **last = &deps;
+
+static void
+add_filedep (const char *pathname)
+{
+ struct filedep *n = XNEW (struct filedep);
+ n->pathname = pathname;
+ *last = n;
+ last = &n->next;
+}
+
+int
+main (int argc, char **argv)
+{
+ struct filedep *d;
+
+ progname = "genmddeps";
+ include_callback = add_filedep;
+
+ if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
+ return (FATAL_EXIT_CODE);
+
+ *last = NULL;
+
+ /* Output a variable containing all of the include files. */
+ fputs ("MD_INCLUDES =", stdout);
+ for (d = deps; d ; d = d->next)
+ printf (" \\\n\t%s", d->pathname);
+ putchar ('\n');
+
+ /* Output make targets for these includes with empty actions. This
+ will guard against make errors when includes are removed. */
+ for (d = deps; d ; d = d->next)
+ printf ("\n%s:\n", d->pathname);
+
+ fflush (stdout);
+ return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
+}
diff --git a/gcc/gensupport.c b/gcc/gensupport.c
index 1fb45c0..a0b3faa 100644
--- a/gcc/gensupport.c
+++ b/gcc/gensupport.c
@@ -37,6 +37,10 @@ int insn_elision = 1;
const char *in_fname;
+/* This callback will be invoked whenever an rtl include directive is
+ processed. To be used for creation of the dependency file. */
+void (*include_callback) (const char *);
+
static struct obstack obstack;
struct obstack *rtl_obstack = &obstack;
@@ -245,6 +249,9 @@ process_include (rtx desc, int lineno)
read_rtx_filename = pathname;
read_rtx_lineno = 1;
+ if (include_callback)
+ include_callback (pathname);
+
/* Read the entire file. */
while (read_rtx (input_file, &desc, &lineno))
process_rtx (desc, lineno);
diff --git a/gcc/gensupport.h b/gcc/gensupport.h
index 4b29d7c..7155717 100644
--- a/gcc/gensupport.h
+++ b/gcc/gensupport.h
@@ -92,4 +92,8 @@ extern void add_predicate (struct pred_data *);
#define FOR_ALL_PREDICATES(p) for (p = first_predicate; p; p = p->next)
+/* This callback will be invoked whenever an rtl include directive is
+ processed. To be used for creation of the dependency file. */
+extern void (*include_callback) (const char *);
+
#endif /* GCC_GENSUPPORT_H */