From patchwork Tue Oct 16 15:23:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 191819 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 9DD2E2C00AA for ; Wed, 17 Oct 2012 02:23:53 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1351005834; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=HiPwUBPrDE0hlx+7kCCeZOCRjdU=; b=suWl9dUo93F/4OW 9q6lPe+yyYp5peAWYAI/x38C4aRcXdFIz2M5w3+SXku/rBvXUXItq+NWo89CFr8U JexPJ1KLYRELf/HpVIe0sg1KPz/Z++RymrqmB5AxhHDmRb43V8JqM5PHQYg/L1v6 kG8tq0vTovcHA0tCUEPmVprqUFDU= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Date:From:To:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=oN/1EFVY22OvlcRZaZl9xjYEZ39z8UZcMCCzkLZwo9lDh5Ik5l9sD+QtTuQ0ka JwP0gdOy9bsYyZPPvEc3Z4J1Hwe+4zzdum4sSXQbAeL/ySQm6fZGGdzKy1XH7sNg FzHVFuipoKC3W9VDtZxJSImmgHnh0yFyuKeE3l7/oXy5k=; Received: (qmail 27228 invoked by alias); 16 Oct 2012 15:23:49 -0000 Received: (qmail 27217 invoked by uid 22791); 16 Oct 2012 15:23:48 -0000 X-SWARE-Spam-Status: No, hits=-4.0 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 16 Oct 2012 15:23:42 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 74B8B5437C7; Tue, 16 Oct 2012 17:23:40 +0200 (CEST) Date: Tue, 16 Oct 2012 17:23:40 +0200 From: Jan Hubicka To: paul@codesourcery.com, burnus@net-b.de, gcc-patches@gcc.gnu.org Subject: [fortran] add __builtin_unreachable Message-ID: <20121016152340.GA8724@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 Hi, this patch add __buliltin_unreachable to Fortran FE and also cleans up the code a bit Bootstrapped/regtested x86_64-linux, OK? Honza * f95-lang.c (gfc_define_builtin): Use set_call_expr_flags. (ATTR_NOTHROW_LEAF_MALLOC_LIST, ATTR_CONST_NORETURN_NOTHROW_LEAF_LIST): New lists. (gfc_init_builtin_functions): Add __builtin_unreachable; tidy malloc/calloc. * calls.c (set_call_expr_flags): New. * tree.h (set_call_expr_flags): Declare. Index: fortran/f95-lang.c =================================================================== --- fortran/f95-lang.c (revision 192483) +++ fortran/f95-lang.c (working copy) @@ -535,9 +535,11 @@ gfc_builtin_function (tree decl) /* So far we need just these 4 attribute types. */ #define ATTR_NOTHROW_LEAF_LIST (ECF_NOTHROW | ECF_LEAF) +#define ATTR_NOTHROW_LEAF_MALLOC_LIST (ECF_NOTHROW | ECF_LEAF | ECF_MALLOC) #define ATTR_CONST_NOTHROW_LEAF_LIST (ECF_NOTHROW | ECF_LEAF | ECF_CONST) #define ATTR_NOTHROW_LIST (ECF_NOTHROW) #define ATTR_CONST_NOTHROW_LIST (ECF_NOTHROW | ECF_CONST) +#define ATTR_CONST_NORETURN_NOTHROW_LEAF_LIST (ECF_CONST | ECF_NOTHROW | ECF_LEAF | ECF_NORETURN) static void gfc_define_builtin (const char *name, tree type, enum built_in_function code, @@ -547,13 +550,7 @@ gfc_define_builtin (const char *name, tr decl = add_builtin_function (name, type, code, BUILT_IN_NORMAL, library_name, NULL_TREE); - if (attr & ECF_CONST) - TREE_READONLY (decl) = 1; - if (attr & ECF_NOTHROW) - TREE_NOTHROW (decl) = 1; - if (attr & ECF_LEAF) - DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("leaf"), - NULL, DECL_ATTRIBUTES (decl)); + set_call_expr_flags (decl, attr); set_builtin_decl (code, decl, true); } @@ -908,6 +905,11 @@ gfc_init_builtin_functions (void) gfc_define_builtin ("__builtin_expect", ftype, BUILT_IN_EXPECT, "__builtin_expect", ATTR_CONST_NOTHROW_LEAF_LIST); + ftype = build_function_type_list (void_type_node, NULL_TREE); + + gfc_define_builtin ("__builtin_unreachable", ftype, BUILT_IN_UNREACHABLE, + "__builtin_unreachable", ATTR_CONST_NORETURN_NOTHROW_LEAF_LIST); + ftype = build_function_type_list (void_type_node, pvoid_type_node, NULL_TREE); gfc_define_builtin ("__builtin_free", ftype, BUILT_IN_FREE, @@ -916,14 +918,12 @@ gfc_init_builtin_functions (void) ftype = build_function_type_list (pvoid_type_node, size_type_node, NULL_TREE); gfc_define_builtin ("__builtin_malloc", ftype, BUILT_IN_MALLOC, - "malloc", ATTR_NOTHROW_LEAF_LIST); - DECL_IS_MALLOC (builtin_decl_explicit (BUILT_IN_MALLOC)) = 1; + "malloc", ATTR_NOTHROW_LEAF_MALLOC_LIST); ftype = build_function_type_list (pvoid_type_node, size_type_node, size_type_node, NULL_TREE); gfc_define_builtin ("__builtin_calloc", ftype, BUILT_IN_CALLOC, - "calloc", ATTR_NOTHROW_LEAF_LIST); - DECL_IS_MALLOC (builtin_decl_explicit (BUILT_IN_CALLOC)) = 1; + "calloc", ATTR_NOTHROW_LEAF_MALLOC_LIST); ftype = build_function_type_list (pvoid_type_node, size_type_node, pvoid_type_node, Index: calls.c =================================================================== --- calls.c (revision 192483) +++ calls.c (working copy) @@ -802,6 +802,36 @@ call_expr_flags (const_tree t) return flags; } +/* Modify DECL for given flags. */ +void +set_call_expr_flags (tree decl, int flags) +{ + if (flags & ECF_NOTHROW) + TREE_NOTHROW (decl) = 1; + if (flags & ECF_CONST) + TREE_READONLY (decl) = 1; + if (flags & ECF_PURE) + DECL_PURE_P (decl) = 1; + if (flags & ECF_NOVOPS) + DECL_IS_NOVOPS (decl) = 1; + if (flags & ECF_NORETURN) + TREE_THIS_VOLATILE (decl) = 1; + if (flags & ECF_MALLOC) + DECL_IS_MALLOC (decl) = 1; + if (flags & ECF_RETURNS_TWICE) + DECL_IS_RETURNS_TWICE (decl) = 1; + if (flags & ECF_LEAF) + DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("leaf"), + NULL, DECL_ATTRIBUTES (decl)); + if (flags & ECF_TM_PURE) + DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("transaction_pure"), + NULL, DECL_ATTRIBUTES (decl)); + /* Looping const or pure is imlpies by noreturn. + There is currently no way to declare looping const or looping pure alone. */ + gcc_assert (!(flags & ECF_LOOPING_CONST_OR_PURE) + || ((flags & ECF_NORETURN) && (flags & (ECF_CONST | ECF_PURE)))); +} + /* Precompute all register parameters as described by ARGS, storing values into fields within the ARGS array. Index: tree.h =================================================================== --- tree.h (revision 192483) +++ tree.h (working copy) @@ -6025,6 +6025,7 @@ extern tree build_duplicate_type (tree); extern int flags_from_decl_or_type (const_tree); extern int call_expr_flags (const_tree); +extern void set_call_expr_flags (tree, int); /* Call argument flags. */