1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2010-2019 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 Contributed by Ken Werner <ken.werner@de.ibm.com> */
22 #define VECTOR(n, type) \
23 type __attribute__ ((vector_size (n * sizeof(type))))
25 typedef VECTOR (8, int) int8
;
27 typedef VECTOR (4, int) int4
;
28 typedef VECTOR (4, unsigned int) uint4
;
29 typedef VECTOR (4, char) char4
;
30 typedef VECTOR (4, float) float4
;
32 typedef VECTOR (2, int) int2
;
33 typedef VECTOR (2, long long) longlong2
;
34 typedef VECTOR (2, float) float2
;
35 typedef VECTOR (2, double) double2
;
37 typedef VECTOR (1, char) char1
;
38 typedef VECTOR (1, int) int1
;
39 typedef VECTOR (1, double) double1
;
45 long long lla
__attribute__ ((mode(DI
))) = 0x0000000100000001ll
;
46 char4 c4
= {1, 2, 3, 4};
47 int4 i4a
= {2, 4, 8, 16};
48 int4 i4b
= {1, 2, 8, 4};
49 float4 f4a
= {2, 4, 8, 16};
50 float4 f4b
= {1, 2, 8, 4};
51 uint4 ui4
= {2, 4, 8, 16};
53 longlong2 ll2
= {1, 2};
60 VECTOR (sizeof(int), char) cv
;
61 } union_with_vector_1
;
66 VECTOR (sizeof(int), char) cv
;
68 } struct_with_vector_1
;
81 /* Simple vector-valued function with a few 16-byte vector
85 add_some_intvecs (int4 a
, int4 b
, int4 c
)
90 /* Many small vector arguments, 4 bytes each. */
93 add_many_charvecs (char4 a
, char4 b
, char4 c
, char4 d
, char4 e
,
94 char4 f
, char4 g
, char4 h
, char4 i
, char4 j
)
96 return (a
+ b
+ c
+ d
+ e
+ f
+ g
+ h
+ i
+ j
);
99 /* Varargs: One fixed and N-1 variable vector arguments. */
102 add_various_floatvecs (int n
, float4 a
, ...)
108 for (i
= 1; i
< n
; i
++)
109 a
+= va_arg (argp
, float4
);
115 /* Struct-wrapped vectors (might be passed as if not wrapped). */
118 add_structvecs (int2 a
, struct just_int2 b
, struct two_int2 c
)
120 struct just_int2 res
;
122 res
.i
= a
+ b
.i
+ c
.i
+ c
.j
;
126 /* Single-element vectors (might be treated like scalars). */
129 add_singlevecs (char1 a
, int1 b
, double1 c
)
131 return (double1
) {a
[0] + b
[0] + c
[0]};
140 res
= add_some_intvecs (i4a
, i4a
+ i4b
, i4b
);
142 res
= add_some_intvecs (i4a
, i4a
+ i4b
, i4b
);
144 add_some_intvecs (i4a
, i4a
+ i4b
, i4b
);