Re: [patch] add x32 support

2013-01-14 Thread Mike Frysinger
On Monday 14 January 2013 14:36:43 Torbjorn Granlund wrote:
> At some point, we'd like to make the assembly code in GMP support x32.

how so ?  for the most part, existing x86_64 assembly should "just work" for 
x32.  pointers tend to be where things get into trouble, but otherwise x32 is 
simply x86_64 with different sizeof(long) & sizeof(void*).  64bit types work 
just fine and with the same performance as in x86_64 -- no ugliness like 32bit 
x86.

`make check` passes for me w/gmp in x32.  so at least something is working.
-mike


signature.asc
Description: This is a digitally signed message part.
___
gmp-devel mailing list
gmp-devel@gmplib.org
http://gmplib.org/mailman/listinfo/gmp-devel


Re: [patch] add x32 support

2013-01-14 Thread Torbjorn Granlund
Richard Henderson  writes:

  On 01/10/2013 12:46 PM, Torbjorn Granlund wrote:
  > (I wonder if this can become a robust ABI with current hardware, unless
  > we pay a major performance price.  It seems like address arithmetic by
  > means of hardware indexing, lea, etc, will be 64-bits, while we want to
  > compute mod 2^32.)
  
  The addr32 prefix takes care of this.
  
Can you please explain a bit about how that works?

Using

insn(%rX), reg

gives me no addr32 prefix, but

insn(%eX), reg

does indeed.  Is that register syntax change the standard way of
handling this?

For assembly code that needs to support both the 64-bit ABI ans x32, it
might be more convenient to conditionally put an explicit ".byte 0x67"
at the preceding line.  Apparently gas also accept "addr32" but then
prints "Warning: stand-alone `addr32' prefix".

An optimisation is to use a 64-bit expresson if one knows that the
expresson >= 0 and < 2^32.  Correct?

So that saves a byte.  Do you know if there are other costs, i.e.,
decoding or execution costs associated to addr32?  (OK, insn aligment vs
cache lines matters, and might cause addr32 to either slow down or speed
up exeuction.)

At some point, we'd like to make the assembly code in GMP support x32.
I think it should already be fine, without any addr32 prefixing, but I
am not sure.  For most reasonable indexing, I'd say that one should not
magically end up with a non-canonical address.

Do you agree?

-- 
Torbjörn
___
gmp-devel mailing list
gmp-devel@gmplib.org
http://gmplib.org/mailman/listinfo/gmp-devel


Re: [patch] add x32 support

2013-01-10 Thread Richard Henderson

On 01/10/2013 12:46 PM, Torbjorn Granlund wrote:

(I wonder if this can become a robust ABI with current hardware, unless
we pay a major performance price.  It seems like address arithmetic by
means of hardware indexing, lea, etc, will be 64-bits, while we want to
compute mod 2^32.)


The addr32 prefix takes care of this.


r~
___
gmp-devel mailing list
gmp-devel@gmplib.org
http://gmplib.org/mailman/listinfo/gmp-devel


Re: [patch] add x32 support

2013-01-10 Thread Mike Frysinger
On Thursday 10 January 2013 15:46:55 Torbjorn Granlund wrote:
> I was mainly concerned about your statement that "the x32 ABI slipped
> through the cracks".  I cannot find any prior communications about this.

i was referring to the people who wrote the first patch which i've seen 
rebased/semi-rewritten rather than the gmp peeps missing it.  i don't think it 
has been submitted yet.

> How could I test this?

do you have an x86_64 processor and running linux-3.4+ ?  the fastest answer 
is to enable x32 support in your kernel config (CONFIG_X86_X32) and then use a 
Gentoo chroot:
http://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3/

unpack that into a dir, chroot into it, then you'll have a multilib setup with 
x32 as the default ABI.

if you have any troubles, feel free to ask and i'll see what's what.
-mike


signature.asc
Description: This is a digitally signed message part.
___
gmp-devel mailing list
gmp-devel@gmplib.org
http://gmplib.org/mailman/listinfo/gmp-devel


Re: [patch] add x32 support

2013-01-10 Thread Marc Glisse

On Thu, 10 Jan 2013, Marc Glisse wrote:


On Thu, 10 Jan 2013, Torbjorn Granlund wrote:


How could I test this?


I don't remember what linux you have access to. Debian for instance has 
packages in "experimental" named libx32gcc1, libc6-x32, etc. Then you just 
need to compile with gcc -mx32.


