[PATCH v2 2/5] LoongArch: Add support for LA32 in sysdeps/loongarch/fpu

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Mon Dec 22 13:16:53 GMT 2025



On 22/12/25 00:52, mengqinggang wrote:
> 
> 在 2025/12/18 21:15, Adhemerval Zanella Netto 写道:
>>
>> On 18/12/25 09:30, mengqinggang wrote:
>>> ---
>>>   sysdeps/loongarch/fpu/e_scalb.c                  | 10 ++++++++++
>>>   sysdeps/loongarch/fpu/e_scalbf.c                 | 10 ++++++++++
>>>   sysdeps/loongarch/fpu/math-use-builtins-llrint.h |  2 +-
>>>   sysdeps/loongarch/fpu/math-use-builtins-logb.h   |  2 +-
>>>   sysdeps/loongarch/fpu/math-use-builtins-lrint.h  |  2 +-
>>>   sysdeps/loongarch/fpu/math-use-builtins-rint.h   |  2 +-
>>>   sysdeps/loongarch/fpu/math-use-builtins-sqrt.h   | 10 ++++++++--
>>>   sysdeps/loongarch/fpu/s_scalbn.c                 | 10 ++++++++++
>>>   sysdeps/loongarch/fpu/s_scalbnf.c                |  8 ++++++++
>>>   sysdeps/loongarch/fpu/w_ilogb-impl.h             |  8 ++++++++
>>>   sysdeps/loongarch/fpu/w_ilogbf-impl.h            |  8 ++++++++
>>>   11 files changed, 66 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/sysdeps/loongarch/fpu/e_scalb.c b/sysdeps/loongarch/fpu/e_scalb.c
>>> index 039cbd6ac8..439e38c6a7 100644
>>> --- a/sysdeps/loongarch/fpu/e_scalb.c
>>> +++ b/sysdeps/loongarch/fpu/e_scalb.c
>>> @@ -16,6 +16,8 @@
>>>      License along with the GNU C Library; if not, see
>>>      <https://www.gnu.org/licenses/>.  */
>>>   +#ifdef __loongarch64
>>> +
>>>   #define NO_MATH_REDIRECT
>>>   #include <math.h>
>>>   #include <libm-alias-finite.h>
>>> @@ -57,4 +59,12 @@ __ieee754_scalb (double x, double fn)
>>>       return x;
>>>   }
>>> +
>>>   libm_alias_finite (__ieee754_scalb, __scalb)
>>> +
>>> +#else /* #ifdef __loongarch64 */
>>> +
>>> +#include <sysdeps/generic/math-type-macros-double.h>
>>> +#include <math/e_scalb_template.c>
>>> +
>>> +#endif /* #ifdef __loongarch64 */
>> I don't have a strong opinion, but maybe it would be better to add
>> an extra Implies subfolder like other ABIs that support multilib
>> and move the loongarch64 implementation to it:
>>
>>    sysdeps/loongarch/fpu/e_scalb.c -> sysdeps/loongarch/loongarch64/fpu/e_scalb.c
>>
>> So the selection is done automatically instead adjust to use the
>> generic implementation on multiple files.
> 
> 
> There is already a sysdeps/loongarch/lp64  for lp64 ABI. Move files controlled by
> __loongarch64 macro to sysdeps/loongarch/lp64/fpu?

Yes.  I see the sysdeps mechanism slight better than the #include <default> because
I decouple the internals of default implementation (the need of inclusion
of math-type...) and where it is placed (moving the generic implementation
to somewhere else breaks this implementation).


More information about the Libc-alpha mailing list