public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@adacore.com>
To: Yao Qi <yao@codesourcery.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [Ping] [patch 0/3] New macro PREFERRED_RENAME_CLASS
Date: Mon, 06 Dec 2010 18:27:00 -0000	[thread overview]
Message-ID: <201012061925.26662.ebotcazou@adacore.com> (raw)
In-Reply-To: <4CF8F991.4080304@codesourcery.com>

> Seems I didn't understand targethook fully before.  You are right.  Done.

Thanks.  The patch is OK for mainline modulo the following last nits:

--- 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.


+  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.

-- 
Eric Botcazou

  reply	other threads:[~2010-12-06 18:27 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-04  5:31 Yao Qi
2010-11-05  9:53 ` Eric Botcazou
2010-11-05 16:08   ` Yao Qi
2010-11-08 12:52     ` Eric Botcazou
2010-11-08 15:11       ` Yao Qi
2010-11-09  9:26         ` Eric Botcazou
2010-11-09 15:33           ` Yao Qi
2010-11-11 17:40             ` Eric Botcazou
2010-11-11 18:01               ` Eric Botcazou
2010-12-01 16:48               ` Yao Qi
2010-12-03 10:58                 ` Eric Botcazou
2010-12-03 14:08                   ` Yao Qi
2010-12-06 18:27                     ` Eric Botcazou [this message]
2010-12-06 20:34                       ` Joseph S. Myers
2010-12-06 20:35                         ` Eric Botcazou
2010-12-06 20:39                           ` Joseph S. Myers
2010-12-06 22:02                             ` Eric Botcazou
2010-12-07 12:35                       ` Yao Qi
2010-12-13 13:10                         ` Eric Botcazou
2011-01-02 17:43                           ` Eric Botcazou
2010-12-13 19:43                     ` ARM bootstrap failure (Re: [Ping] [patch 0/3] New macro PREFERRED_RENAME_CLASS) Ulrich Weigand
2010-12-13 20:46                       ` Ulrich Weigand
2010-12-04 16:06                   ` [Ping] [patch 0/3] New macro PREFERRED_RENAME_CLASS Daniel Jacobowitz
2010-12-06 11:11                     ` Eric Botcazou
2010-11-20 12:05 ` Eric Botcazou
2010-11-23 12:06   ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201012061925.26662.ebotcazou@adacore.com \
    --to=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=yao@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).