1 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f -target-feature +d -target-feature +zve64d -ffreestanding -fsyntax-only -verify -mvscale-min=1 -mvscale-max=1 %s 2 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f -target-feature +d -target-feature +zve64d -ffreestanding -fsyntax-only -verify -mvscale-min=2 -mvscale-max=2 %s 3 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f -target-feature +d -target-feature +zve64d -ffreestanding -fsyntax-only -verify -mvscale-min=4 -mvscale-max=4 %s 4 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f -target-feature +d -target-feature +zve64d -ffreestanding -fsyntax-only -verify -mvscale-min=8 -mvscale-max=8 %s 5 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f -target-feature +d -target-feature +zve64d -ffreestanding -fsyntax-only -verify -mvscale-min=16 -mvscale-max=16 %s 6 7 #include <stdint.h> 8 9 typedef __rvv_bool64_t vbool64_t; 10 typedef __rvv_bool32_t vbool32_t; 11 typedef __rvv_bool16_t vbool16_t; 12 typedef __rvv_bool8_t vbool8_t; 13 typedef __rvv_bool4_t vbool4_t; 14 typedef __rvv_bool2_t vbool2_t; 15 typedef __rvv_bool1_t vbool1_t; 16 17 typedef __rvv_int8mf8_t vint8mf8_t; 18 typedef __rvv_uint8mf8_t vuint8mf8_t; 19 20 typedef __rvv_int8mf4_t vint8mf4_t; 21 typedef __rvv_uint8mf4_t vuint8mf4_t; 22 typedef __rvv_int16mf4_t vint16mf4_t; 23 typedef __rvv_uint16mf4_t vuint16mf4_t; 24 25 typedef __rvv_int8mf2_t vint8mf2_t; 26 typedef __rvv_uint8mf2_t vuint8mf2_t; 27 typedef __rvv_int16mf2_t vint16mf2_t; 28 typedef __rvv_uint16mf2_t vuint16mf2_t; 29 typedef __rvv_int32mf2_t vint32mf2_t; 30 typedef __rvv_uint32mf2_t vuint32mf2_t; 31 typedef __rvv_float32mf2_t vfloat32mf2_t; 32 33 typedef __rvv_int8m1_t vint8m1_t; 34 typedef __rvv_uint8m1_t vuint8m1_t; 35 typedef __rvv_int16m1_t vint16m1_t; 36 typedef __rvv_uint16m1_t vuint16m1_t; 37 typedef __rvv_int32m1_t vint32m1_t; 38 typedef __rvv_uint32m1_t vuint32m1_t; 39 typedef __rvv_int64m1_t vint64m1_t; 40 typedef __rvv_uint64m1_t vuint64m1_t; 41 typedef __rvv_float32m1_t vfloat32m1_t; 42 typedef __rvv_float64m1_t vfloat64m1_t; 43 44 typedef __rvv_int8m2_t vint8m2_t; 45 typedef __rvv_uint8m2_t vuint8m2_t; 46 typedef __rvv_int16m2_t vint16m2_t; 47 typedef __rvv_uint16m2_t vuint16m2_t; 48 typedef __rvv_int32m2_t vint32m2_t; 49 typedef __rvv_uint32m2_t vuint32m2_t; 50 typedef __rvv_int64m2_t vint64m2_t; 51 typedef __rvv_uint64m2_t vuint64m2_t; 52 typedef __rvv_float32m2_t vfloat32m2_t; 53 typedef __rvv_float64m2_t vfloat64m2_t; 54 55 typedef __rvv_int8m4_t vint8m4_t; 56 typedef __rvv_uint8m4_t vuint8m4_t; 57 typedef __rvv_int16m4_t vint16m4_t; 58 typedef __rvv_uint16m4_t vuint16m4_t; 59 typedef __rvv_int32m4_t vint32m4_t; 60 typedef __rvv_uint32m4_t vuint32m4_t; 61 typedef __rvv_int64m4_t vint64m4_t; 62 typedef __rvv_uint64m4_t vuint64m4_t; 63 typedef __rvv_float32m4_t vfloat32m4_t; 64 typedef __rvv_float64m4_t vfloat64m4_t; 65 66 typedef __rvv_int8m8_t vint8m8_t; 67 typedef __rvv_uint8m8_t vuint8m8_t; 68 typedef __rvv_int16m8_t vint16m8_t; 69 typedef __rvv_uint16m8_t vuint16m8_t; 70 typedef __rvv_int32m8_t vint32m8_t; 71 typedef __rvv_uint32m8_t vuint32m8_t; 72 typedef __rvv_int64m8_t vint64m8_t; 73 typedef __rvv_uint64m8_t vuint64m8_t; 74 typedef __rvv_float32m8_t vfloat32m8_t; 75 typedef __rvv_float64m8_t vfloat64m8_t; 76 77 // Define valid fixed-width RVV types 78 typedef vint8mf8_t fixed_int8mf8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 8))); 79 80 typedef vuint8mf8_t fixed_uint8mf8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 8))); 81 82 typedef vint8mf4_t fixed_int8mf4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4))); 83 typedef vint16mf4_t fixed_int16mf4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4))); 84 85 typedef vuint8mf4_t fixed_uint8mf4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4))); 86 typedef vuint16mf4_t fixed_uint16mf4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4))); 87 88 typedef vint8mf2_t fixed_int8mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2))); 89 typedef vint16mf2_t fixed_int16mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2))); 90 typedef vint32mf2_t fixed_int32mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2))); 91 92 typedef vuint8mf2_t fixed_uint8mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2))); 93 typedef vuint16mf2_t fixed_uint16mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2))); 94 typedef vuint32mf2_t fixed_uint32mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2))); 95 96 typedef vfloat32mf2_t fixed_float32mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2))); 97 98 typedef vint8m1_t fixed_int8m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); 99 typedef vint16m1_t fixed_int16m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); 100 typedef vint32m1_t fixed_int32m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); 101 typedef vint64m1_t fixed_int64m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); 102 103 typedef vuint8m1_t fixed_uint8m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); 104 typedef vuint16m1_t fixed_uint16m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); 105 typedef vuint32m1_t fixed_uint32m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); 106 typedef vuint64m1_t fixed_uint64m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); 107 108 typedef vfloat32m1_t fixed_float32m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); 109 typedef vfloat64m1_t fixed_float64m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); 110 111 typedef vint8m2_t fixed_int8m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2))); 112 typedef vint16m2_t fixed_int16m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2))); 113 typedef vint32m2_t fixed_int32m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2))); 114 typedef vint64m2_t fixed_int64m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2))); 115 116 typedef vuint8m2_t fixed_uint8m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2))); 117 typedef vuint16m2_t fixed_uint16m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2))); 118 typedef vuint32m2_t fixed_uint32m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2))); 119 typedef vuint64m2_t fixed_uint64m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2))); 120 121 typedef vfloat32m2_t fixed_float32m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2))); 122 typedef vfloat64m2_t fixed_float64m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2))); 123 124 typedef vint8m4_t fixed_int8m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4))); 125 typedef vint16m4_t fixed_int16m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4))); 126 typedef vint32m4_t fixed_int32m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4))); 127 typedef vint64m4_t fixed_int64m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4))); 128 129 typedef vuint8m4_t fixed_uint8m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4))); 130 typedef vuint16m4_t fixed_uint16m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4))); 131 typedef vuint32m4_t fixed_uint32m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4))); 132 typedef vuint64m4_t fixed_uint64m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4))); 133 134 typedef vfloat32m4_t fixed_float32m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4))); 135 typedef vfloat64m4_t fixed_float64m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4))); 136 137 typedef vint8m8_t fixed_int8m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8))); 138 typedef vint16m8_t fixed_int16m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8))); 139 typedef vint32m8_t fixed_int32m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8))); 140 typedef vint64m8_t fixed_int64m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8))); 141 142 typedef vuint8m8_t fixed_uint8m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8))); 143 typedef vuint16m8_t fixed_uint16m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8))); 144 typedef vuint32m8_t fixed_uint32m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8))); 145 typedef vuint64m8_t fixed_uint64m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8))); 146 147 typedef vfloat32m8_t fixed_float32m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8))); 148 typedef vfloat64m8_t fixed_float64m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8))); 149 150 // GNU vector types 151 typedef int8_t gnu_int8mf8_t __attribute__((vector_size(__riscv_v_fixed_vlen / 64))); 152 153 typedef uint8_t gnu_uint8mf8_t __attribute__((vector_size(__riscv_v_fixed_vlen / 64))); 154 155 typedef int8_t gnu_int8mf4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 32))); 156 typedef int16_t gnu_int16mf4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 32))); 157 158 typedef uint8_t gnu_uint8mf4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 32))); 159 typedef uint16_t gnu_uint16mf4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 32))); 160 161 typedef int8_t gnu_int8mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16))); 162 typedef int16_t gnu_int16mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16))); 163 typedef int32_t gnu_int32mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16))); 164 165 typedef uint8_t gnu_uint8mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16))); 166 typedef uint16_t gnu_uint16mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16))); 167 typedef uint32_t gnu_uint32mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16))); 168 169 typedef float gnu_float32mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16))); 170 171 typedef int8_t gnu_int8m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8))); 172 typedef int16_t gnu_int16m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8))); 173 typedef int32_t gnu_int32m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8))); 174 typedef int64_t gnu_int64m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8))); 175 176 typedef uint8_t gnu_uint8m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8))); 177 typedef uint16_t gnu_uint16m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8))); 178 typedef uint32_t gnu_uint32m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8))); 179 typedef uint64_t gnu_uint64m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8))); 180 181 typedef float gnu_float32m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8))); 182 typedef double gnu_float64m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8))); 183 184 typedef int8_t gnu_int8m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4))); 185 typedef int16_t gnu_int16m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4))); 186 typedef int32_t gnu_int32m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4))); 187 typedef int64_t gnu_int64m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4))); 188 189 typedef uint8_t gnu_uint8m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4))); 190 typedef uint16_t gnu_uint16m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4))); 191 typedef uint32_t gnu_uint32m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4))); 192 typedef uint64_t gnu_uint64m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4))); 193 194 typedef float gnu_float32m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4))); 195 typedef double gnu_float64m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4))); 196 197 typedef int8_t gnu_int8m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2))); 198 typedef int16_t gnu_int16m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2))); 199 typedef int32_t gnu_int32m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2))); 200 typedef int64_t gnu_int64m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2))); 201 202 typedef uint8_t gnu_uint8m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2))); 203 typedef uint16_t gnu_uint16m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2))); 204 typedef uint32_t gnu_uint32m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2))); 205 typedef uint64_t gnu_uint64m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2))); 206 207 typedef float gnu_float32m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2))); 208 typedef double gnu_float64m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2))); 209 210 typedef int8_t gnu_int8m8_t __attribute__((vector_size(__riscv_v_fixed_vlen))); 211 typedef int16_t gnu_int16m8_t __attribute__((vector_size(__riscv_v_fixed_vlen))); 212 typedef int32_t gnu_int32m8_t __attribute__((vector_size(__riscv_v_fixed_vlen))); 213 typedef int64_t gnu_int64m8_t __attribute__((vector_size(__riscv_v_fixed_vlen))); 214 215 typedef uint8_t gnu_uint8m8_t __attribute__((vector_size(__riscv_v_fixed_vlen))); 216 typedef uint16_t gnu_uint16m8_t __attribute__((vector_size(__riscv_v_fixed_vlen))); 217 typedef uint32_t gnu_uint32m8_t __attribute__((vector_size(__riscv_v_fixed_vlen))); 218 typedef uint64_t gnu_uint64m8_t __attribute__((vector_size(__riscv_v_fixed_vlen))); 219 220 typedef float gnu_float32m8_t __attribute__((vector_size(__riscv_v_fixed_vlen))); 221 typedef double gnu_float64m8_t __attribute__((vector_size(__riscv_v_fixed_vlen))); 222 223 // Attribute must have a single argument 224 typedef vint8m1_t no_argument __attribute__((riscv_rvv_vector_bits)); // expected-error {{'riscv_rvv_vector_bits' attribute takes one argument}} 225 typedef vint8m1_t two_arguments __attribute__((riscv_rvv_vector_bits(2, 4))); // expected-error {{'riscv_rvv_vector_bits' attribute takes one argument}} 226 227 // The number of RVV vector bits must be an integer constant expression 228 typedef vint8m1_t non_int_size1 __attribute__((riscv_rvv_vector_bits(2.0))); // expected-error {{'riscv_rvv_vector_bits' attribute requires an integer constant}} 229 typedef vint8m1_t non_int_size2 __attribute__((riscv_rvv_vector_bits("256"))); // expected-error {{'riscv_rvv_vector_bits' attribute requires an integer constant}} 230 231 typedef vbool1_t fixed_bool1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); 232 typedef vbool2_t fixed_bool2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2))); 233 typedef vbool4_t fixed_bool4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4))); 234 typedef vbool8_t fixed_bool8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 8))); 235 typedef vbool16_t fixed_bool16_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 16))); 236 typedef vbool32_t fixed_bool32_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 32))); 237 typedef vbool64_t fixed_bool64_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 64))); 238 239 // Attribute must be attached to a single RVV vector or predicate type. 240 typedef void *badtype1 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); // expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 'void *'}} 241 typedef int badtype2 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); // expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 'int'}} 242 typedef float badtype3 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); // expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 'float'}} 243 244 // Attribute only applies to typedefs. 245 vint8m1_t non_typedef_type __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); // expected-error {{'riscv_rvv_vector_bits' attribute only applies to typedefs}} 246 247 // Test that we can define non-local fixed-length RVV types (unsupported for 248 // sizeless types). 249 fixed_int8m1_t global_int8; 250 fixed_bool1_t global_bool1; 251 252 extern fixed_int8m1_t extern_int8; 253 extern fixed_bool1_t extern_bool1; 254 255 static fixed_int8m1_t static_int8; 256 static fixed_bool1_t static_bool1; 257 258 fixed_int8m1_t *global_int8_ptr; 259 extern fixed_int8m1_t *extern_int8_ptr; 260 static fixed_int8m1_t *static_int8_ptr; 261 __thread fixed_int8m1_t thread_int8; 262 263 typedef fixed_int8m1_t int8_typedef; 264 typedef fixed_int8m1_t *int8_ptr_typedef; 265 266 // Test sized expressions 267 int sizeof_int8 = sizeof(global_int8); 268 int sizeof_int8_var = sizeof(*global_int8_ptr); 269 int sizeof_int8_var_ptr = sizeof(global_int8_ptr); 270 271 extern fixed_int8m1_t *extern_int8_ptr; 272 273 int alignof_int8 = __alignof__(extern_int8); 274 int alignof_int8_var = __alignof__(*extern_int8_ptr); 275 int alignof_int8_var_ptr = __alignof__(extern_int8_ptr); 276 277 void f(int c) { 278 fixed_int8m1_t fs8; 279 vint8m1_t ss8; 280 gnu_int8m1_t gs8; 281 282 // Check conditional expressions where the result is ambiguous are 283 // ill-formed. 284 void *sel __attribute__((unused)); 285 sel = c ? ss8 : fs8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}} 286 sel = c ? fs8 : ss8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}} 287 288 sel = c ? gs8 : ss8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 289 sel = c ? ss8 : gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 290 291 sel = c ? gs8 : fs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 292 sel = c ? fs8 : gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 293 294 // Check binary expressions where the result is ambiguous are ill-formed. 295 ss8 = ss8 + fs8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}} 296 ss8 = ss8 + gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 297 298 fs8 = fs8 + ss8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}} 299 fs8 = fs8 + gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 300 301 gs8 = gs8 + ss8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 302 gs8 = gs8 + fs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 303 304 ss8 += fs8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}} 305 ss8 += gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 306 307 fs8 += ss8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}} 308 fs8 += gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 309 310 gs8 += ss8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 311 gs8 += fs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 312 313 ss8 = ss8 == fs8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}} 314 ss8 = ss8 == gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 315 316 fs8 = fs8 == ss8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}} 317 fs8 = fs8 == gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 318 319 gs8 = gs8 == ss8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 320 gs8 = gs8 == fs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 321 322 ss8 = ss8 & fs8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}} 323 ss8 = ss8 & gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 324 325 fs8 = fs8 & ss8; // expected-error {{cannot combine fixed-length and sizeless RVV vectors in expression, result is ambiguous}} 326 fs8 = fs8 & gs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 327 328 gs8 = gs8 & ss8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 329 gs8 = gs8 & fs8; // expected-error {{cannot combine GNU and RVV vectors in expression, result is ambiguous}} 330 } 331 332 // --------------------------------------------------------------------------// 333 // Sizeof 334 335 #define VECTOR_SIZE ((__riscv_v_fixed_vlen / 8)) 336 337 _Static_assert(sizeof(fixed_int8mf8_t) == VECTOR_SIZE / 8, ""); 338 339 _Static_assert(sizeof(fixed_uint8mf8_t) == VECTOR_SIZE / 8, ""); 340 341 _Static_assert(sizeof(fixed_int8mf4_t) == VECTOR_SIZE / 4, ""); 342 _Static_assert(sizeof(fixed_int16mf4_t) == VECTOR_SIZE / 4, ""); 343 344 _Static_assert(sizeof(fixed_uint8mf4_t) == VECTOR_SIZE / 4, ""); 345 _Static_assert(sizeof(fixed_uint16mf4_t) == VECTOR_SIZE / 4, ""); 346 347 _Static_assert(sizeof(fixed_int8mf2_t) == VECTOR_SIZE / 2, ""); 348 _Static_assert(sizeof(fixed_int16mf2_t) == VECTOR_SIZE / 2, ""); 349 _Static_assert(sizeof(fixed_int32mf2_t) == VECTOR_SIZE / 2, ""); 350 351 _Static_assert(sizeof(fixed_uint8mf2_t) == VECTOR_SIZE / 2, ""); 352 _Static_assert(sizeof(fixed_uint16mf2_t) == VECTOR_SIZE / 2, ""); 353 _Static_assert(sizeof(fixed_uint32mf2_t) == VECTOR_SIZE / 2, ""); 354 355 _Static_assert(sizeof(fixed_float32mf2_t) == VECTOR_SIZE / 2, ""); 356 357 _Static_assert(sizeof(fixed_int8m1_t) == VECTOR_SIZE, ""); 358 _Static_assert(sizeof(fixed_int16m1_t) == VECTOR_SIZE, ""); 359 _Static_assert(sizeof(fixed_int32m1_t) == VECTOR_SIZE, ""); 360 _Static_assert(sizeof(fixed_int64m1_t) == VECTOR_SIZE, ""); 361 362 _Static_assert(sizeof(fixed_uint8m1_t) == VECTOR_SIZE, ""); 363 _Static_assert(sizeof(fixed_uint16m1_t) == VECTOR_SIZE, ""); 364 _Static_assert(sizeof(fixed_uint32m1_t) == VECTOR_SIZE, ""); 365 _Static_assert(sizeof(fixed_int64m1_t) == VECTOR_SIZE, ""); 366 367 _Static_assert(sizeof(fixed_float32m1_t) == VECTOR_SIZE, ""); 368 _Static_assert(sizeof(fixed_float64m1_t) == VECTOR_SIZE, ""); 369 370 _Static_assert(sizeof(fixed_int8m2_t) == VECTOR_SIZE * 2, ""); 371 _Static_assert(sizeof(fixed_int16m2_t) == VECTOR_SIZE * 2, ""); 372 _Static_assert(sizeof(fixed_int32m2_t) == VECTOR_SIZE * 2, ""); 373 _Static_assert(sizeof(fixed_int64m2_t) == VECTOR_SIZE * 2, ""); 374 375 _Static_assert(sizeof(fixed_uint8m2_t) == VECTOR_SIZE * 2, ""); 376 _Static_assert(sizeof(fixed_uint16m2_t) == VECTOR_SIZE * 2, ""); 377 _Static_assert(sizeof(fixed_uint32m2_t) == VECTOR_SIZE * 2, ""); 378 _Static_assert(sizeof(fixed_int64m2_t) == VECTOR_SIZE * 2, ""); 379 380 _Static_assert(sizeof(fixed_float32m2_t) == VECTOR_SIZE * 2, ""); 381 _Static_assert(sizeof(fixed_float64m2_t) == VECTOR_SIZE * 2, ""); 382 383 _Static_assert(sizeof(fixed_int8m4_t) == VECTOR_SIZE * 4, ""); 384 _Static_assert(sizeof(fixed_int16m4_t) == VECTOR_SIZE * 4, ""); 385 _Static_assert(sizeof(fixed_int32m4_t) == VECTOR_SIZE * 4, ""); 386 _Static_assert(sizeof(fixed_int64m4_t) == VECTOR_SIZE * 4, ""); 387 388 _Static_assert(sizeof(fixed_uint8m4_t) == VECTOR_SIZE * 4, ""); 389 _Static_assert(sizeof(fixed_uint16m4_t) == VECTOR_SIZE * 4, ""); 390 _Static_assert(sizeof(fixed_uint32m4_t) == VECTOR_SIZE * 4, ""); 391 _Static_assert(sizeof(fixed_int64m4_t) == VECTOR_SIZE * 4, ""); 392 393 _Static_assert(sizeof(fixed_float32m4_t) == VECTOR_SIZE * 4, ""); 394 _Static_assert(sizeof(fixed_float64m4_t) == VECTOR_SIZE * 4, ""); 395 396 _Static_assert(sizeof(fixed_int8m8_t) == VECTOR_SIZE * 8, ""); 397 _Static_assert(sizeof(fixed_int16m8_t) == VECTOR_SIZE * 8, ""); 398 _Static_assert(sizeof(fixed_int32m8_t) == VECTOR_SIZE * 8, ""); 399 _Static_assert(sizeof(fixed_int64m8_t) == VECTOR_SIZE * 8, ""); 400 401 _Static_assert(sizeof(fixed_uint8m8_t) == VECTOR_SIZE * 8, ""); 402 _Static_assert(sizeof(fixed_uint16m8_t) == VECTOR_SIZE * 8, ""); 403 _Static_assert(sizeof(fixed_uint32m8_t) == VECTOR_SIZE * 8, ""); 404 _Static_assert(sizeof(fixed_int64m8_t) == VECTOR_SIZE * 8, ""); 405 406 _Static_assert(sizeof(fixed_float32m8_t) == VECTOR_SIZE * 8, ""); 407 _Static_assert(sizeof(fixed_float64m8_t) == VECTOR_SIZE * 8, ""); 408 409 _Static_assert(sizeof(fixed_bool1_t) == VECTOR_SIZE, ""); 410 _Static_assert(sizeof(fixed_bool2_t) == VECTOR_SIZE / 2, ""); 411 _Static_assert(sizeof(fixed_bool4_t) == VECTOR_SIZE / 4, ""); 412 _Static_assert(sizeof(fixed_bool8_t) == VECTOR_SIZE / 8, ""); 413 #if __riscv_v_fixed_vlen / 16 >= 8 414 _Static_assert(sizeof(fixed_bool16_t) == VECTOR_SIZE / 16, ""); 415 #else 416 _Static_assert(sizeof(fixed_bool16_t) == 1, ""); 417 #endif 418 #if __riscv_v_fixed_vlen / 32 >= 8 419 _Static_assert(sizeof(fixed_bool32_t) == VECTOR_SIZE / 32, ""); 420 #else 421 _Static_assert(sizeof(fixed_bool32_t) == 1, ""); 422 #endif 423 #if __riscv_v_fixed_vlen / 64 >= 8 424 _Static_assert(sizeof(fixed_bool64_t) == VECTOR_SIZE / 64, ""); 425 #else 426 _Static_assert(sizeof(fixed_bool64_t) == 1, ""); 427 #endif 428 429 // --------------------------------------------------------------------------// 430 // Alignof 431 432 #define VECTOR_ALIGN 8 433 434 _Static_assert(__alignof__(fixed_int8mf8_t) == (sizeof(fixed_int8mf8_t) < VECTOR_ALIGN ? sizeof(fixed_int8mf8_t) : VECTOR_ALIGN), ""); 435 436 _Static_assert(__alignof__(fixed_uint8mf8_t) == (sizeof(fixed_uint8mf8_t) < VECTOR_ALIGN ? sizeof(fixed_int8mf8_t) : VECTOR_ALIGN), ""); 437 438 _Static_assert(__alignof__(fixed_int8mf4_t) == (sizeof(fixed_int8mf4_t) < VECTOR_ALIGN ? sizeof(fixed_int8mf4_t) : VECTOR_ALIGN), ""); 439 _Static_assert(__alignof__(fixed_int16mf4_t) == (sizeof(fixed_int16mf4_t) < VECTOR_ALIGN ? sizeof(fixed_int16mf4_t) : VECTOR_ALIGN), ""); 440 441 _Static_assert(__alignof__(fixed_uint8mf4_t) == (sizeof(fixed_uint8mf4_t) < VECTOR_ALIGN ? sizeof(fixed_uint8mf4_t) : VECTOR_ALIGN), ""); 442 _Static_assert(__alignof__(fixed_uint16mf4_t) == (sizeof(fixed_uint16mf4_t) < VECTOR_ALIGN ? sizeof(fixed_uint16mf4_t) : VECTOR_ALIGN), ""); 443 444 _Static_assert(__alignof__(fixed_int8mf2_t) == (sizeof(fixed_int8mf2_t) < VECTOR_ALIGN ? sizeof(fixed_int8mf2_t) : VECTOR_ALIGN), ""); 445 _Static_assert(__alignof__(fixed_int16mf2_t) == (sizeof(fixed_int16mf2_t) < VECTOR_ALIGN ? sizeof(fixed_int16mf2_t) : VECTOR_ALIGN), ""); 446 _Static_assert(__alignof__(fixed_int32mf2_t) == (sizeof(fixed_int32mf2_t) < VECTOR_ALIGN ? sizeof(fixed_int32mf2_t) : VECTOR_ALIGN), ""); 447 448 _Static_assert(__alignof__(fixed_uint8mf2_t) == (sizeof(fixed_uint8mf2_t) < VECTOR_ALIGN ? sizeof(fixed_uint8mf2_t) : VECTOR_ALIGN), ""); 449 _Static_assert(__alignof__(fixed_uint16mf2_t) == (sizeof(fixed_uint16mf2_t) < VECTOR_ALIGN ? sizeof(fixed_uint16mf2_t) : VECTOR_ALIGN), ""); 450 _Static_assert(__alignof__(fixed_uint32mf2_t) == (sizeof(fixed_uint32mf2_t) < VECTOR_ALIGN ? sizeof(fixed_uint32mf2_t) : VECTOR_ALIGN), ""); 451 452 _Static_assert(__alignof__(fixed_float32mf2_t) == (sizeof(fixed_float32mf2_t) < VECTOR_ALIGN ? sizeof(fixed_float32mf2_t) : VECTOR_ALIGN), ""); 453 454 _Static_assert(__alignof__(fixed_int8m1_t) == VECTOR_ALIGN, ""); 455 _Static_assert(__alignof__(fixed_int16m1_t) == VECTOR_ALIGN, ""); 456 _Static_assert(__alignof__(fixed_int32m1_t) == VECTOR_ALIGN, ""); 457 _Static_assert(__alignof__(fixed_int64m1_t) == VECTOR_ALIGN, ""); 458 459 _Static_assert(__alignof__(fixed_uint8m1_t) == VECTOR_ALIGN, ""); 460 _Static_assert(__alignof__(fixed_uint16m1_t) == VECTOR_ALIGN, ""); 461 _Static_assert(__alignof__(fixed_uint32m1_t) == VECTOR_ALIGN, ""); 462 _Static_assert(__alignof__(fixed_uint64m1_t) == VECTOR_ALIGN, ""); 463 464 _Static_assert(__alignof__(fixed_float32m1_t) == VECTOR_ALIGN, ""); 465 _Static_assert(__alignof__(fixed_float64m1_t) == VECTOR_ALIGN, ""); 466 467 _Static_assert(__alignof__(fixed_int8m2_t) == VECTOR_ALIGN, ""); 468 _Static_assert(__alignof__(fixed_int16m2_t) == VECTOR_ALIGN, ""); 469 _Static_assert(__alignof__(fixed_int32m2_t) == VECTOR_ALIGN, ""); 470 _Static_assert(__alignof__(fixed_int64m2_t) == VECTOR_ALIGN, ""); 471 472 _Static_assert(__alignof__(fixed_uint8m2_t) == VECTOR_ALIGN, ""); 473 _Static_assert(__alignof__(fixed_uint16m2_t) == VECTOR_ALIGN, ""); 474 _Static_assert(__alignof__(fixed_uint32m2_t) == VECTOR_ALIGN, ""); 475 _Static_assert(__alignof__(fixed_uint64m2_t) == VECTOR_ALIGN, ""); 476 477 _Static_assert(__alignof__(fixed_float32m2_t) == VECTOR_ALIGN, ""); 478 _Static_assert(__alignof__(fixed_float64m2_t) == VECTOR_ALIGN, ""); 479 480 _Static_assert(__alignof__(fixed_int8m4_t) == VECTOR_ALIGN, ""); 481 _Static_assert(__alignof__(fixed_int16m4_t) == VECTOR_ALIGN, ""); 482 _Static_assert(__alignof__(fixed_int32m4_t) == VECTOR_ALIGN, ""); 483 _Static_assert(__alignof__(fixed_int64m4_t) == VECTOR_ALIGN, ""); 484 485 _Static_assert(__alignof__(fixed_uint8m4_t) == VECTOR_ALIGN, ""); 486 _Static_assert(__alignof__(fixed_uint16m4_t) == VECTOR_ALIGN, ""); 487 _Static_assert(__alignof__(fixed_uint32m4_t) == VECTOR_ALIGN, ""); 488 _Static_assert(__alignof__(fixed_uint64m4_t) == VECTOR_ALIGN, ""); 489 490 _Static_assert(__alignof__(fixed_float32m4_t) == VECTOR_ALIGN, ""); 491 _Static_assert(__alignof__(fixed_float64m4_t) == VECTOR_ALIGN, ""); 492 493 _Static_assert(__alignof__(fixed_int8m8_t) == VECTOR_ALIGN, ""); 494 _Static_assert(__alignof__(fixed_int16m8_t) == VECTOR_ALIGN, ""); 495 _Static_assert(__alignof__(fixed_int32m8_t) == VECTOR_ALIGN, ""); 496 _Static_assert(__alignof__(fixed_int64m8_t) == VECTOR_ALIGN, ""); 497 498 _Static_assert(__alignof__(fixed_uint8m8_t) == VECTOR_ALIGN, ""); 499 _Static_assert(__alignof__(fixed_uint16m8_t) == VECTOR_ALIGN, ""); 500 _Static_assert(__alignof__(fixed_uint32m8_t) == VECTOR_ALIGN, ""); 501 _Static_assert(__alignof__(fixed_uint64m8_t) == VECTOR_ALIGN, ""); 502 503 _Static_assert(__alignof__(fixed_float32m8_t) == VECTOR_ALIGN, ""); 504 _Static_assert(__alignof__(fixed_float64m8_t) == VECTOR_ALIGN, ""); 505 506 _Static_assert(__alignof__(fixed_bool1_t) == VECTOR_ALIGN, ""); 507 _Static_assert(__alignof__(fixed_bool2_t) == (sizeof(fixed_bool2_t) < VECTOR_ALIGN ? sizeof(fixed_bool2_t) : VECTOR_ALIGN), ""); 508 _Static_assert(__alignof__(fixed_bool4_t) == (sizeof(fixed_bool4_t) < VECTOR_ALIGN ? sizeof(fixed_bool4_t) : VECTOR_ALIGN), ""); 509 _Static_assert(__alignof__(fixed_bool8_t) == (sizeof(fixed_bool8_t) < VECTOR_ALIGN ? sizeof(fixed_bool8_t) : VECTOR_ALIGN), ""); 510 _Static_assert(__alignof__(fixed_bool16_t) == (sizeof(fixed_bool16_t) < VECTOR_ALIGN ? sizeof(fixed_bool16_t) : VECTOR_ALIGN), ""); 511 _Static_assert(__alignof__(fixed_bool32_t) == (sizeof(fixed_bool32_t) < VECTOR_ALIGN ? sizeof(fixed_bool32_t) : VECTOR_ALIGN), ""); 512 _Static_assert(__alignof__(fixed_bool64_t) == (sizeof(fixed_bool64_t) < VECTOR_ALIGN ? sizeof(fixed_bool64_t) : VECTOR_ALIGN), ""); 513 514 // --------------------------------------------------------------------------// 515 // Structs 516 517 struct struct_int64 { fixed_int64m1_t x, y[5]; }; 518 struct struct_float64 { fixed_float64m1_t x, y[5]; }; 519 520 struct struct_int64m2 { fixed_int64m2_t x, y[5]; }; 521 struct struct_float64m2 { fixed_float64m2_t x, y[5]; }; 522 523 struct struct_int64m4 { fixed_int64m4_t x, y[5]; }; 524 struct struct_float64m4 { fixed_float64m4_t x, y[5]; }; 525 526 struct struct_int64m8 { fixed_int64m8_t x, y[5]; }; 527 struct struct_float64m8 { fixed_float64m8_t x, y[5]; }; 528 529 // --------------------------------------------------------------------------// 530 // Unions 531 union union_int64 { fixed_int64m1_t x, y[5]; }; 532 union union_float64 { fixed_float64m1_t x, y[5]; }; 533 534 union union_int64m2 { fixed_int64m2_t x, y[5]; }; 535 union union_float64m2 { fixed_float64m2_t x, y[5]; }; 536 537 union union_int64m4 { fixed_int64m4_t x, y[5]; }; 538 union union_float64m4 { fixed_float64m4_t x, y[5]; }; 539 540 union union_int64m8 { fixed_int64m8_t x, y[5]; }; 541 union union_float64m8 { fixed_float64m8_t x, y[5]; }; 542 543 // --------------------------------------------------------------------------// 544 // Implicit casts 545 546 #define TEST_CAST_COMMON(TYPE) \ 547 v##TYPE##_t to_v##TYPE##_t_from_fixed(fixed_##TYPE##_t x) { return x; } \ 548 fixed_##TYPE##_t from_##TYPE##_t_to_fixed(v##TYPE##_t x) { return x; } 549 550 #define TEST_CAST_GNU(PREFIX, TYPE) \ 551 gnu_##TYPE##_t to_gnu_##TYPE##_t_from_##PREFIX##TYPE##_t(PREFIX##TYPE##_t x) { return x; } \ 552 PREFIX##TYPE##_t from_gnu_##TYPE##_t_to_##PREFIX##TYPE##_t(gnu_##TYPE##_t x) { return x; } 553 554 #define TEST_CAST_VECTOR(TYPE) \ 555 TEST_CAST_COMMON(TYPE) \ 556 TEST_CAST_GNU(v, TYPE) \ 557 TEST_CAST_GNU(fixed_, TYPE) 558 559 TEST_CAST_VECTOR(int8mf8) 560 TEST_CAST_VECTOR(uint8mf8) 561 562 TEST_CAST_VECTOR(int8mf4) 563 TEST_CAST_VECTOR(int16mf4) 564 TEST_CAST_VECTOR(uint8mf4) 565 TEST_CAST_VECTOR(uint16mf4) 566 567 TEST_CAST_VECTOR(int8mf2) 568 TEST_CAST_VECTOR(int16mf2) 569 TEST_CAST_VECTOR(int32mf2) 570 TEST_CAST_VECTOR(uint8mf2) 571 TEST_CAST_VECTOR(uint16mf2) 572 TEST_CAST_VECTOR(uint32mf2) 573 TEST_CAST_VECTOR(float32mf2) 574 575 TEST_CAST_VECTOR(int8m1) 576 TEST_CAST_VECTOR(int16m1) 577 TEST_CAST_VECTOR(int32m1) 578 TEST_CAST_VECTOR(int64m1) 579 TEST_CAST_VECTOR(uint8m1) 580 TEST_CAST_VECTOR(uint16m1) 581 TEST_CAST_VECTOR(uint32m1) 582 TEST_CAST_VECTOR(uint64m1) 583 TEST_CAST_VECTOR(float32m1) 584 TEST_CAST_VECTOR(float64m1) 585 586 TEST_CAST_VECTOR(int8m2) 587 TEST_CAST_VECTOR(int16m2) 588 TEST_CAST_VECTOR(int32m2) 589 TEST_CAST_VECTOR(int64m2) 590 TEST_CAST_VECTOR(uint8m2) 591 TEST_CAST_VECTOR(uint16m2) 592 TEST_CAST_VECTOR(uint32m2) 593 TEST_CAST_VECTOR(uint64m2) 594 TEST_CAST_VECTOR(float32m2) 595 TEST_CAST_VECTOR(float64m2) 596 597 TEST_CAST_VECTOR(int8m4) 598 TEST_CAST_VECTOR(int16m4) 599 TEST_CAST_VECTOR(int32m4) 600 TEST_CAST_VECTOR(int64m4) 601 TEST_CAST_VECTOR(uint8m4) 602 TEST_CAST_VECTOR(uint16m4) 603 TEST_CAST_VECTOR(uint32m4) 604 TEST_CAST_VECTOR(uint64m4) 605 TEST_CAST_VECTOR(float32m4) 606 TEST_CAST_VECTOR(float64m4) 607 608 TEST_CAST_VECTOR(int8m8) 609 TEST_CAST_VECTOR(int16m8) 610 TEST_CAST_VECTOR(int32m8) 611 TEST_CAST_VECTOR(int64m8) 612 TEST_CAST_VECTOR(uint8m8) 613 TEST_CAST_VECTOR(uint16m8) 614 TEST_CAST_VECTOR(uint32m8) 615 TEST_CAST_VECTOR(uint64m8) 616 TEST_CAST_VECTOR(float32m8) 617 TEST_CAST_VECTOR(float64m8) 618 619 TEST_CAST_COMMON(bool1); 620 TEST_CAST_COMMON(bool2); 621 TEST_CAST_COMMON(bool4); 622 TEST_CAST_COMMON(bool8); 623 #if __riscv_v_fixed_vlen / 16 >= 8 624 TEST_CAST_COMMON(bool16); 625 #endif 626 #if __riscv_v_fixed_vlen / 32 >= 8 627 TEST_CAST_COMMON(bool32); 628 #endif 629 #if __riscv_v_fixed_vlen / 64 >= 8 630 TEST_CAST_COMMON(bool64); 631 #endif 632 633 // Test conversion between mask and uint8 is invalid, both have the same 634 // memory representation. 635 fixed_bool1_t to_fixed_bool1_t__from_vuint8m1_t(vuint8m1_t x) { return x; } // expected-error-re {{returning 'vuint8m1_t' (aka '__rvv_uint8m1_t') from a function with incompatible result type 'fixed_bool1_t' (vector of {{[0-9]+}} 'unsigned char' values)}} 636 637 // --------------------------------------------------------------------------// 638 639 // --------------------------------------------------------------------------// 640 // Test the scalable and fixed-length types can be used interchangeably 641 642 vint32m1_t __attribute__((overloadable)) vfunc(vint32m1_t op1, vint32m1_t op2); 643 vfloat64m1_t __attribute__((overloadable)) vfunc(vfloat64m1_t op1, vfloat64m1_t op2); 644 645 vint32m2_t __attribute__((overloadable)) vfunc(vint32m2_t op1, vint32m2_t op2); 646 vfloat64m2_t __attribute__((overloadable)) vfunc(vfloat64m2_t op1, vfloat64m2_t op2); 647 648 vint32m4_t __attribute__((overloadable)) vfunc(vint32m4_t op1, vint32m4_t op2); 649 vfloat64m4_t __attribute__((overloadable)) vfunc(vfloat64m4_t op1, vfloat64m4_t op2); 650 651 vint32m8_t __attribute__((overloadable)) vfunc(vint32m8_t op1, vint32m8_t op2); 652 vfloat64m8_t __attribute__((overloadable)) vfunc(vfloat64m8_t op1, vfloat64m8_t op2); 653 654 vbool1_t __attribute__((overloadable)) vfunc(vbool1_t op1, vbool1_t op2); 655 vbool2_t __attribute__((overloadable)) vfunc(vbool2_t op1, vbool2_t op2); 656 vbool4_t __attribute__((overloadable)) vfunc(vbool4_t op1, vbool4_t op2); 657 vbool8_t __attribute__((overloadable)) vfunc(vbool8_t op1, vbool8_t op2); 658 vbool16_t __attribute__((overloadable)) vfunc(vbool16_t op1, vbool16_t op2); 659 vbool32_t __attribute__((overloadable)) vfunc(vbool32_t op1, vbool32_t op2); 660 vbool64_t __attribute__((overloadable)) vfunc(vbool64_t op1, vbool64_t op2); 661 662 #define TEST_CALL(TYPE) \ 663 fixed_##TYPE##_t \ 664 call_##TYPE##_ff(fixed_##TYPE##_t op1, fixed_##TYPE##_t op2) { \ 665 return vfunc(op1, op2); \ 666 } \ 667 fixed_##TYPE##_t \ 668 call_##TYPE##_fs(fixed_##TYPE##_t op1, v##TYPE##_t op2) { \ 669 return vfunc(op1, op2); \ 670 } \ 671 fixed_##TYPE##_t \ 672 call_##TYPE##_sf(v##TYPE##_t op1, fixed_##TYPE##_t op2) { \ 673 return vfunc(op1, op2); \ 674 } 675 676 TEST_CALL(int32m1) 677 TEST_CALL(float64m1) 678 679 TEST_CALL(int32m2) 680 TEST_CALL(float64m2) 681 682 TEST_CALL(int32m4) 683 TEST_CALL(float64m4) 684 685 TEST_CALL(int32m8) 686 TEST_CALL(float64m8) 687 688 TEST_CALL(bool1) 689 TEST_CALL(bool2) 690 TEST_CALL(bool4) 691 TEST_CALL(bool8) 692 #if __riscv_v_fixed_vlen / 16 >= 8 693 TEST_CALL(bool16) 694 #endif 695 #if __riscv_v_fixed_vlen / 32 >= 8 696 TEST_CALL(bool32) 697 #endif 698 #if __riscv_v_fixed_vlen / 64 >= 8 699 TEST_CALL(bool64) 700 #endif 701 702 // --------------------------------------------------------------------------// 703 // Vector initialization 704 705 #if __riscv_v_fixed_vlen == 256 706 707 typedef vint32m1_t int32x8 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); 708 typedef vfloat64m1_t float64x4 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); 709 710 typedef vint32m2_t int32x16 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2))); 711 typedef vfloat64m2_t float64x8 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2))); 712 713 typedef vint32m4_t int32x32 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4))); 714 typedef vfloat64m4_t float64x16 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4))); 715 716 typedef vint32m8_t int32x64 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8))); 717 typedef vfloat64m8_t float64x32 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8))); 718 719 int32x8 foo = {1, 2, 3, 4, 5, 6, 7, 8}; 720 int32x8 foo2 = {1, 2, 3, 4, 5, 6, 7, 8, 9}; // expected-warning{{excess elements in vector initializer}} 721 722 float64x4 bar = {1.0, 2.0, 3.0, 4.0}; 723 float64x4 bar2 = {1.0, 2.0, 3.0, 4.0, 5.0}; // expected-warning{{excess elements in vector initializer}} 724 725 int32x16 foom2 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; 726 int32x16 foo2m2 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; // expected-warning{{excess elements in vector initializer}} 727 728 float64x8 barm2 = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0}; 729 float64x8 bar2m2 = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; // expected-warning{{excess elements in vector initializer}} 730 731 int32x32 foom4 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 732 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 733 32}; 734 int32x32 foo2m4 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 735 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 736 32, 33}; // expected-warning{{excess elements in vector initializer}} 737 738 float64x16 barm4 = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 739 12.0, 13.0, 14.0, 15.0, 16.0}; 740 float64x16 bar2m4 = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 741 12.0, 13.0, 14.0, 15.0, 16.0, 17.0}; // expected-warning{{excess elements in vector initializer}} 742 743 int32x64 foom8 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 744 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 745 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 746 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 747 64}; 748 int32x64 foo2m8 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 749 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 750 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 751 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 752 63, 64, 65}; // expected-warning{{excess elements in vector initializer}} 753 754 float64x32 barm8 = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 755 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 756 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 757 32.0}; 758 float64x32 bar2m8 = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 759 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 760 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 761 32.0, 33.0}; // expected-warning{{excess elements in vector initializer}} 762 #endif 763 764 // --------------------------------------------------------------------------// 765 // Vector ops 766 767 #define TEST_BINARY(TYPE, NAME, OP) \ 768 TYPE NAME##_##TYPE(TYPE op1, TYPE op2) { \ 769 return op1 OP op2; \ 770 } \ 771 TYPE compound##NAME##_##TYPE(TYPE op1, TYPE op2) { \ 772 op1 OP##= op2; \ 773 return op1; \ 774 } 775 776 #define TEST_COMPARISON(TYPE, NAME, OP) \ 777 TYPE NAME##_##TYPE(TYPE op1, TYPE op2) { \ 778 return op1 OP op2; \ 779 } 780 781 #define TEST_UNARY(TYPE, NAME, OP) \ 782 TYPE NAME##_##TYPE(TYPE op1) { \ 783 return OP op1; \ 784 } 785 786 #define TEST_OPS(TYPE) \ 787 TEST_BINARY(TYPE, add, +) \ 788 TEST_BINARY(TYPE, sub, -) \ 789 TEST_BINARY(TYPE, mul, *) \ 790 TEST_BINARY(TYPE, div, /) \ 791 TEST_COMPARISON(TYPE, eq, ==) \ 792 TEST_COMPARISON(TYPE, ne, !=) \ 793 TEST_COMPARISON(TYPE, lt, <) \ 794 TEST_COMPARISON(TYPE, gt, >) \ 795 TEST_COMPARISON(TYPE, lte, <=) \ 796 TEST_COMPARISON(TYPE, gte, >=) \ 797 TEST_UNARY(TYPE, nop, +) \ 798 TEST_UNARY(TYPE, neg, -) 799 800 #define TEST_INT_OPS(TYPE) \ 801 TEST_OPS(TYPE) \ 802 TEST_BINARY(TYPE, mod, %) \ 803 TEST_BINARY(TYPE, and, &) \ 804 TEST_BINARY(TYPE, or, |) \ 805 TEST_BINARY(TYPE, xor, ^) \ 806 TEST_BINARY(TYPE, shl, <<) \ 807 TEST_BINARY(TYPE, shr, <<) \ 808 TEST_UNARY(TYPE, not, ~) 809 810 TEST_INT_OPS(fixed_int8mf8_t) 811 TEST_INT_OPS(fixed_uint8mf8_t) 812 813 TEST_INT_OPS(fixed_int8mf4_t) 814 TEST_INT_OPS(fixed_int16mf4_t) 815 TEST_INT_OPS(fixed_uint8mf4_t) 816 TEST_INT_OPS(fixed_uint16mf4_t) 817 818 TEST_INT_OPS(fixed_int8mf2_t) 819 TEST_INT_OPS(fixed_int16mf2_t) 820 TEST_INT_OPS(fixed_int32mf2_t) 821 TEST_INT_OPS(fixed_uint8mf2_t) 822 TEST_INT_OPS(fixed_uint16mf2_t) 823 TEST_INT_OPS(fixed_uint32mf2_t) 824 825 TEST_OPS(fixed_float32mf2_t) 826 827 TEST_INT_OPS(fixed_int8m1_t) 828 TEST_INT_OPS(fixed_int16m1_t) 829 TEST_INT_OPS(fixed_int32m1_t) 830 TEST_INT_OPS(fixed_int64m1_t) 831 TEST_INT_OPS(fixed_uint8m1_t) 832 TEST_INT_OPS(fixed_uint16m1_t) 833 TEST_INT_OPS(fixed_uint32m1_t) 834 TEST_INT_OPS(fixed_uint64m1_t) 835 836 TEST_OPS(fixed_float32m1_t) 837 TEST_OPS(fixed_float64m1_t) 838 839 TEST_INT_OPS(fixed_int8m2_t) 840 TEST_INT_OPS(fixed_int16m2_t) 841 TEST_INT_OPS(fixed_int32m2_t) 842 TEST_INT_OPS(fixed_int64m2_t) 843 TEST_INT_OPS(fixed_uint8m2_t) 844 TEST_INT_OPS(fixed_uint16m2_t) 845 TEST_INT_OPS(fixed_uint32m2_t) 846 TEST_INT_OPS(fixed_uint64m2_t) 847 848 TEST_OPS(fixed_float32m2_t) 849 TEST_OPS(fixed_float64m2_t) 850 851 TEST_INT_OPS(fixed_int8m4_t) 852 TEST_INT_OPS(fixed_int16m4_t) 853 TEST_INT_OPS(fixed_int32m4_t) 854 TEST_INT_OPS(fixed_int64m4_t) 855 TEST_INT_OPS(fixed_uint8m4_t) 856 TEST_INT_OPS(fixed_uint16m4_t) 857 TEST_INT_OPS(fixed_uint32m4_t) 858 TEST_INT_OPS(fixed_uint64m4_t) 859 860 TEST_OPS(fixed_float32m4_t) 861 TEST_OPS(fixed_float64m4_t) 862 863 TEST_INT_OPS(fixed_int8m8_t) 864 TEST_INT_OPS(fixed_int16m8_t) 865 TEST_INT_OPS(fixed_int32m8_t) 866 TEST_INT_OPS(fixed_int64m8_t) 867 TEST_INT_OPS(fixed_uint8m8_t) 868 TEST_INT_OPS(fixed_uint16m8_t) 869 TEST_INT_OPS(fixed_uint32m8_t) 870 TEST_INT_OPS(fixed_uint64m8_t) 871 872 TEST_OPS(fixed_float32m8_t) 873 TEST_OPS(fixed_float64m8_t) 874