gcc/gcc/genmddeps.c

72 lines
1.9 KiB
C
Raw Normal View History

/* genmddeps.c - creates a makefile dependency fragment for the md file.
Copyright (C) 2004-2017 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 3, 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; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "bconfig.h"
#include "system.h"
#include "coretypes.h"
#include "errors.h"
read-md.c: Move various state to within class rtx_reader gcc/ChangeLog: * genattrtab.c (attr_string): Use rtx_reader_ptr for call to copy_md_ptr_loc. (gen_attr): Use rtx_reader_ptr for lookup_enum_type call. (write_test_expr): Use rtx_reader_ptr for calls to fprint_c_condition. (write_attr_value): Likewise. * genconditions.c (write_one_condition): Use rtx_reader_ptr for call to print_md_ptr_loc. (write_one_condition): Likewise for calls to print_c_condition. * genconstants.c: Include "statistics.h" and "vec.h". (main): Update for conversion to member functions. * genemit.c (emit_c_code): Use rtx_reader_ptr for call to print_md_ptr_loc. * genenums.c: Include "statistics.h" and "vec.h". (main): Update for conversion of traverse_enum_types to a method. * genmddeps.c: Include "statistics.h" and "vec.h". * genoutput.c (process_template): Use rtx_reader_ptr for call to print_md_ptr_loc. * genpreds.c (write_predicate_subfunction): Likewise. (write_predicate_expr): Likewise for calls to print_c_condition. * genrecog.c (print_test): Likewise. * gensupport.c (process_rtx): Likewise for calls to copy_md_ptr_loc and join_c_conditions. (alter_test_for_insn): Likewise for call to join_c_conditions. (process_substs_on_one_elem): Likewise. (gen_mnemonic_setattr): Update for move of string_obstack to a field of rtx_reader. (mnemonic_htab_callback): Likewise. Fix formatting. (gen_mnemonic_attr): Likewise. * gentarget-def.c (def_target_insn): Use rtx_reader_ptr for calls to print_c_condition. * read-md.c: Include "statistics.h" and "vec.h". (string_obstack): Convert this global to field "m_string_obstack" of class rtx_reader. (ptr_locs): Likewise, as "m_ptr_locs". (ptr_loc_obstack): Likewise, as "m_ptr_loc_obstack". (joined_conditions): Likewise, as "m_joined_conditions". (joined_conditions_obstack): Likewise, as "m_joined_conditions_obstack". (md_constants): Likewise, as "m_md_constants". (enum_types): Likewise, as "m_enum_types". (set_md_ptr_loc): Convert to... (rtx_reader::set_md_ptr_loc): ...member function. (get_md_ptr_loc): Convert to... (rtx_reader::get_md_ptr_loc): ...member function. (copy_md_ptr_loc): Convert to... (rtx_reader::copy_md_ptr_loc): ...member function. (fprint_md_ptr_loc): Convert to... (rtx_reader::fprint_md_ptr_loc): ...member function. (print_md_ptr_loc): Convert to... (rtx_reader::print_md_ptr_loc): ...member function. (join_c_conditions): Convert to... (rtx_reader::join_c_conditions): ...member function. (fprint_c_condition): Convert to... (rtx_reader::fprint_c_condition): ...member function. (print_c_condition): Convert to... (rtx_reader::print_c_condition): ...member function. (read_name): Convert to... (rtx_reader::read_name): ...member function. (read_escape): Convert to... (rtx_reader::read_escape): ...member function. (read_quoted_string): Convert to... (rtx_reader::read_quoted_string): ...member function. (read_braced_string): Convert to... (rtx_reader::read_braced_string): ...member function. (read_string): Convert to... (rtx_reader::read_string): ...member function. (read_skip_construct): Convert to... (rtx_reader::read_skip_construct): ...member function. (handle_constants): Convert to... (rtx_reader::handle_constants): ...member function. (traverse_md_constants): Convert to... (rtx_reader::traverse_md_constants): ...member function. (handle_enum): Convert to... (rtx_reader::handle_enum): ...member function. (lookup_enum_type): Convert to... (rtx_reader::lookup_enum_type): ...member function. (traverse_enum_types): Convert to... (rtx_reader::traverse_enum_types): ...member function. (rtx_reader::rtx_reader): Move initializations of various former global data from rtx_reader::read_md_files to here, as fields, along with the call to unlock_std_streams. (rtx_reader::~rtx_reader): Clean up m_base_dir, and clean up the new fields. (rtx_reader::read_md_files): Move initializations of various global data from here to the ctor. * read-md.h (read_name): Convert to... (rtx_reader::read_name): ...member function. (rtx_reader::read_escape): New method decl. (read_quoted_string): Convert to... (rtx_reader::read_quoted_string): ...member function. (rtx_reader::read_braced_string): New method decl. (read_string): Convert to... (rtx_reader::read_string): ...member function. (rtx_reader::read_skip_construct): New method decl. (rtx_reader::set_md_ptr_loc): New method decl. (rtx_reader::get_md_ptr_loc): New method decl. (copy_md_ptr_loc): Convert to... (rtx_reader::copy_md_ptr_loc): ...member function. (fprint_md_ptr_loc): Convert to... (rtx_reader::fprint_md_ptr_loc): ...member function. (print_md_ptr_loc): Convert to... (rtx_reader::print_md_ptr_loc): ...member function. (rtx_reader::lookup_enum_type): New method decl. (rtx_reader::traverse_enum_types): New method decl. (rtx_reader::handle_constants): New method decl. (traverse_md_constants): Convert to... (rtx_reader::traverse_md_constants): ...member function. (rtx_reader::handle_enum): New method decl. (rtx_reader::join_c_conditions): New method decl. (fprint_c_condition): Convert to... (rtx_reader::fprint_c_condition): ...member function. (print_c_condition): Convert to... (rtx_reader::print_c_condition): ...member function. (rtx_reader::apply_iterator_to_string): New method decl. (rtx_reader::copy_rtx_for_iterators): New method decl. (rtx_reader::read_conditions): New method decl. (rtx_reader::record_potential_iterator_use): New method decl. (rtx_reader::read_mapping): New method decl. (rtx_reader::read_rtx): New method decl. (rtx_reader::read_rtx_code): New method decl. (rtx_reader::read_rtx_operand): New method decl. (rtx_reader::read_nested_rtx): New method decl. (rtx_reader::read_rtx_variadic): New method decl. (rtx_reader::get_string_obstack): New method. (rtx_reader::get_md_constants): New method. (string_obstack): Convert global variable decl to... (rtx_reader::m_string_obstack): ...this new field. (rtx_reader::m_ptr_locs): New field. (rtx_reader::m_ptr_loc_obstack): New field. (rtx_reader::m_joined_conditions): New field. (rtx_reader::m_joined_conditions_obstack): New field. (rtx_reader::m_md_constants): New field. (rtx_reader::m_enum_types): New field. * read-rtl.c (apply_iterator_to_string): Convert to... (rtx_reader::apply_iterator_to_string): ...member function. (copy_rtx_for_iterators): Convert to... (rtx_reader::copy_rtx_for_iterators): ...member function. (add_condition_to_string): Use rtx_reader_ptr for calls join_c_conditions. (apply_iterators): Use rtx_reader_ptr for calls to join_c_conditions and copy_rtx_for_iterators. (read_conditions): Convert to... (rtx_reader::read_conditions): ...member function. (record_potential_iterator_use): Convert to... (rtx_reader::record_potential_iterator_use): ...member function. (read_mapping): Convert to... (rtx_reader::read_mapping): ...member function. (read_subst_mapping): Use rtx_reader_ptr for read_string call. (read_rtx): Convert to... (rtx_reader::read_rtx): ...member function. (read_rtx_code): Convert to... (rtx_reader::read_rtx_code): ...member function. (read_rtx_operand): Convert to... (rtx_reader::read_rtx_operand): ...member function. Update for move of string_obstack to a field. (read_nested_rtx): Convert to.. (rtx_reader::read_nested_rtx): ...member function. (read_rtx_variadic): Convert to.. (rtx_reader::read_rtx_variadic): ...member function. From-SVN: r241293
2016-10-18 02:19:17 +02:00
#include "statistics.h"
#include "vec.h"
Makefile.in (build/genmddeps.o): Depend on $(READ_MD_H). gcc/ * Makefile.in (build/genmddeps.o): Depend on $(READ_MD_H). * genmddeps.c: Include read-md.h. (main): Call init_rtx_reader_args instead of init_md_reader_args. * genattr.c (main): Likewise. * genattrtab.c (main): Likewise. * genautomata.c (main): Likewise. * gencodes.c (main): Likewise. * genconditions.c (main): Likewise. * genconfig.c (main): Likewise. * genconstants.c (main): Likewise. * genemit.c (main): Likewise. * genextract.c (main): Likewise. * genflags.c (main): Likewise. * genopinit.c (main): Likewise. * genoutput.c (main): Likewise. * genpeep.c (main): Likewise. * genrecog.c (main): Likewise. * genpreds.c (main): Likewise. * gensupport.h (in_fname): Move to read-md.h. (init_md_reader_args_cb): Rename to... (init_rtx_reader_args_cb): ...this and return a bool. (init_md_reader_args): Rename to... (init_rtx_reader_args): ...this and return a bool. (include_callback): Move to read-md.h. * gensupport.c (in_fname, include_callback, base_dir, max_include_len) (file_name_list, first_dir_md_include): Move to read-md.c (first_bracket_include): Delete unused variable. (last_dir_md_include): Move to read-md.c. (process_include): Delete, moving code to read-md.c:handle_include. (process_rtx): Don't handle INCLUDE. (save_string): Delete. (rtx_handle_directive): New function. (init_md_reader_args_cb): Rename to... (init_rtx_reader_args_cb): ...this and return a boolean success value. Use read_md_args. (init_md_reader_args): Rename to... (init_rtx_reader_args): ...this and return a boolean success value. * rtl.def (INCLUDE): Delete. * rtl.h (read_rtx): Remove "int *" argument. Add "const char *" argument. * read-rtl.c (read_conditions): Don't gobble ')' here. (read_mapping): Likewise. (read_rtx): Remove LINENO argument. Add RTX_NAME argument. Handle top-level non-rtx constructs here rather than in read_rtx_1. Store the whole queue in *X. Remove call to init_md_reader. (read_rtx_1): Rename to... (read_rtx_code): ...this. Call read_nested_rtx to read subrtxes. Don't handle top-level non-rtx constructs here. Don't handle (nil) here. (read_nested_rtx): New function. Handle (nil) here rather than in read_rtx_code. (read_rtx_variadic): Call read_nested_rtx to read subrtxes. Don't gobble ')' here. * read-md.h (directive_handler_t): New type. (in_fname, include_callback): Moved from read-md.h. (read_constants, init_md_reader): Delete. (read_md_files): Declare. * read-md.c (file_name_list, in_fname, base_dir, first_dir_md_include) (last_dir_md_include_ptr, include_callback, max_include_len): Moved from gensupport.c. (read_constants): Rename to... (handle_constants): ...this. Don't gobble ')' here. (handle_include, handle_file, handle_toplevel_file) (parse_include): New functions, mostly taken from gensupport.c. (init_md_reader): Subsume into... (read_md_files): ...this new function. From-SVN: r160577
2010-06-10 22:23:13 +02:00
#include "read-md.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, const char **argv)
{
struct filedep *d;
progname = "genmddeps";
include_callback = add_filedep;
Remove trailing white spaces. 2009-11-25 H.J. Lu <hongjiu.lu@intel.com> * alias.c: Remove trailing white spaces. * alloc-pool.c: Likewise. * alloc-pool.h: Likewise. * attribs.c: Likewise. * auto-inc-dec.c: Likewise. * basic-block.h: Likewise. * bb-reorder.c: Likewise. * bt-load.c: Likewise. * builtins.c: Likewise. * builtins.def: Likewise. * c-common.c: Likewise. * c-common.h: Likewise. * c-cppbuiltin.c: Likewise. * c-decl.c: Likewise. * c-format.c: Likewise. * c-lex.c: Likewise. * c-omp.c: Likewise. * c-opts.c: Likewise. * c-parser.c: Likewise. * c-pretty-print.c: Likewise. * c-tree.h: Likewise. * c-typeck.c: Likewise. * caller-save.c: Likewise. * calls.c: Likewise. * cfg.c: Likewise. * cfganal.c: Likewise. * cfgexpand.c: Likewise. * cfghooks.c: Likewise. * cfghooks.h: Likewise. * cfglayout.c: Likewise. * cfgloop.c: Likewise. * cfgloop.h: Likewise. * cfgloopmanip.c: Likewise. * cfgrtl.c: Likewise. * cgraph.c: Likewise. * cgraph.h: Likewise. * cgraphbuild.c: Likewise. * cgraphunit.c: Likewise. * cif-code.def: Likewise. * collect2.c: Likewise. * combine.c: Likewise. * convert.c: Likewise. * coverage.c: Likewise. * crtstuff.c: Likewise. * cse.c: Likewise. * cselib.c: Likewise. * dbgcnt.c: Likewise. * dbgcnt.def: Likewise. * dbgcnt.h: Likewise. * dbxout.c: Likewise. * dce.c: Likewise. * ddg.c: Likewise. * ddg.h: Likewise. * defaults.h: Likewise. * df-byte-scan.c: Likewise. * df-core.c: Likewise. * df-problems.c: Likewise. * df-scan.c: Likewise. * df.h: Likewise. * dfp.c: Likewise. * diagnostic.c: Likewise. * diagnostic.h: Likewise. * dominance.c: Likewise. * domwalk.c: Likewise. * double-int.c: Likewise. * double-int.h: Likewise. * dse.c: Likewise. * dwarf2asm.c: Likewise. * dwarf2asm.h: Likewise. * dwarf2out.c: Likewise. * ebitmap.c: Likewise. * ebitmap.h: Likewise. * emit-rtl.c: Likewise. * et-forest.c: Likewise. * except.c: Likewise. * except.h: Likewise. * expmed.c: Likewise. * expr.c: Likewise. * expr.h: Likewise. * final.c: Likewise. * flags.h: Likewise. * fold-const.c: Likewise. * function.c: Likewise. * function.h: Likewise. * fwprop.c: Likewise. * gcc.c: Likewise. * gcov-dump.c: Likewise. * gcov-io.c: Likewise. * gcov-io.h: Likewise. * gcov.c: Likewise. * gcse.c: Likewise. * genattr.c: Likewise. * genattrtab.c: Likewise. * genautomata.c: Likewise. * genchecksum.c: Likewise. * genconfig.c: Likewise. * genflags.c: Likewise. * gengtype-parse.c: Likewise. * gengtype.c: Likewise. * gengtype.h: Likewise. * genmddeps.c: Likewise. * genmodes.c: Likewise. * genopinit.c: Likewise. * genpreds.c: Likewise. * gensupport.c: Likewise. * ggc-common.c: Likewise. * ggc-page.c: Likewise. * ggc-zone.c: Likewise. * ggc.h: Likewise. * gimple-iterator.c: Likewise. * gimple-low.c: Likewise. * gimple-pretty-print.c: Likewise. * gimple.c: Likewise. * gimple.def: Likewise. * gimple.h: Likewise. * gimplify.c: Likewise. * graphds.c: Likewise. * graphite-clast-to-gimple.c: Likewise. * gthr-nks.h: Likewise. * gthr-posix.c: Likewise. * gthr-posix.h: Likewise. * gthr-posix95.h: Likewise. * gthr-single.h: Likewise. * gthr-tpf.h: Likewise. * gthr-vxworks.h: Likewise. * gthr.h: Likewise. * haifa-sched.c: Likewise. * hard-reg-set.h: Likewise. * hooks.c: Likewise. * hooks.h: Likewise. * hosthooks.h: Likewise. * hwint.h: Likewise. * ifcvt.c: Likewise. * incpath.c: Likewise. * init-regs.c: Likewise. * integrate.c: Likewise. * ipa-cp.c: Likewise. * ipa-inline.c: Likewise. * ipa-prop.c: Likewise. * ipa-pure-const.c: Likewise. * ipa-reference.c: Likewise. * ipa-struct-reorg.c: Likewise. * ipa-struct-reorg.h: Likewise. * ipa-type-escape.c: Likewise. * ipa-type-escape.h: Likewise. * ipa-utils.c: Likewise. * ipa-utils.h: Likewise. * ipa.c: Likewise. * ira-build.c: Likewise. * ira-color.c: Likewise. * ira-conflicts.c: Likewise. * ira-costs.c: Likewise. * ira-emit.c: Likewise. * ira-int.h: Likewise. * ira-lives.c: Likewise. * ira.c: Likewise. * jump.c: Likewise. * lambda-code.c: Likewise. * lambda-mat.c: Likewise. * lambda-trans.c: Likewise. * lambda.h: Likewise. * langhooks.c: Likewise. * lcm.c: Likewise. * libgcov.c: Likewise. * lists.c: Likewise. * loop-doloop.c: Likewise. * loop-init.c: Likewise. * loop-invariant.c: Likewise. * loop-iv.c: Likewise. * loop-unroll.c: Likewise. * lower-subreg.c: Likewise. * lto-cgraph.c: Likewise. * lto-compress.c: Likewise. * lto-opts.c: Likewise. * lto-section-in.c: Likewise. * lto-section-out.c: Likewise. * lto-streamer-in.c: Likewise. * lto-streamer-out.c: Likewise. * lto-streamer.c: Likewise. * lto-streamer.h: Likewise. * lto-symtab.c: Likewise. * lto-wpa-fixup.c: Likewise. * matrix-reorg.c: Likewise. * mcf.c: Likewise. * mode-switching.c: Likewise. * modulo-sched.c: Likewise. * omega.c: Likewise. * omega.h: Likewise. * omp-low.c: Likewise. * optabs.c: Likewise. * optabs.h: Likewise. * opts-common.c: Likewise. * opts.c: Likewise. * params.def: Likewise. * params.h: Likewise. * passes.c: Likewise. * plugin.c: Likewise. * postreload-gcse.c: Likewise. * postreload.c: Likewise. * predict.c: Likewise. * predict.def: Likewise. * pretty-print.c: Likewise. * pretty-print.h: Likewise. * print-rtl.c: Likewise. * print-tree.c: Likewise. * profile.c: Likewise. * read-rtl.c: Likewise. * real.c: Likewise. * recog.c: Likewise. * reg-stack.c: Likewise. * regcprop.c: Likewise. * reginfo.c: Likewise. * regmove.c: Likewise. * regrename.c: Likewise. * regs.h: Likewise. * regstat.c: Likewise. * reload.c: Likewise. * reload1.c: Likewise. * resource.c: Likewise. * rtl.c: Likewise. * rtl.def: Likewise. * rtl.h: Likewise. * rtlanal.c: Likewise. * sbitmap.c: Likewise. * sched-deps.c: Likewise. * sched-ebb.c: Likewise. * sched-int.h: Likewise. * sched-rgn.c: Likewise. * sched-vis.c: Likewise. * sdbout.c: Likewise. * sel-sched-dump.c: Likewise. * sel-sched-dump.h: Likewise. * sel-sched-ir.c: Likewise. * sel-sched-ir.h: Likewise. * sel-sched.c: Likewise. * sel-sched.h: Likewise. * sese.c: Likewise. * sese.h: Likewise. * simplify-rtx.c: Likewise. * stack-ptr-mod.c: Likewise. * stmt.c: Likewise. * stor-layout.c: Likewise. * store-motion.c: Likewise. * stringpool.c: Likewise. * stub-objc.c: Likewise. * sync-builtins.def: Likewise. * target-def.h: Likewise. * target.h: Likewise. * targhooks.c: Likewise. * targhooks.h: Likewise. * timevar.c: Likewise. * tlink.c: Likewise. * toplev.c: Likewise. * toplev.h: Likewise. * tracer.c: Likewise. * tree-affine.c: Likewise. * tree-affine.h: Likewise. * tree-browser.def: Likewise. * tree-call-cdce.c: Likewise. * tree-cfg.c: Likewise. * tree-cfgcleanup.c: Likewise. * tree-chrec.c: Likewise. * tree-chrec.h: Likewise. * tree-complex.c: Likewise. * tree-data-ref.c: Likewise. * tree-data-ref.h: Likewise. * tree-dfa.c: Likewise. * tree-dump.c: Likewise. * tree-dump.h: Likewise. * tree-eh.c: Likewise. * tree-flow-inline.h: Likewise. * tree-flow.h: Likewise. * tree-if-conv.c: Likewise. * tree-inline.c: Likewise. * tree-into-ssa.c: Likewise. * tree-loop-distribution.c: Likewise. * tree-loop-linear.c: Likewise. * tree-mudflap.c: Likewise. * tree-nested.c: Likewise. * tree-nomudflap.c: Likewise. * tree-nrv.c: Likewise. * tree-object-size.c: Likewise. * tree-optimize.c: Likewise. * tree-outof-ssa.c: Likewise. * tree-parloops.c: Likewise. * tree-pass.h: Likewise. * tree-phinodes.c: Likewise. * tree-predcom.c: Likewise. * tree-pretty-print.c: Likewise. * tree-profile.c: Likewise. * tree-scalar-evolution.c: Likewise. * tree-ssa-address.c: Likewise. * tree-ssa-alias.c: Likewise. * tree-ssa-ccp.c: Likewise. * tree-ssa-coalesce.c: Likewise. * tree-ssa-copy.c: Likewise. * tree-ssa-copyrename.c: Likewise. * tree-ssa-dce.c: Likewise. * tree-ssa-dom.c: Likewise. * tree-ssa-dse.c: Likewise. * tree-ssa-forwprop.c: Likewise. * tree-ssa-ifcombine.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-live.h: Likewise. * tree-ssa-loop-ch.c: Likewise. * tree-ssa-loop-im.c: Likewise. * tree-ssa-loop-ivcanon.c: Likewise. * tree-ssa-loop-ivopts.c: Likewise. * tree-ssa-loop-manip.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-loop-prefetch.c: Likewise. * tree-ssa-loop-unswitch.c: Likewise. * tree-ssa-loop.c: Likewise. * tree-ssa-math-opts.c: Likewise. * tree-ssa-operands.c: Likewise. * tree-ssa-operands.h: Likewise. * tree-ssa-phiopt.c: Likewise. * tree-ssa-phiprop.c: Likewise. * tree-ssa-pre.c: Likewise. * tree-ssa-propagate.c: Likewise. * tree-ssa-reassoc.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-sink.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa-ter.c: Likewise. * tree-ssa-threadedge.c: Likewise. * tree-ssa-threadupdate.c: Likewise. * tree-ssa-uncprop.c: Likewise. * tree-ssa.c: Likewise. * tree-ssanames.c: Likewise. * tree-switch-conversion.c: Likewise. * tree-tailcall.c: Likewise. * tree-vect-data-refs.c: Likewise. * tree-vect-generic.c: Likewise. * tree-vect-loop-manip.c: Likewise. * tree-vect-loop.c: Likewise. * tree-vect-patterns.c: Likewise. * tree-vect-slp.c: Likewise. * tree-vect-stmts.c: Likewise. * tree-vectorizer.c: Likewise. * tree-vectorizer.h: Likewise. * tree-vrp.c: Likewise. * tree.c: Likewise. * tree.def: Likewise. * tree.h: Likewise. * treestruct.def: Likewise. * unwind-compat.c: Likewise. * unwind-dw2-fde-glibc.c: Likewise. * unwind-dw2.c: Likewise. * value-prof.c: Likewise. * value-prof.h: Likewise. * var-tracking.c: Likewise. * varasm.c: Likewise. * varpool.c: Likewise. * vec.c: Likewise. * vec.h: Likewise. * vmsdbgout.c: Likewise. * web.c: Likewise. * xcoffout.c: Likewise. From-SVN: r154645
2009-11-25 11:55:54 +01:00
Introduce class rtx_reader Bundle up various global variables within gensupport.c into a class rtx_reader, with a view towards making it easier to run the code more than once in-process. gcc/ChangeLog: * genconstants.c (main): Introduce noop_reader and convert call to read_md_files to a method call. * genenums.c (main): Likewise. * genmddeps.c (main): Likewise. * genpreds.c (write_tm_constrs_h): Replace use of "in_fname" with rtx_reader_ptr->get_top_level_filename (). (write_tm_preds_h): Likewise. (write_insn_preds_c): Likewise. * gensupport.c (class gen_reader): New subclass of rtx_reader. (rtx_handle_directive): Convert to... (gen_reader::handle_unknown_directive): ...this. (init_rtx_reader_args_cb): Convert return type from bool to rtx_reader *. Create a gen_reader instance, using it for the call to read_md_files. Return it if no errors occur. (init_rtx_reader_args): Convert return type from bool to rtx_reader *. * gensupport.h (init_rtx_reader_args_cb): Likewise. (init_rtx_reader_args_cb): Likewise. * read-md.c (struct file_name_list): Move to class rtx_reader. (read_md_file): Delete in favor of rtx_reader::m_read_md_file. (read_md_filename): Delete in favor of rtx_reader::m_read_md_filename. (read_md_lineno): Delete in favor of rtx_reader::m_read_md_lineno. (in_fname): Delete in favor of rtx_reader::m_toplevel_fname. (base_dir): Delete in favor of rtx_reader::m_base_dir. (first_dir_md_include): Delete in favor of rtx_reader::m_first_dir_md_include. (last_dir_md_include_ptr): Delete in favor of rtx_reader::m_last_dir_md_include_ptr. (max_include_len): Delete. (rtx_reader_ptr): New. (fatal_with_file_and_line): Use get_filename and get_lineno accessors of rtx_reader_ptr. (require_char_ws): Likewise. (rtx_reader::read_char): New method, based on ::read_char. (rtx_reader::unread_char): New method, based on ::unread_char. (read_escape): Use get_filename and get_lineno accessors of rtx_reader_ptr. (read_braced_string): Use get_lineno accessor of rtx_reader_ptr. (read_string): Use get_filename and get_lineno accessors of rtx_reader_ptr. (rtx_reader::rtx_reader): New ctor. (rtx_reader::~rtx_reader): New dtor. (handle_include): Convert from a function to... (rtx_reader::handle_include): ...this method, converting handle_directive from a callback to a virtual function. (handle_file): Likewise, converting to... (rtx_reader::handle_file): ...this method. (handle_toplevel_file): Likewise, converting to... (rtx_reader::handle_toplevel_file): ...this method. (rtx_reader::get_current_location): New method. (parse_include): Convert from a function to... (rtx_reader::add_include_path): ...this method, dropping redundant update to unused max_include_len. (read_md_files): Convert from a function to... (rtx_reader::read_md_files): ...this method, converting handle_directive from a callback to a virtual function. (noop_reader::handle_unknown_directive): New method. * read-md.h (directive_handler_t): Delete this typedef. (in_fname): Delete. (read_md_file): Delete. (read_md_lineno): Delete. (read_md_filename): Delete. (class rtx_reader): New class. (rtx_reader_ptr): New decl. (class noop_reader): New subclass of rtx_reader. (read_char): Reimplement in terms of rtx_reader::read_char. (unread_char): Reimplement in terms of rtx_reader::unread_char. (read_md_files): Delete. * read-rtl.c (read_rtx_code): Update for deletion of globals read_md_filename and read_md_lineno. From-SVN: r240333
2016-09-21 22:55:06 +02:00
noop_reader reader;
if (!reader.read_md_files (argc, argv, NULL))
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);
}