From patchwork Sun Nov 13 22:31:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 81980 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp755834qge; Sun, 13 Nov 2016 14:31:32 -0800 (PST) X-Received: by 10.99.4.213 with SMTP id 204mr63770861pge.77.1479076292680; Sun, 13 Nov 2016 14:31:32 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g191si19839516pgc.78.2016.11.13.14.31.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Nov 2016 14:31:32 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-441268-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-441268-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-441268-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=uyzYzG6/Y1QmDXwC DGsclYfHrb06Ot+bOCwqeCLCzXiM1aDJZg6pzGa0OyBKYllIeuaHacfJpmHPjnqA 1d088ez8T/0aKTb3ZTyKKpBAj37u0GGwqLRW49oxT2ruq6jez6L1UqWySXFOYpcQ R8SZptJq77iLAjCvFpsX7p2febQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=nQ+aPqY2Bzvt0MdTlvhhp3 ztW5Q=; b=VM4CH+Ko2AVqdAQxEbWAT09sJuOg7kKAbQyz7o9RCb1S5tGsivwzah zOut4l2rpabxUyUmxCvHBmKGl+SCjn41gMRUr+9ElNNWcU7A6ezSsKR/moj/sgvh lDsYZQq21fC6bcjSPCR+0f1hCliwtxNAkdHyHDWdtIRFtP7tXC7CY= Received: (qmail 21024 invoked by alias); 13 Nov 2016 22:31:17 -0000 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 Received: (qmail 20984 invoked by uid 89); 13 Nov 2016 22:31:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=cum X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 13 Nov 2016 22:31:05 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 8196E812EB for ; Sun, 13 Nov 2016 23:31:03 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xiytJ7hyJJmf for ; Sun, 13 Nov 2016 23:31:03 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 5B7FB812DD for ; Sun, 13 Nov 2016 23:31:03 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [ARM] Enable descriptors for nested functions in Ada Date: Sun, 13 Nov 2016 23:31:02 +0100 Message-ID: <1669782.vfRejaKWdb@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-48-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 Similarly to x86, PowerPC and SPARC, this enables the use of custom run-time descriptors in Ada, thus eliminating the need for trampolines and executable stack in presence of pointers to nested functions. This still uses bit 1 for the run-time identification scheme because bumping the function alignment to 64 bits seems undesirable in Thumb mode. Tested on ARM/Linux, OK for the mainline? 2016-11-13 Eric Botcazou PR ada/67205 * config/arm/arm.c (TARGET_CUSTOM_FUNCTION_DESCRIPTORS): Define. (arm_function_ok_for_sibcall): Return false for an indirect call by descriptor if all the argument registers are used. (arm_relayout_function): Use FUNCTION_ALIGNMENT macro to adjust the alignment of the function. -- Eric Botcazou Index: config/arm/arm.c =================================================================== --- config/arm/arm.c (revision 242334) +++ config/arm/arm.c (working copy) @@ -738,6 +738,11 @@ static const struct attribute_spec arm_a #undef TARGET_EXPAND_DIVMOD_LIBFUNC #define TARGET_EXPAND_DIVMOD_LIBFUNC arm_expand_divmod_libfunc +/* Although the architecture reserves bits 0 and 1, only the former is + used for ARM/Thumb ISA selection in v7 and earlier versions. */ +#undef TARGET_CUSTOM_FUNCTION_DESCRIPTORS +#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 2 + struct gcc_target targetm = TARGET_INITIALIZER; /* Obstack for minipool constant handling. */ @@ -6810,6 +6815,29 @@ arm_function_ok_for_sibcall (tree decl, && DECL_WEAK (decl)) return false; + /* We cannot do a tailcall for an indirect call by descriptor if all the + argument registers are used because the only register left to load the + address is IP and it will already contain the static chain. */ + if (!decl && CALL_EXPR_BY_DESCRIPTOR (exp) && !flag_trampolines) + { + tree fntype = TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (exp))); + CUMULATIVE_ARGS cum; + cumulative_args_t cum_v; + + arm_init_cumulative_args (&cum, fntype, NULL_RTX, NULL_TREE); + cum_v = pack_cumulative_args (&cum); + + for (tree t = TYPE_ARG_TYPES (fntype); t; t = TREE_CHAIN (t)) + { + tree type = TREE_VALUE (t); + if (!VOID_TYPE_P (type)) + arm_function_arg_advance (cum_v, TYPE_MODE (type), type, true); + } + + if (!arm_function_arg (cum_v, SImode, integer_type_node, true)) + return false; + } + /* Everything else is ok. */ return true; } @@ -29101,7 +29129,9 @@ arm_relayout_function (tree fndecl) callee_tree = target_option_default_node; struct cl_target_option *opts = TREE_TARGET_OPTION (callee_tree); - SET_DECL_ALIGN (fndecl, FUNCTION_BOUNDARY_P (opts->x_target_flags)); + SET_DECL_ALIGN + (fndecl, + FUNCTION_ALIGNMENT (FUNCTION_BOUNDARY_P (opts->x_target_flags))); } /* Inner function to process the attribute((target(...))), take an argument and