On Sat, 4 Oct 2025, Jakub Jelinek wrote:

> Hi!
> 
> Last year I've extended the asm template syntax in inline asm to support
> %cc0 etc., apparently the first 2 letter generic operand modifier.
> As the following testcase shows, I forgot to tweak the [foo] handling
> for it though.  As final.cc will error on any % ISALPHA not followed by
> digit (with the exception of % c c digit), I think we can safely handle
> this for any 2 letters in between % and [, instead of hardcoding it for
> now only for %cc[ and changing it again next time we add something
> two-letter.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk and
> 15.3?

OK.

Richard.

> 2025-10-04  Jakub Jelinek  <[email protected]>
> 
>       PR middle-end/122133
>       * stmt.cc (resolve_asm_operand_names): Handle % and 2 letters followed
>       by open square.
> 
>       * c-c++-common/toplevel-asm-9.c: New test.
> 
> --- gcc/stmt.cc.jj    2025-07-27 23:31:10.723994037 +0200
> +++ gcc/stmt.cc       2025-10-03 10:29:44.413830622 +0200
> @@ -849,7 +849,8 @@ resolve_asm_operand_names (tree string,
>      {
>        if (c[1] == '[')
>       break;
> -      else if (ISALPHA (c[1]) && c[2] == '[')
> +      else if (ISALPHA (c[1])
> +            && (c[2] == '[' || (ISALPHA (c[2]) && c[3] == '[')))
>       break;
>        else
>       {
> @@ -873,6 +874,8 @@ resolve_asm_operand_names (tree string,
>           p += 1;
>         else if (ISALPHA (p[1]) && p[2] == '[')
>           p += 2;
> +       else if (ISALPHA (p[1]) && ISALPHA (p[2]) && p[3] == '[')
> +         p += 3;
>         else
>           {
>             p += 1 + (p[1] == '%');
> --- gcc/testsuite/c-c++-common/toplevel-asm-9.c.jj    2025-10-03 
> 10:23:04.971437475 +0200
> +++ gcc/testsuite/c-c++-common/toplevel-asm-9.c       2025-10-03 
> 10:33:36.141577934 +0200
> @@ -0,0 +1,12 @@
> +/* PR middle-end/122133 */
> +/* { dg-do compile } */
> +/* { dg-options "-O0" } */
> +
> +extern int v[42], w;
> +int x[42], y;
> +void foo (void);
> +void bar (void) {}
> +
> +asm ("# %cc[foo]: %cc[v]: %cc[w]: %cc[bar] %cc[x] %cc[y]"
> +     :: [foo] ":" (foo), [v] ":" (v), [w] ":" (&w),
> +     [bar] "-i" (bar), [x] "-s" (x), [y] "-s" (&y));
> 
>       Jakub
> 
> 

-- 
Richard Biener <[email protected]>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

Reply via email to