[M3devel] thoughts on NT386/LONGINT?

Tony Hosking hosking at cs.purdue.edu
Sun Jan 24 10:25:07 CET 2010


Yes, I meant the machine stack for LONGINT values.  Regs only for INTEGER.

Antony Hosking | Associate Professor | Computer Science | Purdue University
305 N. University Street | West Lafayette | IN 47907 | USA
Office +1 765 494 6001 | Mobile +1 765 427 5484




On 23 Jan 2010, at 10:31, Jay K wrote:

>  > You might easily just push/pop operands and return values on the stack
> 
> I don't think I understood you.
> My "worst case" was to store everything in temporaries.
> But I think I see now.
> Some sort of stack is required.
> There is the "virtual stack" already in use. (I assume "v" = "virtual").
>    It should already handle constant folding, but its register manipulation isn't right for 64bit values.
> I think what I see now -- just use the machine stack.
> Even to push immediate values.
> And, to be really lame, most/all operations can be function calls.
>  And not even in the "normal" way, but like:
> 
> 
> #ifdef _WIN32
> 
> 
> void __stdcall m3_add64(__int64 a)
> {
>     (&a)[1] += a;
> }
> 
> 
> void __cdecl m3_neg64(__int64 a)
> {
>     a = -a;
> }
> 
> 
> where we convince the C compiler to do the right stack maintenance.
> We'd just generate parameter-less calls.
> For actually passing longint parameters to real Modula-3 functions,
> I'd have to look, but, like, pop_param would do nothing.
> 
> 
>  - Jay
> 
> 
> From: jay.krell at cornell.edu
> To: hosking at cs.purdue.edu
> CC: m3devel at elegosoft.com
> Subject: RE: [M3devel] thoughts on NT386/LONGINT?
> Date: Fri, 22 Jan 2010 22:53:41 +0000
> 
> I'll see what I can figure out.
> 
> 
> I considered pushings pairs of operands in m3x86.m3 but I think
> that won't work.
> 
> 
> Noticing how integer vs. floating point is handled
> is perhaps useful, as this is another way in which m3cg
> is "homogenous" but backends have to act differently
> based on type.
> 
> 
>  - Jay
> 
> 
> 
> From: hosking at cs.purdue.edu
> Date: Fri, 22 Jan 2010 09:49:28 -0500
> To: jay.krell at cornell.edu
> CC: m3devel at elegosoft.com
> Subject: Re: [M3devel] thoughts on NT386/LONGINT?
> 
> That's a very good question.  I suspect allocating register pairs as needed would make for a fairly difficult implementation.  I would err on the side of simplicity for LONGINT code generation rather than complexity.  You might easily just push/pop operands and return values on the stack, on the grounds that modern x86 hardware will do a good job renaming stack locations to registers.  i.e., worry about correctness first and performance later.
> 
> On 22 Jan 2010, at 07:39, Jay K wrote:
> 
> Anyone have any thoughts on how to implement LONGINT on NT386?
>  
> 
> The code is setup to do pretty good constant folding and enregistration.
>  
> 
> I did the work so that constant folding should work for LONGINT.
>  
> 
> However I think doing good enregistration is maybe still
> too much work. In particular, I think every LONGINT
> operation will do a load, operation, store.
> Typical of unoptimized code, but not typical
> of the Modula-3/NT386 quality.
> 
>  
> In particular, there is still this notion of an "operand"
> that might be held in one register.
> 
>  
> I'd have to make it a register pair, or array of registers,
> or invent "psuedo registers" that are register pairs.
> An array of registers is the obvious best choice, but
> none of these are a small change.
>  
> 
> 96 occurences of "reg" in Stackx86.m3, 58 in M3x86.m3,
> would probably all have to change.
> 63 in Codex86.m3 unsure.
>  It is the lowest level and might need to only deal with single
>   registers.
> 
>  
> Returning LONGINT from a function also needs separate attention.
> Maybe I really should go ahead and use an array of registers?
>  
> 
>  - Jay
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100124/4a9b00f9/attachment-0002.html>


More information about the M3devel mailing list