This is based loosely upon svn r217440, "[AArch64] Add bounds checking to
vqdm_lane intrinsics...", but applies to more intrinsics (including e.g.
vget_lane), and does not do the endianness-flipping present on AArch64: the
objective is to exactly preserve behaviour on all valid code. (Yes, the new
qualifier may perhaps give us a location for flipping lanes according to
endianness in the future, but I'm not doing that here.) Checks for lanes being
in range for many insns are thus moved from assembly to expand time, with
inlining history. For example, previous error message:
vqrdmulh_lane_s16_indices_1.c: In function 'test1':
vqrdmulh_lane_s16_indices_1.c:9:1: error: lane out of range
}
^
becomes:
In file included vqrdmulh_lane_s16_indices_1.c:3:0:
In function 'vqrdmulh_lane_s16',
inlined from 'test1' at
gcc/testsuite/gcc.target/aarch64/simd/vqrdmulh_lane_s16_indices_1.c:8:10:
.../install/lib/gcc/arm-none-eabi/5.0.0/include/arm_neon.h:6882:10: error: lane
-1 out of range 0 - 3
return (int16x4_t)builtin_neon_vqrdmulh_lanev4hi (a, b, c);
Note the question of how to common up tests with those in
gcc.target/aarch64/simd/*_indices_1.c is not resolved by this patch.
Cross-tested check-gcc on arm-none-eabi
Bootstrapped on arm-none-linux-gnueabihf cortex-a15
gcc/ChangeLog:
* config/arm/arm-builtins.c (enum arm_type_qualifiers):
Add qualifier_lane_index.
(arm_binop_imm_qualifiers, BINOP_IMM_QUALIFIERS): New.
(arm_getlane_qualifiers): Use qualifier_lane_index.
(arm_lanemac_qualifiers): Rename to...
(arm_mac_n_qualifiers): ...this.
(LANEMAC_QUALIFIERS): Rename to...
(MAC_N_QUALIFIERS): ...this.
(arm_mac_lane_qualifiers, MAC_LANE_QUALIFIERS): New.
(arm_setlane_qualifiers): Use qualifier_lane_index.
(arm_ternop_imm_qualifiers, TERNOP_IMM_QUALIFIERS): New.
(enum builtin_arg): Add NEON_ARG_LANE_INDEX.
(arm_expand_neon_args): Handle NEON_ARG_LANE_INDEX.
(arm_expand_neon_builtin): Handle qualifier_lane_index.
* config/arm/arm-protos.h (neon_lane_bounds): Add const_tree parameter.
* config/arm/arm.c (bounds_check): Likewise, improve error message.
(neon_lane_bounds, neon_const_bounds): Add arguments to bounds_check.
* config/arm/arm_neon_builtins.def (vshrs_n, vshru_n, vrshrs_n,
vrshru_n, vshrn_n, vrshrn_n, vqshrns_n, vqshrnu_n, vqrshrns_n,
vqrshrnu_n, vqshrun_n, vqrshrun_n, vshl_n, vqshl_s_n, vqshl_u_n,
vqshlu_n, vshlls_n, vshllu_n): Change qualifiers to BINOP_IMM.
(vsras_n, vsrau_n, vrsras_n, vrsrau_n, vsri_n, vsli_n): Change
qualifiers to TERNOP_IMM.
(vdup_lane): Change qualifiers to GETLANE.
(vmla_lane, vmlals_lane, vmlalu_lane, vqdmlal_lane, vmls_lane,
vmlsls_lane, vmlslu_lane, vqdmlsl_lane): Change qualifiers to MAC_LANE.
(vmla_n, vmlals_n, vmlalu_n, vqdmlal_n, vmls_n, vmlsls_n, vmlslu_n,
vqdmlsl_n): Change qualifiers to MAC_N.
* config/arm/neon.md (neon_vget_lane<mode>, neon_vget_laneu<mode>,
neon_vget_lanedi, neon_vget_lanev2di, neon_vset_lane<mode>,
neon_vset_lanedi, neon_vdup_lane<mode>, neon_vdup_lanedi,
neon_vdup_lanev2di, neon_vmul_lane<mode>, neon_vmul_lane<mode>,
neon_vmull<sup>_lane<mode>, neon_vqdmull_lane<mode>,
neon_vq<r>dmulh_lane<mode>, neon_vq<r>dmulh_lane<mode>,
neon_vmla_lane<mode>, neon_vmla_lane<mode>, neon_vmlal<sup>_lane<mode>,
neon_vqdmlal_lane<mode>, neon_vmls_lane<mode>, neon_vmls_lane<mode>,
neon_vmlsl<sup>_lane<mode>, neon_vqdmlsl_lane<mode>):
Remove call to neon_lane_bounds.