LoongArch: gas: Add support for s9 register

Message ID 20240125112846.1999078-1-mengqinggang@loongson.cn
State Unresolved
Headers
Series LoongArch: gas: Add support for s9 register |

Checks

Context Check Description
snail/binutils-gdb-check warning Git am fail log

Commit Message

mengqinggang Jan. 25, 2024, 11:28 a.m. UTC
  In LoongArch ABI, r22 register can be used as frame pointer or
static register(s9).

Link: https://github.com/loongson/la-abi-specs/blob/release/lapcs.adoc#general-purpose-registers
---
 gas/config/tc-loongarch.c  | 7 +++++--
 include/opcode/loongarch.h | 1 +
 opcodes/loongarch-opc.c    | 9 +++++++++
 3 files changed, 15 insertions(+), 2 deletions(-)
  

Patch

diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c
index e6a9901673f..e0aff36bbbb 100644
--- a/gas/config/tc-loongarch.c
+++ b/gas/config/tc-loongarch.c
@@ -316,8 +316,11 @@  loongarch_after_parse_args ()
   /* Init ilp32/lp64 registers alias.  */
   r_abi_names = loongarch_r_alias;
   for (i = 0; i < ARRAY_SIZE (loongarch_r_alias); i++)
-    str_hash_insert (r_htab, loongarch_r_alias[i], (void *) (i + 1),
-	0);
+    str_hash_insert (r_htab, loongarch_r_alias[i], (void *) (i + 1), 0);
+
+  for (i = 0; i < ARRAY_SIZE (loongarch_r_alias_1); i++)
+    str_hash_insert (r_htab, loongarch_r_alias_1[i], (void *) (i + 1), 0);
+
   for (i = 0; i < ARRAY_SIZE (loongarch_r_alias_deprecated); i++)
     str_hash_insert (r_deprecated_htab, loongarch_r_alias_deprecated[i],
 	(void *) (i + 1), 0);
diff --git a/include/opcode/loongarch.h b/include/opcode/loongarch.h
index 17de85c38b0..251daf13943 100644
--- a/include/opcode/loongarch.h
+++ b/include/opcode/loongarch.h
@@ -196,6 +196,7 @@  dec2 : [1-9][0-9]?
 
   extern const char *const loongarch_r_normal_name[32];
   extern const char *const loongarch_r_alias[32];
+  extern const char *const loongarch_r_alias_1[32];
   extern const char *const loongarch_r_alias_deprecated[32];
   extern const char *const loongarch_f_normal_name[32];
   extern const char *const loongarch_f_alias[32];
diff --git a/opcodes/loongarch-opc.c b/opcodes/loongarch-opc.c
index 490c689259c..6bd436fa1fe 100644
--- a/opcodes/loongarch-opc.c
+++ b/opcodes/loongarch-opc.c
@@ -49,6 +49,15 @@  const char *const loongarch_r_alias[32] =
   "$s1",   "$s2", "$s3", "$s4", "$s5", "$s6", "$s7", "$s8",
 };
 
+/* Add support for $s9.  */
+const char *const loongarch_r_alias_1[32] =
+{
+  "", "", "", "", "", "", "", "",
+  "", "", "", "", "", "", "", "",
+  "", "", "", "", "", "", "$s9", "",
+  "", "", "", "", "", "", "", "",
+};
+
 const char *const loongarch_r_alias_deprecated[32] =
 {
   "", "", "", "", "$v0", "$v1", "", "", "", "", "", "", "", "", "", "",