[clang] [clang][CUDA] Disable float128 diagnostics for device compilation (PR #83918)

2024-03-06 Thread Artem Belevich via cfe-commits

https://github.com/Artem-B approved this pull request.


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


[clang] [clang][CUDA] Disable float128 diagnostics for device compilation (PR #83918)

2024-03-06 Thread Pranav Kant via cfe-commits

https://github.com/pranavk updated 
https://github.com/llvm/llvm-project/pull/83918

>From c28121199d5e16efb908a3058a52c6b5b2016848 Mon Sep 17 00:00:00 2001
From: Pranav Kant 
Date: Mon, 4 Mar 2024 22:19:04 +
Subject: [PATCH 1/3] [clang][CUDA] Disable float128 diagnostics for device
 compilation

---
 clang/lib/Sema/SemaDeclAttr.cpp | 4 +++-
 clang/lib/Sema/SemaType.cpp | 1 +
 clang/test/SemaCUDA/float128.cu | 9 +
 3 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/SemaCUDA/float128.cu

diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 397b5db0dc0669..e6943efb345ce0 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -4877,7 +4877,9 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo 
,
 NewElemTy = Context.getRealTypeForBitwidth(DestWidth, ExplicitType);
 
   if (NewElemTy.isNull()) {
-Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
+// Only emit diagnostic on host for 128-bit mode attribute
+if (!(DestWidth == 128 && getLangOpts().CUDAIsDevice))
+  Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
 return;
   }
 
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 1e43e36016a66f..4a4e6f80d0d049 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1562,6 +1562,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState 
) {
   case DeclSpec::TST_float128:
 if (!S.Context.getTargetInfo().hasFloat128Type() &&
 !S.getLangOpts().SYCLIsDevice &&
+!S.getLangOpts().CUDAIsDevice &&
 !(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsTargetDevice))
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
 << "__float128";
diff --git a/clang/test/SemaCUDA/float128.cu b/clang/test/SemaCUDA/float128.cu
new file mode 100644
index 00..a59e1b2f8a741a
--- /dev/null
+++ b/clang/test/SemaCUDA/float128.cu
@@ -0,0 +1,9 @@
+// CPU-side compilation on x86 (no errors expected).
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -aux-triple nvptx64 -x 
cuda -fsyntax-only -verify %s
+
+// GPU-side compilation on x86 (no errors expected)
+// RUN: %clang_cc1 -triple nvptx64 -aux-triple x86_64-unknown-linux-gnu 
-fcuda-is-device -x cuda -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
+typedef __float128 _Float128;

>From bcc8d6ea5e7922712017ecb1941a53cf769577b3 Mon Sep 17 00:00:00 2001
From: Pranav Kant 
Date: Mon, 4 Mar 2024 22:31:24 +
Subject: [PATCH 2/3] formatting

---
 clang/lib/Sema/SemaType.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 4a4e6f80d0d049..3148299f6467af 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1561,8 +1561,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState 
) {
 break;
   case DeclSpec::TST_float128:
 if (!S.Context.getTargetInfo().hasFloat128Type() &&
-!S.getLangOpts().SYCLIsDevice &&
-!S.getLangOpts().CUDAIsDevice &&
+!S.getLangOpts().SYCLIsDevice && !S.getLangOpts().CUDAIsDevice &&
 !(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsTargetDevice))
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
 << "__float128";

>From 422af59d7aa7c0095606e0a9bf6ce091ea84b925 Mon Sep 17 00:00:00 2001
From: Pranav Kant 
Date: Wed, 6 Mar 2024 22:33:33 +
Subject: [PATCH 3/3] extend test to compile a device function

---
 clang/test/SemaCUDA/float128.cu | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/clang/test/SemaCUDA/float128.cu b/clang/test/SemaCUDA/float128.cu
index a59e1b2f8a741a..f8f20cb1588d76 100644
--- a/clang/test/SemaCUDA/float128.cu
+++ b/clang/test/SemaCUDA/float128.cu
@@ -1,9 +1,18 @@
 // CPU-side compilation on x86 (no errors expected).
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -aux-triple nvptx64 -x 
cuda -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -aux-triple nvptx64 -x 
cuda -fsyntax-only -verify=cpu %s
 
 // GPU-side compilation on x86 (no errors expected)
-// RUN: %clang_cc1 -triple nvptx64 -aux-triple x86_64-unknown-linux-gnu 
-fcuda-is-device -x cuda -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple nvptx64 -aux-triple x86_64-unknown-linux-gnu 
-fcuda-is-device -x cuda -fsyntax-only -verify=gpu %s
 
-// expected-no-diagnostics
+// cpu-no-diagnostics
 typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
 typedef __float128 _Float128;
+
+// gpu-note@+1 {{'a' defined here}}
+__attribute__((device)) __float128 f(__float128 a, float b) {
+// gpu-note@+1 {{'c' defined here}}
+  __float128 c = b + 1.0;
+  // gpu-error@+2 {{'a' requires 128 bit size '__float128' type support, but 
target 'nvptx64' does not support it}}
+  

[clang] [clang][CUDA] Disable float128 diagnostics for device compilation (PR #83918)

2024-03-05 Thread Artem Belevich via cfe-commits


@@ -0,0 +1,9 @@
+// CPU-side compilation on x86 (no errors expected).
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -aux-triple nvptx64 -x 
cuda -fsyntax-only -verify %s
+
+// GPU-side compilation on x86 (no errors expected)
+// RUN: %clang_cc1 -triple nvptx64 -aux-triple x86_64-unknown-linux-gnu 
-fcuda-is-device -x cuda -fsyntax-only -verify %s

Artem-B wrote:

I'd add a test verifying that we do emit diagnostics if fp128 is used in the 
GPU code.
It would probably need to be done somewhere in the codegen tests as it will not 
fire in the syntax-only checks.

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


[clang] [clang][CUDA] Disable float128 diagnostics for device compilation (PR #83918)

2024-03-05 Thread Artem Belevich via cfe-commits


@@ -4877,7 +4877,9 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo 
,
 NewElemTy = Context.getRealTypeForBitwidth(DestWidth, ExplicitType);
 
   if (NewElemTy.isNull()) {
-Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
+// Only emit diagnostic on host for 128-bit mode attribute

Artem-B wrote:

OK. As long as you're sure that the remaining diag covers all possible uses of 
fp128 on the GPU, it should be fine.

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


[clang] [clang][CUDA] Disable float128 diagnostics for device compilation (PR #83918)

2024-03-04 Thread Pranav Kant via cfe-commits

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


[clang] [clang][CUDA] Disable float128 diagnostics for device compilation (PR #83918)

2024-03-04 Thread Pranav Kant via cfe-commits


@@ -4877,7 +4877,9 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo 
,
 NewElemTy = Context.getRealTypeForBitwidth(DestWidth, ExplicitType);
 
   if (NewElemTy.isNull()) {
-Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
+// Only emit diagnostic on host for 128-bit mode attribute

pranavk wrote:

There are two diags that I disabled as part of this PR:
1. "%0 is not supported on this target"
2. unsupported machine mode __TC__

The diag that got emitted as part of building sample snippet that you pasted in 
this comment thread is neither 1 nor 2. This diag comes from part of clang/LLVM 
when it starts to generate code for nvptx specifically.

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


[clang] [clang][CUDA] Disable float128 diagnostics for device compilation (PR #83918)

2024-03-04 Thread Artem Belevich via cfe-commits


@@ -4877,7 +4877,9 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo 
,
 NewElemTy = Context.getRealTypeForBitwidth(DestWidth, ExplicitType);
 
   if (NewElemTy.isNull()) {
-Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
+// Only emit diagnostic on host for 128-bit mode attribute

Artem-B wrote:

> This is going to error out like this:
> 
> ```
> error: 'a' requires 128 bit size '__float128' type support, but target 
> 'nvptx64-nvidia-cuda' does not support it
> ```

Something does not add up. How would we get `target 'nvptx64-nvidia-cuda'` if 
the diag below only fires if we're compiling for the host?


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


[clang] [clang][CUDA] Disable float128 diagnostics for device compilation (PR #83918)

2024-03-04 Thread Pranav Kant via cfe-commits


@@ -4877,7 +4877,9 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo 
,
 NewElemTy = Context.getRealTypeForBitwidth(DestWidth, ExplicitType);
 
   if (NewElemTy.isNull()) {
-Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
+// Only emit diagnostic on host for 128-bit mode attribute

pranavk wrote:

On second thought, it may be a good idea to add that in the diagnostic test.

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


[clang] [clang][CUDA] Disable float128 diagnostics for device compilation (PR #83918)

2024-03-04 Thread Pranav Kant via cfe-commits


@@ -4877,7 +4877,9 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo 
,
 NewElemTy = Context.getRealTypeForBitwidth(DestWidth, ExplicitType);
 
   if (NewElemTy.isNull()) {
-Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
+// Only emit diagnostic on host for 128-bit mode attribute

pranavk wrote:

This is going to error out like this:

```
error: 'a' requires 128 bit size '__float128' type support, but target 
'nvptx64-nvidia-cuda' does not support it
```

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


[clang] [clang][CUDA] Disable float128 diagnostics for device compilation (PR #83918)

2024-03-04 Thread Artem Belevich via cfe-commits


@@ -4877,7 +4877,9 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo 
,
 NewElemTy = Context.getRealTypeForBitwidth(DestWidth, ExplicitType);
 
   if (NewElemTy.isNull()) {
-Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
+// Only emit diagnostic on host for 128-bit mode attribute

Artem-B wrote:

What do you expect to see if __float128 is used from a GPU function.

Can you check on a toy example.

```
__attribute__((device)) __float128 f(__float128 a, float b) {
  __float128 c = b + 1.0;
  return a + c;
}
```

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


[clang] [clang][CUDA] Disable float128 diagnostics for device compilation (PR #83918)

2024-03-04 Thread Pranav Kant via cfe-commits

https://github.com/pranavk updated 
https://github.com/llvm/llvm-project/pull/83918

>From c28121199d5e16efb908a3058a52c6b5b2016848 Mon Sep 17 00:00:00 2001
From: Pranav Kant 
Date: Mon, 4 Mar 2024 22:19:04 +
Subject: [PATCH 1/2] [clang][CUDA] Disable float128 diagnostics for device
 compilation

---
 clang/lib/Sema/SemaDeclAttr.cpp | 4 +++-
 clang/lib/Sema/SemaType.cpp | 1 +
 clang/test/SemaCUDA/float128.cu | 9 +
 3 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/SemaCUDA/float128.cu

diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 397b5db0dc0669..e6943efb345ce0 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -4877,7 +4877,9 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo 
,
 NewElemTy = Context.getRealTypeForBitwidth(DestWidth, ExplicitType);
 
   if (NewElemTy.isNull()) {
-Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
+// Only emit diagnostic on host for 128-bit mode attribute
+if (!(DestWidth == 128 && getLangOpts().CUDAIsDevice))
+  Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
 return;
   }
 
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 1e43e36016a66f..4a4e6f80d0d049 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1562,6 +1562,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState 
) {
   case DeclSpec::TST_float128:
 if (!S.Context.getTargetInfo().hasFloat128Type() &&
 !S.getLangOpts().SYCLIsDevice &&
+!S.getLangOpts().CUDAIsDevice &&
 !(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsTargetDevice))
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
 << "__float128";
diff --git a/clang/test/SemaCUDA/float128.cu b/clang/test/SemaCUDA/float128.cu
new file mode 100644
index 00..a59e1b2f8a741a
--- /dev/null
+++ b/clang/test/SemaCUDA/float128.cu
@@ -0,0 +1,9 @@
+// CPU-side compilation on x86 (no errors expected).
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -aux-triple nvptx64 -x 
cuda -fsyntax-only -verify %s
+
+// GPU-side compilation on x86 (no errors expected)
+// RUN: %clang_cc1 -triple nvptx64 -aux-triple x86_64-unknown-linux-gnu 
-fcuda-is-device -x cuda -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
+typedef __float128 _Float128;

>From bcc8d6ea5e7922712017ecb1941a53cf769577b3 Mon Sep 17 00:00:00 2001
From: Pranav Kant 
Date: Mon, 4 Mar 2024 22:31:24 +
Subject: [PATCH 2/2] formatting

---
 clang/lib/Sema/SemaType.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 4a4e6f80d0d049..3148299f6467af 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1561,8 +1561,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState 
) {
 break;
   case DeclSpec::TST_float128:
 if (!S.Context.getTargetInfo().hasFloat128Type() &&
-!S.getLangOpts().SYCLIsDevice &&
-!S.getLangOpts().CUDAIsDevice &&
+!S.getLangOpts().SYCLIsDevice && !S.getLangOpts().CUDAIsDevice &&
 !(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsTargetDevice))
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
 << "__float128";

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


[clang] [clang][CUDA] Disable float128 diagnostics for device compilation (PR #83918)

2024-03-04 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff a5b797172cc902db166e9a695716fb81405f86e4 
39fa380fc3df9775e59b1957dca4a7f927702360 -- clang/lib/Sema/SemaDeclAttr.cpp 
clang/lib/Sema/SemaType.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 4a4e6f80d0..3148299f64 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1561,8 +1561,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState 
) {
 break;
   case DeclSpec::TST_float128:
 if (!S.Context.getTargetInfo().hasFloat128Type() &&
-!S.getLangOpts().SYCLIsDevice &&
-!S.getLangOpts().CUDAIsDevice &&
+!S.getLangOpts().SYCLIsDevice && !S.getLangOpts().CUDAIsDevice &&
 !(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsTargetDevice))
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
 << "__float128";

``




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


[clang] [clang][CUDA] Disable float128 diagnostics for device compilation (PR #83918)

2024-03-04 Thread Pranav Kant via cfe-commits

https://github.com/pranavk updated 
https://github.com/llvm/llvm-project/pull/83918

>From c28121199d5e16efb908a3058a52c6b5b2016848 Mon Sep 17 00:00:00 2001
From: Pranav Kant 
Date: Mon, 4 Mar 2024 22:19:04 +
Subject: [PATCH] [clang][CUDA] Disable float128 diagnostics for device
 compilation

---
 clang/lib/Sema/SemaDeclAttr.cpp | 4 +++-
 clang/lib/Sema/SemaType.cpp | 1 +
 clang/test/SemaCUDA/float128.cu | 9 +
 3 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/SemaCUDA/float128.cu

diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 397b5db0dc0669..e6943efb345ce0 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -4877,7 +4877,9 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo 
,
 NewElemTy = Context.getRealTypeForBitwidth(DestWidth, ExplicitType);
 
   if (NewElemTy.isNull()) {
-Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
+// Only emit diagnostic on host for 128-bit mode attribute
+if (!(DestWidth == 128 && getLangOpts().CUDAIsDevice))
+  Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
 return;
   }
 
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 1e43e36016a66f..4a4e6f80d0d049 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1562,6 +1562,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState 
) {
   case DeclSpec::TST_float128:
 if (!S.Context.getTargetInfo().hasFloat128Type() &&
 !S.getLangOpts().SYCLIsDevice &&
+!S.getLangOpts().CUDAIsDevice &&
 !(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsTargetDevice))
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
 << "__float128";
diff --git a/clang/test/SemaCUDA/float128.cu b/clang/test/SemaCUDA/float128.cu
new file mode 100644
index 00..a59e1b2f8a741a
--- /dev/null
+++ b/clang/test/SemaCUDA/float128.cu
@@ -0,0 +1,9 @@
+// CPU-side compilation on x86 (no errors expected).
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -aux-triple nvptx64 -x 
cuda -fsyntax-only -verify %s
+
+// GPU-side compilation on x86 (no errors expected)
+// RUN: %clang_cc1 -triple nvptx64 -aux-triple x86_64-unknown-linux-gnu 
-fcuda-is-device -x cuda -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
+typedef __float128 _Float128;

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


[clang] [clang][CUDA] Disable float128 diagnostics for device compilation (PR #83918)

2024-03-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Pranav Kant (pranavk)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/83918.diff


2 Files Affected:

- (modified) clang/lib/Sema/SemaDeclAttr.cpp (+3-1) 
- (modified) clang/lib/Sema/SemaType.cpp (+1) 


``diff
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 397b5db0dc0669..e6943efb345ce0 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -4877,7 +4877,9 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo 
,
 NewElemTy = Context.getRealTypeForBitwidth(DestWidth, ExplicitType);
 
   if (NewElemTy.isNull()) {
-Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
+// Only emit diagnostic on host for 128-bit mode attribute
+if (!(DestWidth == 128 && getLangOpts().CUDAIsDevice))
+  Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
 return;
   }
 
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 1e43e36016a66f..4a4e6f80d0d049 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1562,6 +1562,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState 
) {
   case DeclSpec::TST_float128:
 if (!S.Context.getTargetInfo().hasFloat128Type() &&
 !S.getLangOpts().SYCLIsDevice &&
+!S.getLangOpts().CUDAIsDevice &&
 !(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsTargetDevice))
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
 << "__float128";

``




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


[clang] [clang][CUDA] Disable float128 diagnostics for device compilation (PR #83918)

2024-03-04 Thread Pranav Kant via cfe-commits

https://github.com/pranavk created 
https://github.com/llvm/llvm-project/pull/83918

None

>From 39fa380fc3df9775e59b1957dca4a7f927702360 Mon Sep 17 00:00:00 2001
From: Pranav Kant 
Date: Mon, 4 Mar 2024 22:19:04 +
Subject: [PATCH] [clang][CUDA] Disable float128 diagnostics for device
 compilation

---
 clang/lib/Sema/SemaDeclAttr.cpp | 4 +++-
 clang/lib/Sema/SemaType.cpp | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 397b5db0dc0669..e6943efb345ce0 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -4877,7 +4877,9 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo 
,
 NewElemTy = Context.getRealTypeForBitwidth(DestWidth, ExplicitType);
 
   if (NewElemTy.isNull()) {
-Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
+// Only emit diagnostic on host for 128-bit mode attribute
+if (!(DestWidth == 128 && getLangOpts().CUDAIsDevice))
+  Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
 return;
   }
 
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 1e43e36016a66f..4a4e6f80d0d049 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1562,6 +1562,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState 
) {
   case DeclSpec::TST_float128:
 if (!S.Context.getTargetInfo().hasFloat128Type() &&
 !S.getLangOpts().SYCLIsDevice &&
+!S.getLangOpts().CUDAIsDevice &&
 !(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsTargetDevice))
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
 << "__float128";

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