public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kito Cheng <kito.cheng@gmail.com>
To: Feng Wang <wangfeng@eswincomputing.com>
Cc: gcc-patches@gcc.gnu.org, jeffreyalaw@gmail.com, juzhe.zhong@rivai.ai
Subject: Re: [PATCH] RISC-V: Add avail interface into function_group_info
Date: Thu, 7 Dec 2023 20:37:45 +0800	[thread overview]
Message-ID: <CA+yXCZA1hk2OcoS5emR5UEJcYUAL1bUZHtzBipgfq+QAvNy-Bg@mail.gmail.com> (raw)
In-Reply-To: <20231207121727.1940-1-wangfeng@eswincomputing.com>

>  #ifndef DEF_RVV_FUNCTION
> -#define DEF_RVV_FUNCTION(NAME, SHAPE, PREDS, OPS_INFO)
> +#define DEF_RVV_FUNCTION(NAME, SHAPE, PREDS, OPS_INFO, AVAIL)

#define DEF_RVV_FUNCTION(NAME, SHAPE, PREDS, OPS_INFO, ...)

And add a comment to mention 5th argument is optional for AVAIL.

>  #endif
>
>  /* Internal helper functions for gimple fold use.  */
> -DEF_RVV_FUNCTION (read_vl, read_vl, none_preds, p_none_void_ops)
> -DEF_RVV_FUNCTION (vlenb, vlenb, none_preds, ul_none_void_ops)
> +DEF_RVV_FUNCTION (read_vl, read_vl, none_preds, p_none_void_ops, always)
> +DEF_RVV_FUNCTION (vlenb, vlenb, none_preds, ul_none_void_ops, always)

Then you don't need to add `always` if it's `always`.

> diff --git a/gcc/config/riscv/riscv-vector-builtins.cc b/gcc/config/riscv/riscv-vector-builtins.cc
> index 6330a3a41c3..dac638b6bcc 100644
> --- a/gcc/config/riscv/riscv-vector-builtins.cc
> +++ b/gcc/config/riscv/riscv-vector-builtins.cc
> @@ -51,6 +51,7 @@
>  #include "riscv-vector-builtins.h"
>  #include "riscv-vector-builtins-shapes.h"
>  #include "riscv-vector-builtins-bases.h"
> +#include "riscv-vector-builtins-avail.h"
>
>  using namespace riscv_vector;
>
> @@ -2684,8 +2685,9 @@ static CONSTEXPR const function_type_info function_types[] = {
>
>  /* A list of all RVV intrinsic functions.  */
>  static function_group_info function_groups[] = {
> -#define DEF_RVV_FUNCTION(NAME, SHAPE, PREDS, OPS_INFO)                         \
> -  {#NAME, &bases::NAME, &shapes::SHAPE, PREDS, OPS_INFO},
> +#define DEF_RVV_FUNCTION(NAME, SHAPE, PREDS, OPS_INFO, AVAIL)                         \

#define DEF_RVV_FUNCTION(NAME, SHAPE, PREDS, OPS_INFO, ...)

__VA_ARGS__

{#NAME, &bases::NAME, &shapes::SHAPE, PREDS, OPS_INFO,\
  __VA_ARGS__},

> +  {#NAME, &bases::NAME, &shapes::SHAPE, PREDS, OPS_INFO,\
> +   riscv_vector_avail_ ## AVAIL},
>  #include "riscv-vector-builtins-functions.def"
>  };
>
> diff --git a/gcc/config/riscv/riscv-vector-builtins.h b/gcc/config/riscv/riscv-vector-builtins.h
> index cd8ccab1724..74d50c2f849 100644
> --- a/gcc/config/riscv/riscv-vector-builtins.h
> +++ b/gcc/config/riscv/riscv-vector-builtins.h
> @@ -232,6 +232,8 @@ struct function_group_info
>       on the index value.  */
>    const predication_type_index *preds;
>    const rvv_op_info ops_infos;
> +  /* Whether the function is available.  */
> +  unsigned int (*avail) (void);

Then write a constexpr constructor like this commit:

https://github.com/gcc-mirror/gcc/commit/9e12010b5e724277ea44c300630802f464407d8d#diff-d6f7db0db31bfb339b01bec450f1b905381eb4730cc5ab2b2794971e34647d64R46-R49

>  };
>
>  class GTY ((user)) function_instance
> --
> 2.17.1
>

      parent reply	other threads:[~2023-12-07 12:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07 12:17 Feng Wang
2023-12-07 12:23 ` juzhe.zhong
2023-12-07 12:31   ` Feng Wang
2023-12-07 12:25 ` juzhe.zhong
2023-12-07 12:37 ` Kito Cheng [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=CA+yXCZA1hk2OcoS5emR5UEJcYUAL1bUZHtzBipgfq+QAvNy-Bg@mail.gmail.com \
    --to=kito.cheng@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jeffreyalaw@gmail.com \
    --cc=juzhe.zhong@rivai.ai \
    --cc=wangfeng@eswincomputing.com \
    /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).