From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130079.outbound.protection.outlook.com [40.107.13.79]) by sourceware.org (Postfix) with ESMTPS id ADC33385BF81; Tue, 14 Jul 2020 10:01:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org ADC33385BF81 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=ELR8lBXGWEqkN02N0IyXX29E/Ou+lrb+RxphVgk+dus=; b=y4my98TIK64q89hejWjeeUTAHFxqfcg+pLAFBITLgjNSCKRLbEuJZaWmAOeNQszMx1K0SqpFQSXQju0JmuS3L0I+jTfSjucAfUXanrJ2QSh5SHPxVirF5PBp+J16B9VELQ8kCWFOKI6H3S+cgsO5+YyZ+hVD+dMSe9mxhhAAMwk= Received: from AM6P195CA0016.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:81::29) by VI1PR08MB3454.eurprd08.prod.outlook.com (2603:10a6:803:88::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20; Tue, 14 Jul 2020 10:01:01 +0000 Received: from AM5EUR03FT026.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:81:cafe::b7) by AM6P195CA0016.outlook.office365.com (2603:10a6:209:81::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Tue, 14 Jul 2020 10:01:01 +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 AM5EUR03FT026.mail.protection.outlook.com (10.152.16.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Tue, 14 Jul 2020 10:01:00 +0000 Received: ("Tessian outbound 73b502bf693a:v62"); Tue, 14 Jul 2020 10:01:00 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 5984982927918120 X-CR-MTA-TID: 64aa7808 Received: from 05124b398562.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 34A10858-287C-4C4C-8874-49458E33A504.1; Tue, 14 Jul 2020 10:00:54 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 05124b398562.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 14 Jul 2020 10:00:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SQJFQyWtUxlEH7Iopd+kK6EE1XnyWiY9TFn4H1JI5r7+dtTD+C33lool7sVoDP9HiYatOd2jUWxAJpjmy5RjbP+BOO43qFc/m6qjWOBjt4JsRnQBZEzfuFlEhBGfVuO4U/LlZD4WFX9PV/t9iJTUZHs/aHXoeLygEpuTj/a9EBkRrAVqTYUjO7DhAYM4SCEOvjVaU6HJyPy/8DFDAIthtBeA2pOtx/0pIFE0Msq5t0nkKu7ROX4+p3o/ZqkQ64Akl1KJu8NUH5TPW6Q8bykftHwoBos7aF8CbWehNH7PAy8mvd+uGDzonj80GZ9plSe+n9kgqW/xAT9zIARJJLfhow== 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=ELR8lBXGWEqkN02N0IyXX29E/Ou+lrb+RxphVgk+dus=; b=GnkLlwTe8xs3CyYU+YPquSHaR1gnsceOm0WrYX0Vc1xpQcmvCc3aVAGwvNWjfMBtCpUIzPnwUzD3G4MmoHd7Nt9rxK56ACoMd/jJ0eEL2L56ugUbEy8Tz/mmGj3HNvdBqnF0e6XP9lnCXYfWvmfGkPmYP6ZsCr7n5oZwMP8Kf33iWiU+ll46sc3u3gKuql+IPG4IcapKZ0+B6YktmczuJsCtHKVwPwGrTHYya10VOleLG3Oo3W4ZmvK7loWYlIqJWOt/TC59SoIPRtlbEjDA7yhfH2zdhn2wXSkJkWmaOJ7TIpOSR9Jmd3vA+0c4aJSwTd/U78YS7Cmbq5h+XDZfyg== 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=ELR8lBXGWEqkN02N0IyXX29E/Ou+lrb+RxphVgk+dus=; b=y4my98TIK64q89hejWjeeUTAHFxqfcg+pLAFBITLgjNSCKRLbEuJZaWmAOeNQszMx1K0SqpFQSXQju0JmuS3L0I+jTfSjucAfUXanrJ2QSh5SHPxVirF5PBp+J16B9VELQ8kCWFOKI6H3S+cgsO5+YyZ+hVD+dMSe9mxhhAAMwk= 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 DB6PR0801MB1800.eurprd08.prod.outlook.com (2603:10a6:4:38::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20; Tue, 14 Jul 2020 10:00:53 +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.3174.026; Tue, 14 Jul 2020 10:00:52 +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: Tue, 14 Jul 2020 11:00:45 +0100 In-Reply-To: (Andrea Corallo's message of "Wed, 01 Jul 2020 18:14:52 +0200") Message-ID: <874kqa1kmq.fsf@arm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Content-Type: text/plain X-ClientProxiedBy: SA9PR10CA0029.namprd10.prod.outlook.com (2603:10b6:806:a7::34) To DB7PR08MB3594.eurprd08.prod.outlook.com (2603:10a6:10:4e::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from krcb (217.140.106.55) by SA9PR10CA0029.namprd10.prod.outlook.com (2603:10b6:806:a7::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Tue, 14 Jul 2020 10:00:51 +0000 X-Originating-IP: [217.140.106.55] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e2a32f4b-1e3c-4127-fc29-08d827dccfe7 X-MS-TrafficTypeDiagnostic: DB6PR0801MB1800:|VI1PR08MB3454: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: hsUw8XMTtOAbEdm2UmDioZsyTii06G5igLoFRbznhFyCWK5hcfID6xeRisEd03yUFMqv2kZOrqwmbM1UdeOueUAzDYDYXSUkO4na5s4dZle+PCSePq7gqdbnATVC7pLaAfyUC4PtbFWlNcNOKmv7+TI0wnYeNM7Lscpz2HcRnWW2n497VqF35fhtt9BwkWKbXLto80V6/Esa0ZAXvwAOY28euxl3CjQiS5o8yTbU2BCpacLPt0ff++Q/VWmUzBQ0loYRbMVdgzyX6uIIkA5VOjh/n6Gsk7rou8iLsFySG8tIY3JYq/OCW/ACzp231CwBVYwQzm0LV3k8KX8jWoc0VQ== 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)(136003)(39860400002)(346002)(396003)(366004)(376002)(66476007)(66556008)(26005)(5660300002)(36756003)(2906002)(316002)(8676002)(2616005)(6486002)(66946007)(16526019)(186003)(4326008)(52116002)(6496006)(956004)(6916009)(8936002)(6666004)(83380400001)(86362001)(44832011)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: z64b/UskXaUu8lawuiRvOVfM3wfDotM2AzMbQAmyTRS+BGpN/w3fAatCuApSSojhH2GvImjBJIzEAUvoDEl046obpCgvsHLha2WRt2H7AZbkpyi/yVc7uvZy1yayQH5OJklx2AkHdXdP2EnJufz8D53wPEbrBxAH/9UeO2AMK9l/JDLjqF04QBLdkIXqnGihVT5RzMXZX1J9AucZwhweu9TAYr03ecplY//woTsqL6QBG8loBASoSUADMPgCepID9MV/mkkdJxTTuxOoXhzvloc+qRavw0j0Ir9z55SSfOhmr2VoSGcxYGh+hW6BFvz71SXURGKIxtUVrnWiMfT8S/CgvdEa46pDDlc5mJb0nxebFrUvRq8hF1WIvkwFjI/0Rr1raMOdPgLAtVNFcfY936ZvMmAt8xNyqRkWYETAKSF8Ej95ZnEMDCibhrxubwYLf1n3Ben/RhSYjlHG7S8SydWW23m1ng40wfCl9bsY8j7CbgQwzLSMyjDjoy1IiArs X-MS-Exchange-Transport-Forked: True X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1800 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: AM5EUR03FT026.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)(376002)(396003)(346002)(136003)(39860400002)(46966005)(478600001)(6496006)(356005)(26005)(83380400001)(82740400003)(8676002)(82310400002)(70206006)(6486002)(5660300002)(44832011)(8936002)(86362001)(336012)(70586007)(316002)(6666004)(956004)(47076004)(2906002)(2616005)(450100002)(6862004)(36906005)(36756003)(4326008)(81166007)(186003)(16526019); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 71873202-131d-4b67-6094-08d827dccb15 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H8F6yYrhdT7UbHsgHuqNeJDF7is/+Zu6ZbM3dHbWCrN9qByetPFCO0J8f5QK2ZyK0WWph6xdV6IVed8SuC2H/SP2fd/c+BDSdoLNigZezucWFsGlTbltEouRTz5Z3D8MWzA8DXheOsu5qHgi4TVqdcaJ6YKCcsp9ex3V0EJnUwEZAseADQ2K26HqTFE5wcdMnm29oFtON5/CxPNm5D14WWHk2ton3o88hEfOuwbldGuZ+CN6i3EAO+J0bMCxBRP0QqRx1heUh3dLgBTQif5WZbZh/Ts7lbXVKLKfKeH0otgOb5kT6O8YwCD0w8uGySaTCAUa6pp2Ij0+G+o2E+t9L2xj+k7PpjXdVunfywS8YzjJheBLUOQEIvjOngxLt+gFeD17QVsKHRfFBzoVMYU+fA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2020 10:01:00.6510 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2a32f4b-1e3c-4127-fc29-08d827dccfe7 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: AM5EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3454 X-Spam-Status: No, score=-11.0 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: Tue, 14 Jul 2020 10:01:07 -0000 Andrea Corallo writes: > 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 Ping