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

Jan Beulich jbeulich@suse.com
Thu May 16 07:53:30 GMT 2024


On 16.05.2024 09:00, Fangrui Song wrote:
> On Wed, May 15, 2024 at 11:54 PM Fangrui Song <maskray@google.com> wrote:
>>
>> 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.
> 
> What should \+ expand to for nested loops?
> 
> .rept 2
>   .rept 2
>     .print "n\+"
>   .endr
> .endr

For macros I expect (didn't try yet) it's the outermost one, so I'd expect
.irp / .irpc / .rept would want to match that. I'll want to see how it ends
up most logically, yet without going through ugly extra hoops.

Jan


More information about the Binutils mailing list