874 lines · c
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 %s2// 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 %s3// 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 %s4// 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 %s5// 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 %s6 7#include <stdint.h>8 9typedef __rvv_bool64_t vbool64_t;10typedef __rvv_bool32_t vbool32_t;11typedef __rvv_bool16_t vbool16_t;12typedef __rvv_bool8_t vbool8_t;13typedef __rvv_bool4_t vbool4_t;14typedef __rvv_bool2_t vbool2_t;15typedef __rvv_bool1_t vbool1_t;16 17typedef __rvv_int8mf8_t vint8mf8_t;18typedef __rvv_uint8mf8_t vuint8mf8_t;19 20typedef __rvv_int8mf4_t vint8mf4_t;21typedef __rvv_uint8mf4_t vuint8mf4_t;22typedef __rvv_int16mf4_t vint16mf4_t;23typedef __rvv_uint16mf4_t vuint16mf4_t;24 25typedef __rvv_int8mf2_t vint8mf2_t;26typedef __rvv_uint8mf2_t vuint8mf2_t;27typedef __rvv_int16mf2_t vint16mf2_t;28typedef __rvv_uint16mf2_t vuint16mf2_t;29typedef __rvv_int32mf2_t vint32mf2_t;30typedef __rvv_uint32mf2_t vuint32mf2_t;31typedef __rvv_float32mf2_t vfloat32mf2_t;32 33typedef __rvv_int8m1_t vint8m1_t;34typedef __rvv_uint8m1_t vuint8m1_t;35typedef __rvv_int16m1_t vint16m1_t;36typedef __rvv_uint16m1_t vuint16m1_t;37typedef __rvv_int32m1_t vint32m1_t;38typedef __rvv_uint32m1_t vuint32m1_t;39typedef __rvv_int64m1_t vint64m1_t;40typedef __rvv_uint64m1_t vuint64m1_t;41typedef __rvv_float32m1_t vfloat32m1_t;42typedef __rvv_float64m1_t vfloat64m1_t;43 44typedef __rvv_int8m2_t vint8m2_t;45typedef __rvv_uint8m2_t vuint8m2_t;46typedef __rvv_int16m2_t vint16m2_t;47typedef __rvv_uint16m2_t vuint16m2_t;48typedef __rvv_int32m2_t vint32m2_t;49typedef __rvv_uint32m2_t vuint32m2_t;50typedef __rvv_int64m2_t vint64m2_t;51typedef __rvv_uint64m2_t vuint64m2_t;52typedef __rvv_float32m2_t vfloat32m2_t;53typedef __rvv_float64m2_t vfloat64m2_t;54 55typedef __rvv_int8m4_t vint8m4_t;56typedef __rvv_uint8m4_t vuint8m4_t;57typedef __rvv_int16m4_t vint16m4_t;58typedef __rvv_uint16m4_t vuint16m4_t;59typedef __rvv_int32m4_t vint32m4_t;60typedef __rvv_uint32m4_t vuint32m4_t;61typedef __rvv_int64m4_t vint64m4_t;62typedef __rvv_uint64m4_t vuint64m4_t;63typedef __rvv_float32m4_t vfloat32m4_t;64typedef __rvv_float64m4_t vfloat64m4_t;65 66typedef __rvv_int8m8_t vint8m8_t;67typedef __rvv_uint8m8_t vuint8m8_t;68typedef __rvv_int16m8_t vint16m8_t;69typedef __rvv_uint16m8_t vuint16m8_t;70typedef __rvv_int32m8_t vint32m8_t;71typedef __rvv_uint32m8_t vuint32m8_t;72typedef __rvv_int64m8_t vint64m8_t;73typedef __rvv_uint64m8_t vuint64m8_t;74typedef __rvv_float32m8_t vfloat32m8_t;75typedef __rvv_float64m8_t vfloat64m8_t;76 77// Define valid fixed-width RVV types78typedef vint8mf8_t fixed_int8mf8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 8)));79 80typedef vuint8mf8_t fixed_uint8mf8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 8)));81 82typedef vint8mf4_t fixed_int8mf4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4)));83typedef vint16mf4_t fixed_int16mf4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4)));84 85typedef vuint8mf4_t fixed_uint8mf4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4)));86typedef vuint16mf4_t fixed_uint16mf4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4)));87 88typedef vint8mf2_t fixed_int8mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2)));89typedef vint16mf2_t fixed_int16mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2)));90typedef vint32mf2_t fixed_int32mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2)));91 92typedef vuint8mf2_t fixed_uint8mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2)));93typedef vuint16mf2_t fixed_uint16mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2)));94typedef vuint32mf2_t fixed_uint32mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2)));95 96typedef vfloat32mf2_t fixed_float32mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2)));97 98typedef vint8m1_t fixed_int8m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));99typedef vint16m1_t fixed_int16m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));100typedef vint32m1_t fixed_int32m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));101typedef vint64m1_t fixed_int64m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));102 103typedef vuint8m1_t fixed_uint8m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));104typedef vuint16m1_t fixed_uint16m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));105typedef vuint32m1_t fixed_uint32m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));106typedef vuint64m1_t fixed_uint64m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));107 108typedef vfloat32m1_t fixed_float32m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));109typedef vfloat64m1_t fixed_float64m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));110 111typedef vint8m2_t fixed_int8m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));112typedef vint16m2_t fixed_int16m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));113typedef vint32m2_t fixed_int32m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));114typedef vint64m2_t fixed_int64m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));115 116typedef vuint8m2_t fixed_uint8m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));117typedef vuint16m2_t fixed_uint16m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));118typedef vuint32m2_t fixed_uint32m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));119typedef vuint64m2_t fixed_uint64m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));120 121typedef vfloat32m2_t fixed_float32m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));122typedef vfloat64m2_t fixed_float64m2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));123 124typedef vint8m4_t fixed_int8m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));125typedef vint16m4_t fixed_int16m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));126typedef vint32m4_t fixed_int32m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));127typedef vint64m4_t fixed_int64m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));128 129typedef vuint8m4_t fixed_uint8m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));130typedef vuint16m4_t fixed_uint16m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));131typedef vuint32m4_t fixed_uint32m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));132typedef vuint64m4_t fixed_uint64m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));133 134typedef vfloat32m4_t fixed_float32m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));135typedef vfloat64m4_t fixed_float64m4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));136 137typedef vint8m8_t fixed_int8m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));138typedef vint16m8_t fixed_int16m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));139typedef vint32m8_t fixed_int32m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));140typedef vint64m8_t fixed_int64m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));141 142typedef vuint8m8_t fixed_uint8m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));143typedef vuint16m8_t fixed_uint16m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));144typedef vuint32m8_t fixed_uint32m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));145typedef vuint64m8_t fixed_uint64m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));146 147typedef vfloat32m8_t fixed_float32m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));148typedef vfloat64m8_t fixed_float64m8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));149 150// GNU vector types151typedef int8_t gnu_int8mf8_t __attribute__((vector_size(__riscv_v_fixed_vlen / 64)));152 153typedef uint8_t gnu_uint8mf8_t __attribute__((vector_size(__riscv_v_fixed_vlen / 64)));154 155typedef int8_t gnu_int8mf4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 32)));156typedef int16_t gnu_int16mf4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 32)));157 158typedef uint8_t gnu_uint8mf4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 32)));159typedef uint16_t gnu_uint16mf4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 32)));160 161typedef int8_t gnu_int8mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16)));162typedef int16_t gnu_int16mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16)));163typedef int32_t gnu_int32mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16)));164 165typedef uint8_t gnu_uint8mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16)));166typedef uint16_t gnu_uint16mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16)));167typedef uint32_t gnu_uint32mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16)));168 169typedef float gnu_float32mf2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 16)));170 171typedef int8_t gnu_int8m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));172typedef int16_t gnu_int16m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));173typedef int32_t gnu_int32m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));174typedef int64_t gnu_int64m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));175 176typedef uint8_t gnu_uint8m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));177typedef uint16_t gnu_uint16m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));178typedef uint32_t gnu_uint32m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));179typedef uint64_t gnu_uint64m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));180 181typedef float gnu_float32m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));182typedef double gnu_float64m1_t __attribute__((vector_size(__riscv_v_fixed_vlen / 8)));183 184typedef int8_t gnu_int8m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));185typedef int16_t gnu_int16m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));186typedef int32_t gnu_int32m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));187typedef int64_t gnu_int64m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));188 189typedef uint8_t gnu_uint8m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));190typedef uint16_t gnu_uint16m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));191typedef uint32_t gnu_uint32m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));192typedef uint64_t gnu_uint64m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));193 194typedef float gnu_float32m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));195typedef double gnu_float64m2_t __attribute__((vector_size(__riscv_v_fixed_vlen / 4)));196 197typedef int8_t gnu_int8m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));198typedef int16_t gnu_int16m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));199typedef int32_t gnu_int32m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));200typedef int64_t gnu_int64m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));201 202typedef uint8_t gnu_uint8m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));203typedef uint16_t gnu_uint16m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));204typedef uint32_t gnu_uint32m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));205typedef uint64_t gnu_uint64m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));206 207typedef float gnu_float32m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));208typedef double gnu_float64m4_t __attribute__((vector_size(__riscv_v_fixed_vlen / 2)));209 210typedef int8_t gnu_int8m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));211typedef int16_t gnu_int16m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));212typedef int32_t gnu_int32m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));213typedef int64_t gnu_int64m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));214 215typedef uint8_t gnu_uint8m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));216typedef uint16_t gnu_uint16m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));217typedef uint32_t gnu_uint32m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));218typedef uint64_t gnu_uint64m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));219 220typedef float gnu_float32m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));221typedef double gnu_float64m8_t __attribute__((vector_size(__riscv_v_fixed_vlen)));222 223// Attribute must have a single argument224typedef vint8m1_t no_argument __attribute__((riscv_rvv_vector_bits)); // expected-error {{'riscv_rvv_vector_bits' attribute takes one argument}}225typedef 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 expression228typedef vint8m1_t non_int_size1 __attribute__((riscv_rvv_vector_bits(2.0))); // expected-error {{'riscv_rvv_vector_bits' attribute requires an integer constant}}229typedef vint8m1_t non_int_size2 __attribute__((riscv_rvv_vector_bits("256"))); // expected-error {{'riscv_rvv_vector_bits' attribute requires an integer constant}}230 231typedef vbool1_t fixed_bool1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));232typedef vbool2_t fixed_bool2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2)));233typedef vbool4_t fixed_bool4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4)));234typedef vbool8_t fixed_bool8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 8)));235typedef vbool16_t fixed_bool16_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 16)));236typedef vbool32_t fixed_bool32_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 32)));237typedef 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.240typedef void *badtype1 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); // expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 'void *'}}241typedef int badtype2 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); // expected-error {{'riscv_rvv_vector_bits' attribute applied to non-RVV type 'int'}}242typedef 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.245vint8m1_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 for248// sizeless types).249fixed_int8m1_t global_int8;250fixed_bool1_t global_bool1;251 252extern fixed_int8m1_t extern_int8;253extern fixed_bool1_t extern_bool1;254 255static fixed_int8m1_t static_int8;256static fixed_bool1_t static_bool1;257 258fixed_int8m1_t *global_int8_ptr;259extern fixed_int8m1_t *extern_int8_ptr;260static fixed_int8m1_t *static_int8_ptr;261__thread fixed_int8m1_t thread_int8;262 263typedef fixed_int8m1_t int8_typedef;264typedef fixed_int8m1_t *int8_ptr_typedef;265 266// Test sized expressions267int sizeof_int8 = sizeof(global_int8);268int sizeof_int8_var = sizeof(*global_int8_ptr);269int sizeof_int8_var_ptr = sizeof(global_int8_ptr);270 271extern fixed_int8m1_t *extern_int8_ptr;272 273int alignof_int8 = __alignof__(extern_int8);274int alignof_int8_var = __alignof__(*extern_int8_ptr);275int alignof_int8_var_ptr = __alignof__(extern_int8_ptr);276 277void 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 are283 // 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// Sizeof334 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 >= 8414_Static_assert(sizeof(fixed_bool16_t) == VECTOR_SIZE / 16, "");415#else416_Static_assert(sizeof(fixed_bool16_t) == 1, "");417#endif418#if __riscv_v_fixed_vlen / 32 >= 8419_Static_assert(sizeof(fixed_bool32_t) == VECTOR_SIZE / 32, "");420#else421_Static_assert(sizeof(fixed_bool32_t) == 1, "");422#endif423#if __riscv_v_fixed_vlen / 64 >= 8424_Static_assert(sizeof(fixed_bool64_t) == VECTOR_SIZE / 64, "");425#else426_Static_assert(sizeof(fixed_bool64_t) == 1, "");427#endif428 429// --------------------------------------------------------------------------//430// Alignof431 432#define VECTOR_ALIGN 8433 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// Structs516 517struct struct_int64 { fixed_int64m1_t x, y[5]; };518struct struct_float64 { fixed_float64m1_t x, y[5]; };519 520struct struct_int64m2 { fixed_int64m2_t x, y[5]; };521struct struct_float64m2 { fixed_float64m2_t x, y[5]; };522 523struct struct_int64m4 { fixed_int64m4_t x, y[5]; };524struct struct_float64m4 { fixed_float64m4_t x, y[5]; };525 526struct struct_int64m8 { fixed_int64m8_t x, y[5]; };527struct struct_float64m8 { fixed_float64m8_t x, y[5]; };528 529// --------------------------------------------------------------------------//530// Unions531union union_int64 { fixed_int64m1_t x, y[5]; };532union union_float64 { fixed_float64m1_t x, y[5]; };533 534union union_int64m2 { fixed_int64m2_t x, y[5]; };535union union_float64m2 { fixed_float64m2_t x, y[5]; };536 537union union_int64m4 { fixed_int64m4_t x, y[5]; };538union union_float64m4 { fixed_float64m4_t x, y[5]; };539 540union union_int64m8 { fixed_int64m8_t x, y[5]; };541union union_float64m8 { fixed_float64m8_t x, y[5]; };542 543// --------------------------------------------------------------------------//544// Implicit casts545 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 559TEST_CAST_VECTOR(int8mf8)560TEST_CAST_VECTOR(uint8mf8)561 562TEST_CAST_VECTOR(int8mf4)563TEST_CAST_VECTOR(int16mf4)564TEST_CAST_VECTOR(uint8mf4)565TEST_CAST_VECTOR(uint16mf4)566 567TEST_CAST_VECTOR(int8mf2)568TEST_CAST_VECTOR(int16mf2)569TEST_CAST_VECTOR(int32mf2)570TEST_CAST_VECTOR(uint8mf2)571TEST_CAST_VECTOR(uint16mf2)572TEST_CAST_VECTOR(uint32mf2)573TEST_CAST_VECTOR(float32mf2)574 575TEST_CAST_VECTOR(int8m1)576TEST_CAST_VECTOR(int16m1)577TEST_CAST_VECTOR(int32m1)578TEST_CAST_VECTOR(int64m1)579TEST_CAST_VECTOR(uint8m1)580TEST_CAST_VECTOR(uint16m1)581TEST_CAST_VECTOR(uint32m1)582TEST_CAST_VECTOR(uint64m1)583TEST_CAST_VECTOR(float32m1)584TEST_CAST_VECTOR(float64m1)585 586TEST_CAST_VECTOR(int8m2)587TEST_CAST_VECTOR(int16m2)588TEST_CAST_VECTOR(int32m2)589TEST_CAST_VECTOR(int64m2)590TEST_CAST_VECTOR(uint8m2)591TEST_CAST_VECTOR(uint16m2)592TEST_CAST_VECTOR(uint32m2)593TEST_CAST_VECTOR(uint64m2)594TEST_CAST_VECTOR(float32m2)595TEST_CAST_VECTOR(float64m2)596 597TEST_CAST_VECTOR(int8m4)598TEST_CAST_VECTOR(int16m4)599TEST_CAST_VECTOR(int32m4)600TEST_CAST_VECTOR(int64m4)601TEST_CAST_VECTOR(uint8m4)602TEST_CAST_VECTOR(uint16m4)603TEST_CAST_VECTOR(uint32m4)604TEST_CAST_VECTOR(uint64m4)605TEST_CAST_VECTOR(float32m4)606TEST_CAST_VECTOR(float64m4)607 608TEST_CAST_VECTOR(int8m8)609TEST_CAST_VECTOR(int16m8)610TEST_CAST_VECTOR(int32m8)611TEST_CAST_VECTOR(int64m8)612TEST_CAST_VECTOR(uint8m8)613TEST_CAST_VECTOR(uint16m8)614TEST_CAST_VECTOR(uint32m8)615TEST_CAST_VECTOR(uint64m8)616TEST_CAST_VECTOR(float32m8)617TEST_CAST_VECTOR(float64m8)618 619TEST_CAST_COMMON(bool1);620TEST_CAST_COMMON(bool2);621TEST_CAST_COMMON(bool4);622TEST_CAST_COMMON(bool8);623#if __riscv_v_fixed_vlen / 16 >= 8624TEST_CAST_COMMON(bool16);625#endif626#if __riscv_v_fixed_vlen / 32 >= 8627TEST_CAST_COMMON(bool32);628#endif629#if __riscv_v_fixed_vlen / 64 >= 8630TEST_CAST_COMMON(bool64);631#endif632 633// Test conversion between mask and uint8 is invalid, both have the same634// memory representation.635fixed_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 interchangeably641 642vint32m1_t __attribute__((overloadable)) vfunc(vint32m1_t op1, vint32m1_t op2);643vfloat64m1_t __attribute__((overloadable)) vfunc(vfloat64m1_t op1, vfloat64m1_t op2);644 645vint32m2_t __attribute__((overloadable)) vfunc(vint32m2_t op1, vint32m2_t op2);646vfloat64m2_t __attribute__((overloadable)) vfunc(vfloat64m2_t op1, vfloat64m2_t op2);647 648vint32m4_t __attribute__((overloadable)) vfunc(vint32m4_t op1, vint32m4_t op2);649vfloat64m4_t __attribute__((overloadable)) vfunc(vfloat64m4_t op1, vfloat64m4_t op2);650 651vint32m8_t __attribute__((overloadable)) vfunc(vint32m8_t op1, vint32m8_t op2);652vfloat64m8_t __attribute__((overloadable)) vfunc(vfloat64m8_t op1, vfloat64m8_t op2);653 654vbool1_t __attribute__((overloadable)) vfunc(vbool1_t op1, vbool1_t op2);655vbool2_t __attribute__((overloadable)) vfunc(vbool2_t op1, vbool2_t op2);656vbool4_t __attribute__((overloadable)) vfunc(vbool4_t op1, vbool4_t op2);657vbool8_t __attribute__((overloadable)) vfunc(vbool8_t op1, vbool8_t op2);658vbool16_t __attribute__((overloadable)) vfunc(vbool16_t op1, vbool16_t op2);659vbool32_t __attribute__((overloadable)) vfunc(vbool32_t op1, vbool32_t op2);660vbool64_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 676TEST_CALL(int32m1)677TEST_CALL(float64m1)678 679TEST_CALL(int32m2)680TEST_CALL(float64m2)681 682TEST_CALL(int32m4)683TEST_CALL(float64m4)684 685TEST_CALL(int32m8)686TEST_CALL(float64m8)687 688TEST_CALL(bool1)689TEST_CALL(bool2)690TEST_CALL(bool4)691TEST_CALL(bool8)692#if __riscv_v_fixed_vlen / 16 >= 8693TEST_CALL(bool16)694#endif695#if __riscv_v_fixed_vlen / 32 >= 8696TEST_CALL(bool32)697#endif698#if __riscv_v_fixed_vlen / 64 >= 8699TEST_CALL(bool64)700#endif701 702// --------------------------------------------------------------------------//703// Vector initialization704 705#if __riscv_v_fixed_vlen == 256706 707typedef vint32m1_t int32x8 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));708typedef vfloat64m1_t float64x4 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));709 710typedef vint32m2_t int32x16 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));711typedef vfloat64m2_t float64x8 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 2)));712 713typedef vint32m4_t int32x32 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));714typedef vfloat64m4_t float64x16 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 4)));715 716typedef vint32m8_t int32x64 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));717typedef vfloat64m8_t float64x32 __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen * 8)));718 719int32x8 foo = {1, 2, 3, 4, 5, 6, 7, 8};720int32x8 foo2 = {1, 2, 3, 4, 5, 6, 7, 8, 9}; // expected-warning{{excess elements in vector initializer}}721 722float64x4 bar = {1.0, 2.0, 3.0, 4.0};723float64x4 bar2 = {1.0, 2.0, 3.0, 4.0, 5.0}; // expected-warning{{excess elements in vector initializer}}724 725int32x16 foom2 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};726int32x16 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 728float64x8 barm2 = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0};729float64x8 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 731int32x32 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};734int32x32 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 738float64x16 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};740float64x16 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 743int32x64 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};748int32x64 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 754float64x32 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};758float64x32 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#endif763 764// --------------------------------------------------------------------------//765// Vector ops766 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 810TEST_INT_OPS(fixed_int8mf8_t)811TEST_INT_OPS(fixed_uint8mf8_t)812 813TEST_INT_OPS(fixed_int8mf4_t)814TEST_INT_OPS(fixed_int16mf4_t)815TEST_INT_OPS(fixed_uint8mf4_t)816TEST_INT_OPS(fixed_uint16mf4_t)817 818TEST_INT_OPS(fixed_int8mf2_t)819TEST_INT_OPS(fixed_int16mf2_t)820TEST_INT_OPS(fixed_int32mf2_t)821TEST_INT_OPS(fixed_uint8mf2_t)822TEST_INT_OPS(fixed_uint16mf2_t)823TEST_INT_OPS(fixed_uint32mf2_t)824 825TEST_OPS(fixed_float32mf2_t)826 827TEST_INT_OPS(fixed_int8m1_t)828TEST_INT_OPS(fixed_int16m1_t)829TEST_INT_OPS(fixed_int32m1_t)830TEST_INT_OPS(fixed_int64m1_t)831TEST_INT_OPS(fixed_uint8m1_t)832TEST_INT_OPS(fixed_uint16m1_t)833TEST_INT_OPS(fixed_uint32m1_t)834TEST_INT_OPS(fixed_uint64m1_t)835 836TEST_OPS(fixed_float32m1_t)837TEST_OPS(fixed_float64m1_t)838 839TEST_INT_OPS(fixed_int8m2_t)840TEST_INT_OPS(fixed_int16m2_t)841TEST_INT_OPS(fixed_int32m2_t)842TEST_INT_OPS(fixed_int64m2_t)843TEST_INT_OPS(fixed_uint8m2_t)844TEST_INT_OPS(fixed_uint16m2_t)845TEST_INT_OPS(fixed_uint32m2_t)846TEST_INT_OPS(fixed_uint64m2_t)847 848TEST_OPS(fixed_float32m2_t)849TEST_OPS(fixed_float64m2_t)850 851TEST_INT_OPS(fixed_int8m4_t)852TEST_INT_OPS(fixed_int16m4_t)853TEST_INT_OPS(fixed_int32m4_t)854TEST_INT_OPS(fixed_int64m4_t)855TEST_INT_OPS(fixed_uint8m4_t)856TEST_INT_OPS(fixed_uint16m4_t)857TEST_INT_OPS(fixed_uint32m4_t)858TEST_INT_OPS(fixed_uint64m4_t)859 860TEST_OPS(fixed_float32m4_t)861TEST_OPS(fixed_float64m4_t)862 863TEST_INT_OPS(fixed_int8m8_t)864TEST_INT_OPS(fixed_int16m8_t)865TEST_INT_OPS(fixed_int32m8_t)866TEST_INT_OPS(fixed_int64m8_t)867TEST_INT_OPS(fixed_uint8m8_t)868TEST_INT_OPS(fixed_uint16m8_t)869TEST_INT_OPS(fixed_uint32m8_t)870TEST_INT_OPS(fixed_uint64m8_t)871 872TEST_OPS(fixed_float32m8_t)873TEST_OPS(fixed_float64m8_t)874