public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Antoni Boucher <bouanto@zoho.com>,
	jit@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] libgccjit: Add vector permutation and vector access operations
Date: Mon, 20 Nov 2023 18:05:10 -0500	[thread overview]
Message-ID: <9db455400eafdfc0ed204d5949840978174380cb.camel@redhat.com> (raw)
In-Reply-To: <fedb53cc48e2062a25d9ba401f96735f42b0e9c8.camel@zoho.com>

On Fri, 2023-11-17 at 17:36 -0500, Antoni Boucher wrote:
> Hi.
> This patch adds a vector permutation and vector access operations
> (bug
> 112602).
> 
> This was split from this patch:
> https://gcc.gnu.org/pipermail/jit/2023q1/001606.html
> 

Thanks for the patch.

Overall, looks good, but 3 minor nitpicks:

[...snip...]

> diff --git a/gcc/jit/docs/topics/compatibility.rst b/gcc/jit/docs/topics/compatibility.rst
> index ebede440ee4..a764e3968d1 100644
> --- a/gcc/jit/docs/topics/compatibility.rst
> +++ b/gcc/jit/docs/topics/compatibility.rst
> @@ -378,3 +378,13 @@ alignment of a variable:
>  --------------------
>  ``LIBGCCJIT_ABI_25`` covers the addition of
>  :func:`gcc_jit_type_get_restrict`
> +
> +
> +.. _LIBGCCJIT_ABI_26:
> +
> +``LIBGCCJIT_ABI_26``
> +--------------------
> +``LIBGCCJIT_ABI_26`` covers the addition of functions to manipulate vectors:
> +
> +  * :func:`gcc_jit_context_new_rvalue_vector_perm`
> +  * :func:`gcc_jit_context_new_vector_access`
> diff --git a/gcc/jit/docs/topics/expressions.rst b/gcc/jit/docs/topics/expressions.rst
> index 42cfee36302..4a45aa13f5c 100644
> --- a/gcc/jit/docs/topics/expressions.rst
> +++ b/gcc/jit/docs/topics/expressions.rst
> @@ -295,6 +295,35 @@ Vector expressions
>  
>        #ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_rvalue_from_vector
>  
> +.. function:: gcc_jit_rvalue * \
> +              gcc_jit_context_new_rvalue_vector_perm (gcc_jit_context *ctxt, \
> +                                                      gcc_jit_location *loc, \
> +                                                      gcc_jit_rvalue *elements1, \
> +                                                      gcc_jit_rvalue *elements2, \
> +                                                      gcc_jit_rvalue *mask);
> +
> +   Build a permutation of two vectors.
> +
> +   "elements1" and "elements2" should have the same type.
> +   The length of "mask" and "elements1" should be the same.
> +   The element type of "mask" should be integral.
> +   The size of the element type of "mask" and "elements1" should be the same.
> +
> +   This entrypoint was added in :ref:`LIBGCCJIT_ABI_25`; you can test for
                                                       ^^
Should be 26

[...snip...]

>  Unary Operations
>  ****************
>  
> @@ -1020,3 +1049,27 @@ Field access is provided separately for both lvalues and rvalues.
>        PTR[INDEX]
>  
>     in C (or, indeed, to ``PTR + INDEX``).
> +
> +.. function:: gcc_jit_lvalue *\
> +              gcc_jit_context_new_vector_access (gcc_jit_context *ctxt,\
> +                                                 gcc_jit_location *loc,\
> +                                                 gcc_jit_rvalue *vector,\
> +                                                 gcc_jit_rvalue *index)
> +
> +   Given an rvalue of vector type ``T __attribute__ ((__vector_size__ (SIZE)))``, get the element `T` at
> +   the given index.
> +
> +   This entrypoint was added in :ref:`LIBGCCJIT_ABI_25`; you can test for
                                                       ^^

Likewise here.

[...snip...]

> @@ -4071,6 +4107,79 @@ gcc_jit_context_new_rvalue_from_vector (gcc_jit_context *ctxt,
>       (gcc::jit::recording::rvalue **)elements);
>  }
>  
> +/* Public entrypoint.  See description in libgccjit.h.
> +
> +   After error-checking, the real work is done by the
> +   gcc::jit::recording::context::new_rvalue_vector_perm method, in
> +   jit-recording.cc.  */
> +
> +gcc_jit_rvalue *
> +gcc_jit_context_new_rvalue_vector_perm (gcc_jit_context *ctxt,
> +					gcc_jit_location *loc,
> +					gcc_jit_rvalue *elements1,
> +					gcc_jit_rvalue *elements2,
> +					gcc_jit_rvalue *mask)
> +{
> +  RETURN_NULL_IF_FAIL (ctxt, NULL, loc, "NULL ctxt");
> +  JIT_LOG_FUNC (ctxt->get_logger ());
> +
> +  /* LOC can be NULL.  */

...but "elements1", "elements2", and "mask" must not be NULL, as
they're dereferenced below.  So this is going to need something like
the following (untested):

  RETURN_NULL_IF_FAIL (elements1, ctxt, loc, "NULL elements1");
  RETURN_NULL_IF_FAIL (elements2, ctxt, loc, "NULL elements2");
  RETURN_NULL_IF_FAIL (mask, ctxt, loc, "NULL mask");

[...snip...]

OK with those fixed.

Thanks
Dave


  reply	other threads:[~2023-11-20 23:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-17 22:36 Antoni Boucher
2023-11-20 23:05 ` David Malcolm [this message]
2023-11-30 22:16   ` Antoni Boucher
2024-01-19 20:21     ` Antoni Boucher
2024-02-17 16:54       ` Antoni Boucher

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=9db455400eafdfc0ed204d5949840978174380cb.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=bouanto@zoho.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jit@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).