224 lines · c
1// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -fsyntax-only \2// RUN: -target-cpu pwr10 %s -verify3// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -fsyntax-only \4// RUN: -target-cpu pwr10 %s -verify5 6// The use of PPC MMA types is strongly restricted. Non-pointer MMA variables7// can only be declared in functions and a limited number of operations are8// supported on these types. This test case checks that invalid uses of MMA9// types are correctly prevented.10 11// vector quad12 13// typedef14typedef __vector_quad vq_t;15 16// function argument17void testVQArg1(__vector_quad vq, int *ptr) { // expected-error {{invalid use of PPC MMA type}}18 __vector_quad *vqp = (__vector_quad *)ptr;19 *vqp = vq;20}21 22void testVQArg2(const __vector_quad vq, int *ptr) { // expected-error {{invalid use of PPC MMA type}}23 __vector_quad *vqp = (__vector_quad *)ptr;24 *vqp = vq;25}26 27void testVQArg6(const vq_t vq, int *ptr) { // expected-error {{invalid use of PPC MMA type}}28 __vector_quad *vqp = (__vector_quad *)ptr;29 *vqp = vq;30}31 32// function return33__vector_quad testVQRet1(int *ptr) { // expected-error {{invalid use of PPC MMA type}}34 __vector_quad *vqp = (__vector_quad *)ptr;35 return *vqp; // expected-error {{invalid use of PPC MMA type}}36}37 38const vq_t testVQRet4(int *ptr) { // expected-error {{invalid use of PPC MMA type}}39 __vector_quad *vqp = (__vector_quad *)ptr;40 return *vqp; // expected-error {{invalid use of PPC MMA type}}41}42 43// global44__vector_quad globalvq; // expected-error {{invalid use of PPC MMA type}}45const __vector_quad globalvq2; // expected-error {{invalid use of PPC MMA type}}46__vector_quad *globalvqp;47const __vector_quad *const globalvqp2;48vq_t globalvq_t; // expected-error {{invalid use of PPC MMA type}}49 50 51// struct field52struct TestVQStruct {53 int a;54 float b;55 __vector_quad c; // expected-error {{invalid use of PPC MMA type}}56 __vector_quad *vq;57};58 59// operators60int testVQOperators1(int *ptr) {61 __vector_quad *vqp = (__vector_quad *)ptr;62 __vector_quad vq1 = *(vqp + 0);63 __vector_quad vq2 = *(vqp + 1);64 __vector_quad vq3 = *(vqp + 2);65 if (vq1) // expected-error {{statement requires expression of scalar type ('__vector_quad' invalid)}}66 *(vqp + 10) = vq1;67 if (!vq2) // expected-error {{invalid argument type '__vector_quad' to unary expression}}68 *(vqp + 11) = vq3;69 int c1 = vq1 && vq2; // expected-error {{invalid operands to binary expression ('__vector_quad' and '__vector_quad')}}70 int c2 = vq2 == vq3; // expected-error {{invalid operands to binary expression ('__vector_quad' and '__vector_quad')}}71 int c3 = vq2 < vq1; // expected-error {{invalid operands to binary expression ('__vector_quad' and '__vector_quad')}}72 return c1 || c2 || c3;73}74 75void testVQOperators2(int *ptr) {76 __vector_quad *vqp = (__vector_quad *)ptr;77 __vector_quad vq1 = *(vqp + 0);78 __vector_quad vq2 = *(vqp + 1);79 __vector_quad vq3 = *(vqp + 2);80 vq1 = -vq1; // expected-error {{invalid argument type '__vector_quad' to unary expression}}81 vq2 = vq1 + vq3; // expected-error {{invalid operands to binary expression ('__vector_quad' and '__vector_quad')}}82 vq2 = vq2 * vq3; // expected-error {{invalid operands to binary expression ('__vector_quad' and '__vector_quad')}}83 vq3 = vq3 | vq3; // expected-error {{invalid operands to binary expression ('__vector_quad' and '__vector_quad')}}84 vq3 = vq3 << 2; // expected-error {{invalid operands to binary expression ('__vector_quad' and 'int')}}85 *(vqp + 10) = vq1;86 *(vqp + 11) = vq2;87 *(vqp + 12) = vq3;88}89 90vector unsigned char testVQOperators3(int *ptr) {91 __vector_quad *vqp = (__vector_quad *)ptr;92 __vector_quad vq1 = *(vqp + 0);93 __vector_quad vq2 = *(vqp + 1);94 __vector_quad vq3 = *(vqp + 2);95 vq1 ? *(vqp + 10) = vq2 : *(vqp + 11) = vq3; // expected-error {{used type '__vector_quad' where arithmetic or pointer type is required}}96 vq2 = vq3;97 return vq2[1]; // expected-error {{subscripted value is not an array, pointer, or vector}}98}99 100void testVQOperators4(int v, void *ptr) {101 __vector_quad *vqp = (__vector_quad *)ptr;102 __vector_quad vq1 = (__vector_quad)v; // expected-error {{used type '__vector_quad' where arithmetic or pointer type is required}}103 __vector_quad vq2 = (__vector_quad)vqp; // expected-error {{used type '__vector_quad' where arithmetic or pointer type is required}}104}105 106// vector pair107 108// typedef109typedef __vector_pair vp_t;110 111// function argument112void testVPArg1(__vector_pair vp, int *ptr) { // expected-error {{invalid use of PPC MMA type}}113 __vector_pair *vpp = (__vector_pair *)ptr;114 *vpp = vp;115}116 117void testVPArg2(const __vector_pair vp, int *ptr) { // expected-error {{invalid use of PPC MMA type}}118 __vector_pair *vpp = (__vector_pair *)ptr;119 *vpp = vp;120}121 122void testVPArg6(const vp_t vp, int *ptr) { // expected-error {{invalid use of PPC MMA type}}123 __vector_pair *vpp = (__vector_pair *)ptr;124 *vpp = vp;125}126 127// function return128__vector_pair testVPRet1(int *ptr) { // expected-error {{invalid use of PPC MMA type}}129 __vector_pair *vpp = (__vector_pair *)ptr;130 return *vpp; // expected-error {{invalid use of PPC MMA type}}131}132 133const vp_t testVPRet4(int *ptr) { // expected-error {{invalid use of PPC MMA type}}134 __vector_pair *vpp = (__vector_pair *)ptr;135 return *vpp; // expected-error {{invalid use of PPC MMA type}}136}137 138// global139__vector_pair globalvp; // expected-error {{invalid use of PPC MMA type}}140const __vector_pair globalvp2; // expected-error {{invalid use of PPC MMA type}}141__vector_pair *globalvpp;142const __vector_pair *const globalvpp2;143vp_t globalvp_t; // expected-error {{invalid use of PPC MMA type}}144 145// struct field146struct TestVPStruct {147 int a;148 float b;149 __vector_pair c; // expected-error {{invalid use of PPC MMA type}}150 __vector_pair *vp;151};152 153// operators154int testVPOperators1(int *ptr) {155 __vector_pair *vpp = (__vector_pair *)ptr;156 __vector_pair vp1 = *(vpp + 0);157 __vector_pair vp2 = *(vpp + 1);158 __vector_pair vp3 = *(vpp + 2);159 if (vp1) // expected-error {{statement requires expression of scalar type ('__vector_pair' invalid)}}160 *(vpp + 10) = vp1;161 if (!vp2) // expected-error {{invalid argument type '__vector_pair' to unary expression}}162 *(vpp + 11) = vp3;163 int c1 = vp1 && vp2; // expected-error {{invalid operands to binary expression ('__vector_pair' and '__vector_pair')}}164 int c2 = vp2 == vp3; // expected-error {{invalid operands to binary expression ('__vector_pair' and '__vector_pair')}}165 int c3 = vp2 < vp1; // expected-error {{invalid operands to binary expression ('__vector_pair' and '__vector_pair')}}166 return c1 || c2 || c3;167}168 169void testVPOperators2(int *ptr) {170 __vector_pair *vpp = (__vector_pair *)ptr;171 __vector_pair vp1 = *(vpp + 0);172 __vector_pair vp2 = *(vpp + 1);173 __vector_pair vp3 = *(vpp + 2);174 vp1 = -vp1; // expected-error {{invalid argument type '__vector_pair' to unary expression}}175 vp2 = vp1 + vp3; // expected-error {{invalid operands to binary expression ('__vector_pair' and '__vector_pair')}}176 vp2 = vp2 * vp3; // expected-error {{invalid operands to binary expression ('__vector_pair' and '__vector_pair')}}177 vp3 = vp3 | vp3; // expected-error {{invalid operands to binary expression ('__vector_pair' and '__vector_pair')}}178 vp3 = vp3 << 2; // expected-error {{invalid operands to binary expression ('__vector_pair' and 'int')}}179 *(vpp + 10) = vp1;180 *(vpp + 11) = vp2;181 *(vpp + 12) = vp3;182}183 184vector unsigned char testVPOperators3(int *ptr) {185 __vector_pair *vpp = (__vector_pair *)ptr;186 __vector_pair vp1 = *(vpp + 0);187 __vector_pair vp2 = *(vpp + 1);188 __vector_pair vp3 = *(vpp + 2);189 vp1 ? *(vpp + 10) = vp2 : *(vpp + 11) = vp3; // expected-error {{used type '__vector_pair' where arithmetic or pointer type is required}}190 vp2 = vp3;191 return vp2[1]; // expected-error {{subscripted value is not an array, pointer, or vector}}192}193 194void testVPOperators4(int v, void *ptr) {195 __vector_pair *vpp = (__vector_pair *)ptr;196 __vector_pair vp1 = (__vector_pair)v; // expected-error {{used type '__vector_pair' where arithmetic or pointer type is required}}197 __vector_pair vp2 = (__vector_pair)vpp; // expected-error {{used type '__vector_pair' where arithmetic or pointer type is required}}198}199 200void testBuiltinTypes1(const __vector_pair *vpp, const __vector_pair *vp2, float f) {201 __vector_pair vp = __builtin_vsx_lxvp(f, vpp); // expected-error {{passing 'float' to parameter of incompatible type 'long'}}202 __builtin_vsx_stxvp(vp, 32799, vp2); // expected-error {{passing 'int' to parameter of incompatible type 'long'}}203}204 205void testBuiltinTypes2(__vector_pair *vpp, const __vector_pair *vp2, unsigned char c) {206 __vector_pair vp = __builtin_vsx_lxvp(6L, vpp); // expected-error {{passing '__vector_pair *' to parameter of incompatible type 'const __vector_pair *'}}207 __builtin_vsx_stxvp(vp, c, vp2); // expected-error {{passing 'unsigned char' to parameter of incompatible type 'long'}}208}209 210void testBuiltinTypes3(vector int v, __vector_pair *vp2, signed long l, unsigned short s) {211 __vector_pair vp = __builtin_vsx_lxvp(l, v); // expected-error {{passing '__vector int' (vector of 4 'int' values) to parameter of incompatible type 'const __vector_pair *'}}212 __builtin_vsx_stxvp(vp, l, s); // expected-error {{passing 'unsigned short' to parameter of incompatible type '__vector_pair *'}}213}214 215void testRestrictQualifiedPointer1(int *__restrict acc) {216 vector float arr[4];217 __builtin_mma_disassemble_acc(arr, acc); // expected-error {{passing 'int *restrict' to parameter of incompatible type '__vector_quad *'}}218}219 220void testVolatileQualifiedPointer1(int *__volatile acc) {221 vector float arr[4];222 __builtin_mma_disassemble_acc(arr, acc); // expected-error {{passing 'int *volatile' to parameter of incompatible type '__vector_quad *'}}223}224