[llvm-dev] Is it legal to pass a half by value on x86_64? (original) (raw)
Wang, Pengfei via llvm-dev llvm-dev at lists.llvm.org
Fri Mar 5 04:30:09 PST 2021
- Previous message: [llvm-dev] Is it legal to pass a half by value on x86_64?
- Next message: [llvm-dev] Is it legal to pass a half by value on x86_64?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 <Sjoerd.Meijer at arm.com> Sent: Friday, March 5, 2021 5:49 PM To: Jason Hafer <jhafer at mathworks.com>; Wang, Pengfei <pengfei.wang at intel.com> Cc: llvm-dev <llvm-dev at lists.llvm.org> 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<https://gitlab.com/x86-psABIs/x86-64-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:
https://clang.llvm.org/docs/LanguageExtensions.html#half-precision-floating-point
Cheers, Sjoerd.
From: llvm-dev <llvm-dev-bounces at lists.llvm.org<mailto:llvm-dev-bounces at lists.llvm.org>> on behalf of Wang, Pengfei via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> Sent: 05 March 2021 06:28 To: Jason Hafer <jhafer at mathworks.com<mailto:jhafer at mathworks.com>> Cc: llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at 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<https://gitlab.com/x86-psABIs/x86-64-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 at lists.llvm.org<mailto:llvm-dev-bounces at lists.llvm.org>> On Behalf Of Jason Hafer via llvm-dev Sent: Friday, March 5, 2021 10:46 AM To: llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org> Cc: Jason Hafer <jhafer at mathworks.com<mailto:jhafer at 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210305/ba5ae36b/attachment.html>
- Previous message: [llvm-dev] Is it legal to pass a half by value on x86_64?
- Next message: [llvm-dev] Is it legal to pass a half by value on x86_64?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]