public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/7] Assorted LoongArch fixes
@ 2021-10-25  3:11 WANG Xuerui
  2021-10-25  3:11 ` [PATCH 1/7] opcodes: LoongArch: explicitly define b{lt/gt/le/ge}z as syntactic sugars WANG Xuerui
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: WANG Xuerui @ 2021-10-25  3:11 UTC (permalink / raw)
  To: binutils; +Cc: Chenghua Xu, liuzhensong, WANG Xuerui

From: WANG Xuerui <git@xen0n.name>

Hi everyone,

Here's some tweaks and fixes that pushes LoongArch a little closer to
other architectures, to hopefully reduce learning costs for newcomers.

- The ubiquitous "ret" instruction is added as syntactic sugar for
  "jirl $zero, $ra, 0".
- The starting address for .text is changed to 0x10000 which many other
  architectures use; the previous value is inherited from MIPS with no
  reason.
- Syntax for jumps are slightly tweaked, primarily for making sure that
  multiple register operands always come in LSB-first order, for
  consistency.

The patches have been brewing since August, and are used to build a
whole Gentoo system without problem. I'll add support for disassembling
known idioms (things like "andi $zero, $zero, 0" -> "nop") and syntactic
sugars in a future series.

WANG Xuerui (7):
  opcodes: LoongArch: explicitly define b{lt/gt/le/ge}z as syntactic
    sugars
  opcodes: LoongArch: move definition of jr to sugar section
  opcodes: LoongArch: sort loongarch_jmp_opcodes entries by opcodes
  opcodes: LoongArch: make all non-native jumps desugar to canonical
    b{gt/le}[u] forms
  opcodes: LoongArch: add "ret" instruction to reduce typing
  opcodes: LoongArch: make beq/bne's operand order "rd, rj" to be
    consistent with all others
  LoongArch: make .text start at 0x10000

 ld/emulparams/elf64loongarch-defs.sh |  2 +-
 opcodes/loongarch-opc.c              | 38 +++++++++++++---------------
 2 files changed, 18 insertions(+), 22 deletions(-)

-- 
2.33.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/7] opcodes: LoongArch: explicitly define b{lt/gt/le/ge}z as syntactic sugars
  2021-10-25  3:11 [PATCH 0/7] Assorted LoongArch fixes WANG Xuerui
@ 2021-10-25  3:11 ` WANG Xuerui
  2021-10-25  3:11 ` [PATCH 2/7] opcodes: LoongArch: move definition of jr to sugar section WANG Xuerui
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: WANG Xuerui @ 2021-10-25  3:11 UTC (permalink / raw)
  To: binutils; +Cc: Chenghua Xu, liuzhensong, WANG Xuerui

From: WANG Xuerui <git@xen0n.name>

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

opcodes/
        * loongarch-opc.c: Remove concrete definitions for bltz, bgtz, blez,
        bgez, and modify the expansion to perform canonicalization instead.
---
 opcodes/loongarch-opc.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/opcodes/loongarch-opc.c b/opcodes/loongarch-opc.c
index 4ccea71ee03..21429b77b97 100644
--- a/opcodes/loongarch-opc.c
+++ b/opcodes/loongarch-opc.c
@@ -738,14 +738,6 @@ 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,%%pcrel(%2)",		0, 0, 0 },
-  { 0x60000000, 0xfc00001f,	"bltz",		"r5:5,sb10:16<<2",		0,				0, 0, 0 },
-  { 0x0,	0x0,		"bgtz",		"r,la",				"bgtz %1,%%pcrel(%2)",		0, 0, 0 },
-  { 0x60000000, 0xfc0003e0,	"bgtz",		"r0:5,sb10:16<<2",		0,				0, 0, 0 },
-  { 0x0,	0x0,		"bgez",		"r,la",				"bgez %1,%%pcrel(%2)",		0, 0, 0 },
-  { 0x64000000, 0xfc00001f,	"bgez",		"r5:5,sb10:16<<2",		0,				0, 0, 0 },
-  { 0x0,	0x0,		"blez",		"r,la",				"blez %1,%%pcrel(%2)",		0, 0, 0 },
-  { 0x64000000, 0xfc0003e0,	"blez",		"r0:5,sb10:16<<2",		0,				0, 0, 0 },
   { 0x0,	0x0,		"beqz",		"r,la",				"beqz %1,%%pcrel(%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,%%pcrel(%2)",		0, 0, 0 },
@@ -776,6 +768,13 @@ static struct loongarch_opcode loongarch_jmp_opcodes[] =
   { 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,		"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 },
+
   { 0 } /* Terminate the list.  */
 };
 
-- 
2.33.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 2/7] opcodes: LoongArch: move definition of jr to sugar section
  2021-10-25  3:11 [PATCH 0/7] Assorted LoongArch fixes WANG Xuerui
  2021-10-25  3:11 ` [PATCH 1/7] opcodes: LoongArch: explicitly define b{lt/gt/le/ge}z as syntactic sugars WANG Xuerui
