From patchwork Fri Oct 11 14:39:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1175247 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-510761-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="tqKCBgNU"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46qVwY55FPz9sNx for ; Sat, 12 Oct 2019 01:39:57 +1100 (AEDT) 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; q=dns; s= default; b=gnuie5ry3Q4WigEK4Fg2p/gCHc1taa2nwUGyRLg3N1zjFCFznZ4Xv xRRS/wnDFJLFxHvDhB0bAyxyM5WKW06nhdy4csHbGv3XjtLIgUVHzwy/wz5HI6eO HxG9lvXqzrUaU/ust/6JPAZqgHjM2YIxD1kJIji+VsSwCYQD+bshc4= 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; s= default; bh=a5bavILeYEfV2+g/EjoctDlO2F4=; b=tqKCBgNUGNl2caL0JTO2 VOBQkx2wfedWdmTX2r5gmGmblSzXvF6Gk0T0jCuKRhJpkhKCU8PdtXLxXOw/JIjj rXxlOH4Asr8+XUHC4hUGY7Hv13l4LummkjQMWWELLZNNOisZCWRUtUlnAU/CoQHm +RgzjjqJdbjkSPeaADKhJII= Received: (qmail 17838 invoked by alias); 11 Oct 2019 14:39:50 -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 17830 invoked by uid 89); 11 Oct 2019 14:39:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Oct 2019 14:39:49 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AB4FA142F for ; Fri, 11 Oct 2019 07:39:47 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 537C73F68E for ; Fri, 11 Oct 2019 07:39:47 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Add expr_callee_abi Date: Fri, 11 Oct 2019 15:39:46 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes This turned out to be useful for the SVE PCS support, and is a natural tree-level analogue of insn_callee_abi. Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install? Richard 2019-10-11 Richard Sandiford gcc/ * function-abi.h (expr_callee_abi): Declare. * function-abi.cc (expr_callee_abi): New function. Index: gcc/function-abi.h =================================================================== --- gcc/function-abi.h 2019-09-30 17:39:33.514597856 +0100 +++ gcc/function-abi.h 2019-10-11 15:38:54.141605718 +0100 @@ -315,5 +315,6 @@ call_clobbered_in_region_p (unsigned int extern const predefined_function_abi &fntype_abi (const_tree); extern function_abi fndecl_abi (const_tree); extern function_abi insn_callee_abi (const rtx_insn *); +extern function_abi expr_callee_abi (const_tree); #endif Index: gcc/function-abi.cc =================================================================== --- gcc/function-abi.cc 2019-09-30 17:39:33.514597856 +0100 +++ gcc/function-abi.cc 2019-10-11 15:38:54.141605718 +0100 @@ -229,3 +229,32 @@ insn_callee_abi (const rtx_insn *insn) return default_function_abi; } + +/* Return the ABI of the function called by CALL_EXPR EXP. Return the + default ABI for erroneous calls. */ + +function_abi +expr_callee_abi (const_tree exp) +{ + gcc_assert (TREE_CODE (exp) == CALL_EXPR); + + if (tree fndecl = get_callee_fndecl (exp)) + return fndecl_abi (fndecl); + + tree callee = CALL_EXPR_FN (exp); + if (callee == error_mark_node) + return default_function_abi; + + tree type = TREE_TYPE (callee); + if (type == error_mark_node) + return default_function_abi; + + if (POINTER_TYPE_P (type)) + { + type = TREE_TYPE (type); + if (type == error_mark_node) + return default_function_abi; + } + + return fntype_abi (type); +}