public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-6622] aarch64: Add bfloat16_t support for aarch64
@ 2023-03-12 23:17 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2023-03-12 23:17 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:13071c3c7d1baed8426bd054744de887eb82446d
commit r13-6622-g13071c3c7d1baed8426bd054744de887eb82446d
Author: Jakub Jelinek <jakub@redhat.com>
Date: Mon Mar 13 00:12:15 2023 +0100
aarch64: Add bfloat16_t support for aarch64
x86_64/i686 has for a few months working std::bfloat16_t support, __bf16
there is no longer a storage only type, but can be used for arithmetics
and is supported in libgcc and libstdc++.
The following patch adds similar support for AArch64.
Unlike the x86 changes, this one keeps the old __bf16 mangling of
u6__bf16 rather than DF16b (so an exception from Itanium ABI), but
otherwise __bf16 and decltype (0.0bf16) are the same type and both
in C++ act as extended floating-point type.
2023-03-13 Jakub Jelinek <jakub@redhat.com>
gcc/
* config/aarch64/aarch64.h (aarch64_bf16_type_node): Remove.
(aarch64_bf16_ptr_type_node): Adjust comment.
* config/aarch64/aarch64.cc (aarch64_gimplify_va_arg_expr): Use
bfloat16_type_node rather than aarch64_bf16_type_node.
(aarch64_libgcc_floating_mode_supported_p,
aarch64_scalar_mode_supported_p): Also support BFmode.
(aarch64_invalid_conversion, aarch64_invalid_unary_op): Remove.
(aarch64_invalid_binary_op): Remove BFmode related rejections.
(TARGET_INVALID_CONVERSION, TARGET_INVALID_UNARY_OP): Don't redefine.
* config/aarch64/aarch64-builtins.cc (aarch64_bf16_type_node): Remove.
(aarch64_int_or_fp_type): Use bfloat16_type_node rather than
aarch64_bf16_type_node.
(aarch64_init_simd_builtin_types): Likewise.
(aarch64_init_bf16_types): Likewise. Don't create bfloat16_type_node,
which is created in tree.cc already.
* config/aarch64/aarch64-sve-builtins.def (svbfloat16_t): Likewise.
gcc/testsuite/
* gcc.target/aarch64/sve/acle/general-c/ternary_bfloat16_opt_n_1.c:
Don't expect one __bf16 related error.
* gcc.target/aarch64/bfloat16_vector_typecheck_1.c: Adjust or remove
dg-error directives for __bf16 being an extended arithmetic type.
* gcc.target/aarch64/bfloat16_vector_typecheck_2.c: Likewise.
* gcc.target/aarch64/bfloat16_scalar_typecheck.c: Likewise.
* g++.target/aarch64/bfloat_cpp_typecheck.C: Don't expect two __bf16
related errors.
libgcc/
* config/aarch64/t-softfp (softfp_extensions): Add bfsf.
(softfp_truncations): Add tfbf dfbf sfbf hfbf.
(softfp_extras): Add floatdibf floatundibf floattibf floatuntibf.
* config/aarch64/libgcc-softfp.ver (GCC_13.0.0): Export
__extendbfsf2 and __trunc{s,d,t,h}fbf2.
* config/aarch64/sfp-machine.h (_FP_NANFRAC_B, _FP_NANSIGN_B): Define.
* soft-fp/floatundibf.c: New file.
* soft-fp/floatdibf.c: New file.
libstdc++-v3/
* config/abi/pre/gnu.ver (CXXABI_1.3.14): Also export __bf16 tinfos
if it isn't mangled as DF16b but u6__bf16.
Diff:
---
gcc/config/aarch64/aarch64-builtins.cc | 18 +-
gcc/config/aarch64/aarch64-sve-builtins.def | 2 +-
gcc/config/aarch64/aarch64.cc | 54 +-----
gcc/config/aarch64/aarch64.h | 5 +-
.../g++.target/aarch64/bfloat_cpp_typecheck.C | 4 +-
.../gcc.target/aarch64/bfloat16_scalar_typecheck.c | 196 ++++++++++-----------
.../aarch64/bfloat16_vector_typecheck_1.c | 100 +++++------
.../aarch64/bfloat16_vector_typecheck_2.c | 100 +++++------
.../sve/acle/general-c/ternary_bfloat16_opt_n_1.c | 2 +-
libgcc/config/aarch64/libgcc-softfp.ver | 13 ++
libgcc/config/aarch64/sfp-machine.h | 2 +
libgcc/config/aarch64/t-softfp | 7 +-
libgcc/soft-fp/floatdibf.c | 45 +++++
libgcc/soft-fp/floatundibf.c | 45 +++++
libstdc++-v3/config/abi/pre/gnu.ver | 3 +
15 files changed, 327 insertions(+), 269 deletions(-)
diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc
index 773c36eb3f6..eaefbf6774b 100644
--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -918,7 +918,6 @@ tree aarch64_fp16_type_node = NULL_TREE;
tree aarch64_fp16_ptr_type_node = NULL_TREE;
/* Back-end node type for brain float (bfloat) types. */
-tree aarch64_bf16_type_node = NULL_TREE;
tree aarch64_bf16_ptr_type_node = NULL_TREE;
/* Wrapper around add_builtin_function. NAME is the name of the built-in
@@ -1010,7 +1009,7 @@ aarch64_int_or_fp_type (machine_mode mode,
case E_DFmode:
return double_type_node;
case E_BFmode:
- return aarch64_bf16_type_node;
+ return bfloat16_type_node;
default:
gcc_unreachable ();
}
@@ -1124,8 +1123,8 @@ aarch64_init_simd_builtin_types (void)
aarch64_simd_types[Float64x2_t].eltype = double_type_node;
/* Init Bfloat vector types with underlying __bf16 type. */
- aarch64_simd_types[Bfloat16x4_t].eltype = aarch64_bf16_type_node;
- aarch64_simd_types[Bfloat16x8_t].eltype = aarch64_bf16_type_node;
+ aarch64_simd_types[Bfloat16x4_t].eltype = bfloat16_type_node;
+ aarch64_simd_types[Bfloat16x8_t].eltype = bfloat16_type_node;
for (i = 0; i < nelts; i++)
{
@@ -1197,7 +1196,7 @@ aarch64_init_simd_builtin_scalar_types (void)
"__builtin_aarch64_simd_poly128");
(*lang_hooks.types.register_builtin_type) (intTI_type_node,
"__builtin_aarch64_simd_ti");
- (*lang_hooks.types.register_builtin_type) (aarch64_bf16_type_node,
+ (*lang_hooks.types.register_builtin_type) (bfloat16_type_node,
"__builtin_aarch64_simd_bf");
/* Unsigned integer types for various mode sizes. */
(*lang_hooks.types.register_builtin_type) (unsigned_intQI_type_node,
@@ -1682,13 +1681,8 @@ aarch64_init_fp16_types (void)
static void
aarch64_init_bf16_types (void)
{
- aarch64_bf16_type_node = make_node (REAL_TYPE);
- TYPE_PRECISION (aarch64_bf16_type_node) = 16;
- SET_TYPE_MODE (aarch64_bf16_type_node, BFmode);
- layout_type (aarch64_bf16_type_node);
-
- lang_hooks.types.register_builtin_type (aarch64_bf16_type_node, "__bf16");
- aarch64_bf16_ptr_type_node = build_pointer_type (aarch64_bf16_type_node);
+ lang_hooks.types.register_builtin_type (bfloat16_type_node, "__bf16");
+ aarch64_bf16_ptr_type_node = build_pointer_type (bfloat16_type_node);
}
/* Pointer authentication builtins that will become NOP on legacy platform.
diff --git a/gcc/config/aarch64/aarch64-sve-builtins.def b/gcc/config/aarch64/aarch64-sve-builtins.def
index 765884dacc1..534f6e69d72 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins.def
+++ b/gcc/config/aarch64/aarch64-sve-builtins.def
@@ -61,7 +61,7 @@ DEF_SVE_MODE (u64offset, none, svuint64_t, bytes)
DEF_SVE_MODE (vnum, none, none, vectors)
DEF_SVE_TYPE (svbool_t, 10, __SVBool_t, boolean_type_node)
-DEF_SVE_TYPE (svbfloat16_t, 14, __SVBfloat16_t, aarch64_bf16_type_node)
+DEF_SVE_TYPE (svbfloat16_t, 14, __SVBfloat16_t, bfloat16_type_node)
DEF_SVE_TYPE (svfloat16_t, 13, __SVFloat16_t, aarch64_fp16_type_node)
DEF_SVE_TYPE (svfloat32_t, 13, __SVFloat32_t, float_type_node)
DEF_SVE_TYPE (svfloat64_t, 13, __SVFloat64_t, double_type_node)
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 8a06879e94f..b27f4354031 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -19871,7 +19871,7 @@ aarch64_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
field_ptr_t = aarch64_fp16_ptr_type_node;
break;
case E_BFmode:
- field_t = aarch64_bf16_type_node;
+ field_t = bfloat16_type_node;
field_ptr_t = aarch64_bf16_ptr_type_node;
break;
case E_V2SImode:
@@ -26561,18 +26561,18 @@ aarch64_dwarf_poly_indeterminate_value (unsigned int i, unsigned int *factor,
}
/* Implement TARGET_LIBGCC_FLOATING_POINT_MODE_SUPPORTED_P - return TRUE
- if MODE is HFmode, and punt to the generic implementation otherwise. */
+ if MODE is [BH]Fmode, and punt to the generic implementation otherwise. */
static bool
aarch64_libgcc_floating_mode_supported_p (scalar_float_mode mode)
{
- return (mode == HFmode
+ return ((mode == HFmode || mode == BFmode)
? true
: default_libgcc_floating_mode_supported_p (mode));
}
/* Implement TARGET_SCALAR_MODE_SUPPORTED_P - return TRUE
- if MODE is HFmode, and punt to the generic implementation otherwise. */
+ if MODE is [BH]Fmode, and punt to the generic implementation otherwise. */
static bool
aarch64_scalar_mode_supported_p (scalar_mode mode)
@@ -26580,7 +26580,7 @@ aarch64_scalar_mode_supported_p (scalar_mode mode)
if (DECIMAL_FLOAT_MODE_P (mode))
return default_decimal_float_supported_p ();
- return (mode == HFmode
+ return ((mode == HFmode || mode == BFmode)
? true
: default_scalar_mode_supported_p (mode));
}
@@ -27048,39 +27048,6 @@ aarch64_stack_protect_guard (void)
return NULL_TREE;
}
-/* Return the diagnostic message string if conversion from FROMTYPE to
- TOTYPE is not allowed, NULL otherwise. */
-
-static const char *
-aarch64_invalid_conversion (const_tree fromtype, const_tree totype)
-{
- if (element_mode (fromtype) != element_mode (totype))
- {
- /* Do no allow conversions to/from BFmode scalar types. */
- if (TYPE_MODE (fromtype) == BFmode)
- return N_("invalid conversion from type %<bfloat16_t%>");
- if (TYPE_MODE (totype) == BFmode)
- return N_("invalid conversion to type %<bfloat16_t%>");
- }
-
- /* Conversion allowed. */
- return NULL;
-}
-
-/* Return the diagnostic message string if the unary operation OP is
- not permitted on TYPE, NULL otherwise. */
-
-static const char *
-aarch64_invalid_unary_op (int op, const_tree type)
-{
- /* Reject all single-operand operations on BFmode except for &. */
- if (element_mode (type) == BFmode && op != ADDR_EXPR)
- return N_("operation not permitted on type %<bfloat16_t%>");
-
- /* Operation allowed. */
- return NULL;
-}
-
/* Return the diagnostic message string if the binary operation OP is
not permitted on TYPE1 and TYPE2, NULL otherwise. */
@@ -27088,11 +27055,6 @@ static const char *
aarch64_invalid_binary_op (int op ATTRIBUTE_UNUSED, const_tree type1,
const_tree type2)
{
- /* Reject all 2-operand operations on BFmode. */
- if (element_mode (type1) == BFmode
- || element_mode (type2) == BFmode)
- return N_("operation not permitted on type %<bfloat16_t%>");
-
if (VECTOR_TYPE_P (type1)
&& VECTOR_TYPE_P (type2)
&& !TYPE_INDIVISIBLE_P (type1)
@@ -27689,12 +27651,6 @@ aarch64_libgcc_floating_mode_supported_p
#undef TARGET_MANGLE_TYPE
#define TARGET_MANGLE_TYPE aarch64_mangle_type
-#undef TARGET_INVALID_CONVERSION
-#define TARGET_INVALID_CONVERSION aarch64_invalid_conversion
-
-#undef TARGET_INVALID_UNARY_OP
-#define TARGET_INVALID_UNARY_OP aarch64_invalid_unary_op
-
#undef TARGET_INVALID_BINARY_OP
#define TARGET_INVALID_BINARY_OP aarch64_invalid_binary_op
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index 7129ed1ff37..2403795e836 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -1237,9 +1237,8 @@ extern const char *aarch64_rewrite_mcpu (int argc, const char **argv);
extern GTY(()) tree aarch64_fp16_type_node;
extern GTY(()) tree aarch64_fp16_ptr_type_node;
-/* This type is the user-visible __bf16, and a pointer to that type. Defined
- in aarch64-builtins.cc. */
-extern GTY(()) tree aarch64_bf16_type_node;
+/* Pointer to the user-visible __bf16 type. __bf16 itself is generic
+ bfloat16_type_node. Defined in aarch64-builtins.cc. */
extern GTY(()) tree aarch64_bf16_ptr_type_node;
/* The generic unwind code in libgcc does not initialize the frame pointer.
diff --git a/gcc/testsuite/g++.target/aarch64/bfloat_cpp_typecheck.C b/gcc/testsuite/g++.target/aarch64/bfloat_cpp_typecheck.C
index e112a38f6ad..b76ea396009 100644
--- a/gcc/testsuite/g++.target/aarch64/bfloat_cpp_typecheck.C
+++ b/gcc/testsuite/g++.target/aarch64/bfloat_cpp_typecheck.C
@@ -9,6 +9,6 @@ void foo (void)
{
bfloat16_t (); /* { dg-bogus {invalid conversion to type 'bfloat16_t'} "" } */
bfloat16_t a = bfloat16_t(); /* { dg-bogus {invalid conversion to type 'bfloat16_t'} "" } */
- bfloat16_t (0x1234); /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16_t (0.1); /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
+ bfloat16_t (0x1234);
+ bfloat16_t (0.1);
}
diff --git a/gcc/testsuite/gcc.target/aarch64/bfloat16_scalar_typecheck.c b/gcc/testsuite/gcc.target/aarch64/bfloat16_scalar_typecheck.c
index f4ae6802883..99876e47ce9 100644
--- a/gcc/testsuite/gcc.target/aarch64/bfloat16_scalar_typecheck.c
+++ b/gcc/testsuite/gcc.target/aarch64/bfloat16_scalar_typecheck.c
@@ -16,8 +16,8 @@ double is_a_double;
float *float_ptr;
-bfloat16_t foo1 (void) { return (bfloat16_t) 0x1234; } /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
-bfloat16_t foo2 (void) { return (bfloat16_t) (short) 0x1234; } /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
+bfloat16_t foo1 (void) { return (bfloat16_t) 0x1234; }
+bfloat16_t foo2 (void) { return (bfloat16_t) (short) 0x1234; }
bfloat16_t footest (bfloat16_t scalar0)
{
@@ -26,87 +26,87 @@ bfloat16_t footest (bfloat16_t scalar0)
bfloat16_t scalar1_1;
bfloat16_t scalar1_2 = glob_bfloat;
- bfloat16_t scalar1_3 = 0; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16_t scalar1_4 = 0.1; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16_t scalar1_5 = is_a_float; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16_t scalar1_6 = is_an_int; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16_t scalar1_7 = is_a_float16; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16_t scalar1_8 = is_a_double; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16_t scalar1_9 = is_a_short_int; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
-
- int initi_1_1 = glob_bfloat; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- float initi_1_2 = glob_bfloat; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- float16_t initi_1_3 = glob_bfloat; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- short initi_1_4 = glob_bfloat; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- double initi_1_5 = glob_bfloat; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
+ bfloat16_t scalar1_3 = 0;
+ bfloat16_t scalar1_4 = 0.1;
+ bfloat16_t scalar1_5 = is_a_float;
+ bfloat16_t scalar1_6 = is_an_int;
+ bfloat16_t scalar1_7 = is_a_float16;
+ bfloat16_t scalar1_8 = is_a_double;
+ bfloat16_t scalar1_9 = is_a_short_int;
+
+ int initi_1_1 = glob_bfloat;
+ float initi_1_2 = glob_bfloat;
+ float16_t initi_1_3 = glob_bfloat;
+ short initi_1_4 = glob_bfloat;
+ double initi_1_5 = glob_bfloat;
bfloat16_t scalar2_1 = {};
bfloat16_t scalar2_2 = { glob_bfloat };
- bfloat16_t scalar2_3 = { 0 }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16_t scalar2_4 = { 0.1 }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16_t scalar2_5 = { is_a_float }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16_t scalar2_6 = { is_an_int }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16_t scalar2_7 = { is_a_float16 }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16_t scalar2_8 = { is_a_double }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16_t scalar2_9 = { is_a_short_int }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
-
- int initi_2_1 = { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- float initi_2_2 = { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- float16_t initi_2_3 = { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- short initi_2_4 = { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- double initi_2_5 = { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
+ bfloat16_t scalar2_3 = { 0 };
+ bfloat16_t scalar2_4 = { 0.1 };
+ bfloat16_t scalar2_5 = { is_a_float };
+ bfloat16_t scalar2_6 = { is_an_int };
+ bfloat16_t scalar2_7 = { is_a_float16 };
+ bfloat16_t scalar2_8 = { is_a_double };
+ bfloat16_t scalar2_9 = { is_a_short_int };
+
+ int initi_2_1 = { glob_bfloat };
+ float initi_2_2 = { glob_bfloat };
+ float16_t initi_2_3 = { glob_bfloat };
+ short initi_2_4 = { glob_bfloat };
+ double initi_2_5 = { glob_bfloat };
/* Assignments. */
glob_bfloat = glob_bfloat;
- glob_bfloat = 0; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- glob_bfloat = 0.1; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- glob_bfloat = is_a_float; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- glob_bfloat = is_an_int; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- glob_bfloat = is_a_float16; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- glob_bfloat = is_a_double; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- glob_bfloat = is_a_short_int; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
-
- is_an_int = glob_bfloat; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- is_a_float = glob_bfloat; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- is_a_float16 = glob_bfloat; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- is_a_double = glob_bfloat; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- is_a_short_int = glob_bfloat; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
+ glob_bfloat = 0;
+ glob_bfloat = 0.1;
+ glob_bfloat = is_a_float;
+ glob_bfloat = is_an_int;
+ glob_bfloat = is_a_float16;
+ glob_bfloat = is_a_double;
+ glob_bfloat = is_a_short_int;
+
+ is_an_int = glob_bfloat;
+ is_a_float = glob_bfloat;
+ is_a_float16 = glob_bfloat;
+ is_a_double = glob_bfloat;
+ is_a_short_int = glob_bfloat;
/* Casting. */
(void) glob_bfloat;
(bfloat16_t) glob_bfloat;
- (int) glob_bfloat; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- (float) glob_bfloat; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- (float16_t) glob_bfloat; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- (double) glob_bfloat; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- (short) glob_bfloat; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
+ (int) glob_bfloat;
+ (float) glob_bfloat;
+ (float16_t) glob_bfloat;
+ (double) glob_bfloat;
+ (short) glob_bfloat;
- (bfloat16_t) is_an_int; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- (bfloat16_t) is_a_float; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- (bfloat16_t) is_a_float16; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- (bfloat16_t) is_a_double; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- (bfloat16_t) is_a_short_int; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
+ (bfloat16_t) is_an_int;
+ (bfloat16_t) is_a_float;
+ (bfloat16_t) is_a_float16;
+ (bfloat16_t) is_a_double;
+ (bfloat16_t) is_a_short_int;
/* Compound literals. */
(bfloat16_t) {};
(bfloat16_t) { glob_bfloat };
- (bfloat16_t) { 0 }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- (bfloat16_t) { 0.1 }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- (bfloat16_t) { is_a_float }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- (bfloat16_t) { is_an_int }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- (bfloat16_t) { is_a_float16 }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- (bfloat16_t) { is_a_double }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- (bfloat16_t) { is_a_short_int }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
-
- (int) { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- (float) { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- (float16_t) { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- (double) { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- (short) { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
+ (bfloat16_t) { 0 };
+ (bfloat16_t) { 0.1 };
+ (bfloat16_t) { is_a_float };
+ (bfloat16_t) { is_an_int };
+ (bfloat16_t) { is_a_float16 };
+ (bfloat16_t) { is_a_double };
+ (bfloat16_t) { is_a_short_int };
+
+ (int) { glob_bfloat };
+ (float) { glob_bfloat };
+ (float16_t) { glob_bfloat };
+ (double) { glob_bfloat };
+ (short) { glob_bfloat };
/* Arrays and Structs. */
@@ -149,16 +149,16 @@ bfloat16_t footest (bfloat16_t scalar0)
bfloat_ptr = &bfloat_ptr3[1];
/* Simple comparison. */
- scalar0 > glob_bfloat; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- glob_bfloat == scalar0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- scalar0 > is_a_float; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- is_a_float == scalar0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- scalar0 > 0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- 0 == scalar0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- scalar0 > 0.1; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- 0.1 == scalar0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- scalar0 > is_an_int; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- is_an_int == scalar0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
+ scalar0 > glob_bfloat;
+ glob_bfloat == scalar0;
+ scalar0 > is_a_float;
+ is_a_float == scalar0;
+ scalar0 > 0;
+ 0 == scalar0;
+ scalar0 > 0.1;
+ 0.1 == scalar0;
+ scalar0 > is_an_int;
+ is_an_int == scalar0;
/* Pointer comparison. */
@@ -178,41 +178,41 @@ bfloat16_t footest (bfloat16_t scalar0)
/* Conditional expressions. */
0 ? scalar0 : scalar0;
- 0 ? scalar0 : is_a_float; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- 0 ? is_a_float : scalar0; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- 0 ? scalar0 : 0; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- 0 ? 0 : scalar0; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- 0 ? 0.1 : scalar0; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- 0 ? scalar0 : 0.1; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
+ 0 ? scalar0 : is_a_float;
+ 0 ? is_a_float : scalar0;
+ 0 ? scalar0 : 0;
+ 0 ? 0 : scalar0;
+ 0 ? 0.1 : scalar0;
+ 0 ? scalar0 : 0.1;
0 ? bfloat_ptr : bfloat_ptr2;
0 ? bfloat_ptr : float_ptr; /* { dg-error {pointer type mismatch in conditional expression} } */
0 ? float_ptr : bfloat_ptr; /* { dg-error {pointer type mismatch in conditional expression} } */
- scalar0 ? scalar0 : scalar0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- scalar0 ? is_a_float : scalar0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- scalar0 ? scalar0 : is_a_float; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- scalar0 ? is_a_float : is_a_float; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
+ scalar0 ? scalar0 : scalar0;
+ scalar0 ? is_a_float : scalar0;
+ scalar0 ? scalar0 : is_a_float;
+ scalar0 ? is_a_float : is_a_float;
/* Unary operators. */
- +scalar0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- -scalar0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- ~scalar0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- !scalar0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
+ +scalar0;
+ -scalar0;
+ ~scalar0; /* { dg-error {wrong type argument to bit-complement} } */
+ !scalar0;
*scalar0; /* { dg-error {invalid type argument of unary '\*'} } */
- __real scalar0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- __imag scalar0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- ++scalar0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- --scalar0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- scalar0++; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- scalar0--; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
+ __real scalar0;
+ __imag scalar0;
+ ++scalar0;
+ --scalar0;
+ scalar0++;
+ scalar0--;
/* Binary arithmetic operations. */
- scalar0 = glob_bfloat + *bfloat_ptr; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- scalar0 = glob_bfloat + 0.1; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- scalar0 = glob_bfloat + 0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- scalar0 = glob_bfloat + is_a_float; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
+ scalar0 = glob_bfloat + *bfloat_ptr;
+ scalar0 = glob_bfloat + 0.1;
+ scalar0 = glob_bfloat + 0;
+ scalar0 = glob_bfloat + is_a_float;
return scalar0;
}
diff --git a/gcc/testsuite/gcc.target/aarch64/bfloat16_vector_typecheck_1.c b/gcc/testsuite/gcc.target/aarch64/bfloat16_vector_typecheck_1.c
index 1a2aa9b3c16..b746dafe15a 100644
--- a/gcc/testsuite/gcc.target/aarch64/bfloat16_vector_typecheck_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/bfloat16_vector_typecheck_1.c
@@ -52,20 +52,20 @@ bfloat16x4_t footest (bfloat16x4_t vector0)
bfloat16x4_t vector2_1 = {};
bfloat16x4_t vector2_2 = { glob_bfloat };
bfloat16x4_t vector2_3 = { glob_bfloat, glob_bfloat, glob_bfloat, glob_bfloat };
- bfloat16x4_t vector2_4 = { 0 }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16x4_t vector2_5 = { 0.1 }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16x4_t vector2_6 = { is_a_float16 }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16x4_t vector2_7 = { is_a_float }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16x4_t vector2_8 = { is_an_int }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16x4_t vector2_9 = { is_a_short_int }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16x4_t vector2_10 = { 0.0, 0, is_a_short_int, is_a_float }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
-
- int32x4_t initi_2_1 = { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- float32x4_t initi_2_2 = { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- float16x4_t initi_2_3 = { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- float32x2_t initi_2_4 = { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- int32x2_t initi_2_5 = { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- int16x4_t initi_2_6 = { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
+ bfloat16x4_t vector2_4 = { 0 };
+ bfloat16x4_t vector2_5 = { 0.1 };
+ bfloat16x4_t vector2_6 = { is_a_float16 };
+ bfloat16x4_t vector2_7 = { is_a_float };
+ bfloat16x4_t vector2_8 = { is_an_int };
+ bfloat16x4_t vector2_9 = { is_a_short_int };
+ bfloat16x4_t vector2_10 = { 0.0, 0, is_a_short_int, is_a_float };
+
+ int32x4_t initi_2_1 = { glob_bfloat };
+ float32x4_t initi_2_2 = { glob_bfloat };
+ float16x4_t initi_2_3 = { glob_bfloat };
+ float32x2_t initi_2_4 = { glob_bfloat };
+ int32x2_t initi_2_5 = { glob_bfloat };
+ int16x4_t initi_2_6 = { glob_bfloat };
/* Assignments to/from vectors. */
@@ -89,25 +89,25 @@ bfloat16x4_t footest (bfloat16x4_t vector0)
/* Assignments to/from elements. */
vector2_3[0] = glob_bfloat;
- vector2_3[0] = is_an_int; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- vector2_3[0] = is_a_short_int; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- vector2_3[0] = is_a_float; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- vector2_3[0] = is_a_float16; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- vector2_3[0] = 0; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- vector2_3[0] = 0.1; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
+ vector2_3[0] = is_an_int;
+ vector2_3[0] = is_a_short_int;
+ vector2_3[0] = is_a_float;
+ vector2_3[0] = is_a_float16;
+ vector2_3[0] = 0;
+ vector2_3[0] = 0.1;
glob_bfloat = vector2_3[0];
- is_an_int = vector2_3[0]; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- is_a_short_int = vector2_3[0]; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- is_a_float = vector2_3[0]; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- is_a_float16 = vector2_3[0]; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
+ is_an_int = vector2_3[0];
+ is_a_short_int = vector2_3[0];
+ is_a_float = vector2_3[0];
+ is_a_float16 = vector2_3[0];
/* Compound literals. */
(bfloat16x4_t) {};
- (bfloat16x4_t) { 0 }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- (bfloat16x4_t) { 0.1 }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
+ (bfloat16x4_t) { 0 };
+ (bfloat16x4_t) { 0.1 };
(bfloat16x4_t) { is_a_float_vec }; /* { dg-error {incompatible types when initializing type '__bf16' using type 'float32x4_t'} } */
(bfloat16x4_t) { is_an_int_vec }; /* { dg-error {incompatible types when initializing type '__bf16' using type 'int32x4_t'} } */
(bfloat16x4_t) { is_a_float_pair }; /* { dg-error {incompatible types when initializing type '__bf16' using type 'float32x2_t'} } */
@@ -190,16 +190,16 @@ bfloat16x4_t footest (bfloat16x4_t vector0)
bfloat_ptr = &bfloat_ptr3[1];
/* Simple comparison. */
- vector0 > glob_bfloat_vec; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- glob_bfloat_vec == vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0 > is_a_float_vec; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- is_a_float_vec == vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0 > 0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- 0 == vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0 > 0.1; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- 0.1 == vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0 > is_an_int_vec; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- is_an_int_vec == vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
+ vector0 > glob_bfloat_vec;
+ glob_bfloat_vec == vector0;
+ vector0 > is_a_float_vec; /* { dg-error {comparing vectors with different element types} } */
+ is_a_float_vec == vector0; /* { dg-error {comparing vectors with different element types} } */
+ vector0 > 0;
+ 0 == vector0;
+ vector0 > 0.1; /* { dg-error {conversion of scalar 'double' to vector 'bfloat16x4_t' involves truncation} } */
+ 0.1 == vector0; /* { dg-error {conversion of scalar 'double' to vector 'bfloat16x4_t' involves truncation} } */
+ vector0 > is_an_int_vec; /* { dg-error {comparing vectors with different element types} } */
+ is_an_int_vec == vector0; /* { dg-error {comparing vectors with different element types} } */
/* Pointer comparison. */
@@ -238,24 +238,24 @@ bfloat16x4_t footest (bfloat16x4_t vector0)
/* Unary operators. */
- +vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- -vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- ~vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- !vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
+ +vector0;
+ -vector0;
+ ~vector0; /* { dg-error {wrong type argument to bit-complement} } */
+ !vector0; /* { dg-error {wrong type argument to unary exclamation mark} } */
*vector0; /* { dg-error {invalid type argument of unary '\*'} } */
- __real vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- __imag vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- ++vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- --vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0++; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0--; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
+ __real vector0; /* { dg-error {wrong type argument to __real} } */
+ __imag vector0; /* { dg-error {wrong type argument to __imag} } */
+ ++vector0;
+ --vector0;
+ vector0++;
+ vector0--;
/* Binary arithmetic operations. */
- vector0 = glob_bfloat_vec + *bfloat_ptr; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0 = glob_bfloat_vec + 0.1; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0 = glob_bfloat_vec + 0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0 = glob_bfloat_vec + is_a_float_vec; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
+ vector0 = glob_bfloat_vec + *bfloat_ptr;
+ vector0 = glob_bfloat_vec + 0.1; /* { dg-error {conversion of scalar 'double' to vector 'bfloat16x4_t' involves truncation} } */
+ vector0 = glob_bfloat_vec + 0;
+ vector0 = glob_bfloat_vec + is_a_float_vec; /* { dg-error {invalid operands to binary \+} } */
return vector0;
}
diff --git a/gcc/testsuite/gcc.target/aarch64/bfloat16_vector_typecheck_2.c b/gcc/testsuite/gcc.target/aarch64/bfloat16_vector_typecheck_2.c
index 586d05a928f..779bb528e41 100644
--- a/gcc/testsuite/gcc.target/aarch64/bfloat16_vector_typecheck_2.c
+++ b/gcc/testsuite/gcc.target/aarch64/bfloat16_vector_typecheck_2.c
@@ -51,20 +51,20 @@ bfloat16x8_t footest (bfloat16x8_t vector0)
bfloat16x8_t vector2_1 = {};
bfloat16x8_t vector2_2 = { glob_bfloat };
bfloat16x8_t vector2_3 = { glob_bfloat, glob_bfloat, glob_bfloat, glob_bfloat };
- bfloat16x8_t vector2_4 = { 0 }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16x8_t vector2_5 = { 0.1 }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16x8_t vector2_6 = { is_a_float16 }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16x8_t vector2_7 = { is_a_float }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16x8_t vector2_8 = { is_an_int }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16x8_t vector2_9 = { is_a_short_int }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- bfloat16x8_t vector2_10 = { 0.0, 0, is_a_short_int, is_a_float }; /* { dg-error "invalid conversion to type 'bfloat16_t'" } */
-
- int32x4_t initi_2_1 = { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- float32x4_t initi_2_2 = { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- float16x8_t initi_2_3 = { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- float64x2_t initi_2_4 = { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- int64x2_t initi_2_5 = { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- int16x8_t initi_2_6 = { glob_bfloat }; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
+ bfloat16x8_t vector2_4 = { 0 };
+ bfloat16x8_t vector2_5 = { 0.1 };
+ bfloat16x8_t vector2_6 = { is_a_float16 };
+ bfloat16x8_t vector2_7 = { is_a_float };
+ bfloat16x8_t vector2_8 = { is_an_int };
+ bfloat16x8_t vector2_9 = { is_a_short_int };
+ bfloat16x8_t vector2_10 = { 0.0, 0, is_a_short_int, is_a_float };
+
+ int32x4_t initi_2_1 = { glob_bfloat };
+ float32x4_t initi_2_2 = { glob_bfloat };
+ float16x8_t initi_2_3 = { glob_bfloat };
+ float64x2_t initi_2_4 = { glob_bfloat };
+ int64x2_t initi_2_5 = { glob_bfloat };
+ int16x8_t initi_2_6 = { glob_bfloat };
/* Assignments to/from vectors. */
@@ -88,25 +88,25 @@ bfloat16x8_t footest (bfloat16x8_t vector0)
/* Assignments to/from elements. */
vector2_3[0] = glob_bfloat;
- vector2_3[0] = is_an_int; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- vector2_3[0] = is_a_short_int; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- vector2_3[0] = is_a_float; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- vector2_3[0] = is_a_float16; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- vector2_3[0] = 0; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- vector2_3[0] = 0.1; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
+ vector2_3[0] = is_an_int;
+ vector2_3[0] = is_a_short_int;
+ vector2_3[0] = is_a_float;
+ vector2_3[0] = is_a_float16;
+ vector2_3[0] = 0;
+ vector2_3[0] = 0.1;
glob_bfloat = vector2_3[0];
- is_an_int = vector2_3[0]; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- is_a_short_int = vector2_3[0]; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- is_a_float = vector2_3[0]; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
- is_a_float16 = vector2_3[0]; /* { dg-error {invalid conversion from type 'bfloat16_t'} } */
+ is_an_int = vector2_3[0];
+ is_a_short_int = vector2_3[0];
+ is_a_float = vector2_3[0];
+ is_a_float16 = vector2_3[0];
/* Compound literals. */
(bfloat16x8_t) {};
- (bfloat16x8_t) { 0 }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
- (bfloat16x8_t) { 0.1 }; /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
+ (bfloat16x8_t) { 0 };
+ (bfloat16x8_t) { 0.1 };
(bfloat16x8_t) { is_a_float_vec }; /* { dg-error {incompatible types when initializing type '__bf16' using type 'float32x4_t'} } */
(bfloat16x8_t) { is_an_int_vec }; /* { dg-error {incompatible types when initializing type '__bf16' using type 'int32x4_t'} } */
(bfloat16x8_t) { is_a_double_pair }; /* { dg-error {incompatible types when initializing type '__bf16' using type 'float64x2_t'} } */
@@ -188,16 +188,16 @@ bfloat16x8_t footest (bfloat16x8_t vector0)
bfloat_ptr = &bfloat_ptr3[1];
/* Simple comparison. */
- vector0 > glob_bfloat_vec; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- glob_bfloat_vec == vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0 > is_a_float_vec; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- is_a_float_vec == vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0 > 0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- 0 == vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0 > 0.1; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- 0.1 == vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0 > is_an_int_vec; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- is_an_int_vec == vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
+ vector0 > glob_bfloat_vec;
+ glob_bfloat_vec == vector0;
+ vector0 > is_a_float_vec; /* { dg-error {comparing vectors with different element types} } */
+ is_a_float_vec == vector0; /* { dg-error {comparing vectors with different element types} } */
+ vector0 > 0;
+ 0 == vector0;
+ vector0 > 0.1; /* { dg-error {conversion of scalar 'double' to vector 'bfloat16x8_t' involves truncation} } */
+ 0.1 == vector0; /* { dg-error {conversion of scalar 'double' to vector 'bfloat16x8_t' involves truncation} } */
+ vector0 > is_an_int_vec; /* { dg-error {comparing vectors with different element types} } */
+ is_an_int_vec == vector0; /* { dg-error {comparing vectors with different element types} } */
/* Pointer comparison. */
@@ -236,24 +236,24 @@ bfloat16x8_t footest (bfloat16x8_t vector0)
/* Unary operators. */
- +vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- -vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- ~vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- !vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
+ +vector0;
+ -vector0;
+ ~vector0; /* { dg-error {wrong type argument to bit-complement} } */
+ !vector0; /* { dg-error {wrong type argument to unary exclamation mark} } */
*vector0; /* { dg-error {invalid type argument of unary '\*'} } */
- __real vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- __imag vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- ++vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- --vector0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0++; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0--; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
+ __real vector0; /* { dg-error {wrong type argument to __real} } */
+ __imag vector0; /* { dg-error {wrong type argument to __imag} } */
+ ++vector0;
+ --vector0;
+ vector0++;
+ vector0--;
/* Binary arithmetic operations. */
- vector0 = glob_bfloat_vec + *bfloat_ptr; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0 = glob_bfloat_vec + 0.1; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0 = glob_bfloat_vec + 0; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
- vector0 = glob_bfloat_vec + is_a_float_vec; /* { dg-error {operation not permitted on type 'bfloat16_t'} } */
+ vector0 = glob_bfloat_vec + *bfloat_ptr;
+ vector0 = glob_bfloat_vec + 0.1; /* { dg-error {conversion of scalar 'double' to vector 'bfloat16x8_t' involves truncation} } */
+ vector0 = glob_bfloat_vec + 0;
+ vector0 = glob_bfloat_vec + is_a_float_vec; /* { dg-error {invalid operands to binary \+} } */
return vector0;
}
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/ternary_bfloat16_opt_n_1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/ternary_bfloat16_opt_n_1.c
index 2d09a8eeb06..cb0605b9a0f 100644
--- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/ternary_bfloat16_opt_n_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/ternary_bfloat16_opt_n_1.c
@@ -18,7 +18,7 @@ f1 (svbool_t pg, svuint8_t u8, svuint16_t u16, svint32_t s32,
svbfdot (f32, bf16, bf16);
svbfdot (f32, 0, bf16); /* { dg-error {passing 'int' to argument 2 of 'svbfdot', which expects 'svbfloat16_t'} } */
svbfdot (f32, f32, bf16); /* { dg-error {passing 'svfloat32_t' to argument 2 of 'svbfdot', which expects 'svbfloat16_t'} } */
- svbfdot (f32, bf16, 0); /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
+ svbfdot (f32, bf16, 0);
svbfdot (f32, bf16, f32); /* { dg-error {passing 'svfloat32_t' to argument 3 of 'svbfdot', which expects 'svbfloat16_t'} } */
svbfdot (f32, bf16, bf);
}
diff --git a/libgcc/config/aarch64/libgcc-softfp.ver b/libgcc/config/aarch64/libgcc-softfp.ver
index 1aafed1971b..0af769135ca 100644
--- a/libgcc/config/aarch64/libgcc-softfp.ver
+++ b/libgcc/config/aarch64/libgcc-softfp.ver
@@ -26,3 +26,16 @@ GCC_11.0 {
__mulhc3
__trunctfhf2
}
+
+%inherit GCC_13.0.0 GCC_11.0.0
+GCC_13.0.0 {
+ __extendbfsf2
+ __floatdibf
+ __floattibf
+ __floatundibf
+ __floatuntibf
+ __truncdfbf2
+ __truncsfbf2
+ __trunctfbf2
+ __trunchfbf2
+}
diff --git a/libgcc/config/aarch64/sfp-machine.h b/libgcc/config/aarch64/sfp-machine.h
index 230da705323..97c38a34c86 100644
--- a/libgcc/config/aarch64/sfp-machine.h
+++ b/libgcc/config/aarch64/sfp-machine.h
@@ -43,10 +43,12 @@ typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__)));
#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_2_udiv(Q,R,X,Y)
#define _FP_NANFRAC_H ((_FP_QNANBIT_H << 1) - 1)
+#define _FP_NANFRAC_B ((_FP_QNANBIT_B << 1) - 1)
#define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
#define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1)
#define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1
#define _FP_NANSIGN_H 0
+#define _FP_NANSIGN_B 0
#define _FP_NANSIGN_S 0
#define _FP_NANSIGN_D 0
#define _FP_NANSIGN_Q 0
diff --git a/libgcc/config/aarch64/t-softfp b/libgcc/config/aarch64/t-softfp
index 981ced7444f..0ff6102359d 100644
--- a/libgcc/config/aarch64/t-softfp
+++ b/libgcc/config/aarch64/t-softfp
@@ -1,9 +1,10 @@
softfp_float_modes := tf
softfp_int_modes := si di ti
-softfp_extensions := sftf dftf hftf
-softfp_truncations := tfsf tfdf tfhf
+softfp_extensions := sftf dftf hftf bfsf
+softfp_truncations := tfsf tfdf tfhf tfbf dfbf sfbf hfbf
softfp_exclude_libgcc2 := n
-softfp_extras := fixhfti fixunshfti floattihf floatuntihf
+softfp_extras := fixhfti fixunshfti floattihf floatuntihf \
+ floatdibf floatundibf floattibf floatuntibf
TARGET_LIBGCC2_CFLAGS += -Wno-missing-prototypes
diff --git a/libgcc/soft-fp/floatdibf.c b/libgcc/soft-fp/floatdibf.c
new file mode 100644
index 00000000000..9cdeba12625
--- /dev/null
+++ b/libgcc/soft-fp/floatdibf.c
@@ -0,0 +1,45 @@
+/* Software floating-point emulation.
+ Convert a 64bit signed integer to bfloat16
+ Copyright (C) 2007-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file into
+ combinations with other programs, and to distribute those
+ combinations without any restriction coming from the use of this
+ file. (The Lesser General Public License restrictions do apply in
+ other respects; for example, they cover modification of the file,
+ and distribution when not linked into a combine executable.)
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "brain.h"
+
+BFtype
+__floatdibf (DItype i)
+{
+ FP_DECL_EX;
+ FP_DECL_B (A);
+ BFtype a;
+
+ FP_INIT_ROUNDMODE;
+ FP_FROM_INT_B (A, i, DI_BITS, UDItype);
+ FP_PACK_RAW_B (a, A);
+ FP_HANDLE_EXCEPTIONS;
+
+ return a;
+}
diff --git a/libgcc/soft-fp/floatundibf.c b/libgcc/soft-fp/floatundibf.c
new file mode 100644
index 00000000000..11e43d6df75
--- /dev/null
+++ b/libgcc/soft-fp/floatundibf.c
@@ -0,0 +1,45 @@
+/* Software floating-point emulation.
+ Convert a 64bit unsigned integer to bfloat16
+ Copyright (C) 2007-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file into
+ combinations with other programs, and to distribute those
+ combinations without any restriction coming from the use of this
+ file. (The Lesser General Public License restrictions do apply in
+ other respects; for example, they cover modification of the file,
+ and distribution when not linked into a combine executable.)
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "brain.h"
+
+BFtype
+__floatundibf (UDItype i)
+{
+ FP_DECL_EX;
+ FP_DECL_B (A);
+ BFtype a;
+
+ FP_INIT_ROUNDMODE;
+ FP_FROM_INT_B (A, i, DI_BITS, UDItype);
+ FP_PACK_RAW_B (a, A);
+ FP_HANDLE_EXCEPTIONS;
+
+ return a;
+}
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 02a449a2f2f..4ae63094eb7 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -2828,6 +2828,9 @@ CXXABI_1.3.14 {
_ZTIDF[0-9]*[_bx];
_ZTIPDF[0-9]*[_bx];
_ZTIPKDF[0-9]*[_bx];
+ _ZTIu6__bf16;
+ _ZTIPu6__bf16;
+ _ZTIPKu6__bf16;
} CXXABI_1.3.13;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-12 23:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-12 23:17 [gcc r13-6622] aarch64: Add bfloat16_t support for aarch64 Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).