Rev 100 | Rev 412 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 100 | Rev 322 | ||
---|---|---|---|
1 | # |
1 | # |
2 | # Copyright (C) 2005 Jakub Jermar |
2 | # Copyright (C) 2005 Jakub Jermar |
3 | # All rights reserved. |
3 | # All rights reserved. |
4 | # |
4 | # |
5 | # Redistribution and use in source and binary forms, with or without |
5 | # Redistribution and use in source and binary forms, with or without |
6 | # modification, are permitted provided that the following conditions |
6 | # modification, are permitted provided that the following conditions |
7 | # are met: |
7 | # are met: |
8 | # |
8 | # |
9 | # - Redistributions of source code must retain the above copyright |
9 | # - Redistributions of source code must retain the above copyright |
10 | # notice, this list of conditions and the following disclaimer. |
10 | # notice, this list of conditions and the following disclaimer. |
11 | # - Redistributions in binary form must reproduce the above copyright |
11 | # - Redistributions in binary form must reproduce the above copyright |
12 | # notice, this list of conditions and the following disclaimer in the |
12 | # notice, this list of conditions and the following disclaimer in the |
13 | # documentation and/or other materials provided with the distribution. |
13 | # documentation and/or other materials provided with the distribution. |
14 | # - The name of the author may not be used to endorse or promote products |
14 | # - The name of the author may not be used to endorse or promote products |
15 | # derived from this software without specific prior written permission. |
15 | # derived from this software without specific prior written permission. |
16 | # |
16 | # |
17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | # |
27 | # |
28 | 28 | ||
29 | .text |
29 | .text |
30 | 30 | ||
31 | .global context_save |
31 | .global context_save |
32 | .global context_restore |
32 | .global context_restore |
33 | 33 | ||
34 | context_save: |
34 | context_save: |
35 | alloc loc0 = ar.pfs, 1, 11, 0, 0 |
35 | alloc loc0 = ar.pfs, 1, 8, 0, 0 |
36 | mov loc1 = ar.unat ;; |
36 | mov loc1 = ar.unat ;; |
37 | /* loc2 */ |
37 | /* loc2 */ |
38 | mov loc3 = ar.rsc |
38 | mov loc3 = ar.rsc |
39 | 39 | ||
40 | .auto |
40 | .auto |
41 | 41 | ||
42 | /* |
42 | /* |
43 | * Flush dirty registers to backing store. |
43 | * Flush dirty registers to backing store. |
44 | * After this ar.bsp and ar.bspstore are equal. |
44 | * After this ar.bsp and ar.bspstore are equal. |
45 | */ |
45 | */ |
46 | flushrs |
46 | flushrs |
47 | mov loc4 = ar.bsp |
47 | mov loc4 = ar.bsp |
48 | 48 | ||
49 | /* |
49 | /* |
50 | * Put RSE to enforced lazy mode. |
50 | * Put RSE to enforced lazy mode. |
51 | * So that ar.rnat can be read. |
51 | * So that ar.rnat can be read. |
52 | */ |
52 | */ |
53 | movl loc5 = ~3 |
53 | movl loc5 = ~3 |
54 | and loc5 = loc3, loc5 |
54 | and loc5 = loc3, loc5 |
55 | mov ar.rsc = loc5 |
55 | mov ar.rsc = loc5 |
56 | mov loc5 = ar.rnat |
56 | mov loc5 = ar.rnat |
57 | 57 | ||
58 | .explicit |
58 | .explicit |
59 | 59 | ||
60 | mov loc6 = ar.lc |
60 | mov loc6 = ar.lc |
61 | mov loc7 = ar.ec |
- | |
62 | mov loc8 = ar.ccv |
- | |
63 | mov loc9 = ar.csd |
- | |
64 | mov loc10 = ar.ssd |
- | |
65 | 61 | ||
66 | /* |
62 | /* |
67 | * Save application registers |
63 | * Save application registers |
68 | */ |
64 | */ |
69 | st8 [in0] = loc0, 8 ;; /* save ar.pfs */ |
65 | st8 [in0] = loc0, 8 ;; /* save ar.pfs */ |
70 | st8 [in0] = loc1, 8 ;; /* save ar.unat (caller) */ |
66 | st8 [in0] = loc1, 8 ;; /* save ar.unat (caller) */ |
71 | mov loc2 = in0 ;; |
67 | mov loc2 = in0 ;; |
72 | add in0 = 8, in0 ;; /* skip ar.unat (callee) */ |
68 | add in0 = 8, in0 ;; /* skip ar.unat (callee) */ |
73 | st8 [in0] = loc3, 8 ;; /* save ar.rsc */ |
69 | st8 [in0] = loc3, 8 ;; /* save ar.rsc */ |
74 | st8 [in0] = loc4, 8 ;; /* save ar.bsp */ |
70 | st8 [in0] = loc4, 8 ;; /* save ar.bsp */ |
75 | st8 [in0] = loc5, 8 ;; /* save ar.rnat */ |
71 | st8 [in0] = loc5, 8 ;; /* save ar.rnat */ |
76 | st8 [in0] = loc6, 8 ;; /* save ar.lc */ |
72 | st8 [in0] = loc6, 8 ;; /* save ar.lc */ |
77 | st8 [in0] = loc7, 8 ;; /* save ar.ec */ |
- | |
78 | st8 [in0] = loc8, 8 ;; /* save ar.ccv */ |
- | |
79 | st8 [in0] = loc9, 8 ;; /* save ar.csd */ |
- | |
80 | st8 [in0] = loc10, 8 ;; /* save ar.ssd */ |
- | |
81 | 73 | ||
82 | /* |
74 | /* |
83 | * Save general registers including NaT bits |
75 | * Save general registers including NaT bits |
84 | */ |
76 | */ |
85 | st8.spill [in0] = r1, 8 ;; |
77 | st8.spill [in0] = r1, 8 ;; |
86 | st8.spill [in0] = r2, 8 ;; |
- | |
87 | st8.spill [in0] = r3, 8 ;; |
- | |
88 | st8.spill [in0] = r4, 8 ;; |
78 | st8.spill [in0] = r4, 8 ;; |
89 | st8.spill [in0] = r5, 8 ;; |
79 | st8.spill [in0] = r5, 8 ;; |
90 | st8.spill [in0] = r6, 8 ;; |
80 | st8.spill [in0] = r6, 8 ;; |
91 | st8.spill [in0] = r7, 8 ;; |
81 | st8.spill [in0] = r7, 8 ;; |
92 | st8.spill [in0] = r8, 8 ;; |
- | |
93 | st8.spill [in0] = r9, 8 ;; |
- | |
94 | st8.spill [in0] = r10, 8 ;; |
- | |
95 | st8.spill [in0] = r11, 8 ;; |
- | |
96 | st8.spill [in0] = r12, 8 ;; /* save sp */ |
82 | st8.spill [in0] = r12, 8 ;; /* save sp */ |
97 | st8.spill [in0] = r13, 8 ;; |
83 | st8.spill [in0] = r13, 8 ;; |
98 | st8.spill [in0] = r14, 8 ;; |
- | |
99 | st8.spill [in0] = r15, 8 ;; |
- | |
100 | st8.spill [in0] = r16, 8 ;; |
- | |
101 | st8.spill [in0] = r17, 8 ;; |
- | |
102 | st8.spill [in0] = r18, 8 ;; |
- | |
103 | st8.spill [in0] = r19, 8 ;; |
- | |
104 | st8.spill [in0] = r20, 8 ;; |
- | |
105 | st8.spill [in0] = r21, 8 ;; |
- | |
106 | st8.spill [in0] = r22, 8 ;; |
- | |
107 | st8.spill [in0] = r23, 8 ;; |
- | |
108 | st8.spill [in0] = r24, 8 ;; |
- | |
109 | st8.spill [in0] = r25, 8 ;; |
- | |
110 | st8.spill [in0] = r26, 8 ;; |
- | |
111 | st8.spill [in0] = r27, 8 ;; |
- | |
112 | st8.spill [in0] = r28, 8 ;; |
- | |
113 | st8.spill [in0] = r29, 8 ;; |
- | |
114 | st8.spill [in0] = r30, 8 ;; |
- | |
115 | st8.spill [in0] = r31, 8 ;; |
- | |
116 | 84 | ||
117 | mov loc3 = ar.unat ;; |
85 | mov loc3 = ar.unat ;; |
118 | st8 [loc2] = loc3 /* save ar.unat (callee) */ |
86 | st8 [loc2] = loc3 /* save ar.unat (callee) */ |
119 | 87 | ||
120 | /* |
88 | /* |
121 | * Save branch registers |
89 | * Save branch registers |
122 | */ |
90 | */ |
123 | mov loc2 = b0 ;; |
91 | mov loc2 = b0 ;; |
124 | st8 [in0] = loc2, 8 /* save pc */ |
92 | st8 [in0] = loc2, 8 /* save pc */ |
125 | mov loc3 = b1 ;; |
93 | mov loc3 = b1 ;; |
126 | st8 [in0] = loc3, 8 |
94 | st8 [in0] = loc3, 8 |
127 | mov loc4 = b2 ;; |
95 | mov loc4 = b2 ;; |
128 | st8 [in0] = loc4, 8 |
96 | st8 [in0] = loc4, 8 |
129 | mov loc5 = b3 ;; |
97 | mov loc5 = b3 ;; |
130 | st8 [in0] = loc5, 8 |
98 | st8 [in0] = loc5, 8 |
131 | mov loc6 = b4 ;; |
99 | mov loc6 = b4 ;; |
132 | st8 [in0] = loc6, 8 |
100 | st8 [in0] = loc6, 8 |
133 | mov loc7 = b5 ;; |
101 | mov loc7 = b5 ;; |
134 | st8 [in0] = loc7, 8 |
102 | st8 [in0] = loc7, 8 |
135 | mov loc8 = b6 ;; |
- | |
136 | st8 [in0] = loc8, 8 |
- | |
137 | mov loc9 = b7 ;; |
- | |
138 | st8 [in0] = loc9, 8 |
- | |
139 | 103 | ||
140 | /* |
104 | /* |
141 | * Save predicate registers |
105 | * Save predicate registers |
142 | */ |
106 | */ |
143 | mov loc2 = pr ;; |
107 | mov loc2 = pr ;; |
144 | st8 [in0] = loc2, 8 |
108 | st8 [in0] = loc2, 8 |
145 | 109 | ||
146 | mov ar.pfs = loc0 |
110 | mov ar.pfs = loc0 |
147 | mov ar.unat = loc1 |
111 | mov ar.unat = loc1 |
148 | 112 | ||
149 | add r8 = r0, r0, 1 /* context_save returns 1 */ |
113 | add r8 = r0, r0, 1 /* context_save returns 1 */ |
150 | br.ret.sptk.many b0 |
114 | br.ret.sptk.many b0 |
151 | 115 | ||
152 | context_restore: |
116 | context_restore: |
153 | alloc loc0 = ar.pfs, 1, 11, 0, 0 ;; |
117 | alloc loc0 = ar.pfs, 1, 8, 0, 0 ;; |
154 | 118 | ||
155 | ld8 loc0 = [in0], 8 ;; /* load ar.pfs */ |
119 | ld8 loc0 = [in0], 8 ;; /* load ar.pfs */ |
156 | ld8 loc1 = [in0], 8 ;; /* load ar.unat (caller) */ |
120 | ld8 loc1 = [in0], 8 ;; /* load ar.unat (caller) */ |
157 | ld8 loc2 = [in0], 8 ;; /* load ar.unat (callee) */ |
121 | ld8 loc2 = [in0], 8 ;; /* load ar.unat (callee) */ |
158 | ld8 loc3 = [in0], 8 ;; /* load ar.rsc */ |
122 | ld8 loc3 = [in0], 8 ;; /* load ar.rsc */ |
159 | ld8 loc4 = [in0], 8 ;; /* load ar.bsp */ |
123 | ld8 loc4 = [in0], 8 ;; /* load ar.bsp */ |
160 | ld8 loc5 = [in0], 8 ;; /* load ar.rnat */ |
124 | ld8 loc5 = [in0], 8 ;; /* load ar.rnat */ |
161 | ld8 loc6 = [in0], 8 ;; /* load ar.lc */ |
125 | ld8 loc6 = [in0], 8 ;; /* load ar.lc */ |
162 | ld8 loc7 = [in0], 8 ;; /* load ar.ec */ |
- | |
163 | ld8 loc8 = [in0], 8 ;; /* load ar.ccv */ |
- | |
164 | ld8 loc9 = [in0], 8 ;; /* load ar.csd */ |
- | |
165 | ld8 loc10 = [in0], 8 ;; /* load ar.ssd */ |
- | |
166 | 126 | ||
167 | .auto |
127 | .auto |
168 | 128 | ||
169 | /* |
129 | /* |
170 | * Invalidate the ALAT |
130 | * Invalidate the ALAT |
171 | */ |
131 | */ |
172 | invala |
132 | invala |
173 | 133 | ||
174 | /* |
134 | /* |
175 | * Restore application registers |
135 | * Restore application registers |
176 | */ |
136 | */ |
177 | 137 | ||
178 | mov ar.bspstore = loc4 |
138 | mov ar.bspstore = loc4 |
179 | mov ar.rnat = loc5 |
139 | mov ar.rnat = loc5 |
180 | mov ar.pfs = loc0 |
140 | mov ar.pfs = loc0 |
181 | mov ar.rsc = loc3 |
141 | mov ar.rsc = loc3 |
182 | 142 | ||
183 | .explicit |
143 | .explicit |
184 | 144 | ||
185 | mov ar.unat = loc2 ;; |
145 | mov ar.unat = loc2 ;; |
186 | mov ar.lc = loc6 |
146 | mov ar.lc = loc6 |
187 | mov ar.ec = loc7 |
- | |
188 | mov ar.ccv = loc8 |
- | |
189 | mov ar.csd = loc9 |
- | |
190 | mov ar.ssd = loc10 |
- | |
191 | 147 | ||
192 | /* |
148 | /* |
193 | * Restore general registers including NaT bits |
149 | * Restore general registers including NaT bits |
194 | */ |
150 | */ |
195 | ld8.fill r1 = [in0], 8 ;; |
151 | ld8.fill r1 = [in0], 8 ;; |
196 | ld8.fill r2 = [in0], 8 ;; |
- | |
197 | ld8.fill r3 = [in0], 8 ;; |
- | |
198 | ld8.fill r4 = [in0], 8 ;; |
152 | ld8.fill r4 = [in0], 8 ;; |
199 | ld8.fill r5 = [in0], 8 ;; |
153 | ld8.fill r5 = [in0], 8 ;; |
200 | ld8.fill r6 = [in0], 8 ;; |
154 | ld8.fill r6 = [in0], 8 ;; |
201 | ld8.fill r7 = [in0], 8 ;; |
155 | ld8.fill r7 = [in0], 8 ;; |
202 | ld8.fill r8 = [in0], 8 ;; |
- | |
203 | ld8.fill r9 = [in0], 8 ;; |
- | |
204 | ld8.fill r10 = [in0], 8 ;; |
- | |
205 | ld8.fill r11 = [in0], 8 ;; |
- | |
206 | ld8.fill r12 = [in0], 8 ;; /* restore sp */ |
156 | ld8.fill r12 = [in0], 8 ;; /* restore sp */ |
207 | ld8.fill r13 = [in0], 8 ;; |
157 | ld8.fill r13 = [in0], 8 ;; |
208 | ld8.fill r14 = [in0], 8 ;; |
- | |
209 | ld8.fill r15 = [in0], 8 ;; |
- | |
210 | ld8.fill r16 = [in0], 8 ;; |
- | |
211 | ld8.fill r17 = [in0], 8 ;; |
- | |
212 | ld8.fill r18 = [in0], 8 ;; |
- | |
213 | ld8.fill r19 = [in0], 8 ;; |
- | |
214 | ld8.fill r20 = [in0], 8 ;; |
- | |
215 | ld8.fill r21 = [in0], 8 ;; |
- | |
216 | ld8.fill r22 = [in0], 8 ;; |
- | |
217 | ld8.fill r23 = [in0], 8 ;; |
- | |
218 | ld8.fill r24 = [in0], 8 ;; |
- | |
219 | ld8.fill r25 = [in0], 8 ;; |
- | |
220 | ld8.fill r26 = [in0], 8 ;; |
- | |
221 | ld8.fill r27 = [in0], 8 ;; |
- | |
222 | ld8.fill r28 = [in0], 8 ;; |
- | |
223 | ld8.fill r29 = [in0], 8 ;; |
- | |
224 | ld8.fill r30 = [in0], 8 ;; |
- | |
225 | ld8.fill r31 = [in0], 8 ;; |
- | |
226 | 158 | ||
227 | /* |
159 | /* |
228 | * Restore branch registers |
160 | * Restore branch registers |
229 | */ |
161 | */ |
230 | ld8 loc2 = [in0], 8 ;; /* restore pc */ |
162 | ld8 loc2 = [in0], 8 ;; /* restore pc */ |
231 | mov b0 = loc2 |
163 | mov b0 = loc2 |
232 | ld8 loc3 = [in0], 8 ;; |
164 | ld8 loc3 = [in0], 8 ;; |
233 | mov b1 = loc3 |
165 | mov b1 = loc3 |
234 | ld8 loc4 = [in0], 8 ;; |
166 | ld8 loc4 = [in0], 8 ;; |
235 | mov b2 = loc4 |
167 | mov b2 = loc4 |
236 | ld8 loc5 = [in0], 8 ;; |
168 | ld8 loc5 = [in0], 8 ;; |
237 | mov b3 = loc5 |
169 | mov b3 = loc5 |
238 | ld8 loc6 = [in0], 8 ;; |
170 | ld8 loc6 = [in0], 8 ;; |
239 | mov b4 = loc6 |
171 | mov b4 = loc6 |
240 | ld8 loc7 = [in0], 8 ;; |
172 | ld8 loc7 = [in0], 8 ;; |
241 | mov b5 = loc7 |
173 | mov b5 = loc7 |
242 | ld8 loc8 = [in0], 8 ;; |
- | |
243 | mov b6 = loc8 |
- | |
244 | ld8 loc9 = [in0], 8 ;; |
- | |
245 | mov b7 = loc9 |
- | |
246 | 174 | ||
247 | /* |
175 | /* |
248 | * Restore predicate registers |
176 | * Restore predicate registers |
249 | */ |
177 | */ |
250 | ld8 loc2 = [in0], 8 ;; |
178 | ld8 loc2 = [in0], 8 ;; |
251 | mov pr = loc2, ~0 |
179 | mov pr = loc2, ~0 |
252 | 180 | ||
253 | mov ar.unat = loc1 |
181 | mov ar.unat = loc1 |
254 | 182 | ||
255 | mov r8 = r0 /* context_restore returns 0 */ |
183 | mov r8 = r0 /* context_restore returns 0 */ |
256 | br.ret.sptk.many b0 |
184 | br.ret.sptk.many b0 |
257 | 185 |