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<Builtin::Info> 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> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, [[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]], <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00> + ++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]], <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00> + 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]], <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00> + --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]], <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00> + 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:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff +// CHECK: [[VAL2:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2 +// CHECK: %{{.*}} = fsub <4 x float> [[VAL1]], [[VAL2]] + ff = ff - ff2; +} + +void test_sub_assign (void) +{ +// CHECK-LABEL: test_sub_assign +// CHECK: [[VAL2:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2 +// CHECK: [[VAL1:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff +// CHECK: %{{.*}} = fsub <4 x float> [[VAL1]], [[VAL2]] + ff -= ff2; +} + +void test_mul (void) +{ +// CHECK-LABEL: test_mul +// CHECK: [[VAL1:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff +// CHECK: [[VAL2:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2 +// CHECK: %{{.*}} = fmul <4 x float> [[VAL1]], [[VAL2]] + ff = ff * ff2; +} + +void test_mul_assign (void) +{ +// CHECK-LABEL: test_mul_assign +// CHECK: [[VAL2:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2 +// CHECK: [[VAL1:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff +// CHECK: %{{.*}} = fmul <4 x float> [[VAL2]], [[VAL1]] + ff *= ff2; +} + +void test_div (void) +{ +// CHECK-LABEL: test_div +// CHECK: [[VAL1:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff +// CHECK: [[VAL2:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2 +// CHECK: %{{.*}} = fdiv <4 x float> [[VAL1]], [[VAL2]] + ff = ff / ff2; +} + +void test_div_assign (void) +{ +// CHECK-LABEL: test_div_assign +// CHECK: [[VAL2:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2 +// CHECK: [[VAL1:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff +// CHECK: %{{.*}} = fdiv <4 x float> [[VAL1]], [[VAL2]] + ff /= ff2; +} + +void test_cmpeq (void) +{ +// CHECK-LABEL: test_cmpeq +// CHECK: [[VAL1:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff +// CHECK: [[VAL2:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2 +// CHECK: [[CMP:%[^ ]+]] = fcmp oeq <4 x float> [[VAL1]], [[VAL2]] +// CHECK: %{{.*}} = sext <4 x i1> [[CMP]] to <4 x i32> + bi = ff == ff2; +} + +void test_cmpne (void) +{ +// CHECK-LABEL: test_cmpne +// CHECK: [[VAL1:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff +// CHECK: [[VAL2:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2 +// CHECK: [[CMP:%[^ ]+]] = fcmp une <4 x float> [[VAL1]], [[VAL2]] +// CHECK: %{{.*}} = sext <4 x i1> [[CMP]] to <4 x i32> + bi = ff != ff2; +} + +void test_cmpge (void) +{ +// CHECK-LABEL: test_cmpge +// CHECK: [[VAL1:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff +// CHECK: [[VAL2:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2 +// CHECK: [[CMP:%[^ ]+]] = fcmp oge <4 x float> [[VAL1]], [[VAL2]] +// CHECK: %{{.*}} = sext <4 x i1> [[CMP]] to <4 x i32> + bi = ff >= ff2; +} + +void test_cmpgt (void) +{ +// CHECK-LABEL: test_cmpgt +// CHECK: [[VAL1:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff +// CHECK: [[VAL2:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2 +// CHECK: [[CMP:%[^ ]+]] = fcmp ogt <4 x float> [[VAL1]], [[VAL2]] +// CHECK: %{{.*}} = sext <4 x i1> [[CMP]] to <4 x i32> + bi = ff > ff2; +} + +void test_cmple (void) +{ +// CHECK-LABEL: test_cmple +// CHECK: [[VAL1:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff +// CHECK: [[VAL2:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2 +// CHECK: [[CMP:%[^ ]+]] = fcmp ole <4 x float> [[VAL1]], [[VAL2]] +// CHECK: %{{.*}} = sext <4 x i1> [[CMP]] to <4 x i32> + bi = ff <= ff2; +} + +void test_cmplt (void) +{ +// CHECK-LABEL: test_cmplt +// CHECK: [[VAL1:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff +// CHECK: [[VAL2:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2 +// CHECK: [[CMP:%[^ ]+]] = fcmp olt <4 x float> [[VAL1]], [[VAL2]] +// CHECK: %{{.*}} = sext <4 x i1> [[CMP]] to <4 x i32> + bi = ff < ff2; +} + 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=308198&r1=308197&r2=308198&view=diff ============================================================================== --- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original) +++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Mon Jul 17 10:46:47 2017 @@ -2275,7 +2275,7 @@ // RUN: -target s390x-unknown-linux \ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ZVECTOR // -// CHECK_SYSTEMZ_ZVECTOR: #define __VEC__ 10301 +// CHECK_SYSTEMZ_ZVECTOR: #define __VEC__ 10302 // Begin amdgcn tests ---------------- // Added: cfe/trunk/test/Sema/zvector2.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/zvector2.c?rev=308198&view=auto ============================================================================== --- cfe/trunk/test/Sema/zvector2.c (added) +++ cfe/trunk/test/Sema/zvector2.c Mon Jul 17 10:46:47 2017 @@ -0,0 +1,211 @@ +// RUN: %clang_cc1 -triple s390x-linux-gnu -fzvector -target-cpu z14 \ +// RUN: -fno-lax-vector-conversions -W -Wall -Wconversion \ +// RUN: -Werror -fsyntax-only -verify %s + +vector signed char sc, sc2; +vector unsigned char uc, uc2; +vector bool char bc, bc2; + +vector signed short ss, ss2; +vector unsigned short us, us2; +vector bool short bs, bs2; + +vector signed int si, si2; +vector unsigned int ui, ui2; +vector bool int bi, bi2; + +vector signed long long sl, sl2; +vector unsigned long long ul, ul2; +vector bool long long bl, bl2; + +vector double fd, fd2; + +vector float ff, ff2; + +void foo(void) +{ + // ------------------------------------------------------------------------- + // Test assignment. + // ------------------------------------------------------------------------- + + ff = ff2; + + sc = ff2; // expected-error {{incompatible type}} + ff = sc2; // expected-error {{incompatible type}} + + uc = ff2; // expected-error {{incompatible type}} + ff = uc2; // expected-error {{incompatible type}} + + bc = ff2; // expected-error {{incompatible type}} + ff = bc2; // expected-error {{incompatible type}} + + fd = ff2; // expected-error {{incompatible type}} + ff = fd2; // expected-error {{incompatible type}} + + // ------------------------------------------------------------------------- + // Test casts to same element width. + // ------------------------------------------------------------------------- + + ui = (vector unsigned int)ff2; + ff = (vector float)si2; + + // ------------------------------------------------------------------------- + // Test casts to different element width. + // ------------------------------------------------------------------------- + + uc = (vector unsigned char)ff2; + us = (vector unsigned short)ff2; + ul = (vector unsigned long long)ff2; + + ff = (vector float)sc2; + ff = (vector float)ss2; + ff = (vector float)sl2; + + // ------------------------------------------------------------------------- + // Test unary operators. + // ------------------------------------------------------------------------- + + ++ff2; + ff++; + + --ff2; + ff--; + + ff = +ff2; + + ff = -ff2; + + ff = ~ff2; // expected-error {{invalid argument}} + + // ------------------------------------------------------------------------- + // Test binary arithmetic operators. + // ------------------------------------------------------------------------- + + ff = ff + ff2; + ff = ff + ui2; // expected-error {{cannot convert}} + ff = si + ff2; // expected-error {{cannot convert}} + ff = fd + ff2; // expected-error {{cannot convert}} + ff += ff2; + ff += fd2; // expected-error {{cannot convert}} + sc += ff2; // expected-error {{cannot convert}} + + ff = ff - ff2; + ff = ff - ui2; // expected-error {{cannot convert}} + ff = si - ff2; // expected-error {{cannot convert}} + ff = fd - ff2; // expected-error {{cannot convert}} + ff -= ff2; + ff -= fd2; // expected-error {{cannot convert}} + sc -= ff2; // expected-error {{cannot convert}} + + ff = ff * ff2; + ff = ff * ui2; // expected-error {{cannot convert}} + ff = si * ff2; // expected-error {{cannot convert}} + ff = fd * ff2; // expected-error {{cannot convert}} + ff *= ff2; + ff *= fd2; // expected-error {{cannot convert}} + sc *= ff2; // expected-error {{cannot convert}} + + ff = ff / ff2; + ff = ff / ui2; // expected-error {{cannot convert}} + ff = si / ff2; // expected-error {{cannot convert}} + ff = fd / ff2; // expected-error {{cannot convert}} + ff /= ff2; + ff /= fd2; // expected-error {{cannot convert}} + sc /= ff2; // expected-error {{cannot convert}} + + ff = ff % ff2; // expected-error {{invalid operands}} + ff = ff % ui2; // expected-error {{invalid operands}} + ff = si % ff2; // expected-error {{invalid operands}} + ff = fd % ff2; // expected-error {{invalid operands}} + ff %= ff2; // expected-error {{invalid operands}} + ff %= fd2; // expected-error {{invalid operands}} + sc %= ff2; // expected-error {{invalid operands}} + + // ------------------------------------------------------------------------- + // Test bitwise binary operators. + // ------------------------------------------------------------------------- + + ff = ff & ff2; // expected-error {{invalid operands}} + ff = bi & ff2; // expected-error {{invalid operands}} + ff = fd & ff2; // expected-error {{invalid operands}} + ff = ff & bi2; // expected-error {{invalid operands}} + ff = ff & si2; // expected-error {{invalid operands}} + ff = ff & ui2; // expected-error {{invalid operands}} + sc &= ff2; // expected-error {{invalid operands}} + ff &= bc2; // expected-error {{invalid operands}} + ff &= fd2; // expected-error {{invalid operands}} + + ff = ff | ff2; // expected-error {{invalid operands}} + ff = bi | ff2; // expected-error {{invalid operands}} + ff = fd | ff2; // expected-error {{invalid operands}} + ff = ff | bi2; // expected-error {{invalid operands}} + ff = ff | si2; // expected-error {{invalid operands}} + ff = ff | ui2; // expected-error {{invalid operands}} + sc |= ff2; // expected-error {{invalid operands}} + ff |= bc2; // expected-error {{invalid operands}} + ff |= fd2; // expected-error {{invalid operands}} + + ff = ff ^ ff2; // expected-error {{invalid operands}} + ff = bi ^ ff2; // expected-error {{invalid operands}} + ff = fd ^ ff2; // expected-error {{invalid operands}} + ff = ff ^ bi2; // expected-error {{invalid operands}} + ff = ff ^ si2; // expected-error {{invalid operands}} + ff = ff ^ ui2; // expected-error {{invalid operands}} + sc ^= ff2; // expected-error {{invalid operands}} + ff ^= bc2; // expected-error {{invalid operands}} + ff ^= fd2; // expected-error {{invalid operands}} + + // ------------------------------------------------------------------------- + // Test shift operators. + // ------------------------------------------------------------------------- + + ff = ff << ff2; // expected-error {{integer is required}} + ff = ff << fd2; // expected-error {{integer is required}} + ff = ff << ui2; // expected-error {{integer is required}} + ff = sl << ff2; // expected-error {{integer is required}} + sc <<= ff2; // expected-error {{integer is required}} + ff <<= ff2; // expected-error {{integer is required}} + fd <<= ff2; // expected-error {{integer is required}} + + ff = ff >> ff2; // expected-error {{integer is required}} + ff = ff >> fd2; // expected-error {{integer is required}} + ff = ff >> ui2; // expected-error {{integer is required}} + ff = sl >> ff2; // expected-error {{integer is required}} + sc >>= ff2; // expected-error {{integer is required}} + ff >>= ff2; // expected-error {{integer is required}} + fd >>= ff2; // expected-error {{integer is required}} + + // ------------------------------------------------------------------------- + // Test comparison operators. + // ------------------------------------------------------------------------- + + (void)(ff == ff2); + (void)(ff == fd2); // expected-error {{cannot convert}} + (void)(ff == ui2); // expected-error {{cannot convert}} + (void)(ui == ff2); // expected-error {{cannot convert}} + + (void)(ff != ff2); + (void)(ff != fd2); // expected-error {{cannot convert}} + (void)(ff != ui2); // expected-error {{cannot convert}} + (void)(ui != ff2); // expected-error {{cannot convert}} + + (void)(ff <= ff2); + (void)(ff <= fd2); // expected-error {{cannot convert}} + (void)(ff <= ui2); // expected-error {{cannot convert}} + (void)(ui <= ff2); // expected-error {{cannot convert}} + + (void)(ff >= ff2); + (void)(ff >= fd2); // expected-error {{cannot convert}} + (void)(ff >= ui2); // expected-error {{cannot convert}} + (void)(ui >= ff2); // expected-error {{cannot convert}} + + (void)(ff < ff2); + (void)(ff < fd2); // expected-error {{cannot convert}} + (void)(ff < ui2); // expected-error {{cannot convert}} + (void)(ui < ff2); // expected-error {{cannot convert}} + + (void)(ff > ff2); + (void)(ff > fd2); // expected-error {{cannot convert}} + (void)(ff > ui2); // expected-error {{cannot convert}} + (void)(ui > ff2); // expected-error {{cannot convert}} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits