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

* Re: Specifying parameter passing convention and place (register)
  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-09 21:29 ` Keith Thompson
  1 sibling, 1 reply; 16+ messages in thread
From: Larry Kilgallen @ 2004-07-06 12:58 UTC (permalink / raw)


In article <opsaot0qmdp4pfvb@bram-2>, "Nick Roberts" <nick.roberts@acm.org> writes:
> 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?

I would think only for non-Ada linkages (incoming and outgoing).

> 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?

GNAT has (reportedly) implemented the DEC Ada mechanism for doing this.
Why not use that ?   Unless you find a particular defect in that design,
commonality is good.



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

* Re: Specifying parameter passing convention and place (register)
  2004-07-06 12:58 ` Larry Kilgallen
@ 2004-07-06 17:30   ` Nick Roberts
  2004-07-07  4:14     ` Larry Kilgallen
  0 siblings, 1 reply; 16+ messages in thread
From: Nick Roberts @ 2004-07-06 17:30 UTC (permalink / raw)


On 6 Jul 2004 07:58:55 -0500, Larry Kilgallen <Kilgallen@SpamCop.net>  
wrote:

> GNAT has (reportedly) implemented the DEC Ada mechanism for doing
> this. Why not use that ?   Unless you find a particular defect in
> that design, commonality is good.

Where would I find the documentation for this, please? I have sought but  
not found.

Would I be right in thinking that, sadly, DEC Ada is now nearly as dead as  
the Dodo? If so, there isn't doesn't really seem to be any reason for me  
to use the DEC Ada mechanism, other than perhaps that it is well-designed  
in general and a good model to copy.

GNAT on any other platform (than VMS) uses the GCC way of inlining machine  
code, which I am certainly not going to replicate.

-- 
Thanks,
Nick Roberts



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

* Re: Specifying parameter passing convention and place (register)
  2004-07-06 17:30   ` Nick Roberts
@ 2004-07-07  4:14     ` Larry Kilgallen
  2004-07-07 13:13       ` Nick Roberts
  0 siblings, 1 reply; 16+ messages in thread
From: Larry Kilgallen @ 2004-07-07  4:14 UTC (permalink / raw)


In article <opsap78nn4p4pfvb@bram-2>, "Nick Roberts" <nick.roberts@acm.org> writes:
> On 6 Jul 2004 07:58:55 -0500, Larry Kilgallen <Kilgallen@SpamCop.net>  
> wrote:
> 
>> GNAT has (reportedly) implemented the DEC Ada mechanism for doing
>> this. Why not use that ?   Unless you find a particular defect in
>> that design, commonality is good.
> 
> Where would I find the documentation for this, please? I have sought but  
> not found.

I would presume it is in the GNAT documentation.

> Would I be right in thinking that, sadly, DEC Ada is now nearly as dead as  
> the Dodo? If so, there isn't doesn't really seem to be any reason for me  
> to use the DEC Ada mechanism, other than perhaps that it is well-designed  
> in general and a good model to copy.

I would think the fact that GNAT also implements it would be a good
reason.  DEC Ada is still used on VAX and Alpha, but is not being
ported to the Itanium implementation of VMS.  No new features are
being added, but support is available from HP.  The current name
is either Compaq Ada or HP Ada, depending on how far the renaming
police have gotten.

> GNAT on any other platform (than VMS) uses the GCC way of inlining machine  
> code, which I am certainly not going to replicate.

I was referring to calling other languages, not inlining.



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

* Re: Specifying parameter passing convention and place (register)
  2004-07-07  4:14     ` Larry Kilgallen
@ 2004-07-07 13:13       ` Nick Roberts
  2004-07-07 18:54         ` Larry Kilgallen
  0 siblings, 1 reply; 16+ messages in thread
From: Nick Roberts @ 2004-07-07 13:13 UTC (permalink / raw)


On 6 Jul 2004 23:14:19 -0500, Larry Kilgallen <Kilgallen@SpamCop.net>  
wrote:

>> Where would I find the documentation for this, please? I have
>> sought but not found.
>
> I would presume it is in the GNAT documentation.

Hehe. First place I looked Larry ;-)

