gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing parameters of type 'ARRAY[0..MAXINDEX] OF ElementType' to C


From: Gaius Mulley
Subject: Re: Passing parameters of type 'ARRAY[0..MAXINDEX] OF ElementType' to C
Date: Tue, 30 Jan 2024 15:18:36 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

Benjamin Kowarsch <trijezdci@gmail.com> writes:

> On Tue, 30 Jan 2024 at 22:55, Gaius Mulley wrote:
>
>  > void p ( char str[], unsigned argc );
>
>  just to confirm the prototype above is correct for gm2 (for both VAR and
>  non VAR open array parameters)
>
> Gaius, how do you handle write access to a non-VAR open array parameter?
>

Hi Benjamin,

> Do you copy the array into temporary local storage into the local
> variable section on the stack and put a pointer to that into the
> contents field of the unbounded record,

yes it uses callee save (via alloca).

In gcc/m2/gm2-compiler/M2GenGCC.mod:1808

When creating the procedure prologue it checks whether the non var open
arrays must be saved:

   (* callee saves non var unbounded parameter contents *)
   SaveNonVarUnboundedParameters (tokenno, CurrentProcedure) ;

and eventually calls MakeCopyUse (which in turn performs alloca,
memcpy and assignment of the new pointer).  It performs compile time
(and runtime) checking to see whether this is necessary

regards,
Gaius

> or do you forbid write access
> altogether?
>
> regards
> benjamin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]