public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Jeff Law <law@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 5/9] Introduce class function_reader
Date: Fri, 16 Sep 2016 22:04:00 -0000	[thread overview]
Message-ID: <1474062146.6782.109.camel@redhat.com> (raw)
In-Reply-To: <37a05f4a-a2aa-9c3e-000b-68aa691723e9@redhat.com>

On Fri, 2016-09-16 at 15:28 -0600, Jeff Law wrote:
> On 09/08/2016 06:30 PM, David Malcolm wrote:
> > This patch generalizes the RTL-reading capabilities so that they
> > can be run on the host as well as the build machine.
> > The available rtx in rtl.def changes dramatically between these
> > two configurations, so a fair amount of #ifdef GENERATOR_FILE is
> > required to express this.
> > 
> > This patch introduces a function_reader subclass of rtx_reader,
> > capable of reading an RTL function dump (or part of one),
> > reconstructing a cfun with a CFG and basic blocks containing insns.
> > 
> > gcc/ChangeLog:
> > 	* Makefile.in (OBJS): Add errors.o, read-md.o, read-rtl.o,
> > 	read-rtl-function.o, and selftest-rtl.o.
> 
> > 	* cfgexpand.c (pass_expand::execute): Move stack
> > initializations
> > 	to rtl_data::init_stack_alignment and call it.  Pass "true"
> > 	for new "emit_insns" param of expand_function_start.
> > 	* emit-rtl.c (gen_reg_rtx): Move regno_pointer_align and
> > 	regno_reg_rtx resizing logic to...
> > 	(emit_status::ensure_regno_capacity): ...this new method.
> > 	(init_emit): Allocate regno_reg_rtx using ggc_cleared_vec_alloc
> > 	rather than ggc_vec_alloc.
> > 	(rtl_data::init_stack_alignment): New method.
> > 	(get_insn_by_uid): New function.
> > 	* emit-rtl.h (rtl_data::init_stack_alignment): New method.
> > 	* errors.c: Use consistent pattern for bconfig.h vs config.h
> > 	includes.
> > 	(progname): Wrap with #ifdef GENERATOR_FILE.
> > 	(error): Likewise.  Add "error: " to message.
> > 	(fatal): Likewise.
> > 	(internal_error): Likewise.
> > 	(trim_filename): Likewise.
> > 	(fancy_abort): Likewise.
> > 	* errors.h (struct file_location): Move here from read-md.h.
> > 	(file_location::file_location): Likewise.
> > 	(error_at): New decl.
> > 	* function-tests.c (selftest::verify_three_block_rtl_cfg):
> > Remove
> > 	"static".
> > 	* function.c (instantiate_decls): Guard call to
> > 	instantiate_decls_1 with if (DECL_INITIAL (fndecl)).
> > 	(expand_function_start): Add param "emit_insns", and use it to
> > 	guard the various gen/emit calls.
> > 	* function.h (emit_status::ensure_regno_capacity): New method.
> > 	(expand_function_start): Add bool param to decl.
> > 	* gensupport.c (gen_reader::gen_reader): Add NULL for new
> > policy
> > 	param of rtx_reader ctor.
> > 	* print-rtl.c (print_rtx): Print "(nil)" rather than an empty
> > 	string for NULL strings.  Print "(nil)" for NULL basic blocks.
> > 	* read-md.c (read_skip_construct): Provide forward decl.
> > 	(read_skip_spaces): Support '/'.
> > 	(require_char): New function.
> > 	(require_word_ws): New function.
> > 	(peek_char): New function.
> > 	(read_name): Rename to...
> > 	(read_name_1): ...this new static function, adding "out_loc"
> > param,
> > 	and converting "missing name or number" to returning false,
> > rather
> > 	than failing.
> > 	(read_name): Reimplement in terms of read_name_1.
> > 	(read_name_or_nil): New function.
> > 	(read_string): Handle "(nil)" by returning NULL.  */
> > 	(rtx_reader::rtx_reader): Add rtl_reader_policy * param, using
> > 	it to initialize m_policy.
> > 	(rtx_reader::~rtx_reader): Free m_base_dir.  Clean up global
> > data.
> > 	* read-md.h (struct file_location): Move to errors.h.
> > 	(file_location::file_location): Likewise.
> > 	Include errors.h.
> > 	(class regno_remapper): New class.
> > 	(struct rtl_reader_policy): New struct.
> > 	(rtx_reader::rtx_reader): Add rtl_reader_policy * param.
> > 	(rtx_reader::add_fixup_insn_uid): New vfunc.
> > 	(rtx_reader::add_fixup_bb): New vfunc.
> > 	(rtx_reader::add_fixup_note_insn_basic_block): New vfunc.
> > 	(rtx_reader::add_fixup_source_location): New vfunc.
> > 	(rtx_reader::add_fixup_jump_label): New vfunc.
> > 	(rtx_reader::add_fixup_expr): New vfunc.
> > 	(rtx_reader::remap_regno): New method.
> > 	(rtx_reader::m_policy): New field.
> > 	(noop_reader::noop_reader): Add NULL for new policy param of
> > 	rtx_reader ctor.
> > 	(peek_char): New decl.
> > 	(require_char): New decl.
> > 	(require_word_ws): New decl.
> > 	(read_name): Convert return type from void to file_location.
> > 	(read_name_or_nil): New decl.
> > 	* read-rtl-function.c: New file.
> > 	* read-rtl-function.h: New file.
> > 	* read-rtl.c: Potentially include config.h rather than
> > bconfig.h.
> > 	For host, include function.h and emit-rtl.h.
> > 	(apply_subst_iterator): Wrap with #ifdef GENERATOR_FILE.
> > 	(bind_subst_iter_and_attr): Likewise.
> > 	(add_condition_to_string): Likewise.
> > 	(add_condition_to_rtx): Likewise.
> > 	(apply_attribute_uses): Likewise.
> > 	(add_current_iterators): Likewise.
> > 	(apply_iterators): Likewise.
> > 	(initialize_iterators): Guard usage of apply_subst_iterator
> > with
> > 	#ifdef GENERATOR_FILE.
> > 	(read_conditions): Wrap with #ifdef GENERATOR_FILE.
> > 	(read_mapping): Likewise.
> > 	(add_define_attr_for_define_subst): Likewise.
> > 	(add_define_subst_attr): Likewise.
> > 	(read_subst_mapping): Likewise.
> > 	(check_code_iterator): Likewise.
> > 	(read_rtx): Likewise.  Move one-time initialization logic to...
> > 	(one_time_initialization): New function.
> > 	(parse_reg_note_name): New function.
> > 	(parse_note_insn_name): New function.
> > 	(maybe_read_location): New function.
> > 	(read_until): New function.
> > 	(strip_trailing_whitespace): New function.
> > 	(read_flags): New function.
> > 	(regno_remapper::get_effective_regno): New method.
> > 	(rtx_reader::remap_regno): New method.
> > 	(read_rtx_code): Remove "static".  Initialize "iterator" to
> > NULL.
> > 	Call one_time_initialization.  Wrap iterator lookup within
> > 	#ifdef GENERATOR_FILE.  Add parsing support for RTL dumps,
> > 	mirroring the special-cases in print_rtx, by calling
> > 	read_flags, reading SYMBOL_REF data, REG_NOTE names,
> > 	INSN_UID values, note-specific data, basic block IDs,
> > 	jump labels, hexdump values of wide ints, REG_EXPR, MEM_EXPR,
> > 	skipping recognized insn names, remapping register numbers.
> > 	When on host, reallocate XSTR and XTMPL fields in the GC
> > -managed
> > 	heap.
> > 	(lookup_global_register): New function.
> > 	(consolidate_reg): New function.
> > 	(consolidate_singletons): New function.
> > 	(read_nested_rtx): Call consolidate_singletons.
> > 	* rtl.h (read_rtx): Wrap decl with #ifdef GENERATOR_FILE.
> > 	(read_rtx_code): New decl.
> > 	* selftest-rtl.c: New file.
> > 	* selftest-rtl.h: New file.
> > 	* selftest-run-tests.c (selftest::run_tests): Run
> > 	read_rtl_function_c_tests.
> > 	* selftest.h  (selftest::read_rtl_function_c_tests): New decl.
> > 	* tree-dfa.c (ssa_default_def): Return NULL_TREE for rtl
> > function
> > 	dumps.
> So I see a couple conceptual things going on here.
> 
> First is initialization/finalization/state handling and various
> fallout 
> items.  Essentially it encompasses all changes that we can make a
> case 
> are useful cleanups and should be handled independently.

