This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 2/4][AArch64]Improve error message for non-constant immediates
- From: Alan Lawrence <alan dot lawrence at arm dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 05 Dec 2014 11:55:21 +0000
- Subject: [PATCH 2/4][AArch64]Improve error message for non-constant immediates
- Authentication-results: sourceware.org; auth=none
The error message when passing a non-constant in place of an immediate to an
arm_neon.h *intrinsic* (as programmers should, rather than the __builtin), is poor:
In file included from gcc/testsuite/gcc.target/aarch64/arg-type-diagnostics-1.c:4:0:
/work/alalaw01/oban/buildfsf-aarch64-none-elf/install/lib/gcc/aarch64-none-elf/5.0.0/include/arm_neon.h:
In function 'foo':
/work/alalaw01/oban/buildfsf-aarch64-none-elf/install/lib/gcc/aarch64-none-elf/5.0.0/include/arm_neon.h:21752:10:
error: incompatible type for argument 3, expected 'const int'
return (int32x2_t) __builtin_aarch64_srsra_nv2si (__a, __b, __c);
...the line number references arm_neon.h, and the meaning of 'const int' is
distinct from what that means in C! Similarly to the previous patch, this patch
improves this to:
In file included from gcc/testsuite/gcc.target/aarch64/arg-type-diagnostics-1.c:4:0:
In function 'vrsra_n_s32',
inlined from 'foo' at
gcc/testsuite/gcc.target/aarch64/arg-type-diagnostics-1.c:13:10:
/work/alalaw01/oban/buildfsf-aarch64-none-elf/install/lib/gcc/aarch64-none-elf/5.0.0/include/arm_neon.h:21752:10:
error: argument 3 must be a constant immediate
return (int32x2_t) __builtin_aarch64_srsra_nv2si (__a, __b, __c);
(This shows arg-type-diagnostics-1.c:13:10, as the actual source line containing
the error).
The code for SIMD_ARG_CONSTANT also covers non-constant lane indices, so error
messages there are improved too.
gcc/ChangeLog:
* gcc/config/aarch64-builtins.c (aarch64_simd_expand_args): Update error
message for SIMD_ARG_CONSTANT.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/arg-type-diagnostics-1.c: Call intrinsic, update
expected error message.
diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c
index f8e14ab40637b66302f5cc194ae9507e37a248f9..09fd49648922a197d4d0a5f4d230af77ee0e31ba 100644
--- a/gcc/config/aarch64/aarch64-builtins.c
+++ b/gcc/config/aarch64/aarch64-builtins.c
@@ -925,8 +925,8 @@ aarch64_simd_expand_args (rtx target, int icode, int have_retval,
if (!(*insn_data[icode].operand[argc + have_retval].predicate)
(op[argc], mode[argc]))
{
- error_at (EXPR_LOCATION (exp), "incompatible type for argument %d, "
- "expected %<const int%>", argc + 1);
+ error ("%Kargument %d must be a constant immediate",
+ exp, argc + 1);
return const0_rtx;
}
break;
diff --git a/gcc/testsuite/gcc.target/aarch64/arg-type-diagnostics-1.c b/gcc/testsuite/gcc.target/aarch64/arg-type-diagnostics-1.c
index 55dd9f66f23cf6e6eff67bd68d875d24c0460d13..a7b7cd3bd8d40faaabbe48a1d382e9860d4497ff 100644
--- a/gcc/testsuite/gcc.target/aarch64/arg-type-diagnostics-1.c
+++ b/gcc/testsuite/gcc.target/aarch64/arg-type-diagnostics-1.c
@@ -3,13 +3,16 @@
#include "arm_neon.h"
-void foo ()
+void foo (int a)
{
- int a;
int32x2_t arg1;
int32x2_t arg2;
int32x2_t result;
arg1 = vcreate_s32 (UINT64_C (0x0000ffffffffffff));
arg2 = vcreate_s32 (UINT64_C (0x16497fffffffffff));
- result = __builtin_aarch64_srsra_nv2si (arg1, arg2, a); /* { dg-error "incompatible type for argument" } */
+ /* The correct line number is in the preamble to the error message,
+ not in the final line (which is all that dg-error inspects). Hence,
+ we have to tell dg-error to ignore the line number. */
+ result = vrsra_n_s32 (arg1, arg2, a);
+ /* { dg-error "must be a constant immediate" "" { target *-*-* } 0 } */
}