Mercurial > pub > dyncall > dyncall
annotate dyncall/dyncall_call_sparc64.s @ 233:8216c86b4cbc
- make dynload_plain test build on windows
author | Tassilo Philipp |
---|---|
date | Sun, 16 Apr 2017 17:50:55 +0200 |
parents | be9cb092625f |
children | 91db39538e78 |
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 |
195 | 86 or %o0, %g0, %i0 /* pass out retval (mov o0 -> i0) */ |
192
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 /* | |
195 | 91 @@@ complete manual with this, and remove from here once done |
0 | 92 |
93 Changes from v8: | |
94 - fundamental data types | |
95 - (un)signed int: 8,16,32,64 | |
96 - float: 32,64,128 | |
97 - float: IEEE 754 compilant | |
98 32 32-bit float registers f0,f1,..,f31 | |
99 32 64-bit float registers f0,f2,..,f62 | |
100 16 128-bit float registers f0,f4,..,f60 | |
101 | |
102 Description: | |
103 We need to raise up a dynamic stack frame. | |
104 Therefore we need to compute the stack size. We do this first, | |
105 in the context of the caller as a leaf function (using o3 as scratch for addition). | |
106 Then we raise the frame, ending up in o0-o3 is then i0-i3. | |
107 | |
108 | |
109 Stack Layout: | |
192
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
110 BIAS = 2047 |
0 | 111 |
112 BIAS+XX: should be 16 byte aligned. | |
113 ... | |
114 136: argument overflow area | |
115 128: 1 extended word for struct/union poiner return value | |
116 BIAS+ 0: 16 extended words for registers (in/local) save area [register window] | |
117 | |
118 | |
119 Function Argument Passing: | |
120 - integer %o0..%o5 (caller view). | |
195 | 121 - floating-point %f0 .. %f31 |
0 | 122 - continuous memory starting at %sp+BIAS+136 (caller view). |
123 | |
124 Register Usage: | |
125 %fp0..%fp31 : floating-point arguments. | |
126 %sp or %o6 : stack pointer, always 8 (or 16?)-byte aligned. | |
127 %fp or %i6 : frame pointer. | |
128 %i0 and %o0 : integer and pointer return values. | |
129 %i7 and %o7 : return address. (caller puts return address to %o7, callee uses %i7) | |
130 %fp0 and %fp1: return value (float). | |
131 %i0..%i5 : input argument registers | |
132 %o0..%o5 : output argument registers | |
133 %g0 : always zero, writes to it have no effect. | |
134 | |
135 Register Mappings: | |
136 r0-7 -> globals | |
137 r8-15 -> outs | |
138 r16-r23 -> locals | |
139 r24-r31 -> ins | |
140 | |
141 Integer Register Overview Table: | |
192
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
142 ID Class Name Description |
0 | 143 ------------------------------------------------------------------------------ |
192
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
144 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
|
145 1 g1 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
146 2 g2 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
147 3 g3 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
148 4 g4 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
149 5 g5 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
150 6 g6 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
151 7 g7 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
152 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
|
153 9 o1 arg 1 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
154 10 o2 arg 2 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
155 11 o3 arg 3 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
156 12 o4 arg 4 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
157 13 o5 arg 5 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
158 14 o6 stack pointer |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
159 15 o7 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
160 16 local l0 scratch |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
161 17 l1 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
162 18 l2 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
163 19 l3 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
164 20 l4 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
165 21 l5 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
166 22 l6 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
167 23 l7 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
168 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
|
169 25 i1 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
170 26 i2 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
171 27 i3 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
172 28 i4 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
173 29 i5 |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
174 30 i6 frame pointer |
cf8134a20759
- b/c no preproc needed, changed some files from .S -> .s
Tassilo Philipp
parents:
178
diff
changeset
|
175 31 i7 |
0 | 176 */ |
177 |