From patchwork Mon Dec 6 18:25:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 74421 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 16D34B708B for ; Tue, 7 Dec 2010 05:27:44 +1100 (EST) Received: (qmail 10033 invoked by alias); 6 Dec 2010 18:27:42 -0000 Received: (qmail 10022 invoked by uid 22791); 6 Dec 2010 18:27:41 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 06 Dec 2010 18:27:32 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id EE8C3CB0224; Mon, 6 Dec 2010 19:27:29 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 27GxZzw0-g+f; Mon, 6 Dec 2010 19:27:29 +0100 (CET) Received: from [192.168.1.2] (bon31-9-83-155-120-49.fbx.proxad.net [83.155.120.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 89CCCCB01B2; Mon, 6 Dec 2010 19:27:29 +0100 (CET) From: Eric Botcazou To: Yao Qi Subject: Re: [Ping] [patch 0/3] New macro PREFERRED_RENAME_CLASS Date: Mon, 6 Dec 2010 19:25:26 +0100 User-Agent: KMail/1.9.9 Cc: gcc-patches@gcc.gnu.org References: <4CD24091.1020904@codesourcery.com> <201012031157.20334.ebotcazou@adacore.com> <4CF8F991.4080304@codesourcery.com> In-Reply-To: <4CF8F991.4080304@codesourcery.com> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <201012061925.26662.ebotcazou@adacore.com> 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 > Seems I didn't understand targethook fully before. You are right. Done. Thanks. The patch is OK for mainline modulo the following last nits: + for (i = nregs - 1; i >= 0; --i) + if (TEST_HARD_REG_BIT (this_unavailable, new_reg + i) + || fixed_regs[new_reg + i] + || global_regs[new_reg + i] + /* Can't use regs which aren't saved by the prologue. */ + || (! df_regs_ever_live_p (new_reg + i) + && ! call_used_regs[new_reg + i]) +#ifdef LEAF_REGISTERS + /* We can't use a non-leaf register if we're in a + leaf function. */ + || (current_function_is_leaf + && !LEAF_REGISTERS[new_reg + i]) +#endif +#ifdef HARD_REGNO_RENAME_OK + || ! HARD_REGNO_RENAME_OK (reg + i, new_reg + i) +#endif + ) + break; + if (i >= 0) + return false; Just use "return false" instead of "break" and remove the "if (i >= 0)" test. + /* See whether it accepts all modes that occur in + definition and uses. */ + for (tmp = this_head->first; tmp; tmp = tmp->next_use) + if ((! HARD_REGNO_MODE_OK (new_reg, GET_MODE (*tmp->loc)) + && ! DEBUG_INSN_P (tmp->insn)) + || (this_head->need_caller_save_reg + && ! (HARD_REGNO_CALL_PART_CLOBBERED + (reg, GET_MODE (*tmp->loc))) + && (HARD_REGNO_CALL_PART_CLOBBERED + (new_reg, GET_MODE (*tmp->loc))))) + break; Likewise, you want "return false" here instead of "break". + /* The register iteration order here is "preferred-register-first". + Firstly(pass == 0), we iterate registers belong to PREFERRED_CLASS, + if we find a new register, we stop immeidately. immediately + /* Iterate registers first in prefered class. */ /* First iterate over registers in our preferred class. */ +reg_class_t +default_preferred_rename_class (reg_class_t rclass) +{ + return NO_REGS; +} + You'll probably need ATTRIBUTE_UNUSED to be able to bootstrap that. Also add the standard comment: /* The default implementation of TARGET_PREFERRED_RENAME_CLASS. */ in front of it. No need to re-submit: make the above changes, check that you still get the desired effect with the hook for the ARM, and bootstrap/regtest on a native platform. Thanks for your patience. --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -2496,6 +2496,8 @@ looking for one that is valid, and will reload one or both registers only if neither labeling works. @end defmac +@hook TARGET_PREFERRED_RENAME_CLASS + @hook TARGET_PREFERRED_RELOAD_CLASS A target hook that places additional restrictions on the register class to use when it is necessary to copy value @var{x} into a register in class It looks like most of the hooks have some text in tm.texi.in so I'd suggest writing a single sentence in target.def and move the rest of the text (with the example) to tm.texi.in. diff --git a/gcc/regrename.c b/gcc/regrename.c index 2535ab7..adbcde5 100644 --- a/gcc/regrename.c +++ b/gcc/regrename.c @@ -38,6 +38,7 @@ #include "timevar.h" #include "tree-pass.h" #include "df.h" +#include "target.h" You also need to add $(TARGET_H) to the regrename.o rule in Makefile.in.