Commit 6d4d616a by Richard Sandiford Committed by Richard Sandiford

[AArch64] Split built-in function codes into major and minor codes

It was easier to add the SVE ACLE support without enumerating every
function at build time.  This in turn meant that it was easier if the
SVE builtins occupied a distinct numberspace from the existing AArch64
ones, which *are* enumerated at build time.  This patch therefore
divides the built-in functions codes into "major" and "minor" codes.
At present the major code is just "general", but the SVE patch will add
"SVE" as well.

Also, it was convenient to put the SVE ACLE support in its own file,
so the patch makes aarch64.c provide the frontline target hooks directly,
forwarding to the other files for the real work.

The reason for organising the files this way is that aarch64.c needs
to define the target hook macros whatever happens, and having aarch64.c
macros forward to aarch64-builtins.c functions and aarch64-bulitins.c
functions forward to the SVE file seemed a bit indirect.  Doing things
the way the patch does them puts aarch64-builtins.c and the SVE code on
more of an equal footing.

The aarch64_(general_)gimple_fold_builtin change is mostly just
reindentation.

2019-09-27  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* config/aarch64/aarch64-protos.h (aarch64_builtin_class): New enum.
	(AARCH64_BUILTIN_SHIFT, AARCH64_BUILTIN_CLASS): New constants.
	(aarch64_gimple_fold_builtin, aarch64_mangle_builtin_type)
	(aarch64_fold_builtin, aarch64_init_builtins, aarch64_expand_builtin):
	(aarch64_builtin_decl, aarch64_builtin_rsqrt): Delete.
	(aarch64_general_mangle_builtin_type, aarch64_general_init_builtins):
	(aarch64_general_fold_builtin, aarch64_general_gimple_fold_builtin):
	(aarch64_general_expand_builtin, aarch64_general_builtin_decl):
	(aarch64_general_builtin_rsqrt): Declare.
	* config/aarch64/aarch64-builtins.c (aarch64_general_add_builtin):
	New function.
	(aarch64_mangle_builtin_type): Rename to...
	(aarch64_general_mangle_builtin_type): ...this.
	(aarch64_init_fcmla_laneq_builtins, aarch64_init_simd_builtins)
	(aarch64_init_crc32_builtins, aarch64_init_builtin_rsqrt)
	(aarch64_init_pauth_hint_builtins, aarch64_init_tme_builtins): Use
	aarch64_general_add_builtin instead of add_builtin_function.
	(aarch64_init_builtins): Rename to...
	(aarch64_general_init_builtins): ...this.  Use
	aarch64_general_add_builtin instead of add_builtin_function.
	(aarch64_builtin_decl): Rename to...
	(aarch64_general_builtin_decl): ...this and remove the unused
	arguments.
	(aarch64_expand_builtin): Rename to...
	(aarch64_general_expand_builtin): ...this and remove the unused
	arguments.
	(aarch64_builtin_rsqrt): Rename to...
	(aarch64_general_builtin_rsqrt): ...this.
	(aarch64_fold_builtin): Rename to...
	(aarch64_general_fold_builtin): ...this.  Take the function subcode
	and return type as arguments.  Remove the "ignored" argument.
	(aarch64_gimple_fold_builtin): Rename to...
	(aarch64_general_gimple_fold_builtin): ...this.  Take the function
	subcode and gcall as arguments, and return the new function call.
	* config/aarch64/aarch64.c (aarch64_init_builtins)
	(aarch64_fold_builtin, aarch64_gimple_fold_builtin)
	(aarch64_expand_builtin, aarch64_builtin_decl): New functions.
	(aarch64_builtin_reciprocal): Call aarch64_general_builtin_rsqrt
	instead of aarch64_builtin_rsqrt.
	(aarch64_mangle_type): Call aarch64_general_mangle_builtin_type
	instead of aarch64_mangle_builtin_type.

