* [Alpha] Implement TARGET_BUILTIN_DECL
@ 2010-09-29 14:40 Richard Henderson
0 siblings, 0 replies; only message in thread
From: Richard Henderson @ 2010-09-29 14:40 UTC (permalink / raw)
To: gcc-patches >> GCC Patches
[-- Attachment #1: Type: text/plain, Size: 47 bytes --]
Tested with qemu cross from x86_64-linux.
r~
[-- Attachment #2: z --]
[-- Type: text/plain, Size: 4179 bytes --]
* config/alpha/alpha.c (alpha_builtins): New.
(alpha_builtin_decl, TARGET_BUILTIN_DECL): New.
(alpha_builtin_function): New.
(alpha_add_builtins, alpha_init_builtins): Use it.
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index 49c86fd..fda8c75 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -6634,6 +6634,36 @@ static GTY(()) tree alpha_v8qi_s;
static GTY(()) tree alpha_v4hi_u;
static GTY(()) tree alpha_v4hi_s;
+static GTY(()) tree alpha_builtins[(int) ALPHA_BUILTIN_max];
+
+/* Return the alpha builtin for CODE. */
+
+static tree
+alpha_builtin_decl (unsigned code, bool initialize_p ATTRIBUTE_UNUSED)
+{
+ if (code >= ALPHA_BUILTIN_max)
+ return error_mark_node;
+ return alpha_builtins[code];
+}
+
+/* Helper function of alpha_init_builtins. Add the built-in specified
+ by NAME, TYPE, CODE, and ECF. */
+
+static void
+alpha_builtin_function (const char *name, tree ftype,
+ enum alpha_builtin code, unsigned ecf)
+{
+ tree decl = add_builtin_function (name, ftype, (int) code,
+ BUILT_IN_MD, NULL, NULL_TREE);
+
+ if (ecf & ECF_CONST)
+ TREE_READONLY (decl) = 1;
+ if (ecf & ECF_NOTHROW)
+ TREE_NOTHROW (decl) = 1;
+
+ alpha_builtins [(int) code] = decl;
+}
+
/* Helper function of alpha_init_builtins. Add the COUNT built-in
functions pointed to by P, with function type FTYPE. */
@@ -6641,26 +6671,19 @@ static void
alpha_add_builtins (const struct alpha_builtin_def *p, size_t count,
tree ftype)
{
- tree decl;
size_t i;
for (i = 0; i < count; ++i, ++p)
if ((target_flags & p->target_mask) == p->target_mask)
- {
- decl = add_builtin_function (p->name, ftype, p->code, BUILT_IN_MD,
- NULL, NULL);
- if (p->is_const)
- TREE_READONLY (decl) = 1;
- TREE_NOTHROW (decl) = 1;
- }
+ alpha_builtin_function (p->name, ftype, p->code,
+ (p->is_const ? ECF_CONST : 0) | ECF_NOTHROW);
}
-
static void
alpha_init_builtins (void)
{
tree dimode_integer_type_node;
- tree ftype, decl;
+ tree ftype;
dimode_integer_type_node = lang_hooks.types.type_for_mode (DImode, 0);
@@ -6686,30 +6709,26 @@ alpha_init_builtins (void)
ftype);
ftype = build_function_type (ptr_type_node, void_list_node);
- decl = add_builtin_function ("__builtin_thread_pointer", ftype,
- ALPHA_BUILTIN_THREAD_POINTER, BUILT_IN_MD,
- NULL, NULL);
- TREE_NOTHROW (decl) = 1;
+ alpha_builtin_function ("__builtin_thread_pointer", ftype,
+ ALPHA_BUILTIN_THREAD_POINTER, ECF_NOTHROW);
ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
- decl = add_builtin_function ("__builtin_set_thread_pointer", ftype,
- ALPHA_BUILTIN_SET_THREAD_POINTER, BUILT_IN_MD,
- NULL, NULL);
- TREE_NOTHROW (decl) = 1;
+ alpha_builtin_function ("__builtin_set_thread_pointer", ftype,
+ ALPHA_BUILTIN_SET_THREAD_POINTER, ECF_NOTHROW);
if (TARGET_ABI_OPEN_VMS)
{
ftype = build_function_type_list (ptr_type_node, ptr_type_node,
NULL_TREE);
- add_builtin_function ("__builtin_establish_vms_condition_handler", ftype,
- ALPHA_BUILTIN_ESTABLISH_VMS_CONDITION_HANDLER,
- BUILT_IN_MD, NULL, NULL_TREE);
+ alpha_builtin_function ("__builtin_establish_vms_condition_handler",
+ ftype,
+ ALPHA_BUILTIN_ESTABLISH_VMS_CONDITION_HANDLER,
+ 0);
ftype = build_function_type_list (ptr_type_node, void_type_node,
NULL_TREE);
- add_builtin_function ("__builtin_revert_vms_condition_handler", ftype,
- ALPHA_BUILTIN_REVERT_VMS_CONDITION_HANDLER,
- BUILT_IN_MD, NULL, NULL_TREE);
+ alpha_builtin_function ("__builtin_revert_vms_condition_handler", ftype,
+ ALPHA_BUILTIN_REVERT_VMS_CONDITION_HANDLER, 0);
}
alpha_v8qi_u = build_vector_type (unsigned_intQI_type_node, 8);
@@ -11082,6 +11101,8 @@ alpha_init_libfuncs (void)
#undef TARGET_HAVE_TLS
#define TARGET_HAVE_TLS HAVE_AS_TLS
+#undef TARGET_BUILTIN_DECL
+#define TARGET_BUILTIN_DECL alpha_builtin_decl
#undef TARGET_INIT_BUILTINS
#define TARGET_INIT_BUILTINS alpha_init_builtins
#undef TARGET_EXPAND_BUILTIN
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-09-28 22:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-29 14:40 [Alpha] Implement TARGET_BUILTIN_DECL Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).