From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,46a68619f4362304,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Specifying parameter passing convention and place (register) Date: Tue, 06 Jul 2004 00:25:28 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de HIMLq5NSZNtuzlefyaVQYwwYGKr7TUkb0h5JU8ylHdPM2OAXo= User-Agent: Opera M2/7.51 (Win32, build 3798) Xref: g2news1.google.com comp.lang.ada:2072 Date: 2004-07-06T00:25:28+01:00 List-Id: What form should a pragma take for specifying the convention and place (register or in memory) for the passing of parameters into and out of subprograms? Should these pragmas be confined to machine code insertions, or some other group of subprograms, or it be permitted for all subprograms? Where should the pragma be placed? Should it be inside the subprogram body, so that the subprogram itself is implicit and does not need to be identified, or should it be in the same specification as the declaration of the subprogram, or somewhere else? One possible problem with placing it in the specification is how to reference a specific subprogram that is one of several overloadings. A different possible approach is the use of representation attributes on subtypes. The GNAT attribute Passed_By_Reference could be used to specify whether a parameter of the subtype is passed by reference or by copy (value). An attribute such as Passing_Place could be a value of an enumeration such as, for example: type Parameter_Passing_Place is ( Default, Stack, AL, AH, DL, DH, CL, CH, BL, BH, AX, DX, CX, BX, SI, DI, BP, SP, EAX, EDX, ECX, EBX, ESI, EDI, EBP, ESP, ST_0, ST_1, ..., ST_7, EDX_EAX, ECX_EBX, ES, FS, GS, ES_EAX, FS_EDX, GS_ECX ); This way, I can declare, for example: subtype Integer_Passed_In_EAX is Integer; for Integer_Passed_By_EAX'Passing_Place use EAX; and then I can declare a function: function Wibble (N: in Integer_Passed_In_EAX) return Integer_Passed_In_EAX; in order to specify that the parameter N and the function are both to be passed in the register EAX. I might declare: subtype Integer_Passed_On_Stack is Integer; for Integer_Passed_On_Stack'Passing_Place use Stack; for Integer_Passed_On_Stack'Stack_Offset use -8; in order to specify that a parameter is to be passed on the stack, and exactly where in the stack it is placed (relative to the stack frame pointer, EBP in the case of the IA-32). I would be grateful for insights and opinions. -- Nick Roberts