From-SVN: r276177
parent c6447c20
2019-09-27 Richard Sandiford <richard.sandiford@arm.com>
* config/aarch64/aarch64-protos.h (aarch64_builtin_class): New enum.
(AARCH64_BUILTIN_SHIFT, AARCH64_BUILTIN_CLASS): New constants.
(aarch64_gimple_fold_builtin, aarch64_mangle_builtin_type)
(aarch64_fold_builtin, aarch64_init_builtins, aarch64_expand_builtin):
(aarch64_builtin_decl, aarch64_builtin_rsqrt): Delete.
(aarch64_general_mangle_builtin_type, aarch64_general_init_builtins):
(aarch64_general_fold_builtin, aarch64_general_gimple_fold_builtin):
(aarch64_general_expand_builtin, aarch64_general_builtin_decl):
(aarch64_general_builtin_rsqrt): Declare.
* config/aarch64/aarch64-builtins.c (aarch64_general_add_builtin):
New function.
(aarch64_mangle_builtin_type): Rename to...
(aarch64_general_mangle_builtin_type): ...this.
(aarch64_init_fcmla_laneq_builtins, aarch64_init_simd_builtins)
(aarch64_init_crc32_builtins, aarch64_init_builtin_rsqrt)
(aarch64_init_pauth_hint_builtins, aarch64_init_tme_builtins): Use
aarch64_general_add_builtin instead of add_builtin_function.
(aarch64_init_builtins): Rename to...
(aarch64_general_init_builtins): ...this. Use
aarch64_general_add_builtin instead of add_builtin_function.
(aarch64_builtin_decl): Rename to...
(aarch64_general_builtin_decl): ...this and remove the unused
arguments.
(aarch64_expand_builtin): Rename to...
(aarch64_general_expand_builtin): ...this and remove the unused
arguments.
(aarch64_builtin_rsqrt): Rename to...
(aarch64_general_builtin_rsqrt): ...this.
(aarch64_fold_builtin): Rename to...
(aarch64_general_fold_builtin): ...this. Take the function subcode
and return type as arguments. Remove the "ignored" argument.
(aarch64_gimple_fold_builtin): Rename to...
(aarch64_general_gimple_fold_builtin): ...this. Take the function
subcode and gcall as arguments, and return the new function call.
* config/aarch64/aarch64.c (aarch64_init_builtins)
(aarch64_fold_builtin, aarch64_gimple_fold_builtin)
(aarch64_expand_builtin, aarch64_builtin_decl): New functions.
(aarch64_builtin_reciprocal): Call aarch64_general_builtin_rsqrt
instead of aarch64_builtin_rsqrt.
(aarch64_mangle_type): Call aarch64_general_mangle_builtin_type
instead of aarch64_mangle_builtin_type.
2019-09-27 Richard Sandiford <richard.sandiford@arm.com>
* target.def (check_builtin_call): New target hook.
* doc/tm.texi.in (TARGET_CHECK_BUILTIN_CALL): New @hook.
* doc/tm.texi: Regenerate.
......
......@@ -433,6 +433,22 @@ enum aarch64_svpattern {
};
#undef AARCH64_SVENUM
/* It's convenient to divide the built-in function codes into groups,
rather than having everything in a single enum. This type enumerates
those groups. */
enum aarch64_builtin_class
{
AARCH64_BUILTIN_GENERAL
};
/* Built-in function codes are structured so that the low
AARCH64_BUILTIN_SHIFT bits contain the aarch64_builtin_class
and the upper bits contain a group-specific subcode. */
const unsigned int AARCH64_BUILTIN_SHIFT = 1;
/* Mask that selects the aarch64_builtin_class part of a function code. */
const unsigned int AARCH64_BUILTIN_CLASS = (1 << AARCH64_BUILTIN_SHIFT) - 1;
void aarch64_post_cfi_startproc (void);
poly_int64 aarch64_initial_elimination_offset (unsigned, unsigned);
int aarch64_get_condition_code (rtx);
......@@ -459,7 +475,6 @@ bool aarch64_float_const_rtx_p (rtx);
bool aarch64_function_arg_regno_p (unsigned);
bool aarch64_fusion_enabled_p (enum aarch64_fusion_pairs);
bool aarch64_gen_cpymemqi (rtx *);
bool aarch64_gimple_fold_builtin (gimple_stmt_iterator *);
bool aarch64_is_extend_from_extract (scalar_int_mode, rtx, rtx);
bool aarch64_is_long_call_p (rtx);
bool aarch64_is_noplt_call_p (rtx);
......@@ -517,7 +532,6 @@ bool aarch64_symbolic_address_p (rtx);
bool aarch64_uimm12_shift (HOST_WIDE_INT);
bool aarch64_use_return_insn_p (void);
bool aarch64_use_simple_return_insn_p (void);
const char *aarch64_mangle_builtin_type (const_tree);
const char *aarch64_output_casesi (rtx *);
enum aarch64_symbol_type aarch64_classify_symbol (rtx, HOST_WIDE_INT);
......@@ -544,7 +558,6 @@ rtx aarch64_simd_vect_par_cnst_half (machine_mode, int, bool);
rtx aarch64_gen_stepped_int_parallel (unsigned int, int, int);
bool aarch64_stepped_int_parallel_p (rtx, int);
rtx aarch64_tls_get_addr (void);
tree aarch64_fold_builtin (tree, int, tree *, bool);
unsigned aarch64_dbx_register_number (unsigned);
unsigned aarch64_trampoline_size (void);
void aarch64_asm_output_labelref (FILE *, const char *);
......@@ -639,18 +652,16 @@ bool aarch64_prepare_sve_int_fma (rtx *, rtx_code);
bool aarch64_prepare_sve_cond_int_fma (rtx *, rtx_code);
#endif /* RTX_CODE */
void aarch64_init_builtins (void);
bool aarch64_process_target_attr (tree);
void aarch64_override_options_internal (struct gcc_options *);
rtx aarch64_expand_builtin (tree exp,
rtx target,
rtx subtarget ATTRIBUTE_UNUSED,
machine_mode mode ATTRIBUTE_UNUSED,
int ignore ATTRIBUTE_UNUSED);
tree aarch64_builtin_decl (unsigned, bool ATTRIBUTE_UNUSED);
tree aarch64_builtin_rsqrt (unsigned int);
const char *aarch64_general_mangle_builtin_type (const_tree);
void aarch64_general_init_builtins (void);
tree aarch64_general_fold_builtin (unsigned int, tree, unsigned int, tree *);
gimple *aarch64_general_gimple_fold_builtin (unsigned int, gcall *);
rtx aarch64_general_expand_builtin (unsigned int, tree, rtx);
tree aarch64_general_builtin_decl (unsigned, bool);
tree aarch64_general_builtin_rsqrt (unsigned int);
tree aarch64_builtin_vectorized_function (unsigned int, tree, tree);
extern void aarch64_split_combinev16qi (rtx operands[3]);
......
......@@ -11646,6 +11646,79 @@ aarch64_memory_move_cost (machine_mode mode ATTRIBUTE_UNUSED,
return aarch64_tune_params.memmov_cost;
}
/* Implement TARGET_INIT_BUILTINS. */
static void
aarch64_init_builtins ()
{
aarch64_general_init_builtins ();
}
/* Implement TARGET_FOLD_BUILTIN. */
static tree
aarch64_fold_builtin (tree fndecl, int nargs, tree *args, bool)
{
unsigned int code = DECL_MD_FUNCTION_CODE (fndecl);
unsigned int subcode = code >> AARCH64_BUILTIN_SHIFT;
tree type = TREE_TYPE (TREE_TYPE (fndecl));
switch (code & AARCH64_BUILTIN_CLASS)
{
case AARCH64_BUILTIN_GENERAL:
return aarch64_general_fold_builtin (subcode, type, nargs, args);
}
gcc_unreachable ();
}
/* Implement TARGET_GIMPLE_FOLD_BUILTIN. */
static bool
aarch64_gimple_fold_builtin (gimple_stmt_iterator *gsi)
{
gcall *stmt = as_a <gcall *> (gsi_stmt (*gsi));
tree fndecl = gimple_call_fndecl (stmt);
unsigned int code = DECL_MD_FUNCTION_CODE (fndecl);
unsigned int subcode = code >> AARCH64_BUILTIN_SHIFT;
gimple *new_stmt = NULL;
switch (code & AARCH64_BUILTIN_CLASS)
{
case AARCH64_BUILTIN_GENERAL:
new_stmt = aarch64_general_gimple_fold_builtin (subcode, stmt);
break;
}
if (!new_stmt)
return false;
gsi_replace (gsi, new_stmt, true);
return true;
}
/* Implement TARGET_EXPAND_BUILTIN. */
static rtx
aarch64_expand_builtin (tree exp, rtx target, rtx, machine_mode, int)
{
tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
unsigned int code = DECL_MD_FUNCTION_CODE (fndecl);
unsigned int subcode = code >> AARCH64_BUILTIN_SHIFT;
switch (code & AARCH64_BUILTIN_CLASS)
{
case AARCH64_BUILTIN_GENERAL:
return aarch64_general_expand_builtin (subcode, exp, target);
}
gcc_unreachable ();
}
/* Implement TARGET_BUILTIN_DECL. */
static tree
aarch64_builtin_decl (unsigned int code, bool initialize_p)
{
unsigned int subcode = code >> AARCH64_BUILTIN_SHIFT;
switch (code & AARCH64_BUILTIN_CLASS)
{
case AARCH64_BUILTIN_GENERAL:
return aarch64_general_builtin_decl (subcode, initialize_p);
}
gcc_unreachable ();
}
/* Return true if it is safe and beneficial to use the approximate rsqrt optabs
to optimize 1.0/sqrt. */
......@@ -11669,7 +11742,14 @@ aarch64_builtin_reciprocal (tree fndecl)
if (!use_rsqrt_p (mode))
return NULL_TREE;
return aarch64_builtin_rsqrt (DECL_MD_FUNCTION_CODE (fndecl));
unsigned int code = DECL_MD_FUNCTION_CODE (fndecl);
unsigned int subcode = code >> AARCH64_BUILTIN_SHIFT;
switch (code & AARCH64_BUILTIN_CLASS)
{
case AARCH64_BUILTIN_GENERAL:
return aarch64_general_builtin_rsqrt (subcode);
}
gcc_unreachable ();
}
/* Emit instruction sequence to compute either the approximate square root
......@@ -15081,7 +15161,7 @@ aarch64_mangle_type (const_tree type)
/* Mangle AArch64-specific internal types. TYPE_NAME is non-NULL_TREE for
builtin types. */
if (TYPE_NAME (type) != NULL)
return aarch64_mangle_builtin_type (type);
return aarch64_general_mangle_builtin_type (type);
/* Use the default mangling. */
return NULL;
......
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