From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from hall.aurel32.net (hall.aurel32.net [IPv6:2001:bc8:30d7:100::1]) by sourceware.org (Postfix) with ESMTPS id 361C23858D33 for ; Sat, 7 Jan 2023 23:29:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 361C23858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=aurel32.net Authentication-Results: sourceware.org; spf=none smtp.mailfrom=aurel32.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=aurel32.net ; s=202004.hall; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Content-Transfer-Encoding:From:Reply-To: Subject:Content-ID:Content-Description:X-Debbugs-Cc; bh=+fUDJZxNVhcFQcDoucN69Ua07QqjsiVpVmX5mHOzfKI=; b=RJYSZwOiDRm2rCErTzCQ1s4yV+ 7fg0ozEBLOii9nVR5x5tAVaHWjaLqo/8HFhgO+AzwqNKv6WhGMeR/02Rnnt5Efw4aQYmH5FXTxXEa M5lixIrJztUS3jJJ7rXtwPkki8vh3ePbLldktqaccS5Rvc4g9IgYlCJ/zIF9Cm9jDCZuN/QS96wwh NBgdISogtYsruGrv5Wccp+gizGPmQu+C4zu7V4OSfTyD4hEsiHJ2pIJCTaH0th92UnUGX63l+5weX cZyvStrT+PGDBIcipG4oqpve1unY32/ou7JyJDav/YBEIwj+0ogEc/rwJMQ36SojCTEKA4Nw/HQ3O 1ACejiOQ==; Received: from [2a01:e34:ec5d:a741:8a4c:7c4e:dc4c:1787] (helo=ohm.rr44.fr) by hall.aurel32.net with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pEIcu-000ZZf-6Q; Sun, 08 Jan 2023 00:29:24 +0100 Received: from aurel32 by ohm.rr44.fr with local (Exim 4.96) (envelope-from ) id 1pEIct-00A405-2I; Sun, 08 Jan 2023 00:29:23 +0100 Date: Sun, 8 Jan 2023 00:29:23 +0100 From: Aurelien Jarno To: Jan Beulich Cc: Binutils , Palmer Dabbelt , Andrew Waterman , Jim Wilson , Nelson Chu Subject: Re: [PATCH] gas/RISC-V: adjust assembler for opcode table re-ordering Message-ID: Mail-Followup-To: Jan Beulich , Binutils , Palmer Dabbelt , Andrew Waterman , Jim Wilson , Nelson Chu References: <6c9f38b9-c582-3a1a-55ce-bb9966940a80@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6c9f38b9-c582-3a1a-55ce-bb9966940a80@suse.com> User-Agent: Mutt/2.2.7 (2022-08-07) X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_NONE,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 List-Id: On 2023-01-06 13:34, Jan Beulich via Binutils wrote: > 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. > --- > 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; Thanks for the patch. I have tested it and confirmed it fix the problem I reported. Regards Aurelien -- Aurelien Jarno GPG: 4096R/1DDD8C9B aurelien@aurel32.net http://www.aurel32.net