From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 100441 invoked by alias); 16 Sep 2016 21:42:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 100414 invoked by uid 89); 16 Sep 2016 21:42:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=reader, policy X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 16 Sep 2016 21:42:28 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7EEBA83F42 for ; Fri, 16 Sep 2016 21:42:27 +0000 (UTC) Received: from vpn-233-121.phx2.redhat.com (vpn-233-121.phx2.redhat.com [10.3.233.121]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8GLgQ9k029854; Fri, 16 Sep 2016 17:42:27 -0400 Message-ID: <1474062146.6782.109.camel@redhat.com> Subject: Re: [PATCH 5/9] Introduce class function_reader From: David Malcolm To: Jeff Law , gcc-patches@gcc.gnu.org Date: Fri, 16 Sep 2016 22:04:00 -0000 In-Reply-To: <37a05f4a-a2aa-9c3e-000b-68aa691723e9@redhat.com> References: <1473381053-18817-1-git-send-email-dmalcolm@redhat.com> <1473381053-18817-6-git-send-email-dmalcolm@redhat.com> <37a05f4a-a2aa-9c3e-000b-68aa691723e9@redhat.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-09/txt/msg01107.txt.bz2 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