@ 2021-10-25  3:11 ` WANG Xuerui
  2021-10-25  3:11 ` [PATCH 3/7] opcodes: LoongArch: sort loongarch_jmp_opcodes entries by opcodes WANG Xuerui
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: WANG Xuerui @ 2021-10-25  3:11 UTC (permalink / raw)
  To: binutils; +Cc: Chenghua Xu, liuzhensong, WANG Xuerui

From: WANG Xuerui <git@xen0n.name>

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

opcodes/
        * loongarch-opc.c: Move definition of jr to "Sugars" section
        below.
---
 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 21429b77b97..08d86ea9f40 100644
--- a/opcodes/loongarch-opc.c
+++ b/opcodes/loongarch-opc.c
@@ -742,7 +742,6 @@ static struct loongarch_opcode loongarch_jmp_opcodes[] =
   { 0x40000000, 0xfc000000,	"beqz",		"r5:5,sb0:5|10:16<<2",		0,				0, 0, 0 },
   { 0x0,	0x0,		"bnez",		"r,la",				"bnez %1,%%pcrel(%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 %%pcrel(%1)",		0, 0, 0 },
   { 0x4c000000, 0xfc000000,	"jirl",		"r0:5,r5:5,s10:16<<2",		0,				0, 0, 0 },
@@ -774,6 +773,7 @@ static struct loongarch_opcode loongarch_jmp_opcodes[] =
   { 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,		"jr",		"r",				"jirl $r0,%1,0",		0, 0, 0 },
 
   { 0 } /* Terminate the list.  */
 };
-- 
2.33.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 3/7] opcodes: LoongArch: sort loongarch_jmp_opcodes entries by opcodes
  2021-10-25  3:11 [PATCH 0/7] Assorted LoongArch fixes WANG Xuerui
  2021-10-25  3:11 ` [PATCH 1/7] opcodes: LoongArch: explicitly define b{lt/gt/le/ge}z as syntactic sugars WANG Xuerui
  2021-10-25  3:11 ` [PATCH 2/7] opcodes: LoongArch: move definition of jr to sugar section WANG Xuerui
@ 2021-10-25  3:11 ` WANG Xuerui
  2021-10-25  3:12 ` [PATCH 4/7] opcodes: LoongArch: make all non-native jumps desugar to canonical b{gt/le}[u] forms WANG Xuerui
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: WANG Xuerui @ 2021-10-25  3:11 UTC (permalink / raw)
  To: binutils; +Cc: Chenghua Xu, liuzhensong, WANG Xuerui

From: WANG Xuerui <git@xen0n.name>

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

opcodes/
        * loongarch-opc.c: Sort loongarch_jmp_opcodes.
---
 opcodes/loongarch-opc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/opcodes/loongarch-opc.c b/opcodes/loongarch-opc.c
index 08d86ea9f40..86f060449dc 100644
--- a/opcodes/loongarch-opc.c
+++ b/opcodes/loongarch-opc.c
@@ -742,9 +742,9 @@ static struct loongarch_opcode loongarch_jmp_opcodes[] =
   { 0x40000000, 0xfc000000,	"beqz",		"r5:5,sb0:5|10:16<<2",		0,				0, 0, 0 },
   { 0x0,	0x0,		"bnez",		"r,la",				"bnez %1,%%pcrel(%2)",		0, 0, 0 },
   { 0x44000000, 0xfc000000,	"bnez",		"r5:5,sb0:5|10:16<<2",		0,				0, 0, 0 },
-  { 0x50000000, 0xfc000000,	"b",		"sb0:10|10:16<<2",		0,				0, 0, 0 },
-  { 0x0,	0x0,		"b",		"la",				"b %%pcrel(%1)",		0, 0, 0 },
   { 0x4c000000, 0xfc000000,	"jirl",		"r0:5,r5:5,s10:16<<2",		0,				0, 0, 0 },