Unfortunately, the GNAT documentation simply refers the reader to the DEC  
documentation, and I cannot find the DEC documentation anywhere :-(

> I would think the fact that GNAT also implements it would be
> a good reason.  DEC Ada is still used on VAX and Alpha, but
> is not being ported to the Itanium implementation of VMS.
> No new features are being added, but support is available
> from HP.

But the point is that GNAT only implements it for VMS targets, and it  
doesn't seem that any Ada compiler targetting VMS has much of future.

> The current name is either Compaq Ada or HP Ada, depending
> on how far the renaming police have gotten.

Well, HP say it is now called 'HP Ada'. Can we have that with sauce?

>> GNAT on any other platform (than VMS) uses the GCC way of
>> inlining machine code, which I am certainly not going to
>> replicate.
>
> I was referring to calling other languages, not inlining.

Yes, but machine code insertions and parameter passing mechanisms are  
deeply intertwined. In particular, a (usable) implementation must provide  
a way to access parameters in a machine code insertion. This is typically  
done by means of implementation-specific attributes, and I'd be interested  
in knowing what attributes (and related pragmas) other Ada implementations  
use, and why.

-- 
Thanks again,
Nick Roberts



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

* Re: Specifying parameter passing convention and place (register)
  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:27           ` Georg Bauhaus
  0 siblings, 2 replies; 16+ messages in thread
From: Larry Kilgallen @ 2004-07-07 18:54 UTC (permalink / raw)


In article <opsarq03jtp4pfvb@bram-2>, "Nick Roberts" <nick.roberts@acm.org> writes:
> On 6 Jul 2004 23:14:19 -0500, Larry Kilgallen <Kilgallen@SpamCop.net>  
> wrote:
> 
>>> Where would I find the documentation for this, please? I have
>>> sought but not found.
>>
>> I would presume it is in the GNAT documentation.
> 
> Hehe. First place I looked Larry ;-)

Well, of course GNAT comes with source, right ?   :-)
 
> Unfortunately, the GNAT documentation simply refers the reader to the DEC  
> documentation, and I cannot find the DEC documentation anywhere :-(

The design of the World Wide Web envisioned that URLs would be somewhat
invisible to readers and clicking links would get you there.  I presume
that works if you work your way through the whole web hierarchy to what
you want, but if you want the following shortcut it is somewhat weirdly
named:

	http://h71000.www7.hp.com/commercial/ada/documentation.html

>> I would think the fact that GNAT also implements it would be
>> a good reason.  DEC Ada is still used on VAX and Alpha, but
>> is not being ported to the Itanium implementation of VMS.
>> No new features are being added, but support is available
>> from HP.
> 
> But the point is that GNAT only implements it for VMS targets, and it  
> doesn't seem that any Ada compiler targetting VMS has much of future.

I thought Robert Dewar had stated they were extending the DEC
features to their other platforms.

>>> GNAT on any other platform (than VMS) uses the GCC way of
>>> inlining machine code, which I am certainly not going to
>>> replicate.
>>
>> I was referring to calling other languages, not inlining.
> 
> Yes, but machine code insertions and parameter passing mechanisms are  
> deeply intertwined. In particular, a (usable) implementation must provide  
> a way to access parameters in a machine code insertion. This is typically  
> done by means of implementation-specific attributes, and I'd be interested  
> in knowing what attributes (and related pragmas) other Ada implementations  
> use, and why.

But my answer was based on VAX/DEC/Compaq/HP Ada, where machine code
insertions are not supported.  One writes (and I have written) an
assembler module and links it to the Ada modules.  I don't have
an understanding of the fascination with machine code insertions
on other operating systems.



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

* Re: Specifying parameter passing convention and place (register)
  2004-07-07 18:54         ` Larry Kilgallen
@ 2004-07-07 21:01           ` Nick Roberts
  2004-07-08 12:06             ` Larry Kilgallen
  2004-07-08 14:09             ` Bob Spooner
  2004-07-08 12:27           ` Georg Bauhaus
  1 sibling, 2 replies; 16+ messages in thread
From: Nick Roberts @ 2004-07-07 21:01 UTC (permalink / raw)


On 7 Jul 2004 13:54:01 -0500, Larry Kilgallen <Kilgallen@SpamCop.net>  
wrote:

> Well, of course GNAT comes with source, right ?   :-)

