annotate doc/manual/callconvs/callconv_mips64.tex @ 302:d55f9d508074

- mips softfloat support for o32 callconv (calls and callbacks, little and big endian) - cleanup of some mips files, removed unnecessary file, renamings.. - doc/manual cleanups, changelog entry
author Tassilo Philipp
date Mon, 21 May 2018 02:48:12 +0200
parents e210193f6cf1
children b104c5beec8b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 %//////////////////////////////////////////////////////////////////////////////
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
2 %
186
e210193f6cf1 - doc cleanups and correction about support, added bibitems, etc.
Tassilo Philipp
parents: 139
diff changeset
3 % Copyright (c) 2007-2016 Daniel Adler <dadler@uni-goettingen.de>,
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
4 % Tassilo Philipp <tphilipp@potion-studios.com>
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
5 %
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 % Permission to use, copy, modify, and distribute this software for any
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 % purpose with or without fee is hereby granted, provided that the above
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
8 % copyright notice and this permission notice appear in all copies.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
9 %
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10 % THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11 % WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 % MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13 % ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 % WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15 % ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 % OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 %
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 %//////////////////////////////////////////////////////////////////////////////
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 \subsection{MIPS64 Calling Convention}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22 \paragraph{Overview}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
24 There are two main ABIs in use for MIPS64 chips, \emph{N64}\cite{MIPSn32/n64} and \emph{N32}\cite{MIPSn32/n64}. Both are
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
25 basically the same, except that N32 uses 32-bit pointers and long integers, instead of 64. All registers of a MIPS64 chip are considered
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
26 to be 64-bit wide, even for the N32 calling convention.\\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
27 The word size is defined to be 32 bits, a dword 64 bits. Note that this is due to historical reasons (terminology didn't change from MIPS32).\\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
28 Other than that there are 64-bit versions of the other ABIs found for MIPS32, e.g. the EABI\cite{MIPSeabi} and O64\cite{MIPSo64}.
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
29
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
30 \paragraph{\product{dyncall} support}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
31
139
5675d34f0a06 - mips64 doc about impl status
cslag
parents: 125
diff changeset
32 For MIPS 64-bit machines, dyncall supports the N64 calling conventions for calls and callbacks (for big- and little-endian targets).
5675d34f0a06 - mips64 doc about impl status
cslag
parents: 125
diff changeset
33 The N32 calling convention might work - it used to, but hasn't been tested, recently.
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
34
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
35 \subsubsection{MIPS N64 Calling Convention}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
36
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
37 \paragraph{Register usage}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
38
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
39 \begin{table}[h]
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
40 \begin{tabular*}{0.95\textwidth}{lll}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
41 Name & Alias & Brief description\\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
42 \hline
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
43 {\bf \$0} & {\bf \$zero} & Hardware zero \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
44 {\bf \$1} & {\bf \$at} & Assembler temporary \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
45 {\bf \$2-\$3} & {\bf \$v0-\$v1} & Integer results \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
46 {\bf \$4-\$11} & {\bf \$a0-\$a7} & Integer arguments, or double precision float arguments\\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
47 {\bf \$12-\$15,\$24} & {\bf \$t4-\$t7,\$t8} & Integer temporaries \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
48 {\bf \$25} & {\bf \$t9} & Integer temporary, hold the address of the called function for all PIC calls (by convention) \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
49 {\bf \$16-\$23} & {\bf \$s0-\$s7} & Preserved \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
50 {\bf \$26,\$27} & {\bf \$kt0,\$kt1} & Reserved for kernel \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
51 {\bf \$28} & {\bf \$gp} & Global pointer, preserve \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
52 {\bf \$29} & {\bf \$sp} & Stack pointer, preserve \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
53 {\bf \$30} & {\bf \$s8} & Frame pointer, preserve \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
54 {\bf \$31} & {\bf \$ra} & Return address, preserve \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
55 {\bf hi, lo} & & Multiply/divide special registers \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
56 {\bf \$f0,\$f2} & & Float results \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
57 {\bf \$f1,\$f3,\$f4-\$f11,\$f20-\$f23} & & Float temporaries \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
58 {\bf \$f12-\$f19} & & Float arguments \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
59 {\bf \$f24-\$f31} & & Preserved \\%@@@on N32, this changes
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
60 \end{tabular*}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
61 \caption{Register usage on MIPS N64 calling convention}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
62 \end{table}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
63
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
64 \paragraph{Parameter passing}
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
65
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
66 \begin{itemize}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
67 \item Stack grows down
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
68 \item Stack parameter order: right-to-left
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
69 \item Caller cleans up the stack
119
f1cc11a9eb98 - mips64 manual appendix clarifications
cslag
parents: 117
diff changeset
70 \item first 8 params \textgreater=\ 64-bit are passed in registers \$a0-\$a7 for integers and \$f12-\$f19 for floats - with mixed float and int parameters,
f1cc11a9eb98 - mips64 manual appendix clarifications
cslag
parents: 117
diff changeset
71 some registers are left out (e.g. first parameter ends up in \$a0 or \$f12, second in \$a1 or \$f13, etc.)
f1cc11a9eb98 - mips64 manual appendix clarifications
cslag
parents: 117
diff changeset
72 \item subsequent arguments are pushed onto the stack
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
73 \item all stack entries are 64-bit aligned
119
f1cc11a9eb98 - mips64 manual appendix clarifications
cslag
parents: 117
diff changeset
74 \item all stack regions are 16-byte aligned
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
75 \item results are returned in \$v0, and for a second one \$v1 is used
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
76 \item float arguments passed in the variable part of a vararg call are passed like integers
125
f1fc1c836baf - mips doc stuff
cslag
parents: 123
diff changeset
77 \item quad precision float arguments are passed in even-odd register pairs, skipping one register if needed
f1fc1c836baf - mips doc stuff
cslag
parents: 123
diff changeset
78 \item integer parameters \textless\ 64 bit are right-justified (meaning occupy higher-address bytes) in their 8-byte slot on the stack, requiring extra-care for big-endian targets
f1fc1c836baf - mips doc stuff
cslag
parents: 123
diff changeset
79 \item single precision float parameters (32 bit) are left-justified in their 8-byte slot on the stack, but are right justified in fp-registers on big endian targets, as they aren't promoted @@@doc says "undecided", but openbsd/octeon(mipseb) has it as described here
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
80 \end{itemize}
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
81
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
82 \paragraph{Stack layout}
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
83
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
84 Stack directly after function prolog:\\
119
f1cc11a9eb98 - mips64 manual appendix clarifications
cslag
parents: 117
diff changeset
85 @@@ WIP, might be wrong
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
86
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
87 \begin{figure}[h]
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
88 \begin{tabular}{5|3|1 1}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
89 \hhline{~-~~}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
90 & \vdots & & \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
91 \hhline{~=~~}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
92 register save area & \hspace{4cm} & & \mrrbrace{5}{caller's frame} \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
93 \hhline{~-~~}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
94 local data & & & \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
95 \hhline{~-~~}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
96 \mrlbrace{3}{parameter area} & \ldots & \mrrbrace{3}{stack parameters} & \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
97 & \ldots & & \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
98 & \ldots & & \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
99 \hhline{~=~~}
119
f1cc11a9eb98 - mips64 manual appendix clarifications
cslag
parents: 117
diff changeset
100 register save area & padding & & \mrrbrace{7}{current frame} \\
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
101 & \$ra & & \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
102 & \$s8 & & \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
103 & \$gp & & \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
104 \hhline{~-~~}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
105 local data & & & \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
106 \hhline{~-~~}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
107 parameter area & & & \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
108 \hhline{~-~~}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
109 & \vdots & & \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
110 \hhline{~-~~}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
111 \end{tabular}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
112 \caption{Stack layout on mips64 n64 calling convention}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
113 \end{figure}
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
114
302
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 186
diff changeset
115
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 186
diff changeset
116 \subsubsection{MIPS N32 Calling Convention}
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 186
diff changeset
117
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 186
diff changeset
118 @@@
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 186
diff changeset
119