[PATCH v2 4/5] LoongArch: Add support for LA32 in sysdeps/unix/sysv/linux/loongarch

mengqinggang mengqinggang@loongson.cn
Fri Dec 19 03:22:57 GMT 2025


在 2025/12/19 10:25, WANG Xuerui 写道:
> On 12/19/25 10:00, mengqinggang wrote:
>>
>> 在 2025/12/18 22:21, WANG Xuerui 写道:
>>> On 12/18/25 21:05, Adhemerval Zanella Netto wrote:
>>>>
>>>>
>>>> On 18/12/25 09:30, mengqinggang wrote:
>>>>> [snip]
>>>>>   @@ -54,7 +54,7 @@ ENTRY (__clone)
>>>>>       syscall        0
>>>>>         blt        a0, zero ,L (error)
>>>>> -    beqz        a0,L (thread_start)
>>>>> +    beq        a0, zero, L (thread_start)
>>>>>         /* Successful return from the parent.  */
>>>>>       ret
>>>>
>>>> Does it meant that loongarch32 does not support all the branch
>>>> instruction from loongarch64? Or that binutils is not recognizing
>>>> beqz as a alias for beq reg, zero ?
>>>
>>> It is a bit interesting: b{eq,ne}z are *different* instructions in 
>>> LA64 and LA32S so that an additional 5 bits becomes free for 
>>> encoding the offset. The reduced subset, LA32R, doesn't have them 
>>> for simplicity reasons.
>>>
>>> We may be able to make "b{eq,ne}z x, y" aliases for "b{eq,ne} x, 
>>> zero, y" respectively for LA32R, and this won't affect compatibility 
>>> because one has to use up-to-date binutils anyway to get any LA32 
>>> support at all.
>>
>>
>> Just only make "b{eq,ne}z" aliases for "b{eq,ne}" on LA32R?
>
> That's what I mean, of course. Although...
>
>>> I don't know if doing this would create confusion for someone 
>>> deliberately choosing beqz for a big offset that isn't expressible 
>>> with beq, but I guess the case is contrived because beq already can 
>>> reach +/-128KiB which is more than enough for conditional branches. 
>
> ... this is what I fear would create confusion, if we're to make such 
> a change ideally we would update the ISA manual and assembly language 
> doc as well to include this precaution.


We can update the ISA manual and assembly language doc after the patch 
applied.


>
>>> Maybe someone from Loongson would prepare a patch for binutils, or I 
>>> can do it later (next week or so).
>
> Are you going to work on this? I'm okay because I'm not going to have 
> much free time. Gotta relax myself (pun intended) for the rest of the 
> year...
>



More information about the Libc-alpha mailing list