I've looked through the source of the GNAT version that I've got (3.15p),  
specifically the file 'einfo.ads' which purportedly lists all the  
attributes, internal and external, that GNAT uses (to decorate the parse  
tree its sends to GCC or Gigi or whatever it's called). It's a long list,  
but no joy.

> The design of the World Wide Web envisioned that URLs would be
> somewhat invisible to readers and clicking links would get you
> there.  I presume that works if you work your way through the
> whole web hierarchy to what you want,

Well thank Google almighty for search engines. Trawling the entire WWW by  
hand these days would be a Sisyphean job indeed.

> but if you want the following shortcut it is somewhat weirdly
> named:
>
> 	http://h71000.www7.hp.com/commercial/ada/documentation.html

Well that weird link redirects me to another page, which, believe it or  
not, is practically the /second/ place I looked! Unfortunately, although  
this page has links to various bits of Ada documentation, none of that  
documentation has the information I need. I have looked in the LRM listed  
there (a PDF file), which lists the implementation-specific pragmas and  
attributes, but there are neither any pragmas nor any attributes relating  
to parameter passing mechanisms.

Do I take it DEC Ada doesn't, in fact, have any such pragmas or attributes?

> I thought Robert Dewar had stated they were extending the DEC
> features to their other platforms.

I don't know, but it doesn't sound very likely that mechanisms relating to  
VAX/VMS or Alpha/VMS (or VAX/Unix) will be very transferable to other  
architectures/environments.

> But my answer was based on VAX/DEC/Compaq/HP Ada, where machine code
> insertions are not supported.  One writes (and I have written) an
> assembler module and links it to the Ada modules.  I don't have
> an understanding of the fascination with machine code insertions
> on other operating systems.

There's no fascination, as such, on my part. It's just that it's a little  
bit easier to have your Ada and assembly code in one source text file than  
in two. For writing a piece of low-to-the-bone level software (of which  
the AdaOS kernel is surely typical), the proportion of assembly required  
is small (less than 10%), probably less than a hundred lines total. It's  
using a sledgehammer to crack a nut to use a separate assembler, isn't it?

-- 
Nick Roberts



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

* Re: Specifying parameter passing convention and place (register)
  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
  1 sibling, 1 reply; 16+ messages in thread
From: Larry Kilgallen @ 2004-07-08 12:06 UTC (permalink / raw)


In article <opsascnzjtp4pfvb@bram-2>, "Nick Roberts" <nick.roberts@acm.org> writes:
> On 7 Jul 2004 13:54:01 -0500, Larry Kilgallen <Kilgallen@SpamCop.net>  
> wrote:

>> but if you want the following shortcut it is somewhat weirdly
>> named:
>>
>> 	http://h71000.www7.hp.com/commercial/ada/documentation.html
> 
> Well that weird link redirects me to another page, which, believe it or  
> not, is practically the /second/ place I looked! Unfortunately, although  
> this page has links to various bits of Ada documentation, none of that  
> documentation has the information I need. I have looked in the LRM listed  
> there (a PDF file), which lists the implementation-specific pragmas and  
> attributes, but there are neither any pragmas nor any attributes relating  
> to parameter passing mechanisms.

Did you look in section 13.9a of that document ?
In particular, look for the word MECHANISM.

> Do I take it DEC Ada doesn't, in fact, have any such pragmas or attributes?
> 
>> I thought Robert Dewar had stated they were extending the DEC
>> features to their other platforms.
> 
> I don't know, but it doesn't sound very likely that mechanisms relating to  
> VAX/VMS or Alpha/VMS (or VAX/Unix) will be very transferable to other  
> architectures/environments.

Certainly the mechanisms VALUE and REFERENCE are of general use.

The mechanism DESCRIPTOR is only for where a large variety of string
representations are supported on the operating system.  For environments
where data passed between languages will never include bounded strings,
bit strings, non-contiguous arrays, then defaulting to your local form
of DESCRIPTOR for a string starting at offset 1 is adequate.

You could add a mechanism called REGISTER, and if GNAT does this
machine code insertion, I am surprised ACT has not added such a
mechanism.



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

* Re: Specifying parameter passing convention and place (register)
  2004-07-07 18:54         ` Larry Kilgallen
  2004-07-07 21:01           ` Nick Roberts
@ 2004-07-08 12:27           ` Georg Bauhaus
  2004-07-08 15:38             ` Larry Kilgallen
  1 sibling, 1 reply; 16+ messages in thread
From: Georg Bauhaus @ 2004-07-08 12:27 UTC (permalink / raw)


Larry Kilgallen <Kilgallen@spamcop.net> wrote:

:        http://h71000.www7.hp.com/commercial/ada/documentation.html

If you start at

	http://h71000.www7.hp.com/doc/

you find a list of languages on the left, not including Ada though. :-(

Do you happen to know whether there is a VAX or Alpha emulator
that allows running the hobbyist's VMS, that is without bying
another computer? So far I have found CHARON (though not a price
tag yet).


Georg



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

* Re: Specifying parameter passing convention and place (register)
  2004-07-07 21:01           ` Nick Roberts
  2004-07-08 12:06             ` Larry Kilgallen
@ 2004-07-08 14:09             ` Bob Spooner
  2004-07-08 18:10               ` Nick Roberts
  1 sibling, 1 reply; 16+ messages in thread
From: Bob Spooner @ 2004-07-08 14:09 UTC (permalink / raw)


Nick,

If you look at the parameter passing mechanisms available when using
interface pragmas such as Export_Procedure, you may be able to specify what
you want.

Bob

"Nick Roberts" <nick.roberts@acm.org> wrote in message
news:opsascnzjtp4pfvb@bram-2...
> On 7 Jul 2004 13:54:01 -0500, Larry Kilgallen <Kilgallen@SpamCop.net>
> wrote:
> >
> > http://h71000.www7.hp.com/commercial/ada/documentation.html
>
> Well that weird link redirects me to another page, which, believe it or
> not, is practically the /second/ place I looked! Unfortunately, although
> this page has links to various bits of Ada documentation, none of that
> documentation has the information I need. I have looked in the LRM listed
> there (a PDF file), which lists the implementation-specific pragmas and
> attributes, but there are neither any pragmas nor any attributes relating
> to parameter passing mechanisms.
>
> Do I take it DEC Ada doesn't, in fact, have any such pragmas or
attributes?
>





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

* Re: Specifying parameter passing convention and place (register)
  2004-07-08 12:06             ` Larry Kilgallen
@ 2004-07-08 15:29               ` Nick Roberts
  0 siblings, 0 replies; 16+ messages in thread
From: Nick Roberts @ 2004-07-08 15:29 UTC (permalink / raw)


On 8 Jul 2004 07:06:15 -0500, Larry Kilgallen <Kilgallen@SpamCop.net>  
wrote:

> ...
> Did you look in section 13.9a of that document ?
> In particular, look for the word MECHANISM.

Aha! Eureka. Sort of.

> Certainly the mechanisms VALUE and REFERENCE are of general use.

Yes indeed, but they say nothing of the passing 'place' (specific  
register, or location in the stack frame, or wherever).

> The mechanism DESCRIPTOR is only for where a large variety of string
> representations are supported on the operating system.  For environments
> where data passed between languages will never include bounded strings,
> bit strings, non-contiguous arrays, then defaulting to your local form
> of DESCRIPTOR for a string starting at offset 1 is adequate.

As far as I'm concerned, the programmer must either specify or discover  
the actual format (in memory) of such parameters, and program (external or  
assembly) accordingly. In almost all cases, the type will be de facto be  
passed by reference, and so the passing place will (to my mind) be the  
place where the address is passed.

> You could add a mechanism called REGISTER,

It noe occurs to me that that would be confusing issues slightly, since a  
mechanism can be by-copy or by-reference, and in either case it can also  
be in-a-register or on-the-stack (or conceivably some other place).

> and if GNAT does this machine code insertion, I am surprised ACT
> has not added such a mechanism.

GNAT uses the GCC inline assembly syntax, which is transferred from GNU C,  
and rather unAdalike. I don't want to replicate it (it would actually be a  
lot of extra work to do so).

I'm very grateful for your help, Larry. All in all, however, I think I  
need something different to suit my own needs.

I think I will have two pragmas:

    pragma Parameter_Mechanism (
       [ENTITY    =>] callable_entity_simple_name,
       [PARAMETER =>] parameter_simple_name [,
       [MECHANISM =>] passing_mechanism] [,
       [PLACE     =>] passing_place] );

    pragma Return_Mechanism (
       [ENTITY    =>] callable_entity_simple_name,
       [MECHANISM =>] passing_mechanism] [,
       [PLACE     =>] passing_place] );

    passing_mechanism ::= BY_COPY | BY_REFERENCE

    passing_place ::= qualified_expression

