diff options
author | Christophe Lyon <christophe.lyon@linaro.org> | 2025-01-08 18:51:27 +0000 |
---|---|---|
committer | Christophe Lyon <christophe.lyon@linaro.org> | 2025-01-10 15:15:02 +0000 |
commit | 288ac095b4df1a47a4cf9ba2efdc56a568a6e951 (patch) | |
tree | 3b811daf4634cd0f0a94b71e3bd23e66351a61a3 | |
parent | 553411851d9d20510979eb4daa6675d01a79aea4 (diff) | |
download | gcc-288ac095b4df1a47a4cf9ba2efdc56a568a6e951.zip gcc-288ac095b4df1a47a4cf9ba2efdc56a568a6e951.tar.gz gcc-288ac095b4df1a47a4cf9ba2efdc56a568a6e951.tar.bz2 |
arm: [MVE intrinsics] Fix tuples field name (PR 118332)
The previous fix only worked for C, for C++ we need to add more
information to the underlying type so that
finish_class_member_access_expr accepts it.
We use the same logic as in aarch64's register_tuple_type for AdvSIMD
tuples.
This patch makes gcc.target/arm/mve/intrinsics/pr118332.c pass in C++
mode.
gcc/ChangeLog:
PR target/118332
* config/arm/arm-mve-builtins.cc (wrap_type_in_struct): Delete.
(register_type_decl): Delete.
(register_builtin_tuple_types): Use
lang_hooks.types.simulate_record_decl.
-rw-r--r-- | gcc/config/arm/arm-mve-builtins.cc | 52 |
1 files changed, 8 insertions, 44 deletions
diff --git a/gcc/config/arm/arm-mve-builtins.cc b/gcc/config/arm/arm-mve-builtins.cc index 4c52415..42b53cc0 100644 --- a/gcc/config/arm/arm-mve-builtins.cc +++ b/gcc/config/arm/arm-mve-builtins.cc @@ -463,47 +463,6 @@ register_vector_type (vector_type_index type) acle_vector_types[0][type] = vectype; } -/* Return a structure type that contains a single field of type FIELD_TYPE. - The field is called 'val', as mandated by ACLE. */ -static tree -wrap_type_in_struct (tree field_type) -{ - tree field = build_decl (input_location, FIELD_DECL, - get_identifier ("val"), field_type); - tree struct_type = lang_hooks.types.make_type (RECORD_TYPE); - DECL_FIELD_CONTEXT (field) = struct_type; - TYPE_FIELDS (struct_type) = field; - layout_type (struct_type); - return struct_type; -} - -/* Register a built-in TYPE_DECL called NAME for TYPE. This is used/needed - when TYPE is a structure type. */ -static void -register_type_decl (tree type, const char *name) -{ - tree decl = build_decl (input_location, TYPE_DECL, - get_identifier (name), type); - TYPE_NAME (type) = decl; - TYPE_STUB_DECL (type) = decl; - lang_hooks.decls.pushdecl (decl); - /* ??? Undo the effect of set_underlying_type for C. The C frontend - doesn't recognize DECL as a built-in because (as intended) the decl has - a real location instead of BUILTINS_LOCATION. The frontend therefore - treats the decl like a normal C "typedef struct foo foo;", expecting - the type for tag "struct foo" to have a dummy unnamed TYPE_DECL instead - of the named one we attached above. It then sets DECL_ORIGINAL_TYPE - on the supposedly unnamed decl, creating a circularity that upsets - dwarf2out. - - We don't want to follow the normal C model and create "struct foo" - tags for tuple types since (a) the types are supposed to be opaque - and (b) they couldn't be defined as a real struct anyway. Treating - the TYPE_DECLs as "typedef struct foo foo;" without creating - "struct foo" would lead to confusing error messages. */ - DECL_ORIGINAL_TYPE (decl) = NULL_TREE; -} - /* Register tuple types of element type TYPE under their arm_mve_types.h names. */ static void @@ -538,13 +497,18 @@ register_builtin_tuple_types (vector_type_index type) && TYPE_MODE_RAW (arrtype) == TYPE_MODE (arrtype) && TYPE_ALIGN (arrtype) == 64); - tree tuple_type = wrap_type_in_struct (arrtype); + /* Build a structure type that contains a single field of type ARRTYPE. + The field is called 'val', as mandated by ACLE. */ + tree field = build_decl (input_location, FIELD_DECL, + get_identifier ("val"), arrtype); + tree tuple_type + = lang_hooks.types.simulate_record_decl (input_location, + buffer, + make_array_slice (&field, 1)); gcc_assert (VECTOR_MODE_P (TYPE_MODE (tuple_type)) && TYPE_MODE_RAW (tuple_type) == TYPE_MODE (tuple_type) && TYPE_ALIGN (tuple_type) == 64); - register_type_decl (tuple_type, buffer); - acle_vector_types[num_vectors >> 1][type] = tuple_type; } } |