From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id A62783858D28 for ; Sat, 4 Nov 2023 07:29:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A62783858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A62783858D28 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1699082969; cv=pass; b=gzdigXi7dQXi9yVcebF5r7jR8zG8akf9qGkbHBNaYRGJfhvPHeBs3Xy6eGISs7dUyRIxoJu6VnykyxKJYjdpu1qlzpq/+exmB2ExKhN6pfzm9EgiHl0iywTMY4aGdD2obwG6gG0xJQYDU/vgEj1QA4vs6k60E/cdf7lhaCAzatY= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1699082969; c=relaxed/simple; bh=AHo8HIn1P1VN00gDE8ZRHLMpMFyjUC1MiD0cWYxNocM=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:Subject:To:From: MIME-Version; b=L/j64SQ+VU9Sa8+HlDZByAOIBEYB5+20JGVGFmQjB1qK8+AEpo8bkZQZ6DPgaj/Kn1htbkM8KYnQt/BOAyFznKo9onaWKHji/cYNIadGdLn55c5e/qmNjGg2q5sv+m2NlfIQmsaFoVScGuLzGrDKB3wkn6ov+X5GG+WLV1BQsQQ= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A43seKa014947; Sat, 4 Nov 2023 07:29:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=message-id : date : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2023-03-30; bh=0DWMZse9ieoxGUe7P+CEKbly5J2CEiacA3NsPzLQvXc=; b=y52HG3q1AZqdeN4mxaQX5YykS/fBxLGCemm+hFkKL3FTYA+7M6U0dUosPlLivzPuvvMC VyEK2aesXyUQObiy5LdtoE8rRaSsJ2Avro/amz7yYKUKbTZlOn6ceHOb9F2ja7Ye+xkZ 2gD+ePxPfVJkgTChb5WQCsxILEhbDLBtYweGDb0m0yKtTPac4T1fPTZObc/c7e7/qcOX PgNs6KeCS+W7+lWlk9uu811rbVgRpvUYyIpKXGEl4klJam2+LSSWYnvIHmX7VVD7fuP/ F7K4Zc+CtpxEGPULoZIaZ6EbKD0ZwPQGuMkTKht8lyuqBBYMe3S22fxeFcfTBO1ec87d 0A== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5cj2r6hm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 04 Nov 2023 07:29:25 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3A43wdbU024798; Sat, 4 Nov 2023 07:29:23 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd971jy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 04 Nov 2023 07:29:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bYhW4ONcMuDMHfqd5oxmchzzdUoKN85FEm0HIlFQL067rQgDsCATs7DvxqtmSm4L0xjIP6FdUVLkHH/gHigpjFMf97z2nMFeqBzK2sLoP9gC/0BY9o6qDl5XSM4tigUiwMvXP8vod7CZVZLaKyBldEjmHfZNP8KMqRtE1VKyJCPc0AvwQ2ks4lqPqMWOdArzFE+KCIBDBzfwBY7pEP3k7RufQRZkHD3jwSDbC6XAeamjw3T/QHcw4/BlUwiuG8Cq3MQoXnyZEu4God0E2s3bqHY3Ds11/St5vMM+5S05IftELFlm17BejAlB94k0ohD+GY30Q8+06mXvmgCe0dfq2A== 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=0DWMZse9ieoxGUe7P+CEKbly5J2CEiacA3NsPzLQvXc=; b=clbXDAoFrXN0PNtMQ4P+UKwqHqs6Y/n6aDM7XShwbHsj9ygEMqLgjsztCfKsyd0GISrU7qXANY31wPpgqGieKpIcatlGIJbUsxkTMCPzl5DFMl0fywLX5XQP0ATJI7EQKYh99S3dTN/00QrBC3KSjf4izIM1PneeaUnttk9xOiH6GMX0YQGQxl4NYSqMZgNTXX527FyL/Bx5NFjNQTG+pwbSmA3yvucVqDkIUD82MQ+qGxg+KB/dm6J8qLZkqUjr9k9fghPRi4pLRgm19QvjfHFfWZU6g219l9ESp/A6cJDg+xNPtvAJ/V1S1t9uu9Rzm3ZRCcKjTt1eG1Ts4VSuYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0DWMZse9ieoxGUe7P+CEKbly5J2CEiacA3NsPzLQvXc=; b=E78RtuLKwFz31NAYnSTXRoASuT0cE34fvZ03T8iVdcg/kmfSQKNBIznQQmyckkpnjhKgxsVJVRINdi4l6a7KP0vXGp5nTkII14uZLWZA793kMqDlky3iaIE9EJWbgeniZPR3UxZ4YpE/BiR3Qu+oHv9e5qeTzjVVSgxFtnQd1cI= Received: from MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by CH0PR10MB5370.namprd10.prod.outlook.com (2603:10b6:610:db::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.25; Sat, 4 Nov 2023 07:29:21 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::40e0:a5cb:e318:c51f]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::40e0:a5cb:e318:c51f%6]) with mapi id 15.20.6954.021; Sat, 4 Nov 2023 07:29:20 +0000 Message-ID: <47dec0fe-492e-43ec-8636-d33f6653d8f9@oracle.com> Date: Sat, 4 Nov 2023 00:29:17 -0700 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH, V2 07/10] gas: synthesize CFI for hand-written asm Content-Language: en-US To: Jan Beulich Cc: binutils@sourceware.org References: <20231030165137.2570939-1-indu.bhagat@oracle.com> <20231030165137.2570939-8-indu.bhagat@oracle.com> From: Indu Bhagat In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: MW4PR02CA0027.namprd02.prod.outlook.com (2603:10b6:303:16d::32) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR1001MB2158:EE_|CH0PR10MB5370:EE_ X-MS-Office365-Filtering-Correlation-Id: fa372a8a-18d9-41ce-ad31-08dbdd07c1e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NTXDglIGu7Vh+s+3nPSkGfnG3EiLV+rWLGIYYwHy1OlgiUnhGOWHT6Mj/JgfUILjZ/JoaqiyzllAtG5g7KGGczK9hWtGATH5dax65LFBEyFNniuyhPq3nT2FSKBs07WXKy5OjJqCuIEFKJB+vrh7EBlucAyHdepcUkOT3PwBXv3Vkkk9U/XXqdsW5sAjJrluTIFNeNNgKKkpPhxXwqRU+3xmMOfKU4WUaSYnDSswRlj0A2vkJPl8GVcrlkXk2mRuESsCEVZorT6yRZAEB0F1zLt5JPNvikCUG/vifYh8bZx8v5SN6WrvRj2WD7NZ+3boNUtMAWyGbMqMClBFhC0/Vggx4NLOYJgGu1CK25qrctuG0w15vxOIVKDDeHorAJSdA22NAghy9CtBpyRl7dfNWDc0qlDGU+xyWXP4I8YKsYkj+ng1Sz5/iNsp0Cj5OF/8Cu4OCE3mhNjODyOqc9I0xxTT16BY2jvoU1re7Oc54/CUrHB3UQyDDiGGXWjGc6LUzeMUxn31QHkWJfzrI/9I3OrTp/nnFIvTaaodCN8lY+4Xs48un/wbQAmGBtYb+HB1t93OjQhDfUfW4u5qKUjK5uP7AMLORpQMvnhoQtE+T+ncRMlGMGXSuvsJDf/V2WJeZc0NBWfMOUuhaT+9nJbAAqFaDtmY/fGigL5KRPbAx4lSuTSvkL6IgSHra6ukDZlp X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2158.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(39860400002)(396003)(346002)(136003)(366004)(230922051799003)(451199024)(186009)(1800799009)(64100799003)(6506007)(53546011)(6666004)(2616005)(6512007)(83380400001)(44832011)(41300700001)(5660300002)(8676002)(4326008)(8936002)(30864003)(2906002)(6486002)(478600001)(316002)(6916009)(66476007)(66556008)(66946007)(36756003)(86362001)(31696002)(38100700002)(31686004)(2004002)(21314003)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Y1oxNGFncG1OdTV2cCtXUHErUWZkNS9SNUF1WUltcTlsc09sdVhxSzZGditE?= =?utf-8?B?bG82RDVXdXJnRWozR0hKdVNkeXVKeUNLOEZUTTR5OFh4dkFveXZlLzlyU0Ja?= =?utf-8?B?V0tvQm1obE9aYWxyeG1LRks1QmRTaXVlNTliM2dSOEUyVVJXTWloS3NDOFlV?= =?utf-8?B?QlFmRmR1aFFMZG5CNE5ZdnM4dDRrQzVybHYrSFU4Kzl2ZW5sdXY1RnNzWmww?= =?utf-8?B?MVZNMlEzWmhVU3VGRjR0SUd5ZTc4RThjcTJSVUN3ZjJDYmhsQUZWKzJlMlpi?= =?utf-8?B?WnRlOGhMREZXMHBWRFZFUkU5cjlSZHUwNm02eXdaZUdVWm1HckxranZrVzJk?= =?utf-8?B?OUxRV0NaYlcydDVZd3pMTHliVVZ5emJnUHZYODQ3aVN5b09HanBJalYwZ2tR?= =?utf-8?B?TDVKcngwY1p2OEs2M0NraFdmdnFLUlZjTlQ2dnhPQjd2cnhTMXhFbDNVSW54?= =?utf-8?B?c29KZWlORnU5R0xQUWdwcFdRWDNwdnpCd0QwZWVORnY4c2k2dkxVQ2pHTDgv?= =?utf-8?B?d29iQ0g5MXIyZVZ5d3lSSktIaDFUQXZNZnF3WGYzWXpPaDkwT3NTNkErQnBm?= =?utf-8?B?cTBzakZ1NlpXZmQyQXhRVE80NTBzRkxVTXhmclhGTDhFekRBQ25VSnJWcElH?= =?utf-8?B?SmxFVkxqWFBMODFubE1pdUJJWHp5cWN3R3pSdmY4dTJYQU9nMTZEVEduRUV2?= =?utf-8?B?THhtSDFZdTJYT1hoNmN1cGxPO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CZwdeiAHy5zErZBJrCu9pQIshPS0SSuFlSPwuTwvh/ky+iYrdweQij3QGg46Iq1Vh2F9ElmKcKYsomIBo+DQFZemNAcXK95K0D07ezbpjmYJ5cfqihenOqTqTx5B06KFlVJgDf7sODLZaqN212d0m5sxa10XU8QxQNdLhPikGteVVDLHnJylLpcag0gHpm6oIFcdhqC4ybVpW9upJWMRXKuYMejVAwEHNRIdGhDatHuoW3buXJdmwDYCsZ9fAftF3eAl8RmAlnvJyriFrxDynLCjoqwf2qNLyKlPhUCX8XxNxVLLlqEyeMTDAdilydKfDJBZRz0NDyoqLgs/aTZdiBYVJS2ozDdkU2PcBmeme2wQbNSV7MuCszZGUD2U/H5elIRfUQSug2JA3A0+F10aNxav54nUSLsnGW/s5wVX71xPft61dA+/SOS99Ayk/QhNIRXN4bOsKYOgu05eXrGfYkN5TCLCQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa372a8a-18d9-41ce-ad31-08dbdd07c1e7 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2023 07:29:19.2384 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OqWxl3VvLIYV7ZIlLNLQNcqpbkMCzH2OPTUUDXX9JJ6WOZpb3GudH8c3B+7INytnvhUX9H8c5cUSAisykNgDTQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5370 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-04_05,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311040061 X-Proofpoint-ORIG-GUID: w2SrVhYc7dcJd5-t0oiI__E8OT1Dz4tf X-Proofpoint-GUID: w2SrVhYc7dcJd5-t0oiI__E8OT1Dz4tf X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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 11/2/23 08:53, Jan Beulich wrote: > On 30.10.2023 17:51, Indu Bhagat wrote: >> --- /dev/null >> +++ b/gas/ginsn.c >> @@ -0,0 +1,1225 @@ >> +/* ginsn.h - GAS instruction representation. >> + Copyright (C) 2023 Free Software Foundation, Inc. >> + >> + This file is part of GAS, the GNU Assembler. >> + >> + GAS is free software; you can redistribute it and/or modify >> + it under the terms of the GNU General Public License as published by >> + the Free Software Foundation; either version 3, or (at your option) >> + any later version. >> + >> + GAS is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + GNU General Public License for more details. >> + >> + You should have received a copy of the GNU General Public License >> + along with GAS; see the file COPYING. If not, write to the Free >> + Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA >> + 02110-1301, USA. */ >> + >> +#include "as.h" >> +#include "subsegs.h" >> +#include "ginsn.h" >> +#include "scfi.h" >> + >> +#ifdef TARGET_USE_GINSN >> + >> +const char *const ginsn_type_names[] = > > This looks like it wants to be static. > OK. >> +{ >> +#define _GINSN_TYPE_ITEM(NAME, STR) STR, >> + _GINSN_TYPES >> +#undef _GINSN_TYPE_ITEM >> +}; >> + >> +const char *const ginsn_src_type_names[] = > > This and ... > >> +{ >> +#define _GINSN_SRC_TYPE_ITEM(NAME, STR) STR, >> + _GINSN_SRC_TYPES >> +#undef _GINSN_SRC_TYPE_ITEM >> +}; >> +const char *const ginsn_dst_type_names[] = > > ... this also look so, but then they're also unused inside this CU, > so when making them static the compiler would complain. If they're > needed by a later patch, perhaps they should be moved there? And > if entirely unused, perhaps they should both be deleted (or at least > commented / #ifdef-ed out)? > Remains of some previous implementation that I discarded. I will remove these. > With the many symbols further down it's also hard to spot whether any > of them should perhaps also be static. > >> +{ >> +#define _GINSN_DST_TYPE_ITEM(NAME, STR) STR, >> + _GINSN_DST_TYPES >> +#undef _GINSN_DST_TYPE_ITEM >> +}; >> + >> +static >> +ginsnS *ginsn_alloc (void) >> +{ >> + ginsnS *ginsn = XCNEW (ginsnS); >> + return ginsn; >> +} >> + >> +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? >> + if (real_p) >> + ginsn->flags |= GINSN_F_INSN_REAL; >> + return ginsn; >> +} >> + >> +static void >> +ginsn_cleanup (ginsnS **ginsnp) >> +{ >> + ginsnS *ginsn; >> + >> + if (!ginsnp || !*ginsnp) >> + return; >> + >> + ginsn = *ginsnp; >> + if (ginsn->scfi_ops) >> + { >> + scfi_ops_cleanup (ginsn->scfi_ops); >> + ginsn->scfi_ops = NULL; >> + } >> + >> + free (ginsn); >> + ginsn = NULL; > > This doesn't do anything useful. Did you perhaps mean to set *ginsnp to NULL, > and then also ahead of calling free()? > Thanks. Yes I meant to do *ginsnp = NULL; >> +} >> + >> +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 ? >> +{ >> + if (!src) >> + return; >> + >> + src->type = type; >> + /* Even when the use-case is SCFI, the value of reg may be > SCFI_NUM_REGS. >> + E.g., in AMD64, push fs etc. */ >> + src->reg = reg; >> + >> + if (type == GINSN_SRC_IMM || type == GINSN_SRC_INDIRECT) >> + src->immdisp = immdisp; > > What's the point of the conditional around the assignment? > Stale conditional. I earlier had some data structures with union etc. which I have since gotten rid of. >> +ginsnS * >> +ginsn_new_add (symbolS *sym, bool real_p, >> + enum ginsn_src_type src1_type, uint32_t src1_val, int32_t src1_disp, >> + enum ginsn_src_type src2_type, uint32_t src2_val, int32_t src2_disp, >> + enum ginsn_dst_type dst_type, uint32_t dst_reg, int32_t dst_disp) >> +{ >> + ginsnS *ginsn = ginsn_init (GINSN_TYPE_ADD, sym, real_p); >> + /* src info. */ >> + ginsn_set_src (&ginsn->src[0], src1_type, src1_val, src1_disp); >> + ginsn_set_src (&ginsn->src[1], src2_type, src2_val, src2_disp); >> + /* dst info. */ >> + ginsn_set_dst (&ginsn->dst, dst_type, dst_reg, dst_disp); >> + >> + return ginsn; >> +} >> + >> +ginsnS * >> +ginsn_new_and (symbolS *sym, bool real_p, >> + enum ginsn_src_type src1_type, uint32_t src1_val, int32_t src1_disp, >> + enum ginsn_src_type src2_type, uint32_t src2_val, int32_t src2_disp, >> + enum ginsn_dst_type dst_type, uint32_t dst_reg, int32_t dst_disp) >> +{ >> + ginsnS *ginsn = ginsn_init (GINSN_TYPE_AND, sym, real_p); >> + /* src info. */ >> + ginsn_set_src (&ginsn->src[0], src1_type, src1_val, src1_disp); >> + ginsn_set_src (&ginsn->src[1], src2_type, src2_val, src2_disp); >> + ginsn_set_dst (&ginsn->dst, dst_type, dst_reg, dst_disp); >> + >> + return ginsn; >> +} > > The comments in the two functions don't look overly useful to me. But if > you have them, please have them be consistent across similar functions. > OK. >> +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. >> +ginsnS * >> +ginsn_new_sub (symbolS *sym, bool real_p, >> + enum ginsn_src_type src1_type, uint32_t src1_val, int32_t src1_disp, >> + enum ginsn_src_type src2_type, uint32_t src2_val, int32_t src2_disp, >> + enum ginsn_dst_type dst_type, uint32_t dst_reg, int32_t dst_disp) >> +{ >> + ginsnS *ginsn = ginsn_init (GINSN_TYPE_SUB, sym, real_p); >> + /* src info. */ >> + ginsn_set_src (&ginsn->src[0], src1_type, src1_val, src1_disp); >> + ginsn_set_src (&ginsn->src[1], src2_type, src2_val, src2_disp); >> + /* dst info. */ >> + ginsn_set_dst (&ginsn->dst, dst_type, dst_reg, dst_disp); >> + >> + return ginsn; >> +} >> + >> +/* PS: Note this API does not identify the displacement values of >> + src1/src2/dst. At this time, it is unnecessary for correctness to support >> + the additional argument. */ > > And why do the displacements need tracking for add, and, and sub? > Hmm, I think its just a bad choice of arg name. The value passed in src1_disp / src2_disp is actually the immediates in case add/sub/and. I will update it. >> +static bool >> +ginsn_indirect_jump_p (ginsnS *ginsn) >> +{ >> + bool ret_p = false; >> + if (!ginsn) >> + return ret_p; >> + >> + ret_p = (ginsn->type == GINSN_TYPE_JUMP >> + && ginsn->src[0].type == GINSN_SRC_REG); > > On x86 an indirect jump can also have a memory source operand (i.e. what > you call "indirect"). > IIRC, This is another case of acceptable loss of information in ginsns. I will double check this too when I get to fixing up the tc-i386.c to address those review comments for the ginsn creation process. >> +static bool >> +ginsn_direct_local_jump_p (ginsnS *ginsn) >> +{ >> + bool ret_p = false; >> + if (!ginsn) >> + return ret_p; >> + >> + ret_p |= (ginsn->type == GINSN_TYPE_JUMP >> + && ginsn->src[0].type == GINSN_SRC_SYMBOL >> + && S_IS_LOCAL (ginsn->src[0].sym)); > > This looks fragile: You may not yet have seen the .globl or .weak directive. > Hmm. I think the usage of S_IS_LOCAL is incorrect here. Further, I already have a defined label -> ginsn map per function block, and the checks with S_IS_LOCAL is not necessary really. Will take a second look. >> +static char* >> +ginsn_src_print (struct ginsn_src *src) >> +{ >> + size_t len = 39; >> + char *src_str = XNEWVEC (char, len); >> + >> + memset (src_str, 0, len); >> + >> + if (src->type == GINSN_SRC_REG) >> + { >> + char *buf = XNEWVEC (char, 32); >> + sprintf (buf, "%%r%d, ", ginsn_get_src_reg (src)); >> + strcat (src_str, buf); >> + } >> + else if (src->type == GINSN_SRC_IMM) >> + { >> + char *buf = XNEWVEC (char, 32); >> + sprintf (buf, "%d, ", ginsn_get_src_imm (src)); > > Here and below, if you stick to int32_t as the type, this wants to use > PRId32. > OK. >> +static const char* >> +ginsn_type_sym_begin_end_print (ginsnS *ginsn) >> +{ >> + int id = 0; >> + const char *ginsn_sym_strs[] >> + = { "", "FUNC_BEGIN", "FUNC_END" }; > > static and with a 2nd const? > OK. >> +static char* >> +ginsn_print (ginsnS *ginsn) >> +{ >> + struct ginsn_src *src; >> + struct ginsn_dst *dst; >> + size_t len = GINSN_LISTING_LEN; >> + char *ginsn_str = XNEWVEC (char, len); >> + >> + memset (ginsn_str, 0, len); >> + >> + strcpy (ginsn_str, "ginsn: "); >> + >> + strcat (ginsn_str, ginsn_type_names[ginsn->type]); >> + strcat (ginsn_str, " "); >> + >> + /* For some ginsn types, no further information is printed for now. */ >> + if (ginsn->type == GINSN_TYPE_CALL >> + || ginsn->type == GINSN_TYPE_RETURN >> + || ginsn->type == GINSN_TYPE_OTHER) >> + goto end; >> + else if (ginsn->type == GINSN_TYPE_SYMBOL) >> + { >> + if (GINSN_F_USER_LABEL_P (ginsn)) >> + strncat (ginsn_str, S_GET_NAME (ginsn->sym), len - 10); >> + else >> + strcat (ginsn_str, ginsn_type_sym_begin_end_print (ginsn)); >> + goto end; >> + } >> + >> + /* src 1. */ >> + src = ginsn_get_src1 (ginsn); >> + strcat (ginsn_str, ginsn_src_print (src)); >> + >> + /* src 2. */ >> + src = ginsn_get_src2 (ginsn); >> + strcat (ginsn_str, ginsn_src_print (src)); >> + >> + /* dst. */ >> + dst = ginsn_get_dst (ginsn); >> + strcat (ginsn_str, ginsn_dst_print (dst)); >> + >> +end: >> + gas_assert (strlen (ginsn_str) < GINSN_LISTING_LEN); > > This check comes too late - if it triggers, you've corrupted memory > already. I wonder anyway why you construct all this "by hand", rather > than using snprintf(). > I will update this to use snprintf instead. Thanks for the review. Indu