diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2020-01-07 10:21:26 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2020-01-07 10:21:26 +0000 |
commit | ab341f5003f8ad9f5ee30ce566d68d8284a31f00 (patch) | |
tree | 0bf5b28df193c9cc10990bf5bd48d954dbc5afa9 /gcc/langhooks.c | |
parent | 683e93d1975f676d00096b7c93b942dbd0491800 (diff) | |
download | gcc-ab341f5003f8ad9f5ee30ce566d68d8284a31f00.zip gcc-ab341f5003f8ad9f5ee30ce566d68d8284a31f00.tar.gz gcc-ab341f5003f8ad9f5ee30ce566d68d8284a31f00.tar.bz2 |
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
Diffstat (limited to 'gcc/langhooks.c')
-rw-r--r-- | gcc/langhooks.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/langhooks.c b/gcc/langhooks.c index e8295978..640bd01 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -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. */ |