The callable_entity_simple_name identifies the subprogram or entry. The  
pragma applies to the entity designated (regardless of the name), so  
renamings can be used to isolate one of a set of overloadings.

The qualified expression of a passing place must be of a subtype declared  
in System.Calling. For the IA-32, we might have the following declarations  
in this package:

    type Register_8  is ( AL,  CL,  DL,  BL,  AH,  CH,  DH,  BH); --  8-bit
    type Register_16 is ( AX,  CX,  DX,  BX,  SP,  BP,  SI,  DI); -- 16-bit
    type Register_32 is (EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI); -- 32-bit
    type Segment_Register is (ES, CS, SS, DS, FS, GS); -- 16-bit

    type Register_64 is
       record
          Upper, Lower: Register_32;
       end record;

    subtype Frame_Offset is Storage_Elements.Storage_Offset;
    -- Parameter or return value is to be located relative to the stack  
frame
    -- pointer (EBP) for a subprogram, or the beginning of the shared data  
area,
    -- for an entry.

In reality these would all be subtypes renaming types declared in another  
package.

Any obvious flaws?

-- 
Nick Roberts



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

* Re: Specifying parameter passing convention and place (register)
  2004-07-08 12:27           ` Georg Bauhaus
@ 2004-07-08 15:38             ` Larry Kilgallen
  2004-07-08 18:03               ` Georg Bauhaus
  0 siblings, 1 reply; 16+ messages in thread
From: Larry Kilgallen @ 2004-07-08 15:38 UTC (permalink / raw)


In article <ccjej3$n5v$1@a1-hrz.uni-duisburg.de>, Georg Bauhaus <sb463ba@l1-hrz.uni-duisburg.de> writes:

> Do you happen to know whether there is a VAX or Alpha emulator
> that allows running the hobbyist's VMS, that is without bying
> another computer? So far I have found CHARON (though not a price
> tag yet).

There are also no-cost emulators available.

Google comp.os.vms for the names and sources I do not know.



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

* Re: Specifying parameter passing convention and place (register)
  2004-07-08 15:38             ` Larry Kilgallen
