brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.6 KiB · b419ba3 Raw
124 lines · c
1// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -flax-vector-conversions=all -Werror -emit-llvm -o - %s | FileCheck %s2// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -flax-vector-conversions=all -verify -fsyntax-only -DERROR_CHECK %s3 4typedef   signed short      int16_t;5typedef   signed int        int32_t;6typedef   signed long long  int64_t;7typedef unsigned short     uint16_t;8typedef unsigned int       uint32_t;9typedef unsigned long long uint64_t;10 11typedef __attribute__((neon_vector_type(8), __clang_arm_mve_strict_polymorphism))  int16_t  int16x8_t;12typedef __attribute__((neon_vector_type(4), __clang_arm_mve_strict_polymorphism))  int32_t  int32x4_t;13typedef __attribute__((neon_vector_type(2), __clang_arm_mve_strict_polymorphism))  int64_t  int64x2_t;14typedef __attribute__((neon_vector_type(8), __clang_arm_mve_strict_polymorphism)) uint16_t uint16x8_t;15typedef __attribute__((neon_vector_type(4), __clang_arm_mve_strict_polymorphism)) uint32_t uint32x4_t;16typedef __attribute__((neon_vector_type(2), __clang_arm_mve_strict_polymorphism)) uint64_t uint64x2_t;17 18// Verify that we can use the [[]] spelling of the attribute.19// We intentionally use the same type alias name to check that both versions20// define the same type.21typedef int16_t [[clang::neon_vector_type(8), clang::__clang_arm_mve_strict_polymorphism]] int16x8_t;22 23// Verify that we can use the attribute outside of a typedef.24void test_param(int16_t [[clang::neon_vector_type(8), clang::__clang_arm_mve_strict_polymorphism]] int16x8);25 26__attribute__((overloadable))27int overload(int16x8_t x, int16_t y); // expected-note {{candidate function}}28__attribute__((overloadable))29int overload(int32x4_t x, int32_t y); // expected-note {{candidate function}}30__attribute__((overloadable))31int overload(uint16x8_t x, uint16_t y); // expected-note {{candidate function}}32__attribute__((overloadable))33int overload(uint32x4_t x, uint32_t y); // expected-note {{candidate function}}34 35int16_t s16;36int32_t s32;37uint16_t u16;38uint32_t u32;39 40int16x8_t vs16;41int32x4_t vs32;42uint16x8_t vu16;43uint32x4_t vu32;44 45// ----------------------------------------------------------------------46// Simple cases where the types are correctly matched47 48// CHECK-LABEL: @test_easy_s16(49// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_int1650int test_easy_s16(void) { return overload(vs16, s16); }51 52// CHECK-LABEL: @test_easy_u16(53// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_uint1654int test_easy_u16(void) { return overload(vu16, u16); }55 56// CHECK-LABEL: @test_easy_s32(57// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_int3258int test_easy_s32(void) { return overload(vs32, s32); }59 60// CHECK-LABEL: @test_easy_u32(61// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_uint3262int test_easy_u32(void) { return overload(vu32, u32); }63 64// ----------------------------------------------------------------------65// Do arithmetic on the scalar, and it may get promoted. We still expect the66// same overloads to be selected if that happens.67 68// CHECK-LABEL: @test_promote_s16(69// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_int1670int test_promote_s16(void) { return overload(vs16, s16 + 1); }71 72// CHECK-LABEL: @test_promote_u16(73// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_uint1674int test_promote_u16(void) { return overload(vu16, u16 + 1); }75 76// CHECK-LABEL: @test_promote_s32(77// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_int3278int test_promote_s32(void) { return overload(vs32, s32 + 1); }79 80// CHECK-LABEL: @test_promote_u32(81// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_uint3282int test_promote_u32(void) { return overload(vu32, u32 + 1); }83 84// ----------------------------------------------------------------------85// Write a simple integer literal without qualification, and expect86// the vector type to make it unambiguous which integer type you meant87// the literal to be.88 89// CHECK-LABEL: @test_literal_s16(90// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_int1691int test_literal_s16(void) { return overload(vs16, 1); }92 93// CHECK-LABEL: @test_literal_u16(94// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_uint1695int test_literal_u16(void) { return overload(vu16, 1); }96 97// CHECK-LABEL: @test_literal_s32(98// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_int3299int test_literal_s32(void) { return overload(vs32, 1); }100 101// CHECK-LABEL: @test_literal_u32(102// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_uint32103int test_literal_u32(void) { return overload(vu32, 1); }104 105// ----------------------------------------------------------------------106// All of those overload resolutions are supposed to be unambiguous even when107// lax vector conversion is enabled. Check here that a lax conversion in a108// different context still works.109int16x8_t lax_conversion(void) { return vu32; }110 111// ----------------------------------------------------------------------112// Use a vector type that there really _isn't_ any overload for, and113// make sure that we get a fatal compile error.114 115#ifdef ERROR_CHECK116int expect_error(uint64x2_t v) {117  return overload(v, 2); // expected-error {{no matching function for call to 'overload'}}118}119 120typedef __attribute__((__clang_arm_mve_strict_polymorphism)) int i; // expected-error {{'__clang_arm_mve_strict_polymorphism' attribute can only be applied to an MVE/NEON vector type}}121typedef __attribute__((__clang_arm_mve_strict_polymorphism)) int f(void); // expected-error {{'__clang_arm_mve_strict_polymorphism' attribute can only be applied to an MVE/NEON vector type}}122typedef __attribute__((__clang_arm_mve_strict_polymorphism)) struct { uint16x8_t v; } s; // expected-error {{'__clang_arm_mve_strict_polymorphism' attribute can only be applied to an MVE/NEON vector type}}123#endif124