public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: Antoni Boucher <bouanto@zoho.com>
To: David Malcolm <dmalcolm@redhat.com>
Cc: Antoni Boucher via Gcc-patches <gcc-patches@gcc.gnu.org>,
	jit@gcc.gnu.org, Andrea Corallo <andrea.corallo@arm.com>
Subject: Re: [PATCH] libgccjit: Handle truncation and extension for casts [PR 95498]
Date: Fri, 12 Feb 2021 20:35:04 -0500	[thread overview]
Message-ID: <20210213013504.o7syxz4xy3qfkq74@bouanto-desktop.localdomain> (raw)
In-Reply-To: <gkr8sfczhd6.fsf@arm.com>

Hi.
I'd like to know what's the status of the review for this patch.
(Same for my other patch 96889: add some reflection functions in the jit 
C api)
Thanks.

On Tue, Jul 21, 2020 at 11:29:57PM +0200, Andrea Corallo wrote:
>Hi Antoni,
>
>a couple of nits and some thoughts.
>
>Antoni Boucher via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
>
>> 2020-07-12  Antoni Boucher  <bouanto@zoho.com>
>>
>> gcc/jit/
>> 	PR target/95498
>> 	* jit-playback.c: Add support to handle truncation and extension
>                       ^^^
>                       here we usually add the function that gets
>modified, you can look at other changelog entries as example.
>
>> diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
>> index 0fddf04da87..4f4a1080c36 100644
>> --- a/gcc/jit/jit-playback.c
>> +++ b/gcc/jit/jit-playback.c
>> @@ -61,22 +61,39 @@ along with GCC; see the file COPYING3.  If not see
>>
>>  /* gcc::jit::playback::context::build_cast uses the convert.h API,
>>     which in turn requires the frontend to provide a "convert"
>> -   function, apparently as a fallback.
>> -
>> -   Hence we provide this dummy one, with the requirement that any casts
>> -   are handled before reaching this.  */
>> +   function, apparently as a fallback for casts that can be simplified
>> +   (truncation, extension). */
>>  extern tree convert (tree type, tree expr);
>>
>>  tree
>>  convert (tree dst_type, tree expr)
>>  {
>> -  gcc_assert (gcc::jit::active_playback_ctxt);
>> -  gcc::jit::active_playback_ctxt->add_error (NULL, "unhandled conversion");
>> -  fprintf (stderr, "input expression:\n");
>> -  debug_tree (expr);
>> -  fprintf (stderr, "requested type:\n");
>> -  debug_tree (dst_type);
>> -  return error_mark_node;
>> +  tree t_ret = NULL;
>> +  t_ret = targetm.convert_to_type (dst_type, expr);
>> +  if (t_ret)
>> +      return t_ret;
>        ^^^
>        indent nit
>> +  enum tree_code dst_code = TREE_CODE (dst_type);
>> +  switch (dst_code)
>> +    {
>> +    case INTEGER_TYPE:
>> +    case ENUMERAL_TYPE:
>> +      t_ret = convert_to_integer (dst_type, expr);
>> +      goto maybe_fold;
>> +
>> +    default:
>> +      gcc_assert (gcc::jit::active_playback_ctxt);
>> +      gcc::jit::active_playback_ctxt->add_error (NULL, "unhandled conversion");
>> +      fprintf (stderr, "input expression:\n");
>> +      debug_tree (expr);
>> +      fprintf (stderr, "requested type:\n");
>> +      debug_tree (dst_type);
>> +      return error_mark_node;
>> +
>> +    maybe_fold:
>> +      if (TREE_CODE (t_ret) != C_MAYBE_CONST_EXPR)
>> +	t_ret = fold (t_ret);
>> +      return t_ret;
>> +    }
>>  }
>
>Looking at 'convert' at c-convert.c:66 the INTEGER_TYPE case here looks
>good, but given the set of casts we accept as input I guess we should
>handle also POINTER_TYPE, BOOLEAN_TYPE and REAL_TYPE.  What do you think
>about?
>
>Hope it helps
>
>Bests
>
>  Andrea

  parent reply	other threads:[~2021-02-13  1:35 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-13  0:30 Antoni Boucher
2020-07-14 21:15 ` David Malcolm
2020-07-21 21:29 ` Andrea Corallo
2020-10-15 19:00   ` Antoni Boucher
2021-02-13  1:35   ` Antoni Boucher [this message]
2021-02-20 18:20 ` Tom Tromey
2021-02-20 22:17   ` Antoni Boucher
2021-05-13  8:34     ` Martin Liška
2021-05-13 22:13     ` David Malcolm
2021-05-13 23:31       ` Antoni Boucher
2021-05-13 23:58         ` David Malcolm
2021-05-26  0:16           ` Antoni Boucher
2021-05-27 22:21             ` David Malcolm
2021-05-28  1:22               ` Antoni Boucher
2021-06-11 17:49                 ` David Malcolm
2021-06-18 20:42                   ` Antoni Boucher
2021-06-18 20:54                     ` David Malcolm
2021-06-18 21:11                       ` Antoni Boucher
2021-06-19  9:08                         ` Bernhard Reutner-Fischer
2021-07-06 13:00                           ` Antoni Boucher
2021-07-08 20:44                             ` David Malcolm
2021-07-08 21:28                               ` Antoni Boucher
2021-07-08 21:34                                 ` David Malcolm

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=20210213013504.o7syxz4xy3qfkq74@bouanto-desktop.localdomain \
    --to=bouanto@zoho.com \
    --cc=andrea.corallo@arm.com \
    --cc=dmalcolm@redhat.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).