[compiler-rt] [builtins][AArch32] Fix __gnu_* functions (PR #137638)
    via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Wed Apr 30 07:25:38 PDT 2025
    
    
  
saturn691 wrote:
> What targets in GCC may call __gnu_h2f and friends and what is their expected interface?
```cpp
float h2f(_Float16 x)
{
    return (float)x;
}
int main()
{
    float x = h2f(1.0f16);
    return !(x == 1.0f);
}
```
This is the test I am running.
>From looking at the new generated assembly, it seems we are using the correct interface (u16 -> u32) as defined in libgcc.
```
200000ec <__gnu_h2f_ieee>:
200000ec: e92d4800     	push	{r11, lr}
200000f0: ee000a10     	vmov	s0, r0
200000f4: ebffffe1     	bl	0x20000080 <__extendhfsf2> @ imm = #-0x7c
200000f8: ee100a10     	vmov	r0, s0
200000fc: e8bd8800     	pop	{r11, pc}
20000100 <__aeabi_h2f>:
20000100: e92d4800     	push	{r11, lr}
20000104: ee000a10     	vmov	s0, r0
20000108: ebffffdc     	bl	0x20000080 <__extendhfsf2> @ imm = #-0x90
2000010c: ee100a10     	vmov	r0, s0
20000110: e8bd8800     	pop	{r11, pc}
```
> What targets in LLVM may call __gnu_h2f and friends and what is their expected interface?
LLVM uses __aeabi_h2f instead. Hence why this change is here to standardise the interfaces.
> Can you make sure that the change to compiler-rt works for all of these targets. For example we may need to compile differently for MachO (Darwin) than for ELF.
I've tested it on Linux- it works. It's actually quite hard to write a test case that works for this without inline assembly. Also, in the `.cpp` - it says if Subtarget is not (!) MachO. This change I presume does not affect MachO targets.
https://github.com/llvm/llvm-project/pull/137638
    
    
More information about the llvm-commits
mailing list