+  { 0x0,	0x0,		"b",		"la",				"b %%pcrel(%1)",		0, 0, 0 },
+  { 0x50000000, 0xfc000000,	"b",		"sb0:10|10:16<<2",		0,				0, 0, 0 },
   { 0x0,	0x0,		"bl",		"la",				"bl %%pcrel(%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,%%pcrel(%3)",	0, 0, 0 },
-- 
2.33.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 4/7] opcodes: LoongArch: make all non-native jumps desugar to canonical b{gt/le}[u] forms
  2021-10-25  3:11 [PATCH 0/7] Assorted LoongArch fixes WANG Xuerui
                   ` (2 preceding siblings ...)
  2021-10-25  3:11 ` [PATCH 3/7] opcodes: LoongArch: sort loongarch_jmp_opcodes entries by opcodes WANG Xuerui
@ 2021-10-25  3:12 ` WANG Xuerui
  2021-10-25  3:12 ` [PATCH 5/7] opcodes: LoongArch: add "ret" instruction to reduce typing WANG Xuerui
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: WANG Xuerui @ 2021-10-25  3:12 UTC (permalink / raw)
  To: binutils; +Cc: Chenghua Xu, liuzhensong, WANG Xuerui

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 5/7] opcodes: LoongArch: add "ret" instruction to reduce typing
  2021-10-25  3:11 [PATCH 0/7] Assorted LoongArch fixes WANG Xuerui
                   ` (3 preceding siblings ...)
  2021-10-25  3:12 ` [PATCH 4/7] opcodes: LoongArch: make all non-native jumps desugar to canonical b{gt/le}[u] forms WANG Xuerui
@ 2021-10-25  3:12 ` WANG Xuerui
  2021-10-25  3:12 ` [PATCH 6/7] opcodes: LoongArch: make beq/bne's operand order "rd, rj" to be consistent with all others WANG Xuerui
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: WANG Xuerui @ 2021-10-25  3:12 UTC (permalink / raw)
  To: binutils; +Cc: Chenghua Xu, liuzhensong, WANG Xuerui

From: WANG Xuerui <git@xen0n.name>

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

opcodes/
        * loongarch-opc.c: Add "ret" to loongarch_jmp_opcodes.
---
 opcodes/loongarch-opc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/opcodes/loongarch-opc.c b/opcodes/loongarch-opc.c
index 1f8f9227a1f..687bfd776c5 100644
--- a/opcodes/loongarch-opc.c
+++ b/opcodes/loongarch-opc.c
@@ -770,6 +770,7 @@ static struct loongarch_opcode loongarch_jmp_opcodes[] =
   { 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 },
+  { 0x0,	0x0,		"ret",		"",				"jirl $r0,$r1,0",		0, 0, 0 },
 
   { 0 } /* Terminate the list.  */
 };
-- 
2.33.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 6/7] opcodes: LoongArch: make beq/bne's operand order "rd, rj" to be consistent with all others
  2021-10-25  3:11 [PATCH 0/7] Assorted LoongArch fixes WANG Xuerui
                   ` (4 preceding siblings ...)
  2021-10-25  3:12 ` [PATCH 5/7] opcodes: LoongArch: add "ret" instruction to reduce typing WANG Xuerui
@ 2021-10-25  3:12 ` WANG Xuerui
  2021-10-25  3:12 ` [PATCH 7/7] LoongArch: make .text start at 0x10000 WANG Xuerui
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: WANG Xuerui @ 2021-10-25  3:12 UTC (permalink / raw)
  To: binutils; +Cc: Chenghua Xu, liuzhensong, WANG Xuerui

From: WANG Xuerui <git@xen0n.name>

This has no functional impact, but keeps the instruction format nice and
clean; all register operands are ordered LSB-first.

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

opcodes/
        * loongarch-opc.c: Swap operand order of beq and bne.
---
 opcodes/loongarch-opc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/opcodes/loongarch-opc.c b/opcodes/loongarch-opc.c
index 687bfd776c5..277ef60c193 100644
--- a/opcodes/loongarch-opc.c
+++ b/opcodes/loongarch-opc.c
@@ -748,9 +748,9 @@ static struct loongarch_opcode loongarch_jmp_opcodes[] =
   { 0x0,	0x0,		"bl",		"la",				"bl %%pcrel(%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,%%pcrel(%3)",	0, 0, 0 },
