Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The most correct way to refer to 32-bit and 64-bit versions of programs

This question is about terminology for 32-bit vs. 64-bit x86.

If I have 2 directories with source code of the same program - one for 32-bit Windows and another for 64-bit Windows, what will be the more correct names for these folders:

  • x86-64 and x64?
  • or IA-32 and x64?

I already have read some web resources, but can't understand. Just for the record:

  • https://superuser.com/questions/179919/x86-vs-x64-why-is-32-bit-called-x86
  • Difference between x86, x32, and x64 architectures?
  • https://en.wikipedia.org/wiki/X86
  • https://en.wikipedia.org/wiki/IA-32
  • https://en.wikipedia.org/wiki/X86-64
like image 961
john c. j. Avatar asked Dec 06 '22 10:12

john c. j.


1 Answers

x86 can be a broad term that covers all CPUs that are backwards-compatible with 8086, and all extensions to the architecture including x86-64.

Note that IA-64 is not x86 at all, it's Itanium (a 64-bit VLIW architecture with explicit speculation / parallelism). It was also designed by Intel, but is totally unrelated to x86 in terms of compatibility or design. (Early IA-64 CPUs also had an x86 core integrated, for compatibility. Intel was pushing IA-64 while AMD was pushing AMD64/x86-64)

Intel sometimes talks about their CPUs as having IA cores + the integrated GPU and the other logic outside of each IA core. (IA = Intel Architecture = x86).


32-bit x86 specifically (excluding 16-bit or 64-bit) can be called

  • IA-32 (used sometimes by Intel)
  • i386 or i686 (common on Linux)
  • (Windows only): x86. Yes really: in the Windows world, "x86" specifically means 32-bit. That's why you have a Program Files (x86) directory with that name. This choice causes potential terminology confusion for everyone, because "x86" is still by far the best way to refer to the architecture in general, as opposed to ARM or MIPS.
  • rarely: x86-32. This is not used officially by any hardware or software vendors I'm aware of, but it is a useful term that's unambiguous.

Never call it x32. x32 is an ILP32 variant of the x86-64 System V ABI: 32-bit pointers in 64-bit mode. https://en.wikipedia.org/wiki/X32_ABI


64-bit x86 is easier to refer to specifically (excluding 32 and 16-bit):

  • x86-64 or x86_64 (the dash vs. underscore is not at all significant. In text most people use a dash, but only _ can be part of function/variable names in most languages.)
  • AMD64 or amd64
  • (Windows only) x64
  • IA-32e or Intel64 (mostly only in Intel CPU-architecture documentation documenting Intel's implementation of x86-64, these aren't popular and I haven't seen them in software directory names or config options). The "e" stands for "extensions", apparently. https://en.wikipedia.org/wiki/X86-64#Intel_64 has a History section that mentions naming. There are very minor differences between Intel and AMD implementations of x86-64, mostly only affecting kernels, not user-space.

Not IA-64, that's a separate architecture.

Of course if you want to be pedantic, x86-64 CPUs are required to support legacy mode, so you can run a pure 32-bit OS on an x86-64 CPU, and it's still a 64-bit CPU.

With a 64-bit kernel running 32-bit user-space, the CPU is in "compatibility" mode, which is a lot like 32-bit protected mode except the page-table format has 52-bit physical addresses. (More than the 36-bit physical address width from PAE page tables, which the x86-64 page-table format is based on.) User-space would be hard pressed to tell the difference between running under a 32-bit kernel vs. a 64-bit kernel, except for OS-specific stuff like asking the kernel with a system call.


Software directory names

Many projects go with i386 vs. x86-64 or amd64. That would be my recommendation as the least ambiguous. (Or maybe i686 if you don't really care about compat with CPUs older than PPro.)

Some, like GMP (the GNU MultiPrecision library) which has hand-written asm for many architectures, uses "x86" and "x86_64". https://gmplib.org/repo/gmp/file/tip/mpn.

(GMP has multiple hand-tuned versions of the same function for different x86 CPUs. Within "x86", there are subdirectories with different versions of functions tuned for Pentum, Core 2, Haswell, and/or taking advantage of instruction-set extensions like BMI2. This is unusual; most projects don't get that specific. Some will maybe have some stuff to take advantage of AVX or AVX512, or SSE4.1 for example, but that's often just within source files.)

like image 173
Peter Cordes Avatar answered Dec 14 '22 22:12

Peter Cordes