diff mbox

[AArch64] Implement %c output template

Message ID 525FC66A.2070806@arm.com
State New
Headers show

Commit Message

Kyrylo Tkachov Oct. 17, 2013, 11:13 a.m. UTC
Hi all,

This patch implements the %c output template for inline asm. The code for it is 
almost identical to the support in arm, so it's pretty straightforward. I've 
added a few compile tests for it as well.

Tested aarch64-none-elf on a model.

Ok for trunk?

Thanks,
Kyrill

[gcc/]
2013-10-17  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     * config/aarch64/aarch64.c (aarch64_print_operand): Handle 'c'.

[gcc/testsuite]
2013-10-17  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     * gcc.target/aarch64/c-output-template.c: New testcase.
     * gcc.target/aarch64/c-output-template-2.c: Likewise.
     * gcc.target/aarch64/c-output-template-3.c: Likewise.

Comments

Marcus Shawcroft Oct. 17, 2013, 4:43 p.m. UTC | #1
On 17 October 2013 12:13, Kyrill Tkachov <kyrylo.tkachov@arm.com> wrote:

> [gcc/]
> 2013-10-17  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
>
>     * config/aarch64/aarch64.c (aarch64_print_operand): Handle 'c'.
>
> [gcc/testsuite]
> 2013-10-17  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
>
>     * gcc.target/aarch64/c-output-template.c: New testcase.
>     * gcc.target/aarch64/c-output-template-2.c: Likewise.
>     * gcc.target/aarch64/c-output-template-3.c: Likewise.

OK
/Marcus
Maxim Kuvyrkov March 20, 2014, 9:28 p.m. UTC | #2
On Oct 18, 2013, at 12:13 AM, Kyrill Tkachov <kyrylo.tkachov@arm.com> wrote:

> Hi all,
> 
> This patch implements the %c output template for inline asm. The code for it is almost identical to the support in arm, so it's pretty straightforward. I've added a few compile tests for it as well.
> 
> Tested aarch64-none-elf on a model.
> 
> Ok for trunk?
> 
> Thanks,
> Kyrill
> 
> [gcc/]
> 2013-10-17  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
> 
>    * config/aarch64/aarch64.c (aarch64_print_operand): Handle 'c'.
> 
> [gcc/testsuite]
> 2013-10-17  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
> 
>    * gcc.target/aarch64/c-output-template.c: New testcase.
>    * gcc.target/aarch64/c-output-template-2.c: Likewise.
>    * gcc.target/aarch64/c-output-template-3.c: Likewise.<aarch64-c-output-temp.patch>

Kyrill,

From the testcases it appears that %c constraint modifier can be used by users through inline assembly -- is this intended use-case or an [unsupported] side-effect?

If "yes" then it, probably, needs documentation in doc/tm.texi or elsewhere.

Thank you,

--
Maxim Kuvyrkov
www.linaro.org
diff mbox

Patch

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index b61b453..d2a3d49 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -3426,6 +3426,32 @@  aarch64_print_operand (FILE *f, rtx x, char code)
 {
   switch (code)
     {
+    /* An integer or symbol address without a preceding # sign.  */
+    case 'c':
+      switch (GET_CODE (x))
+	{
+	case CONST_INT:
+	  fprintf (f, HOST_WIDE_INT_PRINT_DEC, INTVAL (x));
+	  break;
+
+	case SYMBOL_REF:
+	  output_addr_const (f, x);
+	  break;
+
+	case CONST:
+	  if (GET_CODE (XEXP (x, 0)) == PLUS
+	      && GET_CODE (XEXP (XEXP (x, 0), 0)) == SYMBOL_REF)
+	    {
+	      output_addr_const (f, x);
+	      break;
+	    }
+	  /* Fall through.  */
+
+	default:
+	  output_operand_lossage ("Unsupported operand for code '%c'", code);
+	}
+      break;
+
     case 'e':
       /* Print the sign/zero-extend size as a character 8->b, 16->h, 32->w.  */
       {
diff --git a/gcc/testsuite/gcc.target/aarch64/c-output-template-2.c b/gcc/testsuite/gcc.target/aarch64/c-output-template-2.c
new file mode 100644
index 0000000..16ff58d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/c-output-template-2.c
@@ -0,0 +1,15 @@ 
+/* { dg-do compile } */
+
+struct tracepoint {
+    int dummy;
+    int state;
+};
+static struct tracepoint tp;
+
+void
+test (void)
+{
+    __asm__ ("@ %c0" : : "i" (&tp));
+}
+
+/* { dg-final { scan-assembler "@ tp" } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/c-output-template-3.c b/gcc/testsuite/gcc.target/aarch64/c-output-template-3.c
new file mode 100644
index 0000000..e332fe1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/c-output-template-3.c
@@ -0,0 +1,15 @@ 
+/* { dg-do compile } */
+
+struct tracepoint {
+    int dummy;
+    int state;
+};
+static struct tracepoint tp;
+
+void
+test (void)
+{
+    __asm__ ("@ %c0" : : "i" (&tp.state));
+}
+
+/* { dg-final { scan-assembler "@ tp\\+4" } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/c-output-template.c b/gcc/testsuite/gcc.target/aarch64/c-output-template.c
new file mode 100644
index 0000000..1b67c91
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/c-output-template.c
@@ -0,0 +1,9 @@ 
+/* { dg-do compile } */
+
+void
+test (void)
+{
+    __asm__ ("@ %c0" : : "i" (42));
+}
+
+/* { dg-final { scan-assembler "@ 42" } } */