[PATCH 4/7] opcodes: LoongArch: make all non-native jumps desugar to canonical b{gt/le}[u] forms

WANG Xuerui i.swmail@xen0n.name
Mon Oct 25 03:12:00 GMT 2021


From: WANG Xuerui <git@xen0n.name>

2021-10-25  WANG Xuerui <git@xen0n.name>

opcodes/
        * loongarch-opc.c: Remove concrete definitions for blt, bge,
        bltu, bgeu; desugar to bgt, ble, bgtu, bleu with operand order
        swapped respectively.  Make bgez and bltz desugar to ble and bgt
        too.
---
 opcodes/loongarch-opc.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/opcodes/loongarch-opc.c b/opcodes/loongarch-opc.c
index 86f060449dc..1f8f9227a1f 100644
--- a/opcodes/loongarch-opc.c
+++ b/opcodes/loongarch-opc.c
@@ -751,28 +751,24 @@ static struct loongarch_opcode loongarch_jmp_opcodes[] =
   { 0x58000000, 0xfc000000,	"beq",		"r5:5,r0:5,sb10:16<<2",		0,				0, 0, 0 },
   { 0x0,	0x0,		"bne",		"r,r,la",			"bne %1,%2,%%pcrel(%3)",	0, 0, 0 },
   { 0x5c000000, 0xfc000000,	"bne",		"r5:5,r0:5,sb10:16<<2",		0,				0, 0, 0 },
-  { 0x0,	0x0,		"blt",		"r,r,la",			"blt %1,%2,%%pcrel(%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,%%pcrel(%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,%%pcrel(%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,%%pcrel(%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,%%pcrel(%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,%%pcrel(%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,%%pcrel(%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,%%pcrel(%3)",	0, 0, 0 },
   { 0x6c000000, 0xfc000000,	"bleu",		"r0:5,r5:5,sb10:16<<2",		0,				0, 0, 0 },
 
   /* Sugars.  */
-  { 0x0,	0x0,		"bgez",		"r,la",				"bge %1,$r0,%%pcrel(%2)",	0, 0, 0 },
+  { 0x0,	0x0,		"bge",		"r,r,la",			"ble %2,%1,%%pcrel(%3)",	0, 0, 0 },
+  { 0x0,	0x0,		"bgeu",		"r,r,la",			"bleu %2,%1,%%pcrel(%3)",	0, 0, 0 },
+  { 0x0,	0x0,		"bgez",		"r,la",				"ble $r0,%1,%%pcrel(%2)",	0, 0, 0 },
   { 0x0,	0x0,		"bgtz",		"r,la",				"bgt %1,$r0,%%pcrel(%2)",	0, 0, 0 },
   { 0x0,	0x0,		"blez",		"r,la",				"ble %1,$r0,%%pcrel(%2)",	0, 0, 0 },
-  { 0x0,	0x0,		"bltz",		"r,la",				"blt %1,$r0,%%pcrel(%2)",	0, 0, 0 },
+  { 0x0,	0x0,		"blt",		"r,r,la",			"bgt %2,%1,%%pcrel(%3)",	0, 0, 0 },
+  { 0x0,	0x0,		"bltu",		"r,r,la",			"bgtu %2,%1,%%pcrel(%3)",	0, 0, 0 },
+  { 0x0,	0x0,		"bltz",		"r,la",				"bgt $r0,%1,%%pcrel(%2)",	0, 0, 0 },
   { 0x0,	0x0,		"jr",		"r",				"jirl $r0,%1,0",		0, 0, 0 },
 
   { 0 } /* Terminate the list.  */
-- 
2.33.1



More information about the Binutils mailing list