From patchwork Fri Jan 6 12:34:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 40114 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp797480wrt; Fri, 6 Jan 2023 04:35:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXu5cKgzpCDLBqBd9QZQE9uXLMSEoqPgQYfj23WTyZp/YiCRdbfCpGwgEU0Ajoiy7Krohjvn X-Received: by 2002:a17:907:a0d0:b0:7c1:637:585d with SMTP id hw16-20020a170907a0d000b007c10637585dmr47438823ejc.0.1673008500474; Fri, 06 Jan 2023 04:35:00 -0800 (PST) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id rh19-20020a17090720f300b007ae2368c8b7si1108187ejb.138.2023.01.06.04.35.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 04:35:00 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=stpMzQot; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 792CA3858D35 for ; Fri, 6 Jan 2023 12:34:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 792CA3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673008499; bh=L456gopRElc+pFkVC/yX+Skkx4J8WFmdCwIVTsoM4yk=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=stpMzQotgKFnmKnVZm5AYRsfVBpcIlhISy8CAwuEu4dbGubYtrL2e4sifm9xv2naW L011h8tqkEij60M0jJV3yKqGQybmYlsc2Nc5wrV43C5IiwgSijn8uvkLU3/igmMuI0 eFm5m3kAZPIb6OLwKmcZnHHSzto2ZKnJ8nK9EjIQ= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2062.outbound.protection.outlook.com [40.107.21.62]) by sourceware.org (Postfix) with ESMTPS id 2B9FE3858D28 for ; Fri, 6 Jan 2023 12:34:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2B9FE3858D28 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PgJUokexA+YZzoRQ8wBs9Rvmn4XXcmB1Svnv/OOmIG0wp2EGCQZiavQOFCpOoJJgEIL2job9JeN4FJd3b+6uHBGSuYUhzaRN5nZrN2xuFn1UA71dH+x0INc6Pp0rmxTFQpCr2qkUDLcUuTzum3HX2qLZCd0wAR/1OHnRgjDa/3oeJJ3/DwbXqrQHit7ilbRiUZL7pWh3fRVoka6rUMyIAzqJ0/2PhATNuGlsLjM2ftJxAfSnxYXl0Z4Sm61E6ezuB7Wtnt0T9IifNPXWrUoilHE8xmbJBMhLLLEhMkuihMLxenpQdviGJ9joVwR+nSRbAQRtmtcL/lSIkdSHr+YLUA== 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=L456gopRElc+pFkVC/yX+Skkx4J8WFmdCwIVTsoM4yk=; b=Rmivi/yCWuLau+HJMlN5qMiUqVPK1IiR7GG/kmCb5/gzn4jECPwxvYrA2OQkW+tagKuoItMa4y7F6MQg0Eg7w1QS7FduWIDSvhdDFFxenhIAzElNPczGQk+GT6blQVHfcZWxlt/E/bKLWzeS7PcbcmBYQiZA3PMwfyAXt17NAQbe5SWf8gYB/sIuJozmzFxAqSLsPixt8vh7j44M1UxnH79Cp6YAC/i5dliMQq4lA9+e1gw6pM95P+IU0zvkODYHde3JYQIiEqPyXSNFI662WBjckdlvXsOflSsl4G+7IQJAEcIFERYGN0mFYbM9mJvUWlchkVIuXIm05zu8iM3Law== 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 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS8PR04MB7894.eurprd04.prod.outlook.com (2603:10a6:20b:2aa::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 12:34:48 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2991:58a4:e308:4389]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2991:58a4:e308:4389%7]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 12:34:48 +0000 Message-ID: <6c9f38b9-c582-3a1a-55ce-bb9966940a80@suse.com> Date: Fri, 6 Jan 2023 13:34:46 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-US To: Binutils Cc: Palmer Dabbelt , Andrew Waterman , Jim Wilson , Nelson Chu , Aurelien Jarno Subject: [PATCH] gas/RISC-V: adjust assembler for opcode table re-ordering X-ClientProxiedBy: FR3P281CA0016.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1d::21) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB7894:EE_ X-MS-Office365-Filtering-Correlation-Id: 464db6df-49f0-404f-105e-08daefe2660e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RgiG2j2ovTre50ZHa4Logl2M1JU2KkicZNTRcKrUbVVu2rgEX3CQz5JV8OMjV7y8KFibrfHbWtNRRbqo8t4qGdrA6Oc2BrdAmC5z1jqRt19bO6IbYjhGkYGa1LMetkKJ7jlcgwFSog6Zu4J3KyuqZGBkqSv00tSE2oR2B2spWC/+DEQC5k7hXn+jNjP2fwLV7gL5WXQcaF2YkrZnOP+muE8iMzLyRE48nltN210wK6T8FAGGygAEiSG8VUe7L0PalC/ay6RwC+XQFmSN+aIeaiO6SEDQPX+n3/jXUBBnwp+++77SgWbRjg4jd9ZX55fVaoM0w0xzAfanE6/ptc3lI1V+qQIu1HKUvw1/G6Qs0ms513xo4OEGLVbdat7m36MRYqmoLJmdaosTdU8BOwuy5IRmtJu67KxUtTsnzYliAbgr5qiyokxFQIakGhv/6ZvkXoC5G2QZHzVusL53ec8mHZ57z96TQN2jeWSHr8iG+z1LuXv60zZYRFidDKKnbyvdf6ZgrBaw4CIrurNseKrPFboQq4kDUq2An759M6eqsgvoNx/eQe6WkUCVp4jiHZcI9F8BP0eGpQzgbuUipoMeAuZuvcFvhxk1+SLb29STrxNXQ82QkTQg01F7X/hvwb5uvmTF0XSgLp4j2uXkvVOfB9eWZe0e6idsjJr8YYI5D4jki50x5XqIePPC6TgnOsrcwcQurB3p9A6cVV9L2kCd7HMT3zL2r0ndtfY8iLHUmac= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR04MB6560.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(396003)(376002)(346002)(39860400002)(136003)(366004)(451199015)(83380400001)(186003)(26005)(6512007)(6506007)(86362001)(31696002)(36756003)(2616005)(38100700002)(4326008)(8676002)(31686004)(41300700001)(6486002)(2906002)(5660300002)(8936002)(478600001)(6916009)(66556008)(316002)(66946007)(66476007)(54906003)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?BURzMiuvY2i6IMAtn8VCcpP2BT0n?= =?utf-8?q?HItn5mlRYSz20AFk2IuZKv5zctnj7uoSmNiIa6QzhDs+ky+aubGFtZIbnAI+Ytlob?= =?utf-8?q?kG15plTKJbBWdgbjIlirURO10U+PKGU8AevLPol8xAFAK2EDpAt8RxU/oow1x6TyU?= =?utf-8?q?omv89LxaTEY3IuHLxsNBkfACQP+tsU299FERIbrMXb00JMACe0RZFIwvZtt/X1CWa?= =?utf-8?q?sk0Fzd4nHJbo7gU6F0I0iEb6J4pmLTJp019rfCho9UjoaDUwQ7oDQc9NCDTGgPJ06?= =?utf-8?q?O67YD2mHfU8uz6tIS3F5DzL4nWAUMcjgtq056m3jNzbsamnsmWvchyF2miRGaM/XO?= =?utf-8?q?L+dyuoPNOCqT6wj+aBxg96vpqdFlum3JhgE2czuX8s7ZHbZ/Tq1Wx77y8s3xNECzO?= =?utf-8?q?4RyE7tahBi19ETX47NuGBjDRN0ULNUTjKmGSZ75p5xiK5RJDSzLiJsM5Eu5icwTPT?= =?utf-8?q?5mXQWJxlVfOyxsDvA5jwATv8PI70QTq5Edsol2QpQMOHbbXnkiGxkoyQIh3EVUx1Z?= =?utf-8?q?TadqdadYWp9erzec/H2+x6IjjAIkON2q589diHrCvuT0pjX8nhZ1o6DUjaORRu3zc?= =?utf-8?q?A1tyIwji2QZgi2drsHiCy5wlRGwqkiGbtm9X2SEfSV47Mtwri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cUPb1HSD/Pzo?= =?utf-8?q?dfCEwwW6k/Cg?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 464db6df-49f0-404f-105e-08daefe2660e X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2023 12:34:48.2378 (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: SR1XlG7xGbtQe1seuQ27BbcMSRGJKj6iER5L4zw42N6ZEr8lUrwdV+U39GSVEGMreKdbN67ULZSHr0kmM+REbA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7894 X-Spam-Status: No, score=-3028.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jan Beulich via Binutils From: Jan Beulich Reply-To: Jan Beulich Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754276561416413359?= X-GMAIL-MSGID: =?utf-8?q?1754276561416413359?= PR gas/29940 With the single-operand JAL entry now sitting ahead of the two-operand one, the parsing of a two-operand insn would first try to parse an 'a'- style operand, resulting in the insertion of bogus (and otherwise unused) undefined symbols in the symbol table, having register names. Since 'a' is used as 1st operand only with J and JAL, and since JAL is the only insn _also_ allowing for a register as 1st operand (and then there being a 2nd one), special case this parsing aspect right there. Reviewed-by: Palmer Dabbelt --- This, of course, is fragile, but I guess such workarounds are unavoidable with the chosen approach of (recurring) parsing, and with register names being special only in certain contexts. A more generic approach, then possibly also helping performance, might be to count the number of operands first, and do full parsing only when the count matches that in the operand specifier string (at least when there are multiple insn forms). The similar workaround in my_getSmallExpression() actually looks suspicious to me: I expect that it would get in the way of using equates "shadowing" names of GPRs. --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -3266,6 +3266,17 @@ riscv_ip (char *str, struct riscv_cl_ins continue; case 'a': /* 20-bit PC-relative offset. */ + /* Like in my_getSmallExpression() we need to avoid emitting + a stray undefined symbol if the 1st JAL entry doesn't match, + but the 2nd (with 2 operands) might. */ + if (oparg == insn->args) + { + asargStart = asarg; + if (reg_lookup (&asarg, RCLASS_GPR, NULL) + && (*asarg == ',' || (ISSPACE (*asarg) && asarg[1] == ','))) + break; + asarg = asargStart; + } jump: my_getExpression (imm_expr, asarg); asarg = expr_end;