From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2075.outbound.protection.outlook.com [40.107.21.75]) by sourceware.org (Postfix) with ESMTPS id 4C7F5389244D; Wed, 22 Jul 2020 08:45:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4C7F5389244D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Andrea.Corallo@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rrho3+ZpfX1AOflAfyQto0QDPl0IY/TLpCXAVpqwW5w=; b=H71sFwLlGLqXXqofGeGZ1btcwp91zy6mj0fwq5iT04FOrduzV1T0Y8mzZVxcwqXjhqLbDpGcvyBmW2T7sp3QY7/3WyQlUhxHC2oaPaQ2q9adAKEBM4/3SfUYiURaTi9F/tt0Ec/5fjbE7u93rSs/7kS2P/pXdAHhwzIk54C0HQ0= Received: from MR2P264CA0056.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:31::20) by VI1PR08MB3325.eurprd08.prod.outlook.com (2603:10a6:803:3e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.18; Wed, 22 Jul 2020 08:45:31 +0000 Received: from VE1EUR03FT042.eop-EUR03.prod.protection.outlook.com (2603:10a6:500:31:cafe::2d) by MR2P264CA0056.outlook.office365.com (2603:10a6:500:31::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.21 via Frontend Transport; Wed, 22 Jul 2020 08:45:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; gcc.gnu.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;gcc.gnu.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT042.mail.protection.outlook.com (10.152.19.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.10 via Frontend Transport; Wed, 22 Jul 2020 08:45:30 +0000 Received: ("Tessian outbound 73b502bf693a:v62"); Wed, 22 Jul 2020 08:45:30 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 903ed6e063a0425e X-CR-MTA-TID: 64aa7808 Received: from 28d436667cb2.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id BDCDE5DA-86E2-4E4D-8804-E1ABA289861A.1; Wed, 22 Jul 2020 08:45:24 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 28d436667cb2.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 22 Jul 2020 08:45:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aWAt8OvgCx6AxfZBatab6VlYEEc1GTVJM7afQJGawrKL6U7uyBWs8QICQ2N0g+sN5XpXCOROoIvxndw23hP8oJmmXe3sImH5efAIiOOmy7vGnsqWkWUfAy/0HVVwmI/lVSYb1veFWItQRuCzgJJa59oLQSxnN9sOzJKfCtxKfIJrr1x/Z4/XPgcVU+0QPcg73g7E6HmWBYNol67N9g+buXNGlMfF72onX8068ipWkCvoSBLp7oo/nsb0VOCVBC1c0u4Qm2TGhCbda0iz1dm5dxsYdWFCCUuq240+EOGImhEjpcXWffnEIA4JEBfXEA7kQvIB/Fh2uWZnvCFT2vC22w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rrho3+ZpfX1AOflAfyQto0QDPl0IY/TLpCXAVpqwW5w=; b=LzD6ZPEUnu6EGg4RhkcaZveKni0Xjnndo/mVkRhzBhuKDheuj0qzZlh1ojijnq3UQ7yXJy4PBHKIQjow1BgrQMtfjYvt4cNL73KRza/hds/zbwtS5gfRP8afcM8jhl0pRapE1YfA0Yz8SZklL5mXN68FLXMgcZiQ4x4pY9kaVsti2kv+6fUMrhPI+XgdF3bSViACJm7GkkBOoMdmp+H8oUB2G5jZc1J5oiMCXP5C6DqpFMFn4JQxjhYVQPUvmygS1cncSnAb6n4WIqhLmlPL4ZnKRoLSE5ueJullOirr5fwCAdlHOw8OrtCOdVsEP5tbJjv1RQ19sDlbw8aoNWzFZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rrho3+ZpfX1AOflAfyQto0QDPl0IY/TLpCXAVpqwW5w=; b=H71sFwLlGLqXXqofGeGZ1btcwp91zy6mj0fwq5iT04FOrduzV1T0Y8mzZVxcwqXjhqLbDpGcvyBmW2T7sp3QY7/3WyQlUhxHC2oaPaQ2q9adAKEBM4/3SfUYiURaTi9F/tt0Ec/5fjbE7u93rSs/7kS2P/pXdAHhwzIk54C0HQ0= Authentication-Results-Original: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; Received: from DB7PR08MB3594.eurprd08.prod.outlook.com (2603:10a6:10:4e::11) by DBBPR08MB4823.eurprd08.prod.outlook.com (2603:10a6:10:df::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.17; Wed, 22 Jul 2020 08:45:22 +0000 Received: from DB7PR08MB3594.eurprd08.prod.outlook.com ([fe80::9f3:461:834d:7ca]) by DB7PR08MB3594.eurprd08.prod.outlook.com ([fe80::9f3:461:834d:7ca%7]) with mapi id 15.20.3195.026; Wed, 22 Jul 2020 08:45:22 +0000 From: Andrea Corallo To: Alex Coplan Cc: "jit@gcc.gnu.org" , nd , David Malcolm , gcc-patches@gcc.gnu.org Subject: [PATCH] libgccjit: Improve doc and comments regarding type casts (Was: Clarifying the permitted type conversions) References: Date: Wed, 22 Jul 2020 10:45:20 +0200 In-Reply-To: (Alex Coplan's message of "Thu, 9 Jul 2020 14:15:14 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Content-Type: multipart/mixed; boundary="=-=-=" X-ClientProxiedBy: LO2P123CA0068.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1::32) To DB7PR08MB3594.eurprd08.prod.outlook.com (2603:10a6:10:4e::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from e112547 (217.140.99.251) by LO2P123CA0068.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.22 via Frontend Transport; Wed, 22 Jul 2020 08:45:21 +0000 X-Originating-IP: [217.140.99.251] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b7cd6d72-3759-40ab-a5d6-08d82e1b9734 X-MS-TrafficTypeDiagnostic: DBBPR08MB4823:|VI1PR08MB3325: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: XbF69k9IsyydUkXE2oxW0rLSjWznS1vFS1GqRrZzlm9ct+y1pvHhEfyxXdLrWxUZEdMCA8QOXmjCMMWDHUXxC/Ruk1nA3UlORtglCylJf/87dBqIJiLxeOL2K5U5q16Q+F7MIczcj/gd2pnrBed3oo+vWD8/gt9h292NDSvVIT0a3eM2Kd6yf4NQe3CrLvg6MZs1yh2UeSpkdGJ/nodk8fqErhb6GkTzq9q8QvXDhZRZGsp/GFB1VwWCgGCQ3n1C5Exe927U7jT2Lv6jxccybz8abKprbW5Io+CIa06Tj9uaO8IHXjPs7VFBH6sO66d8 X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR08MB3594.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39850400004)(366004)(136003)(396003)(376002)(346002)(37006003)(54906003)(6636002)(8936002)(6486002)(316002)(86362001)(956004)(2616005)(44832011)(8676002)(2906002)(53546011)(66556008)(66476007)(4326008)(36756003)(16526019)(478600001)(52116002)(26005)(186003)(6862004)(83380400001)(5660300002)(66946007)(6496006)(66616009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 7CV1FPWeploYo0etLj0bERemE2sa+blGIutCw5CDlYfoc8bKlEszlHifSPULTiBwHREJEPs+pfn50uBsGz4Js46IBzC4VpXs4UyJYRZAlTLRsDVTDXhhJHRlMFUzOEOcmJG+XWyOjJK528g4ly/zm3240Zs8mAwS0to2InGQ+xxCn6Ve2vqkeObxlT2Awnl9UIqwNcQiXOLpmTqeEGckqYLF0d82ULiZBHvVmwrxpkldk04a1U7gDjX7DmWp4XK7uqYsm7/K0FIWl7JKdvFylafFc5xhrtlVI7sEzdnsW8U1knmrdVWFvDe4HpYK6DsFpWibW0DqOOh7w1DL8bjKAkHC/7x98YobRFVE0IrQjEy0yoqXbBT+rd1fWC0ctMUIw9NfcazWhsGEeM6Blxi0g0A59p1WODkvZlbgAHlYulSz3eZHqqqRxaMulDpu5JgDDY+fTlMvl3sLhnN6snNzOpNNmPVYuT82ZDaDrBFshI5amrOQ1fxu+cjXlfmx9OEg X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4823 Original-Authentication-Results: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT042.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFTY:; SFS:(4636009)(136003)(346002)(39860400002)(376002)(396003)(46966005)(47076004)(6496006)(450100002)(8676002)(82740400003)(70586007)(6636002)(86362001)(5660300002)(36756003)(54906003)(37006003)(8936002)(66616009)(70206006)(956004)(6486002)(26005)(53546011)(2616005)(4326008)(82310400002)(478600001)(16526019)(83380400001)(36906005)(316002)(186003)(2906002)(81166007)(44832011)(356005)(6862004)(336012); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 71ecda91-d41f-48f5-e305-08d82e1b9209 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qD3eMh5t77ZjKNreGdSs+1Ui2lkVY3R05gQCQtyVa4xrLMXYtlDATB3Sxb41MGNrLHTqSdNbOKOHCwHOmWCWw7AShonPgjCIV20qq4IEefHxB28JuC/b8fwd8lqZDRWbDW7W+wX2/a721T5Gw/fUlqJ7hoqTgSYMp2oOdBFnvTlPWDj3FaeciHib/ErBTpNKraL7OajQKDZIVX9UMxlJEeh3WlL+8eXq7LSBPNs8Lxyk54pul3gZmtDhgCa4+ZYLRYlVBAD2tbPxMPZExAnyn3JRcIme/cnjPsYkdfjrei5tYHOoSRMc3bBToC0cr0S5g6T3qFO9inrIeo83sRZgefP4+DRj4wIDJXtgpsngrgHKoTNz5TuAA4TL+TyxsWPSRbWD6FeyifN+qwx2C+o2EA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2020 08:45:30.7160 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7cd6d72-3759-40ab-a5d6-08d82e1b9734 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3325 X-Spam-Status: No, score=-15.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY 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: Wed, 22 Jul 2020 08:45:35 -0000 --=-=-= Content-Type: text/plain Alex Coplan writes: > Secondly, I wanted to clarify the situation with respect to explicit > casts; that is, those conversions allowed by gcc_jit_context_new_cast(). > The docs [0] say: > > Currently only a limited set of conversions are possible: > - int <-> float > - int <-> bool > - P* <-> Q*, for pointer types P and Q > > However, empirically (at least on aarch64), libgccjit appears to allow > me to compile casts between any pair of types in the following set > without any complaint: > > { > SIGNED_CHAR, > UNSIGNED_CHAR, > SHORT, > UNSIGNED_SHORT, > INT, > UNSIGNED_INT, > LONG, > UNSIGNED_LONG, > LONG_LONG, > UNSIGNED_LONG_LONG > } Hi Alex, Looking at the code I believe all these casts are meant to be supported (read your intuition was correct). Also IMO source of confusion is that the doc is mentioning 'int' and 'float' but I believe would be better to have like 'integral' and 'floating-point' to clearly disambiguates with respect to the C types. AFAIU the set of supported casts should be like: integral <-> integral floating-point <-> floating-point integral <-> floating-point integral <-> bool P* <-> Q* for pointer types P and Q. I'd propose to install the following patch to make doc and comments homogeneous at documenting what do we accept, and I guess we should just consider bugs if some of these conversions is not handled correctly or leads to ICE. Bests Andrea gcc/jit/ChangeLog 2020-07-21 Andrea Corallo * docs/_build/texinfo/libgccjit.texi (Type-coercion): Improve doc on allowed type casting. * docs/topics/expressions.rst (gccjit::context::new_cast) (gcc_jit_context_new_cast): Likewise. * libgccjit.c: Improve comment on allowed type casting. * libgccjit.h: Likewise --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-libgccjit-improve-documentation-on-type-conversions.patch >From 914b9e86808c947d4bb2b06c6960fd8031125f67 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Tue, 21 Jul 2020 20:12:23 +0200 Subject: [PATCH] libgccjit: improve documentation on type conversions gcc/jit/ChangeLog 2020-07-21 Andrea Corallo * docs/_build/texinfo/libgccjit.texi (Type-coercion): Improve doc on allowed type casting. * docs/topics/expressions.rst (gccjit::context::new_cast) (gcc_jit_context_new_cast): Likewise. * libgccjit.c: Improve comment on allowed type casting. * libgccjit.h: Likewise --- gcc/jit/docs/_build/texinfo/libgccjit.texi | 30 +++++++++++++++------- gcc/jit/docs/topics/expressions.rst | 8 +++--- gcc/jit/libgccjit.c | 8 +++--- gcc/jit/libgccjit.h | 7 +++-- 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/gcc/jit/docs/_build/texinfo/libgccjit.texi b/gcc/jit/docs/_build/texinfo/libgccjit.texi index 1e14be010426..b170f24d1bb1 100644 --- a/gcc/jit/docs/_build/texinfo/libgccjit.texi +++ b/gcc/jit/docs/_build/texinfo/libgccjit.texi @@ -6685,13 +6685,19 @@ Currently only a limited set of conversions are possible: @itemize * @item -int <-> float +integral <-> integral @item -int <-> bool +floating-point <-> floating-point @item -P* <-> Q*, for pointer types P and Q +integral <-> floating-point + +@item +integral <-> bool + +@item +P* <-> Q* for pointer types P and Q @end itemize @end quotation @end deffn @@ -12964,14 +12970,20 @@ Currently only a limited set of conversions are possible: @itemize * -@item -int <-> float +@item +integral <-> integral -@item -int <-> bool +@item +floating-point <-> floating-point -@item -P* <-> Q*, for pointer types P and Q +@item +integral <-> floating-point + +@item +integral <-> bool + +@item +P* <-> Q*, for pointer types P and Q @end itemize @end quotation @end deffn diff --git a/gcc/jit/docs/topics/expressions.rst b/gcc/jit/docs/topics/expressions.rst index d783ceea51a8..051cee5db211 100644 --- a/gcc/jit/docs/topics/expressions.rst +++ b/gcc/jit/docs/topics/expressions.rst @@ -504,9 +504,11 @@ Type-coercion Currently only a limited set of conversions are possible: - * int <-> float - * int <-> bool - * P* <-> Q*, for pointer types P and Q + * integral <-> integral + * floating-point <-> floating-point + * integral <-> floating-point + * integral <-> bool + * P* <-> Q* for pointer types P and Q Lvalues ------- diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c index 3d04f6db3aff..403233d5577a 100644 --- a/gcc/jit/libgccjit.c +++ b/gcc/jit/libgccjit.c @@ -1629,9 +1629,11 @@ gcc_jit_context_new_call_through_ptr (gcc_jit_context *ctxt, We only permit these kinds of cast: - int <-> float - int <-> bool - P* <-> Q* for pointer types P and Q. */ + integral <-> integral + floating-point <-> floating-point + integral <-> floating-point + integral <-> bool + P* <-> Q* for pointer types P and Q. */ static bool is_valid_cast (gcc::jit::recording::type *src_type, diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h index 1c5a12e9c015..228befa896d7 100644 --- a/gcc/jit/libgccjit.h +++ b/gcc/jit/libgccjit.h @@ -996,8 +996,11 @@ gcc_jit_context_new_call_through_ptr (gcc_jit_context *ctxt, /* Type-coercion. Currently only a limited set of conversions are possible: - int <-> float - int <-> bool */ + integral <-> integral + floating-point <-> floating-point + integral <-> floating-point + integral <-> bool + P* <-> Q* for pointer types P and Q. */ extern gcc_jit_rvalue * gcc_jit_context_new_cast (gcc_jit_context *ctxt, gcc_jit_location *loc, -- 2.17.1 --=-=-=--