I think you've described patch 1 of the kit :)

> Second is all the grunt work necessary to suck in a RTL reader into
> the 
> target's cc1.  The Makefile.in changes, all the GENERATOR_FILE stuff,
> and of course the new rtx_reader class, regno_mapper and the like.
> 
> I think that'll allow us to spend more time looking at the raw
> mechanics 
> of how to pull in an RTL reader into cc1.
> 
> Jeff

  reply	other threads:[~2016-09-16 21:42 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-09  0:01 [PATCH 0/9] RFC: selftests based on RTL dumps David Malcolm
2016-09-09  0:01 ` [PATCH 9/9] cse.c selftests David Malcolm
2016-09-16 20:34   ` Jeff Law
2016-09-16 21:28     ` David Malcolm
2016-09-19 17:37       ` Jeff Law
2016-09-22  3:23         ` [PATCH] Introduce selftest::locate_file David Malcolm
2016-09-28 16:33           ` Jeff Law
2016-09-09  0:01 ` [PATCH 4/9] Expose forcibly_ggc_collect and run it after all selftests David Malcolm
2016-09-16 20:30   ` Jeff Law
2016-09-09  0:01 ` [PATCH 6/9] df selftests David Malcolm
2016-09-16 20:40   ` Jeff Law
2016-09-16 21:34     ` David Malcolm
2016-09-09  0:01 ` [PATCH 8/9] final.c selftests David Malcolm
2016-09-16 21:12   ` Jeff Law
2016-09-16 21:41     ` David Malcolm
2016-09-19 21:38       ` Jeff Law
2016-09-09  0:01 ` [PATCH 1/9] Introduce class rtx_reader David Malcolm
2016-09-16 22:15   ` Jeff Law
2016-09-21 17:22     ` [PATCH, v2] " David Malcolm
2016-09-21 20:44       ` Richard Sandiford
2016-09-09  0:01 ` [PATCH 7/9] combine.c selftests David Malcolm
2016-09-16 20:45   ` Jeff Law
2016-09-16 21:39     ` David Malcolm
2016-09-09  0:01 ` [PATCH 3/9] selftest.h: add temp_override fixture David Malcolm
2016-09-14 22:24   ` Trevor Saunders
2016-09-16 20:37   ` Jeff Law
2016-09-09  0:01 ` [PATCH 2/9] Add selftest::read_file David Malcolm
2016-09-16 21:19   ` Jeff Law
2016-09-09  0:13 ` [PATCH 5/9] Introduce class function_reader David Malcolm
2016-09-16 21:31   ` Jeff Law
2016-09-16 22:04     ` David Malcolm [this message]
2016-09-19 21:39       ` Jeff Law
2016-09-12 14:14 ` [PATCH 0/9] RFC: selftests based on RTL dumps Bernd Schmidt
2016-09-12 18:59   ` David Malcolm
2016-09-13 11:35     ` Bernd Schmidt
2016-09-14 10:33       ` Bernd Schmidt
2016-09-16 20:26       ` Jeff Law
2016-09-16 21:28         ` David Malcolm
2016-09-19 17:50           ` Jeff Law
2016-09-20 14:34             ` Register numbers in RTL dumps (was Re: [PATCH 0/9] RFC: selftests based on RTL dumps) David Malcolm
2016-09-20 14:38               ` Bernd Schmidt
2016-09-20 15:26                 ` Jeff Law
2016-09-20 15:38                   ` Bernd Schmidt
2016-09-20 19:35                   ` David Malcolm
2016-09-21 18:59                     ` [PATCH] print-rtx.c: add 'h', v' and 'p' prefixes to regnos David Malcolm
2016-09-28 16:30                       ` Jeff Law
2016-09-28 16:33                         ` Bernd Schmidt
2016-09-28 17:11                           ` Jeff Law
2016-09-28 17:19                             ` Bernd Schmidt
2016-09-29 13:00                               ` David Malcolm
2016-09-29 17:32                               ` Jeff Law
2016-09-13 20:39     ` [PATCH 0/9] RFC: selftests based on RTL dumps Jeff Law
2016-09-14  8:44       ` Richard Biener
2016-09-16 20:16         ` Jeff Law
2016-09-16 21:27           ` David Malcolm
2016-09-19 12:21             ` Bernd Schmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1474062146.6782.109.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).