From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sender4-pp-o91.zoho.com (sender4-pp-o91.zoho.com [136.143.188.91]) by sourceware.org (Postfix) with ESMTPS id 7550B3836C1B; Sat, 13 Feb 2021 01:35:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7550B3836C1B ARC-Seal: i=1; a=rsa-sha256; t=1613180107; cv=none; d=zohomail.com; s=zohoarc; b=WNFTaHBdA/ooLbb5GzC84JBfvqwptpbrW8SwmaNEmctPosTOg8aZKioe8Ohl/dJ1bEYocNUwQPCBB9SG/kYBdJVXIAPAXwCr8hpC1wFTKp0egT2FBsykhNaI9JNwSaHmEYk0Y9NH6036eFKYd/Zjm3XslRbQMNa7PikUJHZA1D8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613180107; h=Content-Type:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=b1Bs4GxSkELjPg2CADJtDlNPI0lsVDUWPAdcwVlNWZM=; b=kAB8CAfPV362rhKELLHlbhvphaXGn0L2SsNnKvuR64tWT4pDgVRq2CRgSD8JUu72iw/QEt7g2AMSRPzMB3+CHU0qs46Qyww2oGZQvGs2dkzoguiNQ7gMVX/fObtXyLW9PIAdKz4HvWxIXqnGIe2GwTsei4ShYpn/g7P56cBhvh0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=bouanto@zoho.com; dmarc=pass header.from= header.from= Received: from localhost (38.87.1.99 [38.87.1.99]) by mx.zohomail.com with SMTPS id 1613180106141864.7877345228588; Fri, 12 Feb 2021 17:35:06 -0800 (PST) Date: Fri, 12 Feb 2021 20:35:04 -0500 From: Antoni Boucher To: David Malcolm Cc: Antoni Boucher via Gcc-patches , jit@gcc.gnu.org, Andrea Corallo Subject: Re: [PATCH] libgccjit: Handle truncation and extension for casts [PR 95498] Message-ID: <20210213013504.o7syxz4xy3qfkq74@bouanto-desktop.localdomain> References: <20200713003002.bs5hwv4gav6ml5rt@bouanto-laptop.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-ZohoMailClient: External X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: jit@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Jit mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Feb 2021 01:35:17 -0000 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 writes: > >> 2020-07-12 Antoni Boucher >> >> 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