aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2024-11-11 12:32:17 +0000
committerRichard Sandiford <richard.sandiford@arm.com>2024-11-11 12:32:17 +0000
commitcb83ad9d93fa113a5d038a727b1f8a2bd48a3696 (patch)
tree5212b3a5e5d85e0f62df3bbae05b135e26cbeed8 /gcc
parentbd45d4f9955022e688e75756b0cd8b8e54b33d4b (diff)
downloadgcc-cb83ad9d93fa113a5d038a727b1f8a2bd48a3696.zip
gcc-cb83ad9d93fa113a5d038a727b1f8a2bd48a3696.tar.gz
gcc-cb83ad9d93fa113a5d038a727b1f8a2bd48a3696.tar.bz2
aarch64: Parameterise SVE pointer type inference
All extending gather load intrinsics encode the source type in their name (e.g. svld1sb for an extending load from signed bytes). The type of the extension result has to be specified using an explicit type suffix; it isn't something that can be inferred from the arguments, since there are multiple valid choices for the same arguments. This meant that type inference for gather loads was only needed for non-extending loads, in which case the pointer target had to be a 32-bit or 64-bit element type. The gather_scatter_p argument to function_resolver::infer_pointer_type therefore controlled two things: how we should react to vector base addresses, and whether we should require a minimum element size of 32. The element size restriction doesn't apply to the upcomding SVE2.1 svld1q intrinsic, so this patch adds a separate argument for the minimum element size requirement. gcc/ * config/aarch64/aarch64-sve-builtins.h (function_resolver::target_type_restrictions): New enum. (function_resolver::infer_pointer_type): Add an extra argument that specifies what the target type can be. * config/aarch64/aarch64-sve-builtins.cc (function_resolver::infer_pointer_type): Likewise. * config/aarch64/aarch64-sve-builtins-shapes.cc (load_gather_sv_base::get_target_type_restrictions): New virtual member function. (load_gather_sv_base::resolve): Use it. Update call to infer_pointer_type.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/aarch64/aarch64-sve-builtins-shapes.cc10
-rw-r--r--gcc/config/aarch64/aarch64-sve-builtins.cc8
-rw-r--r--gcc/config/aarch64/aarch64-sve-builtins.h4
3 files changed, 17 insertions, 5 deletions
diff --git a/gcc/config/aarch64/aarch64-sve-builtins-shapes.cc b/gcc/config/aarch64/aarch64-sve-builtins-shapes.cc
index e1204c2..cf32154 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins-shapes.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins-shapes.cc
@@ -815,14 +815,22 @@ struct load_gather_sv_base : public overloaded_base<0>
unsigned int i, nargs;
mode_suffix_index mode;
type_suffix_index type;
+ auto restrictions = get_target_type_restrictions (r);
if (!r.check_gp_argument (2, i, nargs)
- || (type = r.infer_pointer_type (i, true)) == NUM_TYPE_SUFFIXES
+ || (type = r.infer_pointer_type (i, true,
+ restrictions)) == NUM_TYPE_SUFFIXES
|| (mode = r.resolve_sv_displacement (i + 1, type, true),
mode == MODE_none))
return error_mark_node;
return r.resolve_to (mode, type);
}
+
+ virtual function_resolver::target_type_restrictions
+ get_target_type_restrictions (const function_instance &) const
+ {
+ return function_resolver::TARGET_32_64;
+ }
};
/* Base class for load_ext_gather_index and load_ext_gather_offset,
diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc b/gcc/config/aarch64/aarch64-sve-builtins.cc
index a259f63..9fb0d6f 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins.cc
@@ -1998,10 +1998,12 @@ function_resolver::infer_64bit_scalar_integer_pair (unsigned int argno)
corresponding type suffix. Return that type suffix on success,
otherwise report an error and return NUM_TYPE_SUFFIXES.
GATHER_SCATTER_P is true if the function is a gather/scatter
- operation, and so requires a pointer to 32-bit or 64-bit data. */
+ operation. RESTRICTIONS describes any additional restrictions
+ on the target type. */
type_suffix_index
function_resolver::infer_pointer_type (unsigned int argno,
- bool gather_scatter_p)
+ bool gather_scatter_p,
+ target_type_restrictions restrictions)
{
tree actual = get_argument_type (argno);
if (actual == error_mark_node)
@@ -2027,7 +2029,7 @@ function_resolver::infer_pointer_type (unsigned int argno,
return NUM_TYPE_SUFFIXES;
}
unsigned int bits = type_suffixes[type].element_bits;
- if (gather_scatter_p && bits != 32 && bits != 64)
+ if (restrictions == TARGET_32_64 && bits != 32 && bits != 64)
{
error_at (location, "passing %qT to argument %d of %qE, which"
" expects a pointer to 32-bit or 64-bit elements",
diff --git a/gcc/config/aarch64/aarch64-sve-builtins.h b/gcc/config/aarch64/aarch64-sve-builtins.h
index 1fb7abe..5bd9b88 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins.h
+++ b/gcc/config/aarch64/aarch64-sve-builtins.h
@@ -488,6 +488,7 @@ public:
class function_resolver : public function_call_info
{
public:
+ enum target_type_restrictions { TARGET_ANY, TARGET_32_64 };
enum { SAME_SIZE = 256, HALF_SIZE, QUARTER_SIZE };
static const type_class_index SAME_TYPE_CLASS = NUM_TYPE_CLASSES;
@@ -518,7 +519,8 @@ public:
vector_type_index infer_predicate_type (unsigned int);
type_suffix_index infer_integer_scalar_type (unsigned int);
type_suffix_index infer_64bit_scalar_integer_pair (unsigned int);
- type_suffix_index infer_pointer_type (unsigned int, bool = false);
+ type_suffix_index infer_pointer_type (unsigned int, bool = false,
+ target_type_restrictions = TARGET_ANY);
sve_type infer_sve_type (unsigned int);
sve_type infer_vector_or_tuple_type (unsigned int, unsigned int);
type_suffix_index infer_vector_type (unsigned int);