Hans and DarkDust answer covered i386/i686 and amd64/x86_64, so there's no sense in revisiting them. This answer will focus on X32, and provide some info learned after a X32 port.
x32 is an ABI for amd64/x86_64 CPUs using 32-bit integers, longs and pointers. The idea is to combine the smaller memory and cache footprint from 32-bit data types with the larger register set of x86_64. (Reference: Debian X32 Port page).
x32 can provide up to about 30% reduction in memory usage and up to about 40% increase in speed. The use cases for the architecture are:
- vserver hosting (memory bound)
- netbooks/tablets (low memory, performance)
- scientific tasks (performance)
x32 is a somewhat recent addition. It requires kernel support (3.4 and above), distro support (see below), libc support (2.11 or above), and GCC 4.8 and above (improved address size prefix support).
For distros, it was made available in Ubuntu 13.04 or Fedora 17. Kernel support only required pointer to be in the range from 0x00000000 to 0xffffffff. From the System V Application Binary Interface, AMD64 (With LP64 and ILP32 Programming Models), Section 10.4, p. 132 (its the only sentence):
10.4 Kernel Support
Kernel should limit stack and addresses returned from system calls between 0x00000000 to 0xffffffff.
When booting a kernel with the support, you must use syscall.x32=y
option. When building a kernel, you must include the CONFIG_X86_X32=y
option. (Reference: Debian X32 Port page and X32 System V Application Binary Interface).
Here is some of what I have learned through a recent port after the Debian folks reported a few bugs on us after testing:
- the system is a lot like X86
- the preprocessor defines
__x86_64__
(and friends) and __ILP32__
, but not __i386__
/__i686__
(and friends)
- you cannot use
__ILP32__
alone because it shows up unexpectedly under Clang and Sun Studio
- when interacting with the stack, you must use the 64-bit instructions
pushq
and popq
- once a register is populated/configured from 32-bit data types, you can perform the 64-bit operations on them, like
adcq
- be careful of the 0-extension that occurs on the upper 32-bits.
If you are looking for a test platform, then you can use Debian 8 or above. Their wiki page at Debian X32 Port has all the information. The 3-second tour: (1) enable X32 in the kernel at boot; (2) use debootstrap
to install the X32 chroot environment, and (3) chroot debian-x32
to enter into the environment and test your software.