aarch64: Add basic target_print_operand support for CONST_STRING

Message ID 20231026140740.3833021-1-victor.donascimento@arm.com
State Accepted
Headers
Series aarch64: Add basic target_print_operand support for CONST_STRING |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Victor Do Nascimento Oct. 26, 2023, 2:07 p.m. UTC
  Motivated by the need to print system register names in output
assembly, this patch adds the required logic to
`aarch64_print_operand' to accept rtxs of type CONST_STRING and
process these accordingly.

Consequently, an rtx such as:

  (set (reg/i:DI 0 x0)
         (unspec:DI [(const_string ("s3_3_c13_c2_2"))])

can now be output correctly using the following output pattern when
composing `define_insn's:

  "mrs\t%x0, %1"

Testing:
 - Bootstrap/regtest on aarch64-linux-gnu done.

gcc/ChangeLog

	* config/aarch64/aarch64.cc (aarch64_print_operand): Add
	support for CONST_STRING.
---
 gcc/config/aarch64/aarch64.cc | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Richard Sandiford Oct. 26, 2023, 3:44 p.m. UTC | #1
Victor Do Nascimento <victor.donascimento@arm.com> writes:
> Motivated by the need to print system register names in output
> assembly, this patch adds the required logic to
> `aarch64_print_operand' to accept rtxs of type CONST_STRING and
> process these accordingly.
>
> Consequently, an rtx such as:
>
>   (set (reg/i:DI 0 x0)
>          (unspec:DI [(const_string ("s3_3_c13_c2_2"))])
>
> can now be output correctly using the following output pattern when
> composing `define_insn's:
>
>   "mrs\t%x0, %1"
>
> Testing:
>  - Bootstrap/regtest on aarch64-linux-gnu done.
>
> gcc/ChangeLog
>
> 	* config/aarch64/aarch64.cc (aarch64_print_operand): Add
> 	support for CONST_STRING.

OK, thanks.

Richard

> ---
>  gcc/config/aarch64/aarch64.cc | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
> index 62b1ae0652f..c715f6369bc 100644
> --- a/gcc/config/aarch64/aarch64.cc
> +++ b/gcc/config/aarch64/aarch64.cc
> @@ -12346,6 +12346,11 @@ aarch64_print_operand (FILE *f, rtx x, int code)
>  
>        switch (GET_CODE (x))
>  	{
> +	case CONST_STRING:
> +	  {
> +	    asm_fprintf (f, "%s", XSTR (x, 0));
> +	    break;
> +	  }
>  	case REG:
>  	  if (aarch64_sve_data_mode_p (GET_MODE (x)))
>  	    {
  

Patch

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 62b1ae0652f..c715f6369bc 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -12346,6 +12346,11 @@  aarch64_print_operand (FILE *f, rtx x, int code)
 
       switch (GET_CODE (x))
 	{
+	case CONST_STRING:
+	  {
+	    asm_fprintf (f, "%s", XSTR (x, 0));
+	    break;
+	  }
 	case REG:
 	  if (aarch64_sve_data_mode_p (GET_MODE (x)))
 	    {