[Ping] [patch 0/3] New macro PREFERRED_RENAME_CLASS

Eric Botcazou ebotcazou@adacore.com
Fri Dec 3 10:58:00 GMT 2010


> In this patch, most of part is same as the previous one, except three
> changes,
>
> 1. compute superunion set of all the classes in the chain,
>
>   reg_class_superunion_in_chain
>     =
> reg_class_superunion[(int)reg_class_superunion_in_chain][(int)tmp->cl];
>
> 2. compute the preferred class of reg_class_superunion_in_chain by hook,
>
>    preferred_class
>      = targetm.preferred_rename_class(reg_class_superunion_in_chain);
>
> 3. Iterate registers first in preferred_class, and stop once better
> register is found.  Then, iterate the rest of registers as usual.

Almost OK, but:

+	  enum reg_class reg_class_superunion_in_chain = NO_REGS;

The name is too long, leading to

+	      reg_class_superunion_in_chain
+		= reg_class_superunion[(int)reg_class_superunion_in_chain][(int)tmp->cl];

Just call it "superunion_class".


+	  /* The register iteration order here is "preferred-register-first".
+	     Firstly(i == 0), we iterate registers belong to class
+	     PREFERRED_CLASS, if we find a new register, we stop immeidately.

"... we iterate over registers that belong to PREFERRED_CLASS; if we find a 
new register, we stop immediately."

+	     Otherwise, we iterate once more (i == 1) registers, which
+	     doesn't belong class PREFERRED_CLASS.

"...over registers that don't belong to PREFERRED_CLASS".

+	     If preferred class is not found by target hook, PREFERRED_CLASS
+	     is NO_REGS, and registers are iterated in an ascending order
+	     without any preference.  */

"If PREFERRED_CLASS is NO_REGS, we iterate over all registers in ascending 
order without any preference".

But the loop is still run twice, isn't it?  Can we skip the first run if 
PREFERRED_CLASS is NO_REGS, for example by starting at 1 instead of 0?

The usual convention for this kind of scheme (mutiple runs) in the RTL 
optimizers is to use PASS as iteration variable:

  for (pass = 0; pass < 2; pass++)

and just test (pass == 0) or (pass == 1), i.e. don't use PREFER at all:

  /* In the first pass, iterate over registers first in preferred class.  */
  if (pass == 0
      && !TEST_HARD_REG_BIT (reg_class_contents[preferred_class], new_reg))
    continue;

[...]

  /* If we find a new reg in our preferred class, stop immediately.  */
  if (pass == 0 && best_new_reg != reg)
    {
      found = true;
      break;
    }


As for the hook itself: drop the PREFERRED_RENAME_CLASS macro entirely, i.e. 
the default hook is just:

reg_class_t
default_preferred_rename_class (reg_class_t rclass)
{
  return NO_REGS;
}

and back-ends must implement the function (or use the default).


Finally, I have a question for native speakers: does preferred_rename_class 
sound good or would preferred_renaming_class be better?

-- 
Eric Botcazou



More information about the Gcc-patches mailing list