@ 2004-07-08 18:03               ` Georg Bauhaus
  0 siblings, 0 replies; 16+ messages in thread
From: Georg Bauhaus @ 2004-07-08 18:03 UTC (permalink / raw)


Larry Kilgallen <Kilgallen@spamcop.net> wrote:
:> Do you happen to know whether there is a VAX or Alpha emulator
:> that allows running the hobbyist's VMS, that is without bying
:> another computer? So far I have found CHARON (though not a price
:> tag yet).
: 
: There are also no-cost emulators available.

Looks promising. Thanks



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

* Re: Specifying parameter passing convention and place (register)
  2004-07-08 14:09             ` Bob Spooner
@ 2004-07-08 18:10               ` Nick Roberts
  0 siblings, 0 replies; 16+ messages in thread
From: Nick Roberts @ 2004-07-08 18:10 UTC (permalink / raw)


On Thu, 8 Jul 2004 10:09:06 -0400, Bob Spooner <rls19@psu.edu> wrote:

> Nick,
>
> If you look at the parameter passing mechanisms available when using
> interface pragmas such as Export_Procedure, you may be able to specify  
> what
> you want.

Thanks Bob, but the options there don't seem to allow specification of the  
'place' (register or location in the stack frame) to pass a parameter (or  
return result). I outlined a couple of pragmas I might use in a sibling  
message in this thread.

-- 
Nick Roberts



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

* Re: Specifying parameter passing convention and place (register)
  2004-07-05 23:25 Specifying parameter passing convention and place (register) Nick Roberts
  2004-07-06 12:58 ` Larry Kilgallen
@ 2004-07-09 21:29 ` Keith Thompson
  2004-07-09 21:50   ` Nick Roberts
  1 sibling, 1 reply; 16+ messages in thread
From: Keith Thompson @ 2004-07-09 21:29 UTC (permalink / raw)


"Nick Roberts" <nick.roberts@acm.org> writes:
> 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?
[...]
> 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.
[...]

It seems counterintuitive to associate the parameter passing method
with a subtype rather than with a formal parameter.

What about something like this?

    function Wibble (N: in Integer);
    for Wibble'Parameter_Passing use ( N => EAX );

Adjust names and syntax to taste.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.



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

* Re: Specifying parameter passing convention and place (register)
  2004-07-09 21:29 ` Keith Thompson
@ 2004-07-09 21:50   ` Nick Roberts
  0 siblings, 0 replies; 16+ messages in thread
From: Nick Roberts @ 2004-07-09 21:50 UTC (permalink / raw)


On Fri, 09 Jul 2004 21:29:08 GMT, Keith Thompson <kst-u@mib.org> wrote:

> ...
> It seems counterintuitive to associate the parameter
> passing method with a subtype rather than with a formal
> parameter.
>
> What about something like this?
>
>     function Wibble (N: in Integer);
>     for Wibble'Parameter_Passing use ( N => EAX );
>
> Adjust names and syntax to taste.

I agree, and I've outlined a scheme in another post in this thread.

-- 
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