xref: /netbsd-src/external/lgpl3/gmp/dist/doc/isa_abi_headache (revision 9aa0541bdf64142d9a27c2cf274394d60182818f)
1Copyright 2000 Free Software Foundation, Inc.
2
3This file is part of the GNU MP Library.
4
5The GNU MP Library is free software; you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation; either version 3 of the License, or (at your
8option) any later version.
9
10The GNU MP Library is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
13License for more details.
14
15You should have received a copy of the GNU Lesser General Public License
16along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
17
18
19
20
21Terms Used In This Document:
22  ISA = Instruction Set Architecture.   The instructions the current
23        processor provides.
24  ABI = Application Binary Interface.  Specifies calling convention,
25        type sizes, etc.
26  AR64 = Arithmetic operations are 64-bit using 64-bit instructions
27	 (E.g., addition, subtraction, load, store, of 64-bit integer types
28	 are done with single instructions, not 32 bits at a time.)
29  Environment = The operating system and compiler.
30
31GMP is a very complex package to build since its speed is very
32sensitive to the ISA and ABI.  For example, if the ISA provides 64-bit
33instructions, it is crucial that GMP is configured to use them.
34
35Most environments that run on a 64-bit ISA provide more than one ABI.
36Typically one of the supported ABI's is a backward compatible 32-bit
37ABI, and one ABI provides 64-bit addressing and `long' (sometimes
38known as LP64).  But a few environments (IRIX, HP-UX) provide
39intermediate ABI's using 32-bit addressing but allow efficient 64-bit
40operations through a `long long' type.  For the latter to be useful to
41GMP, the ABI must allow operations using the native 64-bit
42instructions provided by the ISA, and allow passing of 64-bit
43quantities atomically.
44
45The ABI is typically chosen by means of command line options to the
46compiler tools (gcc, cc, c89, nm, ar, ld, as).  Different environments
47use different defaults, but as of this writing (May 2000) the
48dominating default is to the plain 32-bit ABI in its most arcane form.
49
50The GMP 3.0.x approach was to compile using the ABI that gives the
51best performance.  That places the burden on users to pass special
52options to the compiler when they compile their GMP applications.
53That approach has its advantages and disadvantages.  The main
54advantage is that users don't unknowingly get bad GMP performance.
55The main disadvantage is that users' compiles (actually links) will
56fail unless they pass special compiler options.
57
58** SPARC
59
60System vendors often confuse ABI, ISA, and implementation.  The worst
61case is Solaris, were the unbundled compiler confuses ISA and ABI, and
62the options have very confusing names.
63
64     option		interpretation
65     ======		==============
66cc   -xarch=v8plus	ISA=sparcv9, ABI=V8plus (PTR=32, see below)
67gcc  -mv8plus		ISA=sparcv9, ABI=V8plus (see below)
68cc   -xarch=v9		ISA=sparcv9, ABI=V9 (implying AR=64, PTR=64)
69
70It's hard to believe, but the option v8plus really means ISA=V9!
71
72Solaris releases prior to version 7 running on a V9 CPU fails to
73save/restore the upper 32 bits of the `i' and `l' registers.  The
74`v8plus' option generates code that use as many V9 features as
75possible under such circumstances.
76
77** MIPS
78
79The IRIX 6 compilers gets things right.  They have a clear
80understanding of the differences between ABI and ISA.  The option
81names are descriptive.
82
83     option		interpretation
84     ======		==============
85cc   -n32		ABI=n32 (implying AR=64, PTR=32)
86gcc  -mabi=n32		ABI=n32 (implying AR=64, PTR=32)
87cc   -64		ABI=64 (implying AR=64, PTR=64)
88gcc  -mabi=64		ABI=64 (implying AR=64, PTR=64)
89cc   -mips3		ISA=mips3
90gcc  -mips3		ISA=mips3
91cc   -mips4		ISA=mips4
92gcc  -mips4		ISA=mips4
93
94** HP-PA
95
96HP-UX is somewhat weird, but not as broken as Solaris.
97
98     option		interpretation
99     ======		==============
100cc   +DA2.0		ABI=32bit (implying AR=64, PTR=32)
101cc   +DD64		ABI=64bit (implying AR=64, PTR=64)
102
103Code performing 64-bit arithmetic in the HP-UX 32-bit is not
104compatible with the 64-bit ABI; the former has a calling convention
105that passes/returns 64-bit integer quantities as two 32-bit chunks.
106
107** PowerPC
108
109While the PowerPC ABI's are capable of supporting 64-bit
110registers/operations, the compilers under AIX are similar to Solaris'
111cc in that they don't currently provide any 32-bit addressing with
11264-bit arithmetic.
113
114     option			interpretation
115     ======			==============
116cc   -q64			ABI=64bit (implying AR=64, PTR=64)
117gcc  -maix64 -mpowerpc64	ABI=64bit (implying AR=64, PTR=64)
118