From: mengqinggang <mengqinggang@loongson.cn>
To: binutils@sourceware.org
Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn,
liuzhensong@loongson.cn, cailulu@loongson.cn, xry111@xry111.site,
i.swmail@xen0n.name, maskray@google.com, luweining@loongson.cn,
wanglei@loongson.cn, hejinyang@loongson.cn,
mengqinggang@loongson.cn
Subject: [PATCH v2] LoongArch: gas: Add support for s9 register
Date: Fri, 26 Jan 2024 11:11:33 +0800 [thread overview]
Message-ID: <20240126031133.3457231-1-mengqinggang@loongson.cn> (raw)
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
---
[v1] -> [v2]:
- Add a test.
gas/config/tc-loongarch.c | 7 +++++--
gas/testsuite/gas/loongarch/loongarch.exp | 1 +
gas/testsuite/gas/loongarch/reg-s9.l | 1 +
gas/testsuite/gas/loongarch/reg-s9.s | 2 ++
include/opcode/loongarch.h | 1 +
opcodes/loongarch-opc.c | 9 +++++++++
6 files changed, 19 insertions(+), 2 deletions(-)
create mode 100644 gas/testsuite/gas/loongarch/reg-s9.l
create mode 100644 gas/testsuite/gas/loongarch/reg-s9.s
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/gas/testsuite/gas/loongarch/loongarch.exp b/gas/testsuite/gas/loongarch/loongarch.exp
index 9ece4e810ff..422b858917e 100644
--- a/gas/testsuite/gas/loongarch/loongarch.exp
+++ b/gas/testsuite/gas/loongarch/loongarch.exp
@@ -31,4 +31,5 @@ if [istarget loongarch*-*-*] {
}
run_list_test "align"
+ run_list_test "reg-s9"
}
diff --git a/gas/testsuite/gas/loongarch/reg-s9.l b/gas/testsuite/gas/loongarch/reg-s9.l
new file mode 100644
index 00000000000..8ea739b7641
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/reg-s9.l
@@ -0,0 +1 @@
+# No warning or error expected.
diff --git a/gas/testsuite/gas/loongarch/reg-s9.s b/gas/testsuite/gas/loongarch/reg-s9.s
new file mode 100644
index 00000000000..74f40481ff2
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/reg-s9.s
@@ -0,0 +1,2 @@
+# Add support for $s9 register
+addi.d $t0, $s9, 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", "", "", "", "", "", "", "", "", "", "",
--
2.36.0
reply other threads:[~2024-01-26 3:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240126031133.3457231-1-mengqinggang@loongson.cn \
--to=mengqinggang@loongson.cn \
--cc=binutils@sourceware.org \
--cc=cailulu@loongson.cn \
--cc=chenglulu@loongson.cn \
--cc=hejinyang@loongson.cn \
--cc=i.swmail@xen0n.name \
--cc=liuzhensong@loongson.cn \
--cc=luweining@loongson.cn \
--cc=maskray@google.com \
--cc=wanglei@loongson.cn \
--cc=xry111@xry111.site \
--cc=xuchenghua@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).