r344611 - [SystemZ] Actually enable -mzvector keywords

2018-10-16 Thread Ulrich Weigand via cfe-commits
Author: uweigand
Date: Tue Oct 16 07:57:20 2018
New Revision: 344611

URL: http://llvm.org/viewvc/llvm-project?rev=344611&view=rev
Log:
[SystemZ] Actually enable -mzvector keywords

It appears when initially committing the support for the IBM Z vector
extension language, one critical line was lost, causing the specific
keywords __vector, __bool, and vec_step to not actually be enabled.
(Note that this does not affect "vector" and "bool"!)

Unfortunately, this was not caught by any tests either.  (All existing
Z vector tests just use the regular "vector" and "bool" keywords ...)

Fixed by adding the missing line and updating the tests.


Modified:
cfe/trunk/lib/Basic/IdentifierTable.cpp
cfe/trunk/test/Sema/zvector.c
cfe/trunk/test/Sema/zvector2.c

Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=344611&r1=344610&r2=344611&view=diff
==
--- cfe/trunk/lib/Basic/IdentifierTable.cpp (original)
+++ cfe/trunk/lib/Basic/IdentifierTable.cpp Tue Oct 16 07:57:20 2018
@@ -155,6 +155,7 @@ static KeywordStatus getKeywordStatus(co
   if (LangOpts.WChar && (Flags & WCHARSUPPORT)) return KS_Enabled;
   if (LangOpts.Char8 && (Flags & CHAR8SUPPORT)) return KS_Enabled;
   if (LangOpts.AltiVec && (Flags & KEYALTIVEC)) return KS_Enabled;
+  if (LangOpts.ZVector && (Flags & KEYZVECTOR)) return KS_Enabled;
   if (LangOpts.OpenCL && !LangOpts.OpenCLCPlusPlus && (Flags & KEYOPENCLC))
 return KS_Enabled;
   if (LangOpts.OpenCLCPlusPlus && (Flags & KEYOPENCLCXX)) return KS_Enabled;

Modified: cfe/trunk/test/Sema/zvector.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/zvector.c?rev=344611&r1=344610&r2=344611&view=diff
==
--- cfe/trunk/test/Sema/zvector.c (original)
+++ cfe/trunk/test/Sema/zvector.c Tue Oct 16 07:57:20 2018
@@ -37,6 +37,49 @@ unsigned long ul_scalar;
 
 double fd_scalar;
 
+// Verify that __vector is also recognized
+__vector signed char sc3;
+__vector unsigned char uc3;
+__vector bool char bc3;
+__vector signed short ss3;
+__vector unsigned short us3;
+__vector bool short bs3;
+__vector signed int si3;
+__vector unsigned int ui3;
+__vector bool int bi3;
+__vector signed long long sl3;
+__vector unsigned long long ul3;
+__vector bool long long bl3;
+__vector double fd3;
+__vector long ll3; // expected-error {{cannot use 'long' with '__vector'}}
+__vector float ff3; // expected-error {{cannot use 'float' with '__vector'}}
+
+// Likewise for __bool
+vector __bool char bc4;
+vector __bool short bs4;
+vector __bool int bi4;
+vector __bool long long bl4;
+__vector __bool char bc5;
+__vector __bool short bs5;
+__vector __bool int bi5;
+__vector __bool long long bl5;
+
+// Verify operation of vec_step
+int res_sc[vec_step(sc) == 16 ? 1 : -1];
+int res_uc[vec_step(uc) == 16 ? 1 : -1];
+int res_bc[vec_step(bc) == 16 ? 1 : -1];
+int res_ss[vec_step(ss) == 8 ? 1 : -1];
+int res_us[vec_step(us) == 8 ? 1 : -1];
+int res_bs[vec_step(bs) == 8 ? 1 : -1];
+int res_si[vec_step(si) == 4 ? 1 : -1];
+int res_ui[vec_step(ui) == 4 ? 1 : -1];
+int res_bi[vec_step(bi) == 4 ? 1 : -1];
+int res_sl[vec_step(sl) == 2 ? 1 : -1];
+int res_ul[vec_step(ul) == 2 ? 1 : -1];
+int res_bl[vec_step(bl) == 2 ? 1 : -1];
+int res_fd[vec_step(fd) == 2 ? 1 : -1];
+
+
 void foo(void)
 {
   // -

Modified: cfe/trunk/test/Sema/zvector2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/zvector2.c?rev=344611&r1=344610&r2=344611&view=diff
==
--- cfe/trunk/test/Sema/zvector2.c (original)
+++ cfe/trunk/test/Sema/zvector2.c Tue Oct 16 07:57:20 2018
@@ -22,6 +22,13 @@ vector double fd, fd2;
 
 vector float ff, ff2;
 
+// Verify that __vector is also recognized
+__vector float ff3;
+
+// Verify operation of vec_step
+int res_ff[vec_step(ff) == 4 ? 1 : -1];
+
+
 void foo(void)
 {
   // -


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


r348247 - [SystemZ] Do not support __float128

2018-12-04 Thread Ulrich Weigand via cfe-commits
Author: uweigand
Date: Tue Dec  4 02:51:36 2018
New Revision: 348247

URL: http://llvm.org/viewvc/llvm-project?rev=348247&view=rev
Log:
[SystemZ] Do not support __float128

As of rev. 268898, clang supports __float128 on SystemZ.  This seems to
have been in error.  GCC has never supported __float128 on SystemZ,
since the "long double" type on the platform is already IEEE-128. (GCC
only supports __float128 on platforms where "long double" is some other
data type.)

For compatibility reasons this patch removes __float128 on SystemZ
again.  The test case is updated accordingly.


Modified:
cfe/trunk/lib/Basic/Targets/OSTargets.h
cfe/trunk/test/CodeGenCXX/float128-declarations.cpp

Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=348247&r1=348246&r2=348247&view=diff
==
--- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h Tue Dec  4 02:51:36 2018
@@ -364,7 +364,6 @@ public:
   break;
 case llvm::Triple::x86:
 case llvm::Triple::x86_64:
-case llvm::Triple::systemz:
   this->HasFloat128 = true;
   break;
 }

Modified: cfe/trunk/test/CodeGenCXX/float128-declarations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/float128-declarations.cpp?rev=348247&r1=348246&r2=348247&view=diff
==
--- cfe/trunk/test/CodeGenCXX/float128-declarations.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/float128-declarations.cpp Tue Dec  4 02:51:36 2018
@@ -6,8 +6,6 @@
 // RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
 // RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-linux-gnu -std=c++11 \
 // RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
-// RUN: %clang_cc1 -emit-llvm -triple systemz-unknown-linux-gnu -std=c++11 \
-// RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-SYSZ
 // RUN: %clang_cc1 -emit-llvm -triple i686-pc-openbsd -std=c++11 \
 // RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
 // RUN: %clang_cc1 -emit-llvm -triple amd64-pc-openbsd -std=c++11 \
@@ -18,8 +16,7 @@
 // RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
 //
 /*  Various contexts where type __float128 can appear. The different check
-prefixes are due to different mangling on X86 and different calling
-convention on SystemZ. */
+prefixes are due to different mangling on X86.  */
 
 /*  Namespace */
 namespace {
@@ -122,25 +119,3 @@ int main(void) {
 // CHECK-X86-DAG: [[F4L:%[a-z0-9]+]] = load fp128, fp128* %f4l
 // CHECK-X86-DAG: [[INC:%[a-z0-9]+]] = fadd fp128 [[F4L]], 
0xL3FFF
 // CHECK-X86-DAG: store fp128 [[INC]], fp128* %f4l
-
-// CHECK-SYSZ-DAG: @_ZN12_GLOBAL__N_13f1nE = internal global fp128 
0xL
-// CHECK-SYSZ-DAG: @_ZN12_GLOBAL__N_13f2nE = internal global fp128 
0xL40040800
-// CHECK-SYSZ-DAG: @_ZN12_GLOBAL__N_15arr1nE = internal global [10 x fp128]
-// CHECK-SYSZ-DAG: @_ZN12_GLOBAL__N_15arr2nE = internal global [3 x fp128] 
[fp128 0xL3FFF, fp128 
0xL40008000, fp128 0xL4025176592E0]
-// CHECK-SYSZ-DAG: define internal void 
@_ZN12_GLOBAL__N_16func1nERKU10__float128(fp128*
-// CHECK-SYSZ-DAG: @f1f = global fp128 0xL
-// CHECK-SYSZ-DAG: @f2f = global fp128 0xL40040333
-// CHECK-SYSZ-DAG: @arr1f = global [10 x fp128]
-// CHECK-SYSZ-DAG: @arr2f = global [3 x fp128] [fp128 
0xLBFFF, fp128 0xLC0008000, 
fp128 0xLC025176592E0]
-// CHECK-SYSZ-DAG: declare void @_Z6func1fU10__float128(fp128*
-// CHECK-SYSZ-DAG: define linkonce_odr void @_ZN2C1C2EU10__float128(%class.C1* 
%this, fp128*
-// CHECK-SYSZ-DAG: define linkonce_odr void @_ZN2C16func2cEU10__float128(fp128*
-// CHECK-SYSZ-DAG: define linkonce_odr void 
@_Z6func1tIU10__float128ET_S0_(fp128*
-// CHECK-SYSZ-DAG: @__const.main.s1 = private unnamed_addr constant %struct.S1 
{ fp128 0xL40060800 }
-// CHECK-SYSZ-DAG: store fp128 0xLF0AFD0EBFF292DCE42E0B38CDD83F26F, fp128* 
%f1l, align 16
-// CHECK-SYSZ-DAG: store fp128 0xL8000, fp128* 
%f2l, align 16
-// CHECK-SYSZ-DAG: store fp128 0xL7FFE, fp128* 
%f3l, align 16
-// CHECK-SYSZ-DAG: store fp128 0xLBFFF, fp128* 
%f5l, align 16
-// CHECK-SYSZ-DAG: [[F4L:%[a-z0-9]+]] = load fp128, fp128* %f4l
-// CHECK-SYSZ-DAG: [[INC:%[a-z0-9]+]] = fadd fp128 [[F4L]], 
0xL3FFF
-// CHECK-SYSZ-DAG: store fp128 [[INC]], fp128* %f4l


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


r365933 - [SystemZ] Add support for new cpu architecture - arch13

2019-07-12 Thread Ulrich Weigand via cfe-commits
Author: uweigand
Date: Fri Jul 12 11:14:51 2019
New Revision: 365933

URL: http://llvm.org/viewvc/llvm-project?rev=365933&view=rev
Log:
[SystemZ] Add support for new cpu architecture - arch13

This patch series adds support for the next-generation arch13
CPU architecture to the SystemZ backend.

This includes:
- Basic support for the new processor and its features.
- Support for low-level builtins mapped to new LLVM intrinsics.
- New high-level intrinsics in vecintrin.h.
- Indicate support by defining  __VEC__ == 10303.

Note: No currently available Z system supports the arch13
architecture.  Once new systems become available, the
official system name will be added as supported -march name.


Added:
cfe/trunk/test/CodeGen/builtins-systemz-vector3-error.c
cfe/trunk/test/CodeGen/builtins-systemz-vector3.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector3-error.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector3.c
Modified:
cfe/trunk/include/clang/Basic/BuiltinsSystemZ.def
cfe/trunk/lib/Basic/Targets/SystemZ.cpp
cfe/trunk/lib/Basic/Targets/SystemZ.h
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/vecintrin.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/builtins-systemz-zvector.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector2.c
cfe/trunk/test/CodeGen/systemz-abi-vector.c
cfe/trunk/test/CodeGen/systemz-abi.c
cfe/trunk/test/CodeGen/target-data.c
cfe/trunk/test/Driver/systemz-march.c
cfe/trunk/test/Misc/target-invalid-cpu-note.c
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsSystemZ.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsSystemZ.def?rev=365933&r1=365932&r2=365933&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsSystemZ.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsSystemZ.def Fri Jul 12 11:14:51 2019
@@ -276,5 +276,20 @@ TARGET_BUILTIN(__builtin_s390_vfnmssb, "
 TARGET_BUILTIN(__builtin_s390_vfsqsb, "V4fV4f", "nc", "vector-enhancements-1")
 TARGET_BUILTIN(__builtin_s390_vftcisb, "V4SiV4fIii*", "nc", 
"vector-enhancements-1")
 
+// Vector-enhancements facility 2 intrinsics.
+TARGET_BUILTIN(__builtin_s390_vsld, "V16UcV16UcV16UcIi", "nc", 
"vector-enhancements-2")
+TARGET_BUILTIN(__builtin_s390_vsrd, "V16UcV16UcV16UcIi", "nc", 
"vector-enhancements-2")
+TARGET_BUILTIN(__builtin_s390_vstrsb, "V16UcV16UcV16UcV16Uci*", "nc", 
"vector-enhancements-2")
+TARGET_BUILTIN(__builtin_s390_vstrsh, "V16UcV8UsV8UsV16Uci*", "nc", 
"vector-enhancements-2")
+TARGET_BUILTIN(__builtin_s390_vstrsf, "V16UcV4UiV4UiV16Uci*", "nc", 
"vector-enhancements-2")
+TARGET_BUILTIN(__builtin_s390_vstrszb, "V16UcV16UcV16UcV16Uci*", "nc", 
"vector-enhancements-2")
+TARGET_BUILTIN(__builtin_s390_vstrszh, "V16UcV8UsV8UsV16Uci*", "nc", 
"vector-enhancements-2")
+TARGET_BUILTIN(__builtin_s390_vstrszf, "V16UcV4UiV4UiV16Uci*", "nc", 
"vector-enhancements-2")
+
+// Helpers to implement vec_revb.
+TARGET_BUILTIN(__builtin_s390_vlbrh, "V8UsV8Us", "nc", "vector")
+TARGET_BUILTIN(__builtin_s390_vlbrf, "V4UiV4Ui", "nc", "vector")
+TARGET_BUILTIN(__builtin_s390_vlbrg, "V2ULLiV2ULLi", "nc", "vector")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Basic/Targets/SystemZ.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/SystemZ.cpp?rev=365933&r1=365932&r2=365933&view=diff
==
--- cfe/trunk/lib/Basic/Targets/SystemZ.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/SystemZ.cpp Fri Jul 12 11:14:51 2019
@@ -91,7 +91,8 @@ static constexpr ISANameRevision ISARevi
   {{"arch9"}, 9}, {{"z196"}, 9},
   {{"arch10"}, 10}, {{"zEC12"}, 10},
   {{"arch11"}, 11}, {{"z13"}, 11},
-  {{"arch12"}, 12}, {{"z14"}, 12}
+  {{"arch12"}, 12}, {{"z14"}, 12},
+  {{"arch13"}, 13},
 };
 
 int SystemZTargetInfo::getISARevision(StringRef Name) const {
@@ -118,6 +119,7 @@ bool SystemZTargetInfo::hasFeature(Strin
   .Case("arch10", ISARevision >= 10)
   .Case("arch11", ISARevision >= 11)
   .Case("arch12", ISARevision >= 12)
+  .Case("arch13", ISARevision >= 13)
   .Case("htm", HasTransactionalExecution)
   .Case("vx", HasVector)
   .Default(false);
@@ -142,7 +144,7 @@ void SystemZTargetInfo::getTargetDefines
   if (HasVector)
 Builder.defineMacro("__VX__");
   if (Opts.ZVector)
-Builder.defineMacro("__VEC__", "10302");
+Builder.defineMacro("__VEC__", "10303");
 }
 
 ArrayRef SystemZTargetInfo::getTargetBuiltins() const {

Modified: cfe/trunk/lib/Basic/Targets/SystemZ.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/SystemZ.h?rev=365933&r1=365932&r2=365933&view=diff
==
--- cfe/trunk/lib/Basic/Targets/SystemZ.h (original)
+++ cfe/trunk/lib/Basic/Targets/SystemZ.h Fri

r349751 - [SystemZ] Fix wrong codegen caused by typos in vecintrin.h

2018-12-20 Thread Ulrich Weigand via cfe-commits
Author: uweigand
Date: Thu Dec 20 05:09:09 2018
New Revision: 349751

URL: http://llvm.org/viewvc/llvm-project?rev=349751&view=rev
Log:
[SystemZ] Fix wrong codegen caused by typos in vecintrin.h

The following two bugs in SystemZ high-level vector intrinsics are
fixes by this patch:

- The float case of vec_insert_and_zero should generate a VLLEZF
  pattern, but currently erroneously generates VLLEZLF.

- The float and double versions of vec_orc erroneously generate
  and-with-complement instead of or-with-complement.

The patch also fixes a couple of typos in the associated test.


Modified:
cfe/trunk/lib/Headers/vecintrin.h
cfe/trunk/test/CodeGen/builtins-systemz-zvector2.c

Modified: cfe/trunk/lib/Headers/vecintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/vecintrin.h?rev=349751&r1=349750&r2=349751&view=diff
==
--- cfe/trunk/lib/Headers/vecintrin.h (original)
+++ cfe/trunk/lib/Headers/vecintrin.h Thu Dec 20 05:09:09 2018
@@ -381,7 +381,7 @@ vec_insert_and_zero(const unsigned long
 static inline __ATTRS_o_ai vector float
 vec_insert_and_zero(const float *__ptr) {
   vector float __vec = (vector float)0;
-  __vec[0] = *__ptr;
+  __vec[1] = *__ptr;
   return __vec;
 }
 #endif
@@ -5942,13 +5942,13 @@ vec_orc(vector unsigned long long __a, v
 
 static inline __ATTRS_o_ai vector float
 vec_orc(vector float __a, vector float __b) {
-  return (vector float)((vector unsigned int)__a &
+  return (vector float)((vector unsigned int)__a |
 ~(vector unsigned int)__b);
 }
 
 static inline __ATTRS_o_ai vector double
 vec_orc(vector double __a, vector double __b) {
-  return (vector double)((vector unsigned long long)__a &
+  return (vector double)((vector unsigned long long)__a |
  ~(vector unsigned long long)__b);
 }
 #endif

Modified: cfe/trunk/test/CodeGen/builtins-systemz-zvector2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-systemz-zvector2.c?rev=349751&r1=349750&r2=349751&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-systemz-zvector2.c (original)
+++ cfe/trunk/test/CodeGen/builtins-systemz-zvector2.c Thu Dec 20 05:09:09 2018
@@ -65,9 +65,9 @@ void test_core(void) {
   d = vec_extract(vd, idx);
   // CHECK: extractelement <2 x double> %{{.*}}, i32 %{{.*}}
 
-  vf = vec_insert(d, vf, idx);
+  vf = vec_insert(f, vf, idx);
   // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 %{{.*}}
-  vd = vec_insert(f, vd, idx);
+  vd = vec_insert(d, vd, idx);
   // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 %{{.*}}
 
   vf = vec_promote(f, idx);
@@ -76,7 +76,7 @@ void test_core(void) {
   // CHECK: insertelement <2 x double> undef, double %{{.*}}, i32 %{{.*}}
 
   vf = vec_insert_and_zero(cptrf);
-  // CHECK: insertelement <4 x float> , float %{{.*}}, i32 0
+  // CHECK: insertelement <4 x float> , float %{{.*}}, i32 1
   vd = vec_insert_and_zero(cptrd);
   // CHECK: insertelement <2 x double> , 
double %{{.*}}, i32 0
 
@@ -227,8 +227,8 @@ void test_compare(void) {
   idx = vec_all_lt(vd, vd);
   // CHECK: call { <2 x i64>, i32 } @llvm.s390.vfchdbs(<2 x double> %{{.*}}, 
<2 x double> %{{.*}})
 
-  idx = vec_all_nge(vd, vd);
-  // CHECK: call { <2 x i64>, i32 } @llvm.s390.vfchedbs(<2 x double> %{{.*}}, 
<2 x double> %{{.*}})
+  idx = vec_all_nge(vf, vf);
+  // CHECK: call { <4 x i32>, i32 } @llvm.s390.vfchesbs(<4 x float> %{{.*}}, 
<4 x float> %{{.*}})
   idx = vec_all_nge(vd, vd);
   // CHECK: call { <2 x i64>, i32 } @llvm.s390.vfchedbs(<2 x double> %{{.*}}, 
<2 x double> %{{.*}})
 


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


r372436 - [SystemZ] Support z15 processor name

2019-09-20 Thread Ulrich Weigand via cfe-commits
Author: uweigand
Date: Fri Sep 20 16:06:03 2019
New Revision: 372436

URL: http://llvm.org/viewvc/llvm-project?rev=372436&view=rev
Log:
[SystemZ] Support z15 processor name

The recently announced IBM z15 processor implements the architecture
already supported as "arch13" in LLVM.  This patch adds support for
"z15" as an alternate architecture name for arch13.

Corrsponding LLVM support was committed as rev. 372435.


Modified:
cfe/trunk/lib/Basic/Targets/SystemZ.cpp
cfe/trunk/test/CodeGen/builtins-systemz-vector3-error.c
cfe/trunk/test/CodeGen/builtins-systemz-vector3.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector3-error.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector3.c
cfe/trunk/test/CodeGen/systemz-abi-vector.c
cfe/trunk/test/CodeGen/systemz-abi.c
cfe/trunk/test/CodeGen/target-data.c
cfe/trunk/test/Driver/systemz-march.c
cfe/trunk/test/Misc/target-invalid-cpu-note.c
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets/SystemZ.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/SystemZ.cpp?rev=372436&r1=372435&r2=372436&view=diff
==
--- cfe/trunk/lib/Basic/Targets/SystemZ.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/SystemZ.cpp Fri Sep 20 16:06:03 2019
@@ -92,7 +92,7 @@ static constexpr ISANameRevision ISARevi
   {{"arch10"}, 10}, {{"zEC12"}, 10},
   {{"arch11"}, 11}, {{"z13"}, 11},
   {{"arch12"}, 12}, {{"z14"}, 12},
-  {{"arch13"}, 13},
+  {{"arch13"}, 13}, {{"z15"}, 13}
 };
 
 int SystemZTargetInfo::getISARevision(StringRef Name) const {

Modified: cfe/trunk/test/CodeGen/builtins-systemz-vector3-error.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-systemz-vector3-error.c?rev=372436&r1=372435&r2=372436&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-systemz-vector3-error.c (original)
+++ cfe/trunk/test/CodeGen/builtins-systemz-vector3-error.c Fri Sep 20 16:06:03 
2019
@@ -1,5 +1,5 @@
 // REQUIRES: systemz-registered-target
-// RUN: %clang_cc1 -target-cpu arch13 -triple s390x-unknown-unknown \
+// RUN: %clang_cc1 -target-cpu z15 -triple s390x-unknown-unknown \
 // RUN: -Wall -Wno-unused -Werror -fsyntax-only -verify %s
 
 typedef __attribute__((vector_size(16))) signed char vec_schar;

Modified: cfe/trunk/test/CodeGen/builtins-systemz-vector3.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-systemz-vector3.c?rev=372436&r1=372435&r2=372436&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-systemz-vector3.c (original)
+++ cfe/trunk/test/CodeGen/builtins-systemz-vector3.c Fri Sep 20 16:06:03 2019
@@ -1,5 +1,5 @@
 // REQUIRES: systemz-registered-target
-// RUN: %clang_cc1 -target-cpu arch13 -triple s390x-ibm-linux 
-flax-vector-conversions=none \
+// RUN: %clang_cc1 -target-cpu z15 -triple s390x-ibm-linux 
-flax-vector-conversions=none \
 // RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
 
 typedef __attribute__((vector_size(16))) signed char vec_schar;

Modified: cfe/trunk/test/CodeGen/builtins-systemz-zvector3-error.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-systemz-zvector3-error.c?rev=372436&r1=372435&r2=372436&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-systemz-zvector3-error.c (original)
+++ cfe/trunk/test/CodeGen/builtins-systemz-zvector3-error.c Fri Sep 20 
16:06:03 2019
@@ -1,5 +1,5 @@
 // REQUIRES: systemz-registered-target
-// RUN: %clang_cc1 -target-cpu arch13 -triple s390x-linux-gnu \
+// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
 // RUN: -fzvector -flax-vector-conversions=none \
 // RUN: -Wall -Wno-unused -Werror -fsyntax-only -verify %s
 

Modified: cfe/trunk/test/CodeGen/builtins-systemz-zvector3.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-systemz-zvector3.c?rev=372436&r1=372435&r2=372436&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-systemz-zvector3.c (original)
+++ cfe/trunk/test/CodeGen/builtins-systemz-zvector3.c Fri Sep 20 16:06:03 2019
@@ -1,8 +1,8 @@
 // REQUIRES: systemz-registered-target
-// RUN: %clang_cc1 -target-cpu arch13 -triple s390x-linux-gnu \
+// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
 // RUN: -O -fzvector -flax-vector-conversions=none \
 // RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -target-cpu arch13 -triple s390x-linux-gnu \
+// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
 // RUN: -O -fzvector -flax-vector-conversions=none \
 // RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s 
--check-prefix=CHECK-ASM
 

Modified: cfe/trunk/test/CodeGen/systemz-

[clang] 7f00395 - [SystemZ] Implement __builtin_eh_return_data_regno

2020-07-24 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2020-07-24T10:28:06+02:00
New Revision: 7f003957bfcd1ed29ded176f04e3cdb55a0c0112

URL: 
https://github.com/llvm/llvm-project/commit/7f003957bfcd1ed29ded176f04e3cdb55a0c0112
DIFF: 
https://github.com/llvm/llvm-project/commit/7f003957bfcd1ed29ded176f04e3cdb55a0c0112.diff

LOG: [SystemZ] Implement __builtin_eh_return_data_regno

Implement __builtin_eh_return_data_regno for SystemZ.
Match behavior of GCC.

Author: slavek-kucera

Differential Revision: https://reviews.llvm.org/D84341

Added: 


Modified: 
clang/lib/Basic/Targets/SystemZ.h
clang/test/CodeGen/builtins-systemz.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/SystemZ.h 
b/clang/lib/Basic/Targets/SystemZ.h
index d7869e3754a8..39fdcf90d0c8 100644
--- a/clang/lib/Basic/Targets/SystemZ.h
+++ b/clang/lib/Basic/Targets/SystemZ.h
@@ -157,6 +157,10 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public 
TargetInfo {
   const char *getLongDoubleMangling() const override { return "g"; }
 
   bool hasExtIntType() const override { return true; }
+
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+return RegNo < 4 ? 6 + RegNo : -1;
+  }
 };
 } // namespace targets
 } // namespace clang

diff  --git a/clang/test/CodeGen/builtins-systemz.c 
b/clang/test/CodeGen/builtins-systemz.c
index f5de7009acba..bf8a995383a2 100644
--- a/clang/test/CodeGen/builtins-systemz.c
+++ b/clang/test/CodeGen/builtins-systemz.c
@@ -142,3 +142,10 @@ void test_htmxl1(void) {
   result = __TM_failure_code (tdb);
 }
 
+void test_eh_return_data_regno() {
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0); // CHECK: store volatile i32 6
+  res = __builtin_eh_return_data_regno(1); // CHECK: store volatile i32 7
+  res = __builtin_eh_return_data_regno(2); // CHECK: store volatile i32 8
+  res = __builtin_eh_return_data_regno(3); // CHECK: store volatile i32 9
+}



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


[clang] 80a1b95 - [SystemZ ABI] Allow class types in GetSingleElementType

2020-07-07 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2020-07-07T19:56:19+02:00
New Revision: 80a1b95b8e72674cef7efb39636dc73c248ae6f3

URL: 
https://github.com/llvm/llvm-project/commit/80a1b95b8e72674cef7efb39636dc73c248ae6f3
DIFF: 
https://github.com/llvm/llvm-project/commit/80a1b95b8e72674cef7efb39636dc73c248ae6f3.diff

LOG: [SystemZ ABI] Allow class types in GetSingleElementType

The SystemZ ABI specifies that aggregate types with just a single
member of floating-point type shall be passed as if they were just
a scalar of that type.  This applies to both struct and class types
(but not unions).

However, the current ABI support code in clang only checks this
case for struct types, which means that for class types, generated
code does not adhere to the platform ABI.

Fixed by accepting both struct and class types in the
SystemZABIInfo::GetSingleElementType routine.

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/systemz-abi.c
clang/test/CodeGen/systemz-abi.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 7947aff6cc2f..801adc29acd1 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -7208,7 +7208,9 @@ bool SystemZABIInfo::isFPArgumentType(QualType Ty) const {
 }
 
 QualType SystemZABIInfo::GetSingleElementType(QualType Ty) const {
-  if (const RecordType *RT = Ty->getAsStructureType()) {
+  const RecordType *RT = Ty->getAs();
+
+  if (RT && RT->isStructureOrClassType()) {
 const RecordDecl *RD = RT->getDecl();
 QualType Found;
 

diff  --git a/clang/test/CodeGen/systemz-abi.c 
b/clang/test/CodeGen/systemz-abi.c
index 35adbbe301c4..9f9cb2275bfa 100644
--- a/clang/test/CodeGen/systemz-abi.c
+++ b/clang/test/CodeGen/systemz-abi.c
@@ -155,6 +155,17 @@ struct agg_nofloat3 pass_agg_nofloat3(struct agg_nofloat3 
arg) { return arg; }
 // CHECK-LABEL: define void @pass_agg_nofloat3(%struct.agg_nofloat3* noalias 
sret align 4 %{{.*}}, i32 %{{.*}})
 
 
+// Union types likewise are *not* float-like aggregate types
+
+union union_float { float a; };
+union union_float pass_union_float(union union_float arg) { return arg; }
+// CHECK-LABEL: define void @pass_union_float(%union.union_float* noalias sret 
align 4 %{{.*}}, i32 %{{.*}})
+
+union union_double { double a; };
+union union_double pass_union_double(union union_double arg) { return arg; }
+// CHECK-LABEL: define void @pass_union_double(%union.union_double* noalias 
sret align 8 %{{.*}}, i64 %{{.*}})
+
+
 // Accessing variable argument lists
 
 int va_int(__builtin_va_list l) { return __builtin_va_arg(l, int); }

diff  --git a/clang/test/CodeGen/systemz-abi.cpp 
b/clang/test/CodeGen/systemz-abi.cpp
index cb381e88dd8f..7604dea41dde 100644
--- a/clang/test/CodeGen/systemz-abi.cpp
+++ b/clang/test/CodeGen/systemz-abi.cpp
@@ -2,10 +2,24 @@
 // RUN: %clang_cc1 -triple s390x-linux-gnu -emit-llvm -x c++ -o - %s 
-mfloat-abi soft \
 // RUN:   | FileCheck %s --check-prefix=SOFT-FLOAT
 
+// Verify that class types are also recognized as float-like aggregate types
+
+class agg_float_class { float a; };
+class agg_float_class pass_agg_float_class(class agg_float_class arg) { return 
arg; }
+// CHECK-LABEL: define void 
@_Z20pass_agg_float_class15agg_float_class(%class.agg_float_class* noalias sret 
align 4 %{{.*}}, float %{{.*}})
+// SOFT-FLOAT-LABEL: define void 
@_Z20pass_agg_float_class15agg_float_class(%class.agg_float_class* noalias sret 
align 4 %{{.*}}, i32 %{{.*}})
+
+class agg_double_class { double a; };
+class agg_double_class pass_agg_double_class(class agg_double_class arg) { 
return arg; }
+// CHECK-LABEL: define void 
@_Z21pass_agg_double_class16agg_double_class(%class.agg_double_class* noalias 
sret align 8 %{{.*}}, double %{{.*}})
+// SOFT-FLOAT-LABEL: define void 
@_Z21pass_agg_double_class16agg_double_class(%class.agg_double_class* noalias 
sret align 8 %{{.*}}, i64 %{{.*}})
+
+
 // For compatibility with GCC, this structure is passed in an FPR in C++,
 // but passed in a GPR in C (checked in systemz-abi.c).
 
 struct agg_float_cpp { float a; int : 0; };
 struct agg_float_cpp pass_agg_float_cpp(struct agg_float_cpp arg) { return 
arg; }
 // CHECK-LABEL: define void 
@_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret 
align 4 %{{.*}}, float %{{.*}})
-// SOFT-FLOAT:  define void 
@_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret 
align 4 %{{.*}}, i32 %{{.*}})
+// SOFT-FLOAT-LABEL:  define void 
@_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret 
align 4 %{{.*}}, i32 %{{.*}})
+



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


[clang] 4c5a93b - [ABI] Handle C++20 [[no_unique_address]] attribute

2020-07-10 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2020-07-10T14:01:05+02:00
New Revision: 4c5a93bd58bad70e91ac525b0e020bd5119a321a

URL: 
https://github.com/llvm/llvm-project/commit/4c5a93bd58bad70e91ac525b0e020bd5119a321a
DIFF: 
https://github.com/llvm/llvm-project/commit/4c5a93bd58bad70e91ac525b0e020bd5119a321a.diff

LOG: [ABI] Handle C++20 [[no_unique_address]] attribute

Many platform ABIs have special support for passing aggregates that
either just contain a single member of floatint-point type, or else
a homogeneous set of members of the same floating-point type.

When making this determination, any extra "empty" members of the
aggregate type will typically be ignored.  However, in C++ (at least
in all prior versions), no data member would actually count as empty,
even if it's type is an empty record -- it would still be considered
to take up at least one byte of space, and therefore make those ABI
special cases not apply.

This is now changing in C++20, which introduced the [[no_unique_address]]
attribute.  Members of empty record type, if they also carry this
attribute, now do *not* take up any space in the type, and therefore
the ABI special cases for single-element or homogeneous aggregates
should apply.

The C++ Itanium ABI has been updated accordingly, and GCC 10 has
added support for this new case.  This patch now adds support to
LLVM.  This is cross-platform; it affects all platforms that use
the single-element or homogeneous aggregate ABI special case and
implement this using any of the following common subroutines
in lib/CodeGen/TargetInfo.cpp:
  isEmptyField
  isEmptyRecord
  isSingleElementStruct
  isHomogeneousAggregate

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/systemz-abi.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index b83267dec6f0..9cd63ebe29ee 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -499,11 +499,15 @@ static bool isEmptyField(ASTContext &Context, const 
FieldDecl *FD,
 
   // Constant arrays of empty records count as empty, strip them off.
   // Constant arrays of zero length always count as empty.
+  bool WasArray = false;
   if (AllowArrays)
 while (const ConstantArrayType *AT = Context.getAsConstantArrayType(FT)) {
   if (AT->getSize() == 0)
 return true;
   FT = AT->getElementType();
+  // The [[no_unique_address]] special case below does not apply to
+  // arrays of C++ empty records, so we need to remember this fact.
+  WasArray = true;
 }
 
   const RecordType *RT = FT->getAs();
@@ -514,7 +518,14 @@ static bool isEmptyField(ASTContext &Context, const 
FieldDecl *FD,
   //
   // FIXME: We should use a predicate for whether this behavior is true in the
   // current ABI.
-  if (isa(RT->getDecl()))
+  //
+  // The exception to the above rule are fields marked with the
+  // [[no_unique_address]] attribute (since C++20).  Those do count as empty
+  // according to the Itanium ABI.  The exception applies only to records,
+  // not arrays of records, so we must also check whether we stripped off an
+  // array type above.
+  if (isa(RT->getDecl()) &&
+  (WasArray || !FD->hasAttr()))
 return false;
 
   return isEmptyRecord(Context, FT, AllowArrays);
@@ -7236,6 +7247,10 @@ QualType SystemZABIInfo::GetSingleElementType(QualType 
Ty) const {
   if (getContext().getLangOpts().CPlusPlus &&
   FD->isZeroLengthBitField(getContext()))
 continue;
+  // Like isSingleElementStruct(), ignore C++20 empty data members.
+  if (FD->hasAttr() &&
+  isEmptyRecord(getContext(), FD->getType(), true))
+continue;
 
   // Unlike isSingleElementStruct(), arrays do not count.
   // Nested structures still do though.

diff  --git a/clang/test/CodeGen/systemz-abi.cpp 
b/clang/test/CodeGen/systemz-abi.cpp
index 7604dea41dde..a91cb72ae33e 100644
--- a/clang/test/CodeGen/systemz-abi.cpp
+++ b/clang/test/CodeGen/systemz-abi.cpp
@@ -23,3 +23,37 @@ struct agg_float_cpp pass_agg_float_cpp(struct agg_float_cpp 
arg) { return arg;
 // CHECK-LABEL: define void 
@_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret 
align 4 %{{.*}}, float %{{.*}})
 // SOFT-FLOAT-LABEL:  define void 
@_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret 
align 4 %{{.*}}, i32 %{{.*}})
 
+
+// A field member of empty class type in C++ makes the record nonhomogeneous,
+// unless it is marked as [[no_unique_address]].  This does not apply to 
arrays.
+struct empty { };
+struct agg_nofloat_empty { float a; empty dummy; };
+struct agg_nofloat_empty pass_agg_nofloat_empty(struct agg_nofloat_empty arg) 
{ return arg; }
+// CHECK-LABEL: define void 
@_Z22pass_agg_nofloat_empty17agg_nofloat_empty(%struct.agg_nofloat_empty* 
noalias sret align 4 %{{.*}}, i64 %{{.*}})
+// SOFT-FLOAT-LABEL:  define void 

[clang] 095ccf4 - [SystemZ] Avoid __INTPTR_TYPE__ conversions in vecintrin.h

2020-04-28 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2020-04-28T18:49:49+02:00
New Revision: 095ccf4455654750cd4c0296ff91565c2b613319

URL: 
https://github.com/llvm/llvm-project/commit/095ccf4455654750cd4c0296ff91565c2b613319
DIFF: 
https://github.com/llvm/llvm-project/commit/095ccf4455654750cd4c0296ff91565c2b613319.diff

LOG: [SystemZ] Avoid __INTPTR_TYPE__ conversions in vecintrin.h

Some intrinsics in vecintrin.h are currently implemented by
performing address arithmetic in __INTPTR_TYPE__ and converting
the result to some pointer type.  While this works correctly,
it leads to suboptimal code generation since many optimizers
cannot trace the provenance of the resulting pointers.

Fixed by using "char *" pointer arithmetic instead.

Added: 


Modified: 
clang/lib/Headers/vecintrin.h

Removed: 




diff  --git a/clang/lib/Headers/vecintrin.h b/clang/lib/Headers/vecintrin.h
index aa2a0c300120..e58c9769e8cb 100644
--- a/clang/lib/Headers/vecintrin.h
+++ b/clang/lib/Headers/vecintrin.h
@@ -860,7 +860,7 @@ vec_gather_element(__vector signed int __vec,
const signed int *__ptr, int __index)
   __constant_range(__index, 0, 3) {
   __vec[__index] = *(const signed int *)(
-(__INTPTR_TYPE__)__ptr + (__INTPTR_TYPE__)__offset[__index]);
+(const char *)__ptr + __offset[__index]);
   return __vec;
 }
 
@@ -870,7 +870,7 @@ vec_gather_element(__vector __bool int __vec,
const unsigned int *__ptr, int __index)
   __constant_range(__index, 0, 3) {
   __vec[__index] = *(const unsigned int *)(
-(__INTPTR_TYPE__)__ptr + (__INTPTR_TYPE__)__offset[__index]);
+(const char *)__ptr + __offset[__index]);
   return __vec;
 }
 
@@ -880,7 +880,7 @@ vec_gather_element(__vector unsigned int __vec,
const unsigned int *__ptr, int __index)
   __constant_range(__index, 0, 3) {
   __vec[__index] = *(const unsigned int *)(
-(__INTPTR_TYPE__)__ptr + (__INTPTR_TYPE__)__offset[__index]);
+(const char *)__ptr + __offset[__index]);
   return __vec;
 }
 
@@ -890,7 +890,7 @@ vec_gather_element(__vector signed long long __vec,
const signed long long *__ptr, int __index)
   __constant_range(__index, 0, 1) {
   __vec[__index] = *(const signed long long *)(
-(__INTPTR_TYPE__)__ptr + (__INTPTR_TYPE__)__offset[__index]);
+(const char *)__ptr + __offset[__index]);
   return __vec;
 }
 
@@ -900,7 +900,7 @@ vec_gather_element(__vector __bool long long __vec,
const unsigned long long *__ptr, int __index)
   __constant_range(__index, 0, 1) {
   __vec[__index] = *(const unsigned long long *)(
-(__INTPTR_TYPE__)__ptr + (__INTPTR_TYPE__)__offset[__index]);
+(const char *)__ptr + __offset[__index]);
   return __vec;
 }
 
