From patchwork Sat Aug 25 15:04:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 179974 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 2569E2C0102 for ; Sun, 26 Aug 2012 01:04:27 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1346511868; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=d2d9YvR+dVDJk+/oSVNrMV8ojUc=; b=ngkTUFHnq4yIqbd2YYUDjzUN6SIvmVVjDPcGU+DXvHj7A1kaC+HTYK/rpmAZCU J6fgAhwF+80gMKuP3CwIufjhJU96K50+cIjzcFyd/Dn9oxml9F9PBA7hWjB87gxo 9ZvFyxQZAlcmAeceQVkENriosCS2+yZ86jyCj9fBuyFu8= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=KKZdudM7XwRYgP41MLgPzUdvx9frn0ze6FBE1xy4e5tfYSTwfm0I0e7s4ZKfjX tXBTNcQhDp8iMDuHptf6Wc61sXDZgGSMZNQ2Ey/ws14oKIa+2zxE6sqyFH0ROHM8 5IJGIFhsysbW18J6ecb7jrckjx1/0CweXLI7W5X0etYAQ=; Received: (qmail 7517 invoked by alias); 25 Aug 2012 15:04:21 -0000 Received: (qmail 7505 invoked by uid 22791); 25 Aug 2012 15:04:20 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-pb0-f47.google.com (HELO mail-pb0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 25 Aug 2012 15:04:06 +0000 Received: by pbcwy7 with SMTP id wy7so5136547pbc.20 for ; Sat, 25 Aug 2012 08:04:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.240.138 with SMTP id wa10mr20780951pbc.145.1345907045495; Sat, 25 Aug 2012 08:04:05 -0700 (PDT) Received: by 10.66.248.131 with HTTP; Sat, 25 Aug 2012 08:04:05 -0700 (PDT) In-Reply-To: References: <50366DE2.1010502@gjlay.de> <1345746440.2312.23.camel@yam-132-YW-E178-FTW> <5036969F.1050507@gjlay.de> <5038A118.6040904@gjlay.de> Date: Sat, 25 Aug 2012 17:04:05 +0200 Message-ID: Subject: [PATCH v2, middle-end]: Introduce TARGET_REJECT_COMBINED_INSN target hook From: Uros Bizjak To: gcc-patches@gcc.gnu.org Cc: Oleg Endo , Georg-Johann Lay , Richard Guenther , Jakub Jelinek , Yuri Rumyantsev , Igor Zamyatin , "Joseph S. Myers" Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hello! v2 patch differences: - moves hook description text to target.def - fixes error path to clear clobbers, as expected by recog_for_combine callers 2012-08-25 Uros Bizjak * target.def (reject_combined_insn): New target hook. * doc/tm.texi.in (TARGET_REJECT_COMBINED_INSN): New hook. * doc/tm.texi: Regenerated. * combine.c (recog_for_combine): Call targetm.reject_combined_insn to allow targets to reject combined insn. Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32}. OK for mainline? Uros. Index: target.def =================================================================== --- target.def (revision 190665) +++ target.def (working copy) @@ -1984,7 +1984,16 @@ DEFHOOK const char *, (const_rtx insn), default_invalid_within_doloop) +/* Returns true if the combined insn should be rejected + for some reason. */ DEFHOOK +(reject_combined_insn, +"Take an instruction in @var{insn} and return @code{true} if the instruction\ + should be rejected as a combination of two or more instructions.", + bool, (rtx insn), + hook_bool_rtx_false) + +DEFHOOK (valid_dllimport_attribute_p, "@var{decl} is a variable or function with @code{__attribute__((dllimport))}\ specified. Use this hook if the target needs to add extra validation\ Index: combine.c =================================================================== --- combine.c (revision 190665) +++ combine.c (working copy) @@ -10500,11 +10500,13 @@ static int recog_for_combine (rtx *pnewpat, rtx insn, rtx *pnotes) { rtx pat = *pnewpat; + rtx pat_without_clobbers; int insn_code_number; int num_clobbers_to_add = 0; int i; - rtx notes = 0; + rtx notes = NULL_RTX; rtx old_notes, old_pat; + int old_icode; /* If PAT is a PARALLEL, check to see if it contains the CLOBBER we use to indicate that something didn't match. If we find such a @@ -10518,7 +10520,7 @@ recog_for_combine (rtx *pnewpat, rtx insn, rtx *pn old_pat = PATTERN (insn); old_notes = REG_NOTES (insn); PATTERN (insn) = pat; - REG_NOTES (insn) = 0; + REG_NOTES (insn) = NULL_RTX; insn_code_number = recog (pat, insn, &num_clobbers_to_add); if (dump_file && (dump_flags & TDF_DETAILS)) @@ -10564,6 +10566,9 @@ recog_for_combine (rtx *pnewpat, rtx insn, rtx *pn print_rtl_single (dump_file, pat); } } + + pat_without_clobbers = pat; + PATTERN (insn) = old_pat; REG_NOTES (insn) = old_notes; @@ -10605,6 +10610,35 @@ recog_for_combine (rtx *pnewpat, rtx insn, rtx *pn pat = newpat; } + if (insn_code_number >= 0 + && insn_code_number != NOOP_MOVE_INSN_CODE) + { + old_pat = PATTERN (insn); + old_notes = REG_NOTES (insn); + old_icode = INSN_CODE (insn); + PATTERN (insn) = pat; + REG_NOTES (insn) = notes; + + /* Allow targets to reject combined insn. */ + if (targetm.reject_combined_insn (insn)) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fputs ("Instruction not appropriate for target.", + dump_file); + + /* Callers expect recog_for_combine to strip + clobbers from the pattern on failure. */ + pat = pat_without_clobbers; + notes = NULL_RTX; + + insn_code_number = -1; + } + + PATTERN (insn) = old_pat; + REG_NOTES (insn) = old_notes; + INSN_CODE (insn) = old_icode; + } + *pnewpat = pat; *pnotes = notes; Index: doc/tm.texi =================================================================== --- doc/tm.texi (revision 190665) +++ doc/tm.texi (working copy) @@ -10938,6 +10938,10 @@ By default, the RTL loop optimizer does not use a loops containing function calls or branch on table instructions. @end deftypefn +@deftypefn {Target Hook} bool TARGET_REJECT_COMBINED_INSN (rtx @var{insn}) +Take an instruction in @var{insn} and return @code{true} if the instruction should be rejected as a combination of two or more instructions. +@end deftypefn + @defmac MD_CAN_REDIRECT_BRANCH (@var{branch1}, @var{branch2}) Take a branch insn in @var{branch1} and another in @var{branch2}. Index: doc/tm.texi.in =================================================================== --- doc/tm.texi.in (revision 190665) +++ doc/tm.texi.in (working copy) @@ -10796,6 +10796,8 @@ By default, the RTL loop optimizer does not use a loops containing function calls or branch on table instructions. @end deftypefn +@hook TARGET_REJECT_COMBINED_INSN + @defmac MD_CAN_REDIRECT_BRANCH (@var{branch1}, @var{branch2}) Take a branch insn in @var{branch1} and another in @var{branch2}.