diff mbox series

[v2] LoongArch: Allow s9 as a register alias

Message ID 20240305115125.368489-1-xry111@xry111.site
State New
Headers show
Series [v2] LoongArch: Allow s9 as a register alias | expand

Commit Message

Xi Ruoyao March 5, 2024, 11:50 a.m. UTC
The psABI allows using s9 as an alias of r22.

gcc/ChangeLog:

	* config/loongarch/loongarch.h (ADDITIONAL_REGISTER_NAMES): Add
	s9 as an alias of r22.
---

v1 -> v2: Add a test case.

Ok for trunk?

 gcc/config/loongarch/loongarch.h                   | 1 +
 gcc/testsuite/gcc.target/loongarch/regname-fp-s9.c | 3 +++
 2 files changed, 4 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/loongarch/regname-fp-s9.c

Comments

Lulu Cheng March 5, 2024, 12:09 p.m. UTC | #1
在 2024/3/5 下午7:50, Xi Ruoyao 写道:
> The psABI allows using s9 as an alias of r22.
>
> gcc/ChangeLog:
>
> 	* config/loongarch/loongarch.h (ADDITIONAL_REGISTER_NAMES): Add
> 	s9 as an alias of r22.
> ---
>
> v1 -> v2: Add a test case.
>
> Ok for trunk?
Ok. Thanks!
>
>   gcc/config/loongarch/loongarch.h                   | 1 +
>   gcc/testsuite/gcc.target/loongarch/regname-fp-s9.c | 3 +++
>   2 files changed, 4 insertions(+)
>   create mode 100644 gcc/testsuite/gcc.target/loongarch/regname-fp-s9.c
>
> diff --git a/gcc/config/loongarch/loongarch.h b/gcc/config/loongarch/loongarch.h
> index 8b453ab3140..bf2351f0968 100644
> --- a/gcc/config/loongarch/loongarch.h
> +++ b/gcc/config/loongarch/loongarch.h
> @@ -931,6 +931,7 @@ typedef struct {
>     { "t8",	20 + GP_REG_FIRST },					\
>     { "x",	21 + GP_REG_FIRST },					\
>     { "fp",	22 + GP_REG_FIRST },					\
> +  { "s9",	22 + GP_REG_FIRST },					\
>     { "s0",	23 + GP_REG_FIRST },					\
>     { "s1",	24 + GP_REG_FIRST },					\
>     { "s2",	25 + GP_REG_FIRST },					\
> diff --git a/gcc/testsuite/gcc.target/loongarch/regname-fp-s9.c b/gcc/testsuite/gcc.target/loongarch/regname-fp-s9.c
> new file mode 100644
> index 00000000000..d2e3b80f83c
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/loongarch/regname-fp-s9.c
> @@ -0,0 +1,3 @@
> +/* { dg-do compile } */
> +register long s9 asm("s9"); /* { dg-note "conflicts with 's9'" } */
> +register long fp asm("fp"); /* { dg-warning "register of 'fp' used for multiple global register variables" } */
diff mbox series

Patch

diff --git a/gcc/config/loongarch/loongarch.h b/gcc/config/loongarch/loongarch.h
index 8b453ab3140..bf2351f0968 100644
--- a/gcc/config/loongarch/loongarch.h
+++ b/gcc/config/loongarch/loongarch.h
@@ -931,6 +931,7 @@  typedef struct {
   { "t8",	20 + GP_REG_FIRST },					\
   { "x",	21 + GP_REG_FIRST },					\
   { "fp",	22 + GP_REG_FIRST },					\
+  { "s9",	22 + GP_REG_FIRST },					\
   { "s0",	23 + GP_REG_FIRST },					\
   { "s1",	24 + GP_REG_FIRST },					\
   { "s2",	25 + GP_REG_FIRST },					\
diff --git a/gcc/testsuite/gcc.target/loongarch/regname-fp-s9.c b/gcc/testsuite/gcc.target/loongarch/regname-fp-s9.c
new file mode 100644
index 00000000000..d2e3b80f83c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/regname-fp-s9.c
@@ -0,0 +1,3 @@ 
+/* { dg-do compile } */
+register long s9 asm("s9"); /* { dg-note "conflicts with 's9'" } */
+register long fp asm("fp"); /* { dg-warning "register of 'fp' used for multiple global register variables" } */