@@ -910,7 +910,7 @@ vec_gather_element(__vector unsigned long long __vec,
const unsigned long long *__ptr, int __index)
   __constant_range(__index, 0, 1) {
   __vec[__index] = *(const unsigned long long *)(
-(__INTPTR_TYPE__)__ptr + (__INTPTR_TYPE__)__offset[__index]);
+(const char *)__ptr + __offset[__index]);
   return __vec;
 }
 
@@ -921,7 +921,7 @@ vec_gather_element(__vector float __vec,
const float *__ptr, int __index)
   __constant_range(__index, 0, 3) {
   __vec[__index] = *(const float *)(
-(__INTPTR_TYPE__)__ptr + (__INTPTR_TYPE__)__offset[__index]);
+(const char *)__ptr + __offset[__index]);
   return __vec;
 }
 #endif
@@ -932,7 +932,7 @@ vec_gather_element(__vector double __vec,
const double *__ptr, int __index)
   __constant_range(__index, 0, 1) {
   __vec[__index] = *(const double *)(
-(__INTPTR_TYPE__)__ptr + (__INTPTR_TYPE__)__offset[__index]);
+(const char *)__ptr + __offset[__index]);
   return __vec;
 }
 
@@ -943,7 +943,7 @@ vec_scatter_element(__vector signed int __vec,
 __vector unsigned int __offset,
 signed int *__ptr, int __index)
   __constant_range(__index, 0, 3) {
-  *(signed int *)((__INTPTR_TYPE__)__ptr + __offset[__index]) =
+  *(signed int *)((char *)__ptr + __offset[__index]) =
 __vec[__index];
 }
 
@@ -952,7 +952,7 @@ vec_scatter_element(__vector __bool int __vec,
 __vector unsigned int __offset,
 unsigned int *__ptr, int __index)
   __constant_range(__index, 0, 3) {
-  *(unsigned int *)((__INTPTR_TYPE__)__ptr + __offset[__index]) =
+  *(unsigned int *)((char *)__ptr + __offset[__index]) =
 __vec[__index];
 }
 
@@ -961,7 +961,7 @@ vec_scatter_element(__vector unsigned int __vec,
 __vector unsigned int __offset,
 unsigned int *__ptr, int __index)
   __constant_range(__index, 0, 3) {
-  *(unsigned int *)((__INTPTR_TYPE__)__ptr + __offset[__index]) =
+  *(unsigned int *)((char *)__ptr + __offset[__index]) =
 __vec[__index];
 }
 
