~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to gmp3/doc/isa_abi_headache

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

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