(original) (raw)
I guess it’s designed for language portability. You can use this type across different platforms. Nevertheless, I’m not a FE expert, so I cannot think out other intentions.
The \_Float16 is a primitive type in the latest x86 ABI, but there’s no X86 target that supports it yet. So you cannot use it on X86 by now. I think that’s the difference from \_\_fp16 and why should use it.
We also have some discussion here. https://reviews.llvm.org/D97318
Thanks
Pengfei
From: Sjoerd Meijer
Sent: Friday, March 5, 2021 5:49 PM
To: Jason Hafer ; Wang, Pengfei
Cc: llvm-dev
Subject: Re: Is it legal to pass a half by value on x86\_64?
\_\_fp16 is a pure storage format. You cannot pass it by value, because only ABI permissive types can be passed by value while \_\_fp16 is not one of them.
Yep. Any specific reason to use a pure storage format? The native type is \_Float16 and would give some benefits, but this is not yet supported on x86, see also:
Cheers,
Sjoerd.
From: llvm-dev <llvm-dev-bounces@lists.llvm.org> on behalf of Wang, Pengfei via llvm-dev <llvm-dev@lists.llvm.org>
Sent: 05 March 2021 06:28
To: Jason Hafer <jhafer@mathworks.com>
Cc: llvm-dev <llvm-dev@lists.llvm.org>
Subject: Re: \[llvm-dev\] Is it legal to pass a half by value on x86\_64?
Hi Jason,
\_\_fp16 is a pure storage format. You cannot pass it by value, because only ABI permissive types can be passed by value while \_\_fp16 is not one of them.
- if "define void @foo(i8, i8, i8, i8, half) " is even legal to use
half as a target independent type is legal for LLVM. It’s not legal for unsupported target like X86\. The behavior depends on how we lowering it. But I don’t know why there’s differences between Linux and Windows. Maybe because “\_\_gnu\_f2h\_ieee” is a Linux only function?
Thanks
Pengfei
From: llvm-dev <llvm-dev-bounces@lists.llvm.org>
On Behalf Of Jason Hafer via llvm-dev
Sent: Friday, March 5, 2021 10:46 AM
To: llvm-dev@lists.llvm.org
Cc: Jason Hafer <jhafer@mathworks.com>
Subject: \[llvm-dev\] Is it legal to pass a half by value on x86\_64?
Hello,
I am attempting to understand an anomaly I am seeing when dealing with half on Windows and could use some help.
Using LLVM 8 or 10, if I have IR of the flavor below:
define void @foo(i8, i8, i8, i8, half) {
%6 = alloca half
store half %4, half\* %6, align 1
...
ret void
}
Using x86\_64-pc-linux, we convert the float passed in with \_\_gnu\_f2h\_ieee.
Using x86\_64-pc-windows I do not get the conversion, so we end up with incorrect math operations.
While investigating I noticed clang gave me the error below:
error: parameters cannot have \_\_fp16 type; did you forget \* ?
void foo(int dc1, int dc2,int dc3,int dc4, \_\_fp16 in)
So, this got me wondering if "define void @foo(i8, i8, i8, i8, half) " is even legal to use or if I should rather pass by ref? I have yet to find documentation to convince me one way or the other. Thus, I was hoping someone here might be able to shed some light on the issue.
Thank you in advance!
Cheers,
JP