From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id 14DEB3857C70; Wed, 6 Jul 2022 13:31:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 14DEB3857C70 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Pierre-Marie de Rodat To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1532] [Ada] Document the various function return mechanisms X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/master X-Git-Oldrev: e5802d60130bd804663559471f9c5f3561dfab4d X-Git-Newrev: cd7d1f448a4a826a4210121ed6bec989913ba4e7 Message-Id: <20220706133123.14DEB3857C70@sourceware.org> Date: Wed, 6 Jul 2022 13:31:23 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jul 2022 13:31:23 -0000 https://gcc.gnu.org/g:cd7d1f448a4a826a4210121ed6bec989913ba4e7 commit r13-1532-gcd7d1f448a4a826a4210121ed6bec989913ba4e7 Author: Eric Botcazou Date: Thu Jun 16 13:22:18 2022 +0200 [Ada] Document the various function return mechanisms gcc/ada/ * exp_ch6.adb (Function return mechanisms): New paragraph. Diff: --- gcc/ada/exp_ch6.adb | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index b5764ad12e1..bf51e64c463 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -83,7 +83,48 @@ with Validsw; use Validsw; package body Exp_Ch6 is - -- Suffix for BIP formals + -------------------------------- + -- Function return mechanisms -- + -------------------------------- + + -- This is a summary of the various function return mechanisms implemented + -- in GNAT for Ada 2005 and later versions of the language. In the below + -- table, the first column must be read as an if expression: if the result + -- type of the function is limited, then the return mechanism is and ...; + -- elsif the result type is indefinite or large definite, then ...; elsif + -- ...; else ... The different mechanisms are implemented either in the + -- front end, or in the back end, or partly in both ends, depending on the + -- result type. + + -- Result type | Return mechanism | Front end | Back end + -- -------------------------------------------------------------------- + + -- Limited Build In Place All + + -- Indefinite/ Secondary Stack Needs Fin. Others + -- Large definite + + -- Needs Fin. Secondary Stack All + -- (BERS False) + + -- Needs Fin. Invisible Parameter All All + -- (BERS True) (return) (call) + + -- By Reference Invisible Parameter All + + -- Others Primary stack/ All + -- Registers + + -- Needs Fin.: type needs finalization [RM 7.6(9.1/2-9.6/2)] + -- BERS: Opt.Back_End_Return_Slot setting + + -- The table is valid for all calls except for those dispatching on result; + -- the latter calls are considered as returning a class-wide type and thus + -- always return on the secondary stack, with the help of a small wrapper + -- function (thunk) if the original result type is not itself returned on + -- the secondary stack as per the above table. + + -- Suffixes for Build-In-Place extra formals BIP_Alloc_Suffix : constant String := "BIPalloc"; BIP_Storage_Pool_Suffix : constant String := "BIPstoragepool";