@@ -970,7 +970,7 @@ vec_scatter_element(__vector signed long long __vec,

[llvm] [clang] [SystemZ] Add backchain target-feature (PR #71668)

2023-11-08 Thread Ulrich Weigand via cfe-commits

https://github.com/uweigand approved this pull request.

LGTM.   Thanks for taking care of this, Ilya!

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


[clang] [SystemZ] Do not run mbackchain-4.c test without SystemZ target (PR #71678)

2023-11-08 Thread Ulrich Weigand via cfe-commits

https://github.com/uweigand approved this pull request.

LGTM - sorry for missing that.

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


[llvm] [clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-11-14 Thread Ulrich Weigand via cfe-commits


@@ -1026,6 +1030,78 @@ void SystemZAsmPrinter::emitADASection() {
   OutStreamer->popSection();
 }
 
+static uint32_t getProductVersion(Module &M) {
+  if (auto *VersionVal = cast_or_null(
+  M.getModuleFlag("zos_product_major_version")))
+return cast(VersionVal->getValue())->getZExtValue();

uweigand wrote:

I think instead of these two casts, these days you're supposed to use the new 
`mdconst` interface, e.g. like
```
if (auto *VersionVal = mdconst::extract_or_null(
M.getModuleFlag("zos_product_major_version"))
```


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


[llvm] [clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-11-14 Thread Ulrich Weigand via cfe-commits


@@ -1026,6 +1030,78 @@ void SystemZAsmPrinter::emitADASection() {
   OutStreamer->popSection();
 }
 
+static uint32_t getProductVersion(Module &M) {
+  if (auto *VersionVal = cast_or_null(
+  M.getModuleFlag("zos_product_major_version")))
+return cast(VersionVal->getValue())->getZExtValue();
+  return LLVM_VERSION_MAJOR;
+}
+
+static uint32_t getProductRelease(Module &M) {
+  if (auto *ReleaseVal = cast_or_null(
+  M.getModuleFlag("zos_product_minor_version")))
+return cast(ReleaseVal->getValue())->getZExtValue();
+  return LLVM_VERSION_MINOR;
+}
+
+static uint32_t getProductPatch(Module &M) {
+  if (auto *PatchVal = cast_or_null(
+  M.getModuleFlag("zos_product_patchlevel")))
+return cast(PatchVal->getValue())->getZExtValue();
+  return LLVM_VERSION_PATCH;
+}
+
+static time_t getTranslationTime(Module &M) {
+  std::time_t Time = 0;
+  if (auto *Val = cast_or_null(
+  M.getModuleFlag("zos_translation_time"))) {
+long SecondsSinceEpoch = 
cast(Val->getValue())->getSExtValue();
+Time = static_cast(SecondsSinceEpoch);
+  }
+  return Time;
+}
+
+void SystemZAsmPrinter::emitIDRLSection(Module &M) {
+  OutStreamer->pushSection();
+  OutStreamer->switchSection(getObjFileLowering().getIDRLSection());
+  constexpr unsigned IDRLDataLength = 30;
+  std::time_t Time = getTranslationTime(M);
+
+  uint32_t ProductVersion = getProductVersion(M);
+  uint32_t ProductRelease = getProductRelease(M);
+
+  std::string ProductID;
+  if (auto *MD = M.getModuleFlag("zos_product_id"))
+ProductID = cast(MD)->getString().str();
+
+  if (ProductID.empty()) {
+char ProductIDFormatted[11]; // 10 + null.
+snprintf(ProductIDFormatted, sizeof(ProductIDFormatted), "LLVM  %02d%02d",
+ ProductVersion, ProductRelease);
+ProductID = ProductIDFormatted;
+  }
+
+  // Remove - from Product Id, which makes it consistent with legacy.
+  // The binder expects alphanumeric characters only.
+  std::size_t DashFound = ProductID.find("-");
+  if (DashFound != std::string::npos)
+ProductID.erase(ProductID.begin() + DashFound);

uweigand wrote:

Can there be multiple dashes, and if so, should they all be removed?   What 
about other disallowed characters?  At this point the ProductID could be 
user-provided in the IR, so shouldn't be careful here?

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


[llvm] [clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-11-14 Thread Ulrich Weigand via cfe-commits

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


[llvm] [clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-11-14 Thread Ulrich Weigand via cfe-commits


@@ -1026,6 +1030,78 @@ void SystemZAsmPrinter::emitADASection() {
   OutStreamer->popSection();
 }
 
+static uint32_t getProductVersion(Module &M) {
+  if (auto *VersionVal = cast_or_null(
+  M.getModuleFlag("zos_product_major_version")))
+return cast(VersionVal->getValue())->getZExtValue();
+  return LLVM_VERSION_MAJOR;
+}
+
+static uint32_t getProductRelease(Module &M) {
+  if (auto *ReleaseVal = cast_or_null(
+  M.getModuleFlag("zos_product_minor_version")))
+return cast(ReleaseVal->getValue())->getZExtValue();
+  return LLVM_VERSION_MINOR;
+}
+
+static uint32_t getProductPatch(Module &M) {
+  if (auto *PatchVal = cast_or_null(
+  M.getModuleFlag("zos_product_patchlevel")))
+return cast(PatchVal->getValue())->getZExtValue();
+  return LLVM_VERSION_PATCH;
+}
+
+static time_t getTranslationTime(Module &M) {
+  std::time_t Time = 0;
+  if (auto *Val = cast_or_null(
+  M.getModuleFlag("zos_translation_time"))) {
+long SecondsSinceEpoch = 
cast(Val->getValue())->getSExtValue();
+Time = static_cast(SecondsSinceEpoch);
+  }
+  return Time;
+}
+
+void SystemZAsmPrinter::emitIDRLSection(Module &M) {
+  OutStreamer->pushSection();
+  OutStreamer->switchSection(getObjFileLowering().getIDRLSection());
+  constexpr unsigned IDRLDataLength = 30;
+  std::time_t Time = getTranslationTime(M);
+
+  uint32_t ProductVersion = getProductVersion(M);
+  uint32_t ProductRelease = getProductRelease(M);
+
+  std::string ProductID;
+  if (auto *MD = M.getModuleFlag("zos_product_id"))
+ProductID = cast(MD)->getString().str();
+
+  if (ProductID.empty()) {
+char ProductIDFormatted[11]; // 10 + null.
+snprintf(ProductIDFormatted, sizeof(ProductIDFormatted), "LLVM  %02d%02d",
+ ProductVersion, ProductRelease);

uweigand wrote:

In this case, `ProductVersion` and `ProductRelease` seem to be present twice, 
first as part of the ID and then again separately.  (This is different from 
when clang sets the ID as just "clang".)  Is this deliberate?

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


[llvm] [clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-11-14 Thread Ulrich Weigand via cfe-commits


@@ -1026,6 +1030,78 @@ void SystemZAsmPrinter::emitADASection() {
   OutStreamer->popSection();
 }
 
+static uint32_t getProductVersion(Module &M) {
+  if (auto *VersionVal = cast_or_null(
+  M.getModuleFlag("zos_product_major_version")))
+return cast(VersionVal->getValue())->getZExtValue();
+  return LLVM_VERSION_MAJOR;
+}
+
+static uint32_t getProductRelease(Module &M) {
+  if (auto *ReleaseVal = cast_or_null(
+  M.getModuleFlag("zos_product_minor_version")))
+return cast(ReleaseVal->getValue())->getZExtValue();
+  return LLVM_VERSION_MINOR;
+}
+
+static uint32_t getProductPatch(Module &M) {
+  if (auto *PatchVal = cast_or_null(
+  M.getModuleFlag("zos_product_patchlevel")))
+return cast(PatchVal->getValue())->getZExtValue();
+  return LLVM_VERSION_PATCH;
+}
+
+static time_t getTranslationTime(Module &M) {
+  std::time_t Time = 0;
+  if (auto *Val = cast_or_null(
+  M.getModuleFlag("zos_translation_time"))) {
+long SecondsSinceEpoch = 
cast(Val->getValue())->getSExtValue();
+Time = static_cast(SecondsSinceEpoch);
+  }
+  return Time;
+}
+
+void SystemZAsmPrinter::emitIDRLSection(Module &M) {
+  OutStreamer->pushSection();
+  OutStreamer->switchSection(getObjFileLowering().getIDRLSection());
+  constexpr unsigned IDRLDataLength = 30;
+  std::time_t Time = getTranslationTime(M);
+
+  uint32_t ProductVersion = getProductVersion(M);
+  uint32_t ProductRelease = getProductRelease(M);
+
+  std::string ProductID;
+  if (auto *MD = M.getModuleFlag("zos_product_id"))
+ProductID = cast(MD)->getString().str();
+
+  if (ProductID.empty()) {
+char ProductIDFormatted[11]; // 10 + null.
+snprintf(ProductIDFormatted, sizeof(ProductIDFormatted), "LLVM  %02d%02d",
+ ProductVersion, ProductRelease);
+ProductID = ProductIDFormatted;
+  }
+
+  // Remove - from Product Id, which makes it consistent with legacy.
+  // The binder expects alphanumeric characters only.
+  std::size_t DashFound = ProductID.find("-");
+  if (DashFound != std::string::npos)
+ProductID.erase(ProductID.begin() + DashFound);
+
+  SmallString TempStr;
+  raw_svector_ostream O(TempStr);
+  O << formatv("{0}{1,0-2:d}{2,0-2:d}{3:%Y-%m-%d %H:%M:%S}", ProductID.c_str(),
+   ProductVersion, ProductRelease, llvm::sys::toUtcTime(Time));

uweigand wrote:

Can this overflow?  In the default case above, you ensure the ProductID has 10 
bytes.  But in the case where the ID comes from the IR, its length can be 
anything, and is not checked here.

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


[llvm] [clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-11-14 Thread Ulrich Weigand via cfe-commits


@@ -976,6 +976,40 @@ void CodeGenModule::Release() {
   Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
   getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
 
+  if (getTriple().isOSzOS()) {
+getModule().addModuleFlag(llvm::Module::Warning,
+  "zos_product_major_version",
+  uint32_t(CLANG_VERSION_MAJOR));
+getModule().addModuleFlag(llvm::Module::Warning,
+  "zos_product_minor_version",
+  uint32_t(CLANG_VERSION_MINOR));
+getModule().addModuleFlag(llvm::Module::Warning, "zos_product_patchlevel",
+  uint32_t(CLANG_VERSION_PATCHLEVEL));
+std::string ProductId;
+#ifdef CLANG_VENDOR
+ProductId = #CLANG_VENDOR;
+#else
+ProductId = "clang";
+#endif
+getModule().addModuleFlag(llvm::Module::Error, "zos_product_id",
+  llvm::MDString::get(VMContext, ProductId));
+
+// Record the language because we need it for the PPA2.
+StringRef lang_str = languageToString(
+LangStandard::getLangStandardForKind(LangOpts.LangStd).Language);
+getModule().addModuleFlag(llvm::Module::Error, "zos_cu_language",
+  llvm::MDString::get(VMContext, lang_str));
+
+time_t TT = PreprocessorOpts.SourceDateEpoch
+? *PreprocessorOpts.SourceDateEpoch
+: std::time(nullptr);
+getModule().addModuleFlag(llvm::Module::Max, "zos_translation_time",
+  static_cast(TT));
+
+getModule().addModuleFlag(llvm::Module::Error, "zos_le_char_mode",
+  llvm::MDString::get(VMContext, "ascii"));

uweigand wrote:

Is "ascii" the correct default here?   In either case, please add a comment 
stating multiple modes will be supported in the future, so we understand why 
this code is here.

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


[clang] [llvm] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-11-14 Thread Ulrich Weigand via cfe-commits

https://github.com/uweigand commented:

Please find a couple of additional comments inline, related to module flag 
processing.

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


[llvm] [clang] [SystemZ] Support i128 as legal type in VRs (PR #74625)

2023-12-06 Thread Ulrich Weigand via cfe-commits

uweigand wrote:

@JonPsson1 - please have a look at the effects of i128 support in particular on 
atomics
@redstar - can you check impact on the z/OS ABI?  we may need to handle legal 
i128 there too, but there doesn't appear to be any in-tree test case for 
passing i128 on z/OS

Any other comments welcome as well!

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


[clang] [llvm] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-11-22 Thread Ulrich Weigand via cfe-commits


@@ -1026,6 +1030,71 @@ void SystemZAsmPrinter::emitADASection() {
   OutStreamer->popSection();
 }
 
+static uint32_t getProductVersion(Module &M) {
+  if (auto *VersionVal = mdconst::extract_or_null(
+  M.getModuleFlag("zos_product_major_version")))
+return VersionVal->getValue().getZExtValue();
+  return LLVM_VERSION_MAJOR;
+}
+
+static uint32_t getProductRelease(Module &M) {
+  if (auto *ReleaseVal = cast_or_null(
+  M.getModuleFlag("zos_product_minor_version")))
+return cast(ReleaseVal->getValue())->getZExtValue();
+  return LLVM_VERSION_MINOR;
+}
+
+static uint32_t getProductPatch(Module &M) {
+  if (auto *PatchVal = cast_or_null(
+  M.getModuleFlag("zos_product_patchlevel")))
+return cast(PatchVal->getValue())->getZExtValue();
+  return LLVM_VERSION_PATCH;
+}
+
+static time_t getTranslationTime(Module &M) {
+  std::time_t Time = 0;
+  if (auto *Val = cast_or_null(
+  M.getModuleFlag("zos_translation_time"))) {
+long SecondsSinceEpoch = 
cast(Val->getValue())->getSExtValue();
+Time = static_cast(SecondsSinceEpoch);
+  }
+  return Time;
+}
+
+void SystemZAsmPrinter::emitIDRLSection(Module &M) {
+  OutStreamer->pushSection();
+  OutStreamer->switchSection(getObjFileLowering().getIDRLSection());
+  constexpr unsigned IDRLDataLength = 30;
+  std::time_t Time = getTranslationTime(M);
+
+  uint32_t ProductVersion = getProductVersion(M);
+  uint32_t ProductRelease = getProductRelease(M);
+
+  std::string ProductID;
+  if (auto *MD = M.getModuleFlag("zos_product_id"))
+ProductID = cast(MD)->getString().str();
+
+  if (ProductID.empty()) {
+char ProductIDFormatted[11]; // 10 + null.
+snprintf(ProductIDFormatted, sizeof(ProductIDFormatted), "LLVM");

uweigand wrote:

This `snprintf` call now looks superfluous - just set ProductID to "LLVM".

Also, I think this should all now go into a `getProductID` helper analogous to 
`getProductVersion` and the like.

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


[llvm] [clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-11-22 Thread Ulrich Weigand via cfe-commits


@@ -1026,6 +1030,71 @@ void SystemZAsmPrinter::emitADASection() {
   OutStreamer->popSection();
 }
 
+static uint32_t getProductVersion(Module &M) {
+  if (auto *VersionVal = mdconst::extract_or_null(
+  M.getModuleFlag("zos_product_major_version")))
+return VersionVal->getValue().getZExtValue();

uweigand wrote:

I don't think you need the separate `getValue()` here any more.

Also, you should be making the change to use `mdconst` not only in this one 
place, but in all places where you use `getModuleFlag` to retrieve an integer 
constant.

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


[llvm] [clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-11-22 Thread Ulrich Weigand via cfe-commits


@@ -1026,6 +1030,78 @@ void SystemZAsmPrinter::emitADASection() {
   OutStreamer->popSection();
 }
 
+static uint32_t getProductVersion(Module &M) {
+  if (auto *VersionVal = cast_or_null(
+  M.getModuleFlag("zos_product_major_version")))
+return cast(VersionVal->getValue())->getZExtValue();
+  return LLVM_VERSION_MAJOR;
+}
+
+static uint32_t getProductRelease(Module &M) {
+  if (auto *ReleaseVal = cast_or_null(
+  M.getModuleFlag("zos_product_minor_version")))
+return cast(ReleaseVal->getValue())->getZExtValue();
+  return LLVM_VERSION_MINOR;
+}
+
+static uint32_t getProductPatch(Module &M) {
+  if (auto *PatchVal = cast_or_null(
+  M.getModuleFlag("zos_product_patchlevel")))
+return cast(PatchVal->getValue())->getZExtValue();
+  return LLVM_VERSION_PATCH;
+}
+
+static time_t getTranslationTime(Module &M) {
+  std::time_t Time = 0;
+  if (auto *Val = cast_or_null(
+  M.getModuleFlag("zos_translation_time"))) {
+long SecondsSinceEpoch = 
cast(Val->getValue())->getSExtValue();
+Time = static_cast(SecondsSinceEpoch);
+  }
+  return Time;
+}
+
+void SystemZAsmPrinter::emitIDRLSection(Module &M) {
+  OutStreamer->pushSection();
+  OutStreamer->switchSection(getObjFileLowering().getIDRLSection());
+  constexpr unsigned IDRLDataLength = 30;
+  std::time_t Time = getTranslationTime(M);
+
+  uint32_t ProductVersion = getProductVersion(M);
+  uint32_t ProductRelease = getProductRelease(M);
+
+  std::string ProductID;
+  if (auto *MD = M.getModuleFlag("zos_product_id"))
+ProductID = cast(MD)->getString().str();
+
+  if (ProductID.empty()) {
+char ProductIDFormatted[11]; // 10 + null.
+snprintf(ProductIDFormatted, sizeof(ProductIDFormatted), "LLVM  %02d%02d",
+ ProductVersion, ProductRelease);
+ProductID = ProductIDFormatted;
+  }
+
+  // Remove - from Product Id, which makes it consistent with legacy.
+  // The binder expects alphanumeric characters only.
+  std::size_t DashFound = ProductID.find("-");
+  if (DashFound != std::string::npos)
+ProductID.erase(ProductID.begin() + DashFound);

uweigand wrote:

In the back-end, the string comes from a module flag in the IR - when providing 
their own IR file, a user could set that flag to anything, including a string 
with multiple dashes.  So if this is a problem for the rest of the toolchain, 
we need to be more careful in handling it.

If this is not actually a problem in the binder, then I guess removing that 
code here is fine.

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


[llvm] [clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-11-22 Thread Ulrich Weigand via cfe-commits


@@ -976,6 +976,46 @@ void CodeGenModule::Release() {
   Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
   getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
 
+  if (getTriple().isOSzOS()) {
+getModule().addModuleFlag(llvm::Module::Warning,
+  "zos_product_major_version",
+  uint32_t(CLANG_VERSION_MAJOR));
+getModule().addModuleFlag(llvm::Module::Warning,
+  "zos_product_minor_version",
+  uint32_t(CLANG_VERSION_MINOR));
+getModule().addModuleFlag(llvm::Module::Warning, "zos_product_patchlevel",
+  uint32_t(CLANG_VERSION_PATCHLEVEL));
+std::string ProductId;
+#ifdef CLANG_VENDOR
+ProductId = #CLANG_VENDOR;
+#else
+ProductId = "clang";
+#endif
+// Remove - from Product Id, which makes it consistent with legacy.
+std::size_t DashFound = ProductId.find("-");
+if (DashFound != std::string::npos)
+  ProductId.erase(ProductId.begin() + DashFound);

uweigand wrote:

Now that this code is moved here, it could only make a difference when 
compiling clang with a `CLANG_VENDOR` containing a dash.  If that is a problem 
for your use case, then why not simply build with the desired `CLANG_VENDOR` to 
begin with?  It's a bit unclear to me which general problem this code solves at 
this place now.

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


[clang] [llvm] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-10-31 Thread Ulrich Weigand via cfe-commits

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


[clang] [llvm] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-10-31 Thread Ulrich Weigand via cfe-commits

https://github.com/uweigand requested changes to this pull request.


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


[llvm] [clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-10-31 Thread Ulrich Weigand via cfe-commits


@@ -976,6 +976,40 @@ void CodeGenModule::Release() {
   Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
   getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
 
+  if (getTriple().isOSzOS()) {
+getModule().addModuleFlag(llvm::Module::Warning, "Product Major Version",
+  uint32_t(CLANG_VERSION_MAJOR));
+getModule().addModuleFlag(llvm::Module::Warning, "Product Minor Version",
+  uint32_t(CLANG_VERSION_MINOR));
+getModule().addModuleFlag(llvm::Module::Warning, "Product Patchlevel",
+  uint32_t(CLANG_VERSION_PATCHLEVEL));
+
+// Record the language because we need it for the PPA2.
+StringRef lang_str = languageToString(
+LangStandard::getLangStandardForKind(LangOpts.LangStd).Language);
+getModule().addModuleFlag(llvm::Module::Error, "zos_cu_language",
+  llvm::MDString::get(VMContext, lang_str));
+
+std::string ProductId;
+#ifdef CLANG_VENDOR
+ProductId = #CLANG_VENDOR;
+#else
+ProductId = "clang";
+#endif
+
+getModule().addModuleFlag(llvm::Module::Error, "Product Id",
+  llvm::MDString::get(VMContext, ProductId));
+
+getModule().addModuleFlag(llvm::Module::Error, "TranslationTime",

uweigand wrote:

I don't think `Error` is the correct setting for this.  That would prevent LTO 
unless modules were built at the exact same time.  Rather, I think this should 
be `Max` here.

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


[clang] [llvm] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-10-31 Thread Ulrich Weigand via cfe-commits


@@ -90,6 +90,7 @@ LANGOPT(C23   , 1, 0, "C23")
 LANGOPT(MSVCCompat, 1, 0, "Microsoft Visual C++ full compatibility 
mode")
 LANGOPT(Kernel, 1, 0, "Kernel mode")
 LANGOPT(MicrosoftExt  , 1, 0, "Microsoft C++ extensions")
+LANGOPT(ASCIICharMode , 1, 1, "z/OS Language Environment Character mode")

uweigand wrote:

This doesn't appear to do anything except for setting the PPA flag.   Is this 
correct?  If the implementation is simply incomplete / not present yet, I don't 
think we should add this flag now - rather, we should have the PPA flag reflect 
the default and update this once full support for ASCII mode is merged.

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


[clang] [llvm] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-10-31 Thread Ulrich Weigand via cfe-commits


@@ -976,6 +976,40 @@ void CodeGenModule::Release() {
   Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
   getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
 
+  if (getTriple().isOSzOS()) {
+getModule().addModuleFlag(llvm::Module::Warning, "Product Major Version",
+  uint32_t(CLANG_VERSION_MAJOR));
+getModule().addModuleFlag(llvm::Module::Warning, "Product Minor Version",
+  uint32_t(CLANG_VERSION_MINOR));
+getModule().addModuleFlag(llvm::Module::Warning, "Product Patchlevel",
+  uint32_t(CLANG_VERSION_PATCHLEVEL));
+
+// Record the language because we need it for the PPA2.
+StringRef lang_str = languageToString(
+LangStandard::getLangStandardForKind(LangOpts.LangStd).Language);
+getModule().addModuleFlag(llvm::Module::Error, "zos_cu_language",
+  llvm::MDString::get(VMContext, lang_str));
+
+std::string ProductId;
+#ifdef CLANG_VENDOR
+ProductId = #CLANG_VENDOR;
+#else
+ProductId = "clang";
+#endif
+
+getModule().addModuleFlag(llvm::Module::Error, "Product Id",
+  llvm::MDString::get(VMContext, ProductId));

uweigand wrote:

Same comment as above about the name space.  Also, please move this up next to 
the other product-related flags.

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


[llvm] [clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-10-31 Thread Ulrich Weigand via cfe-commits


@@ -1765,7 +1765,7 @@ void Clang::RenderTargetOptions(const llvm::Triple 
&EffectiveTriple,
 break;
 
   case llvm::Triple::systemz:
-AddSystemZTargetArgs(Args, CmdArgs);
+AddSystemZTargetArgs(EffectiveTriple, Args, CmdArgs);

uweigand wrote:

This (and the related) changes are no longer needed now.

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


[clang] [llvm] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-10-31 Thread Ulrich Weigand via cfe-commits


@@ -976,6 +976,40 @@ void CodeGenModule::Release() {
   Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
   getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
 
+  if (getTriple().isOSzOS()) {
+getModule().addModuleFlag(llvm::Module::Warning, "Product Major Version",
+  uint32_t(CLANG_VERSION_MAJOR));
+getModule().addModuleFlag(llvm::Module::Warning, "Product Minor Version",
+  uint32_t(CLANG_VERSION_MINOR));
+getModule().addModuleFlag(llvm::Module::Warning, "Product Patchlevel",
+  uint32_t(CLANG_VERSION_PATCHLEVEL));

uweigand wrote:

I think I commented on that previously:  these flags are set only on z/OS, but 
have rather generic names.   If they're z/OS specific, I think they should have 
names in the "zos_..." name space like the others.

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


[clang] [llvm] [SystemZ] Support i128 as legal type in VRs (PR #74625)

2023-12-14 Thread Ulrich Weigand via cfe-commits


@@ -1183,6 +1187,35 @@ void SystemZDAGToDAGISel::loadVectorConstant(
   SelectCode(Op.getNode());
 }
 
+SDNode *SystemZDAGToDAGISel::loadPoolVectorConstant(APInt Val, EVT VT, SDLoc 
DL) {
+  SDNode *ResNode;
+  assert (VT.getSizeInBits() == 128);
+
+  SDValue CP = CurDAG->getTargetConstantPool(
+  ConstantInt::get(Type::getInt128Ty(*CurDAG->getContext()), Val),
+  TLI->getPointerTy(CurDAG->getDataLayout()));
+
+  EVT PtrVT = CP.getValueType();
+  SDValue Ops[] = {
+SDValue(CurDAG->getMachineNode(SystemZ::LARL, DL, PtrVT, CP), 0),
+CurDAG->getTargetConstant(0, DL, PtrVT),
+CurDAG->getRegister(0, PtrVT),
+CurDAG->getEntryNode()
+  };
+  ResNode = CurDAG->getMachineNode(SystemZ::VL, DL, VT, MVT::Other, Ops);
+
+  // Annotate ResNode with memory operand information so that MachineInstr
+  // queries work properly. This e.g. gives the register allocation the
+  // required information for rematerialization.
+  MachineFunction& MF = CurDAG->getMachineFunction();
+  MachineMemOperand *MemOp =
+  MF.getMachineMemOperand(MachinePointerInfo::getConstantPool(MF),
+  MachineMemOperand::MOLoad, 8, Align(8));
+

uweigand wrote:

Fixed, thanks!

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


[clang] [llvm] [SystemZ] Support i128 as legal type in VRs (PR #74625)

2023-12-14 Thread Ulrich Weigand via cfe-commits


@@ -1466,7 +1509,15 @@ static SDValue convertValVTToLocVT(SelectionDAG &DAG, 
const SDLoc &DL,
 static SDValue lowerI128ToGR128(SelectionDAG &DAG, SDValue In) {
   SDLoc DL(In);
   SDValue Lo, Hi;
-  std::tie(Lo, Hi) = DAG.SplitScalar(In, DL, MVT::i64, MVT::i64);
+  if (DAG.getTargetLoweringInfo().isTypeLegal(MVT::i128)) {
+Lo = DAG.getNode(ISD::TRUNCATE, DL, MVT::i64, In);

uweigand wrote:

Hmmm.  According to the specs, `EXTRACT_ELEMENT` (and therefore `SplitScalar`) 
is only supposed to be used on non-legal types, for values that will be broken 
up into multiple registers.   However, the actual implementation doesn't appear 
to verify this, and expands `EXTRACT_ELEMENT` even for a legal `i128`, to the 
same code ...

I would still prefer to not rely on that undocumented behavior, and use the 
explicit expansion.  Also, this keeps the implementation symmetrical to 
`lowerGR128ToI128`, and may be slightly more efficient as it omits generating 
and then immediately eliminating the `EXTRACT_ELEMENT` nodes.

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


[clang] [llvm] [SystemZ] Support i128 as legal type in VRs (PR #74625)

2023-12-14 Thread Ulrich Weigand via cfe-commits


@@ -2772,6 +2837,27 @@ static unsigned getTestUnderMaskCond(unsigned BitSize, 
unsigned CCMask,
 // Update the arguments with the TM version if so.
 static void adjustForTestUnderMask(SelectionDAG &DAG, const SDLoc &DL,
Comparison &C) {
+  // Use VECTOR TEST UNDER MASK for i128 operations.
+  if (C.Op0.getValueType() == MVT::i128) {

uweigand wrote:

Well, we need `VCEQS` to set CC which takes an extra cycle, so it should both 
be three cycles, but then VTM is shorter.

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


[clang] [llvm] [SystemZ] Support i128 as legal type in VRs (PR #74625)

2023-12-14 Thread Ulrich Weigand via cfe-commits


@@ -2918,16 +3049,17 @@ static Comparison getCmp(SelectionDAG &DAG, SDValue 
CmpOp0, SDValue CmpOp1,
  bool IsSignaling = false) {
   if (CmpOp1.getOpcode() == ISD::Constant) {
 assert(!Chain);
-uint64_t Constant = cast(CmpOp1)->getZExtValue();
 unsigned Opcode, CCValid;

uweigand wrote:

`getZExtValue` will crash when the constant is 128-bit, which can now happen.  
Therefore I'm now only evaluating it in code paths where we know the constant 
cannot be 128-bit.

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


[clang] [llvm] [SystemZ] Support i128 as legal type in VRs (PR #74625)

2023-12-14 Thread Ulrich Weigand via cfe-commits


@@ -6481,6 +6737,71 @@ SDValue SystemZTargetLowering::combineLOAD(
 SDNode *N, DAGCombinerInfo &DCI) const {
   SelectionDAG &DAG = DCI.DAG;
   EVT LdVT = N->getValueType(0);
+  SDLoc DL(N);
+
+  // Replace an i128 load that is used solely to move its value into GPRs
+  // by separate loads of both halves.
+  if (LdVT == MVT::i128) {
+LoadSDNode *LD = cast(N);
+if (!LD->isSimple() || !ISD::isNormalLoad(LD))
+  return SDValue();
+
+// Scan through all users.
+SmallVector, 2> Users;
+int UsedElements = 0;
+for (SDNode::use_iterator UI = LD->use_begin(), UIEnd = LD->use_end();
+ UI != UIEnd; ++UI) {
+  // Skip the uses of the chain.
+  if (UI.getUse().getResNo() != 0)
+continue;
+
+  // Verify every user is a TRUNCATE to i64 of the low or high half ...
+  SDNode *User = *UI;
+  int Index = 1;
+  if (User->getOpcode() == ISD::SRL &&
+  User->getOperand(1).getOpcode() == ISD::Constant &&
+  cast(User->getOperand(1))->getZExtValue() == 64 &&
+  User->hasOneUse()) {
+User = *User->use_begin();
+Index = 0;
+  }
+  if (User->getOpcode() != ISD::TRUNCATE ||
+  User->getValueType(0) != MVT::i64)
+return SDValue();
+
+  // ... and no half is extracted twice.
+  if (UsedElements & (1 << Index))
+return SDValue();
+
+  UsedElements |= 1 << Index;
+  Users.push_back(std::make_pair(User, Index));
+}
+
+// Rewrite each extraction as an independent load.
+SmallVector ArgChains;
+for (auto UserAndIndex : Users) {
+  SDNode *User = UserAndIndex.first;
+  unsigned Offset = User->getValueType(0).getStoreSize() * 
UserAndIndex.second;
+  SDValue Ptr =

uweigand wrote:

Well, `getStoreSize` should be 8 here, but seems clearer to refer to it 
symbolically.

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


[clang] [llvm] [SystemZ] Support i128 as legal type in VRs (PR #74625)

2023-12-14 Thread Ulrich Weigand via cfe-commits


@@ -1516,48 +1536,206 @@ let Predicates = [FeatureVector] in {
   }
 }
 
+//===--===//
+// Support for 128-bit integer values in vector registers
+//===--===//
+
+// Loads and stores.
+let Predicates = [FeatureVector] in {
+  def : Pat<(i128 (load bdxaddr12only:$addr)),
+(VL bdxaddr12only:$addr)>;
+  def : Pat<(store (i128 VR128:$src), bdxaddr12only:$addr),
+(VST VR128:$src, bdxaddr12only:$addr)>;
+}
+
+// Full i128 move from GPR pair.
+let Predicates = [FeatureVector] in
+  def : Pat<(i128 (or (zext GR64:$x), (shl (anyext GR64:$y), (i32 64,
+(VLVGP GR64:$y, GR64:$x)>;
+
+// Any-extensions from GPR to i128.
+let Predicates = [FeatureVector] in {
+  def : Pat<(i128 (anyext GR32:$x)), (VLVGP32 GR32:$x, GR32:$x)>;
+  def : Pat<(i128 (anyext GR64:$x)), (VLVGP GR64:$x, GR64:$x)>;
+}
+
+// Any-extending loads into i128.
+let Predicates = [FeatureVector] in {
+  def : Pat<(i128 (extloadi8 bdxaddr12only:$addr)),
+(VLREPB bdxaddr12only:$addr)>;
+  def : Pat<(i128 (extloadi16 bdxaddr12only:$addr)),
+(VLREPH bdxaddr12only:$addr)>;
+  def : Pat<(i128 (extloadi32 bdxaddr12only:$addr)),
+(VLREPF bdxaddr12only:$addr)>;
+  def : Pat<(i128 (extloadi64 bdxaddr12only:$addr)),
+(VLREPG bdxaddr12only:$addr)>;
+}
+
+// Truncations from i128 to GPR.
+let Predicates = [FeatureVector] in {
+  def : Pat<(i32 (trunc (i128 VR128:$vec))),
+(EXTRACT_SUBREG (VLGVF VR128:$vec, zero_reg, 3), subreg_l32)>;
+  def : Pat<(i32 (trunc (srl (i128 VR128:$vec), (i32 32,
+(EXTRACT_SUBREG (VLGVF VR128:$vec, zero_reg, 2), subreg_l32)>;
+  def : Pat<(i32 (trunc (srl (i128 VR128:$vec), (i32 64,
+(EXTRACT_SUBREG (VLGVF VR128:$vec, zero_reg, 1), subreg_l32)>;
+  def : Pat<(i32 (trunc (srl (i128 VR128:$vec), (i32 96,
+(EXTRACT_SUBREG (VLGVF VR128:$vec, zero_reg, 0), subreg_l32)>;
+  def : Pat<(i64 (trunc (i128 VR128:$vec))),
+(VLGVG VR128:$vec, zero_reg, 1)>;
+  def : Pat<(i64 (trunc (srl (i128 VR128:$vec), (i32 64,
+(VLGVG VR128:$vec, zero_reg, 0)>;
+}
+
+// Truncating stores from i128.
+let Predicates = [FeatureVector] in {
+  def : Pat<(truncstorei8 (i128 VR128:$x), bdxaddr12only:$addr),
+(VSTEB VR128:$x, bdxaddr12only:$addr, 15)>;
+  def : Pat<(truncstorei16 (i128 VR128:$x), bdxaddr12only:$addr),
+(VSTEH VR128:$x, bdxaddr12only:$addr, 7)>;
+  def : Pat<(truncstorei32 (i128 VR128:$x), bdxaddr12only:$addr),
+(VSTEF VR128:$x, bdxaddr12only:$addr, 3)>;
+  def : Pat<(truncstorei32 (srl (i128 VR128:$x), (i32 32)), 
bdxaddr12only:$addr),
+(VSTEF VR128:$x, bdxaddr12only:$addr, 2)>;
+  def : Pat<(truncstorei32 (srl (i128 VR128:$x), (i32 64)), 
bdxaddr12only:$addr),
+(VSTEF VR128:$x, bdxaddr12only:$addr, 1)>;
+  def : Pat<(truncstorei32 (srl (i128 VR128:$x), (i32 96)), 
bdxaddr12only:$addr),
+(VSTEF VR128:$x, bdxaddr12only:$addr, 0)>;
+  def : Pat<(truncstorei64 (i128 VR128:$x), bdxaddr12only:$addr),
+(VSTEG VR128:$x, bdxaddr12only:$addr, 1)>;
+  def : Pat<(truncstorei64 (srl (i128 VR128:$x), (i32 64)), 
bdxaddr12only:$addr),
+(VSTEG VR128:$x, bdxaddr12only:$addr, 0)>;
+}
+
+// Zero-extensions from GPR to i128.
+let Predicates = [FeatureVector] in {
+  def : Pat<(i128 (zext8 (anyext GR32:$x))),
+(VLVGB (VGBM 0), GR32:$x, zero_reg, 15)>;
+  def : Pat<(i128 (zext16 (anyext GR32:$x))),
+(VLVGH (VGBM 0), GR32:$x, zero_reg, 7)>;
+  def : Pat<(i128 (zext GR32:$x)),
+(VLVGF (VGBM 0), GR32:$x, zero_reg, 3)>;
+  def : Pat<(i128 (zext GR64:$x)),
+(VLVGG (VGBM 0), GR64:$x, zero_reg, 1)>;
+}
+
+// Zero-extending loads into i128.
+let Predicates = [FeatureVector] in {
+  def : Pat<(i128 (zextloadi8 bdxaddr12only:$addr)),
+(VLEB (VGBM 0), bdxaddr12only:$addr, 15)>;
+  def : Pat<(i128 (zextloadi16 bdxaddr12only:$addr)),
+(VLEH (VGBM 0), bdxaddr12only:$addr, 7)>;
+  def : Pat<(i128 (zextloadi32 bdxaddr12only:$addr)),
+(VLEF (VGBM 0), bdxaddr12only:$addr, 3)>;
+  def : Pat<(i128 (zextloadi64 bdxaddr12only:$addr)),
+(VLEG (VGBM 0), bdxaddr12only:$addr, 1)>;
+}
+
+// In-register i128 sign-extensions.
+let Predicates = [FeatureVector] in {
+  def : Pat<(i128 (sext_inreg VR128:$x, i8)),
+(VSRAB (VREPB VR128:$x, 15), (VREPIB 120))>;
+  def : Pat<(i128 (sext_inreg VR128:$x, i16)),
+(VSRAB (VREPH VR128:$x, 7), (VREPIB 112))>;
+  def : Pat<(i128 (sext_inreg VR128:$x, i32)),
+(VSRAB (VREPF VR128:$x, 3), (VREPIB 96))>;
+  def : Pat<(i128 (sext_inreg VR128:$x, i64)),
+(VSRAB (VREPG VR128:$x, 1), (VREPIB 64))>;
+}
+
+// Sign-extensions from GPR to i128.
+let Predicates = [FeatureVector] in {
+  def : Pat<(i128 (sext_inreg (anyext

[clang] [llvm] [SystemZ] Support i128 as legal type in VRs (PR #74625)

2023-12-14 Thread Ulrich Weigand via cfe-commits

uweigand wrote:

> I have looked through the changes and made some comments inline.

Thanks for the review!

> Commenting:

Fixed, thanks!

> I happened to notice some cases with room for improvement:

Good catch.  I've not addressed these right now, this can be done as a 
follow-up.  (The memory case is a bit tedious due to TableGen pattern 
limitations ...)

> As a side question: I forgot why we can get CCMask '5' here: it seems it 
> should be CCMASK_CMP_NE ('6'), if we reverse the LOC operation..?

No, 5 is correct here.  Reversing XORs the mask with the set of valid bits, so 
we have 13 ^ 8 == 5.

Looking at the VTM instruction, we have the following valid condition codes 
(making up the 13, i.e. 0, 1, or 3):
0 - Selected bits all zeros; or all mask bits zero
1 - Selected bits a mix of zeros and ones
2 - n/a
3 - Selected bits all ones

The original mask is 8, i.e. condition code 0 ("selected bits all zeros").  
Reversing this needs to check for condition codes 1 or 3, i.e. mask 5 
("selected bits a mix of zeros and ones" or "selected bits all ones").


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


[clang] [llvm] [SystemZ] Support i128 as legal type in VRs (PR #74625)

2023-12-14 Thread Ulrich Weigand via cfe-commits

uweigand wrote:

Fixed merge conflicts, updated as described above, and fixed support for i128 
parameters in the z/OS XPLINK ABI.

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


[llvm] [clang] [SystemZ] Support i128 as legal type in VRs (PR #74625)

2023-12-15 Thread Ulrich Weigand via cfe-commits

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


[clang] [llvm] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-11-23 Thread Ulrich Weigand via cfe-commits


@@ -1026,6 +1030,72 @@ void SystemZAsmPrinter::emitADASection() {
   OutStreamer->popSection();
 }
 
+static std::string getProductID(Module &M) {
+  std::string ProductID;
+  if (auto *MD = M.getModuleFlag("zos_product_id"))
+ProductID = cast(MD)->getString().str();
+  if (ProductID.empty())
+ProductID = "LLVM";
+  return ProductID;
+}
+
+static uint32_t getProductVersion(Module &M) {
+  if (auto *VersionVal = mdconst::extract_or_null(
+  M.getModuleFlag("zos_product_major_version")))
+return VersionVal->getZExtValue();
+  return LLVM_VERSION_MAJOR;
+}
+
+static uint32_t getProductRelease(Module &M) {
+  if (auto *ReleaseVal = mdconst::extract_or_null(
+  M.getModuleFlag("zos_product_minor_version")))
+return ReleaseVal->getZExtValue();
+  return LLVM_VERSION_MINOR;
+}
+
+static uint32_t getProductPatch(Module &M) {
+  if (auto *PatchVal = mdconst::extract_or_null(
+  M.getModuleFlag("zos_product_patchlevel")))
+return PatchVal->getZExtValue();
+  return LLVM_VERSION_PATCH;
+}
+
+static time_t getTranslationTime(Module &M) {
+  std::time_t Time = 0;
+  if (auto *Val = mdconst::extract_or_null(
+  M.getModuleFlag("zos_translation_time"))) {
+long SecondsSinceEpoch =  Val->getSExtValue();
+Time = static_cast(SecondsSinceEpoch);
+  }
+  return Time;
+}
+
+void SystemZAsmPrinter::emitIDRLSection(Module &M) {
+  OutStreamer->pushSection();
+  OutStreamer->switchSection(getObjFileLowering().getIDRLSection());
+  constexpr unsigned IDRLDataLength = 30;
+  std::time_t Time = getTranslationTime(M);
+
+  uint32_t ProductVersion = getProductVersion(M);
+  uint32_t ProductRelease = getProductRelease(M);
+
+  std::string ProductID = getProductID(M);
+
+  SmallString TempStr;
+  raw_svector_ostream O(TempStr);
+  O << formatv("{0}{1,0-2:d}{2,0-2:d}{3:%Y-%m-%d %H:%M:%S}",
+   ProductID.substr(0, 10).c_str(), ProductVersion, ProductRelease,
+   llvm::sys::toUtcTime(Time));
+  SmallString Data;
+  ConverterEBCDIC::convertToEBCDIC(TempStr, Data);
+
+  OutStreamer->emitInt8(0);   // Reserved.
+  OutStreamer->emitInt8(3);   // Format.
+  OutStreamer->emitInt16(IDRLDataLength); // Length.
+  OutStreamer->emitBytes(Data.str());

uweigand wrote:

One more question about this string - the Length field is hardcoded to 30.  
Does that mean that there are exactly 30 bytes supposed to always follow here?  
 I'm not sure this is guaranteed by the formatv above ...

Also, there doesn't seem to be any test that verifies the layout of this IDRL 
section, I think we definitely need one.

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


[clang] [SystemZ] Move new test into existing CodeGen test. (PR #73230)

2023-11-23 Thread Ulrich Weigand via cfe-commits

https://github.com/uweigand approved this pull request.

LGTM, thanks!

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


[llvm] [clang] [SystemZ] Properly support 16 byte atomic int/fp types and ops. (PR #73134)

2023-11-24 Thread Ulrich Weigand via cfe-commits

https://github.com/uweigand commented:

Not sure about the is_lock_free results, see inline comments.

What does recent GCC return for those?

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


[llvm] [clang] [SystemZ] Properly support 16 byte atomic int/fp types and ops. (PR #73134)

2023-11-24 Thread Ulrich Weigand via cfe-commits


@@ -0,0 +1,71 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple s390x-linux-gnu -O1 -emit-llvm %s -o - | FileCheck 
%s
+//
+// Test __atomic_is_lock_free() for __int128 with default alignment (8
+// bytes), atomic alignment (16 bytes) and with a null pointer. Also test
+// __atomic_always_lock_free() and __c11_atomic_is_lock_free().
+
+#include 
+#include 
+
+__int128 Ptr_Al8   __attribute__((aligned(8)));
+__int128 Ptr_Al16 __attribute__((aligned(16)));
+
+// CHECK-LABEL: @fun_PtrAl8_is_lock_free(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CALL:%.*]] = tail call zeroext i1 
@__atomic_is_lock_free(i64 noundef 16, ptr noundef nonnull @Ptr_Al8) 
#[[ATTR2:[0-9]+]]
+// CHECK-NEXT:ret i1 [[CALL]]
+//
+_Bool fun_PtrAl8_is_lock_free() {
+  return __atomic_is_lock_free(16, &Ptr_Al8);
+}
+
+// CHECK-LABEL: @fun_PtrAl8_always_lock_free(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret i1 false
+//
+_Bool fun_PtrAl8_always_lock_free() {
+  return __atomic_always_lock_free(16, &Ptr_Al8);
+}
+
+// CHECK-LABEL: @fun_PtrAl16_is_lock_free(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CALL:%.*]] = tail call zeroext i1 
@__atomic_is_lock_free(i64 noundef 16, ptr noundef nonnull @Ptr_Al16) #[[ATTR2]]

uweigand wrote:

Here I would have expected `true`, assuming the compiler correctly figures out 
the object is 16-byte aligned.

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


[clang] [llvm] [SystemZ] Properly support 16 byte atomic int/fp types and ops. (PR #73134)

2023-11-24 Thread Ulrich Weigand via cfe-commits


@@ -0,0 +1,71 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple s390x-linux-gnu -O1 -emit-llvm %s -o - | FileCheck 
%s
+//
+// Test __atomic_is_lock_free() for __int128 with default alignment (8
+// bytes), atomic alignment (16 bytes) and with a null pointer. Also test
+// __atomic_always_lock_free() and __c11_atomic_is_lock_free().
+
+#include 
+#include 
+
+__int128 Ptr_Al8   __attribute__((aligned(8)));
+__int128 Ptr_Al16 __attribute__((aligned(16)));
+
+// CHECK-LABEL: @fun_PtrAl8_is_lock_free(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CALL:%.*]] = tail call zeroext i1 
@__atomic_is_lock_free(i64 noundef 16, ptr noundef nonnull @Ptr_Al8) 
#[[ATTR2:[0-9]+]]
+// CHECK-NEXT:ret i1 [[CALL]]
+//
+_Bool fun_PtrAl8_is_lock_free() {
+  return __atomic_is_lock_free(16, &Ptr_Al8);
+}
+
+// CHECK-LABEL: @fun_PtrAl8_always_lock_free(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret i1 false
+//
+_Bool fun_PtrAl8_always_lock_free() {
+  return __atomic_always_lock_free(16, &Ptr_Al8);
+}
+
+// CHECK-LABEL: @fun_PtrAl16_is_lock_free(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CALL:%.*]] = tail call zeroext i1 
@__atomic_is_lock_free(i64 noundef 16, ptr noundef nonnull @Ptr_Al16) #[[ATTR2]]
+// CHECK-NEXT:ret i1 [[CALL]]
+//
+_Bool fun_PtrAl16_is_lock_free() {
+  return __atomic_is_lock_free(16, &Ptr_Al16);
+}
+
+// CHECK-LABEL: @fun_PtrAl16_always_lock_free(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret i1 false
+//
+_Bool fun_PtrAl16_always_lock_free() {
+  return __atomic_always_lock_free(16, &Ptr_Al16);
+}
+
+// CHECK-LABEL: @fun_noptr_is_lock_free(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret i1 true
+//
+_Bool fun_noptr_is_lock_free() {
+  return __atomic_is_lock_free(16, 0);

uweigand wrote:

But this seems actually incorrect - when using *default* assumptions, the 
operation should *not* be lock-free ...

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


[clang] [llvm] [SystemZ] Properly support 16 byte atomic int/fp types and ops. (PR #73134)

2023-11-24 Thread Ulrich Weigand via cfe-commits

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


[clang] [llvm] [SystemZ] Properly support 16 byte atomic int/fp types and ops. (PR #73134)

2023-11-24 Thread Ulrich Weigand via cfe-commits

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


[clang] [llvm] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-11-27 Thread Ulrich Weigand via cfe-commits

https://github.com/uweigand approved this pull request.

This version LGTM now, thanks!

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


[llvm] [clang] [clang, SystemZ] Pass HasDef flag to getMinGlobalAlign(). (PR #73511)

2023-11-28 Thread Ulrich Weigand via cfe-commits


@@ -1687,7 +1687,8 @@ CharUnits ASTContext::getDeclAlign(const Decl *D, bool 
ForAlignof) const {
   if (VD->hasGlobalStorage() && !ForAlignof) {
 uint64_t TypeSize =
 !BaseT->isIncompleteType() ? getTypeSize(T.getTypePtr()) : 0;
-Align = std::max(Align, getTargetInfo().getMinGlobalAlign(TypeSize));
+Align = std::max(Align, getTargetInfo().getMinGlobalAlign(
+TypeSize, VD->hasDefinition()));

uweigand wrote:

So the intent of the option is to 1) when emitting a symbol definition 
directly, keep using the 2-byte ABI alignment, but 2) when refering to a symbol 
that *might* be defined externally, do not make using any alignment assumption. 
 In GCC this is using the same checks used elsewhere to test where a symbol is 
guaranteed local or might be external (keeping in mind things like weak symbols 
or ELF overrides).

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


[llvm] [clang] [clang, SystemZ] Pass HasDef flag to getMinGlobalAlign(). (PR #73511)

2023-11-28 Thread Ulrich Weigand via cfe-commits

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


[clang] c61eb44 - [SystemZ] Implement vector rotate in terms of funnel shift

2023-12-04 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2023-12-04T16:52:00+01:00
New Revision: c61eb440059d6e9c18e6f8404e06bf125aa942c9

URL: 
https://github.com/llvm/llvm-project/commit/c61eb440059d6e9c18e6f8404e06bf125aa942c9
DIFF: 
https://github.com/llvm/llvm-project/commit/c61eb440059d6e9c18e6f8404e06bf125aa942c9.diff

LOG: [SystemZ] Implement vector rotate in terms of funnel shift

Clang currently implements a set of vector rotate builtins
(__builtin_s390_verll*) in terms of platform-specific LLVM
intrinsics.  To simplify the IR (and allow for common code
optimizations if applicable), this patch removes those LLVM
intrinsics and implements the builtins in terms of the
platform-independent funnel shift intrinsics instead.

Also, fix the prototype of the __builtin_s390_verll*
builtins for full compatibility with GCC.

Added: 
llvm/test/CodeGen/SystemZ/vec-rot-01.ll
llvm/test/CodeGen/SystemZ/vec-rot-02.ll

Modified: 
clang/include/clang/Basic/BuiltinsSystemZ.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Headers/vecintrin.h
clang/test/CodeGen/SystemZ/builtins-systemz-vector.c
clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
llvm/include/llvm/IR/IntrinsicsSystemZ.td
llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
llvm/lib/Target/SystemZ/SystemZISelLowering.h
llvm/lib/Target/SystemZ/SystemZInstrVector.td
llvm/lib/Target/SystemZ/SystemZOperators.td
llvm/test/CodeGen/SystemZ/vec-intrinsics-01.ll

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsSystemZ.def 
b/clang/include/clang/Basic/BuiltinsSystemZ.def
index 079e411364885..b84cf5b9cec9f 100644
--- a/clang/include/clang/Basic/BuiltinsSystemZ.def
+++ b/clang/include/clang/Basic/BuiltinsSystemZ.def
@@ -105,10 +105,10 @@ TARGET_BUILTIN(__builtin_s390_verimb, 
"V16UcV16UcV16UcV16UcIi", "nc", "vector")
 TARGET_BUILTIN(__builtin_s390_verimh, "V8UsV8UsV8UsV8UsIi", "nc", "vector")
 TARGET_BUILTIN(__builtin_s390_verimf, "V4UiV4UiV4UiV4UiIi", "nc", "vector")
 TARGET_BUILTIN(__builtin_s390_verimg, "V2ULLiV2ULLiV2ULLiV2ULLiIi", "nc", 
"vector")
-TARGET_BUILTIN(__builtin_s390_verllb, "V16UcV16UcUi", "nc", "vector")
-TARGET_BUILTIN(__builtin_s390_verllh, "V8UsV8UsUi", "nc", "vector")
-TARGET_BUILTIN(__builtin_s390_verllf, "V4UiV4UiUi", "nc", "vector")
-TARGET_BUILTIN(__builtin_s390_verllg, "V2ULLiV2ULLiUi", "nc", "vector")
+TARGET_BUILTIN(__builtin_s390_verllb, "V16UcV16UcUc", "nc", "vector")
+TARGET_BUILTIN(__builtin_s390_verllh, "V8UsV8UsUc", "nc", "vector")
+TARGET_BUILTIN(__builtin_s390_verllf, "V4UiV4UiUc", "nc", "vector")
+TARGET_BUILTIN(__builtin_s390_verllg, "V2ULLiV2ULLiUc", "nc", "vector")
 TARGET_BUILTIN(__builtin_s390_verllvb, "V16UcV16UcV16Uc", "nc", "vector")
 TARGET_BUILTIN(__builtin_s390_verllvh, "V8UsV8UsV8Us", "nc", "vector")
 TARGET_BUILTIN(__builtin_s390_verllvf, "V4UiV4UiV4Ui", "nc", "vector")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 65d9862621061..a0f4172002613 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18337,6 +18337,32 @@ Value 
*CodeGenFunction::EmitSystemZBuiltinExpr(unsigned BuiltinID,
 return Builder.CreateCall(F, {X, Undef});
   }
 
+  case SystemZ::BI__builtin_s390_verllb:
+  case SystemZ::BI__builtin_s390_verllh:
+  case SystemZ::BI__builtin_s390_verllf:
+  case SystemZ::BI__builtin_s390_verllg: {
+llvm::Type *ResultType = ConvertType(E->getType());
+llvm::Value *Src = EmitScalarExpr(E->getArg(0));
+llvm::Value *Amt = EmitScalarExpr(E->getArg(1));
+// Splat scalar rotate amount to vector type.
+unsigned NumElts = 
cast(ResultType)->getNumElements();
+Amt = Builder.CreateIntCast(Amt, ResultType->getScalarType(), false);
+Amt = Builder.CreateVectorSplat(NumElts, Amt);
+Function *F = CGM.getIntrinsic(Intrinsic::fshl, ResultType);
+return Builder.CreateCall(F, { Src, Src, Amt });
+  }
+
+  case SystemZ::BI__builtin_s390_verllvb:
+  case SystemZ::BI__builtin_s390_verllvh:
+  case SystemZ::BI__builtin_s390_verllvf:
+  case SystemZ::BI__builtin_s390_verllvg: {
+llvm::Type *ResultType = ConvertType(E->getType());
+llvm::Value *Src = EmitScalarExpr(E->getArg(0));
+llvm::Value *Amt = EmitScalarExpr(E->getArg(1));
+Function *F = CGM.getIntrinsic(Intrinsic::fshl, ResultType);
+return Builder.CreateCall(F, { Src, Src, Amt });
+  }
+
   case SystemZ::BI__builtin_s390_vfsqsb:
   case SystemZ::BI__builtin_s390_vfsqdb: {
 llvm::Type *ResultType = ConvertType(E->getType());

diff  --git a/clang/lib/Headers/vecintrin.h b/clang/lib/Headers/vecintrin.h
index ec1dbfd015f6e..0c535225c78e5 100644
--- a/clang/lib/Headers/vecintrin.h
+++ b/clang/lib/Headers/vecintrin.h
@@ -6565,45 +6565,45 @@ vec_rl(__vector unsigned long long __a, __vector 
unsigned long long __b) {
 static inline __ATTRS_o_ai __vector signed char
 vec_rli(__vector signed char __a, unsigned long __b) {
   return (__vecto

[clang] dca432c - [SystemZ] Fix naming of vlrlr/vstrlr builtins

2023-12-04 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2023-12-04T16:53:18+01:00
New Revision: dca432cb7b1c282f5dc861095813c4f40f109619

URL: 
https://github.com/llvm/llvm-project/commit/dca432cb7b1c282f5dc861095813c4f40f109619
DIFF: 
https://github.com/llvm/llvm-project/commit/dca432cb7b1c282f5dc861095813c4f40f109619.diff

LOG: [SystemZ] Fix naming of vlrlr/vstrlr builtins

The builtins that expand to the vlrl/vlrlr and vstrl/vstrlr
instructions are currently named inconsistently between GCC
and clang.  Rename the clang versions to match GCC.

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsSystemZ.def
clang/lib/Headers/vecintrin.h
clang/test/CodeGen/SystemZ/builtins-systemz-vector2.c
llvm/include/llvm/IR/IntrinsicsSystemZ.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsSystemZ.def 
b/clang/include/clang/Basic/BuiltinsSystemZ.def
index b84cf5b9cec9f..02171d29ffd91 100644
--- a/clang/include/clang/Basic/BuiltinsSystemZ.def
+++ b/clang/include/clang/Basic/BuiltinsSystemZ.def
@@ -253,8 +253,8 @@ TARGET_BUILTIN(__builtin_s390_vfsqdb, "V2dV2d", "nc", 
"vector")
 TARGET_BUILTIN(__builtin_s390_vftcidb, "V2SLLiV2dIii*", "nc", "vector")
 
 // Vector-enhancements facility 1 intrinsics.
-TARGET_BUILTIN(__builtin_s390_vlrl, "V16ScUivC*", "", "vector-enhancements-1")
-TARGET_BUILTIN(__builtin_s390_vstrl, "vV16ScUiv*", "", "vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vlrlr, "V16ScUivC*", "", "vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vstrlr, "vV16ScUiv*", "", 
"vector-enhancements-1")
 TARGET_BUILTIN(__builtin_s390_vbperm, "V2ULLiV16UcV16Uc", "nc", 
"vector-enhancements-1")
 TARGET_BUILTIN(__builtin_s390_vmslg, "V16UcV2ULLiV2ULLiV16UcIi", "nc", 
"vector-enhancements-1")
 TARGET_BUILTIN(__builtin_s390_vfmaxdb, "V2dV2dV2dIi", "nc", 
"vector-enhancements-1")

diff  --git a/clang/lib/Headers/vecintrin.h b/clang/lib/Headers/vecintrin.h
index 0c535225c78e5..0ea411f40218e 100644
--- a/clang/lib/Headers/vecintrin.h
+++ b/clang/lib/Headers/vecintrin.h
@@ -1543,7 +1543,7 @@ vec_load_len(const double *__ptr, unsigned int __len) {
 #if __ARCH__ >= 12
 static inline __ATTRS_ai __vector unsigned char
 vec_load_len_r(const unsigned char *__ptr, unsigned int __len) {
-  return (__vector unsigned char)__builtin_s390_vlrl(__len, __ptr);
+  return (__vector unsigned char)__builtin_s390_vlrlr(__len, __ptr);
 }
 #endif
 
@@ -1617,7 +1617,7 @@ vec_store_len(__vector double __vec, double *__ptr,
 static inline __ATTRS_ai void
 vec_store_len_r(__vector unsigned char __vec, unsigned char *__ptr,
 unsigned int __len) {
-  __builtin_s390_vstrl((__vector signed char)__vec, __len, __ptr);
+  __builtin_s390_vstrlr((__vector signed char)__vec, __len, __ptr);
 }
 #endif
 

diff  --git a/clang/test/CodeGen/SystemZ/builtins-systemz-vector2.c 
b/clang/test/CodeGen/SystemZ/builtins-systemz-vector2.c
index 0fcfeeafbfaa6..5e287e28ed201 100644
--- a/clang/test/CodeGen/SystemZ/builtins-systemz-vector2.c
+++ b/clang/test/CodeGen/SystemZ/builtins-systemz-vector2.c
@@ -33,10 +33,10 @@ void test_core(void) {
   vul = __builtin_s390_vbperm(vuc, vuc);
   // CHECK: call <2 x i64> @llvm.s390.vbperm(<16 x i8> %{{.*}}, <16 x i8> 
%{{.*}})
 
-  vsc = __builtin_s390_vlrl(len, cptr);
+  vsc = __builtin_s390_vlrlr(len, cptr);
   // CHECK: call <16 x i8> @llvm.s390.vlrl(i32 %{{.*}}, ptr %{{.*}})
 
-  __builtin_s390_vstrl(vsc, len, ptr);
+  __builtin_s390_vstrlr(vsc, len, ptr);
   // CHECK: call void @llvm.s390.vstrl(<16 x i8> %{{.*}}, i32 %{{.*}}, ptr 
%{{.*}})
 }
 

diff  --git a/llvm/include/llvm/IR/IntrinsicsSystemZ.td 
b/llvm/include/llvm/IR/IntrinsicsSystemZ.td
index 9f79bdfa9d2d2..a9d80ee5a5c7a 100644
--- a/llvm/include/llvm/IR/IntrinsicsSystemZ.td
+++ b/llvm/include/llvm/IR/IntrinsicsSystemZ.td
@@ -398,11 +398,11 @@ let TargetPrefix = "s390" in {
  [IntrNoMem, ImmArg>, 
ImmArg>]>;
 
   // Instructions from the Vector Packed Decimal Facility
-  def int_s390_vlrl : ClangBuiltin<"__builtin_s390_vlrl">,
+  def int_s390_vlrl : ClangBuiltin<"__builtin_s390_vlrlr">,
   Intrinsic<[llvm_v16i8_ty], [llvm_i32_ty, llvm_ptr_ty],
 [IntrReadMem, IntrArgMemOnly]>;
 
-  def int_s390_vstrl : ClangBuiltin<"__builtin_s390_vstrl">,
+  def int_s390_vstrl : ClangBuiltin<"__builtin_s390_vstrlr">,
Intrinsic<[], [llvm_v16i8_ty, llvm_i32_ty, llvm_ptr_ty],
  [IntrArgMemOnly, IntrWriteMem]>;
 



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


[clang] 9d27139 - [SystemZ] Fix __builtin_s390_vceq* inconsistency

2023-12-04 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2023-12-04T17:00:05+01:00
New Revision: 9d27139293890a18b903c62f2c43954cc2bc302d

URL: 
https://github.com/llvm/llvm-project/commit/9d27139293890a18b903c62f2c43954cc2bc302d
DIFF: 
https://github.com/llvm/llvm-project/commit/9d27139293890a18b903c62f2c43954cc2bc302d.diff

LOG: [SystemZ] Fix __builtin_s390_vceq* inconsistency

The __builtin_s390_vceq* family of builtins currently take
signed arguments with clang, but unsigned with GCC.  Update
clang to match existing GCC precendent.

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsSystemZ.def
clang/lib/Headers/vecintrin.h
clang/test/CodeGen/SystemZ/builtins-systemz-vector.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsSystemZ.def 
b/clang/include/clang/Basic/BuiltinsSystemZ.def
index 02171d29ffd91..4cfc52ae42168 100644
--- a/clang/include/clang/Basic/BuiltinsSystemZ.def
+++ b/clang/include/clang/Basic/BuiltinsSystemZ.def
@@ -80,10 +80,10 @@ TARGET_BUILTIN(__builtin_s390_vavglb, "V16UcV16UcV16Uc", 
"nc", "vector")
 TARGET_BUILTIN(__builtin_s390_vavglh, "V8UsV8UsV8Us", "nc", "vector")
 TARGET_BUILTIN(__builtin_s390_vavglf, "V4UiV4UiV4Ui", "nc", "vector")
 TARGET_BUILTIN(__builtin_s390_vavglg, "V2ULLiV2ULLiV2ULLi", "nc", "vector")
-TARGET_BUILTIN(__builtin_s390_vceqbs, "V16ScV16ScV16Sci*", "nc", "vector")
-TARGET_BUILTIN(__builtin_s390_vceqhs, "V8SsV8SsV8Ssi*", "nc", "vector")
-TARGET_BUILTIN(__builtin_s390_vceqfs, "V4SiV4SiV4Sii*", "nc", "vector")
-TARGET_BUILTIN(__builtin_s390_vceqgs, "V2SLLiV2SLLiV2SLLii*", "nc", "vector")
+TARGET_BUILTIN(__builtin_s390_vceqbs, "V16ScV16UcV16Uci*", "nc", "vector")
+TARGET_BUILTIN(__builtin_s390_vceqhs, "V8SsV8UsV8Usi*", "nc", "vector")
+TARGET_BUILTIN(__builtin_s390_vceqfs, "V4SiV4UiV4Uii*", "nc", "vector")
+TARGET_BUILTIN(__builtin_s390_vceqgs, "V2SLLiV2ULLiV2ULLii*", "nc", "vector")
 TARGET_BUILTIN(__builtin_s390_vchbs, "V16ScV16ScV16Sci*", "nc", "vector")
 TARGET_BUILTIN(__builtin_s390_vchhs, "V8SsV8SsV8Ssi*", "nc", "vector")
 TARGET_BUILTIN(__builtin_s390_vchfs, "V4SiV4SiV4Sii*", "nc", "vector")

diff  --git a/clang/lib/Headers/vecintrin.h b/clang/lib/Headers/vecintrin.h
index 0ea411f40218e..ecfd6cd1a2f87 100644
--- a/clang/lib/Headers/vecintrin.h
+++ b/clang/lib/Headers/vecintrin.h
@@ -2689,7 +2689,8 @@ vec_cmplt(__vector double __a, __vector double __b) {
 static inline __ATTRS_o_ai int
 vec_all_eq(__vector signed char __a, __vector signed char __b) {
   int __cc;
-  __builtin_s390_vceqbs(__a, __b, &__cc);
+  __builtin_s390_vceqbs((__vector unsigned char)__a,
+(__vector unsigned char)__b, &__cc);
   return __cc == 0;
 }
 
@@ -2697,7 +2698,8 @@ vec_all_eq(__vector signed char __a, __vector signed char 
__b) {
 static inline __ATTRS_o_ai int
 vec_all_eq(__vector signed char __a, __vector __bool char __b) {
   int __cc;
-  __builtin_s390_vceqbs(__a, (__vector signed char)__b, &__cc);
+  __builtin_s390_vceqbs((__vector unsigned char)__a,
+(__vector unsigned char)__b, &__cc);
   return __cc == 0;
 }
 
@@ -2705,15 +2707,15 @@ vec_all_eq(__vector signed char __a, __vector __bool 
char __b) {
 static inline __ATTRS_o_ai int
 vec_all_eq(__vector __bool char __a, __vector signed char __b) {
   int __cc;
-  __builtin_s390_vceqbs((__vector signed char)__a, __b, &__cc);
+  __builtin_s390_vceqbs((__vector unsigned char)__a,
+(__vector unsigned char)__b, &__cc);
   return __cc == 0;
 }
 
 static inline __ATTRS_o_ai int
 vec_all_eq(__vector unsigned char __a, __vector unsigned char __b) {
   int __cc;
-  __builtin_s390_vceqbs((__vector signed char)__a,
-(__vector signed char)__b, &__cc);
+  __builtin_s390_vceqbs(__a, __b, &__cc);
   return __cc == 0;
 }
 
@@ -2721,8 +2723,7 @@ vec_all_eq(__vector unsigned char __a, __vector unsigned 
char __b) {
 static inline __ATTRS_o_ai int
 vec_all_eq(__vector unsigned char __a, __vector __bool char __b) {
   int __cc;
-  __builtin_s390_vceqbs((__vector signed char)__a,
-(__vector signed char)__b, &__cc);
+  __builtin_s390_vceqbs(__a, (__vector unsigned char)__b, &__cc);
   return __cc == 0;
 }
 
@@ -2730,23 +2731,23 @@ vec_all_eq(__vector unsigned char __a, __vector __bool 
char __b) {
 static inline __ATTRS_o_ai int
 vec_all_eq(__vector __bool char __a, __vector unsigned char __b) {
   int __cc;
-  __builtin_s390_vceqbs((__vector signed char)__a,
-(__vector signed char)__b, &__cc);
+  __builtin_s390_vceqbs((__vector unsigned char)__a, __b, &__cc);
   return __cc == 0;
 }
 
 static inline __ATTRS_o_ai int
 vec_all_eq(__vector __bool char __a, __vector __bool char __b) {
   int __cc;
-  __builtin_s390_vceqbs((__vector signed char)__a,
-(__vector signed char)__b, &__cc);
+  __builtin_s390_vceqbs((__vector unsigned char)__a,
+(__vector unsigned char)__b, &__cc

[llvm] [clang] [SystemZ] Properly support 16 byte atomic int/fp types and ops. (PR #73134)

2023-12-04 Thread Ulrich Weigand via cfe-commits

https://github.com/uweigand approved this pull request.

This version LGTM now.

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


[clang] 1283ccb - Support z16 processor name

2022-04-21 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2022-04-21T19:58:22+02:00
New Revision: 1283ccb610feef4f2e0edf22f66a705155a0e0c7

URL: 
https://github.com/llvm/llvm-project/commit/1283ccb610feef4f2e0edf22f66a705155a0e0c7
DIFF: 
https://github.com/llvm/llvm-project/commit/1283ccb610feef4f2e0edf22f66a705155a0e0c7.diff

LOG: Support z16 processor name

The recently announced IBM z16 processor implements the architecture
already supported as "arch14" in LLVM.  This patch adds support for
"z16" as an alternate architecture name for arch14.

Added: 
llvm/test/MC/Disassembler/SystemZ/insns-z16.txt
llvm/test/MC/SystemZ/insn-bad-z16.s
llvm/test/MC/SystemZ/insn-good-z16.s

Modified: 
clang/lib/Basic/Targets/SystemZ.cpp
clang/test/CodeGen/SystemZ/builtins-systemz-vector4.c
clang/test/CodeGen/SystemZ/builtins-systemz-zvector4-error.c
clang/test/CodeGen/SystemZ/builtins-systemz-zvector4.c
clang/test/CodeGen/SystemZ/systemz-abi-vector.c
clang/test/CodeGen/SystemZ/systemz-abi.c
clang/test/Driver/systemz-march.c
clang/test/Misc/target-invalid-cpu-note.c
clang/test/Preprocessor/predefined-arch-macros.c
llvm/lib/Support/Host.cpp
llvm/lib/Target/SystemZ/SystemZProcessors.td
llvm/test/CodeGen/SystemZ/vec-intrinsics-04.ll
llvm/unittests/Support/Host.cpp

Removed: 
llvm/test/MC/Disassembler/SystemZ/insns-arch14.txt
llvm/test/MC/SystemZ/insn-bad-arch14.s
llvm/test/MC/SystemZ/insn-good-arch14.s



diff  --git a/clang/lib/Basic/Targets/SystemZ.cpp 
b/clang/lib/Basic/Targets/SystemZ.cpp
index 3af9216315132..84874b58ba68c 100644
--- a/clang/lib/Basic/Targets/SystemZ.cpp
+++ b/clang/lib/Basic/Targets/SystemZ.cpp
@@ -104,7 +104,7 @@ static constexpr ISANameRevision ISARevisions[] = {
   {{"arch11"}, 11}, {{"z13"}, 11},
   {{"arch12"}, 12}, {{"z14"}, 12},
   {{"arch13"}, 13}, {{"z15"}, 13},
-  {{"arch14"}, 14}
+  {{"arch14"}, 14}, {{"z16"}, 14},
 };
 
 int SystemZTargetInfo::getISARevision(StringRef Name) const {

diff  --git a/clang/test/CodeGen/SystemZ/builtins-systemz-vector4.c 
b/clang/test/CodeGen/SystemZ/builtins-systemz-vector4.c
index b0cd994904134..c5ce47cea2ea8 100644
--- a/clang/test/CodeGen/SystemZ/builtins-systemz-vector4.c
+++ b/clang/test/CodeGen/SystemZ/builtins-systemz-vector4.c
@@ -1,5 +1,5 @@
 // REQUIRES: systemz-registered-target
-// RUN: %clang_cc1 -target-cpu arch14 -triple s390x-ibm-linux 
-flax-vector-conversions=none \
+// RUN: %clang_cc1 -target-cpu z16 -triple s390x-ibm-linux 
-flax-vector-conversions=none \
 // RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
 
 typedef __attribute__((vector_size(16))) signed char vec_schar;

diff  --git a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector4-error.c 
b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector4-error.c
index a893e77acbf60..df547cb99f24b 100644
--- a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector4-error.c
+++ b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector4-error.c
@@ -1,5 +1,5 @@
 // REQUIRES: systemz-registered-target
-// RUN: %clang_cc1 -target-cpu arch14 -triple s390x-linux-gnu \
+// RUN: %clang_cc1 -target-cpu z16 -triple s390x-linux-gnu \
 // RUN: -fzvector -flax-vector-conversions=none \
 // RUN: -Wall -Wno-unused -Werror -fsyntax-only -verify %s
 

diff  --git a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector4.c 
b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector4.c
index 602886c17d198..adc55927ce366 100644
--- a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector4.c
+++ b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector4.c
@@ -1,8 +1,8 @@
 // REQUIRES: systemz-registered-target
-// RUN: %clang_cc1 -target-cpu arch14 -triple s390x-linux-gnu \
+// RUN: %clang_cc1 -target-cpu z16 -triple s390x-linux-gnu \
 // RUN: -O2 -fzvector -flax-vector-conversions=none \
 // RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -target-cpu arch14 -triple s390x-linux-gnu \
+// RUN: %clang_cc1 -target-cpu z16 -triple s390x-linux-gnu \
 // RUN: -O2 -fzvector -flax-vector-conversions=none \
 // RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s 
--check-prefix=CHECK-ASM
 

diff  --git a/clang/test/CodeGen/SystemZ/systemz-abi-vector.c 
b/clang/test/CodeGen/SystemZ/systemz-abi-vector.c
index 4a4f03c813463..7817249da757b 100644
--- a/clang/test/CodeGen/SystemZ/systemz-abi-vector.c
+++ b/clang/test/CodeGen/SystemZ/systemz-abi-vector.c
@@ -14,6 +14,8 @@
 // RUN:   -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-VECTOR %s
 // RUN: %clang_cc1 -no-opaque-pointers -no-enable-noundef-analysis -triple 
s390x-linux-gnu -target-cpu arch13 \
 // RUN:   -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-VECTOR %s
+// RUN: %clang_cc1 -no-opaque-pointers -no-enable-noundef-analysis -triple 
s390x-linux-gnu -target-cpu z16 \
+// RUN:   -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-VECTOR %s
 // RUN: %clang_cc1 -no-opaque-pointers -no-enable-noundef-analysis

[libunwind] 364c502 - [libunwind] Add SystemZ support

2022-05-02 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2022-05-02T14:35:29+02:00
New Revision: 364c5023d2ce1617c706b185892ddfaa2fd4d166

URL: 
https://github.com/llvm/llvm-project/commit/364c5023d2ce1617c706b185892ddfaa2fd4d166
DIFF: 
https://github.com/llvm/llvm-project/commit/364c5023d2ce1617c706b185892ddfaa2fd4d166.diff

LOG: [libunwind] Add SystemZ support

Add support for the SystemZ (s390x) architecture to libunwind.

Support should be feature-complete with the exception of
unwinding from signal handlers (to be added later).

Reviewed by: MaskRay

Differential Revision: https://reviews.llvm.org/D124248

Added: 


Modified: 
libunwind/include/__libunwind_config.h
libunwind/include/libunwind.h
libunwind/src/Registers.hpp
libunwind/src/UnwindCursor.hpp
libunwind/src/UnwindRegistersRestore.S
libunwind/src/UnwindRegistersSave.S
libunwind/src/config.h
libunwind/src/libunwind.cpp

Removed: 




diff  --git a/libunwind/include/__libunwind_config.h 
b/libunwind/include/__libunwind_config.h
index 30f5e0a23d08e..e626567d4e594 100644
--- a/libunwind/include/__libunwind_config.h
+++ b/libunwind/include/__libunwind_config.h
@@ -29,6 +29,7 @@
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_HEXAGON   34
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_RISCV 64
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_VE143
+#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_S390X 83
 
 #if defined(_LIBUNWIND_IS_NATIVE_ONLY)
 # if defined(__linux__)
@@ -160,6 +161,11 @@
 #  define _LIBUNWIND_CONTEXT_SIZE 67
 #  define _LIBUNWIND_CURSOR_SIZE 79
 #  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_VE
+# elif defined(__s390x__)
+#  define _LIBUNWIND_TARGET_S390X 1
+#  define _LIBUNWIND_CONTEXT_SIZE 34
+#  define _LIBUNWIND_CURSOR_SIZE 46
+#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_S390X
 # else
 #  error "Unsupported architecture."
 # endif
@@ -178,6 +184,7 @@
 # define _LIBUNWIND_TARGET_HEXAGON 1
 # define _LIBUNWIND_TARGET_RISCV 1
 # define _LIBUNWIND_TARGET_VE 1
+# define _LIBUNWIND_TARGET_S390X 1
 # define _LIBUNWIND_CONTEXT_SIZE 167
 # define _LIBUNWIND_CURSOR_SIZE 179
 # define _LIBUNWIND_HIGHEST_DWARF_REGISTER 287

diff  --git a/libunwind/include/libunwind.h b/libunwind/include/libunwind.h
index a69e72fc132df..3d8fd2146ebbd 100644
--- a/libunwind/include/libunwind.h
+++ b/libunwind/include/libunwind.h
@@ -1177,4 +1177,46 @@ enum {
   UNW_VE_VL   = 145,
 };
 
+// s390x register numbers
+enum {
+  UNW_S390X_R0  = 0,
+  UNW_S390X_R1  = 1,
+  UNW_S390X_R2  = 2,
+  UNW_S390X_R3  = 3,
+  UNW_S390X_R4  = 4,
+  UNW_S390X_R5  = 5,
+  UNW_S390X_R6  = 6,
+  UNW_S390X_R7  = 7,
+  UNW_S390X_R8  = 8,
+  UNW_S390X_R9  = 9,
+  UNW_S390X_R10 = 10,
+  UNW_S390X_R11 = 11,
+  UNW_S390X_R12 = 12,
+  UNW_S390X_R13 = 13,
+  UNW_S390X_R14 = 14,
+  UNW_S390X_R15 = 15,
+  UNW_S390X_F0  = 16,
+  UNW_S390X_F2  = 17,
+  UNW_S390X_F4  = 18,
+  UNW_S390X_F6  = 19,
+  UNW_S390X_F1  = 20,
+  UNW_S390X_F3  = 21,
+  UNW_S390X_F5  = 22,
+  UNW_S390X_F7  = 23,
+  UNW_S390X_F8  = 24,
+  UNW_S390X_F10 = 25,
+  UNW_S390X_F12 = 26,
+  UNW_S390X_F14 = 27,
+  UNW_S390X_F9  = 28,
+  UNW_S390X_F11 = 29,
+  UNW_S390X_F13 = 30,
+  UNW_S390X_F15 = 31,
+  // 32-47 Control Registers
+  // 48-63 Access Registers
+  UNW_S390X_PSWM= 64,
+  UNW_S390X_PSWA= 65,
+  // 66-67 Reserved
+  // 68-83 Vector Registers %v16-%v31
+};
+
 #endif

diff  --git a/libunwind/src/Registers.hpp b/libunwind/src/Registers.hpp
index 32c13e6c9a248..28c617f34999b 100644
--- a/libunwind/src/Registers.hpp
+++ b/libunwind/src/Registers.hpp
@@ -39,6 +39,7 @@ enum {
   REGISTERS_HEXAGON,
   REGISTERS_RISCV,
   REGISTERS_VE,
+  REGISTERS_S390X,
 };
 
 #if defined(_LIBUNWIND_TARGET_I386)
@@ -4716,6 +4717,293 @@ inline const char *Registers_ve::getRegisterName(int 
regNum) {
 }
 #endif // _LIBUNWIND_TARGET_VE
 
+#if defined(_LIBUNWIND_TARGET_S390X)
+/// Registers_s390x holds the register state of a thread in a
+/// 64-bit Linux on IBM zSystems process.
+class _LIBUNWIND_HIDDEN Registers_s390x {
+public:
+  Registers_s390x();
+  Registers_s390x(const void *registers);
+
+  boolvalidRegister(int num) const;
+  uint64_tgetRegister(int num) const;
+  voidsetRegister(int num, uint64_t value);
+  boolvalidFloatRegister(int num) const;
+  double  getFloatRegister(int num) const;
+  voidsetFloatRegister(int num, double value);
+  boolvalidVectorRegister(int num) const;
+  v128getVectorRegister(int num) const;
+  voidsetVectorRegister(int num, v128 value);
+  static const char *getRegisterName(int num);
+  voidjumpto();
+  static int  lastDwarfRegNum() { return 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_S390X; }
+  static int  getArch() { return REGISTERS_S390X; }
+
+  uint6

[libunwind] 7167237 - [libunwind][SystemZ] Unwind out of signal handlers

2022-05-04 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2022-05-04T10:43:11+02:00
New Revision: 71672375fe91d602699ae2a6d6a88e910ff91b5c

URL: 
https://github.com/llvm/llvm-project/commit/71672375fe91d602699ae2a6d6a88e910ff91b5c
DIFF: 
https://github.com/llvm/llvm-project/commit/71672375fe91d602699ae2a6d6a88e910ff91b5c.diff

LOG: [libunwind][SystemZ] Unwind out of signal handlers

Unwinding out of signal handlers currently does not work since
the sigreturn trampoline is not annotated with CFI data.

Fix this by detecting the sigreturn trampoline during unwinding
and providing appropriate unwind data manually. This follows
closely the approach used by existing code for the AArch64 target.

Reviewed by: MaskRay

Differential Revision: https://reviews.llvm.org/D124765

Added: 


Modified: 
libunwind/src/UnwindCursor.hpp
libunwind/test/signal_unwind.pass.cpp
libunwind/test/unwind_leaffunction.pass.cpp

Removed: 




diff  --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 655e41d81d5eb..7e56eff471596 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -953,7 +953,7 @@ class UnwindCursor : public AbstractUnwindCursor{
   }
 #endif
 
-#if defined(_LIBUNWIND_TARGET_LINUX) && defined(_LIBUNWIND_TARGET_AARCH64)
+#if defined(_LIBUNWIND_TARGET_LINUX) && (defined(_LIBUNWIND_TARGET_AARCH64) || 
defined(_LIBUNWIND_TARGET_S390X))
   bool setInfoForSigReturn() {
 R dummy;
 return setInfoForSigReturn(dummy);
@@ -962,8 +962,14 @@ class UnwindCursor : public AbstractUnwindCursor{
 R dummy;
 return stepThroughSigReturn(dummy);
   }
+  #if defined(_LIBUNWIND_TARGET_AARCH64)
   bool setInfoForSigReturn(Registers_arm64 &);
   int stepThroughSigReturn(Registers_arm64 &);
+  #endif
+  #if defined(_LIBUNWIND_TARGET_S390X)
+  bool setInfoForSigReturn(Registers_s390x &);
+  int stepThroughSigReturn(Registers_s390x &);
+  #endif
   template  bool setInfoForSigReturn(Registers &) {
 return false;
   }
@@ -1258,7 +1264,7 @@ class UnwindCursor : public AbstractUnwindCursor{
   unw_proc_info_t  _info;
   bool _unwindInfoMissing;
   bool _isSignalFrame;
-#if defined(_LIBUNWIND_TARGET_LINUX) && defined(_LIBUNWIND_TARGET_AARCH64)
+#if defined(_LIBUNWIND_TARGET_LINUX) && (defined(_LIBUNWIND_TARGET_AARCH64) || 
defined(_LIBUNWIND_TARGET_S390X))
   bool _isSigReturn = false;
 #endif
 };
@@ -2465,7 +2471,7 @@ int UnwindCursor::stepWithTBTable(pint_t pc, 
tbtable *TBTable,
 
 template 
 void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) {
-#if defined(_LIBUNWIND_TARGET_LINUX) && defined(_LIBUNWIND_TARGET_AARCH64)
+#if defined(_LIBUNWIND_TARGET_LINUX) && (defined(_LIBUNWIND_TARGET_AARCH64) || 
defined(_LIBUNWIND_TARGET_S390X))
   _isSigReturn = false;
 #endif
 
@@ -2580,7 +2586,7 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool 
isReturnAddress) {
   }
 #endif // #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
 
-#if defined(_LIBUNWIND_TARGET_LINUX) && defined(_LIBUNWIND_TARGET_AARCH64)
+#if defined(_LIBUNWIND_TARGET_LINUX) && (defined(_LIBUNWIND_TARGET_AARCH64) || 
defined(_LIBUNWIND_TARGET_S390X))
   if (setInfoForSigReturn())
 return;
 #endif
@@ -2653,6 +2659,104 @@ int UnwindCursor::stepThroughSigReturn(Registers_arm64 &) {
 }
 #endif // defined(_LIBUNWIND_TARGET_LINUX) && 
defined(_LIBUNWIND_TARGET_AARCH64)
 
+#if defined(_LIBUNWIND_TARGET_LINUX) && defined(_LIBUNWIND_TARGET_S390X)
+template 
+bool UnwindCursor::setInfoForSigReturn(Registers_s390x &) {
+  // Look for the sigreturn trampoline. The trampoline's body is a
+  // specific instruction (see below). Typically the trampoline comes from the
+  // vDSO (i.e. the __kernel_[rt_]sigreturn function). A libc might provide its
+  // own restorer function, though, or user-mode QEMU might write a trampoline
+  // onto the stack.
+  const pint_t pc = static_cast(this->getReg(UNW_REG_IP));
+  const uint16_t inst = _addressSpace.get16(pc);
+  if (inst == 0x0a77 || inst == 0x0aad) {
+_info = {};
+_info.start_ip = pc;
+_info.end_ip = pc + 2;
+_isSigReturn = true;
+return true;
+  }
+  return false;
+}
+
+template 
+int UnwindCursor::stepThroughSigReturn(Registers_s390x &) {
+  // Determine current SP.
+  const pint_t sp = static_cast(this->getReg(UNW_REG_SP));
+  // According to the s390x ABI, the CFA is at (incoming) SP + 160.
+  const pint_t cfa = sp + 160;
+
+  // Determine current PC and instruction there (this must be either
+  // a "svc __NR_sigreturn" or "svc __NR_rt_sigreturn").
+  const pint_t pc = static_cast(this->getReg(UNW_REG_IP));
+  const uint16_t inst = _addressSpace.get16(pc);
+
+  // Find the addresses of the signo and sigcontext in the frame.
+  pint_t pSigctx = 0;
+  pint_t pSigno = 0;
+
+  // "svc __NR_sigreturn" uses a non-RT signal trampoline frame.
+  if (inst == 0x0a77) {
+// Layout of a non-RT signal trampoline frame, starting at the CFA:
+/

[libunwind] 24ec521 - [libunwind][SystemZ] Use process_vm_readv to avoid potential segfaults

2022-07-18 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2022-07-18T16:54:48+02:00
New Revision: 24ec521cd7bb51447f4ab03460d91c57378d49f7

URL: 
https://github.com/llvm/llvm-project/commit/24ec521cd7bb51447f4ab03460d91c57378d49f7
DIFF: 
https://github.com/llvm/llvm-project/commit/24ec521cd7bb51447f4ab03460d91c57378d49f7.diff

LOG: [libunwind][SystemZ] Use process_vm_readv to avoid potential segfaults

Fix potential crashes during unwind when checking for signal frames
and the current PC is invalid.

The same bug was fixed for aarch64 in https://reviews.llvm.org/D126343.

Reviewed by: MaskRay

Differential Revision: https://reviews.llvm.org/D129856

Added: 


Modified: 
libunwind/src/UnwindCursor.hpp
libunwind/test/bad_unwind_info.pass.cpp

Removed: 




diff  --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index e363f9e59c9a..b8bd9bc59010 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -2695,8 +2695,14 @@ bool UnwindCursor::setInfoForSigReturn(Registers_s390x &) {
   // own restorer function, though, or user-mode QEMU might write a trampoline
   // onto the stack.
   const pint_t pc = static_cast(this->getReg(UNW_REG_IP));
-  const uint16_t inst = _addressSpace.get16(pc);
-  if (inst == 0x0a77 || inst == 0x0aad) {
+  // The PC might contain an invalid address if the unwind info is bad, so
+  // directly accessing it could cause a segfault. Use process_vm_readv to
+  // read the memory safely instead.
+  uint16_t inst;
+  struct iovec local_iov = {&inst, sizeof inst};
+  struct iovec remote_iov = {reinterpret_cast(pc), sizeof inst};
+  long bytesRead = process_vm_readv(getpid(), &local_iov, 1, &remote_iov, 1, 
0);
+  if (bytesRead == sizeof inst && (inst == 0x0a77 || inst == 0x0aad)) {
 _info = {};
 _info.start_ip = pc;
 _info.end_ip = pc + 2;

diff  --git a/libunwind/test/bad_unwind_info.pass.cpp 
b/libunwind/test/bad_unwind_info.pass.cpp
index 97427ea92273..06017d17ab57 100644
--- a/libunwind/test/bad_unwind_info.pass.cpp
+++ b/libunwind/test/bad_unwind_info.pass.cpp
@@ -10,7 +10,7 @@
 // Ensure that libunwind doesn't crash on invalid info; the Linux aarch64
 // sigreturn frame check would previously attempt to access invalid memory in
 // this scenario.
-// REQUIRES: linux && (target={{aarch64-.+}} || target={{x86_64-.+}})
+// REQUIRES: linux && (target={{aarch64-.+}} || target={{s390x-.+}} || 
target={{x86_64-.+}})
 
 // GCC doesn't support __attribute__((naked)) on AArch64.
 // UNSUPPORTED: gcc
@@ -36,6 +36,20 @@ __attribute__((naked)) void bad_unwind_info() {
   ".cfi_def_cfa_offset 0\n"
   ".cfi_restore x30\n"
   "ret\n");
+#elif defined(__s390x__)
+  __asm__("stmg%r14,%r15,112(%r15)\n"
+ "mvghi   104(%r15),4\n"
+  "# purposely use incorrect offset for %r14\n"
+  ".cfi_offset 14, -56\n"
+  ".cfi_offset 15, -40\n"
+  "lay %r15,-160(%r15)\n"
+  ".cfi_def_cfa_offset 320\n"
+  "brasl   %r14,stepper\n"
+  "lmg %r14,%r15,272(%r15)\n"
+  ".cfi_restore 15\n"
+  ".cfi_restore 14\n"
+  ".cfi_def_cfa_offset 160\n"
+  "br  %r14\n");
 #elif defined(__x86_64__)
   __asm__("pushq   %rbx\n"
   ".cfi_def_cfa_offset 16\n"
@@ -48,7 +62,7 @@ __attribute__((naked)) void bad_unwind_info() {
   ".cfi_def_cfa_offset 8\n"
   "ret\n");
 #else
-#error This test is only supported on aarch64 or x86-64
+#error This test is only supported on aarch64, s390x, or x86-64
 #endif
 }
 



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


[clang] c9062e8 - Reapply [libomptarget] Build plugins-nextgen for SystemZ (#83978)

2024-03-15 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2024-03-15T19:06:43+01:00
New Revision: c9062e8f786864f86d330babce78a1926cc5b072

URL: 
https://github.com/llvm/llvm-project/commit/c9062e8f786864f86d330babce78a1926cc5b072
DIFF: 
https://github.com/llvm/llvm-project/commit/c9062e8f786864f86d330babce78a1926cc5b072.diff

LOG: Reapply [libomptarget] Build plugins-nextgen for SystemZ (#83978)

The plugin was not getting built as the build_generic_elf64 macro
assumes the LLVM triple processor name matches the CMake processor name,
which is unfortunately not the case for SystemZ.

Fix this by providing two separate arguments instead.

Actually building the plugin exposed a number of other issues causing
various test failures. Specifically, I've had to add the SystemZ target
to
- CompilerInvocation::ParseLangArgs
- linkDevice in ClangLinuxWrapper.cpp
- OMPContext::OMPContext (to set the device_kind_cpu trait)
- LIBOMPTARGET_ALL_TARGETS in libomptarget/CMakeLists.txt
- a check_plugin_target call in libomptarget/src/CMakeLists.txt

Finally, I've had to set a number of test cases to UNSUPPORTED on
s390x-ibm-linux-gnu; all these tests were already marked as UNSUPPORTED
for x86_64-pc-linux-gnu and aarch64-unknown-linux-gnu and are failing on
s390x for what seem to be the same reason.

In addition, this also requires support for BE ELF files in
plugins-nextgen: https://github.com/llvm/llvm-project/pull/85246

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
llvm/lib/Frontend/OpenMP/OMPContext.cpp
openmp/libomptarget/CMakeLists.txt
openmp/libomptarget/plugins-nextgen/CMakeLists.txt
openmp/libomptarget/plugins-nextgen/aarch64/CMakeLists.txt
openmp/libomptarget/plugins-nextgen/ppc64/CMakeLists.txt
openmp/libomptarget/plugins-nextgen/ppc64le/CMakeLists.txt
openmp/libomptarget/plugins-nextgen/s390x/CMakeLists.txt
openmp/libomptarget/plugins-nextgen/x86_64/CMakeLists.txt
openmp/libomptarget/src/CMakeLists.txt
openmp/libomptarget/test/api/omp_dynamic_shared_memory.c
openmp/libomptarget/test/jit/empty_kernel_lvl1.c
openmp/libomptarget/test/jit/empty_kernel_lvl2.c
openmp/libomptarget/test/jit/type_punning.c
openmp/libomptarget/test/mapping/auto_zero_copy.cpp
openmp/libomptarget/test/mapping/auto_zero_copy_globals.cpp
openmp/libomptarget/test/offloading/barrier_fence.c
openmp/libomptarget/test/offloading/bug49334.cpp
openmp/libomptarget/test/offloading/default_thread_limit.c
openmp/libomptarget/test/offloading/ompx_bare.c
openmp/libomptarget/test/offloading/ompx_coords.c
openmp/libomptarget/test/offloading/ompx_saxpy_mixed.c
openmp/libomptarget/test/offloading/parallel_target_teams_reduction.cpp
openmp/libomptarget/test/offloading/small_trip_count.c
openmp/libomptarget/test/offloading/small_trip_count_thread_limit.cpp
openmp/libomptarget/test/offloading/spmdization.c
openmp/libomptarget/test/offloading/target_critical_region.cpp
openmp/libomptarget/test/offloading/thread_limit.c
openmp/libomptarget/test/ompt/target_memcpy.c
openmp/libomptarget/test/ompt/target_memcpy_emi.c
openmp/libomptarget/test/ompt/veccopy.c
openmp/libomptarget/test/ompt/veccopy_data.c
openmp/libomptarget/test/ompt/veccopy_disallow_both.c
openmp/libomptarget/test/ompt/veccopy_emi.c
openmp/libomptarget/test/ompt/veccopy_emi_map.c
openmp/libomptarget/test/ompt/veccopy_map.c

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 451bdb9386f587..2d3cbb98efcb57 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4014,6 +4014,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, 
ArgList &Args,
 
   if (TT.getArch() == llvm::Triple::UnknownArch ||
   !(TT.getArch() == llvm::Triple::aarch64 || TT.isPPC() ||
+TT.getArch() == llvm::Triple::systemz ||
 TT.getArch() == llvm::Triple::nvptx ||
 TT.getArch() == llvm::Triple::nvptx64 ||
 TT.getArch() == llvm::Triple::amdgcn ||

diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 535ef42c78c463..c60be2789bd61e 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -562,6 +562,7 @@ Expected linkDevice(ArrayRef 
InputFiles,
   case Triple::aarch64_be:
   case Triple::ppc64:
   case Triple::ppc64le:
+  case Triple::systemz:
 return generic::clang(InputFiles, Args);
   default:
 return createStringError(inconvertibleErrorCode(),

diff  --git a/llvm/lib/Frontend/OpenMP/OMPContext.cpp 
b/llvm/lib/Frontend/OpenMP/OMPContext.cpp
index e870c5aa2ba6b8..37936d6000c891 100644
--- a/llvm/lib/Frontend/O

[clang] [llvm] [GOFF][z/OS] Change PrivateGlobalPrefix and PrivateLabelPrefix to be L# (PR #85730)

2024-03-20 Thread Ulrich Weigand via cfe-commits

https://github.com/uweigand approved this pull request.

LGTM, thanks!

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


[clang] [llvm] [openmp] [libomptarget] Build plugins-nextgen for SystemZ (PR #83978)

2024-03-06 Thread Ulrich Weigand via cfe-commits

https://github.com/uweigand updated 
https://github.com/llvm/llvm-project/pull/83978

>From e0cca3ddec75c7624c27a75ae6741dee3b0044fa Mon Sep 17 00:00:00 2001
From: Ulrich Weigand 
Date: Tue, 5 Mar 2024 10:03:55 +0100
Subject: [PATCH] [libomptarget] Build plugins-nextgen for SystemZ

The plugin was not getting built as the build_generic_elf64
macro assumes the LLVM triple processor name matches the
CMake processor name, which is unfortunately not the case
for SystemZ.

Fix this by providing two separate arguments instead.

Actually building the plugin exposed a number of other issues
causing various test failures.  Specifically, I've had to add
the SystemZ target to
- CompilerInvocation::ParseLangArgs
- linkDevice in ClangLinuxWrapper.cpp
- OMPContext::OMPContext (to set the device_kind_cpu trait)
- LIBOMPTARGET_ALL_TARGETS in libomptarget/CMakeLists.txt
- a check_plugin_target call in libomptarget/src/CMakeLists.txt

Finally, I've had to set a number of test cases to UNSUPPORTED
on s390x-ibm-linux-gnu; all these tests were already marked as
UNSUPPORTED for x86_64-pc-linux-gnu and aarch64-unknown-linux-gnu
and are failing on s390x for what seem to be the same reason.

In addition, this also requires support for BE ELF files in
plugins-nextgen: https://github.com/llvm/llvm-project/pull/83976
---
 clang/lib/Frontend/CompilerInvocation.cpp| 1 +
 clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp  | 1 +
 llvm/lib/Frontend/OpenMP/OMPContext.cpp  | 1 +
 openmp/libomptarget/CMakeLists.txt   | 2 ++
 openmp/libomptarget/plugins-nextgen/CMakeLists.txt   | 9 ++---
 .../libomptarget/plugins-nextgen/aarch64/CMakeLists.txt  | 2 +-
 openmp/libomptarget/plugins-nextgen/ppc64/CMakeLists.txt | 2 +-
 .../libomptarget/plugins-nextgen/ppc64le/CMakeLists.txt  | 2 +-
 openmp/libomptarget/plugins-nextgen/s390x/CMakeLists.txt | 2 +-
 .../libomptarget/plugins-nextgen/x86_64/CMakeLists.txt   | 2 +-
 openmp/libomptarget/src/CMakeLists.txt   | 1 +
 openmp/libomptarget/test/api/omp_dynamic_shared_memory.c | 2 ++
 openmp/libomptarget/test/jit/empty_kernel_lvl1.c | 2 ++
 openmp/libomptarget/test/jit/empty_kernel_lvl2.c | 2 ++
 openmp/libomptarget/test/jit/type_punning.c  | 2 ++
 openmp/libomptarget/test/mapping/auto_zero_copy.cpp  | 2 ++
 .../libomptarget/test/mapping/auto_zero_copy_globals.cpp | 2 ++
 openmp/libomptarget/test/offloading/barrier_fence.c  | 2 ++
 openmp/libomptarget/test/offloading/bug49334.cpp | 2 ++
 .../libomptarget/test/offloading/default_thread_limit.c  | 2 ++
 openmp/libomptarget/test/offloading/ompx_bare.c  | 5 -
 openmp/libomptarget/test/offloading/ompx_coords.c| 2 ++
 openmp/libomptarget/test/offloading/ompx_saxpy_mixed.c   | 2 ++
 .../test/offloading/parallel_target_teams_reduction.cpp  | 2 ++
 openmp/libomptarget/test/offloading/small_trip_count.c   | 2 ++
 .../test/offloading/small_trip_count_thread_limit.cpp| 2 ++
 openmp/libomptarget/test/offloading/spmdization.c| 2 ++
 .../test/offloading/target_critical_region.cpp   | 2 ++
 openmp/libomptarget/test/offloading/thread_limit.c   | 2 ++
 openmp/libomptarget/test/ompt/target_memcpy.c| 2 ++
 openmp/libomptarget/test/ompt/target_memcpy_emi.c| 2 ++
 openmp/libomptarget/test/ompt/veccopy.c  | 2 ++
 openmp/libomptarget/test/ompt/veccopy_data.c | 2 ++
 openmp/libomptarget/test/ompt/veccopy_disallow_both.c| 2 ++
 openmp/libomptarget/test/ompt/veccopy_emi.c  | 2 ++
 openmp/libomptarget/test/ompt/veccopy_emi_map.c  | 2 ++
 openmp/libomptarget/test/ompt/veccopy_map.c  | 2 ++
 37 files changed, 71 insertions(+), 9 deletions(-)

diff --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 691f3b989b81e5..7e17c3e49acaf6 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4012,6 +4012,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, 
ArgList &Args,
 
   if (TT.getArch() == llvm::Triple::UnknownArch ||
   !(TT.getArch() == llvm::Triple::aarch64 || TT.isPPC() ||
+TT.getArch() == llvm::Triple::systemz ||
 TT.getArch() == llvm::Triple::nvptx ||
 TT.getArch() == llvm::Triple::nvptx64 ||
 TT.getArch() == llvm::Triple::amdgcn ||
diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 576e8f2cd7f8fd..b3efa56b33021a 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -552,6 +552,7 @@ Expected linkDevice(ArrayRef 
InputFiles,
   case Triple::aarch64_be:
   case Triple::ppc64:
   case Triple::ppc64le:
+  case Triple::systemz:
 return generic::clang(InputFiles, Args);
   default:
 return createStringErr

[clang] [llvm] [openmp] [libomptarget] Build plugins-nextgen for SystemZ (PR #83978)

2024-03-06 Thread Ulrich Weigand via cfe-commits

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


[clang] 70677c8 - Revert "[libomptarget] Build plugins-nextgen for SystemZ (#83978)"

2024-03-06 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2024-03-06T21:37:43+01:00
New Revision: 70677c81debbeacfc2a2fe968e632522ea1b53e1

URL: 
https://github.com/llvm/llvm-project/commit/70677c81debbeacfc2a2fe968e632522ea1b53e1
DIFF: 
https://github.com/llvm/llvm-project/commit/70677c81debbeacfc2a2fe968e632522ea1b53e1.diff

LOG: Revert "[libomptarget] Build plugins-nextgen for SystemZ (#83978)"

This reverts commit 3ecd38c8e1d34b1e4639a1de9f0cb56c7957cbd2.

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
llvm/lib/Frontend/OpenMP/OMPContext.cpp
openmp/libomptarget/CMakeLists.txt
openmp/libomptarget/plugins-nextgen/CMakeLists.txt
openmp/libomptarget/plugins-nextgen/aarch64/CMakeLists.txt
openmp/libomptarget/plugins-nextgen/ppc64/CMakeLists.txt
openmp/libomptarget/plugins-nextgen/ppc64le/CMakeLists.txt
openmp/libomptarget/plugins-nextgen/s390x/CMakeLists.txt
openmp/libomptarget/plugins-nextgen/x86_64/CMakeLists.txt
openmp/libomptarget/src/CMakeLists.txt
openmp/libomptarget/test/api/omp_dynamic_shared_memory.c
openmp/libomptarget/test/jit/empty_kernel_lvl1.c
openmp/libomptarget/test/jit/empty_kernel_lvl2.c
openmp/libomptarget/test/jit/type_punning.c
openmp/libomptarget/test/mapping/auto_zero_copy.cpp
openmp/libomptarget/test/mapping/auto_zero_copy_globals.cpp
openmp/libomptarget/test/offloading/barrier_fence.c
openmp/libomptarget/test/offloading/bug49334.cpp
openmp/libomptarget/test/offloading/default_thread_limit.c
openmp/libomptarget/test/offloading/ompx_bare.c
openmp/libomptarget/test/offloading/ompx_coords.c
openmp/libomptarget/test/offloading/ompx_saxpy_mixed.c
openmp/libomptarget/test/offloading/parallel_target_teams_reduction.cpp
openmp/libomptarget/test/offloading/small_trip_count.c
openmp/libomptarget/test/offloading/small_trip_count_thread_limit.cpp
openmp/libomptarget/test/offloading/spmdization.c
openmp/libomptarget/test/offloading/target_critical_region.cpp
openmp/libomptarget/test/offloading/thread_limit.c
openmp/libomptarget/test/ompt/target_memcpy.c
openmp/libomptarget/test/ompt/target_memcpy_emi.c
openmp/libomptarget/test/ompt/veccopy.c
openmp/libomptarget/test/ompt/veccopy_data.c
openmp/libomptarget/test/ompt/veccopy_disallow_both.c
openmp/libomptarget/test/ompt/veccopy_emi.c
openmp/libomptarget/test/ompt/veccopy_emi_map.c
openmp/libomptarget/test/ompt/veccopy_map.c

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 7e17c3e49acaf6..691f3b989b81e5 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4012,7 +4012,6 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, 
ArgList &Args,
 
   if (TT.getArch() == llvm::Triple::UnknownArch ||
   !(TT.getArch() == llvm::Triple::aarch64 || TT.isPPC() ||
-TT.getArch() == llvm::Triple::systemz ||
 TT.getArch() == llvm::Triple::nvptx ||
 TT.getArch() == llvm::Triple::nvptx64 ||
 TT.getArch() == llvm::Triple::amdgcn ||

diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index b3efa56b33021a..576e8f2cd7f8fd 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -552,7 +552,6 @@ Expected linkDevice(ArrayRef 
InputFiles,
   case Triple::aarch64_be:
   case Triple::ppc64:
   case Triple::ppc64le:
-  case Triple::systemz:
 return generic::clang(InputFiles, Args);
   default:
 return createStringError(inconvertibleErrorCode(),

diff  --git a/llvm/lib/Frontend/OpenMP/OMPContext.cpp 
b/llvm/lib/Frontend/OpenMP/OMPContext.cpp
index 37936d6000c891..e870c5aa2ba6b8 100644
--- a/llvm/lib/Frontend/OpenMP/OMPContext.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPContext.cpp
@@ -44,7 +44,6 @@ OMPContext::OMPContext(bool IsDeviceCompilation, Triple 
TargetTriple) {
   case Triple::ppcle:
   case Triple::ppc64:
   case Triple::ppc64le:
-  case Triple::systemz:
   case Triple::x86:
   case Triple::x86_64:
 ActiveTraits.set(unsigned(TraitProperty::device_kind_cpu));

diff  --git a/openmp/libomptarget/CMakeLists.txt 
b/openmp/libomptarget/CMakeLists.txt
index b382137b70ee2a..a74eff0c0bebf3 100644
--- a/openmp/libomptarget/CMakeLists.txt
+++ b/openmp/libomptarget/CMakeLists.txt
@@ -56,8 +56,6 @@ set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} 
x86_64-pc-linux-gnu-L
 set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} 
nvptx64-nvidia-cuda")
 set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} 
nvptx64-nvidia-cuda-LTO")
 set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} 
nvptx64-nvidia-cuda-JIT-LTO")
-set (LIBOMPTARGET_ALL_T

[clang] [llvm] [openmp] [libomptarget] Build plugins-nextgen for SystemZ (PR #83978)

2024-03-05 Thread Ulrich Weigand via cfe-commits

https://github.com/uweigand created 
https://github.com/llvm/llvm-project/pull/83978

The plugin was not getting built as the build_generic_elf64 macro assumes the 
LLVM triple processor name matches the CMake processor name, which is 
unfortunately not the case for SystemZ.

Fix this by providing two separate arguments instead.

Actually building the plugin exposed a number of other issues causing various 
test failures.  Specifically, I've had to add the SystemZ target to
- CompilerInvocation::ParseLangArgs
- linkDevice in ClangLinuxWrapper.cpp
- OMPContext::OMPContext (to set the device_kind_cpu trait)
- LIBOMPTARGET_ALL_TARGETS in libomptarget/CMakeLists.txt
- a check_plugin_target call in libomptarget/src/CMakeLists.txt

Finally, I've had to set a number of test cases to UNSUPPORTED on 
s390x-ibm-linux-gnu; all these tests were already marked as UNSUPPORTED for 
x86_64-pc-linux-gnu and aarch64-unknown-linux-gnu and are failing on s390x for 
what seem to be the same reason.

In addition, this also requires support for BE ELF files in plugins-nextgen: 
https://github.com/llvm/llvm-project/pull/83976

>From 0ab19aae09cfdc1c0213ce1365d8a47a32d6ec9c Mon Sep 17 00:00:00 2001
From: Ulrich Weigand 
Date: Tue, 5 Mar 2024 10:03:55 +0100
Subject: [PATCH] [libomptarget] Build plugins-nextgen for SystemZ

The plugin was not getting built as the build_generic_elf64
macro assumes the LLVM triple processor name matches the
CMake processor name, which is unfortunately not the case
for SystemZ.

Fix this by providing two separate arguments instead.

Actually building the plugin exposed a number of other issues
causing various test failures.  Specifically, I've had to add
the SystemZ target to
- CompilerInvocation::ParseLangArgs
- linkDevice in ClangLinuxWrapper.cpp
- OMPContext::OMPContext (to set the device_kind_cpu trait)
- LIBOMPTARGET_ALL_TARGETS in libomptarget/CMakeLists.txt
- a check_plugin_target call in libomptarget/src/CMakeLists.txt

Finally, I've had to set a number of test cases to UNSUPPORTED
on s390x-ibm-linux-gnu; all these tests were already marked as
UNSUPPORTED for x86_64-pc-linux-gnu and aarch64-unknown-linux-gnu
and are failing on s390x for what seem to be the same reason.

In addition, this also requires support for BE ELF files in
plugins-nextgen: https://github.com/llvm/llvm-project/pull/83976
---
 clang/lib/Frontend/CompilerInvocation.cpp| 1 +
 clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp  | 1 +
 llvm/lib/Frontend/OpenMP/OMPContext.cpp  | 1 +
 openmp/libomptarget/CMakeLists.txt   | 2 ++
 openmp/libomptarget/plugins-nextgen/CMakeLists.txt   | 9 ++---
 .../libomptarget/plugins-nextgen/aarch64/CMakeLists.txt  | 2 +-
 openmp/libomptarget/plugins-nextgen/ppc64/CMakeLists.txt | 2 +-
 .../libomptarget/plugins-nextgen/ppc64le/CMakeLists.txt  | 2 +-
 openmp/libomptarget/plugins-nextgen/s390x/CMakeLists.txt | 2 +-
 .../libomptarget/plugins-nextgen/x86_64/CMakeLists.txt   | 2 +-
 openmp/libomptarget/src/CMakeLists.txt   | 1 +
 openmp/libomptarget/test/api/omp_dynamic_shared_memory.c | 2 ++
 openmp/libomptarget/test/jit/empty_kernel_lvl1.c | 2 ++
 openmp/libomptarget/test/jit/empty_kernel_lvl2.c | 2 ++
 openmp/libomptarget/test/jit/type_punning.c  | 2 ++
 openmp/libomptarget/test/mapping/auto_zero_copy.cpp  | 2 ++
 .../libomptarget/test/mapping/auto_zero_copy_globals.cpp | 2 ++
 openmp/libomptarget/test/offloading/barrier_fence.c  | 2 ++
 openmp/libomptarget/test/offloading/bug49334.cpp | 2 ++
 .../libomptarget/test/offloading/default_thread_limit.c  | 2 ++
 openmp/libomptarget/test/offloading/ompx_bare.c  | 2 ++
 openmp/libomptarget/test/offloading/ompx_coords.c| 2 ++
 openmp/libomptarget/test/offloading/ompx_saxpy_mixed.c   | 2 ++
 .../test/offloading/parallel_target_teams_reduction.cpp  | 2 ++
 openmp/libomptarget/test/offloading/small_trip_count.c   | 2 ++
 .../test/offloading/small_trip_count_thread_limit.cpp| 2 ++
 openmp/libomptarget/test/offloading/spmdization.c| 2 ++
 .../test/offloading/target_critical_region.cpp   | 2 ++
 openmp/libomptarget/test/offloading/thread_limit.c   | 2 ++
 openmp/libomptarget/test/ompt/target_memcpy.c| 2 ++
 openmp/libomptarget/test/ompt/target_memcpy_emi.c| 2 ++
 openmp/libomptarget/test/ompt/veccopy.c  | 2 ++
 openmp/libomptarget/test/ompt/veccopy_data.c | 2 ++
 openmp/libomptarget/test/ompt/veccopy_disallow_both.c| 2 ++
 openmp/libomptarget/test/ompt/veccopy_emi.c  | 2 ++
 openmp/libomptarget/test/ompt/veccopy_emi_map.c  | 2 ++
 openmp/libomptarget/test/ompt/veccopy_map.c  | 2 ++
 37 files changed, 69 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 691f3b989b81e5..7e17c3e49acaf6 100644
--- a/clang/lib/Frontend/CompilerInvocation

[clang] [SystemZ][z/OS] Add support for recognizing z/OS personality function in Clang (PR #76073)

2024-01-15 Thread Ulrich Weigand via cfe-commits

https://github.com/uweigand approved this pull request.

LGTM

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


[libcxx] [clang] [mlir] [compiler-rt] [llvm] [asan] Enable StackSafetyAnalysis by default (PR #77210)

2024-01-15 Thread Ulrich Weigand via cfe-commits

uweigand wrote:

This now causes failures in the SystemZ build bot:
https://lab.llvm.org/buildbot/#/builders/94/builds/18295


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


[llvm] [compiler-rt] [libcxx] [clang] [mlir] [asan] Enable StackSafetyAnalysis by default (PR #77210)

2024-01-16 Thread Ulrich Weigand via cfe-commits

uweigand wrote:

> This now causes failures in the SystemZ build bot: 
> https://lab.llvm.org/buildbot/#/builders/94/builds/18295

Looking at this a bit more, before this patch the stack alignment test passes 
because the IR is instrumented to include a call to `__asan_alloca_poison` 
using a 32-byte aligned alloca.  *With* this patch, that code is missing 
completely and there is no 32-byte aligned alloca, and therefore the whole 
stack is never re-aligned to a 32-byte boundary.

Not sure why the `__asan_alloca_poison` call is missing now ...


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


[libcxx] [mlir] [llvm] [compiler-rt] [clang] [asan] Enable StackSafetyAnalysis by default (PR #77210)

2024-01-19 Thread Ulrich Weigand via cfe-commits

uweigand wrote:

@MaskRay I've done a bit more analysis now, and what seems to be going on is 
that with stack safety analysis off, this check:
```
  char array[len];
  assert(!(reinterpret_cast(array) & 31L));
```
succeeds because the VLA allocation gets instrumented, and therefore the VLA 
address is guaranteed to be 32-byte aligned.

However, with stack safety analysis *on*, that analysis (correctly) detects 
that the VLA is actually never accessed, and therefore the allocation does not 
need be instrumented.  Because it is isn't instrumented, it remains a regular 
alloca without special alignment requirements.

Therefore, there is no guarantee that the assert will succeed.  If the incoming 
stack pointer happened to already be 32-byte aligned, it will succeed - 
otherwise (and that's the cases where we're seeing failures on s390x), it will 
not.

This seems to be a platform-independent bug that just happens to be visible 
only on some platforms sometimes.


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


[clang] [clang] Language to String function (PR #69487)

2023-10-26 Thread Ulrich Weigand via cfe-commits

uweigand wrote:

This is intended to be used by the z/OS target, see the patch here: 
https://github.com/llvm/llvm-project/pull/68926

I asked Yusra to pull this part out into a separate PR.

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


[clang] 76e9c2a - [FPEnv] Generate constrained FP comparisons from clang

2020-01-10 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2020-01-10T14:33:10+01:00
New Revision: 76e9c2a9870e36415eb343d28942a42296f85597

URL: 
https://github.com/llvm/llvm-project/commit/76e9c2a9870e36415eb343d28942a42296f85597
DIFF: 
https://github.com/llvm/llvm-project/commit/76e9c2a9870e36415eb343d28942a42296f85597.diff

LOG: [FPEnv] Generate constrained FP comparisons from clang

Update the IRBuilder to generate constrained FP comparisons in
CreateFCmp when IsFPConstrained is true, similar to the other
places in the IRBuilder.

Also, add a new CreateFCmpS to emit signaling FP comparisons,
and use it in clang where comparisons are supposed to be signaling
(currently, only when emitting code for the <, <=, >, >= operators).

Note that there is currently no way to add fast-math flags to a
constrained FP comparison, since this is implemented as an intrinsic
call that returns a boolean type, and FMF are only allowed for calls
returning a floating-point type. However, given the discussion around
https://bugs.llvm.org/show_bug.cgi?id=42179, it seems that FCmp itself
really shouldn't have any FMF either, so this is probably OK.

Reviewed by: craig.topper

Differential Revision: https://reviews.llvm.org/D71467

Added: 
clang/test/CodeGen/fpconstrained-cmp-double.c
clang/test/CodeGen/fpconstrained-cmp-float.c

Modified: 
clang/lib/CodeGen/CGExprScalar.cpp
llvm/include/llvm/IR/IRBuilder.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 4adaca8ae571..4338d1c3dcdf 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -798,17 +798,17 @@ class ScalarExprEmitter
   // Comparisons.
   Value *EmitCompare(const BinaryOperator *E, llvm::CmpInst::Predicate 
UICmpOpc,
  llvm::CmpInst::Predicate SICmpOpc,
- llvm::CmpInst::Predicate FCmpOpc);
-#define VISITCOMP(CODE, UI, SI, FP) \
+ llvm::CmpInst::Predicate FCmpOpc, bool IsSignaling);
+#define VISITCOMP(CODE, UI, SI, FP, SIG) \
 Value *VisitBin##CODE(const BinaryOperator *E) { \
   return EmitCompare(E, llvm::ICmpInst::UI, llvm::ICmpInst::SI, \
- llvm::FCmpInst::FP); }
-  VISITCOMP(LT, ICMP_ULT, ICMP_SLT, FCMP_OLT)
-  VISITCOMP(GT, ICMP_UGT, ICMP_SGT, FCMP_OGT)
-  VISITCOMP(LE, ICMP_ULE, ICMP_SLE, FCMP_OLE)
-  VISITCOMP(GE, ICMP_UGE, ICMP_SGE, FCMP_OGE)
-  VISITCOMP(EQ, ICMP_EQ , ICMP_EQ , FCMP_OEQ)
-  VISITCOMP(NE, ICMP_NE , ICMP_NE , FCMP_UNE)
+ llvm::FCmpInst::FP, SIG); }
+  VISITCOMP(LT, ICMP_ULT, ICMP_SLT, FCMP_OLT, true)
+  VISITCOMP(GT, ICMP_UGT, ICMP_SGT, FCMP_OGT, true)
+  VISITCOMP(LE, ICMP_ULE, ICMP_SLE, FCMP_OLE, true)
+  VISITCOMP(GE, ICMP_UGE, ICMP_SGE, FCMP_OGE, true)
+  VISITCOMP(EQ, ICMP_EQ , ICMP_EQ , FCMP_OEQ, false)
+  VISITCOMP(NE, ICMP_NE , ICMP_NE , FCMP_UNE, false)
 #undef VISITCOMP
 
   Value *VisitBinAssign (const BinaryOperator *E);
@@ -3804,7 +3804,8 @@ static llvm::Intrinsic::ID GetIntrinsic(IntrinsicType IT,
 Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,
   llvm::CmpInst::Predicate UICmpOpc,
   llvm::CmpInst::Predicate SICmpOpc,
-  llvm::CmpInst::Predicate FCmpOpc) {
+  llvm::CmpInst::Predicate FCmpOpc,
+  bool IsSignaling) {
   TestAndClearIgnoreResultAssign();
   Value *Result;
   QualType LHSTy = E->getLHS()->getType();
@@ -3900,7 +3901,10 @@ Value *ScalarExprEmitter::EmitCompare(const 
BinaryOperator *E,
 if (BOInfo.isFixedPointBinOp()) {
   Result = EmitFixedPointBinOp(BOInfo);
 } else if (LHS->getType()->isFPOrFPVectorTy()) {
-  Result = Builder.CreateFCmp(FCmpOpc, LHS, RHS, "cmp");
+  if (!IsSignaling)
+Result = Builder.CreateFCmp(FCmpOpc, LHS, RHS, "cmp");
+  else
+Result = Builder.CreateFCmpS(FCmpOpc, LHS, RHS, "cmp");
 } else if (LHSTy->hasSignedIntegerRepresentation()) {
   Result = Builder.CreateICmp(SICmpOpc, LHS, RHS, "cmp");
 } else {
@@ -3957,6 +3961,8 @@ Value *ScalarExprEmitter::EmitCompare(const 
BinaryOperator *E,
 
 Value *ResultR, *ResultI;
 if (CETy->isRealFloatingType()) {
+  // As complex comparisons can only be equality comparisons, they
+  // are never signaling comparisons.
   ResultR = Builder.CreateFCmp(FCmpOpc, LHS.first, RHS.first, "cmp.r");
   ResultI = Builder.CreateFCmp(FCmpOpc, LHS.second, RHS.second, "cmp.i");
 } else {

diff  --git a/clang/test/CodeGen/fpconstrained-cmp-double.c 
b/clang/test/CodeGen/fpconstrained-cmp-double.c
new file mode 100644
index ..2819970a3fcf
--- /dev/null
+++ b/clang/test/CodeGen/fpconstrained-cmp-double.c
@@ -0,0 +1,151 @@
+// RUN: %clang_cc1 -ffp-exception-behavior=ignore -emit-llvm -o - %s | 
FileCheck %s -ch

[clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-10-13 Thread Ulrich Weigand via cfe-commits


@@ -10,7 +10,7 @@
 // .byte (i.e., the one for the 3) would, it seems, also match
 // the .byte line below for the 34.
 
-// RUN: %clang_cc1 --target=s390x-ibm-zos -xc -S -o - %s | FileCheck %s 
--check-prefix CHECK-C
+// RUN: %clang --target=s390x-ibm-zos -xc -S -o - %s | FileCheck %s 
--check-prefix CHECK-C

uweigand wrote:

No, you should be using `%clang_cc1` here.  You'll just need to fix the 
arguments as appropriate for `%clang_cc1` - look at what the other tests in 
this directory are doing.

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


[clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-10-16 Thread Ulrich Weigand via cfe-commits


@@ -976,6 +976,24 @@ void CodeGenModule::Release() {
   Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
   getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
 
+  if (getTriple().isOSzOS()) {
+int32_t ProductVersion, ProductRelease, ProductPatch;
+ProductVersion = LLVM_VERSION_MAJOR, ProductRelease = LLVM_VERSION_MINOR,
+ProductPatch = LLVM_VERSION_PATCH;
+getModule().addModuleFlag(llvm::Module::Warning, "Product Major Version",
+  ProductVersion);
+getModule().addModuleFlag(llvm::Module::Warning, "Product Minor Version",
+  ProductRelease);
+getModule().addModuleFlag(llvm::Module::Warning, "Product Patchlevel",
+  ProductPatch);

uweigand wrote:

These are set only on z/OS, but the flag names appear generic.  If they're (set 
and) used only on z/OS, shouldn't they carry a z/OS specific name like below?

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


[clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-10-16 Thread Ulrich Weigand via cfe-commits


@@ -2267,6 +2268,14 @@ void Clang::AddSystemZTargetArgs(const ArgList &Args,
 CmdArgs.push_back("-mfloat-abi");
 CmdArgs.push_back("soft");
   }
+
+  if (Triple.isOSzOS()) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back(
+Args.MakeArgString(llvm::Twine("-translation-time=")
+   .concat(llvm::Twine(std::time(nullptr)))
+   .str()));
+  }

uweigand wrote:

Is there a good reason for this to be a command-line option, or could this also 
be a module flag just like the others added above?  Seems odd to use two 
different mechanisms here.

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


[clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-10-16 Thread Ulrich Weigand via cfe-commits


@@ -10,9 +10,49 @@
 #include "clang/Config/config.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/TargetParser/Triple.h"
 using namespace clang;
 
+const char *clang::languageToString(Language L) {
+  // I would like to make this function and the definition of Language
+  // in the .h file simply expand the contents of a .def file.
+  // However, in the .h the members of the enum have doxygen annotations
+  // and/or comments which would be lost.

uweigand wrote:

I'm not sure I have a good solution for this, but I'd like to see comments on 
this from the wider clang community.  Maybe it would make sense to submit just 
this function as a separate PR.

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


[clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-10-16 Thread Ulrich Weigand via cfe-commits


@@ -1026,6 +1036,68 @@ void SystemZAsmPrinter::emitADASection() {
   OutStreamer->popSection();
 }
 
+static uint32_t getProductVersion(Module &M) {
+  if (auto *VersionVal = cast_or_null(
+  M.getModuleFlag("Product Major Version")))
+return cast(VersionVal->getValue())->getZExtValue();
+  return LLVM_VERSION_MAJOR;
+}
+
+static uint32_t getProductRelease(Module &M) {
+  if (auto *ReleaseVal = cast_or_null(
+  M.getModuleFlag("Product Minor Version")))
+return cast(ReleaseVal->getValue())->getZExtValue();
+  return LLVM_VERSION_MINOR;
+}
+
+static uint32_t getProductPatch(Module &M) {
+  if (auto *PatchVal = cast_or_null(
+  M.getModuleFlag("Product Patchlevel")))
+return cast(PatchVal->getValue())->getZExtValue();
+  return LLVM_VERSION_PATCH;
+}
+
+void SystemZAsmPrinter::emitIDRLSection(Module &M) {
+  OutStreamer->pushSection();
+  OutStreamer->switchSection(getObjFileLowering().getIDRLSection());
+  constexpr unsigned IDRLDataLength = 30;
+  std::time_t Time = TranslationTime;
+
+  uint32_t ProductVersion = getProductVersion(M);
+  uint32_t ProductRelease = getProductRelease(M);
+
+  std::string ProductID;
+  if (auto *MD = M.getModuleFlag("Product Id"))

uweigand wrote:

This is never set in clang by your patch.  Should it be?

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


[clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-10-16 Thread Ulrich Weigand via cfe-commits


@@ -976,6 +976,24 @@ void CodeGenModule::Release() {
   Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
   getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
 
+  if (getTriple().isOSzOS()) {
+int32_t ProductVersion, ProductRelease, ProductPatch;
+ProductVersion = LLVM_VERSION_MAJOR, ProductRelease = LLVM_VERSION_MINOR,
+ProductPatch = LLVM_VERSION_PATCH;

uweigand wrote:

Do we need extra variables for this?

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


[clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)

2023-10-16 Thread Ulrich Weigand via cfe-commits


@@ -1296,6 +1372,124 @@ void SystemZAsmPrinter::emitPPA1(MCSymbol *FnEndSym) {
   4);
 }
 
+void SystemZAsmPrinter::emitStartOfAsmFile(Module &M) {
+  if (TM.getTargetTriple().isOSzOS())
+emitPPA2(M);
+  AsmPrinter::emitStartOfAsmFile(M);
+}
+
+void SystemZAsmPrinter::emitPPA2(Module &M) {
+  OutStreamer->pushSection();
+  OutStreamer->switchSection(getObjFileLowering().getPPA2Section());
+  MCContext &OutContext = OutStreamer->getContext();
+  // Make CELQSTRT symbol.
+  const char *StartSymbolName = "CELQSTRT";
+  MCSymbol *CELQSTRT = OutContext.getOrCreateSymbol(StartSymbolName);
+
+  // Create symbol and assign to class field for use in PPA1.
+  PPA2Sym = OutContext.createTempSymbol("PPA2", false);
+  MCSymbol *DateVersionSym = OutContext.createTempSymbol("DVS", false);
+
+  std::time_t Time = TranslationTime;
+  SmallString<15> CompilationTime; // 14 + null
+  raw_svector_ostream O(CompilationTime);
+  O << formatv("{0:%Y%m%d%H%M%S}", llvm::sys::toUtcTime(Time));
+
+  uint32_t ProductVersion = getProductVersion(M),
+   ProductRelease = getProductRelease(M),
+   ProductPatch = getProductPatch(M);
+
+  SmallString<7> Version; // 6 + null
+  raw_svector_ostream ostr(Version);
+  ostr << formatv("{0,0-2:d}{1,0-2:d}{2,0-2:d}", ProductVersion, 
ProductRelease,
+  ProductPatch);
+
+  // Drop 0 during conversion.
+  SmallString CompilationTimeStr;
+  SmallString VersionStr;
+
+  ConverterEBCDIC::convertToEBCDIC(CompilationTime, CompilationTimeStr);
+  ConverterEBCDIC::convertToEBCDIC(Version, VersionStr);
+
+  enum class PPA2MemberId : uint8_t {
+// See z/OS Language Environment Vendor Interfaces v2r5, p.23, for
+// complete list. Only the C runtime is supported by this backend.
+LE_C_Runtime = 3,
+  };
+  enum class PPA2MemberSubId : uint8_t {
+// List of languages using the LE C runtime implementation.
+C = 0x00,
+CXX = 0x01,
+Swift = 0x03,
+Go = 0x60,
+LLVMBasedLang = 0xe7,
+  };
+  // PPA2 Flags
+  enum class PPA2Flags : uint8_t {
+CompileForBinaryFloatingPoint = 0x80,
+CompiledWithXPLink = 0x01,
+CompiledUnitASCII = 0x04,
+HasServiceInfo = 0x20,
+  };
+
+  PPA2MemberSubId MemberSubId = PPA2MemberSubId::LLVMBasedLang;
+  if (auto *MD = M.getModuleFlag("zos_cu_language")) {
+StringRef Language = cast(MD)->getString();
+MemberSubId = StringSwitch(Language)
+  .Case("C", PPA2MemberSubId::C)
+  .Case("CXX", PPA2MemberSubId::CXX)
+  .Case("Swift", PPA2MemberSubId::Swift)
+  .Case("Go", PPA2MemberSubId::Go)
+  .Default(PPA2MemberSubId::LLVMBasedLang);
+  }
+
+  // Emit PPA2 section.
+  OutStreamer->emitLabel(PPA2Sym);
+  OutStreamer->emitInt8(static_cast(PPA2MemberId::LE_C_Runtime));
+  OutStreamer->emitInt8(static_cast(MemberSubId));
+  OutStreamer->emitInt8(0x22); // Member defined, c370_plist+c370_env
+  OutStreamer->emitInt8(0x04); // Control level 4 (XPLink)
+  OutStreamer->emitAbsoluteSymbolDiff(CELQSTRT, PPA2Sym, 4);
+  OutStreamer->emitInt32(0x);
+  OutStreamer->emitAbsoluteSymbolDiff(DateVersionSym, PPA2Sym, 4);
+  OutStreamer->emitInt32(
+  0x); // Offset to main entry point, always 0 (so says TR).
+  uint8_t Flgs = 
static_cast(PPA2Flags::CompileForBinaryFloatingPoint);
+  Flgs |= static_cast(PPA2Flags::CompiledWithXPLink);
+
+  if (auto *MD = M.getModuleFlag("zos_le_char_mode")) {

uweigand wrote:

This is also nowhere set in clang right now.  Should it be?   If it isn't set, 
is EBCDIC the right default?

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


[clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #65407)

2023-09-07 Thread Ulrich Weigand via cfe-commits

uweigand wrote:

SystemZ back-end changes LGTM.Additional reviews as to the Clang and time 
support changes would be appreciated.

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


[clang] [clang][CodeGen] Use byval for SystemZ indirect arguments (PR #66404)

2023-09-14 Thread Ulrich Weigand via cfe-commits

uweigand wrote:

This looks correct to me.  I'm just wondering if there's any unexpected change 
of generated code due to this - did you do a comparison before/after of some 
larger code bases?

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


[clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #65407)

2023-09-06 Thread Ulrich Weigand via cfe-commits

https://github.com/uweigand approved this pull request.

LGTM

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


[clang] 9c9d88d - [SystemZ] Allow configuring default CLANG_SYSTEMZ_ARCH

2020-03-30 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2020-03-30T14:20:48+02:00
New Revision: 9c9d88d8b1bb6468f6c4258fe41bbcd01f742801

URL: 
https://github.com/llvm/llvm-project/commit/9c9d88d8b1bb6468f6c4258fe41bbcd01f742801
DIFF: 
https://github.com/llvm/llvm-project/commit/9c9d88d8b1bb6468f6c4258fe41bbcd01f742801.diff

LOG: [SystemZ] Allow configuring default CLANG_SYSTEMZ_ARCH

On Ubuntu, we want to raise default CLANG_SYSTEMZ_ARCH to z13,
thus allow configuring this via CMake.
On Debian, we want to raise it to z196.

Author: Dimitri John Ledkov
Differential Revision: https://reviews.llvm.org/D75914

Added: 


Modified: 
clang/CMakeLists.txt
clang/lib/Driver/ToolChains/Arch/SystemZ.cpp

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 7809d6529195..c9e76c5e4518 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -306,6 +306,10 @@ if (NOT DEFINED MATCHED_ARCH OR "${CMAKE_MATCH_1}" LESS 35)
 "Default architecture for OpenMP offloading to Nvidia GPUs." FORCE)
 endif()
 
+set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING
+  "SystemZ Default Arch")
+add_definitions( -DCLANG_SYSTEMZ_DEFAULT_ARCH="${CLANG_SYSTEMZ_DEFAULT_ARCH}")
+
 set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING
   "Vendor-specific text for showing with version information.")
 

diff  --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp 
b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
index 4d871104c95a..b263fb7df09e 100644
--- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
@@ -47,7 +47,7 @@ std::string systemz::getSystemZTargetCPU(const ArgList &Args) 
{
 
 return std::string(CPUName);
   }
-  return "z10";
+  return CLANG_SYSTEMZ_DEFAULT_ARCH;
 }
 
 void systemz::getSystemZTargetFeatures(const Driver &D, const ArgList &Args,



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


[clang] 9f99aba - [clang][SystemZ] Add support for -march=native

2019-12-16 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2019-12-16T16:11:32+01:00
New Revision: 9f99aba1cfeb603f368c45ef78ba9795bab16d47

URL: 
https://github.com/llvm/llvm-project/commit/9f99aba1cfeb603f368c45ef78ba9795bab16d47
DIFF: 
https://github.com/llvm/llvm-project/commit/9f99aba1cfeb603f368c45ef78ba9795bab16d47.diff

LOG: [clang][SystemZ] Add support for -march=native

Handle -march=native in systemz::getSystemZTargetCPU, similar to
how this is done on other platforms.  Also change the return type
to std::string instead of const char *.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
clang/lib/Driver/ToolChains/Arch/SystemZ.h
clang/lib/Driver/ToolChains/Gnu.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp 
b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
index ca60b85cf8a0..2b77d59fdc66 100644
--- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
@@ -9,15 +9,27 @@
 #include "SystemZ.h"
 #include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/Host.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
 using namespace clang;
 using namespace llvm::opt;
 
-const char *systemz::getSystemZTargetCPU(const ArgList &Args) {
-  if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ))
-return A->getValue();
+std::string systemz::getSystemZTargetCPU(const ArgList &Args) {
+  if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
+llvm::StringRef CPUName = A->getValue();
+
+if (CPUName == "native") {
+  std::string CPU = llvm::sys::getHostCPUName();
+  if (!CPU.empty() && CPU != "generic")
+return CPU;
+  else
+return "";
+}
+
+return CPUName;
+  }
   return "z10";
 }
 

diff  --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.h 
b/clang/lib/Driver/ToolChains/Arch/SystemZ.h
index 11d77fa01cc8..77dcbc47be5c 100644
--- a/clang/lib/Driver/ToolChains/Arch/SystemZ.h
+++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.h
@@ -11,6 +11,7 @@
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Option/Option.h"
+#include 
 #include 
 
 namespace clang {
@@ -18,7 +19,7 @@ namespace driver {
 namespace tools {
 namespace systemz {
 
-const char *getSystemZTargetCPU(const llvm::opt::ArgList &Args);
+std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args);
 
 void getSystemZTargetFeatures(const llvm::opt::ArgList &Args,
   std::vector &Features);

diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 250e924fb84c..7c0bcdcaf074 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -862,7 +862,7 @@ void tools::gnutools::Assembler::ConstructJob(Compilation 
&C,
   case llvm::Triple::systemz: {
 // Always pass an -march option, since our default of z10 is later
 // than the GNU assembler's default.
-StringRef CPUName = systemz::getSystemZTargetCPU(Args);
+std::string CPUName = systemz::getSystemZTargetCPU(Args);
 CmdArgs.push_back(Args.MakeArgString("-march=" + CPUName));
 break;
   }



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


Re: [clang-tools-extra] a0ff8cd - [clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor if token-after-cursor fails.

2019-12-16 Thread Ulrich Weigand via cfe-commits


Sam McCall wrote:

>LOG: [clangd] Reapply b60896fad926 Fall back to selecting
token-before-cursor if token-after-cursor fails.
>
>This reverts commit 8f876d5105507f874c0fb86bc779c9853eab3fe2.

I believe this has caused a significant number of build bot failures,
with error messages along these lines:
(see
http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/28908/steps/build%20stage%201/logs/stdio
)


In file included from /usr/include/c++/7/memory:64:0,

from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/llvm/include/llvm/ADT/Optional.h:22,


from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/../clang-tidy/ClangTidyOptions.h:13,


from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/ClangdServer.h:12,


from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/ClangdServer.cpp:9:

/usr/include/c++/7/bits/stl_construct.h: In instantiation of 'void
std::_Construct(_T1*, _Args&& ...) [with _T1 =
clang::clangd::Tweak::Selection; _Args = {const
clang::clangd::Tweak::Selection&}]':
/usr/include/c++/7/bits/stl_uninitialized.h:83:18:   required from 'static
_ForwardIterator
std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy
(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator =
__gnu_cxx::__normal_iterator >; _ForwardIterator =
clang::clangd::Tweak::Selection*; bool _TrivialValueTypes = false]'
/usr/include/c++/7/bits/stl_uninitialized.h:134:15:   required from
'_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator,
_ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator >; _ForwardIterator =
clang::clangd::Tweak::Selection*]'
/usr/include/c++/7/bits/stl_uninitialized.h:289:37:   required from
'_ForwardIterator std::__uninitialized_copy_a(_InputIterator,
_InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with
_InputIterator = __gnu_cxx::__normal_iterator >; _ForwardIterator =
clang::clangd::Tweak::Selection*; _Tp = clang::clangd::Tweak::Selection]'
/usr/include/c++/7/bits/stl_vector.h:331:31:   required from
'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with
_Tp = clang::clangd::Tweak::Selection; _Alloc =
std::allocator]'
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/llvm/include/llvm/Support/Error.h:483:5:
   required from 'llvm::Expected::Expected(OtherT&&, typename
std::enable_if::value>::type*) [with OtherT
= std::vector&; T =
std::vector; typename
std::enable_if::value>::type = void]'
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/ClangdServer.cpp:394:10:
   required from here
/usr/include/c++/7/bits/stl_construct.h:75:7: error: use of deleted
function 'clang::clangd::Tweak::Selection::Selection(const
clang::clangd::Tweak::Selection&)'
 { ::new(static_cast(__p)) _T1(std::forward<_Args>
(__args)...); }
   ^~
In file included
from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/ClangdServer.h:28:0,


from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/ClangdServer.cpp:9:

/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/refactor/Tweak.h:49:10:
 note: 'clang::clangd::Tweak::Selection::Selection(const
clang::clangd::Tweak::Selection&)' is implicitly deleted because the
default definition would be ill-formed:
   struct Selection {
  ^
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/refactor/Tweak.h:49:10:
 error: use of deleted function
'clang::clangd::SelectionTree::SelectionTree(const
clang::clangd::SelectionTree&)'
In file included
from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/refactor/Tweak.h:25:0,


from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/ClangdServer.h:28,


from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/ClangdServer.cpp:9:

/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/Selection.h:96:3:
 note: declared here
   SelectionTree(const SelectionTree &) = delete;
   ^


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


[clang] cebba7c - [SystemZ] Avoid unnecessary conversions in vecintrin.h

2020-01-16 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2020-01-16T18:58:14+01:00
New Revision: cebba7ce3952c8f37a923fa3a10360fd4c463775

URL: 
https://github.com/llvm/llvm-project/commit/cebba7ce3952c8f37a923fa3a10360fd4c463775
DIFF: 
https://github.com/llvm/llvm-project/commit/cebba7ce3952c8f37a923fa3a10360fd4c463775.diff

LOG: [SystemZ] Avoid unnecessary conversions in vecintrin.h

Use floating-point instead of integer zero constants to avoid
creating implicit conversions, which currently cause suboptimal
code to be generated with -ffp-exception-behavior=strict.

NFC otherwise.

Added: 


Modified: 
clang/lib/Headers/vecintrin.h

Removed: 




diff  --git a/clang/lib/Headers/vecintrin.h b/clang/lib/Headers/vecintrin.h
index c71b76a3ee39..6f9b609f2dfe 100644
--- a/clang/lib/Headers/vecintrin.h
+++ b/clang/lib/Headers/vecintrin.h
@@ -290,7 +290,7 @@ vec_promote(unsigned long long __scalar, int __index) {
 #if __ARCH__ >= 12
 static inline __ATTRS_o_ai vector float
 vec_promote(float __scalar, int __index) {
-  const vector float __zero = (vector float)0;
+  const vector float __zero = (vector float)0.0f;
   vector float __vec = __builtin_shufflevector(__zero, __zero, -1, -1, -1, -1);
   __vec[__index & 3] = __scalar;
   return __vec;
@@ -299,7 +299,7 @@ vec_promote(float __scalar, int __index) {
 
 static inline __ATTRS_o_ai vector double
 vec_promote(double __scalar, int __index) {
-  const vector double __zero = (vector double)0;
+  const vector double __zero = (vector double)0.0;
   vector double __vec = __builtin_shufflevector(__zero, __zero, -1, -1);
   __vec[__index & 1] = __scalar;
   return __vec;
@@ -366,7 +366,7 @@ vec_insert_and_zero(const unsigned long long *__ptr) {
 #if __ARCH__ >= 12
 static inline __ATTRS_o_ai vector float
 vec_insert_and_zero(const float *__ptr) {
-  vector float __vec = (vector float)0;
+  vector float __vec = (vector float)0.0f;
   __vec[1] = *__ptr;
   return __vec;
 }
@@ -374,7 +374,7 @@ vec_insert_and_zero(const float *__ptr) {
 
 static inline __ATTRS_o_ai vector double
 vec_insert_and_zero(const double *__ptr) {
-  vector double __vec = (vector double)0;
+  vector double __vec = (vector double)0.0;
   __vec[0] = *__ptr;
   return __vec;
 }



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


r294197 - [SystemZ] Provide predefined __ARCH__ and __VX__ macros

2017-02-06 Thread Ulrich Weigand via cfe-commits
Author: uweigand
Date: Mon Feb  6 11:04:22 2017
New Revision: 294197

URL: http://llvm.org/viewvc/llvm-project?rev=294197&view=rev
Log:
[SystemZ] Provide predefined __ARCH__ and __VX__ macros

GCC 7 will predefine two new macros on s390x:

- __ARCH__ indicates the ISA architecture level
- __VX__ indicates that the vector facility is available

This adds those macros to clang as well to ensure continued
compatibility with GCC.


Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=294197&r1=294196&r2=294197&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Feb  6 11:04:22 2017
@@ -7037,6 +7037,15 @@ public:
 Builder.defineMacro("__zarch__");
 Builder.defineMacro("__LONG_DOUBLE_128__");
 
+const std::string ISARev = llvm::StringSwitch(CPU)
+   .Cases("arch8", "z10", "8")
+   .Cases("arch9", "z196", "9")
+   .Cases("arch10", "zEC12", "10")
+   .Cases("arch11", "z13", "11")
+   .Default("");
+if (!ISARev.empty())
+  Builder.defineMacro("__ARCH__", ISARev);
+
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
@@ -7044,6 +7053,8 @@ public:
 
 if (HasTransactionalExecution)
   Builder.defineMacro("__HTM__");
+if (HasVector)
+  Builder.defineMacro("__VX__");
 if (Opts.ZVector)
   Builder.defineMacro("__VEC__", "10301");
   }

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=294197&r1=294196&r2=294197&view=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Mon Feb  6 11:04:22 
2017
@@ -2035,35 +2035,76 @@
 
 // Begin SystemZ/GCC/Linux tests 
 //
+// RUN: %clang -march=arch8 -E -dM %s -o - 2>&1 \
+// RUN: -target s390x-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH8
 // RUN: %clang -march=z10 -E -dM %s -o - 2>&1 \
 // RUN: -target s390x-unknown-linux \
-// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_Z10
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH8
 //
-// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
-// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
-// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
-// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
-// CHECK_SYSTEMZ_Z10: #define __LONG_DOUBLE_128__ 1
-// CHECK_SYSTEMZ_Z10: #define __s390__ 1
-// CHECK_SYSTEMZ_Z10: #define __s390x__ 1
-// CHECK_SYSTEMZ_Z10: #define __zarch__ 1
+// CHECK_SYSTEMZ_ARCH8: #define __ARCH__ 8
+// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+// CHECK_SYSTEMZ_ARCH8: #define __LONG_DOUBLE_128__ 1
+// CHECK_SYSTEMZ_ARCH8: #define __s390__ 1
+// CHECK_SYSTEMZ_ARCH8: #define __s390x__ 1
+// CHECK_SYSTEMZ_ARCH8: #define __zarch__ 1
 //
-// RUN: %clang -march=zEC12 -E -dM %s -o - 2>&1 \
+// RUN: %clang -march=arch9 -E -dM %s -o - 2>&1 \
 // RUN: -target s390x-unknown-linux \
-// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ZEC12
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH9
+// RUN: %clang -march=z196 -E -dM %s -o - 2>&1 \
+// RUN: -target s390x-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH9
+//
+// CHECK_SYSTEMZ_ARCH9: #define __ARCH__ 9
+// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+// CHECK_SYSTEMZ_ARCH9: #define __LONG_DOUBLE_128__ 1
+// CHECK_SYSTEMZ_ARCH9: #define __s390__ 1
+// CHECK_SYSTEMZ_ARCH9: #define __s390x__ 1
+// CHECK_SYSTEMZ_ARCH9: #define __zarch__ 1
+//
 // RUN: %clang -march=arch10 -E -dM %s -o - 2>&1 \
 // RUN: -target s390x-unknown-linux \
-// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ZEC12
+// RUN:   | FileCheck -match-full-lines %s -check-

r307156 - [SystemZ] Simplify handling of ISA revisions

2017-07-05 Thread Ulrich Weigand via cfe-commits
Author: uweigand
Date: Wed Jul  5 06:19:47 2017
New Revision: 307156

URL: http://llvm.org/viewvc/llvm-project?rev=307156&view=rev
Log:
[SystemZ] Simplify handling of ISA revisions

This moves determination of the ISA revision from the CPU name to
one single place, removing a bunch of duplicated code.  It also
makes the supported ISA revisions available as feature strings.

No functional change.


Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=307156&r1=307155&r2=307156&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jul  5 06:19:47 2017
@@ -7424,13 +7424,14 @@ class SystemZTargetInfo : public TargetI
   static const Builtin::Info BuiltinInfo[];
   static const char *const GCCRegNames[];
   std::string CPU;
+  int ISARevision;
   bool HasTransactionalExecution;
   bool HasVector;
 
 public:
   SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
-  : TargetInfo(Triple), CPU("z10"), HasTransactionalExecution(false),
-HasVector(false) {
+  : TargetInfo(Triple), CPU("z10"), ISARevision(8),
+HasTransactionalExecution(false), HasVector(false) {
 IntMaxType = SignedLong;
 Int64Type = SignedLong;
 TLSSupported = true;
@@ -7452,14 +7453,7 @@ public:
 Builder.defineMacro("__zarch__");
 Builder.defineMacro("__LONG_DOUBLE_128__");
 
-const std::string ISARev = llvm::StringSwitch(CPU)
-   .Cases("arch8", "z10", "8")
-   .Cases("arch9", "z196", "9")
-   .Cases("arch10", "zEC12", "10")
-   .Cases("arch11", "z13", "11")
-   .Default("");
-if (!ISARev.empty())
-  Builder.defineMacro("__ARCH__", ISARev);
+Builder.defineMacro("__ARCH__", Twine(ISARevision));
 
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
@@ -7492,37 +7486,35 @@ public:
   BuiltinVaListKind getBuiltinVaListKind() const override {
 return TargetInfo::SystemZBuiltinVaList;
   }
+  int getISARevision(const StringRef &Name) const {
+return llvm::StringSwitch(Name)
+  .Cases("arch8", "z10", 8)
+  .Cases("arch9", "z196", 9)
+  .Cases("arch10", "zEC12", 10)
+  .Cases("arch11", "z13", 11)
+  .Default(-1);
+  }
   bool setCPU(const std::string &Name) override {
 CPU = Name;
-bool CPUKnown = llvm::StringSwitch(Name)
-  .Case("z10", true)
-  .Case("arch8", true)
-  .Case("z196", true)
-  .Case("arch9", true)
-  .Case("zEC12", true)
-  .Case("arch10", true)
-  .Case("z13", true)
-  .Case("arch11", true)
-  .Default(false);
-
-return CPUKnown;
+ISARevision = getISARevision(CPU);
+return ISARevision != -1;
   }
   bool
   initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine &Diags,
  StringRef CPU,
  const std::vector &FeaturesVec) const override {
-if (CPU == "zEC12" || CPU == "arch10")
-  Features["transactional-execution"] = true;
-if (CPU == "z13" || CPU == "arch11") {
+int ISARevision = getISARevision(CPU);
+if (ISARevision >= 10)
   Features["transactional-execution"] = true;
+if (ISARevision >= 11)
   Features["vector"] = true;
-}
 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
   }
 
   bool handleTargetFeatures(std::vector &Features,
 DiagnosticsEngine &Diags) override {
 HasTransactionalExecution = false;
+HasVector = false;
 for (const auto &Feature : Features) {
   if (Feature == "+transactional-execution")
 HasTransactionalExecution = true;
@@ -7541,6 +7533,10 @@ public:
   bool hasFeature(StringRef Feature) const override {
 return llvm::StringSwitch(Feature)
 .Case("systemz", true)
+.Case("arch8", ISARevision >= 8)
+.Case("arch9", ISARevision >= 9)
+.Case("arch10", ISARevision >= 10)
+.Case("arch11", ISARevision >= 11)
 .Case("htm", HasTransactionalExecution)
 .Case("vx", HasVector)
 .Default(false);


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


r308197 - [SystemZ] Add support for IBM z14 processor (1/3)

2017-07-17 Thread Ulrich Weigand via cfe-commits
Author: uweigand
Date: Mon Jul 17 10:45:57 2017
New Revision: 308197

URL: http://llvm.org/viewvc/llvm-project?rev=308197&view=rev
Log:
[SystemZ] Add support for IBM z14 processor (1/3)

This patch series adds support for the IBM z14 processor.  This part includes:
- Basic support for the new processor and its features.
- Support for low-level builtins mapped to new LLVM intrinsics.

Support for the -fzvector extension to vector float and the new
high-level vector intrinsics is provided by separate patches.


Added:
cfe/trunk/test/CodeGen/builtins-systemz-vector2-error.c
cfe/trunk/test/CodeGen/builtins-systemz-vector2.c
Modified:
cfe/trunk/include/clang/Basic/BuiltinsSystemZ.def
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/systemz-abi-vector.c
cfe/trunk/test/CodeGen/systemz-abi.c
cfe/trunk/test/CodeGen/target-data.c
cfe/trunk/test/Driver/systemz-march.c
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsSystemZ.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsSystemZ.def?rev=308197&r1=308196&r2=308197&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsSystemZ.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsSystemZ.def Mon Jul 17 10:45:57 2017
@@ -253,5 +253,29 @@ TARGET_BUILTIN(__builtin_s390_vfmsdb, "V
 TARGET_BUILTIN(__builtin_s390_vfsqdb, "V2dV2d", "nc", "vector")
 TARGET_BUILTIN(__builtin_s390_vftcidb, "V2SLLiV2dIii*", "nc", "vector")
 
+// Vector-enhancements facility 1 intrinsics.
+TARGET_BUILTIN(__builtin_s390_vlrl, "V16ScUivC*", "", "vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vstrl, "vV16ScUiv*", "", "vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vbperm, "V2ULLiV16UcV16Uc", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vmslg, "V16UcV2ULLiV2ULLiV16UcIi", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfmaxdb, "V2dV2dV2dIi", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfmindb, "V2dV2dV2dIi", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfnmadb, "V2dV2dV2dV2d", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfnmsdb, "V2dV2dV2dV2d", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfcesbs, "V4SiV4fV4fi*", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfchsbs, "V4SiV4fV4fi*", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfchesbs, "V4SiV4fV4fi*", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfisb, "V4fV4fIiIi", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfmaxsb, "V4fV4fV4fIi", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfminsb, "V4fV4fV4fIi", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vflnsb, "V4fV4f", "nc", "vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vflpsb, "V4fV4f", "nc", "vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfmasb, "V4fV4fV4fV4f", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfmssb, "V4fV4fV4fV4f", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfnmasb, "V4fV4fV4fV4f", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfnmssb, "V4fV4fV4fV4f", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfsqsb, "V4fV4f", "nc", "vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vftcisb, "V4SiV4fIii*", "nc", 
"vector-enhancements-1")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=308197&r1=308196&r2=308197&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Jul 17 10:45:57 2017
@@ -7503,6 +7503,7 @@ public:
   .Cases("arch9", "z196", 9)
   .Cases("arch10", "zEC12", 10)
   .Cases("arch11", "z13", 11)
+  .Cases("arch12", "z14", 12)
   .Default(-1);
   }
   bool setCPU(const std::string &Name) override {
@@ -7519,6 +7520,8 @@ public:
   Features["transactional-execution"] = true;
 if (ISARevision >= 11)
   Features["vector"] = true;
+if (ISARevision >= 12)
+  Features["vector-enhancements-1"] = true;
 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
   }
 
@@ -7548,6 +7551,7 @@ public:
 .Case("arch9", ISARevision >= 9)
 .Case("arch10", ISARevision >= 10)
 .Case("arch11", ISARevision >= 11)
+.Case("arch12", ISARevision >= 12)
 .Case("htm", HasTransactionalExecution)
 .Case("vx", HasVector)
 .Default(false);

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=308197&r1=30

r308198 - [SystemZ] Add support for IBM z14 processor (2/3)

2017-07-17 Thread Ulrich Weigand via cfe-commits
Author: uweigand
Date: Mon Jul 17 10:46:47 2017
New Revision: 308198

URL: http://llvm.org/viewvc/llvm-project?rev=308198&view=rev
Log:
[SystemZ] Add support for IBM z14 processor (2/3)

This patch extends the -fzvector language feature to enable the new
"vector float" data type when compiling at -march=z14.  This matches
the updated extension definition implemented by other compilers for
the platform, which is indicated to applications by pre-defining
__VEC__ to 10302 (instead of 10301).


Added:
cfe/trunk/test/CodeGen/zvector2.c
cfe/trunk/test/Sema/zvector2.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=308198&r1=308197&r2=308198&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Jul 17 10:46:47 2017
@@ -7476,7 +7476,7 @@ public:
 if (HasVector)
   Builder.defineMacro("__VX__");
 if (Opts.ZVector)
-  Builder.defineMacro("__VEC__", "10301");
+  Builder.defineMacro("__VEC__", "10302");
   }
   ArrayRef getTargetBuiltins() const override {
 return llvm::makeArrayRef(BuiltinInfo,

Modified: cfe/trunk/lib/Sema/DeclSpec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=308198&r1=308197&r2=308198&view=diff
==
--- cfe/trunk/lib/Sema/DeclSpec.cpp (original)
+++ cfe/trunk/lib/Sema/DeclSpec.cpp Mon Jul 17 10:46:47 2017
@@ -1082,8 +1082,10 @@ void DeclSpec::Finish(Sema &S, const Pri
!S.getLangOpts().ZVector)
 S.Diag(TSTLoc, diag::err_invalid_vector_double_decl_spec);
 } else if (TypeSpecType == TST_float) {
-  // vector float is unsupported for ZVector.
-  if (S.getLangOpts().ZVector)
+  // vector float is unsupported for ZVector unless we have the
+  // vector-enhancements facility 1 (ISA revision 12).
+  if (S.getLangOpts().ZVector &&
+  !S.Context.getTargetInfo().hasFeature("arch12"))
 S.Diag(TSTLoc, diag::err_invalid_vector_float_decl_spec);
 } else if (TypeSpecWidth == TSW_long) {
   // vector long is unsupported for ZVector and deprecated for AltiVec.

Added: cfe/trunk/test/CodeGen/zvector2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/zvector2.c?rev=308198&view=auto
==
--- cfe/trunk/test/CodeGen/zvector2.c (added)
+++ cfe/trunk/test/CodeGen/zvector2.c Mon Jul 17 10:46:47 2017
@@ -0,0 +1,194 @@
+// RUN: %clang_cc1 -triple s390x-linux-gnu -target-cpu z14 -fzvector \
+// RUN:  -O -emit-llvm -o - -W -Wall -Werror %s | FileCheck %s
+
+volatile vector float ff, ff2;
+volatile vector bool int bi;
+
+void test_assign (void)
+{
+// CHECK-LABEL: test_assign
+// CHECK: [[VAL:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: store volatile <4 x float> [[VAL]], <4 x float>* @ff
+  ff = ff2;
+}
+
+void test_pos (void)
+{
+// CHECK-LABEL: test_pos
+// CHECK: [[VAL:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: store volatile <4 x float> [[VAL]], <4 x float>* @ff
+  ff = +ff2;
+}
+
+void test_neg (void)
+{
+// CHECK-LABEL: test_neg
+// CHECK: [[VAL:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: %{{.*}} = fsub <4 x float> , [[VAL]]
+  ff = -ff2;
+}
+
+void test_preinc (void)
+{
+// CHECK-LABEL: test_preinc
+// CHECK: [[VAL:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: %{{.*}} = fadd <4 x float> [[VAL]], 
+  ++ff2;
+}
+
+void test_postinc (void)
+{
+// CHECK-LABEL: test_postinc
+// CHECK: [[VAL:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: %{{.*}} = fadd <4 x float> [[VAL]], 
+  ff2++;
+}
+
+void test_predec (void)
+{
+// CHECK-LABEL: test_predec
+// CHECK: [[VAL:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: %{{.*}} = fadd <4 x float> [[VAL]], 
+  --ff2;
+}
+
+void test_postdec (void)
+{
+// CHECK-LABEL: test_postdec
+// CHECK: [[VAL:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: %{{.*}} = fadd <4 x float> [[VAL]], 
+  ff2--;
+}
+
+void test_add (void)
+{
+// CHECK-LABEL: test_add
+// CHECK: [[VAL1:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff
+// CHECK: [[VAL2:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: %{{.*}} = fadd <4 x float> [[VAL1]], [[VAL2]]
+  ff = ff + ff2;
+}
+
+void test_add_assign (void)
+{
+// CHECK-LABEL: test_add_assign
+// CHECK: [[VAL2:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: [[VAL1:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff
+// CHECK: %{{.*}} = fadd <4 x float> [[VAL2]], [[VAL1]]
+  ff += ff2;
+}
+
+void test_sub (void)
+{
+// CHECK-LABEL: test_sub
+// CHECK: [[VAL1

Re: [PATCH v3] [PPC64]: Add support for Swift calling convention

2017-07-24 Thread Ulrich Weigand via cfe-commits

Andrew Jeffery  wrote on 24.07.2017 03:54:05:

> > > > +  bool shouldPassIndirectlyForSwift(CharUnits totalSize,
> > > > +ArrayRef scalars,
> > > > +bool asReturnValue)
constoverride {
> > > > +return occupiesMoreThan(CGT, scalars, /*total*/ 4);
> >
> > I don't know much about Swift; the code changes seem reasonable. One
> > question I have is: from where does this number 4 come? Is there some
> > corresponding patch to Swift that this matches?
>
> As far as I'm aware a patch to Swift is not necessary, rather 4 comes
> from Ulrich's '[PowerPC] Support multiple return values with fast isel'
> patch[1] which allows up to 4 values to be returned in registers.
>
> To give some confidence, with this patch Swift builds and the tests
> pass for PPC64 on PPC64. Looking at the other implementations of
> shouldPassIndirectlyForSwift() none of them seem to have behaviour
> dependent on asReturnValue, however must say I'm not certain about the
> false (argument) case. Maybe Ulrich can provide some insight?

That LLVM back-end patch simply *allows* front-ends to return integers
in up to 4 registers.  (I did this because Anton Blanchard pointed out
in PR 26190 that Swift at that time wanted to return three values in
registers.)  The choice of 4 here is somewhat arbitrary, and the back-
end could as well be changed to allow using up to 8 registers; in fact,
this would even be more logical since it would allow using any of the
argument registers also as return register.

But this has really nothing to do with how Swift choses to *use* this.
Which and how many values Swift wants to return in registers is in
the end a choice to be made by the front-end.  Ideally, there should
be an ABI document specifying the Swift ABI for each platform.  I
don't really know what Swift is trying to do here; in particular, I
do not know whether Swift is attempting to be compatible with some
other ABI to allow interoperability, or whether this is a completely
private choice.  So I cannot really say whether 4 is "correct" here.

Bye,
Ulrich
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r322562 - [SystemZ] Support vector registers with inline asm

2018-01-16 Thread Ulrich Weigand via cfe-commits
Author: uweigand
Date: Tue Jan 16 07:39:23 2018
New Revision: 322562

URL: http://llvm.org/viewvc/llvm-project?rev=322562&view=rev
Log:
[SystemZ] Support vector registers with inline asm

Allow using vector register names and the "v" constraint
in inline asm to ensure compatibility with GCC.


Modified:
cfe/trunk/lib/Basic/Targets/SystemZ.cpp
cfe/trunk/lib/Basic/Targets/SystemZ.h

Modified: cfe/trunk/lib/Basic/Targets/SystemZ.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/SystemZ.cpp?rev=322562&r1=322561&r2=322562&view=diff
==
--- cfe/trunk/lib/Basic/Targets/SystemZ.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/SystemZ.cpp Tue Jan 16 07:39:23 2018
@@ -30,15 +30,30 @@ const Builtin::Info SystemZTargetInfo::B
 };
 
 const char *const SystemZTargetInfo::GCCRegNames[] = {
-"r0",  "r1",  "r2",  "r3",  "r4",  "r5",  "r6", "r7",  "r8",  "r9", "r10",
-"r11", "r12", "r13", "r14", "r15", "f0",  "f2", "f4",  "f6",  "f1", "f3",
-"f5",  "f7",  "f8",  "f10", "f12", "f14", "f9", "f11", "f13", "f15"
+"r0",  "r1",  "r2",  "r3",  "r4",  "r5",  "r6",  "r7",
+"r8",  "r9",  "r10", "r11", "r12", "r13", "r14", "r15",
+"f0",  "f2",  "f4",  "f6",  "f1",  "f3",  "f5",  "f7",
+"f8",  "f10", "f12", "f14", "f9",  "f11", "f13", "f15",
+/*ap*/"", "cc", /*fp*/"", /*rp*/"", "a0",  "a1",
+"v16", "v18", "v20", "v22", "v17", "v19", "v21", "v23",
+"v24", "v26", "v28", "v30", "v25", "v27", "v29", "v31"
+};
+
+const TargetInfo::AddlRegName GCCAddlRegNames[] = {
+{{"v0"}, 16}, {{"v2"},  17}, {{"v4"},  18}, {{"v6"},  19},
+{{"v1"}, 20}, {{"v3"},  21}, {{"v5"},  22}, {{"v7"},  23},
+{{"v8"}, 24}, {{"v10"}, 25}, {{"v12"}, 26}, {{"v14"}, 27},
+{{"v9"}, 28}, {{"v11"}, 29}, {{"v13"}, 30}, {{"v15"}, 31}
 };
 
 ArrayRef SystemZTargetInfo::getGCCRegNames() const {
   return llvm::makeArrayRef(GCCRegNames);
 }
 
+ArrayRef SystemZTargetInfo::getGCCAddlRegNames() 
const {
+  return llvm::makeArrayRef(GCCAddlRegNames);
+}
+
 bool SystemZTargetInfo::validateAsmConstraint(
 const char *&Name, TargetInfo::ConstraintInfo &Info) const {
   switch (*Name) {
@@ -48,6 +63,7 @@ bool SystemZTargetInfo::validateAsmConst
   case 'a': // Address register
   case 'd': // Data register (equivalent to 'r')
   case 'f': // Floating-point register
+  case 'v': // Vector register
 Info.setAllowsRegister();
 return true;
 

Modified: cfe/trunk/lib/Basic/Targets/SystemZ.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/SystemZ.h?rev=322562&r1=322561&r2=322562&view=diff
==
--- cfe/trunk/lib/Basic/Targets/SystemZ.h (original)
+++ cfe/trunk/lib/Basic/Targets/SystemZ.h Tue Jan 16 07:39:23 2018
@@ -62,6 +62,8 @@ public:
 return None;
   }
 
+  ArrayRef getGCCAddlRegNames() const override;
+
   bool validateAsmConstraint(const char *&Name,
  TargetInfo::ConstraintInfo &info) const override;
 


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


r285578 - [SystemZ] Add -march=archX aliases

2016-10-31 Thread Ulrich Weigand via cfe-commits
Author: uweigand
Date: Mon Oct 31 09:38:05 2016
New Revision: 285578

URL: http://llvm.org/viewvc/llvm-project?rev=285578&view=rev
Log:
[SystemZ] Add -march=archX aliases

For compatibility with other compilers on the platform, allow specifying
levels of the z/Architecture instead of model names with -march.  In
particular, the following aliases are now supported:

  -march=arch8   equals  -march=z10
  -march=arch9   equals  -march=z196
  -march=arch10  equals  -march=zEC12
  -march=arch11  equals  -march=z13

This parallels the equivalent (and prerequisite) LLVM change in r285577.


Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/CodeGen/systemz-abi-vector.c
cfe/trunk/test/CodeGen/systemz-abi.c
cfe/trunk/test/CodeGen/target-data.c
cfe/trunk/test/Driver/systemz-march.c
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=285578&r1=285577&r2=285578&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Oct 31 09:38:05 2016
@@ -6941,9 +6941,13 @@ public:
 CPU = Name;
 bool CPUKnown = llvm::StringSwitch(Name)
   .Case("z10", true)
+  .Case("arch8", true)
   .Case("z196", true)
+  .Case("arch9", true)
   .Case("zEC12", true)
+  .Case("arch10", true)
   .Case("z13", true)
+  .Case("arch11", true)
   .Default(false);
 
 return CPUKnown;
@@ -6952,9 +6956,9 @@ public:
   initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine &Diags,
  StringRef CPU,
  const std::vector &FeaturesVec) const override {
-if (CPU == "zEC12")
+if (CPU == "zEC12" || CPU == "arch10")
   Features["transactional-execution"] = true;
-if (CPU == "z13") {
+if (CPU == "z13" || CPU == "arch11") {
   Features["transactional-execution"] = true;
   Features["vector"] = true;
 }

Modified: cfe/trunk/test/CodeGen/systemz-abi-vector.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/systemz-abi-vector.c?rev=285578&r1=285577&r2=285578&view=diff
==
--- cfe/trunk/test/CodeGen/systemz-abi-vector.c (original)
+++ cfe/trunk/test/CodeGen/systemz-abi-vector.c Mon Oct 31 09:38:05 2016
@@ -4,6 +4,8 @@
 // RUN:   -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-VECTOR %s
 // RUN: %clang_cc1 -triple s390x-linux-gnu -target-cpu z13 \
 // RUN:   -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-VECTOR %s
+// RUN: %clang_cc1 -triple s390x-linux-gnu -target-cpu arch11 \
+// RUN:   -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-VECTOR %s
 
 // Vector types
 

Modified: cfe/trunk/test/CodeGen/systemz-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/systemz-abi.c?rev=285578&r1=285577&r2=285578&view=diff
==
--- cfe/trunk/test/CodeGen/systemz-abi.c (original)
+++ cfe/trunk/test/CodeGen/systemz-abi.c Mon Oct 31 09:38:05 2016
@@ -4,6 +4,8 @@
 // RUN:   -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple s390x-linux-gnu -target-cpu z13 \
 // RUN:   -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple s390x-linux-gnu -target-cpu arch11 \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
 
 // Scalar types
 

Modified: cfe/trunk/test/CodeGen/target-data.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-data.c?rev=285578&r1=285577&r2=285578&view=diff
==
--- cfe/trunk/test/CodeGen/target-data.c (original)
+++ cfe/trunk/test/CodeGen/target-data.c Mon Oct 31 09:38:05 2016
@@ -169,6 +169,8 @@
 
 // RUN: %clang_cc1 -triple s390x-unknown -target-cpu z13 -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=SYSTEMZ-VECTOR
+// RUN: %clang_cc1 -triple s390x-unknown -target-cpu arch11 -o - -emit-llvm %s 
| \
+// RUN: FileCheck %s -check-prefix=SYSTEMZ-VECTOR
 // SYSTEMZ-VECTOR: target datalayout = 
"E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64"
 
 // RUN: %clang_cc1 -triple msp430-unknown -o - -emit-llvm %s | \

Modified: cfe/trunk/test/Driver/systemz-march.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/systemz-march.c?rev=285578&r1=285577&r2=285578&view=diff
==
--- cfe/trunk/test/Driver/systemz-march.c (original)
+++ cfe/trunk/test/Driver/systemz-march.c Mon Oct 31 09:38:05 2016
@@ -2,12 +2,22 @@
 
 // RUN: not %clang -target s390x -S -emit-llvm -march=z9 %s -o - 2>&1 | 
FileCheck --check-prefix=CHECK-Z9 %s
 // RUN: %clang -target s390x -### -S -emit-llvm -march=z10 %s 2>&1 | FileCheck 
--check-prefix=CHECK-Z10 %s
+// RUN: %clang -target s390x -### -S -emit-llvm -march=arch8 %s 2>&1

Re: r259183 - Add target triple to CodeGenOpenCL/pipe_types.cl test case

2016-02-04 Thread Ulrich Weigand via cfe-commits


Hans,

would it be OK to backport this test case fix to the 3.8 branch?
This is currently the only failing test on the branch for SystemZ.

Thanks!

>Author: uweigand
>Date: Fri Jan 29 04:45:23 2016
>New Revision: 259183
>
>URL: http://llvm.org/viewvc/llvm-project?rev=259183&view=rev
>Log:
>Add target triple to CodeGenOpenCL/pipe_types.cl test case
>
>The test is failing on SystemZ since different IR is being
>generated due to platform ABI differences.  Add a target triple.
>
>Fix suggested by Anastasia Stulova.
>
>
>Modified:
>cfe/trunk/test/CodeGenOpenCL/pipe_types.cl


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand | Phone: +49-7031/16-3727
  STSM, GNU/Linux compilers and toolchain
  IBM Deutschland Research & Development GmbH
  Vorsitzende des Aufsichtsrats: Martina Koederitz | Geschäftsführung: Dirk
Wittkopp
  Sitz der Gesellschaft: Böblingen | Registergericht: Amtsgericht
Stuttgart, HRB 243294
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r259931 - [SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

2016-02-05 Thread Ulrich Weigand via cfe-commits
Author: uweigand
Date: Fri Feb  5 15:34:28 2016
New Revision: 259931

URL: http://llvm.org/viewvc/llvm-project?rev=259931&view=rev
Log:
[SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_[1248] macros on SystemZ.

This fixes a miscompile of GCC C++11 standard library headers
due to use of those macros in an ABI-changing manner.

See e.g. /usr/include/c++/4.8.5/ext/concurrence.h:

  // Compile time constant that indicates prefered locking policy in
  // the current configuration.
  static const _Lock_policy __default_lock_policy =
#ifdef __GTHREADS
#if (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) \
 && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4))
  _S_atomic;
#else
  _S_mutex;
#endif
#else
  _S_single;
#endif

A different choice of __default_lock_policy causes different
sizes of several of the C++11 data structures, which are then
incompatible when inlined in clang-compiled code with what the
(GCC-compiled) external library expects.

This in turn leads to various crashes when using std::thread
in code compiled with clang, as see e.g. via the ThreadPool
unit tests.  See PR 26473 for an example.


Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=259931&r1=259930&r2=259931&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Feb  5 15:34:28 2016
@@ -6166,6 +6166,12 @@ public:
 Builder.defineMacro("__s390x__");
 Builder.defineMacro("__zarch__");
 Builder.defineMacro("__LONG_DOUBLE_128__");
+
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
+
 if (HasTransactionalExecution)
   Builder.defineMacro("__HTM__");
 if (Opts.ZVector)

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=259931&r1=259930&r2=259931&view=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Fri Feb  5 15:34:28 
2016
@@ -1787,6 +1787,10 @@
 // RUN: -target s390x-unknown-linux \
 // RUN:   | FileCheck %s -check-prefix=CHECK_SYSTEMZ_Z10
 //
+// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
+// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
+// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
 // CHECK_SYSTEMZ_Z10: #define __LONG_DOUBLE_128__ 1
 // CHECK_SYSTEMZ_Z10: #define __s390__ 1
 // CHECK_SYSTEMZ_Z10: #define __s390x__ 1
@@ -1796,6 +1800,10 @@
 // RUN: -target s390x-unknown-linux \
 // RUN:   | FileCheck %s -check-prefix=CHECK_SYSTEMZ_ZEC12
 //
+// CHECK_SYSTEMZ_ZEC12: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
+// CHECK_SYSTEMZ_ZEC12: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
+// CHECK_SYSTEMZ_ZEC12: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+// CHECK_SYSTEMZ_ZEC12: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
 // CHECK_SYSTEMZ_ZEC12: #define __HTM__ 1
 // CHECK_SYSTEMZ_ZEC12: #define __LONG_DOUBLE_128__ 1
 // CHECK_SYSTEMZ_ZEC12: #define __s390__ 1


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


Re: r259931 - [SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

2016-02-05 Thread Ulrich Weigand via cfe-commits


Hans,

this is one more patch that should go into 3.8  --  it fixes miscompiles of
code using GCC-provided C++11 system headers like .

With this patch, the test suite is now clean also with a bootstrapped
clang.

>Author: uweigand
>Date: Fri Feb  5 15:34:28 2016
>New Revision: 259931
>
>URL: http://llvm.org/viewvc/llvm-project?rev=259931&view=rev
>Log: [SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros
>
>Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_[1248] macros on SystemZ.
>
>This fixes a miscompile of GCC C++11 standard library headers
>due to use of those macros in an ABI-changing manner.
>
>See e.g. /usr/include/c++/4.8.5/ext/concurrence.h:
>
>  // Compile time constant that indicates prefered locking policy in
>  // the current configuration.
>  static const _Lock_policy __default_lock_policy =
>#ifdef __GTHREADS
>#if (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) \
> && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4))
>  _S_atomic;
>#else
>  _S_mutex;
>#endif
>#else
>  _S_single;
>#endif
>
>A different choice of __default_lock_policy causes different
>sizes of several of the C++11 data structures, which are then
>incompatible when inlined in clang-compiled code with what the
>(GCC-compiled) external library expects.
>
>This in turn leads to various crashes when using std::thread
>in code compiled with clang, as see e.g. via the ThreadPool
>unit tests.  See PR 26473 for an example.
>
>
>Modified:
>cfe/trunk/lib/Basic/Targets.cpp
>cfe/trunk/test/Preprocessor/predefined-arch-macros.c


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand | Phone: +49-7031/16-3727
  STSM, GNU/Linux compilers and toolchain
  IBM Deutschland Research & Development GmbH
  Vorsitzende des Aufsichtsrats: Martina Koederitz | Geschäftsführung: Dirk
Wittkopp
  Sitz der Gesellschaft: Böblingen | Registergericht: Amtsgericht
Stuttgart, HRB 243294
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r259931 - [SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

2016-02-08 Thread Ulrich Weigand via cfe-commits
Hal Finkel  wrote on 05.02.2016 23:14:54:

> Just a general comment: I believe we've now fixed this bug for at
> least four different architectures (each time as a separate effort).

Yes.  Unfortunately I only noticed that after I'd already spent half
a day debugging the problem from scratch on System Z :-/

> Is there some kind of auditing we could do to make sure we don't run
> into this again?

Well, on GCC common code automatically predefines the macro if and
only if the back end actually implements the corresponding builtin
without an external function call.   We cannot really do that in LLVM
due to the stronger separation between front end and back end here.

However, I guess we could at least provide a *test case* that verifies
that front end and back end make the same choice.  This would have to
be a test case that runs a full compile (from un-preprocessed source
straight through to assembler output) so we can verify the interaction
of front end and back end, which I guess is frowned upon these days ...

The following example implements one idea I came up with:
(See attached file: atomic-predefines.c)

It is neither perfectly complete (it only checks the current target,
not all; and it doesn't check any variants of the current target,
e.g. different CPU types), nor is it perfectly safe (some targets
could theoretically emit weird code to implement a function call
that would throw off the heuristics in this test).

In addition, I noticed when running it against some of the more
obscure targets like Hexagon, the test actually triggers internal
errors in the back end, so those probably ought to be fixed first.

Any suggestions to improve this test welcome!


Bye,
Ulrich


atomic-predefines.c
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r259931 - [SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

2016-02-09 Thread Ulrich Weigand via cfe-commits
Hal Finkel  wrote on 09.02.2016 04:59:21:

> We generally notice this when we try to use some part of the C++
> standard library (std::atomic or std::thread as I recall). Could we
> have something in the test-suite that uses that functionality in a
> way likely to expose this bug?

Well, when I looked into it, the problem was already in the
std::thread constructor, which sets up a data structure incorrectly
so that the new thread immediately crashes on startup.

I guess any application that uses C++11 threads should show this
problem immediately.

Bye,
Ulrich
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r259931 - [SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

2016-02-15 Thread Ulrich Weigand via cfe-commits
Hal Finkel  wrote on 09.02.2016 18:16:21:

> > I guess any application that uses C++11 threads should show this
> > problem immediately.
>
> I'm not sure we have anything like that in our test suite. Could you
> add a simple test?

Hmm, it looks like Nemanja already added this:

SingleSource/UnitTests/C++11/stdthreadbug.cpp

But the test is restricted to run only on ppc64le:

#if defined(_LITTLE_ENDIAN) && defined(__PPC64__)
...

I think there's no particular reason for that restriction.
Do you think we should just enable it on all platforms?

Bye,
Ulrich
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r259931 - [SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

2016-02-15 Thread Ulrich Weigand via cfe-commits
Hal Finkel  wrote on 15.02.2016 16:30:15:

> > Hmm, it looks like Nemanja already added this:
> >
> > SingleSource/UnitTests/C++11/ stdthreadbug.cpp
> >
> > But the test is restricted to run only on ppc64le:
> >
> > #if defined(_LITTLE_ENDIAN) && defined(__PPC64__)
> > ...
> >
> > I think there's no particular reason for that restriction.
> > Do you think we should just enable it on all platforms?
>
> Yes, certainly. Sometimes we need to blacklist some tests for some
> platforms, but only fundamentally-platform-specific tests should be
> white listed like this.

OK, I've checked this in as rev. 260894.

Bye,
Ulrich
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17142: SystemZ: Check that argument -fzvector is only given for -z13

2016-02-15 Thread Ulrich Weigand via cfe-commits
uweigand added a subscriber: uweigand.
uweigand added a comment.

I'm not sure this is the right approach.  In any case, it differs from how the 
option is handled in GCC.

-mzvector enables the language *syntax* extension, i.e. allows use of the 
"vector unsigned int" etc. data types.  Note that this is simply syntactic 
sugar, the same vector types can *always* be enabled using the 
attribute((vector_size)) extension instead.

Therefore, GCC allows -mzvector to be always used, even when using a -march= 
setting that does not include z13 vector operations.   In the latter case, the 
operations on vector types are simply implemented via scalar operations, just 
like what happens when you use attribute((vector_size)) without hardware vector 
support.

However, there is one hitch: most of the vector *built-ins* cannot be supported 
without hardware vector support.  But I guess the correct fix for that problem 
is to disable those built-ins, not to disable all of -mzvector.


http://reviews.llvm.org/D17142



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


Re: [PATCH] D19432: [SystemZ] Support Swift calling convention

2016-04-27 Thread Ulrich Weigand via cfe-commits
uweigand accepted this revision.
uweigand added a comment.
This revision is now accepted and ready to land.

LGTM.


http://reviews.llvm.org/D19432



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


Re: [PATCH] D19891: [clang] [SystemZ] Add -mbackchain option.

2016-05-04 Thread Ulrich Weigand via cfe-commits
uweigand accepted this revision.
uweigand added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rL LLVM

http://reviews.llvm.org/D19891



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


  1   2   3   4   >