Hmm, it also requires installing a kernel compiled with a different 
option, etc, so scratch that, sorry :-(


--
Marc Glisse
___
gmp-devel mailing list
gmp-devel@gmplib.org
http://gmplib.org/mailman/listinfo/gmp-devel


Re: [patch] add x32 support

2013-01-10 Thread Marc Glisse

On Thu, 10 Jan 2013, Torbjorn Granlund wrote:


How could I test this?


I don't remember what linux you have access to. Debian for instance has 
packages in "experimental" named libx32gcc1, libc6-x32, etc. Then you just 
need to compile with gcc -mx32.


--
Marc Glisse
___
gmp-devel mailing list
gmp-devel@gmplib.org
http://gmplib.org/mailman/listinfo/gmp-devel


Re: [patch] add x32 support

2013-01-10 Thread Torbjorn Granlund
Mike Frysinger  writes:

  On Thursday 10 January 2013 15:05:12 Torbjorn Granlund wrote:
  > Mike Frysinger  writes:
  > 
  >   looks like support for the x32 ABI slipped through the cracks.  here's
  > the patch updated to latest hg branch (http://gmplib.org:8000/gmp).
  > 
  > What is this?  Please give some context.
  
  a simple google for "x32 abi":
  http://en.wikipedia.org/wiki/X32_ABI
  https://sites.google.com/site/x32abi/

Right another ABI.

I was mainly concerned about your statement that "the x32 ABI slipped
through the cracks".  I cannot find any prior communications about this.

How could I test this?

(I wonder if this can become a robust ABI with current hardware, unless
we pay a major performance price.  It seems like address arithmetic by
means of hardware indexing, lea, etc, will be 64-bits, while we want to
compute mod 2^32.)

-- 
Torbjörn
___
gmp-devel mailing list
gmp-devel@gmplib.org
http://gmplib.org/mailman/listinfo/gmp-devel


Re: [patch] add x32 support

2013-01-10 Thread Mike Frysinger
On Thursday 10 January 2013 15:05:12 Torbjorn Granlund wrote:
> Mike Frysinger  writes:
> 
>   looks like support for the x32 ABI slipped through the cracks.  here's
> the patch updated to latest hg branch (http://gmplib.org:8000/gmp).
> 
> What is this?  Please give some context.

a simple google for "x32 abi":
http://en.wikipedia.org/wiki/X32_ABI
https://sites.google.com/site/x32abi/
-mike


signature.asc
Description: This is a digitally signed message part.
___
gmp-devel mailing list
gmp-devel@gmplib.org
http://gmplib.org/mailman/listinfo/gmp-devel


Re: [patch] add x32 support

2013-01-10 Thread Torbjorn Granlund
Mike Frysinger  writes:

  looks like support for the x32 ABI slipped through the cracks.  here's the 
  patch updated to latest hg branch (http://gmplib.org:8000/gmp).

What is this?  Please give some context.

-- 
Torbjörn
___
gmp-devel mailing list
gmp-devel@gmplib.org
http://gmplib.org/mailman/listinfo/gmp-devel


[patch] add x32 support

2013-01-10 Thread Mike Frysinger
looks like support for the x32 ABI slipped through the cracks.  here's the 
patch updated to latest hg branch (http://gmplib.org:8000/gmp).
-mike

diff -r f47abbae9591 configure.ac
--- a/configure.ac  Thu Jan 10 13:37:36 2013 +0100
+++ b/configure.ac  Thu Jan 10 14:53:40 2013 -0500
@@ -1668,9 +1668,21 @@
CALLING_CONVENTIONS_OBJS_64='amd64call.lo amd64check$U.lo'
SPEED_CYCLECOUNTER_OBJ_64=x86_64.lo
cyclecounter_size_64=2
-   abilist="64 32"
+
+   cclist_x32="gcc"
+   gcc_x32_cflags="$gcc_cflags -mx32"
+   gcc_x32_cflags_optlist="$gcc_64_cflags_optlist"
+   CALLING_CONVENTIONS_OBJS_x32="$CALLING_CONVENTIONS_OBJS_64"
+   SPEED_CYCLECOUNTER_OBJ_x32="$SPEED_CYCLECOUNTER_OBJ_64"
+   cyclecounter_size_x32="$cyclecounter_size_64"
+   path_x32="$path_64"
+   limb_x32=longlong
+   any_x32_testlist="sizeof-long-4"
+
+   abilist="64 x32 32"
if test "$enable_assembly" = "yes" ; then
extra_functions_64="invert_limb_table"
+   extra_functions_x32=$extra_functions_64
fi
 
case $host in
@@ -3427,7 +3439,7 @@
  GMP_INCLUDE_MPN(x86/darwin.m4) ;;
  esac
   ;;
-64)
+64|x32)
   GMP_INCLUDE_MPN(x86_64/x86_64-defs.m4)
   AC_DEFINE(HAVE_HOST_CPU_FAMILY_x86_64)
  case $host in


signature.asc
Description: This is a digitally signed message part.
___
gmp-devel mailing list
gmp-devel@gmplib.org
http://gmplib.org/mailman/listinfo/gmp-devel