+2010-06-10 Richard Sandiford <rdsandiford@googlemail.com>
+
+ * Makefile.in (BUILD_RTL): Move build/read-md.o to...
+ (BUILD_MD): ...this new variable.
+ (simple_generated_rtl_h, simple_generated_rtl_c): New variables
+ that include the old contents of simple_generated_h and
+ simple_generated_c.
+ (simple_generated_h, simple_generated_c): Include them. Add
+ insn-constants.h.
+ (s-%): Make simple_generated_{h,c} stamps depend on $(MD_DEPS)
+ and simple_generated_rtl_{h,c} stamps depend on insn-conditions.md.
+ Remove these dependencies from the main rule and include
+ insn-conditions.md in the command line only if it appears
+ in the dependency list.
+ (insn-constants.h, s-constants): Delete.
+ (build/genconstants.o): Don't depend on $(RTL_BASE_H), $(GTM_H)
+ or gensupport.h.
+ (build/genmddeps.o): Likewise.
+ (genprogrtl): New variable that contains everything from genprogmd
+ except mddeps and constants.
+ (genprogmd): Redefine in terms of genprogrtl. Make these programs
+ depend on $(BUILD_MD)
+ (genprog): New variable. Make these programs depend on
+ $(BUILD_ERRORS).
+ * genmddeps.c: Don't include tm.h, rtl.h or gensupport.h.
+ (main): Use read_md_files instead of init_rtx_reader_args.
+ * genconstants.c: As for genmddeps.c.
+ * read-md.h (read_skip_construct): Declare.
+ * read-md.c (read_skip_construct): New function.
+ (handle_file): Allow a null handle_directive, skipping the
+ construct if so.
+ (parse_include): Update the comment accordingly.
+
2010-06-10 Richard Sandiford <rdsandiford@googlemail.com>
* Makefile.in (build/genmddeps.o): Depend on $(READ_MD_H).
# even if we are cross-building GCC.
BUILD_LIBS = $(BUILD_LIBIBERTY)
-BUILD_RTL = build/read-md.o build/rtl.o build/read-rtl.o build/ggc-none.o \
+BUILD_RTL = build/rtl.o build/read-rtl.o build/ggc-none.o \
build/vec.o build/min-insn-modes.o build/gensupport.o \
build/print-rtl.o
+BUILD_MD = build/read-md.o
BUILD_ERRORS = build/errors.o
# Specify the directories to be searched for header files.
reload.h $(REGS_H) tm-constrs.h
# For each of the files generated by running a generator program over
-# the machine description, the following pair of static pattern rules
-# runs the generator program only if the machine description has changed,
-# but touches the target file only when its contents actually change.
-# The "; @true" construct forces Make to recheck the timestamp on the
-# target file.
+# the machine description, the following static pattern rules run the
+# generator program only if the machine description has changed,
+# but touch the target file only when its contents actually change.
+# The "; @true" construct forces Make to recheck the timestamp on
+# the target file.
-simple_generated_h = insn-attr.h insn-codes.h insn-config.h insn-flags.h
+simple_rtl_generated_h = insn-attr.h insn-codes.h insn-config.h insn-flags.h
-simple_generated_c = insn-attrtab.c insn-automata.c insn-emit.c \
- insn-extract.c insn-opinit.c insn-output.c \
- insn-peep.c insn-recog.c
+simple_rtl_generated_c = insn-attrtab.c insn-automata.c insn-emit.c \
+ insn-extract.c insn-opinit.c insn-output.c \
+ insn-peep.c insn-recog.c
+
+simple_generated_h = $(simple_rtl_generated_h) insn-constants.h
+
+simple_generated_c = $(simple_rtl_generated_c)
+
+$(simple_generated_h:insn-%.h=s-%) \
+$(simple_generated_c:insn-%.c=s-%): s-%: $(MD_DEPS)
+
+$(simple_rtl_generated_h:insn-%.h=s-%) \
+$(simple_rtl_generated_c:insn-%.c=s-%): s-%: insn-conditions.md
$(simple_generated_h): insn-%.h: s-%; @true
-$(simple_generated_h:insn-%.h=s-%): s-%: build/gen%$(build_exeext) \
- $(MD_DEPS) insn-conditions.md
+$(simple_generated_h:insn-%.h=s-%): s-%: build/gen%$(build_exeext)
$(RUN_GEN) build/gen$*$(build_exeext) $(md_file) \
- insn-conditions.md > tmp-$*.h
+ $(filter insn-conditions.md,$^) > tmp-$*.h
$(SHELL) $(srcdir)/../move-if-change tmp-$*.h insn-$*.h
$(STAMP) s-$*
$(simple_generated_c): insn-%.c: s-%; @true
-$(simple_generated_c:insn-%.c=s-%): s-%: build/gen%$(build_exeext) \
- $(MD_DEPS) insn-conditions.md
+$(simple_generated_c:insn-%.c=s-%): s-%: build/gen%$(build_exeext)
$(RUN_GEN) build/gen$*$(build_exeext) $(md_file) \
- insn-conditions.md > tmp-$*.c
+ $(filter insn-conditions.md,$^) > tmp-$*.c
$(SHELL) $(srcdir)/../move-if-change tmp-$*.c insn-$*.c
$(STAMP) s-$*
-# genconstants needs to run before insn-conditions.md is available
-# (because the constants may be used in the conditions).
-insn-constants.h: s-constants; @true
-s-constants: build/genconstants$(build_exeext) $(MD_DEPS)
- $(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
-
# gencheck doesn't read the machine description, and the file produced
# doesn't use the insn-* convention.
tree-check.h: s-check ; @true
gensupport.h
build/genconfig.o : genconfig.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H) \
coretypes.h $(GTM_H) errors.h gensupport.h
-build/genconstants.o : genconstants.c $(RTL_BASE_H) $(BCONFIG_H) \
- $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
+build/genconstants.o : genconstants.c $(BCONFIG_H) $(SYSTEM_H) \
+ coretypes.h errors.h $(READ_MD_H)
build/genemit.o : genemit.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H) \
coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
build/genextract.o : genextract.c $(RTL_BASE_H) $(BCONFIG_H) \
build/gengtype.o : gengtype.c $(BCONFIG_H) $(SYSTEM_H) gengtype.h \
rtl.def insn-notes.def errors.h double-int.h $(HASHTAB_H)
build/genmddeps.o: genmddeps.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h \
- $(GTM_H) $(RTL_BASE_H) errors.h $(READ_MD_H) gensupport.h
+ errors.h $(READ_MD_H)
build/genmodes.o : genmodes.c $(BCONFIG_H) $(SYSTEM_H) errors.h \
$(HASHTAB_H) machmode.def $(extra_modes_file)
build/genopinit.o : genopinit.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H) \
$(LINKER_FOR_BUILD) $(BUILD_LINKERFLAGS) $(BUILD_LDFLAGS) -o $@ \
$(filter-out $(BUILD_LIBDEPS), $^) $(BUILD_LIBS)
-# All these programs use the MD reader ($(BUILD_RTL)).
-genprogmd = attr attrtab automata codes conditions config constants emit \
- extract flags mddeps opinit output peep preds recog
-$(genprogmd:%=build/gen%$(build_exeext)): $(BUILD_RTL) $(BUILD_ERRORS)
+# All these programs use the RTL reader ($(BUILD_RTL)).
+genprogrtl = attr attrtab automata codes conditions config emit \
+ extract flags opinit output peep preds recog
+$(genprogrtl:%=build/gen%$(build_exeext)): $(BUILD_RTL)
+
+# All these programs use the MD reader ($(BUILD_MD)).
+genprogmd = $(genprogrtl) mddeps constants
+$(genprogmd:%=build/gen%$(build_exeext)): $(BUILD_MD)
+
+# All generator programs need to report errors
+genprog = $(genprogmd) genrtl modes gtype
+$(genprog:%=build/gen%$(build_exeext)): $(BUILD_ERRORS)
# These programs need libs over and above what they get from the above list.
build/genautomata$(build_exeext) : BUILD_LIBS += -lm
# These programs are not linked with the MD reader.
-build/gengenrtl$(build_exeext) : $(BUILD_ERRORS)
-build/genmodes$(build_exeext) : $(BUILD_ERRORS)
-build/gengtype$(build_exeext) : build/gengtype-lex.o build/gengtype-parse.o \
- $(BUILD_ERRORS)
+build/gengtype$(build_exeext) : build/gengtype-lex.o build/gengtype-parse.o
# Generated source files for gengtype.
gengtype-lex.c : gengtype-lex.l
return stringbuf;
}
+/* Skip the rest of a construct that started at line LINENO and that
+ is currently nested by DEPTH levels of parentheses. */
+
+void
+read_skip_construct (int depth, int lineno)
+{
+ struct md_name name;
+ int c;
+
+ do
+ {
+ c = read_skip_spaces ();
+ if (c == EOF)
+ {
+ error_with_line (lineno, "unterminated construct");
+ exit (1);
+ }
+ switch (c)
+ {
+ case '(':
+ depth++;
+ break;
+
+ case ')':
+ depth--;
+ break;
+
+ case ':':
+ case '[':
+ case ']':
+ case '/':
+ break;
+
+ case '\"':
+ case '{':
+ unread_char (c);
+ read_string (false);
+ break;
+
+ default:
+ unread_char (c);
+ read_name (&name);
+ break;
+ }
+ }
+ while (depth > 0);
+ unread_char (c);
+}
+
/* Given a string, return the number of comma-separated elements in it.
Return 0 for the null string. */
handle_constants ();
else if (strcmp (directive.string, "include") == 0)
handle_include (lineno, handle_directive);
- else
+ else if (handle_directive)
handle_directive (lineno, directive.string);
+ else
+ read_skip_construct (1, lineno);
c = read_skip_spaces ();
if (c != ')')
It should return true if it recognizes the argument or false if a
generic error should be reported.
- The parser calls HANDLE_DIRECTIVE for each unknown directive.
+ If HANDLE_DIRECTIVE is nonnull, the parser calls it for each
+ unknown directive, otherwise it just skips such directives.
See the comment above the directive_handler_t definition for
details about the callback's interface. */