From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 2270C3858412 for ; Mon, 1 Aug 2022 03:43:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2270C3858412 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from [10.20.4.152] (unknown [10.20.4.152]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxv9DZS+di3xVIAA--.36685S3; Mon, 01 Aug 2022 11:43:21 +0800 (CST) Subject: Re: [PATCH 1/2] opcodes: LoongArch: make all non-native jumps desugar to canonical b{lt/ge}[u] forms To: WANG Xuerui , binutils@sourceware.org Cc: Chenghua Xu , Xi Ruoyao , WANG Xuerui References: <20220727110757.2520234-1-i.swmail@xen0n.name> <20220727110757.2520234-2-i.swmail@xen0n.name> From: liuzhensong Message-ID: Date: Mon, 1 Aug 2022 11:43:20 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20220727110757.2520234-2-i.swmail@xen0n.name> Content-Language: en-US X-CM-TRANSID: AQAAf9Dxv9DZS+di3xVIAA--.36685S3 X-Coremail-Antispam: 1UD129KBjvJXoW3AF1rWFW5Jr1rAF15ArW7CFg_yoW7KF13pr 1rt3yYkaykJr1rAF17G34UGry5Jw48Za4UJr4UXF45Ar1YqF1jqr15XrsYgF18Jw4rA34j qF13ArWqvF1UWw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvq14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AKxV WxJr0_GcWle2I262IYc4CY6c8Ij28IcVAaY2xG8wAv7VC0I7IYx2IY67AKxVWUJVWUGwAv 7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JM4x0x7 Aq67IIx4CEVc8vx2IErcIFxwCjr7xvwVCIw2I0I7xG6c02F41lc7I2V7IY0VAS07AlzVAY IcxG8wCY02Avz4vE-syl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2 IqxVAqx4xG67AKxVWUGVWUWwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v2 6r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2 IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2 jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0x ZFpf9x0JUp5l8UUUUU= X-CM-SenderInfo: holx6xphqv003j6o00pqjv00gofq/ X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00, BODY_8BITS, GIT_PATCH_0, HTML_MESSAGE, KAM_DMARC_STATUS, NICE_REPLY_A, SCC_10_SHORT_WORD_LINES, SCC_5_SHORT_WORD_LINES, 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 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Mon, 01 Aug 2022 03:43:27 -0000 在 2022/7/27 下午7:07, WANG Xuerui 写道: > 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 }, +  /* Jumps implemented with macros.  */ +  { 0x0,       0x0,            "jr", "r",                            "jirl $r0,%1,0",                0, 0, 0 }, +  { 0x0,       0x0,            "bgt", "r,r,la",                       "blt %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,            "ble", "r,r,la",                       "bge %2,%1,%%b16(%3)",          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 }, Maybe it's better to sort according to the order of the real instructions. > { 0 } /* Terminate the list. */ > }; >