Commit bce2b8f9 by Matthew Wahab Committed by Matthew Wahab

[PATCH 10/17][ARM] Refactor support code for NEON builtins.

gcc/
2016-09-23  Matthew Wahab  <matthew.wahab@arm.com>

	* config/arm/arm-builtins.c (arm_init_neon_builtin): New.
	(arm_init_builtins): Move body of a loop to the standalone
	function arm_init_neon_builtin.
	(arm_expand_neon_builtin_1): New.  Update comment.  Function body
	moved from arm_neon_builtin with some white-space fixes.
	(arm_expand_neon_builtin): Move code into the standalone function
	arm_expand_neon_builtin_1.

From-SVN: r240416
parent 55a9b91b
2016-09-23 Matthew Wahab <matthew.wahab@arm.com>
* config/arm/arm-builtins.c (arm_init_neon_builtin): New.
(arm_init_builtins): Move body of a loop to the standalone
function arm_init_neon_builtin.
(arm_expand_neon_builtin_1): New. Update comment. Function body
moved from arm_neon_builtin with some white-space fixes.
(arm_expand_neon_builtin): Move code into the standalone function
arm_expand_neon_builtin_1.
2016-09-23 Matthew Wahab <matthew.wahab@arm.com>
* config/arm/iterators.md (VCVTHI): New.
(NEON_VCMP): Add UNSPEC_VCLT and UNSPEC_VCLE. Fix a long line.
(NEON_VAGLTE): New.
......
......@@ -543,7 +543,7 @@ enum arm_builtins
};
#define ARM_BUILTIN_NEON_PATTERN_START \
(ARM_BUILTIN_MAX - ARRAY_SIZE (neon_builtin_data))
(ARM_BUILTIN_NEON_BASE + 1)
#undef CF
#undef VAR1
......@@ -895,38 +895,14 @@ arm_init_simd_builtin_scalar_types (void)
"__builtin_neon_uti");
}
/* Set up all the NEON builtins, even builtins for instructions that are not
in the current target ISA to allow the user to compile particular modules
with different target specific options that differ from the command line
options. Such builtins will be rejected in arm_expand_builtin. */
/* Set up a NEON builtin. */
static void
arm_init_neon_builtins (void)
arm_init_neon_builtin (unsigned int fcode,
neon_builtin_datum *d)
{
unsigned int i, fcode = ARM_BUILTIN_NEON_PATTERN_START;
arm_init_simd_builtin_types ();
/* Strong-typing hasn't been implemented for all AdvSIMD builtin intrinsics.
Therefore we need to preserve the old __builtin scalar types. It can be
removed once all the intrinsics become strongly typed using the qualifier
system. */
arm_init_simd_builtin_scalar_types ();
tree lane_check_fpr = build_function_type_list (void_type_node,
intSI_type_node,
intSI_type_node,
NULL);
arm_builtin_decls[ARM_BUILTIN_NEON_LANE_CHECK] =
add_builtin_function ("__builtin_arm_lane_check", lane_check_fpr,
ARM_BUILTIN_NEON_LANE_CHECK, BUILT_IN_MD,
NULL, NULL_TREE);
for (i = 0; i < ARRAY_SIZE (neon_builtin_data); i++, fcode++)
{
bool print_type_signature_p = false;
char type_signature[SIMD_MAX_BUILTIN_ARGS] = { 0 };
neon_builtin_datum *d = &neon_builtin_data[i];
char namebuf[60];
tree ftype = NULL;
tree fndecl = NULL;
......@@ -1021,6 +997,39 @@ arm_init_neon_builtins (void)
fndecl = add_builtin_function (namebuf, ftype, fcode, BUILT_IN_MD,
NULL, NULL_TREE);
arm_builtin_decls[fcode] = fndecl;
}
/* Set up all the NEON builtins, even builtins for instructions that are not
in the current target ISA to allow the user to compile particular modules
with different target specific options that differ from the command line
options. Such builtins will be rejected in arm_expand_builtin. */
static void
arm_init_neon_builtins (void)
{
unsigned int i, fcode = ARM_BUILTIN_NEON_PATTERN_START;
arm_init_simd_builtin_types ();
/* Strong-typing hasn't been implemented for all AdvSIMD builtin intrinsics.
Therefore we need to preserve the old __builtin scalar types. It can be
removed once all the intrinsics become strongly typed using the qualifier
system. */
arm_init_simd_builtin_scalar_types ();
tree lane_check_fpr = build_function_type_list (void_type_node,
intSI_type_node,
intSI_type_node,
NULL);
arm_builtin_decls[ARM_BUILTIN_NEON_LANE_CHECK] =
add_builtin_function ("__builtin_arm_lane_check", lane_check_fpr,
ARM_BUILTIN_NEON_LANE_CHECK, BUILT_IN_MD,
NULL, NULL_TREE);
for (i = 0; i < ARRAY_SIZE (neon_builtin_data); i++, fcode++)
{
neon_builtin_datum *d = &neon_builtin_data[i];
arm_init_neon_builtin (fcode, d);
}
}
......@@ -2211,40 +2220,16 @@ constant_arg:
return target;
}
/* Expand a Neon builtin, i.e. those registered only if TARGET_NEON holds.
Most of these are "special" because they don't have symbolic
/* Expand a neon builtin. This is also used for vfp builtins, which behave in
the same way. These builtins are "special" because they don't have symbolic
constants defined per-instruction or per instruction-variant. Instead, the
required info is looked up in the table neon_builtin_data. */
required info is looked up in the NEON_BUILTIN_DATA record that is passed
into the function. */
static rtx
arm_expand_neon_builtin (int fcode, tree exp, rtx target)
arm_expand_neon_builtin_1 (int fcode, tree exp, rtx target,
neon_builtin_datum *d)
{
/* Check in the context of the function making the call whether the
builtin is supported. */
if (! TARGET_NEON)
{
fatal_error (input_location,
"You must enable NEON instructions (e.g. -mfloat-abi=softfp -mfpu=neon) to use these intrinsics.");
return const0_rtx;
}
if (fcode == ARM_BUILTIN_NEON_LANE_CHECK)
{
/* Builtin is only to check bounds of the lane passed to some intrinsics
that are implemented with gcc vector extensions in arm_neon.h. */
tree nlanes = CALL_EXPR_ARG (exp, 0);
gcc_assert (TREE_CODE (nlanes) == INTEGER_CST);
rtx lane_idx = expand_normal (CALL_EXPR_ARG (exp, 1));
if (CONST_INT_P (lane_idx))
neon_lane_bounds (lane_idx, 0, TREE_INT_CST_LOW (nlanes), exp);
else
error ("%Klane index must be a constant immediate", exp);
/* Don't generate any RTL. */
return const0_rtx;
}
neon_builtin_datum *d =
&neon_builtin_data[fcode - ARM_BUILTIN_NEON_PATTERN_START];
enum insn_code icode = d->code;
builtin_arg args[SIMD_MAX_BUILTIN_ARGS + 1];
int num_args = insn_data[d->code].n_operands;
......@@ -2300,6 +2285,45 @@ arm_expand_neon_builtin (int fcode, tree exp, rtx target)
&args[1]);
}
/* Expand a Neon builtin, i.e. those registered only if TARGET_NEON holds.
Most of these are "special" because they don't have symbolic
constants defined per-instruction or per instruction-variant. Instead, the
required info is looked up in the table neon_builtin_data. */
static rtx
arm_expand_neon_builtin (int fcode, tree exp, rtx target)
{
if (fcode >= ARM_BUILTIN_NEON_BASE && ! TARGET_NEON)
{
fatal_error (input_location,
"You must enable NEON instructions"
" (e.g. -mfloat-abi=softfp -mfpu=neon)"
" to use these intrinsics.");
return const0_rtx;
}
if (fcode == ARM_BUILTIN_NEON_LANE_CHECK)
{
/* Builtin is only to check bounds of the lane passed to some intrinsics
that are implemented with gcc vector extensions in arm_neon.h. */
tree nlanes = CALL_EXPR_ARG (exp, 0);
gcc_assert (TREE_CODE (nlanes) == INTEGER_CST);
rtx lane_idx = expand_normal (CALL_EXPR_ARG (exp, 1));
if (CONST_INT_P (lane_idx))
neon_lane_bounds (lane_idx, 0, TREE_INT_CST_LOW (nlanes), exp);
else
error ("%Klane index must be a constant immediate", exp);
/* Don't generate any RTL. */
return const0_rtx;
}
neon_builtin_datum *d
= &neon_builtin_data[fcode - ARM_BUILTIN_NEON_PATTERN_START];
return arm_expand_neon_builtin_1 (fcode, exp, target, d);
}
/* Expand an expression EXP that calls a built-in function,
with result going to TARGET if that's convenient
(and in mode MODE if that's convenient).
......
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