public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] LoongArch: Add support for b ".L1" and beq "$t0", "$t1", ".L1"
@ 2023-12-06  3:17 mengqinggang
  2023-12-06  3:28 ` WANG Xuerui
  0 siblings, 1 reply; 10+ messages in thread
From: mengqinggang @ 2023-12-06  3:17 UTC (permalink / raw)
  To: binutils
  Cc: xuchenghua, chenglulu, liuzhensong, cailulu, xry111, i.swmail,
	maskray, mengqinggang

Support register and symbol names enclosed in double quotation marks.
---
 .../gas/loongarch/double_quotation_marks.d    | 11 +++++
 .../gas/loongarch/double_quotation_marks.s    |  2 +
 opcodes/loongarch-coder.c                     | 41 ++++++++++++++++---
 3 files changed, 48 insertions(+), 6 deletions(-)
 create mode 100644 gas/testsuite/gas/loongarch/double_quotation_marks.d
 create mode 100644 gas/testsuite/gas/loongarch/double_quotation_marks.s

diff --git a/gas/testsuite/gas/loongarch/double_quotation_marks.d b/gas/testsuite/gas/loongarch/double_quotation_marks.d
new file mode 100644
index 00000000000..99c6d343e4c
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/double_quotation_marks.d
@@ -0,0 +1,11 @@
+#as:
+#objdump: -dr
+
+.*:[    ]+file format .*
+
+
+Disassembly of section .text:
+
+.* <.text>:
+[ 	]+0:[ 	]+5800018d[ 	]+beq[ 	]+\$t0, \$t1, 0[ 	]+# 0x0
+[ 	]+0: R_LARCH_B16[ 	]+.L1
diff --git a/gas/testsuite/gas/loongarch/double_quotation_marks.s b/gas/testsuite/gas/loongarch/double_quotation_marks.s
new file mode 100644
index 00000000000..bb8acb99a40
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/double_quotation_marks.s
@@ -0,0 +1,2 @@
+# Before only support beq $t0, $t1, .L1
+beq "$t0", "$t1", ".L1"
diff --git a/opcodes/loongarch-coder.c b/opcodes/loongarch-coder.c
index a68ae1c3106..198de81aa25 100644
--- a/opcodes/loongarch-coder.c
+++ b/opcodes/loongarch-coder.c
@@ -254,16 +254,45 @@ loongarch_split_args_by_comma (char *args, const char *arg_strs[])
 {
   size_t num = 0;
 
+  /* Supporting <b ".L1"> or <beq "r1", "r2", ".L1">, ignore the first '"'.
+     Mismatched '"' is judged by common code and the white characters also
+     removed by common code. The code like <b ".L1"> or <b "r1","r2",".L1">.  */
+  if ('"' == *args)
+    args++;
+
   if (*args)
     arg_strs[num++] = args;
   for (; *args; args++)
-    if (*args == ',')
-      {
-	if (MAX_ARG_NUM_PLUS_2 - 1 == num)
+    {
+      /* Supporting <b ".L1"> or <beq "r1","r2",".L1>",
+	 ignore the last '"'.  */
+      if (('"' == *args) && ('\0' == *(args+1)))
+	{
+	  *args = '\0';
 	  break;
-	else
-	  *args = '\0', arg_strs[num++] = args + 1;
-      }
+	}
+
+      /* Supporting <b ".L1"> or <beq "r1","r2",".L1>",
+	 ignore the '"' before ','.  */
+      if (('"' == *args) && (',' == *(args+1)))
+	*args = '\0';
+
+      if (*args == ',')
+	{
+	  if (MAX_ARG_NUM_PLUS_2 - 1 == num)
+	    break;
+	  else
+	    {
+	      *args = '\0';
+	      /* Supporting <b ".L1"> or <beq "r1","r2",".L1">,
+		 ignore the '"' after ','.  */
+	      if('"' == *(args+1))
+		arg_strs[num++] = args + 2;
+	      else
+		arg_strs[num++] = args + 1;
+	    }
+	}
+    }
   arg_strs[num] = NULL;
   return num;
 }
-- 
2.36.0


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

end of thread, other threads:[~2023-12-08  1:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-06  3:17 [PATCH] LoongArch: Add support for b ".L1" and beq "$t0", "$t1", ".L1" mengqinggang
2023-12-06  3:28 ` WANG Xuerui
2023-12-06  3:45   ` Fangrui Song
     [not found]   ` <DS7PR12MB5765C29D265229889294CBF6CB84A@DS7PR12MB5765.namprd12.prod.outlook.com>
2023-12-06  4:55     ` Xi Ruoyao
2023-12-06  6:14       ` Fangrui Song
     [not found]       ` <MN0PR12MB5761C1CE97F155CFA535A33CCB84A@MN0PR12MB5761.namprd12.prod.outlook.com>
2023-12-06  6:35         ` Xi Ruoyao
2023-12-06  6:07   ` mengqinggang
2023-12-06  6:16     ` Xi Ruoyao
2023-12-06  6:22       ` Xi Ruoyao
2023-12-06  6:27         ` mengqinggang

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