From patchwork Mon Nov 1 12:09:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 69758 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 BA8661007D2 for ; Mon, 1 Nov 2010 23:10:21 +1100 (EST) Received: (qmail 27354 invoked by alias); 1 Nov 2010 12:10:17 -0000 Received: (qmail 27333 invoked by uid 22791); 1 Nov 2010 12:10:14 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 01 Nov 2010 12:10:03 +0000 Received: (qmail 3891 invoked from network); 1 Nov 2010 12:09:59 -0000 Received: from unknown (HELO ?192.168.0.100?) (yao@127.0.0.2) by mail.codesourcery.com with ESMTPA; 1 Nov 2010 12:09:59 -0000 Subject: Re: [patch 2/3] tm.texi documentation on macro PREFERRED_RENAME_CLASS From: Yao Qi To: Anatoly Sokolov Cc: gcc-patches@gcc.gnu.org In-Reply-To: <994BD5F896C4485BB72CE0F39FAB8367@Vista> References: <4CBFE0BD.3080807@codesourcery.com> <4CBFE30C.7090308@codesourcery.com> <1288145771.1793.103.camel@yaolp> <994BD5F896C4485BB72CE0F39FAB8367@Vista> Date: Mon, 01 Nov 2010 20:09:51 +0800 Message-ID: <1288613391.4864.4.camel@yaolp> Mime-Version: 1.0 X-IsSubscribed: yes 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 On Wed, 2010-10-27 at 20:22 +0400, Anatoly Sokolov wrote: > Hi > > Use reg_class_t instead of enum reg_class in midle end. > Hi, Anatoly, Changed it in my new patch. > > + enum reg_class cl; > + reg_class_t cl; > > if (DEBUG_INSN_P (tmp->insn)) > > continue; > > n_uses++; > > >+ cl = (enum reg_class) > >+ targetm.preferred_rename_class(tmp->cl); > + cl = targetm.preferred_rename_class(tmp->cl); > > IOR_COMPL_HARD_REG_SET (this_unavailable, > >- reg_class_contents[tmp->cl]); > >+ reg_class_contents[cl]); > + reg_class_contents[(int) cl]); > > Anatoly. gcc/ * target.def: New hook preferred_rename_class. * targhook.c (default_preferred_rename_class): New. * targhook.h: Declare it. * regrename.c (regrename_optimize): Call target hook preferred_rename_class to rename register class. * doc/tm.texi.in: New hook TARGET_PREFERRED_RENAME_CLASS. diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index a9592b1..d098d87 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -2585,6 +2585,8 @@ only if neither labeling works. This macro also has strict and non-strict variants. @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 diff --git a/gcc/regrename.c b/gcc/regrename.c index 11ae466..b9f6440 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" #if HOST_BITS_PER_WIDE_INT <= MAX_RECOG_OPERANDS #error "Use a different bitmap implementation for untracked_operands." @@ -384,12 +385,14 @@ regrename_optimize (void) n_uses = 0; for (tmp = this_head->first; tmp; tmp = tmp->next_use) { + reg_class_t cl; if (DEBUG_INSN_P (tmp->insn)) continue; n_uses++; + cl = targetm.preferred_rename_class(tmp->cl); IOR_COMPL_HARD_REG_SET (this_unavailable, - reg_class_contents[tmp->cl]); + reg_class_contents[(int)cl]); } if (n_uses < 2) diff --git a/gcc/target.def b/gcc/target.def index 82f3040..843ea8c 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -2089,6 +2089,20 @@ DEFHOOK bool, (reg_class_t rclass), default_class_likely_spilled_p) +DEFHOOK +(preferred_rename_class, + "A target hook that places additional restrictions on the register\ + class to use when it is necessary to rename a register in class\ + @var{class} to another class, or perhaps still @var{class},\ + if you don't define macro @code{PREFERRED_RENAME_CLASS}.\ + Sometimes returning a more restrictive class makes better code. For\ + example, on ARM, thumb-2 instructions using @code{LOW_REGS} may be\ + smaller than instructions using @code{GENERIC_REGS}. By returning\ + @code{LOW_REGS} from @code{PREFERRED_RENAME_CLASS}, code size can\ + be reduced.", + reg_class_t, (reg_class_t rclass), + default_preferred_rename_class) + /* This target hook allows the backend to perform additional processing while initializing for variable expansion. */ DEFHOOK diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 5948e3f..ea94c87 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -1256,6 +1256,16 @@ default_preferred_output_reload_class (rtx x ATTRIBUTE_UNUSED, #endif } +reg_class_t +default_preferred_rename_class (reg_class_t rclass) +{ +#ifdef PREFERRED_RENAME_CLASS + return PREFERRED_RENAME_CLASS ((enum reg_class)rclass); +#else + return rclass; +#endif +} + /* The default implementation of TARGET_CLASS_LIKELY_SPILLED_P. */ bool diff --git a/gcc/targhooks.h b/gcc/targhooks.h index 7b640cc..ba3dd17 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -156,6 +156,7 @@ extern int default_register_move_cost (enum machine_mode, reg_class_t, extern bool default_profile_before_prologue (void); extern reg_class_t default_preferred_reload_class (rtx, reg_class_t); extern reg_class_t default_preferred_output_reload_class (rtx, reg_class_t); +extern reg_class_t default_preferred_rename_class (reg_class_t rclass); extern bool default_class_likely_spilled_p (reg_class_t); extern enum unwind_info_type default_debug_unwind_info (void);