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

Nicolas Miller via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 24 05:57:07 PST 2025


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 <nicolas.miller at codeplay.com>
Date: Mon, 24 Feb 2025 13:49:24 +0000
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 <class T>



More information about the cfe-commits mailing list