Mercurial > pub > dyncall > dyncall
annotate dyncall/dyncall_call_sparc64.s @ 192:cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
- some format/whitespace cleanup for readability, some declutter
author | Tassilo Philipp |
---|---|
date | Tue, 14 Mar 2017 14:14:47 +0100 |
parents | dyncall/dyncall_call_sparc64.S@183594497726 |
children | be9cb092625f |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncall | |
178
183594497726
- renamed sparc_v9 -> sparc64 for consistency (with other platforms using 32/64 suffix instead of instrset name)
cslag
parents:
0
diff
changeset
|
5 File: dyncall/dyncall_call_sparc64.S |
183594497726
- renamed sparc_v9 -> sparc64 for consistency (with other platforms using 32/64 suffix instead of instrset name)
cslag
parents:
0
diff
changeset
|
6 Description: Call kernel for sparc64 (v9) ABI. |
0 | 7 License: |
8 | |
9 Copyright (c) 2011-2015 Daniel Adler <dadler@uni-goettingen.de> | |
10 | |
11 Permission to use, copy, modify, and distribute this software for any | |
12 purpose with or without fee is hereby granted, provided that the above | |
13 copyright notice and this permission notice appear in all copies. | |
14 | |
15 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
16 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
17 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
18 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
21 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
22 | |
23 */ | |
24 | |
25 | |
192
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
26 /* NOTE: %sp/%fp for v9 are offset, using them needs a "BIAS" of 2047 */ |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
27 .set BIAS, 2047 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
28 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
29 .text |
0 | 30 .global dcCall_v9 |
31 /* dcCall_sparc64( DCCallVM* , void * target ) */ | |
32 /* o0 o1 */ | |
33 dcCall_v9: | |
192
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
34 or %o0, %g0, %o3 /* o3: callvm */ |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
35 or %o1, %g0, %o0 /* o0: target */ |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
36 ldx [%o3+24], %o1 /* o1: mVecSize */ |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
37 add %o3, 32, %o2 /* o2: stack */ |
0 | 38 /* Compute a matching stack size (approximate): o3 = align(o1+136,16) */ |
39 | |
192
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
40 add %o1, (16+1+6)*8+15, %o3 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
41 and %o3, -16, %o3 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
42 neg %o3 /* o3: -stacksize */ |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
43 save %sp, %o3, %sp |
0 | 44 |
192
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
45 ldd [%i2+8*0 ], %f0 /* Load double-precision float registers. */ |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
46 ldd [%i2+8*1 ], %f2 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
47 ldd [%i2+8*2 ], %f4 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
48 ldd [%i2+8*3 ], %f6 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
49 ldd [%i2+8*4 ], %f8 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
50 ldd [%i2+8*5 ], %f10 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
51 ldd [%i2+8*6 ], %f12 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
52 ldd [%i2+8*7 ], %f14 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
53 ldd [%i2+8*8 ], %f16 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
54 ldd [%i2+8*9 ], %f18 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
55 ldd [%i2+8*10], %f20 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
56 ldd [%i2+8*11], %f22 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
57 ldd [%i2+8*12], %f24 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
58 ldd [%i2+8*13], %f26 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
59 ldd [%i2+8*14], %f28 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
60 ldd [%i2+8*15], %f30 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
61 ldx [%i2+8*0 ], %o0 /* Load output registers. */ |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
62 ldx [%i2+8*1 ], %o1 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
63 ldx [%i2+8*2 ], %o2 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
64 ldx [%i2+8*3 ], %o3 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
65 ldx [%i2+8*4 ], %o4 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
66 ldx [%i2+8*5 ], %o5 |
0 | 67 sub %i1, 48, %i1 |
68 cmp %i1, 0 | |
192
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
69 ble .do_call |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
70 nop |
0 | 71 /* Copy loop: */ |
192
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
72 add %i2, 48, %i2 /* skip homing area */ |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
73 or %g0, %g0, %l0 /* l0 = offset initialized to 0. */ |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
74 add %sp, BIAS+((16+6)*8), %l2 /* l2 = argument area on stack space (7th word). (64+4+6*4 = byte offset 92). */ |
0 | 75 .next: |
192
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
76 ldx [%i2+%l0],%l1 /* Read from arg buffer(%i2) to %l1. */ |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
77 stx %l1, [%l2+%l0] /* Write %l1 to stack space(%l2). */ |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
78 add %l0, 8, %l0 /* Increment offset. */ |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
79 sub %i1, 8, %i1 /* Decrement copy size. */ |
0 | 80 cmp %i1, 0 |
81 bgt .next | |
82 nop | |
83 .do_call: | |
192
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
84 call %i0 /* Call target. */ |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
85 nop |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
86 or %o0, %g0, %i0 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
87 jmpl %i7 + 8, %g0 /* optimized restore;retl;nop */ |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
88 restore |
0 | 89 |
90 /* | |
192
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
91 @@@ all of this needs to go in manual |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
92 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
93 or %o0, %g0, %i0 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
94 or %o1, %g0, %i1 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
95 or %o2, %g0, %i2 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
96 or %o3, %g0, %i3 |
0 | 97 return %i7 + 8 |
192
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
98 nop |
0 | 99 |
100 Changes from v8: | |
101 - fundamental data types | |
102 - (un)signed int: 8,16,32,64 | |
103 - float: 32,64,128 | |
104 - float: IEEE 754 compilant | |
105 32 32-bit float registers f0,f1,..,f31 | |
106 32 64-bit float registers f0,f2,..,f62 | |
107 16 128-bit float registers f0,f4,..,f60 | |
108 | |
109 Description: | |
110 We need to raise up a dynamic stack frame. | |
111 Therefore we need to compute the stack size. We do this first, | |
112 in the context of the caller as a leaf function (using o3 as scratch for addition). | |
113 Then we raise the frame, ending up in o0-o3 is then i0-i3. | |
114 | |
115 | |
116 Stack Layout: | |
192
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
117 BIAS = 2047 |
0 | 118 |
119 BIAS+XX: should be 16 byte aligned. | |
120 ... | |
121 136: argument overflow area | |
122 128: 1 extended word for struct/union poiner return value | |
123 BIAS+ 0: 16 extended words for registers (in/local) save area [register window] | |
124 | |
125 | |
126 Function Argument Passing: | |
127 - integer %o0..%o5 (caller view). | |
128 - floating-point %f0 .. %f15 | |
129 - continuous memory starting at %sp+BIAS+136 (caller view). | |
130 | |
131 Register Usage: | |
132 %fp0..%fp31 : floating-point arguments. | |
133 %sp or %o6 : stack pointer, always 8 (or 16?)-byte aligned. | |
134 %fp or %i6 : frame pointer. | |
135 %i0 and %o0 : integer and pointer return values. | |
136 %i7 and %o7 : return address. (caller puts return address to %o7, callee uses %i7) | |
137 %fp0 and %fp1: return value (float). | |
138 %i0..%i5 : input argument registers | |
139 %o0..%o5 : output argument registers | |
140 %g0 : always zero, writes to it have no effect. | |
141 | |
142 Register Mappings: | |
143 r0-7 -> globals | |
144 r8-15 -> outs | |
145 r16-r23 -> locals | |
146 r24-r31 -> ins | |
147 | |
148 Integer Register Overview Table: | |
192
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
149 ID Class Name Description |
0 | 150 ------------------------------------------------------------------------------ |
192
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
151 0 globals g0 always zero, writes to it have no effect |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
152 1 g1 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
153 2 g2 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
154 3 g3 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
155 4 g4 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
156 5 g5 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
157 6 g6 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
158 7 g7 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
159 8 out o0 [int/ptr] arg 0 and return |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
160 9 o1 arg 1 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
161 10 o2 arg 2 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
162 11 o3 arg 3 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
163 12 o4 arg 4 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
164 13 o5 arg 5 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
165 14 o6 stack pointer |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
166 15 o7 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
167 16 local l0 scratch |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
168 17 l1 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
169 18 l2 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
170 19 l3 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
171 20 l4 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
172 21 l5 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
173 22 l6 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
174 23 l7 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
175 24 in i0 [int/pt] arg 0 and return |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
176 25 i1 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
177 26 i2 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
178 27 i3 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
179 28 i4 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
180 29 i5 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
181 30 i6 frame pointer |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
182 31 i7 |
0 | 183 */ |
184 |