-  { 0x58000000, 0xfc000000,	"beq",		"r5:5,r0:5,sb10:16<<2",		0,				0, 0, 0 },
+  { 0x58000000, 0xfc000000,	"beq",		"r0:5,r5: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 },
+  { 0x5c000000, 0xfc000000,	"bne",		"r0:5,r5: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,		"ble",		"r,r,la",			"ble %1,%2,%%pcrel(%3)",	0, 0, 0 },
-- 
2.33.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 7/7] LoongArch: make .text start at 0x10000
  2021-10-25  3:11 [PATCH 0/7] Assorted LoongArch fixes WANG Xuerui
                   ` (5 preceding siblings ...)
  2021-10-25  3:12 ` [PATCH 6/7] opcodes: LoongArch: make beq/bne's operand order "rd, rj" to be consistent with all others WANG Xuerui
@ 2021-10-25  3:12 ` WANG Xuerui
  2021-11-11  1:08 ` [PATCH 0/7] Assorted LoongArch fixes WANG Xuerui
  2021-11-16  3:32 ` Chenghua Xu
  8 siblings, 0 replies; 10+ messages in thread
From: WANG Xuerui @ 2021-10-25  3:12 UTC (permalink / raw)
  To: binutils; +Cc: Chenghua Xu, liuzhensong, WANG Xuerui

From: WANG Xuerui <git@xen0n.name>

The previous value obviously is coming from MIPS; no reason is given as
to why this is absolutely needed.  Just change to get closer to RISC-V
and a few other arches.

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

ld/
        * emulparams/elf64loongarch-defs.sh: Change TEXT_START_ADDR to
        0x10000.
---
 ld/emulparams/elf64loongarch-defs.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ld/emulparams/elf64loongarch-defs.sh b/ld/emulparams/elf64loongarch-defs.sh
index c793f5d8388..744b018a6f6 100644
--- a/ld/emulparams/elf64loongarch-defs.sh
+++ b/ld/emulparams/elf64loongarch-defs.sh
@@ -30,7 +30,7 @@ esac
 # LoongArch nop is 'andi $r0,$r0,0'.
 NOP=0x00004003
 
-TEXT_START_ADDR=0x120000000
+TEXT_START_ADDR=0x10000
 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
 COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
 
-- 
2.33.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/7] Assorted LoongArch fixes
  2021-10-25  3:11 [PATCH 0/7] Assorted LoongArch fixes WANG Xuerui
                   ` (6 preceding siblings ...)
  2021-10-25  3:12 ` [PATCH 7/7] LoongArch: make .text start at 0x10000 WANG Xuerui
@ 2021-11-11  1:08 ` WANG Xuerui
  2021-11-16  3:32 ` Chenghua Xu
  8 siblings, 0 replies; 10+ messages in thread
From: WANG Xuerui @ 2021-11-11  1:08 UTC (permalink / raw)
  To: binutils; +Cc: Chenghua Xu, liuzhensong

On 10/25/21 11:11, WANG Xuerui wrote:

> From: WANG Xuerui <git@xen0n.name>
>
> Hi everyone,
>
> Here's some tweaks and fixes that pushes LoongArch a little closer to
> other architectures, to hopefully reduce learning costs for newcomers.
>
> - The ubiquitous "ret" instruction is added as syntactic sugar for
>    "jirl $zero, $ra, 0".
> - The starting address for .text is changed to 0x10000 which many other
>    architectures use; the previous value is inherited from MIPS with no
>    reason.
> - Syntax for jumps are slightly tweaked, primarily for making sure that
>    multiple register operands always come in LSB-first order, for
>    consistency.
>
> The patches have been brewing since August, and are used to build a
> whole Gentoo system without problem. I'll add support for disassembling
> known idioms (things like "andi $zero, $zero, 0" -> "nop") and syntactic
> sugars in a future series.
>
> WANG Xuerui (7):
>    opcodes: LoongArch: explicitly define b{lt/gt/le/ge}z as syntactic
>      sugars
>    opcodes: LoongArch: move definition of jr to sugar section
>    opcodes: LoongArch: sort loongarch_jmp_opcodes entries by opcodes
>    opcodes: LoongArch: make all non-native jumps desugar to canonical
>      b{gt/le}[u] forms
>    opcodes: LoongArch: add "ret" instruction to reduce typing
>    opcodes: LoongArch: make beq/bne's operand order "rd, rj" to be
>      consistent with all others
>    LoongArch: make .text start at 0x10000
>
>   ld/emulparams/elf64loongarch-defs.sh |  2 +-
>   opcodes/loongarch-opc.c              | 38 +++++++++++++---------------
>   2 files changed, 18 insertions(+), 22 deletions(-)
>
Friendly ping for review? I have several more patches waiting already, 
or I'll have to rebase instead.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/7] Assorted LoongArch fixes
  2021-10-25  3:11 [PATCH 0/7] Assorted LoongArch fixes WANG Xuerui
                   ` (7 preceding siblings ...)
  2021-11-11  1:08 ` [PATCH 0/7] Assorted LoongArch fixes WANG Xuerui
@ 2021-11-16  3:32 ` Chenghua Xu
  8 siblings, 0 replies; 10+ messages in thread
From: Chenghua Xu @ 2021-11-16  3:32 UTC (permalink / raw)
  To: WANG Xuerui, binutils; +Cc: liuzhensong, WANG Xuerui

Hi Xuerui,

Sorry for delay.

Changing the opcode orders are fine for me,  but please consider using 
"macro" instruction instead of "sugar" in the comments.

Adding 'ret' macro instruction should be hold, Maybe we need start a 
discussion on LoongArch Documents. By the way, I dislike it.

Changing .text start should  be hold, we need find the reason why other 
target use 0x10000.

Thanks.

On 10/25/21 11:11 AM, WANG Xuerui wrote:
> From: WANG Xuerui <git@xen0n.name>
>
> Hi everyone,
>
> Here's some tweaks and fixes that pushes LoongArch a little closer to
> other architectures, to hopefully reduce learning costs for newcomers.
>
> - The ubiquitous "ret" instruction is added as syntactic sugar for
>    "jirl $zero, $ra, 0".
> - The starting address for .text is changed to 0x10000 which many other
>    architectures use; the previous value is inherited from MIPS with no
>    reason.
> - Syntax for jumps are slightly tweaked, primarily for making sure that
>    multiple register operands always come in LSB-first order, for
>    consistency.
>
> The patches have been brewing since August, and are used to build a
> whole Gentoo system without problem. I'll add support for disassembling
> known idioms (things like "andi $zero, $zero, 0" -> "nop") and syntactic
> sugars in a future series.
>
> WANG Xuerui (7):
>    opcodes: LoongArch: explicitly define b{lt/gt/le/ge}z as syntactic
>      sugars
>    opcodes: LoongArch: move definition of jr to sugar section
>    opcodes: LoongArch: sort loongarch_jmp_opcodes entries by opcodes
>    opcodes: LoongArch: make all non-native jumps desugar to canonical
>      b{gt/le}[u] forms
>    opcodes: LoongArch: add "ret" instruction to reduce typing
>    opcodes: LoongArch: make beq/bne's operand order "rd, rj" to be
>      consistent with all others
>    LoongArch: make .text start at 0x10000
>
>   ld/emulparams/elf64loongarch-defs.sh |  2 +-
>   opcodes/loongarch-opc.c              | 38 +++++++++++++---------------
>   2 files changed, 18 insertions(+), 22 deletions(-)
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-11-16  3:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25  3:11 [PATCH 0/7] Assorted LoongArch fixes WANG Xuerui
2021-10-25  3:11 ` [PATCH 1/7] opcodes: LoongArch: explicitly define b{lt/gt/le/ge}z as syntactic sugars WANG Xuerui
2021-10-25  3:11 ` [PATCH 2/7] opcodes: LoongArch: move definition of jr to sugar section WANG Xuerui
2021-10-25  3:11 ` [PATCH 3/7] opcodes: LoongArch: sort loongarch_jmp_opcodes entries by opcodes WANG Xuerui
2021-10-25  3:12 ` [PATCH 4/7] opcodes: LoongArch: make all non-native jumps desugar to canonical b{gt/le}[u] forms WANG Xuerui
2021-10-25  3:12 ` [PATCH 5/7] opcodes: LoongArch: add "ret" instruction to reduce typing WANG Xuerui
2021-10-25  3:12 ` [PATCH 6/7] opcodes: LoongArch: make beq/bne's operand order "rd, rj" to be consistent with all others WANG Xuerui
2021-10-25  3:12 ` [PATCH 7/7] LoongArch: make .text start at 0x10000 WANG Xuerui
2021-11-11  1:08 ` [PATCH 0/7] Assorted LoongArch fixes WANG Xuerui
2021-11-16  3:32 ` Chenghua Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).