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
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)
(aarch64_sve::nvectors_if_data_type): Replace with...
(aarch64_sve::builtin_type_p): ...this.
{
sve_switcher sve;
register_builtin_types ();
+ if (in_lto_p)
+ handle_arm_sve_h ();
}
/* Register vector type TYPE under its arm_sve.h name. */
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;
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);
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
#include "tree-diagnostic.h"
#include "output.h"
#include "timevar.h"
+#include "stor-layout.h"
/* Do nothing; in many cases the default hook. */
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. */
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.
* gcc.target/aarch64/sve/pcs/asm_1.c: Likewise.
* gcc.target/aarch64/sve/pcs/asm_2.c: Likewise.
--- /dev/null
+/* { dg-do run { target aarch64_sve_hw } } */
+/* { dg-options "-O2 -flto -ffixed-z0 -ffixed-p0" } */
+
+#include "asm_3.c"