From patchwork Tue Sep 28 22:41:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 66030 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 2E25AB710B for ; Wed, 29 Sep 2010 08:41:30 +1000 (EST) Received: (qmail 14366 invoked by alias); 28 Sep 2010 22:41:25 -0000 Received: (qmail 14352 invoked by uid 22791); 28 Sep 2010 22:41:24 -0000 X-SWARE-Spam-Status: No, hits=-5.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_QE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 28 Sep 2010 22:41:18 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8SMfGQA002507 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 28 Sep 2010 18:41:16 -0400 Received: from anchor.twiddle.home (ovpn-113-89.phx2.redhat.com [10.3.113.89]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8SMfEMk019609 for ; Tue, 28 Sep 2010 18:41:15 -0400 Message-ID: <4CA26F0A.7000701@redhat.com> Date: Tue, 28 Sep 2010 15:41:14 -0700 From: Richard Henderson User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc13 Thunderbird/3.1.4 MIME-Version: 1.0 To: "gcc-patches >> GCC Patches" Subject: [Alpha] Implement TARGET_BUILTIN_DECL X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Tested with qemu cross from x86_64-linux. r~ * 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