From patchwork Fri Mar 10 09:26:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 67296 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp770107wrd; Fri, 10 Mar 2023 01:27:13 -0800 (PST) X-Google-Smtp-Source: AK7set+h7ujQDTa007IPcTPkUsKw61ZrW4dsVbi9WSsuinlC/Fgk4L4p/AJ5+QNbnz8Z2aXme+mh X-Received: by 2002:aa7:d0ce:0:b0:4af:61f6:53c4 with SMTP id u14-20020aa7d0ce000000b004af61f653c4mr24418307edo.32.1678440433764; Fri, 10 Mar 2023 01:27:13 -0800 (PST) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r21-20020a170906705500b008b17b56c4d1si1577277ejj.1000.2023.03.10.01.27.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 01:27:13 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=TszugHWq; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 8CF71385B51A for ; Fri, 10 Mar 2023 09:27:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8CF71385B51A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678440432; bh=PiyxKJzXtkUYSqlI3A4AkT/RBrVoctPlsL6qnF8eqbQ=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=TszugHWqdPPLt9Rmvk01JmloS/y70Ih5uad2PsrYpnvxa7Q6QdqmBJiywQkcYuJzl Jus5Xi3nxgTZj4U0t2q1lyH1sFqXLi6WS26oIPYTnRmKn/Bhc9gaQ9IUnBNzZM7yI0 A9bgb7UWKPYxpwbzfD9L2cnaY/wI8Q7tf9uE3Qxc= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2069.outbound.protection.outlook.com [40.107.21.69]) by sourceware.org (Postfix) with ESMTPS id 3E5C7385040E for ; Fri, 10 Mar 2023 09:26:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3E5C7385040E ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lUJNQon99Yd59MHheH9QpU16J9f89VGhvh5mJ4wcQv2RV6sEohBYbc0VYnKE5yzX+8Or/FDhcwB2d8IU1H0sfaCU0V+wGh7FAK6zyMjknSB6bMS6ZvhgIlOoKFxg1J9p1eedwWEjYfyq2RQ/bPaV0+Bup//oqa7FAdbMD9ecxavNxcHrsPc5GNBWZOYU6/pwRouWTSgE28DJW0ZGSJH20zlD5vJSPwyFM6+GCrztj4WqU1+0Me4MplExzj7FZHm6MWZGGyMsysQa/jGLoNPuX1d0IBRARO6OILrtI3EjkO2EwiWR1f2LZr0Gagrd4l70DDwLZgt2bvEb0kSO6ccEqg== 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=PiyxKJzXtkUYSqlI3A4AkT/RBrVoctPlsL6qnF8eqbQ=; b=NomKhd0CSPTGVcaFdRixTGKd6W8rtymMItha88KA2mV8rLFeLBlJpg8/CmamPBZAieBFK6u4u2J6EuxKMkd4tpBf/WSm9mIHI4ylfOLr+LFaSjaiVSvtii+8++0YpZdllQ+RfA6xdRAaf1/3kKZzVB5WQ6hypC/lq+czPdSqbMHXGGdfp6KPBYpTuE3TNy1DOz+XoFF9ELSsqLIUj65sTnblR+xb12wJKYN8AM+UXRKcmSaIkHaY2broUd1fQUzbj5xPY7bicF/BVh4yfwpzvKRjVk+9JwqbcLman6Jea2K7cwZsI/127D43pJ6wJdsSrlU2iYrwGJeBqOxeZgtYPw== 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 DBBPR04MB7642.eurprd04.prod.outlook.com (2603:10a6:10:207::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 09:26:28 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%5]) with mapi id 15.20.6178.019; Fri, 10 Mar 2023 09:26:27 +0000 Message-ID: <5352e5fd-d1c5-4267-c802-73d6074e80ca@suse.com> Date: Fri, 10 Mar 2023 10:26:25 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: [PATCH v2 3/7] RISC-V: avoid redundant and misleading/wrong error messages Content-Language: en-US To: Binutils Cc: Palmer Dabbelt , Andrew Waterman , Jim Wilson , Nelson Chu References: In-Reply-To: X-ClientProxiedBy: FR2P281CA0015.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::25) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|DBBPR04MB7642:EE_ X-MS-Office365-Filtering-Correlation-Id: d5e2ed0e-7e33-4166-2556-08db2149867c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Nbl4Yiq98kMiZASwHVyGgCAuLbBrraCkW12EBLqVkust/2MlvdbH+haI5QoS72lC7H57JuRLc/r3pM1deL4rTWSW0il5Of+IyYiG0xGLjvq7En4Q8GdG89gwXQMaY31FYcf6te3vtak6Te90cx7UuKU5KzJKq1P7dM4sQxspn4z9OLAPmGo4PIomcAwD3kB6kw0xMSKtJ1fPgyqt/Ul7hSY0aqAhfXOTknQ1pG1NRt/bACx8s44aG1AcBSIM2x7jzNvo5S+YHADFjnoE5/u9QVmFhKWecCkGVjKDOkqC5fxlzZ/gvmp+FDBdlqxq1WRl8JM5L3VzUcyw+6t3Z3ghnor25Fhq3UfSgB4foROEsik2f/0f37s2uZxtBzA3dIxMDqcR4tPqYWofOSN8VFW4ZgI9f/qjO5/fkyehMHooBYP5FLDjyuWW6t1Nty4n0qmgCTI/W8+RkwMmKFJqquujd+Twu8MwEr6OzSSmPZtJs8r2K+R5J1DD+ihvXBzpIrG5mi5aagiAerlOUHW2zZApTSnF8BdNYAkyrfVXOFuHdb8RSufze2dxvyAg5nsfk0onDKX7WZL0szz0BOBvu9pdgk/ndo77JWYvJITjDKElEW8DeTzjz+tJWMkhN8yef+ApM81zUfV/8Wbp06A22l0y/yjWzbDpyk2Lct7VxK+wt0AH4z/RAXEwgmYeNtl9rld8wqLQCAY+jFQVoLrtO4lbOL6NPCpbN/N6viLtVbWJ9aA= 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:(13230025)(346002)(396003)(136003)(366004)(39860400002)(376002)(451199018)(31686004)(83380400001)(36756003)(478600001)(54906003)(38100700002)(316002)(2616005)(6486002)(6512007)(186003)(8936002)(41300700001)(26005)(6506007)(15650500001)(66946007)(66556008)(8676002)(66476007)(5660300002)(31696002)(4326008)(2906002)(86362001)(6916009)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?TF7Qg7voExbEmOQ/ZScSrVS4zLtQ?= =?utf-8?q?rF+5/VxeNvVYWXsH+Z2tUwZpdIQ3V47p01Eh6bDllH4enKtUjKDtD5E096ahDQh9r?= =?utf-8?q?V6xua9DvzY16WRvx7Z8hA2e5i4VQDx2SGac36E/sIYulGK/Fc1gKxSuUTXzxvh1vF?= =?utf-8?q?EzsWMZGynUsRqLkC2lzdOUD15XTgUgDBVHr3f1dPgGGSyEQBzllA2dkVP1OXiD5ac?= =?utf-8?q?Ucr8DVXUyTml8/rQWpnsaTXNSF/aCH8y2Bwa4X5h+R7fINWQbw0fjr0FIERiAzgM7?= =?utf-8?q?EgN7BWay6cONPtxD83ZXtlFn7kt4klPocbPKQFwxRbLzwVbgIaA1VJUN1DA101jC1?= =?utf-8?q?jeoxgFgWkDuT0GNb5tUERx2gPwQOmqlA+JQKH/lIaOrPmQyZxSa+0YfacAuNJcg+z?= =?utf-8?q?wM9+SvYJ/IsRv6L5Hackowb726dn8vAxPjWbq4PFvlPPt2T9QmqN159pilPmmxbms?= =?utf-8?q?MWW9Gn8AILSax0DZjo6IoANMgvQJyzNRkP+DaL3wXBAIQ4l7yVHDKklfNhTci/qs7?= =?utf-8?q?1ern+R43+i5kNNOohI12j1KKrY79O1dR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sREH6Z7kMrpBH1ZkeEXD0se?= =?utf-8?q?N90wNVH+JpuPjsXCZtZ3RBhPCElbZxLJearnXC5vCizkR9UsX8sz+otASqunNHs+3?= =?utf-8?q?6cjqkPlMQvkt?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5e2ed0e-7e33-4166-2556-08db2149867c X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 09:26:27.8012 (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: CKCOVBRC/8p0W1h5DmiEViclVRsXJgUp+PLjQ11y/U/E97WBrAX+EJtreU07ZQqMwh1uyqqx7unotnzcq1Zlbw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7642 X-Spam-Status: No, score=-3028.2 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?1759972356658098892?= X-GMAIL-MSGID: =?utf-8?q?1759972356658098892?= The use of a wrong (for the insn) relocation operator (or a future one which simply isn't recognized by older gas yet) doesn't render the (rest of the) expression "bad". Furthermore alongside the error from expression() in most cases the parser would emit another error then anyway. Suppress the call to my_getExpression() in such a case, arranging for a guaranteed subsequent error message by marking the expression "illegal". --- Of course superfluous "bad expression" errors remain for format specifiers where my_getExpression() is used directly. I guess once the GPR special casing has disappeared from my_getSmallExpression() (see "RISC-V: adjust logic to avoid register name symbols"), both functions could be folded (which would also eliminate the unclear split between when which of the two is used). --- v2: New. --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -2265,6 +2265,15 @@ my_getSmallExpression (expressionS *ep, && reloc_index < 1 && parse_relocation (&str, reloc, percent_op)); + if (*str == '%') + { + /* expression() will choke on anything looking like an (unrecognized) + relocation specifier. Don't even call it, avoiding multiple (and + perhaps redundant) error messages; our caller will issue one. */ + ep->X_op = O_illegal; + return 0; + } + my_getExpression (ep, crux); str = expr_parse_end; --- a/gas/testsuite/gas/riscv/tprel-add.l +++ b/gas/testsuite/gas/riscv/tprel-add.l @@ -1,4 +1,3 @@ .*: Assembler messages: -.*: Error: bad expression .*: Error: illegal operands `amoadd.w x8,x9,%tprel_add\(i\)\(x10\)' .*: Error: illegal operands `add a5,a5,tp,0'