1 // REQUIRES: powerpc-registered-target
2 
3 // RUN: %clang_cc1 -target-feature +altivec -target-feature +power9-vector \
4 // RUN:   -triple powerpc64-unknown-unknown -fsyntax-only   \
5 // RUN: -flax-vector-conversions=integer \
6 // RUN: -Wall -Werror -verify %s
7 
8 // RUN: %clang_cc1 -target-feature +altivec -target-feature +power9-vector  \
9 // RUN: -triple powerpc64le-unknown-unknown -fsyntax-only    \
10 // RUN: -flax-vector-conversions=integer \
11 // RUN: -Wall -Werror -verify %s
12 
13 // FIXME: Fix <altivec.h> so this test also passes under
14 // -flax-vector-conversions=none (this last test exists to produce an error if
15 // we change the default to that without fixing <altivec.h>).
16 // RUN: %clang_cc1 -target-feature +altivec -target-feature +power9-vector \
17 // RUN:   -triple powerpc64-unknown-unknown -fsyntax-only   \
18 // RUN: -Wall -Werror -verify %s
19 
20 #include <altivec.h>
21 
22 extern vector signed int vsi;
23 extern vector signed int vui;
24 extern vector float vf;
25 extern vector unsigned char vuc;
26 extern vector signed __int128 vsllli;
27 
28 void testInsertWord(void) {
29   int index = 5;
30   vector unsigned char v1 = vec_insert4b(vsi, vuc, index); // expected-error {{argument to '__builtin_vsx_insertword' must be a constant integer}}
31   vector unsigned long long v2 = vec_extract4b(vuc, index);   // expected-error {{argument to '__builtin_vsx_extractuword' must be a constant integer}}
32 }
33 
34 void testXXPERMDI(int index) {
35   vec_xxpermdi(vsi); //expected-error {{too few arguments to function call, expected 3, have 1}}
36   vec_xxpermdi(vsi, vsi, 2, 4); //expected-error {{too many arguments to function call, expected 3, have 4}}
37   vec_xxpermdi(vsi, vsi, index); //expected-error {{argument 3 to '__builtin_vsx_xxpermdi' must be a 2-bit unsigned literal (i.e. 0, 1, 2 or 3)}}
38   vec_xxpermdi(1, 2, 3); //expected-error {{first two arguments to '__builtin_vsx_xxpermdi' must be vectors}}
39   vec_xxpermdi(vsi, vuc, 2); //expected-error {{first two arguments to '__builtin_vsx_xxpermdi' must have the same type}}
40 }
41 
42 void testXXSLDWI(int index) {
43   vec_xxsldwi(vsi); //expected-error {{too few arguments to function call, expected 3, have 1}}
44   vec_xxsldwi(vsi, vsi, 2, 4); //expected-error {{too many arguments to function call, expected 3, have 4}}
45   vec_xxsldwi(vsi, vsi, index); //expected-error {{argument 3 to '__builtin_vsx_xxsldwi' must be a 2-bit unsigned literal (i.e. 0, 1, 2 or 3)}}
46   vec_xxsldwi(1, 2, 3); //expected-error {{first two arguments to '__builtin_vsx_xxsldwi' must be vectors}}
47   vec_xxsldwi(vsi, vuc, 2); //expected-error {{first two arguments to '__builtin_vsx_xxsldwi' must have the same type}}
48 }
49 
50 void testCTF(int index) {
51   vec_ctf(vsi, index); //expected-error {{argument to '__builtin_altivec_vcfsx' must be a constant integer}} expected-error {{argument to '__builtin_altivec_vcfux' must be a constant integer}}
52   vec_ctf(vui, index); //expected-error {{argument to '__builtin_altivec_vcfsx' must be a constant integer}} expected-error {{argument to '__builtin_altivec_vcfux' must be a constant integer}}
53 }
54 
55 void testVCFSX(int index) {
56   vec_vcfsx(vsi, index); //expected-error {{argument to '__builtin_altivec_vcfsx' must be a constant integer}}
57 }
58 
59 void testVCFUX(int index) {
60   vec_vcfux(vui, index); //expected-error {{argument to '__builtin_altivec_vcfux' must be a constant integer}}
61 }
62 
63 void testCTS(int index) {
64   vec_cts(vf, index); //expected-error {{argument to '__builtin_altivec_vctsxs' must be a constant integer}}
65 
66 }
67 
68 void testVCTSXS(int index) {
69   vec_vctsxs(vf, index); //expected-error {{argument to '__builtin_altivec_vctsxs' must be a constant integer}}
70 }
71 
72 void testCTU(int index) {
73   vec_ctu(vf, index); //expected-error {{argument to '__builtin_altivec_vctuxs' must be a constant integer}}
74 
75 }
76 
77 void testVCTUXS(int index) {
78   vec_vctuxs(vf, index); //expected-error {{argument to '__builtin_altivec_vctuxs' must be a constant integer}}
79 }
80 
81 void testUnpack128(int index) {
82   __builtin_unpack_vector_int128(vsllli, index); //expected-error {{argument to '__builtin_unpack_vector_int128' must be a constant integer}}
83   __builtin_unpack_vector_int128(vsllli, 5); //expected-error {{argument value 5 is outside the valid range [0, 1]}}
84 }
85 
86 void testDSS(int index) {
87   vec_dss(index); //expected-error {{argument to '__builtin_altivec_dss' must be a constant integer}}
88   vec_dss(5); //expected-error {{argument value 5 is outside the valid range [0, 3]}}
89 }
90 
91 void testDST(int index) {
92   vec_dst(&vsi, index, index); //expected-error {{argument to '__builtin_altivec_dst' must be a constant integer}}
93   vec_dst(&vsi, index, 5); //expected-error {{argument value 5 is outside the valid range [0, 3]}}
94   vec_dstt(&vsi, index, index); //expected-error {{argument to '__builtin_altivec_dstt' must be a constant integer}}
95   vec_dstt(&vsi, index, 5); //expected-error {{argument value 5 is outside the valid range [0, 3]}}
96   vec_dstst(&vsi, index, index); //expected-error {{argument to '__builtin_altivec_dstst' must be a constant integer}}
97   vec_dstst(&vsi, index, 5); //expected-error {{argument value 5 is outside the valid range [0, 3]}}
98   vec_dststt(&vsi, index, index); //expected-error {{argument to '__builtin_altivec_dststt' must be a constant integer}}
99   vec_dststt(&vsi, index, 5); //expected-error {{argument value 5 is outside the valid range [0, 3]}}
100 }
101