From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14343 invoked by alias); 26 Jun 2015 08:36:22 -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 14330 invoked by uid 89); 26 Jun 2015 08:36:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00,KAM_ASCII_DIVIDERS,SPF_PASS autolearn=no version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 26 Jun 2015 08:36:20 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-25-_fJbx2bKQLmYH-e0Qzp0lQ-1 Received: from localhost ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 26 Jun 2015 09:36:17 +0100 From: Richard Sandiford To: Markus Trippelsdorf Mail-Followup-To: Markus Trippelsdorf ,gcc-patches@gcc.gnu.org, Mikhail Maltsev , richard.sandiford@arm.com Cc: gcc-patches@gcc.gnu.org, Mikhail Maltsev Subject: Re: Add .def file for public target instructions References: <87ioaegtcp.fsf@googlemail.com> <20150626070647.GA402@x4> Date: Fri, 26 Jun 2015 08:45:00 -0000 In-Reply-To: <20150626070647.GA402@x4> (Markus Trippelsdorf's message of "Fri, 26 Jun 2015 09:06:47 +0200") Message-ID: <878ub6rhmn.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-MC-Unique: _fJbx2bKQLmYH-e0Qzp0lQ-1 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2015-06/txt/msg01901.txt.bz2 Markus Trippelsdorf writes: > On 2015.06.23 at 19:41 +0100, Richard Sandiford wrote: >>=20 >> gcc/ >> * Makefile.in (TARGET_DEF): Add target-insns.def. >> (.PRECIOUS, simple_rtl_generated_h): Add insn-target-def.h. >> (build/gentarget-def.o): New rule. >> (genprogrtl): Add target-def. >> * target-insns.def, gentarget-def.c: New files. >> * target.def: Add targetm.have_* and targetm.gen_* hooks, >> based on the contents of target-insns.def. >> * defaults.h (HAVE_simple_return, gen_simple_return): Delete. >> (HAVE_return, gen_return): Delete. >> * target-def.h: Include insn-target-def.h. >> * cfgrtl.c (force_nonfallthru_and_redirect): Use targetm interface >> instead of direct calls. Rely on them to do the appropriate assertions. >> * function.c (gen_return_pattern): Likewise. Return an rtx_insn *. >> (convert_jumps_to_returns): Use targetm interface instead of >> direct calls. >> (thread_prologue_and_epilogue_insns): Likewise. >> * reorg.c (find_end_label, dbr_schedule): Likewise. >> * shrink-wrap.h (SHRINK_WRAPPING_ENABLED): Likewise. >> * shrink-wrap.c (convert_to_simple_return): Likewise. >> (try_shrink_wrapping): Use SHRINK_WRAPPING_ENABLED. > > The patch breaks bootstrap on ppc64le. During libgcc configuration: Yeah, sorry about that. The problem is due to confusion about whether the generator should emit a barrier or not. After the final instruction in a sequence, it should always be up to the caller to insert any necessary barriers, just like it is for define_insns, and for define_expands implemented in C++ with DONE. I'm testing the following patch. Thanks, Richard gcc/ * rtl.h (emit): Add an optional boolean parameter to control whether barriers are emitted. * emit-rtl.c (emit): Likewise. * gensupport.c (get_emit_function): Return null rather than "emit". * genemit.c (gen_emit_seq): Handle the null return value. Don't emit barriers after the final instruction in the sequence. * gentarget-def.c (main): Don't emit barriers after the instruction. Index: gcc/rtl.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/rtl.h 2015-06-26 09:09:10.128602409 +0100 +++ gcc/rtl.h 2015-06-26 09:09:10.316600233 +0100 @@ -3494,7 +3494,7 @@ extern void add_insn (rtx_insn *); extern void add_insn_before (rtx, rtx, basic_block); extern void add_insn_after (rtx, rtx, basic_block); extern void remove_insn (rtx); -extern rtx_insn *emit (rtx); +extern rtx_insn *emit (rtx, bool =3D true); extern void emit_insn_at_entry (rtx); extern rtx gen_lowpart_SUBREG (machine_mode, rtx); extern rtx gen_const_mem (machine_mode, rtx); Index: gcc/emit-rtl.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/emit-rtl.c 2015-06-26 09:09:10.124602455 +0100 +++ gcc/emit-rtl.c 2015-06-26 09:09:10.316600233 +0100 @@ -5303,11 +5303,14 @@ set_dst_reg_note (rtx insn, enum reg_not return NULL_RTX; } =0C -/* Emit the rtl pattern X as an appropriate kind of insn. +/* Emit the rtl pattern X as an appropriate kind of insn. Also emit a + following barrier if the instruction needs one and if ALLOW_BARRIER_P + is true. + If X is a label, it is simply added into the insn chain. */ =20 rtx_insn * -emit (rtx x) +emit (rtx x, bool allow_barrier_p) { enum rtx_code code =3D classify_insn (x); =20 @@ -5320,7 +5323,8 @@ emit (rtx x) case JUMP_INSN: { rtx_insn *insn =3D emit_jump_insn (x); - if (any_uncondjump_p (insn) || GET_CODE (x) =3D=3D RETURN) + if (allow_barrier_p + && (any_uncondjump_p (insn) || GET_CODE (x) =3D=3D RETURN)) return emit_barrier (); return insn; } Index: gcc/gensupport.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/gensupport.c 2015-06-26 09:09:10.124602455 +0100 +++ gcc/gensupport.c 2015-06-26 09:09:10.316600233 +0100 @@ -2983,7 +2983,9 @@ get_pattern_stats (struct pattern_stats stats->max_scratch_opno)) + 1; } =20 -/* Return the emit_* function that should be used for pattern X. */ +/* Return the emit_* function that should be used for pattern X, or NULL + if we can't pick a particular type at compile time and should instead + fall back to "emit". */ =20 const char * get_emit_function (rtx x) @@ -3000,7 +3002,7 @@ get_emit_function (rtx x) return "emit_jump_insn"; =20 case UNKNOWN: - return "emit"; + return NULL; =20 default: gcc_unreachable (); Index: gcc/genemit.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/genemit.c 2015-06-26 09:09:10.124602455 +0100 +++ gcc/genemit.c 2015-06-26 09:09:10.316600233 +0100 @@ -277,12 +277,22 @@ gen_emit_seq (rtvec vec, char *used) { for (int i =3D 0, len =3D GET_NUM_ELEM (vec); i < len; ++i) { + bool last_p =3D (i =3D=3D len - 1); rtx next =3D RTVEC_ELT (vec, i); - printf (" %s (", get_emit_function (next)); - gen_exp (next, DEFINE_EXPAND, used); - printf (");\n"); - if (needs_barrier_p (next)) - printf (" emit_barrier ();"); + if (const char *name =3D get_emit_function (next)) + { + printf (" %s (", name); + gen_exp (next, DEFINE_EXPAND, used); + printf (");\n"); + if (!last_p && needs_barrier_p (next)) + printf (" emit_barrier ();"); + } + else + { + printf (" emit ("); + gen_exp (next, DEFINE_EXPAND, used); + printf (", %s);\n", last_p ? "false" : "true"); + } } } =0C Index: gcc/gentarget-def.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/gentarget-def.c 2015-06-26 09:09:10.124602455 +0100 +++ gcc/gentarget-def.c 2015-06-26 09:09:10.316600233 +0100 @@ -245,7 +245,7 @@ main (int argc, char **argv) printf (" if (rtx_insn *insn =3D dyn_cast (x))\n"); printf (" return insn;\n"); printf (" start_sequence ();\n"); - printf (" emit (x);\n"); + printf (" emit (x, false);\n"); printf (" rtx_insn *res =3D get_insns ();\n"); printf (" end_sequence ();\n"); printf (" return res;\n");