Blame doc/isa_abi_headache

Packit 5c3484
Copyright 2000 Free Software Foundation, Inc.
Packit 5c3484
Packit 5c3484
This file is part of the GNU MP Library.
Packit 5c3484
Packit 5c3484
The GNU MP Library is free software; you can redistribute it and/or modify
Packit 5c3484
it under the terms of either:
Packit 5c3484
Packit 5c3484
  * the GNU Lesser General Public License as published by the Free
Packit 5c3484
    Software Foundation; either version 3 of the License, or (at your
Packit 5c3484
    option) any later version.
Packit 5c3484
Packit 5c3484
or
Packit 5c3484
Packit 5c3484
  * the GNU General Public License as published by the Free Software
Packit 5c3484
    Foundation; either version 2 of the License, or (at your option) any
Packit 5c3484
    later version.
Packit 5c3484
Packit 5c3484
or both in parallel, as here.
Packit 5c3484
Packit 5c3484
The GNU MP Library is distributed in the hope that it will be useful, but
Packit 5c3484
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit 5c3484
or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
Packit 5c3484
for more details.
Packit 5c3484
Packit 5c3484
You should have received copies of the GNU General Public License and the
Packit 5c3484
GNU Lesser General Public License along with the GNU MP Library.  If not,
Packit 5c3484
see https://www.gnu.org/licenses/.
Packit 5c3484
Packit 5c3484
Packit 5c3484
Packit 5c3484
Packit 5c3484
Terms Used In This Document:
Packit 5c3484
  ISA = Instruction Set Architecture.   The instructions the current
Packit 5c3484
        processor provides.
Packit 5c3484
  ABI = Application Binary Interface.  Specifies calling convention,
Packit 5c3484
        type sizes, etc.
Packit 5c3484
  AR64 = Arithmetic operations are 64-bit using 64-bit instructions
Packit 5c3484
	 (E.g., addition, subtraction, load, store, of 64-bit integer types
Packit 5c3484
	 are done with single instructions, not 32 bits at a time.)
Packit 5c3484
  Environment = The operating system and compiler.
Packit 5c3484
Packit 5c3484
GMP is a very complex package to build since its speed is very
Packit 5c3484
sensitive to the ISA and ABI.  For example, if the ISA provides 64-bit
Packit 5c3484
instructions, it is crucial that GMP is configured to use them.
Packit 5c3484
Packit 5c3484
Most environments that run on a 64-bit ISA provide more than one ABI.
Packit 5c3484
Typically one of the supported ABI's is a backward compatible 32-bit
Packit 5c3484
ABI, and one ABI provides 64-bit addressing and `long' (sometimes
Packit 5c3484
known as LP64).  But a few environments (IRIX, HP-UX) provide
Packit 5c3484
intermediate ABI's using 32-bit addressing but allow efficient 64-bit
Packit 5c3484
operations through a `long long' type.  For the latter to be useful to
Packit 5c3484
GMP, the ABI must allow operations using the native 64-bit
Packit 5c3484
instructions provided by the ISA, and allow passing of 64-bit
Packit 5c3484
quantities atomically.
Packit 5c3484
Packit 5c3484
The ABI is typically chosen by means of command line options to the
Packit 5c3484
compiler tools (gcc, cc, c89, nm, ar, ld, as).  Different environments
Packit 5c3484
use different defaults, but as of this writing (May 2000) the
Packit 5c3484
dominating default is to the plain 32-bit ABI in its most arcane form.
Packit 5c3484
Packit 5c3484
The GMP 3.0.x approach was to compile using the ABI that gives the
Packit 5c3484
best performance.  That places the burden on users to pass special
Packit 5c3484
options to the compiler when they compile their GMP applications.
Packit 5c3484
That approach has its advantages and disadvantages.  The main
Packit 5c3484
advantage is that users don't unknowingly get bad GMP performance.
Packit 5c3484
The main disadvantage is that users' compiles (actually links) will
Packit 5c3484
fail unless they pass special compiler options.
Packit 5c3484
Packit 5c3484
** SPARC
Packit 5c3484
Packit 5c3484
System vendors often confuse ABI, ISA, and implementation.  The worst
Packit 5c3484
case is Solaris, were the unbundled compiler confuses ISA and ABI, and
Packit 5c3484
the options have very confusing names.
Packit 5c3484
Packit 5c3484
     option		interpretation
Packit 5c3484
     ======		==============
Packit 5c3484
cc   -xarch=v8plus	ISA=sparcv9, ABI=V8plus (PTR=32, see below)
Packit 5c3484
gcc  -mv8plus		ISA=sparcv9, ABI=V8plus (see below)
Packit 5c3484
cc   -xarch=v9		ISA=sparcv9, ABI=V9 (implying AR=64, PTR=64)
Packit 5c3484
Packit 5c3484
It's hard to believe, but the option v8plus really means ISA=V9!
Packit 5c3484
Packit 5c3484
Solaris releases prior to version 7 running on a V9 CPU fails to
Packit 5c3484
save/restore the upper 32 bits of the `i' and `l' registers.  The
Packit 5c3484
`v8plus' option generates code that use as many V9 features as
Packit 5c3484
possible under such circumstances.
Packit 5c3484
Packit 5c3484
** MIPS
Packit 5c3484
Packit 5c3484
The IRIX 6 compilers gets things right.  They have a clear
Packit 5c3484
understanding of the differences between ABI and ISA.  The option
Packit 5c3484
names are descriptive.
Packit 5c3484
Packit 5c3484
     option		interpretation
Packit 5c3484
     ======		==============
Packit 5c3484
cc   -n32		ABI=n32 (implying AR=64, PTR=32)
Packit 5c3484
gcc  -mabi=n32		ABI=n32 (implying AR=64, PTR=32)
Packit 5c3484
cc   -64		ABI=64 (implying AR=64, PTR=64)
Packit 5c3484
gcc  -mabi=64		ABI=64 (implying AR=64, PTR=64)
Packit 5c3484
cc   -mips3		ISA=mips3
Packit 5c3484
gcc  -mips3		ISA=mips3
Packit 5c3484
cc   -mips4		ISA=mips4
Packit 5c3484
gcc  -mips4		ISA=mips4
Packit 5c3484
Packit 5c3484
** HP-PA
Packit 5c3484
Packit 5c3484
HP-UX is somewhat weird, but not as broken as Solaris.
Packit 5c3484
Packit 5c3484
     option		interpretation
Packit 5c3484
     ======		==============
Packit 5c3484
cc   +DA2.0		ABI=32bit (implying AR=64, PTR=32)
Packit 5c3484
cc   +DD64		ABI=64bit (implying AR=64, PTR=64)
Packit 5c3484
Packit 5c3484
Code performing 64-bit arithmetic in the HP-UX 32-bit is not
Packit 5c3484
compatible with the 64-bit ABI; the former has a calling convention
Packit 5c3484
that passes/returns 64-bit integer quantities as two 32-bit chunks.
Packit 5c3484
Packit 5c3484
** PowerPC
Packit 5c3484
Packit 5c3484
While the PowerPC ABI's are capable of supporting 64-bit
Packit 5c3484
registers/operations, the compilers under AIX are similar to Solaris'
Packit 5c3484
cc in that they don't currently provide any 32-bit addressing with
Packit 5c3484
64-bit arithmetic.
Packit 5c3484
Packit 5c3484
     option			interpretation
Packit 5c3484
     ======			==============
Packit 5c3484
cc   -q64			ABI=64bit (implying AR=64, PTR=64)
Packit 5c3484
gcc  -maix64 -mpowerpc64	ABI=64bit (implying AR=64, PTR=64)