[mercury-users] 64-bit ints on 32-bit platforms

Michael Day mikeday at yeslogic.com
Fri Oct 16 16:59:21 AEDT 2009


Hi Zoltan,

> Yes. By definition, unboxed values are stored (amongst other places)
> in machine registers, and on 32 bit machines, those are (again by definition)
> 32 bits in size.

In C it is possible to write a function like this:

int64_t foo(int64_t x)
{
     return x + 1;
}

and compile it with gcc for a 32-bit architecture, and it will 
transparently use two 32-bit registers for the return value:

foo:
         movl    4(%esp), %eax
         movl    8(%esp), %edx
         addl    $1, %eax
         adcl    $0, %edx
         ret

Presumably the equivalent function in Mercury would need to allocate 8 
bytes to store the result value and return the pointer to it, which 
seems like it could be costly if lots of arithmetic was being done.

Cheers,

Michael

-- 
Print XML with Prince!
http://www.princexml.com
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list