llvm-project/clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
David Green 123064dc39 [Clang][Arm] Convert -fallow-half-arguments-and-returns to a target option. NFC
This cc1 option -fallow-half-arguments-and-returns allows __fp16 to be
passed by argument and returned, without giving an error. It is
currently always enabled for Arm and AArch64, by forcing the option in
the driver. This means any cc1 tests (especially those needing
arm_neon.h) need to specify the option too, to prevent the error from
being emitted.

This changes it to a target option instead, set to true for Arm and
AArch64. This allows the option to be removed. Previously it was implied
by -fnative_half_arguments_and_returns, which is set for certain
languages like open_cl, renderscript and hlsl, so that option now too
controls the errors. There were are few other non-arm uses of
-fallow-half-arguments-and-returns but I believe they were unnecessary.
The strictfp_builtins.c tests were converted from __fp16 to _Float16 to
avoid the issues.

Differential Revision: https://reviews.llvm.org/D133885
2022-09-29 11:00:32 +01:00

55 lines
2.2 KiB
C++

// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=1 -mvscale-max=1 -flax-vector-conversions=none -ffreestanding -fsyntax-only -verify %s
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=2 -mvscale-max=2 -flax-vector-conversions=none -ffreestanding -fsyntax-only -verify %s
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=4 -mvscale-max=4 -flax-vector-conversions=none -ffreestanding -fsyntax-only -verify %s
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=8 -mvscale-max=8 -flax-vector-conversions=none -ffreestanding -fsyntax-only -verify %s
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=16 -mvscale-max=16 -flax-vector-conversions=none -ffreestanding -fsyntax-only -verify %s
// REQUIRES: aarch64-registered-target || arm-registered-target
// expected-no-diagnostics
#include <arm_sve.h>
#define N __ARM_FEATURE_SVE_BITS
#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
typedef svfloat32_t fixed_float32_t FIXED_ATTR;
typedef svfloat64_t fixed_float64_t FIXED_ATTR;
typedef svint32_t fixed_int32_t FIXED_ATTR;
typedef svint64_t fixed_int64_t FIXED_ATTR;
typedef svbool_t fixed_bool_t FIXED_ATTR;
// SVE VLSTs can be cast to SVE VLATs, regardless of lane size.
// NOTE: the list below is NOT exhaustive for all SVE types.
#define CAST(from, to) \
void from##_to_##to(from a, to b) { \
b = (to) a; \
}
#define TESTCASE(ty1, ty2) \
CAST(ty1, ty2) \
CAST(ty2, ty1)
TESTCASE(fixed_float32_t, svfloat32_t)
TESTCASE(fixed_float32_t, svfloat64_t)
TESTCASE(fixed_float32_t, svint32_t)
TESTCASE(fixed_float32_t, svint64_t)
TESTCASE(fixed_float64_t, svfloat32_t)
TESTCASE(fixed_float64_t, svfloat64_t)
TESTCASE(fixed_float64_t, svint32_t)
TESTCASE(fixed_float64_t, svint64_t)
TESTCASE(fixed_int32_t, svfloat32_t)
TESTCASE(fixed_int32_t, svfloat64_t)
TESTCASE(fixed_int32_t, svint32_t)
TESTCASE(fixed_int32_t, svint64_t)
TESTCASE(fixed_int64_t, svfloat32_t)
TESTCASE(fixed_int64_t, svfloat64_t)
TESTCASE(fixed_int64_t, svint32_t)
TESTCASE(fixed_int64_t, svint64_t)
TESTCASE(fixed_bool_t, svbool_t)