public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: Andrew Carlotti <andrew.carlotti@arm.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH v2.1 3/4] aarch64: Consolidate simd type lookup functions
Date: Wed, 20 Jul 2022 09:24:24 +0100	[thread overview]
Message-ID: <mpt35ewur7r.fsf@arm.com> (raw)
In-Reply-To: <Ytb2X5CUOy8lFSIK@e124511.cambridge.arm.com> (Andrew Carlotti's message of "Tue, 19 Jul 2022 19:22:23 +0100")

Andrew Carlotti <andrew.carlotti@arm.com> writes:
> On Wed, Jul 13, 2022 at 05:36:04PM +0100, Richard Sandiford wrote:
>> I like the part about getting rid of:
>> 
>> static tree
>> aarch64_simd_builtin_type (machine_mode mode,
>> 			   bool unsigned_p, bool poly_p)
>> 
>> and the flow of the new function.  However, I think it's still
>> slightly more readable if we keep the switch and lookup routines
>> separate, partly to keep down the size of the main routine and
>> partly to avoid the goto.
>
> I agree.
>
>> So how about:
>> 
>> - aarch64_simd_builtin_std_type becomes aarch64_int_or_fp_element_type
>>   but otherwise stays as-is
>>
>> ...
>
> I've called it aarch64_int_or_fp_type, because it's sometimes used for
> an operand that doesn't represent an element of a vector.
>
>
> Updated patch below.
>
> ---
>
> There were several similarly-named functions, which each built or looked up an
> operand type using a different subset of valid modes or qualifiers.
>
> This change provides a single function to return operand types, which can
> additionally handle const and pointer qualifiers. For clarity, the existing
> functionality is kept in separate helper functions.
>
> gcc/ChangeLog:
>
> 	* config/aarch64/aarch64-builtins.cc
> 	(aarch64_simd_builtin_std_type): Rename to...
> 	(aarch64_int_or_fp_type): ...this, and allow irrelevant qualifiers.
> 	(aarch64_lookup_simd_builtin_type): Rename to...
> 	(aarch64_simd_builtin_type): ...this. Add const/pointer
> 	support, and extract table lookup to...
> 	(aarch64_lookup_simd_type_in_table): ...this function.
> 	(aarch64_init_crc32_builtins): Update to use aarch64_simd_builtin_type.
> 	(aarch64_init_fcmla_laneq_builtins): Ditto.
> 	(aarch64_init_simd_builtin_functions): Ditto.

LGTM, thanks.  OK for trunk with a couple of minor formatting fixes:

> diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc
> index 55ad2e8b6831d6cc2b039270c8656d429347092d..cd7c2a79d9b4d67adf1d9de1f9b56eb3a0d1ee2b 100644
> --- a/gcc/config/aarch64/aarch64-builtins.cc
> +++ b/gcc/config/aarch64/aarch64-builtins.cc
> @@ -788,12 +788,13 @@ aarch64_general_mangle_builtin_type (const_tree type)
>    return NULL;
>  }
>  
> +/* Helper function for aarch64_simd_builtin_type. */
>  static tree
> -aarch64_simd_builtin_std_type (machine_mode mode,
> -			       enum aarch64_type_qualifiers q)
> +aarch64_int_or_fp_type (machine_mode mode,
> +			       enum aarch64_type_qualifiers qualifiers)

This line should be reindented so that the arguments continue to line up.

>  {
> -#define QUAL_TYPE(M)  \
> -  ((q == qualifier_none) ? int##M##_type_node : unsigned_int##M##_type_node);
> +#define QUAL_TYPE(M) ((qualifiers & qualifier_unsigned) \
> +		       ? unsigned_int##M##_type_node : int##M##_type_node);
>    switch (mode)
>      {
>      case E_QImode:
> [...]
> @@ -1383,13 +1381,13 @@ aarch64_init_simd_builtins (void)
>  static void
>  aarch64_init_crc32_builtins ()
>  {
> -  tree usi_type = aarch64_simd_builtin_std_type (SImode, qualifier_unsigned);
> +  tree usi_type = aarch64_simd_builtin_type (SImode, qualifier_unsigned);
>    unsigned int i = 0;
>  
>    for (i = 0; i < ARRAY_SIZE (aarch64_crc_builtin_data); ++i)
>      {
>        aarch64_crc_builtin_datum* d = &aarch64_crc_builtin_data[i];
> -      tree argtype = aarch64_simd_builtin_std_type (d->mode,
> +      tree argtype = aarch64_simd_builtin_type (d->mode,
>  						    qualifier_unsigned);

Same here.

Richard

>        tree ftype = build_function_type_list (usi_type, usi_type, argtype, NULL_TREE);
>        tree attrs = aarch64_get_attributes (FLAG_NONE, d->mode);

      reply	other threads:[~2022-07-20  8:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-13 13:41 [PATCH v2 " Andrew Carlotti
2022-07-13 16:36 ` Richard Sandiford
2022-07-19 18:22   ` [PATCH v2.1 " Andrew Carlotti
2022-07-20  8:24     ` Richard Sandiford [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mpt35ewur7r.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=andrew.carlotti@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).