Commit 3ea91401 by Stam Markianos-Wright

[GCC][PATCH][ARM] Add Bfloat16_t scalar type, vector types and machine modes to ARM back-end [2/2]

gcc/ChangeLog:

2020-01-16  Stam Markianos-Wright  <stam.markianos-wright@arm.com>

	* config/arm/arm.c
	(arm_invalid_conversion): New function for target hook.
	(arm_invalid_unary_op): New function for target hook.
	(arm_invalid_binary_op): New function for target hook.

gcc/testsuite/ChangeLog:

2020-01-16  Stam Markianos-Wright  <stam.markianos-wright@arm.com>

	* g++.target/arm/bfloat_cpp_typecheck.C: New test.
	* gcc.target/arm/bfloat16_scalar_typecheck.c: New test.
	* gcc.target/arm/bfloat16_vector_typecheck_1.c: New test.
	* gcc.target/arm/bfloat16_vector_typecheck_2.c: New test.
parent 2e87b2f4
2020-01-16 Stam Markianos-Wright <stam.markianos-wright@arm.com>
* config/arm/arm.c
(arm_invalid_conversion): New function for target hook.
(arm_invalid_unary_op): New function for target hook.
(arm_invalid_binary_op): New function for target hook.
2020-01-16 Stam Markianos-Wright <stam.markianos-wright@arm.com>
* config.gcc: Add arm_bf16.h.
* config/arm/arm-builtins.c (arm_mangle_builtin_type): Fix comment.
(arm_simd_builtin_std_type): Add BFmode.
......
......@@ -692,6 +692,15 @@ static const struct attribute_spec arm_attribute_table[] =
#undef TARGET_MANGLE_TYPE
#define TARGET_MANGLE_TYPE arm_mangle_type
#undef TARGET_INVALID_CONVERSION
#define TARGET_INVALID_CONVERSION arm_invalid_conversion
#undef TARGET_INVALID_UNARY_OP
#define TARGET_INVALID_UNARY_OP arm_invalid_unary_op
#undef TARGET_INVALID_BINARY_OP
#define TARGET_INVALID_BINARY_OP arm_invalid_binary_op
#undef TARGET_ATOMIC_ASSIGN_EXPAND_FENV
#define TARGET_ATOMIC_ASSIGN_EXPAND_FENV arm_atomic_assign_expand_fenv
......@@ -32785,6 +32794,55 @@ arm_coproc_ldc_stc_legitimate_address (rtx op)
return false;
}
/* Return the diagnostic message string if conversion from FROMTYPE to
TOTYPE is not allowed, NULL otherwise. */
static const char *
arm_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 *
arm_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. */
static const char *
arm_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%>");
/* Operation allowed. */
return NULL;
}
/* Implement TARGET_CAN_CHANGE_MODE_CLASS.
In VFPv1, VFP registers could only be accessed in the mode they were
......
2020-01-16 Stam Markianos-Wright <stam.markianos-wright@arm.com>
* g++.target/arm/bfloat_cpp_typecheck.C: New test.
* gcc.target/arm/bfloat16_scalar_typecheck.c: New test.
* gcc.target/arm/bfloat16_vector_typecheck_1.c: New test.
* gcc.target/arm/bfloat16_vector_typecheck_2.c: New test.
2020-01-16 Stam Markianos-Wright <stam.markianos-wright@arm.com>
* g++.dg/abi/mangle-neon.C: Add BF16 SIMD types.
* g++.dg/ext/arm-bf16/bf16-mangle-1.C: New test.
* gcc.target/arm/bfloat16_scalar_1_1.c: New test.
......
/* { dg-do assemble { target { arm*-*-* } } } */
/* { dg-require-effective-target arm_v8_2a_bf16_neon_ok } */
/* { dg-add-options arm_v8_2a_bf16_neon } */
/* { dg-additional-options "-O3 --save-temps" } */
#include <arm_neon.h>
void foo (void)
{
bfloat16_t (); /* { dg-bogus {invalid conversion to type 'bfloat16_t'} "" { xfail *-*-* } } */
bfloat16_t a = bfloat16_t(); /* { dg-bogus {invalid conversion to type 'bfloat16_t'} "" { xfail *-*-* } } */
bfloat16_t (0x1234); /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
bfloat16_t (0.1); /* { dg-error {invalid conversion to type 'bfloat16_t'} } */
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment