From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by sourceware.org (Postfix) with ESMTPS id 5709F3858D20 for ; Fri, 11 Aug 2023 03:08:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5709F3858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=xen0n.name Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xen0n.name DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1691723281; bh=jnAmhd6aNVm9DvI0oCeors+PCeW8ytbx1yKMjaDQ8F8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=GteFw5r7y+mwizXhPWGcFYpBFmk8UTjmYM3K9hYkQnglbNFIWTB3Qlo8nFYcNmUW6 1xAqPoWRgPMSSAv8/BR/+lZEwGqRs2amlC5D9p/kBZzz7JeERJJEd8oOIKtQEadmFE KXOoEGLAYo0iL3FS2SXipV/gt2qrYE3tHWc9G4C4= Received: from [100.100.34.13] (unknown [220.248.53.61]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id DE77E600B5; Fri, 11 Aug 2023 11:08:00 +0800 (CST) Message-ID: <06b6500e-6e0c-c210-ad8d-afc913f5aa79@xen0n.name> Date: Fri, 11 Aug 2023 11:08:00 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH v1 1/2] LoongArch: Fix pcaddi format string Content-Language: en-US To: Xi Ruoyao , mengqinggang , binutils@sourceware.org Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn, liuzhensong@loongson.cn, i.swmail@xen0n.name, maskray@google.com References: <20230809013939.3388720-1-mengqinggang@loongson.cn> <20230809013939.3388720-2-mengqinggang@loongson.cn> <548af2c302efcdb23ae3bedd7249db9e618930be.camel@xry111.site> From: WANG Xuerui In-Reply-To: <548af2c302efcdb23ae3bedd7249db9e618930be.camel@xry111.site> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,SPF_HELO_NONE,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 List-Id: On 2023/8/9 19:37, Xi Ruoyao wrote: > On Wed, 2023-08-09 at 09:39 +0800, mengqinggang wrote: >> Add "<<2" for pcaddi format string >> --- >>  opcodes/loongarch-opc.c | 2 +- >>  1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/opcodes/loongarch-opc.c b/opcodes/loongarch-opc.c >> index 2f02e33dbec..7d110683e93 100644 >> --- a/opcodes/loongarch-opc.c >> +++ b/opcodes/loongarch-opc.c >> @@ -564,7 +564,7 @@ static struct loongarch_opcode loongarch_imm_opcodes[] = >>    { 0x10000000, 0xfc000000,    "addu16i.d",    "r0:5,r5:5,s10:16",             0,                      0,      0,      0 }, >>    { 0x14000000, 0xfe000000,    "lu12i.w",      "r0:5,s5:20",                   0,                      0,      0,      0 }, >>    { 0x16000000, 0xfe000000,    "lu32i.d",      "r0:5,s5:20",                   0,                      0,      0,      0 }, >> -  { 0x18000000, 0xfe000000,    "pcaddi",       "r0:5,s5:20",                   0,                      0,      0,      0 }, >> +  { 0x18000000, 0xfe000000,    "pcaddi",       "r0:5,s5:20<<2",                0,                      0,      0,      0 }, > > The Linux kernel already uses things like "pcaddi t0, 4". To me this > change will break them completely, and fixing it on the kernel side will > be difficult (we'll need to create some nasty gas version check). Thanks for the heads-up, I initially was inclined to accept this patch but was hindered by real life, then saw this. The asymmetry is unfortunately real and here to stay, because in this case code would be broken without any build-time errors or warnings, and such breakage would go unnoticed until the moment the wrong instruction gets executed. > So I don't think we should make such a backward incompatible change > without a very compelling reason. You may argue that "<<2" has a better > readability, but if we really need the readability we can write > > pcaddi t0, 4 # << 2 > > in the code anyway. The immediate operand means "delta in # of instructions": > pcaddi t0, 4 # insns Which is *arguably more* intuitive than the new semantics implied by "<<2", since IMO it's more natural to think in terms of instruction words when we talk about PC-relative tricks with instruction fetch in mind. IMO a better way forward could be to document this wart in an upcoming revision of the LoongArch ISA manual. (It already contains assembler syntax tips for insns like alsl.* so another similar addition should be appropriate.) It's not sure at this moment whether an overhaul of LoongArch assembler is going to happen, so we have little choice if we want to keep downstream fuss to a minimum.