public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v1] LoongArch: gcsrxchg cannot use r0 and r1 as rj registers
@ 2024-02-29 11:40 Lulu Cai
  0 siblings, 0 replies; only message in thread
From: Lulu Cai @ 2024-02-29 11:40 UTC (permalink / raw)
  To: binutils
  Cc: xuchenghua, chenglulu, liuzhensong, mengqinggang, xry111,
	i.swmail, maskray, luweining, wanglei, hejinyang, Lulu Cai

---
 gas/config/tc-loongarch.c                         | 5 +++--
 gas/testsuite/gas/loongarch/check_gcsrxchg_regs.d | 3 +++
 gas/testsuite/gas/loongarch/check_gcsrxchg_regs.l | 2 ++
 gas/testsuite/gas/loongarch/check_gcsrxchg_regs.s | 1 +
 gas/testsuite/gas/loongarch/lvz-lbt.d             | 2 +-
 gas/testsuite/gas/loongarch/lvz-lbt.s             | 2 +-
 6 files changed, 11 insertions(+), 4 deletions(-)
 create mode 100644 gas/testsuite/gas/loongarch/check_gcsrxchg_regs.d
 create mode 100644 gas/testsuite/gas/loongarch/check_gcsrxchg_regs.l
 create mode 100644 gas/testsuite/gas/loongarch/check_gcsrxchg_regs.s

diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c
index de92366eda4..3a661e76967 100644
--- a/gas/config/tc-loongarch.c
+++ b/gas/config/tc-loongarch.c
@@ -962,8 +962,9 @@ check_this_insn_before_appending (struct loongarch_cl_insn *ip)
     }
   else if (ip->insn->mask != 0 && (ip->insn_bin & 0xfe0003c0) == 0x04000000
 	   /* csrxchg  rd, rj, csr_num  */
-	   && (strcmp ("csrxchg", ip->name) == 0))
-    as_fatal (_("csrxchg require rj != $r0 && rj != $r1"));
+	   && (strcmp ("csrxchg", ip->name) == 0
+	       || strcmp ("gcsrxchg", ip->name) == 0))
+    as_fatal (_("g?csrxchg require rj != $r0 && rj != $r1"));
 
   return ret;
 }
diff --git a/gas/testsuite/gas/loongarch/check_gcsrxchg_regs.d b/gas/testsuite/gas/loongarch/check_gcsrxchg_regs.d
new file mode 100644
index 00000000000..f8ff34e2473
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/check_gcsrxchg_regs.d
@@ -0,0 +1,3 @@
+#as:
+#source: check_gcsrxchg_regs.s
+#error_output: check_gcsrxchg_regs.l
diff --git a/gas/testsuite/gas/loongarch/check_gcsrxchg_regs.l b/gas/testsuite/gas/loongarch/check_gcsrxchg_regs.l
new file mode 100644
index 00000000000..54cbdaf657b
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/check_gcsrxchg_regs.l
@@ -0,0 +1,2 @@
+.*: Assembler messages:
+.*error: g\?csrxchg require rj != \$r0 && rj != \$r1
diff --git a/gas/testsuite/gas/loongarch/check_gcsrxchg_regs.s b/gas/testsuite/gas/loongarch/check_gcsrxchg_regs.s
new file mode 100644
index 00000000000..acc2f51fbc3
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/check_gcsrxchg_regs.s
@@ -0,0 +1 @@
+gcsrxchg	$r0, $r1, 1
diff --git a/gas/testsuite/gas/loongarch/lvz-lbt.d b/gas/testsuite/gas/loongarch/lvz-lbt.d
index f89707762dc..557f3ac1a6d 100644
--- a/gas/testsuite/gas/loongarch/lvz-lbt.d
+++ b/gas/testsuite/gas/loongarch/lvz-lbt.d
@@ -10,7 +10,7 @@ Disassembly of section .text:
 00000000.* <.text>:
 [ 	]*0:[ 	]*05000400[ 	]*gcsrrd[ 	]*\$zero,[ 	]*0x1[ 	]*
 [ 	]*4:[ 	]*05000420[ 	]*gcsrwr[ 	]*\$zero,[ 	]*0x1[ 	]*
-[ 	]*8:[ 	]*05000420[ 	]*gcsrwr[ 	]*\$zero,[ 	]*0x1[ 	]*
+[ 	]*8:[ 	]*05000483[ 	]*gcsrxchg[ 	]*\$sp, \$a0, 0x1
 [ 	]*c:[ 	]*06482401[ 	]*gtlbflush[ 	]*
 [ 	]*10:[ 	]*002b8001[ 	]*hvcl[ 	]*0x1[ 	]*
 [ 	]*14:[ 	]*00000820[ 	]*movgr2scr[ 	]*\$scr0,[ 	]*\$ra[ 	]*
diff --git a/gas/testsuite/gas/loongarch/lvz-lbt.s b/gas/testsuite/gas/loongarch/lvz-lbt.s
index 64469a4362d..850f77ff3a7 100644
--- a/gas/testsuite/gas/loongarch/lvz-lbt.s
+++ b/gas/testsuite/gas/loongarch/lvz-lbt.s
@@ -1,6 +1,6 @@
 gcsrrd	$r0, 1
 gcsrwr	$r0, 1
-gcsrxchg	$r0, $r1, 1
+gcsrxchg	$r3, $r4, 1
 gtlbflush
 hvcl	1
 movgr2scr	$scr0, $r1
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-29 11:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-29 11:40 [PATCH v1] LoongArch: gcsrxchg cannot use r0 and r1 as rj registers Lulu Cai

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).