comp.lang.ada
 help / color / mirror / Atom feed
* Specifying parameter passing convention and place (register)
@ 2004-07-05 23:25 Nick Roberts
  2004-07-06 12:58 ` Larry Kilgallen
  2004-07-09 21:29 ` Keith Thompson
  0 siblings, 2 replies; 16+ messages in thread
From: Nick Roberts @ 2004-07-05 23:25 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2004-07-09 21:50 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-05 23:25 Specifying parameter passing convention and place (register) Nick Roberts
2004-07-06 12:58 ` Larry Kilgallen
2004-07-06 17:30   ` Nick Roberts
2004-07-07  4:14     ` Larry Kilgallen
2004-07-07 13:13       ` Nick Roberts
2004-07-07 18:54         ` Larry Kilgallen
2004-07-07 21:01           ` Nick Roberts
2004-07-08 12:06             ` Larry Kilgallen
2004-07-08 15:29               ` Nick Roberts
2004-07-08 14:09             ` Bob Spooner
2004-07-08 18:10               ` Nick Roberts
2004-07-08 12:27           ` Georg Bauhaus
2004-07-08 15:38             ` Larry Kilgallen
2004-07-08 18:03               ` Georg Bauhaus
2004-07-09 21:29 ` Keith Thompson
2004-07-09 21:50   ` Nick Roberts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox