On Wed, Jul 15, 2026 at 05:34:22PM +0530, jeevitha wrote:
> Hi All,
> 
> The following patch has been bootstrapped and regtested on powerpc64le-linux.
> 
> Add a new %W print modifier to print_operand that prints the VSX
> register number plus two.
> 
> Some future Power instruction patterns require printing two VSX
> registers corresponding to a __vector_pair operand. The existing
> %x print modifier emits the first VSX register using VSX register
> numbering. Add a new %W print modifier to emit the second VSX
> register of the pair.

Please modify your patch so the 'W' case followings 'w'.  The
print_operand function uses the convention that the cases are
alphabetical in order (lower case then upper case).  I.e. the 'W' case
should follow 'w' and not 'x':

It may also be useful to not allow %W to be used for FPR registers FR30
or FR31 and likewise for Altivec registers V30 or V31.  In practice
since %W is to be used for dense math registers, you would never get %W
on those registers, but it doesn't hurt to be sure.

Likewise, I can imagine it might be helpful to give an error if the
mode byte size of the register (i.e. GET_MODE_SIZE (x)) is not at least
48 or possibly 64.  That way you ensure that it doesn't reference some
random register that isn't related to the register you are using.

> 2025-07-14  Jeevitha Palanisamy  <[email protected]>
>           Kishan Parmar  <[email protected]>
> 
> gcc/
>       * config/rs6000/rs6000.cc (print_operand): Add the `%W`
>       print modifier to print the VSX register number plus two.
> 
> diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
> index 7743c9cdc4a..64683102e9e 100644
> --- a/gcc/config/rs6000/rs6000.cc
> +++ b/gcc/config/rs6000/rs6000.cc
> @@ -14527,6 +14527,27 @@ print_operand (FILE *file, rtx x, int code)
>                        ? reg - 32
>                        : reg - FIRST_ALTIVEC_REGNO + 32);
>  
> +#ifdef TARGET_REGNAMES
> +       if (TARGET_REGNAMES)
> +         fprintf (file, "%%vs%d", vsx_reg);
> +       else
> +#endif
> +         fprintf (file, "%d", vsx_reg);
> +     }
> +      return;
> +
> +    case 'W':
> +      /* Like '%x', but prints the VSX register number +2.  */
> +      if (!REG_P (x) || !VSX_REGNO_P (REGNO (x)))
> +     output_operand_lossage ("invalid %%W value");
> +      else
> +     {
> +       int reg = REGNO (x);
> +       int vsx_reg = (FP_REGNO_P (reg)
> +                      ? reg - 32
> +                      : reg - FIRST_ALTIVEC_REGNO + 32);
> +       vsx_reg += 2;
> +
>  #ifdef TARGET_REGNAMES
>         if (TARGET_REGNAMES)
>           fprintf (file, "%%vs%d", vsx_reg);
> 
> 
> 

-- 
Michael Meissner, IBM
PO Box 98, Ayer, Massachusetts, USA, 01432
email: [email protected]

Reply via email to