[v2] IBM zSystems: Fix TARGET_D_CPU_VERSIONS

Message ID 20230124084701.258605-1-stefansf@linux.ibm.com
State Committed
Commit a4e725a10baf02c004c982772e22905fe99c1670
Headers
Series [v2] IBM zSystems: Fix TARGET_D_CPU_VERSIONS |

Commit Message

Stefan Schulze Frielinghaus Jan. 24, 2023, 8:47 a.m. UTC
  In the context of D the interpretation of S390, S390X, and SystemZ is a
bit fuzzy.  The wording S390X was wrongly deprecated in favour of
SystemZ by commit
https://github.com/dlang/dlang.org/commit/3b50a4c3faf01c32234d0ef8be5f82915a61c23f
Thus, SystemZ is used for 64-bit targets, now, and S390 for 31-bit
targets.  However, in TARGET_D_CPU_VERSIONS depending on TARGET_ZARCH we
set the CPU version to SystemZ.  This is also the case if compiled for
31-bit targets leading to the following error:

libphobos/libdruntime/core/sys/posix/sys/stat.d:967:13: error: static assert:  '96u == 144u' is false
  967 |             static assert(stat_t.sizeof == 144);
      |             ^

Thus in order to keep this patch simple I went for keeping SystemZ for
64-bit targets and S390, as usual, for 31-bit targets and dropped the
distinction between ESA and z/Architecture.

Bootstrapped and regtested on IBM zSystems.  Ok for mainline?

gcc/ChangeLog:

	* config/s390/s390-d.cc (s390_d_target_versions): Fix detection
	of CPU version.
---
 gcc/config/s390/s390-d.cc | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
  

Comments

Iain Buclaw Jan. 24, 2023, 11:05 a.m. UTC | #1
Excerpts from Stefan Schulze Frielinghaus's message of Januar 24, 2023 9:47 am:
> In the context of D the interpretation of S390, S390X, and SystemZ is a
> bit fuzzy.  The wording S390X was wrongly deprecated in favour of
> SystemZ by commit
> https://github.com/dlang/dlang.org/commit/3b50a4c3faf01c32234d0ef8be5f82915a61c23f
> Thus, SystemZ is used for 64-bit targets, now, and S390 for 31-bit
> targets.  However, in TARGET_D_CPU_VERSIONS depending on TARGET_ZARCH we
> set the CPU version to SystemZ.  This is also the case if compiled for
> 31-bit targets leading to the following error:
> 
> libphobos/libdruntime/core/sys/posix/sys/stat.d:967:13: error: static assert:  '96u == 144u' is false
>   967 |             static assert(stat_t.sizeof == 144);
>       |             ^
> 
> Thus in order to keep this patch simple I went for keeping SystemZ for
> 64-bit targets and S390, as usual, for 31-bit targets and dropped the
> distinction between ESA and z/Architecture.
> 
> Bootstrapped and regtested on IBM zSystems.  Ok for mainline?
> 

OK.
  
Andreas Krebbel Jan. 24, 2023, 4:04 p.m. UTC | #2
On 1/24/23 09:47, Stefan Schulze Frielinghaus wrote:
> In the context of D the interpretation of S390, S390X, and SystemZ is a
> bit fuzzy.  The wording S390X was wrongly deprecated in favour of
> SystemZ by commit
> https://github.com/dlang/dlang.org/commit/3b50a4c3faf01c32234d0ef8be5f82915a61c23f
> Thus, SystemZ is used for 64-bit targets, now, and S390 for 31-bit
> targets.  However, in TARGET_D_CPU_VERSIONS depending on TARGET_ZARCH we
> set the CPU version to SystemZ.  This is also the case if compiled for
> 31-bit targets leading to the following error:
> 
> libphobos/libdruntime/core/sys/posix/sys/stat.d:967:13: error: static assert:  '96u == 144u' is false
>   967 |             static assert(stat_t.sizeof == 144);
>       |             ^
> 
> Thus in order to keep this patch simple I went for keeping SystemZ for
> 64-bit targets and S390, as usual, for 31-bit targets and dropped the
> distinction between ESA and z/Architecture.
> 
> Bootstrapped and regtested on IBM zSystems.  Ok for mainline?
> 
> gcc/ChangeLog:
> 
> 	* config/s390/s390-d.cc (s390_d_target_versions): Fix detection
> 	of CPU version.

Ok, thanks!

Andreas
  

Patch

diff --git a/gcc/config/s390/s390-d.cc b/gcc/config/s390/s390-d.cc
index d10b45f7de4..6e9c80f7283 100644
--- a/gcc/config/s390/s390-d.cc
+++ b/gcc/config/s390/s390-d.cc
@@ -30,10 +30,11 @@  along with GCC; see the file COPYING3.  If not see
 void
 s390_d_target_versions (void)
 {
-  if (TARGET_ZARCH)
-    d_add_builtin_version ("SystemZ");
-  else if (TARGET_64BIT)
-    d_add_builtin_version ("S390X");
+  if (TARGET_64BIT)
+    {
+      d_add_builtin_version ("S390X");
+      d_add_builtin_version ("SystemZ");
+    }
   else
     d_add_builtin_version ("S390");