[PATCH] D106410: [PowerPC] Emit error for Altivec vector initializations when -faltivec-src-compat=gcc is specified
amyk marked an inline comment as done. amyk added a comment. Addressed Nemanja's comment on the commit. https://reviews.llvm.org/rG5ea6117a9e9eae49ad1295fa422266ef3832e419 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D106410/new/ https://reviews.llvm.org/D106410 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D106410: [PowerPC] Emit error for Altivec vector initializations when -faltivec-src-compat=gcc is specified
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG5ea6117a9e9e: [PowerPC] Emit error for Altivec vector initializations when -faltivec-src… (authored by amyk). Changed prior to commit: https://reviews.llvm.org/D106410?vs=360312=363086#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D106410/new/ https://reviews.llvm.org/D106410 Files: clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaCast.cpp clang/lib/Sema/SemaExpr.cpp clang/test/CodeGen/vector-bool-pixel-altivec-init-no-parentheses.c clang/test/CodeGen/vector-bool-pixel-altivec-init.c Index: clang/test/CodeGen/vector-bool-pixel-altivec-init.c === --- clang/test/CodeGen/vector-bool-pixel-altivec-init.c +++ clang/test/CodeGen/vector-bool-pixel-altivec-init.c @@ -10,6 +10,12 @@ // RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \ // RUN: -faltivec-src-compat=xl -triple powerpc64le-unknown-unknown -S \ // RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=XL +// RUN: not %clang_cc1 -target-feature +altivec -target-feature +vsx \ +// RUN: -faltivec-src-compat=gcc -triple powerpc-unknown-unknown -S \ +// RUN: -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=GCC +// RUN: not %clang_cc1 -target-feature +altivec -target-feature +vsx \ +// RUN: -faltivec-src-compat=gcc -triple powerpc64le-unknown-unknown -S \ +// RUN: -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=GCC // RUN: %clang -mcpu=pwr8 -faltivec-src-compat=mixed --target=powerpc-unknown-unknown \ // RUN: -S -emit-llvm %s -o - | FileCheck %s --check-prefix=MIXED // RUN: %clang -mcpu=pwr9 -faltivec-src-compat=mixed --target=powerpc-unknown-unknown \ @@ -18,6 +24,10 @@ // RUN: -S -emit-llvm %s -o - | FileCheck %s --check-prefix=XL // RUN: %clang -mcpu=pwr9 -faltivec-src-compat=xl --target=powerpc-unknown-unknown \ // RUN: -S -emit-llvm %s -o - | FileCheck %s --check-prefix=XL +// RUN: not %clang -mcpu=pwr8 -faltivec-src-compat=gcc --target=powerpc-unknown-unknown \ +// RUN: -S -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=GCC +// RUN: not %clang -mcpu=pwr9 -faltivec-src-compat=gcc --target=powerpc-unknown-unknown \ +// RUN: -S -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=GCC // Vector bool type vector bool char vbi8_1; @@ -41,6 +51,7 @@ vbi8_1 = (vector bool char)('a'); // MIXED: // XL: + // GCC: error: invalid conversion between vector type '__vector __bool unsigned char' (vector of 16 'unsigned char' values) and integer type 'unsigned char' of different size char c = 'c'; vbi8_2 = (vector bool char)(c); // MIXED: [[INS:%.*]] = insertelement <16 x i8> @@ -48,11 +59,13 @@ // XL: [[INS_ELT:%.*]] = insertelement <16 x i8> // XL: [[SHUFF:%.*]] = shufflevector <16 x i8> [[INS_ELT]], <16 x i8> poison, <16 x i32> zeroinitializer // XL: store <16 x i8> [[SHUFF]] + // GCC: error: invalid conversion between vector type '__vector __bool unsigned char' (vector of 16 'unsigned char' values) and integer type 'unsigned char' of different size // vector bool short initialization vbi16_1 = (vector bool short)(5); // MIXED: // XL: + // GCC: error: invalid conversion between vector type '__vector __bool unsigned short' (vector of 8 'unsigned short' values) and integer type 'unsigned short' of different size short si16 = 55; vbi16_2 = (vector bool short)(si16); // MIXED: [[INS:%.*]] = insertelement <8 x i16> @@ -60,11 +73,13 @@ // XL: [[INS_ELT:%.*]] = insertelement <8 x i16> // XL: [[SHUFF:%.*]] = shufflevector <8 x i16> [[INS_ELT]], <8 x i16> poison, <8 x i32> zeroinitializer // XL: store <8 x i16> [[SHUFF]] + // GCC: error: invalid conversion between vector type '__vector __bool unsigned short' (vector of 8 'unsigned short' values) and integer type 'unsigned short' of different size // vector bool int initialization vbi32_1 = (vector bool int)(9); // MIXED: // XL: + // GCC: error: invalid conversion between vector type '__vector __bool unsigned int' (vector of 4 'unsigned int' values) and integer type 'unsigned int' of different size int si32 = 99; vbi32_2 = (vector bool int)(si32); // MIXED: [[INS:%.*]] = insertelement <4 x i32> @@ -72,11 +87,13 @@ // XL: [[INS_ELT:%.*]] = insertelement <4 x i32> // XL: [[SHUFF:%.*]] = shufflevector <4 x i32> [[INS_ELT]], <4 x i32> poison, <4 x i32> zeroinitializer // XL: store <4 x i32> [[SHUFF]] + // GCC: error: invalid conversion between vector type '__vector __bool unsigned int' (vector of 4 'unsigned int' values) and integer type 'unsigned int' of different size // vector bool long long initialization vbi64_1 = (vector bool long long)(13); // MIXED: // XL: + // GCC: error: invalid conversion between vector type '__vector __bool unsigned long long' (vector of 2
[PATCH] D106410: [PowerPC] Emit error for Altivec vector initializations when -faltivec-src-compat=gcc is specified
nemanjai accepted this revision. nemanjai added a comment. This revision is now accepted and ready to land. Other than the naming nit, this LGTM. Comment at: clang/include/clang/Sema/Sema.h:6103 + // these vectors on gcc (an error is emitted). + bool IsAltivecCompatGCC(SourceRange R, QualType VecTy, QualType SrcTy); + I think a more appropriate name here would be something like `CheckAltivecInitFromScalar()` Since this checks whether initialization of an Altivec vector type from a scalar is allowed. The fact that it is not allowed only if we have the GCC source compat option specified isn't really the important aspect to the caller - the caller only cares if it is OK to allow an initialization of an Altivec vector from a scalar. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D106410/new/ https://reviews.llvm.org/D106410 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D106410: [PowerPC] Emit error for Altivec vector initializations when -faltivec-src-compat=gcc is specified
amyk added a comment. Ping. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D106410/new/ https://reviews.llvm.org/D106410 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D106410: [PowerPC] Emit error for Altivec vector initializations when -faltivec-src-compat=gcc is specified
amyk created this revision. amyk added reviewers: PowerPC, nemanjai, stefanp. amyk added projects: PowerPC, LLVM, clang. Herald added a subscriber: shchenz. amyk requested review of this revision. Under the `-faltivec-src-compat=gcc` option, AltiVec vector initialization should be treated as if they were compiled with gcc - which is, to emit an error when the vectors are initialized in the parenthesized or non-parenthesized manner. This patch implements this behaviour. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D106410 Files: clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaCast.cpp clang/lib/Sema/SemaExpr.cpp clang/test/CodeGen/vector-bool-pixel-altivec-init-no-parentheses.c clang/test/CodeGen/vector-bool-pixel-altivec-init.c Index: clang/test/CodeGen/vector-bool-pixel-altivec-init.c === --- clang/test/CodeGen/vector-bool-pixel-altivec-init.c +++ clang/test/CodeGen/vector-bool-pixel-altivec-init.c @@ -10,6 +10,12 @@ // RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \ // RUN: -faltivec-src-compat=xl -triple powerpc64le-unknown-unknown -S \ // RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=XL +// RUN: not %clang_cc1 -target-feature +altivec -target-feature +vsx \ +// RUN: -faltivec-src-compat=gcc -triple powerpc-unknown-unknown -S \ +// RUN: -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=GCC +// RUN: not %clang_cc1 -target-feature +altivec -target-feature +vsx \ +// RUN: -faltivec-src-compat=gcc -triple powerpc64le-unknown-unknown -S \ +// RUN: -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=GCC // RUN: %clang -mcpu=pwr8 -faltivec-src-compat=mixed --target=powerpc-unknown-unknown \ // RUN: -S -emit-llvm %s -o - | FileCheck %s --check-prefix=MIXED // RUN: %clang -mcpu=pwr9 -faltivec-src-compat=mixed --target=powerpc-unknown-unknown \ @@ -18,6 +24,10 @@ // RUN: -S -emit-llvm %s -o - | FileCheck %s --check-prefix=XL // RUN: %clang -mcpu=pwr9 -faltivec-src-compat=xl --target=powerpc-unknown-unknown \ // RUN: -S -emit-llvm %s -o - | FileCheck %s --check-prefix=XL +// RUN: not %clang -mcpu=pwr8 -faltivec-src-compat=gcc --target=powerpc-unknown-unknown \ +// RUN: -S -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=GCC +// RUN: not %clang -mcpu=pwr9 -faltivec-src-compat=gcc --target=powerpc-unknown-unknown \ +// RUN: -S -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=GCC // Vector bool type vector bool char vbi8_1; @@ -41,6 +51,7 @@ vbi8_1 = (vector bool char)('a'); // MIXED: // XL: + // GCC: error: invalid conversion between vector type '__vector __bool unsigned char' (vector of 16 'unsigned char' values) and integer type 'unsigned char' of different size char c = 'c'; vbi8_2 = (vector bool char)(c); // MIXED: [[INS:%.*]] = insertelement <16 x i8> @@ -48,11 +59,13 @@ // XL: [[INS_ELT:%.*]] = insertelement <16 x i8> // XL: [[SHUFF:%.*]] = shufflevector <16 x i8> [[INS_ELT]], <16 x i8> poison, <16 x i32> zeroinitializer // XL: store <16 x i8> [[SHUFF]] + // GCC: error: invalid conversion between vector type '__vector __bool unsigned char' (vector of 16 'unsigned char' values) and integer type 'unsigned char' of different size // vector bool short initialization vbi16_1 = (vector bool short)(5); // MIXED: // XL: + // GCC: error: invalid conversion between vector type '__vector __bool unsigned short' (vector of 8 'unsigned short' values) and integer type 'unsigned short' of different size short si16 = 55; vbi16_2 = (vector bool short)(si16); // MIXED: [[INS:%.*]] = insertelement <8 x i16> @@ -60,11 +73,13 @@ // XL: [[INS_ELT:%.*]] = insertelement <8 x i16> // XL: [[SHUFF:%.*]] = shufflevector <8 x i16> [[INS_ELT]], <8 x i16> poison, <8 x i32> zeroinitializer // XL: store <8 x i16> [[SHUFF]] + // GCC: error: invalid conversion between vector type '__vector __bool unsigned short' (vector of 8 'unsigned short' values) and integer type 'unsigned short' of different size // vector bool int initialization vbi32_1 = (vector bool int)(9); // MIXED: // XL: + // GCC: error: invalid conversion between vector type '__vector __bool unsigned int' (vector of 4 'unsigned int' values) and integer type 'unsigned int' of different size int si32 = 99; vbi32_2 = (vector bool int)(si32); // MIXED: [[INS:%.*]] = insertelement <4 x i32> @@ -72,11 +87,13 @@ // XL: [[INS_ELT:%.*]] = insertelement <4 x i32> // XL: [[SHUFF:%.*]] = shufflevector <4 x i32> [[INS_ELT]], <4 x i32> poison, <4 x i32> zeroinitializer // XL: store <4 x i32> [[SHUFF]] + // GCC: error: invalid conversion between vector type '__vector __bool unsigned int' (vector of 4 'unsigned int' values) and integer type 'unsigned int' of different size // vector bool long long initialization vbi64_1 = (vector bool long long)(13); // MIXED: // XL: + // GCC: error: invalid conversion