[clang] [clang][SYCL] Disable float128 device mode diagnostic (PR #128513)

2025-03-13 Thread Nicolas Miller via cfe-commits


@@ -4700,7 +4700,8 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo 
&CI,
 
   if (NewElemTy.isNull()) {
 // Only emit diagnostic on host for 128-bit mode attribute
-if (!(DestWidth == 128 && getLangOpts().CUDAIsDevice))
+if (!(DestWidth == 128 &&
+  (getLangOpts().CUDAIsDevice || getLangOpts().SYCLIsDevice)))

npmiller wrote:

No I'm not very familiar with this part of the compiler, and even less with 
OpenMP.

https://github.com/llvm/llvm-project/pull/128513
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][SYCL] Disable float128 device mode diagnostic (PR #128513)

2025-03-12 Thread Nicolas Miller via cfe-commits


@@ -4700,7 +4700,8 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo 
&CI,
 
   if (NewElemTy.isNull()) {
 // Only emit diagnostic on host for 128-bit mode attribute
-if (!(DestWidth == 128 && getLangOpts().CUDAIsDevice))
+if (!(DestWidth == 128 &&
+  (getLangOpts().CUDAIsDevice || getLangOpts().SYCLIsDevice)))

npmiller wrote:

I'll try to reproduce this with OpenMP and open a follow up PR if it has the 
same issue

https://github.com/llvm/llvm-project/pull/128513
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][SYCL] Disable float128 device mode diagnostic (PR #128513)

2025-03-13 Thread Nicolas Miller via cfe-commits


@@ -4700,7 +4700,8 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo 
&CI,
 
   if (NewElemTy.isNull()) {
 // Only emit diagnostic on host for 128-bit mode attribute
-if (!(DestWidth == 128 && getLangOpts().CUDAIsDevice))
+if (!(DestWidth == 128 &&
+  (getLangOpts().CUDAIsDevice || getLangOpts().SYCLIsDevice)))

npmiller wrote:

Not sure exactly how it works for OpenMP, but it doesn't seem to be affected, 
with a `float128.cpp` file just containing:

 ```cpp
 typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
 ```
 
 And testing without this patch:
 
 With SYCL:
 ```
$ ./bin/clang++ float128.cpp -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xclang 
-fsycl-is-device -fsyntax-only -o o
 float128.cpp:1:52: error: unsupported machine mode '__TC__'
1 | typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
  |^
1 error generated.
$
 ```
 
 With OpenMP:
 ```
$ ./bin/clang++ ../build/float128.cpp -fopenmp 
-fopenmp-targets=nvptx64-nvidia-cuda -Xclang -fopenmp-is-target-device 
-fsyntax-only -o o
$
 ```
 
 And same thing without specifying an OpenMP target.

https://github.com/llvm/llvm-project/pull/128513
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][SYCL] Disable float128 device mode diagnostic (PR #128513)

2025-02-24 Thread Nicolas Miller via cfe-commits

https://github.com/npmiller created 
https://github.com/llvm/llvm-project/pull/128513

This diagnostic is disabled for device compilation as float128 is not supported 
on the device side.

Other diagnostics are already covering the cases where float128 is actually 
used in the kernel code, and it's already tested for in the existing test.

This is expanding on the patch 318bff6 that handled this for cuda compilation.

>From 88ecd2f5a57203ed1b29439c48c533371812fe80 Mon Sep 17 00:00:00 2001
From: Nicolas Miller 
Date: Mon, 24 Feb 2025 13:49:24 +
Subject: [PATCH] [clang][SYCL] Disable float128 device mode diagnostic

This diagnostic is disabled for device compilation as float128 is not
supported on the device side.

Other diagnostics are already covering the cases where float128 is
actually used in the kernel code, and it's already tested for in the
existing test.

This is expanding on the patch 318bff6 that handled this for cuda
compilation.
---
 clang/lib/Sema/SemaDeclAttr.cpp  | 3 ++-
 clang/test/SemaSYCL/float128.cpp | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 620290af9509f..a13c04d69c4ba 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -4700,7 +4700,8 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo 
&CI,
 
   if (NewElemTy.isNull()) {
 // Only emit diagnostic on host for 128-bit mode attribute
-if (!(DestWidth == 128 && getLangOpts().CUDAIsDevice))
+if (!(DestWidth == 128 &&
+  (getLangOpts().CUDAIsDevice || getLangOpts().SYCLIsDevice)))
   Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
 return;
   }
diff --git a/clang/test/SemaSYCL/float128.cpp b/clang/test/SemaSYCL/float128.cpp
index b1a022216aaff..e41dea38dbe75 100644
--- a/clang/test/SemaSYCL/float128.cpp
+++ b/clang/test/SemaSYCL/float128.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple spir64 -fsycl-is-device -verify -fsyntax-only %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsycl-is-device -fsyntax-only %s
 
+typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
 typedef __float128 BIGTY;
 
 template 

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


[clang] [clang][SYCL] Disable float128 device mode diagnostic (PR #128513)

2025-02-24 Thread Nicolas Miller via cfe-commits


@@ -4700,7 +4700,8 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo 
&CI,
 
   if (NewElemTy.isNull()) {
 // Only emit diagnostic on host for 128-bit mode attribute
-if (!(DestWidth == 128 && getLangOpts().CUDAIsDevice))
+if (!(DestWidth == 128 &&
+  (getLangOpts().CUDAIsDevice || getLangOpts().SYCLIsDevice)))

npmiller wrote:

Side-note `CUDAIsDevice || SYCLIsDevice` seems like a pretty common pattern and 
I believe HIP also uses `CUDAIsDevice`, it could be good to refactor in the 
future this to have a common "device compilation" option if possible.

https://github.com/llvm/llvm-project/pull/128513
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits