Skip to content

[SystemZ][zOS] disable _Float16 support on z/OS #145532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 26, 2025

Conversation

perry-ca
Copy link
Contributor

The new half float type (aka _Float16 ) isn't supported on z/OS.

@llvmbot llvmbot added clang Clang issues not falling into any other category backend:SystemZ clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jun 24, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 24, 2025

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-systemz

Author: Sean Perry (perry-ca)

Changes

The new half float type (aka _Float16 ) isn't supported on z/OS.


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

3 Files Affected:

  • (modified) clang/lib/Basic/Targets/SystemZ.h (+3-2)
  • (modified) clang/test/Sema/Float16.c (+1)
  • (modified) clang/test/SemaCXX/Float16.cpp (+1-1)
diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h
index 1f69530c4757f..bb7b6640570a5 100644
--- a/clang/lib/Basic/Targets/SystemZ.h
+++ b/clang/lib/Basic/Targets/SystemZ.h
@@ -76,6 +76,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
     MinGlobalAlign = 16;
     HasUnalignedAccess = true;
     if (Triple.isOSzOS()) {
+      HasFloat16 = false;
       if (Triple.isArch64Bit()) {
         AddrSpaceMap = &ZOSAddressMap;
       }
@@ -89,6 +90,8 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
       resetDataLayout("E-m:l-p1:32:32-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-"
                       "a:8:16-n32:64");
     } else {
+      // Support _Float16.
+      HasFloat16 = true;
       TLSSupported = true;
       resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64"
                       "-v128:64-a:8:16-n32:64");
@@ -102,8 +105,6 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
     // and instead the backend will promote each half operation to float
     // individually.
     HasLegalHalfType = false;
-    // Support _Float16.
-    HasFloat16 = true;
 
     HasStrictFP = true;
   }
diff --git a/clang/test/Sema/Float16.c b/clang/test/Sema/Float16.c
index 9269a0ded4eb9..2830213b6099f 100644
--- a/clang/test/Sema/Float16.c
+++ b/clang/test/Sema/Float16.c
@@ -6,6 +6,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-linux-gnu %s -DHAVE
 // RUN: %clang_cc1 -fsyntax-only -verify -triple riscv32 %s -DHAVE
 // RUN: %clang_cc1 -fsyntax-only -verify -triple riscv64 %s -DHAVE
+// RUN: %clang_cc1 -fsyntax-only -verify -triple s390x-ibm-zos %s
 
 #ifndef HAVE
 // expected-error@+2{{_Float16 is not supported on this target}}
diff --git a/clang/test/SemaCXX/Float16.cpp b/clang/test/SemaCXX/Float16.cpp
index 61b02a50687b9..9646a8d0c317f 100644
--- a/clang/test/SemaCXX/Float16.cpp
+++ b/clang/test/SemaCXX/Float16.cpp
@@ -4,7 +4,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -triple spir-unknown-unknown %s -DHAVE
 // RUN: %clang_cc1 -fsyntax-only -verify -triple armv7a-linux-gnu %s -DHAVE
 // RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-linux-gnu %s -DHAVE
-
+// RUN: %clang_cc1 -fsyntax-only -verify -triple s390x-ibm-zos %s
 #ifdef HAVE
 // expected-no-diagnostics
 #endif // HAVE

@perry-ca perry-ca self-assigned this Jun 24, 2025
Copy link
Member

@uweigand uweigand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is fine with me if this is what you want for z/OS. Note that on Linux, _Float16 also wasn't supported previously, we've made the choice to add it.

@perry-ca
Copy link
Contributor Author

I guess this is fine with me if this is what you want for z/OS. Note that on Linux, _Float16 also wasn't supported previously, we've made the choice to add it.

We don't see any reason not to support this either. However, we need to first update the z/OS ABI to ensure no binary compat issues. We'll enable it once we synchronize everything.

@perry-ca perry-ca merged commit a0c5f19 into llvm:main Jun 26, 2025
7 checks passed
anthonyhatran pushed a commit to anthonyhatran/llvm-project that referenced this pull request Jun 26, 2025
The new half float type (aka _Float16 ) isn't supported on z/OS.
@perry-ca perry-ca deleted the perry/zos-no-fp16 branch June 27, 2025 15:26
rlavaee pushed a commit to rlavaee/llvm-project that referenced this pull request Jul 1, 2025
The new half float type (aka _Float16 ) isn't supported on z/OS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:SystemZ clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants