[PATCH] gas: Fix \+ expansion for .irp and .irpc

Fangrui Song maskray@google.com
Thu May 16 06:54:13 GMT 2024


On Wed, May 15, 2024 at 10:53 PM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 16.05.2024 04:42, Fangrui Song wrote:
> > --- /dev/null
> > +++ b/gas/testsuite/gas/macros/count-repeat.s
> > @@ -0,0 +1,8 @@
> > +     .rept 1
> > +     .print "\+"
> > +     .endr
> > +     .print "\+"
> > +     .endr
> > +     .irpc i,1
> > +     .print "\+"
> > +     .endr

> I can't help thinking that this can't possibly assemble (or if it does,
> there's a bug elsewhere), for (presumably) missing an .irp line to
> match the middle .endr.
>
> Just to mention it - I'm intending to extend \+ support to at least .irp
> and .irpc; whether that can also reasonably be done for .rept I haven't
> checked yet.
>
> Jan

I agree, extending \+ operator .irp, .irpc, and .rept will make a lot of sense.

We will finally get a for loop   (unsigned i = 0; i != count; i++)

.rept 3
.print "\+"   # 0 1 2
.endp

Previously, I resorted to .irpc i,0123456789   \i   .endr when the
loop count is <= 10, but there is no elegant way to reference \i when
the loop count is > 10.



-- 
宋方睿


More information about the Binutils mailing list