aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiufu Guo <guojiufu@linux.ibm.com>2024-07-23 13:34:20 +0800
committerguojiufu <guojiufu@linux.ibm.com>2024-07-23 18:21:25 +0800
commit472eab9ab1fdfd0ba3a555ea9eb50e20307c7052 (patch)
treeaaef8ca99e642abff50cfbb5db496e874d25d440
parent7793f5b4194253acaac0b53d8a1c95d9b5c8f4bb (diff)
downloadgcc-472eab9ab1fdfd0ba3a555ea9eb50e20307c7052.zip
gcc-472eab9ab1fdfd0ba3a555ea9eb50e20307c7052.tar.gz
gcc-472eab9ab1fdfd0ba3a555ea9eb50e20307c7052.tar.bz2
report message for operator %a on unaddressible operand
Hi, For PR96866, when printing asm code for modifier "%a", an addressable operand is required. While the constraint "X" allow any kind of operand even which is hard to get the address directly. e.g. extern symbol whose address is in TOC. An error message would be reported to indicate the invalid asm operand. Compare with previous version, test case is updated with -mno-pcrel. Bootstrap&regtest pass on ppc64{,le}. Is this ok for trunk? BR, Jeff(Jiufu Guo) PR target/96866 gcc/ChangeLog: * config/rs6000/rs6000.cc (print_operand_address): Emit message for unsupported operand. gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr96866-1.c: New test. * gcc.target/powerpc/pr96866-2.c: New test.
-rw-r--r--gcc/config/rs6000/rs6000.cc7
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr96866-1.c18
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr96866-2.c13
3 files changed, 37 insertions, 1 deletions
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 8521156..0bcc6a2 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -14706,7 +14706,12 @@ print_operand_address (FILE *file, rtx x)
fprintf (file, "@%s(%s)", SMALL_DATA_RELOC,
reg_names[SMALL_DATA_REG]);
else
- gcc_assert (!TARGET_TOC);
+ {
+ /* Do not support getting address directly from TOC, emit error.
+ No more work is needed for !TARGET_TOC. */
+ if (TARGET_TOC)
+ output_operand_lossage ("%%a requires an address of memory");
+ }
}
else if (GET_CODE (x) == PLUS && REG_P (XEXP (x, 0))
&& REG_P (XEXP (x, 1)))
diff --git a/gcc/testsuite/gcc.target/powerpc/pr96866-1.c b/gcc/testsuite/gcc.target/powerpc/pr96866-1.c
new file mode 100644
index 0000000..72e59a1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr96866-1.c
@@ -0,0 +1,18 @@
+/* The "%a" modifier can't get the address of extern symbol directly from TOC
+ with -fPIC, even the symbol is propagated for "X" constraint under -O2. */
+/* { dg-options "-fPIC -O2 -mno-pcrel" } */
+
+/* It's to verify no ICE here, ignore error messages about invalid 'asm'. */
+/* { dg-excess-errors "pr96866-1.c" } */
+
+int x[2];
+
+int __attribute__ ((noipa))
+f1 (void)
+{
+ int n;
+ int *p = x;
+ *p++;
+ __asm__ volatile("ld %0, %a1" : "=r"(n) : "X"(p));
+ return n;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr96866-2.c b/gcc/testsuite/gcc.target/powerpc/pr96866-2.c
new file mode 100644
index 0000000..72bb15f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr96866-2.c
@@ -0,0 +1,13 @@
+/* The "%a" modifier can't get the address of extern symbol directly from TOC
+ with -fPIC. */
+/* { dg-options "-fPIC -O2 -mno-pcrel" } */
+
+/* It's to verify no ICE here, ignore error messages about invalid 'asm'. */
+/* { dg-excess-errors "pr96866-2.c" } */
+
+void
+f (void)
+{
+ extern int x;
+ __asm__ volatile("#%a0" ::"X"(&x));
+}