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 6797B3858424 for ; Fri, 29 Jul 2022 10:06:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6797B3858424 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=1659089182; bh=hiylWYuC7j0JTk2OgQ6JukisLuee4a809xpBra2xCTI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=nITwmgpP+6pnYJIETH4jd4VT7FtXvs7GTEszsRTiLTriPfZwsbUC/d8ZTI7X3a3oW 45SZXzi11T1CWJmYOip9iSxOMWLGKW6NpHRZWBcXaLkA2y2kZ6PEB28dYqnlJWRiiz B/l4bK9da3bDksD6xlQ3WiG2TGUQfYzIjKtnr59o= Received: from [100.100.57.219] (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)) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id C1A0960104; Fri, 29 Jul 2022 18:06:21 +0800 (CST) Message-ID: <569a795d-d62a-ab9a-3071-fac52144bf0e@xen0n.name> Date: Fri, 29 Jul 2022 18:06:21 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:105.0) Gecko/20100101 Thunderbird/105.0a1 Subject: Re: [PATCH 1/2] opcodes: LoongArch: make all non-native jumps desugar to canonical b{lt/ge}[u] forms Content-Language: en-US To: liuzhensong , WANG Xuerui , binutils@sourceware.org Cc: Chenghua Xu , Xi Ruoyao , WANG Xuerui , chenglulu@loongson.cn References: <20220727110757.2520234-1-i.swmail@xen0n.name> <20220727110757.2520234-2-i.swmail@xen0n.name> <7923c152-9a27-2eef-d91e-7a9c2a343213@loongson.cn> <09e3fe4a-81ec-f829-0d5e-5b59753dd1c8@xen0n.name> <8a0d2034-f7a4-53db-858b-98bddbb36c16@loongson.cn> From: WANG Xuerui In-Reply-To: <8a0d2034-f7a4-53db-858b-98bddbb36c16@loongson.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.0 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 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-List-Received-Date: Fri, 29 Jul 2022 10:06:29 -0000 On 2022/7/29 18:02, liuzhensong wrote: > > 在 2022/7/29 下午5:42, WANG Xuerui 写道: >> On 2022/7/29 09:18, liuzhensong wrote: >>> >>> >>> On 2022/7/27 下午7:07, WANG Xuerui wrote: >>>> From: WANG Xuerui >>>> >>>> Also re-order the jump/branch opcodes while at it, so that insns are >>>> sorted in ascending order according to opcodes, and the label form >>>> preceding the real definition. >>>> --- >>>>   opcodes/loongarch-opc.c | 31 ++++++++++++------------------- >>>>   1 file changed, 12 insertions(+), 19 deletions(-) >>>> >>>> diff --git a/opcodes/loongarch-opc.c b/opcodes/loongarch-opc.c >>>> index 08ba101a902..6f5e42d57e5 100644 >>>> --- a/opcodes/loongarch-opc.c >>>> +++ b/opcodes/loongarch-opc.c >>>> @@ -810,22 +810,13 @@ static struct loongarch_opcode >>>> loongarch_float_jmp_opcodes[] = >>>>   static struct loongarch_opcode loongarch_jmp_opcodes[] = >>>>   { >>>>     /* match,    mask,        name, format, macro,            >>>> include, exclude, pinfo.  */ >>>> -  { 0x0,    0x0,        "bltz",        "r,la", "bltz >>>> %1,%%b16(%2)",        0, 0, 0 }, >>>> -  { 0x60000000, 0xfc00001f,    "bltz", "r5:5,sb10:16<<2",        >>>> 0,                0, 0, 0 }, >>>> -  { 0x0,    0x0,        "bgtz",        "r,la", "bgtz >>>> %1,%%b16(%2)",        0, 0, 0 }, >>>> -  { 0x60000000, 0xfc0003e0,    "bgtz", "r0:5,sb10:16<<2",        >>>> 0,                0, 0, 0 }, >>>> -  { 0x0,    0x0,        "bgez",        "r,la", "bgez >>>> %1,%%b16(%2)",        0, 0, 0 }, >>>> -  { 0x64000000, 0xfc00001f,    "bgez", "r5:5,sb10:16<<2",        >>>> 0,                0, 0, 0 }, >>>> -  { 0x0,    0x0,        "blez",        "r,la", "blez >>>> %1,%%b16(%2)",        0, 0, 0 }, >>>> -  { 0x64000000, 0xfc0003e0,    "blez", "r0:5,sb10:16<<2",        >>>> 0,                0, 0, 0 }, >>>>     { 0x0,    0x0,        "beqz", "r,la", "beqz >>>> %1,%%b21(%2)",        0, 0, 0 }, >>>>     { 0x40000000, 0xfc000000,    "beqz", >>>> "r5:5,sb0:5|10:16<<2",        0,                0, 0, 0 }, >>>>     { 0x0,    0x0,        "bnez", "r,la", "bnez >>>> %1,%%b21(%2)",        0, 0, 0 }, >>>>     { 0x44000000, 0xfc000000,    "bnez", >>>> "r5:5,sb0:5|10:16<<2",        0,                0, 0, 0 }, >>>> -  { 0x0,    0x0,        "jr",        "r", "jirl $r0,%1,0",        >>>> 0, 0, 0 }, >>>> -  { 0x50000000, 0xfc000000,    "b", "sb0:10|10:16<<2",        >>>> 0,                0, 0, 0 }, >>>> -  { 0x0,    0x0,        "b",        "la",                "b >>>> %%b26(%1)",            0, 0, 0 }, >>>>     { 0x4c000000, 0xfc000000,    "jirl", >>>> "r0:5,r5:5,s10:16<<2",        0,                0, 0, 0 }, >>>> +  { 0x0,    0x0,        "b",        "la",                "b >>>> %%b26(%1)",            0, 0, 0 }, >>>> +  { 0x50000000, 0xfc000000,    "b", "sb0:10|10:16<<2",        >>>> 0,                0, 0, 0 }, >>>>     { 0x0,    0x0,        "bl",        "la", "bl >>>> %%b26(%1)",            0, 0, 0 }, >>>>     { 0x54000000, 0xfc000000,    "bl", "sb0:10|10:16<<2",        >>>> 0,                0, 0, 0 }, >>>>     { 0x0,    0x0,        "beq",        "r,r,la", "beq >>>> %1,%2,%%b16(%3)",        0, 0, 0 }, >>>> @@ -834,20 +825,22 @@ static struct loongarch_opcode >>>> loongarch_jmp_opcodes[] = >>>>     { 0x5c000000, 0xfc000000,    "bne", >>>> "r5:5,r0:5,sb10:16<<2",        0,                0, 0, 0 }, >>>>     { 0x0,    0x0,        "blt",        "r,r,la", "blt >>>> %1,%2,%%b16(%3)",        0, 0, 0 }, >>>>     { 0x60000000, 0xfc000000,    "blt", >>>> "r5:5,r0:5,sb10:16<<2",        0,                0, 0, 0 }, >>>> -  { 0x0,    0x0,        "bgt",        "r,r,la", "bgt >>>> %1,%2,%%b16(%3)",        0, 0, 0 }, >>>> -  { 0x60000000, 0xfc000000,    "bgt", >>>> "r0:5,r5:5,sb10:16<<2",        0,                0, 0, 0 }, >>>>     { 0x0,    0x0,        "bge",        "r,r,la", "bge >>>> %1,%2,%%b16(%3)",        0, 0, 0 }, >>>>     { 0x64000000, 0xfc000000,    "bge", >>>> "r5:5,r0:5,sb10:16<<2",        0,                0, 0, 0 }, >>>> -  { 0x0,    0x0,        "ble",        "r,r,la", "ble >>>> %1,%2,%%b16(%3)",        0, 0, 0 }, >>>> -  { 0x64000000, 0xfc000000,    "ble", >>>> "r0:5,r5:5,sb10:16<<2",        0,                0, 0, 0 }, >>>>     { 0x0,    0x0,        "bltu",        "r,r,la", "bltu >>>> %1,%2,%%b16(%3)",        0, 0, 0 }, >>>>     { 0x68000000, 0xfc000000,    "bltu", >>>> "r5:5,r0:5,sb10:16<<2",        0,                0, 0, 0 }, >>>> -  { 0x0,    0x0,        "bgtu",        "r,r,la", "bgtu >>>> %1,%2,%%b16(%3)",        0, 0, 0 }, >>>> -  { 0x68000000, 0xfc000000,    "bgtu", >>>> "r0:5,r5:5,sb10:16<<2",        0,                0, 0, 0 }, >>>>     { 0x0,    0x0,        "bgeu",        "r,r,la", "bgeu >>>> %1,%2,%%b16(%3)",        0, 0, 0 }, >>>>     { 0x6c000000, 0xfc000000,    "bgeu", >>>> "r5:5,r0:5,sb10:16<<2",        0,                0, 0, 0 }, >>>> -  { 0x0,    0x0,        "bleu",        "r,r,la", "bleu >>>> %1,%2,%%b16(%3)",        0, 0, 0 }, >>>> -  { 0x6c000000, 0xfc000000,    "bleu", >>>> "r0:5,r5:5,sb10:16<<2",        0,                0, 0, 0 }, >>>> +  /* Jumps implemented with macros.  */ >>>> +  { 0x0,    0x0,        "bgt",        "r,r,la", "blt >>>> %2,%1,%%b16(%3)",        0, 0, 0 }, >>>> +  { 0x0,    0x0,        "ble",        "r,r,la", "bge >>>> %2,%1,%%b16(%3)",        0, 0, 0 }, >>>> +  { 0x0,    0x0,        "bltz",        "r,la", "blt >>>> %1,$r0,%%b16(%2)",        0, 0, 0 }, >>>> +  { 0x0,    0x0,        "bgtz",        "r,la", "blt >>>> $r0,%1,%%b16(%2)",        0, 0, 0 }, >>>> +  { 0x0,    0x0,        "bgez",        "r,la", "bge >>>> %1,$r0,%%b16(%2)",        0, 0, 0 }, >>>> +  { 0x0,    0x0,        "blez",        "r,la", "bge >>>> $r0,%1,%%b16(%2)",        0, 0, 0 }, >>>> +  { 0x0,    0x0,        "bgtu",        "r,r,la", "bltu >>>> %2,%1,%%b16(%3)",        0, 0, 0 }, >>>> +  { 0x0,    0x0,        "bleu",        "r,r,la", "bgeu >>>> %2,%1,%%b16(%3)",        0, 0, 0 }, >>>> +  { 0x0,    0x0,        "jr",        "r", "jirl $r0,%1,0",        >>>> 0, 0, 0 }, >>>>     { 0 } /* Terminate the list.  */ >>>>   }; >>> Looks good to me.  And I don't think the instruction "ret" is >>> necessary in [PATCH 2/2]. >> >> Please don't be so subjective. You and Chenghua never gave objective >> reasons against "ret", your rejections seem to be just based on some >> kind of personal preference. All while ignoring the objective >> readability improvement and ease of learning gained by adding such >> support, and I believe there must be community members in favor of >> the addition. >> >> And it's not like everyone must immediately migrate to it, people may >> well continue to write "jr ra" or even "jirl zero, ra, 0", only those >> of us preferring brevity would have one more palatable choice... > If gcc is not required to be generated instruction "ret" by default, I > think it can be added. > Yeah that was never my intention to force everyone onto this. I always wanted to ease the learning curve of LoongArch assembly, and improve its readability and brevity along the way. All my effort around the assembler is centered around this, including the addition of "ret" of course. And thanks for the very much needed communication and understanding.