From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120055.outbound.protection.outlook.com [40.107.12.55]) by sourceware.org (Postfix) with ESMTPS id B59F33857007; Wed, 1 Jul 2020 16:15:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B59F33857007 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=ws6VZ4+Dt7VWmYDEMmlm8YaJSV0mlng51voyQKAiLLs=; b=69hPc2EsAdRkNYts1eYd8s2LvYOjvB05ulzJ0B8yQVgrmWxgFMV9PvTR8uaeoY32T8zIsdOqoNY0bfu0A01k4RD8+Iz6lNdxDOSUuH0nhYgIEsHWKBuZxLbBh714ZoOGT8iQrKur6LvdkA63FsNu7KMiC4dzqtMyLPMODptAkwY= Received: from MR2P264CA0006.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:1::18) by PR2PR08MB4683.eurprd08.prod.outlook.com (2603:10a6:101:27::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.21; Wed, 1 Jul 2020 16:15:08 +0000 Received: from VE1EUR03FT046.eop-EUR03.prod.protection.outlook.com (2603:10a6:500:1:cafe::7f) by MR2P264CA0006.outlook.office365.com (2603:10a6:500:1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.20 via Frontend Transport; Wed, 1 Jul 2020 16:15:07 +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 VE1EUR03FT046.mail.protection.outlook.com (10.152.19.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20 via Frontend Transport; Wed, 1 Jul 2020 16:15:07 +0000 Received: ("Tessian outbound f7489b7e84a7:v62"); Wed, 01 Jul 2020 16:15:07 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 91a3a7f448bfc512 X-CR-MTA-TID: 64aa7808 Received: from 9aa33bc19d8e.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 498D7A82-8CC7-4CAD-8062-DF5734587F64.1; Wed, 01 Jul 2020 16:15:01 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9aa33bc19d8e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 01 Jul 2020 16:15:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D4yZxlYxkuAovYkwfJXH/7z3E8rtIKZV6wrzbdTOfubVl7cX+zDE/0PKAU2AheR4f8VpzVMDyk2QVwpW4jihoMdrBhSpXQ49VZDm1nmACZlADiQ4VnypldRwpR7QeSlz3+BUTNvVlVkFCYhiVmtXVtSaNW+8vE1OLQUcqKcELHzEZv7dRIRUmA/ftHP++SHibYesakQ6tNBjPGTUJhHksj+tMnUXeLV4ZOQv0g/4+G1kWnTNTu2gT5sv1xBuLlv/lcFafOppqz0fMFGle39aIWFoFfdA7UeYk2sUx0Y3DDugsr3DVMOM2rqQy+tski+vPFhkEvsspCCqo6XASWDakw== 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=ws6VZ4+Dt7VWmYDEMmlm8YaJSV0mlng51voyQKAiLLs=; b=Fubwh9W90UbbT9KnKXfowa2uXvYIF1Cnj1P7uWM7mnBdSOuIWAGvj1E+2EJTPhbP3D3mmyLZk4moX8zQblMdwaHlNl2aCRHL67TFsRLApA1YkI7ULL9u3c5Z1bzQ/drGtQFSeFWUerPAnGanpnFi84Zg/IP2FOxlHkXs124Q3OfrHaCjT/IC/CI/Zwahub8HeHi/3zK+NGfPGx8c1nNP59KpCNOH9L/ctBKWMZT1qR/0Sonmo4EAEF/cSiQbXiDmvJbECHP3NaQRQcWcbfIR6x0GuyDs+aUWUKkqXeDraFhNcPtBqt5q3Cc4iuOW76fkAkLQVEGHVezJ05ORg4bKMQ== 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=ws6VZ4+Dt7VWmYDEMmlm8YaJSV0mlng51voyQKAiLLs=; b=69hPc2EsAdRkNYts1eYd8s2LvYOjvB05ulzJ0B8yQVgrmWxgFMV9PvTR8uaeoY32T8zIsdOqoNY0bfu0A01k4RD8+Iz6lNdxDOSUuH0nhYgIEsHWKBuZxLbBh714ZoOGT8iQrKur6LvdkA63FsNu7KMiC4dzqtMyLPMODptAkwY= 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 DB7PR08MB3516.eurprd08.prod.outlook.com (2603:10a6:10:4f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.21; Wed, 1 Jul 2020 16:14:59 +0000 Received: from DB7PR08MB3594.eurprd08.prod.outlook.com ([fe80::5447:f1c0:97c:aa35]) by DB7PR08MB3594.eurprd08.prod.outlook.com ([fe80::5447:f1c0:97c:aa35%7]) with mapi id 15.20.3131.028; Wed, 1 Jul 2020 16:14:59 +0000 From: Andrea Corallo To: David Malcolm Cc: jit@gcc.gnu.org, nd@arm.com, gcc-patches@gcc.gnu.org Subject: Re: [PATCH] libgccjit: Add new gcc_jit_context_new_blob entry point References: <59a8d345c642d49281a601278946e087a4bbe3e2.camel@redhat.com> <87zh9kumwi.fsf@arm.com> Date: Wed, 01 Jul 2020 18:14:52 +0200 In-Reply-To: <87zh9kumwi.fsf@arm.com> (Andrea Corallo's message of "Wed, 03 Jun 2020 17:36:29 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Content-Type: text/plain X-ClientProxiedBy: DM6PR18CA0013.namprd18.prod.outlook.com (2603:10b6:5:15b::26) 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 DM6PR18CA0013.namprd18.prod.outlook.com (2603:10b6:5:15b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.20 via Frontend Transport; Wed, 1 Jul 2020 16:14:57 +0000 X-Originating-IP: [217.140.99.251] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 2be6725b-a89d-453d-44f7-08d81dd9ebae X-MS-TrafficTypeDiagnostic: DB7PR08MB3516:|PR2PR08MB4683: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-Forefront-PRVS: 04519BA941 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: WBx+9zm2QS1EK2UmBCawUsTTtTB83Jg5ufKBTTmp94EBfYej6yFaMzIKA2l8pmNFZsxAzSlkZsZpE9uBm7gTRX4L3mN7db7OFCsyVlauBRIfIOVoafvc5o/tDagT+qmN5rVcbfISscLwi9U0sxEw8xogbsh0sZMjABL/+Mflx3SbMJ30T96gWz2W+iIfBTSHcvzLuMGWioOkGy1Fzcxnbdbvo7VT0Z7klt9QIi+N2WHlQ1Pij3ZHNRtkw0zFcUCeBneFd3iIxdZB0SQvSBrRX/2KLdUtlgKJV1JD9GZ98LNRVHg/nMo33QDsndkHmPoJCT9MA73KceX0MWDebJ24hg== 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)(396003)(346002)(366004)(39860400002)(376002)(136003)(83380400001)(478600001)(2616005)(5660300002)(66556008)(66476007)(6486002)(26005)(6666004)(186003)(4326008)(52116002)(8936002)(66946007)(16526019)(956004)(6916009)(6496006)(316002)(86362001)(44832011)(36756003)(8676002)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: VPBp5fqOczE36O+MGE16bC/VAjxDzYEm+pu+aEK7Mmyo1IrLdndI24qsqMr866kBTVh0firUo4nyww4bb3G1tP7178TktJm7RDC1uArI5L3UPCn7dlVGPXlYF+SLAM6vFRIFY5MdEesTjs+kcrjsvn+1zjX4ucGu/2sPEou/kRhmfiVWbwJ8xJ7pF93R02lpmk/A3bkktvclL28snZ55rcXWgwQUHIGm65y7Op43nXLvcgmw/vmti0G6ExCdM03qiiaK5YU6P3iBI1bfhyBAe7pWaJL2Y5qBZRhFYZ5uYH6xm7Uq9YXiQi6Bt0BJwjEI+imebGUEhroSwsR/bHsjJbmmvSZtqobtF9g3twjs/Y/nHczdXbBxXAZT2ZEZnWO16jlXH4a7wfoXC5kde2vqQaUVv/2vnnCDxvV1TYhFuUqNIMoNLy47DBaMIsscXr+3V3BLhzQsziKqLnWBDmHhdGxmlXMNLbBYr9g+Skit/t5hxct6Mm95BUOz1+RiO/YH X-MS-Exchange-Transport-Forked: True X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3516 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: VE1EUR03FT046.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)(39860400002)(346002)(376002)(136003)(396003)(46966005)(956004)(83380400001)(356005)(8676002)(70206006)(16526019)(2616005)(26005)(186003)(70586007)(6496006)(47076004)(82740400003)(44832011)(81166007)(6666004)(86362001)(6862004)(478600001)(2906002)(4326008)(6486002)(36906005)(8936002)(450100002)(36756003)(82310400002)(336012)(5660300002)(316002); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 698a7b8e-1df6-42e3-2099-08d81dd9e6fd X-Forefront-PRVS: 04519BA941 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bJaenCNt5U3d7x/0+vRuYKD3FXzWUf+2cZs+Gj4gtsDFMU9aTpcjh/DwpdYmInlow4S4t9ubf4a1SMXy8F/0A3+y4GbvmU+hmY6uj/lNq1HhxLjWUr9BGx89QVUGndyH5U0d/QrAdxGyK99K42jOi03Wu+77ypijzQ7sR3tFiWMsKizp0S3cmQwuK/vZb/W/H+cep8fFuFrKwGHEwlnibwtM9qw7kSwyZn+CPp6ORzAQjtiB1Zhluoah4dsDbQ/GB+hyRBElkmW8Km9/K5PTPOJ/bVlvCExH/OiXvBzUY0fwTUSHX6bxVjAMmkUd1+GVN8O9wllCiaaqxv+thGW4QQjiXshURDbzIbGuj7+IBP3c/Lj8Kt3UcdcopdqgXu7LEfTUgsulZhCsnkZMhY6XjQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2020 16:15:07.0541 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2be6725b-a89d-453d-44f7-08d81dd9ebae 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: VE1EUR03FT046.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB4683 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, 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, 01 Jul 2020 16:15:12 -0000 Andrea Corallo writes: >> It occurred to me that the entrypoint is combining two things: >> - creating a global char[] >> - creating an initializer for that global >> >> which got me wondering if we should instead have a way to add >> initializers for globals. >> >> My first thought was something like: >> >> gcc_jit_context_new_global_with_initializer >> >> which would be like gcc_jit_context_new_global but would have an >> additional gcc_jit_rvalue *init_value param? >> The global would have to be of kind GCC_JIT_GLOBAL_EXPORTED or >> GCC_JIT_GLOBAL_INTERNAL, not GCC_JIT_GLOBAL_IMPORTED. >> >> Alternatively, maybe it would be better to have >> >> gcc_jit_global_set_initializer (gcc_jit_lvalue *global, >> gcc_jit_rvalue *init_val); >> >> to make the API more flexible. >> >> But even if we had this, we'd still need some way to create the rvalue >> for that initial value. Also, maybe there ought to be a distinction >> between rvalues that can vary at runtime vs those that can be computed >> at compile-time (and are thus suitable for use in static >> initialization). >> >> I suspect you may have gone through the same thought process and come >> up with a simpler approach. (I'm mostly just "thinking out loud" >> here, sorry if it isn't very coherent). > > Yes I had kind of similar thoughs. > > Ideally would be good to have a generic solution, the complication is > that as you mentioned not every rvalue is suitable for initializing > every global, but rather the opposite. My fear was that the space to be > covered would be non trivial for a robust solution in this case. > > Also I believe we currently have no way to express in libgccjit rvalues > an array with some content, so how to use this as initializer? Perhaps > also we should have a new type gcc_jit_initializer? > > On the other hand I thought that for simple things like integers the > problem is tipically already solved with an assignment in some init code > (infact I think so far nobody complained) while the real standing > limitation is for blobs (perhaps I'm wrong). And in the end if you can > stuff some data in, you can use it later for any scope. > > Another "hybrid" solution would be to have specific entry point for each > type of the subset we want to allow for static initialization. This way > we still control the creation of the initializer internally so it's > safe. In this view this blob entry point would be just one of these > (probably with a different name like > 'gcc_jit_context_new_glob_init_char_array'). > Hi Dave, wanted to ask if you formed an opinion about the patch and/or more in general the problem of static initialize data. Thanks Andrea