mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-23 07:00:27 +08:00
Add a generic lhd_simulate_enum_decl
Normally we only create SVE ACLE functions when arm_sve.h is included. But for LTO we need to do it at start-up, so that the functions are already defined when streaming in the LTO objects. One hitch with doing that is that LTO doesn't yet implement the simulate_enum_decl langhook. This patch adds a simple default implementation that it can use. 2020-01-07 Richard Sandiford <richard.sandiford@arm.com> gcc/ * langhooks-def.h (lhd_simulate_enum_decl): Declare. (LANG_HOOKS_SIMULATE_ENUM_DECL): Use it. * langhooks.c: Include stor-layout.h. (lhd_simulate_enum_decl): New function. * config/aarch64/aarch64-sve-builtins.cc (init_builtins): Call handle_arm_sve_h for the LTO frontend. (register_vector_type): Cope with null returns from pushdecl. gcc/testsuite/ * gcc.target/aarch64/sve/pcs/asm_4.c: New test. From-SVN: r279954
This commit is contained in:
parent
683e93d197
commit
ab341f5003
@ -1,3 +1,13 @@
|
||||
2020-01-07 Richard Sandiford <richard.sandiford@arm.com>
|
||||
|
||||
* langhooks-def.h (lhd_simulate_enum_decl): Declare.
|
||||
(LANG_HOOKS_SIMULATE_ENUM_DECL): Use it.
|
||||
* langhooks.c: Include stor-layout.h.
|
||||
(lhd_simulate_enum_decl): New function.
|
||||
* config/aarch64/aarch64-sve-builtins.cc (init_builtins): Call
|
||||
handle_arm_sve_h for the LTO frontend.
|
||||
(register_vector_type): Cope with null returns from pushdecl.
|
||||
|
||||
2020-01-07 Richard Sandiford <richard.sandiford@arm.com>
|
||||
|
||||
* config/aarch64/aarch64-protos.h (aarch64_sve::svbool_type_p)
|
||||
|
@ -3044,6 +3044,8 @@ init_builtins ()
|
||||
{
|
||||
sve_switcher sve;
|
||||
register_builtin_types ();
|
||||
if (in_lto_p)
|
||||
handle_arm_sve_h ();
|
||||
}
|
||||
|
||||
/* Register vector type TYPE under its arm_sve.h name. */
|
||||
@ -3060,7 +3062,8 @@ register_vector_type (vector_type_index type)
|
||||
right form, even if it doesn't have the right name. This should give
|
||||
better error recovery behavior than installing error_mark_node or
|
||||
installing an incorrect type. */
|
||||
if (TREE_CODE (decl) == TYPE_DECL
|
||||
if (decl
|
||||
&& TREE_CODE (decl) == TYPE_DECL
|
||||
&& TYPE_MAIN_VARIANT (TREE_TYPE (decl)) == vectype)
|
||||
vectype = TREE_TYPE (decl);
|
||||
acle_vector_types[0][type] = vectype;
|
||||
|
@ -54,6 +54,8 @@ extern void lhd_print_error_function (diagnostic_context *,
|
||||
extern void lhd_set_decl_assembler_name (tree decl);
|
||||
extern void lhd_overwrite_decl_assembler_name (tree decl, tree name);
|
||||
extern bool lhd_warn_unused_global_decl (const_tree);
|
||||
extern tree lhd_simulate_enum_decl (location_t, const char *,
|
||||
vec<string_int_pair>);
|
||||
extern tree lhd_type_for_size (unsigned precision, int unsignedp);
|
||||
extern void lhd_incomplete_type_error (location_t, const_tree, const_tree);
|
||||
extern tree lhd_type_promotes_to (tree);
|
||||
@ -171,7 +173,7 @@ extern tree lhd_make_node (enum tree_code);
|
||||
extern tree lhd_unit_size_without_reusable_padding (tree);
|
||||
|
||||
#define LANG_HOOKS_MAKE_TYPE lhd_make_node
|
||||
#define LANG_HOOKS_SIMULATE_ENUM_DECL NULL
|
||||
#define LANG_HOOKS_SIMULATE_ENUM_DECL lhd_simulate_enum_decl
|
||||
#define LANG_HOOKS_CLASSIFY_RECORD NULL
|
||||
#define LANG_HOOKS_TYPE_FOR_SIZE lhd_type_for_size
|
||||
#define LANG_HOOKS_INCOMPLETE_TYPE_ERROR lhd_incomplete_type_error
|
||||
|
@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "tree-diagnostic.h"
|
||||
#include "output.h"
|
||||
#include "timevar.h"
|
||||
#include "stor-layout.h"
|
||||
|
||||
/* Do nothing; in many cases the default hook. */
|
||||
|
||||
@ -473,6 +474,44 @@ lhd_make_node (enum tree_code code)
|
||||
return make_node (code);
|
||||
}
|
||||
|
||||
/* Default implementation of LANG_HOOKS_SIMULATE_ENUM_DECL. Assume a
|
||||
simple int-based enumerator (which is all the hook can be used for
|
||||
at present) and push each decl individually without any decoration.
|
||||
|
||||
This definition is suitable for LTO and is generic enough that it
|
||||
might be reusable elsewhere. */
|
||||
tree
|
||||
lhd_simulate_enum_decl (location_t loc, const char *name,
|
||||
vec<string_int_pair> values)
|
||||
{
|
||||
tree enumtype = lang_hooks.types.make_type (ENUMERAL_TYPE);
|
||||
tree enumdecl = build_decl (loc, TYPE_DECL, get_identifier (name), enumtype);
|
||||
TYPE_STUB_DECL (enumtype) = enumdecl;
|
||||
|
||||
tree value_chain = NULL_TREE;
|
||||
string_int_pair *value;
|
||||
unsigned int i;
|
||||
FOR_EACH_VEC_ELT (values, i, value)
|
||||
{
|
||||
tree value_decl = build_decl (loc, CONST_DECL,
|
||||
get_identifier (value->first), enumtype);
|
||||
DECL_INITIAL (value_decl) = build_int_cst (integer_type_node,
|
||||
value->second);
|
||||
lang_hooks.decls.pushdecl (value_decl);
|
||||
value_chain = tree_cons (value_decl, DECL_INITIAL (value_decl),
|
||||
value_chain);
|
||||
}
|
||||
|
||||
TYPE_MIN_VALUE (enumtype) = TYPE_MIN_VALUE (integer_type_node);
|
||||
TYPE_MAX_VALUE (enumtype) = TYPE_MAX_VALUE (integer_type_node);
|
||||
SET_TYPE_ALIGN (enumtype, TYPE_ALIGN (integer_type_node));
|
||||
TYPE_PRECISION (enumtype) = TYPE_PRECISION (integer_type_node);
|
||||
layout_type (enumtype);
|
||||
lang_hooks.decls.pushdecl (enumdecl);
|
||||
|
||||
return enumtype;
|
||||
}
|
||||
|
||||
/* Default implementation of LANG_HOOKS_TYPE_FOR_SIZE.
|
||||
Return an integer type with PRECISION bits of precision,
|
||||
that is unsigned if UNSIGNEDP is nonzero, otherwise signed. */
|
||||
|
@ -1,3 +1,7 @@
|
||||
2020-01-07 Richard Sandiford <richard.sandiford@arm.com>
|
||||
|
||||
* gcc.target/aarch64/sve/pcs/asm_4.c: New test.
|
||||
|
||||
2020-01-07 Richard Sandiford <richard.sandiford@arm.com>
|
||||
|
||||
* g++.target/aarch64/sve/acle/general-c++/mangle_5.C: New test.
|
||||
|
4
gcc/testsuite/gcc.target/aarch64/sve/pcs/asm_4.c
Normal file
4
gcc/testsuite/gcc.target/aarch64/sve/pcs/asm_4.c
Normal file
@ -0,0 +1,4 @@
|
||||
/* { dg-do run { target aarch64_sve_hw } } */
|
||||
/* { dg-options "-O2 -flto -ffixed-z0 -ffixed-p0" } */
|
||||
|
||||
#include "asm_3.c"
|
Loading…
x
Reference in New Issue
Block a user