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.tkac...@arm.com>

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

[gcc/testsuite]
2013-10-17  Kyrylo Tkachov  <kyrylo.tkac...@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.
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" } } */

Reply via email to