From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2087.outbound.protection.outlook.com [40.107.21.87]) by sourceware.org (Postfix) with ESMTPS id 3A59D385B53E for ; Mon, 6 Nov 2023 11:03:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A59D385B53E Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3A59D385B53E Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.21.87 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1699268613; cv=pass; b=kwEY3469kYpx+xsEcpHVk525+QwSeAbHa8dCw+fWb0m5Fwf1Nlsu1CezlT1GpJOOh1HI6C+QSyGDJc2hp1C/vWeeNMa+zwGJ5wvBpX4IS7+imctwi/c0rGsk+5yzdEXaJqgOqUULoKqnwaa95WVCDDyECEF5J/d90FwL3sfJrgk= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1699268613; c=relaxed/simple; bh=7ALEM8gHHDKvWA763lnF5byjsojNMUTRvswrtxTncsA=; h=DKIM-Signature:Message-ID:Date:Subject:To:From:MIME-Version; b=qEfpiwvKee6ICcxZ5/a6tVWKmXY4nUDCfIqd8MUY/L6UvEeyZ29y92buIDyCgXaq69bhvtEMldLpxGWO9mymj4ZCpKw41vHxg0ZBa0MZksD6qP89T6iwywsG2dv0THucaiYPftGotqnCFMcOsxaYzG0gI7Xf159e1wL5vIJxkFk= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AW7Tkbl2wLYZLDP1ObOKQOFuzQ2ZRI2UIeoVFz36xNIjUhLgUjnlK4Iva6WpkWjVWfWtWg6F389IXN5pTgwcAWYA/htqUg6XtSApBP+eQx3i5q0ncemh/cFteQEiDtSxux1jlvW4Ku6ACpCbQPpW0p1D/0jpEFXgykeRrbmXf0pyVlxhbIqfiVFwBaRGtMJ9E5bSsGiVeIJQmZgN6v/qoif8g28RE5o2f+Q4I+yy7dNalascn0xBEWjI6Qck6Givl4TJCBn+2gR1VH5aTFNOtMxDUct4s6b7giiUGGAz7vd05yRVzDSTN6/RxjZHrbePI8+9hbLKy5pAIClEk5sA7g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Uia6qb5XAao3XQlcPd/5xVVc8+ufZ/J8uGHMckOCmrU=; b=TN9J4q1ctJecZ2L+I33HmkdBIGuztiuvLUQrEhuUzbtPS4se+U+Q7oDMRJaBIqFSb8EUo6GpOXVypcojMvbsg+zDfvXlQEzYtCPM1tVy0usvIDXOpRtd4Pzt8Q6lm4LXQch7/pyWMAjV3rPkg/P5H/qJ6o07t6ULpA3/dOWjFGxJskl7gv0+uD3fLUjESEs7J3eDnsbpIEfkFp9Vh40rmHeh335yFsQzPDVG0Onm7f+9L2jNhsvQ1P4zYnuE2ha8n7NRlsAuYqr3638vJBbkN9UuOrTuixOHbodFdVM0+D5CgMfRIhvu7OLwks4IQK7jbuEOPXbhRQh7HIjWwgLL0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Uia6qb5XAao3XQlcPd/5xVVc8+ufZ/J8uGHMckOCmrU=; b=fmQJ+qUXdPZniAiIIOrpy+d2Bzzg5N4oWYiwA5MqkSxrhc2L0Re8URaJ+kfNpBGS2y1HZxNwQYrQF+bMxeYE8WtRscCQuhPMd41jBRUj/E0Jufbnq/VHgzlvcV7E/Rv1G0B0ZlRWvf4RrUgjD9BeYQtVe3Sb9AWlMbqeCVBaTF2hO2y4nIPW9toZQD4hpkE47ZLr3oH+XFzuRD4iYvpu/26Pu82wB7BoEv6UkDyxqQUk6FMpIOkq7VnYj6aYgKltcD05wZVgcGzPhrZ9gkRDMWXDQOnp5VJfPFlwBuVPiIdGDvL5gBFoJoROwYS9d3K12P4Z4JyXH2MLiF+3wNmkNg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from DU2PR04MB8790.eurprd04.prod.outlook.com (2603:10a6:10:2e1::23) by AS1PR04MB9630.eurprd04.prod.outlook.com (2603:10a6:20b:475::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.19; Mon, 6 Nov 2023 11:03:19 +0000 Received: from DU2PR04MB8790.eurprd04.prod.outlook.com ([fe80::eb8e:fa24:44c1:5d44]) by DU2PR04MB8790.eurprd04.prod.outlook.com ([fe80::eb8e:fa24:44c1:5d44%3]) with mapi id 15.20.6977.016; Mon, 6 Nov 2023 11:03:19 +0000 Message-ID: <37342fe7-2dc1-614a-f4c7-26e0b0318bbf@suse.com> Date: Mon, 6 Nov 2023 12:03:20 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH, V2 07/10] gas: synthesize CFI for hand-written asm Content-Language: en-US To: Indu Bhagat Cc: binutils@sourceware.org References: <20231030165137.2570939-1-indu.bhagat@oracle.com> <20231030165137.2570939-8-indu.bhagat@oracle.com> <47dec0fe-492e-43ec-8636-d33f6653d8f9@oracle.com> From: Jan Beulich In-Reply-To: <47dec0fe-492e-43ec-8636-d33f6653d8f9@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR3P281CA0179.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::16) To DU2PR04MB8790.eurprd04.prod.outlook.com (2603:10a6:10:2e1::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8790:EE_|AS1PR04MB9630:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c7a5268-a383-41e9-52bd-08dbdeb7fc48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +pS21j0uVj62DySOpS74YfDzJrRI+kvo8pU82lbdX9Wdkntm9R+LGoalrbIiM4aGOrLB/UxuXI02dkqZ+X5WSUhFm3XJ7poyCAI6duGleeQxp0t7Ki4ZcDqjG80VS4RcMsLKf7VUYeiE7bhvJLzQ3g7hBBBSXSl5AtbUBzKxO90tgmoKatKNeRJFx5OaephwheHRA5ZY2aKAnANlzz5HLw1L2RQfS/154zWv/7K4EsRnv8PnfEr1/OAozEAeSTK3ByC5LayGzKApBePUMISaV2GOb3+BYMpMMAje+JEY4aj7JveWdlx7hfW4SExw4DFcpPN621QKClb/fXHMTlpy7xUfVfcOhab91nJjm+KvNCdmzpUA9wHpAaAJAvRFNcrv8H8S7HkFRtUSLV08+9QsMAhjkUJgkA/+JqnNKzzfZd+DZ20BByrTqQZYQ+1H/iMuHCMvq6eURTUHncV9mVS3g7vZzRxHzp0VH0Yd8LHw/zutwr/2zq66B0l8fRAgCAMAt7eb6atm3OcusG/AfC4Pzyi8chXkWHTwAOzGOT9regMHt/WiZnEBAGG3F0CJkyc3cbHBTnvHXZa9VLoK8xqvMOf2VmmRPdL05do3Q1Pslo3pADnFbngfaNTpijjeVguDdxDmL60doTZdDD/T2hflqZ7mCi6K1AyZcWXegLeVXoY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8790.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(396003)(366004)(346002)(39860400002)(136003)(230922051799003)(64100799003)(186009)(1800799009)(451199024)(478600001)(31686004)(36756003)(66899024)(2616005)(8936002)(38100700002)(86362001)(31696002)(6512007)(41300700001)(5660300002)(53546011)(26005)(6666004)(2906002)(6506007)(316002)(6916009)(66476007)(6486002)(66946007)(66556008)(4326008)(8676002)(83380400001)(21314003)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Uy82SnFEZ3c5R25weVFBNFllQXhHOVdRSVF6TEl3QlA3ejNacDBaVURLbXBQ?= =?utf-8?B?MWtmK0U2V0lSSFpnYXdPRDJ6KzdvRDFCbmU1MG82VnhTdnB0WTNaeEJ2Z3ZB?= =?utf-8?B?MFlzaURiU01rYmllaXpRYzJlNTJDMElMZDVLMGxKOUJSNU5qMm1LeC9YTnB3?= =?utf-8?B?OEdDK1RoUUdxL2dUZDIzYTBYQTVuY1UvaGlGVTd6Tmo1YzdkREtYQnRSVHg0?= =?utf-8?B?bjBRcXRhUnluS2Q2VE5xSG9lcUdnTUNIaGxCeVllTVNJbkRhelNnbEZ4cERl?= =?utf-8?B?aDIyMTNObUZGUE9MeVJiT3V3b3hDWTJzcURDcTRCc1RzUHE1OHlaaTZWcmhm?= =?utf-8?B?cmFzeFB5aXBjUDhQN3JoL2xBOUtFZ2FHTThJTzltZDJ4cXNBT3c3aC9kRnVv?= =?utf-8?B?TUVVQWlJRFpOM05XaDBHR2I5ME1ZOE1HOHMvb1JhbjNXWmttZmk5WVl1cjNp?= =?utf-8?B?Wm4yeWlJVURNU1g1aW9YMkh2NWU4TXNuMlNxakVLWU5XcEM3cCs3Yzk0cy8v?= =?utf-8?B?T0pTNWk3SERRMDh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O?= =?utf-8?B?YlpKMXp2TDdYV2loSjUrNVhjVjRLeEljamFJMU9KTTg4OGkrcU1PcjExKzZh?= =?utf-8?B?aVRqNGt3ZG9JRWpBNW52cmw5V3VGU0VVNld4UkRxMUdtTVVBTFpuYmd6UW1F?= =?utf-8?B?YWhoeDBtK0JsNjlPY0pHZzFYWXRkeUl1b0IzbWFJVFFHTmlWeW1OM3hJMkp4?= =?utf-8?B?YVhyRXlEdU94ZDRid2hSLzZPOSswUXR5VmZ1NzhLTmdDUEUrbGZWaTBVSHYw?= =?utf-8?B?ZVdpaXN6a3J1MS9JbDUwbmRhNGpRTEVOaWg2RzlXTnlmYm13NlBvVmJxbzE0?= =?utf-8?B?RVJLb1ZnTlBLaXBwbXN2V1htbkFWRVk4STJ2Mnc1bVJhZU1CVGY0RlJQYThI?= =?utf-8?B?WmhYYjEyMWdlN2F3SXJ5U0VlMnVPNkU5bGZaM28yT2E4WXhGSE5ldXVLb3lO?= =?utf-8?B?cDJEdXorTnNtS2kxZk4xRTh6YkFWdGc0VldocXNZREZWR1cwOUwzcFhkd0dQ?= =?utf-8?B?Q1RDNmdDeGIwc1dQdWI3bzBrajE0TXNLc1VaLzVOa2R1VndJRzBwckVZTFFT?= =?utf-8?B?dE1HYkZjS1FCVVVlb3o1KzhLVmRxSUh4aFRpSzJVVzhzenRKeWJmeGVpWDVO?= =?utf-8?B?NXNNMUR1Y2pxZkpETVNVYVpLK2lNdktvTjBoV0g1aXBBQ2tQQ1NUcksyUnpV?= =?utf-8?Q?+z++prJsahQmTd6N1zluJ9HD4?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c7a5268-a383-41e9-52bd-08dbdeb7fc48 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8790.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 11:03:19.7193 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LGI3DiqUtY2pLXSD6ohdJnUPlswWAK02FT08rHRd1qO/Hgxy5gseJFXrqpfnfV34ooam7UlaUixnxhXq2F2x9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9630 X-Spam-Status: No, score=-3028.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 04.11.2023 08:29, Indu Bhagat wrote: > On 11/2/23 08:53, Jan Beulich wrote: >> On 30.10.2023 17:51, Indu Bhagat wrote: >>> +static ginsnS* >>> +ginsn_init (enum ginsn_type type, symbolS *sym, bool real_p) >>> +{ >>> + ginsnS *ginsn = ginsn_alloc (); >>> + ginsn->type = type; >>> + ginsn->sym = sym; >> >> Is a symbol hanging off of a ginsn ever intended to be altered? If >> not, field and function argument would want to be pointer-to-const. >> > > No. This symbol is not intended to be altered. > > However, using const symbolS* will cause complaints of "passing argument > 1 of ‘S_GET_NAME’ discards ‘const’ qualifier" etc. Calling most of the > S_XXX (symbolS *sym) will need some type casting etc, but that will > somewhat defeat the purpose? Well, yes, of course you shouldn't be casting away const-ness. I've made a patch to adjust S_GET_NAME(), which I'll post after having run a full set of tests on it. >>> +static void >>> +ginsn_set_src (struct ginsn_src *src, enum ginsn_src_type type, uint32_t reg, >>> + int32_t immdisp) >> >> I find the use of fixed-width types suspicious here: For reg, likely it wants >> to be unsigned int. For immdisp it's less clear: Immediates can be wider than >> 32 bits, and they may also be either signed ot unsigned. From an abstract >> perspective, assuming the immediate value actually is used for anything, I'd >> expect offsetT to be used, following struct expressionS' X_add_number. >> > > Thanks, I will consider trying offsetT for immediate. It is a more > appropriate data type than int32_t. For reg, why is uint32_t less > appropriate than unsigned int ? Fixed-width types come with a price: In principle they may not even be available, and they may also not be the most efficient types to deal with for an architecture. Therefore my rule of thumb is that they're best used only for "describing" interfaces. As long as (here) register numbers will fit in an unsigned int, using that basic type looks more appropriate to me. >>> +ginsnS * >>> +ginsn_new_mov (symbolS *sym, bool real_p, >>> + enum ginsn_src_type src_type, uint32_t src_reg, int32_t src_disp, >>> + enum ginsn_dst_type dst_type, uint32_t dst_reg, int32_t dst_disp) >>> +{ >>> + ginsnS *ginsn = ginsn_init (GINSN_TYPE_MOV, sym, real_p); >>> + /* src info. */ >>> + ginsn_set_src (&ginsn->src[0], src_type, src_reg, src_disp); >>> + /* dst info. */ >>> + ginsn_set_dst (&ginsn->dst, dst_type, dst_reg, dst_disp); >>> + >>> + return ginsn; >>> +} >> >> As indicated before, if both src and dst can be indirect here, ... >> >>> +ginsnS * >>> +ginsn_new_store (symbolS *sym, bool real_p, >>> + enum ginsn_src_type src_type, uint32_t src_reg, >>> + enum ginsn_dst_type dst_type, uint32_t dst_reg, int32_t dst_disp) >>> +{ >>> + ginsnS *ginsn = ginsn_init (GINSN_TYPE_STORE, sym, real_p); >>> + /* src info. */ >>> + ginsn_set_src (&ginsn->src[0], src_type, src_reg, 0); >>> + /* dst info. */ >>> + gas_assert (dst_type == GINSN_DST_INDIRECT); >>> + ginsn_set_dst (&ginsn->dst, dst_type, dst_reg, dst_disp); >>> + >>> + return ginsn; >>> +} >>> + >>> +ginsnS * >>> +ginsn_new_load (symbolS *sym, bool real_p, >>> + enum ginsn_src_type src_type, uint32_t src_reg, int32_t src_disp, >>> + enum ginsn_dst_type dst_type, uint32_t dst_reg) >>> +{ >>> + ginsnS *ginsn = ginsn_init (GINSN_TYPE_LOAD, sym, real_p); >>> + /* src info. */ >>> + gas_assert (src_type == GINSN_SRC_INDIRECT); >>> + ginsn_set_src (&ginsn->src[0], src_type, src_reg, src_disp); >>> + /* dst info. */ >>> + ginsn_set_dst (&ginsn->dst, dst_type, dst_reg, 0); >>> + >>> + return ginsn; >>> +} >> >> ... I can't see what these are needed for. >> > > For x86, they may not seem necessary. But for other architectures, or > say for future uses-cases, we may need them. I think it is more > meaningful (and readable) to see a LOAD/STORE/MOV ginsn for a machine > instruction of the same type. For other RISC-like ISAs, it is clearer > to have separate MOV/LOAD/STORE instructions. > > ginsn is meant to provide an infrastructure for other uses cases that > may crop up later. But then I consider it as odd that you munge loads/stores on x86 into ginsn_new_mov(), by using "indirect" operands. Imo it would be better to be consistent here, one way or the other. Jan