yaxunl marked 3 inline comments as done.
yaxunl added inline comments.

================
Comment at: clang/lib/CodeGen/TargetInfo.cpp:2821
+    } else if (k == BuiltinType::Float16 || k == BuiltinType::Half) {
+      // AMD64 does not support _Float16 or __fp16. When used in
+      // languages supporting it, _Float16 or __fp16 is for storage only,
----------------
pengfei wrote:
> It's true that AMD64 does not support _Float16, but __fp16 is supported on 
> every target.
> See 
> https://clang.llvm.org/docs/LanguageExtensions.html#half-precision-floating-point
will fix comments


================
Comment at: clang/lib/CodeGen/TargetInfo.cpp:2822
+      // AMD64 does not support _Float16 or __fp16. When used in
+      // languages supporting it, _Float16 or __fp16 is for storage only,
+      // which is equivalent to 16 bit integer. We need this to interop with
----------------
pengfei wrote:
> __fp16 is storage format while _Float16 isn't.
will fix comments


================
Comment at: clang/lib/CodeGen/TargetInfo.cpp:2824
+      // which is equivalent to 16 bit integer. We need this to interop with
+      // gcc where 16 bit integer is used in place of _Float16 or __fp16.
+      Lo = Integer;
----------------
pengfei wrote:
> The GCC should take _Floatn as floating types, see 
> https://gcc.gnu.org/onlinedocs/gcc-8.2.0/gcc/Floating-Types.html#Floating-Types
> Can you provide the information how gcc uses as 16 bit integer for _Float16?
GCC does not allow _Float16 or __fp16 to be used for x86_64.

HIP language allows _Float16 or __fp16 type to be used with x86_64. To be able 
to passing _Float16 or __fp16 values between C++ using gcc and HIP using clang, 
users often write code like this:


```
struct half_t {
#ifdef __GNUC__
uint16_t x;
#else
_Float16 x;
#endif
};

void fun1(half_t x);
```
And usually fun1 is defined in HIP and compiled by clang to object file, then 
they call it in C++ which is compiled by gcc. Then the caller will pass half_t 
by register. However clang passes half_t by stack. This causes issue.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97318/new/

https://reviews.llvm.org/D97318

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to