root / target-sparc / cc_helper.c @ d7582078
History | View | Annotate | Download (10.8 kB)
1 | cffc5818 | Blue Swirl | /*
|
---|---|---|---|
2 | cffc5818 | Blue Swirl | * Helpers for lazy condition code handling
|
3 | cffc5818 | Blue Swirl | *
|
4 | cffc5818 | Blue Swirl | * Copyright (c) 2003-2005 Fabrice Bellard
|
5 | cffc5818 | Blue Swirl | *
|
6 | cffc5818 | Blue Swirl | * This library is free software; you can redistribute it and/or
|
7 | cffc5818 | Blue Swirl | * modify it under the terms of the GNU Lesser General Public
|
8 | cffc5818 | Blue Swirl | * License as published by the Free Software Foundation; either
|
9 | cffc5818 | Blue Swirl | * version 2 of the License, or (at your option) any later version.
|
10 | cffc5818 | Blue Swirl | *
|
11 | cffc5818 | Blue Swirl | * This library is distributed in the hope that it will be useful,
|
12 | cffc5818 | Blue Swirl | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | cffc5818 | Blue Swirl | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | cffc5818 | Blue Swirl | * Lesser General Public License for more details.
|
15 | cffc5818 | Blue Swirl | *
|
16 | cffc5818 | Blue Swirl | * You should have received a copy of the GNU Lesser General Public
|
17 | cffc5818 | Blue Swirl | * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
18 | cffc5818 | Blue Swirl | */
|
19 | cffc5818 | Blue Swirl | |
20 | cffc5818 | Blue Swirl | #include "cpu.h" |
21 | cffc5818 | Blue Swirl | #include "helper.h" |
22 | cffc5818 | Blue Swirl | |
23 | c5f9864e | Andreas Färber | static uint32_t compute_all_flags(CPUSPARCState *env)
|
24 | cffc5818 | Blue Swirl | { |
25 | cffc5818 | Blue Swirl | return env->psr & PSR_ICC;
|
26 | cffc5818 | Blue Swirl | } |
27 | cffc5818 | Blue Swirl | |
28 | c5f9864e | Andreas Färber | static uint32_t compute_C_flags(CPUSPARCState *env)
|
29 | cffc5818 | Blue Swirl | { |
30 | cffc5818 | Blue Swirl | return env->psr & PSR_CARRY;
|
31 | cffc5818 | Blue Swirl | } |
32 | cffc5818 | Blue Swirl | |
33 | cffc5818 | Blue Swirl | static inline uint32_t get_NZ_icc(int32_t dst) |
34 | cffc5818 | Blue Swirl | { |
35 | cffc5818 | Blue Swirl | uint32_t ret = 0;
|
36 | cffc5818 | Blue Swirl | |
37 | cffc5818 | Blue Swirl | if (dst == 0) { |
38 | cffc5818 | Blue Swirl | ret = PSR_ZERO; |
39 | cffc5818 | Blue Swirl | } else if (dst < 0) { |
40 | cffc5818 | Blue Swirl | ret = PSR_NEG; |
41 | cffc5818 | Blue Swirl | } |
42 | cffc5818 | Blue Swirl | return ret;
|
43 | cffc5818 | Blue Swirl | } |
44 | cffc5818 | Blue Swirl | |
45 | cffc5818 | Blue Swirl | #ifdef TARGET_SPARC64
|
46 | c5f9864e | Andreas Färber | static uint32_t compute_all_flags_xcc(CPUSPARCState *env)
|
47 | cffc5818 | Blue Swirl | { |
48 | cffc5818 | Blue Swirl | return env->xcc & PSR_ICC;
|
49 | cffc5818 | Blue Swirl | } |
50 | cffc5818 | Blue Swirl | |
51 | c5f9864e | Andreas Färber | static uint32_t compute_C_flags_xcc(CPUSPARCState *env)
|
52 | cffc5818 | Blue Swirl | { |
53 | cffc5818 | Blue Swirl | return env->xcc & PSR_CARRY;
|
54 | cffc5818 | Blue Swirl | } |
55 | cffc5818 | Blue Swirl | |
56 | cffc5818 | Blue Swirl | static inline uint32_t get_NZ_xcc(target_long dst) |
57 | cffc5818 | Blue Swirl | { |
58 | cffc5818 | Blue Swirl | uint32_t ret = 0;
|
59 | cffc5818 | Blue Swirl | |
60 | cffc5818 | Blue Swirl | if (!dst) {
|
61 | cffc5818 | Blue Swirl | ret = PSR_ZERO; |
62 | cffc5818 | Blue Swirl | } else if (dst < 0) { |
63 | cffc5818 | Blue Swirl | ret = PSR_NEG; |
64 | cffc5818 | Blue Swirl | } |
65 | cffc5818 | Blue Swirl | return ret;
|
66 | cffc5818 | Blue Swirl | } |
67 | cffc5818 | Blue Swirl | #endif
|
68 | cffc5818 | Blue Swirl | |
69 | cffc5818 | Blue Swirl | static inline uint32_t get_V_div_icc(target_ulong src2) |
70 | cffc5818 | Blue Swirl | { |
71 | cffc5818 | Blue Swirl | uint32_t ret = 0;
|
72 | cffc5818 | Blue Swirl | |
73 | cffc5818 | Blue Swirl | if (src2 != 0) { |
74 | cffc5818 | Blue Swirl | ret = PSR_OVF; |
75 | cffc5818 | Blue Swirl | } |
76 | cffc5818 | Blue Swirl | return ret;
|
77 | cffc5818 | Blue Swirl | } |
78 | cffc5818 | Blue Swirl | |
79 | c5f9864e | Andreas Färber | static uint32_t compute_all_div(CPUSPARCState *env)
|
80 | cffc5818 | Blue Swirl | { |
81 | cffc5818 | Blue Swirl | uint32_t ret; |
82 | cffc5818 | Blue Swirl | |
83 | cffc5818 | Blue Swirl | ret = get_NZ_icc(CC_DST); |
84 | cffc5818 | Blue Swirl | ret |= get_V_div_icc(CC_SRC2); |
85 | cffc5818 | Blue Swirl | return ret;
|
86 | cffc5818 | Blue Swirl | } |
87 | cffc5818 | Blue Swirl | |
88 | c5f9864e | Andreas Färber | static uint32_t compute_C_div(CPUSPARCState *env)
|
89 | cffc5818 | Blue Swirl | { |
90 | cffc5818 | Blue Swirl | return 0; |
91 | cffc5818 | Blue Swirl | } |
92 | cffc5818 | Blue Swirl | |
93 | cffc5818 | Blue Swirl | static inline uint32_t get_C_add_icc(uint32_t dst, uint32_t src1) |
94 | cffc5818 | Blue Swirl | { |
95 | cffc5818 | Blue Swirl | uint32_t ret = 0;
|
96 | cffc5818 | Blue Swirl | |
97 | cffc5818 | Blue Swirl | if (dst < src1) {
|
98 | cffc5818 | Blue Swirl | ret = PSR_CARRY; |
99 | cffc5818 | Blue Swirl | } |
100 | cffc5818 | Blue Swirl | return ret;
|
101 | cffc5818 | Blue Swirl | } |
102 | cffc5818 | Blue Swirl | |
103 | cffc5818 | Blue Swirl | static inline uint32_t get_C_addx_icc(uint32_t dst, uint32_t src1, |
104 | cffc5818 | Blue Swirl | uint32_t src2) |
105 | cffc5818 | Blue Swirl | { |
106 | cffc5818 | Blue Swirl | uint32_t ret = 0;
|
107 | cffc5818 | Blue Swirl | |
108 | cffc5818 | Blue Swirl | if (((src1 & src2) | (~dst & (src1 | src2))) & (1U << 31)) { |
109 | cffc5818 | Blue Swirl | ret = PSR_CARRY; |
110 | cffc5818 | Blue Swirl | } |
111 | cffc5818 | Blue Swirl | return ret;
|
112 | cffc5818 | Blue Swirl | } |
113 | cffc5818 | Blue Swirl | |
114 | cffc5818 | Blue Swirl | static inline uint32_t get_V_add_icc(uint32_t dst, uint32_t src1, |
115 | cffc5818 | Blue Swirl | uint32_t src2) |
116 | cffc5818 | Blue Swirl | { |
117 | cffc5818 | Blue Swirl | uint32_t ret = 0;
|
118 | cffc5818 | Blue Swirl | |
119 | cffc5818 | Blue Swirl | if (((src1 ^ src2 ^ -1) & (src1 ^ dst)) & (1U << 31)) { |
120 | cffc5818 | Blue Swirl | ret = PSR_OVF; |
121 | cffc5818 | Blue Swirl | } |
122 | cffc5818 | Blue Swirl | return ret;
|
123 | cffc5818 | Blue Swirl | } |
124 | cffc5818 | Blue Swirl | |
125 | cffc5818 | Blue Swirl | #ifdef TARGET_SPARC64
|
126 | cffc5818 | Blue Swirl | static inline uint32_t get_C_add_xcc(target_ulong dst, target_ulong src1) |
127 | cffc5818 | Blue Swirl | { |
128 | cffc5818 | Blue Swirl | uint32_t ret = 0;
|
129 | cffc5818 | Blue Swirl | |
130 | cffc5818 | Blue Swirl | if (dst < src1) {
|
131 | cffc5818 | Blue Swirl | ret = PSR_CARRY; |
132 | cffc5818 | Blue Swirl | } |
133 | cffc5818 | Blue Swirl | return ret;
|
134 | cffc5818 | Blue Swirl | } |
135 | cffc5818 | Blue Swirl | |
136 | cffc5818 | Blue Swirl | static inline uint32_t get_C_addx_xcc(target_ulong dst, target_ulong src1, |
137 | cffc5818 | Blue Swirl | target_ulong src2) |
138 | cffc5818 | Blue Swirl | { |
139 | cffc5818 | Blue Swirl | uint32_t ret = 0;
|
140 | cffc5818 | Blue Swirl | |
141 | cffc5818 | Blue Swirl | if (((src1 & src2) | (~dst & (src1 | src2))) & (1ULL << 63)) { |
142 | cffc5818 | Blue Swirl | ret = PSR_CARRY; |
143 | cffc5818 | Blue Swirl | } |
144 | cffc5818 | Blue Swirl | return ret;
|
145 | cffc5818 | Blue Swirl | } |
146 | cffc5818 | Blue Swirl | |
147 | cffc5818 | Blue Swirl | static inline uint32_t get_V_add_xcc(target_ulong dst, target_ulong src1, |
148 | cffc5818 | Blue Swirl | target_ulong src2) |
149 | cffc5818 | Blue Swirl | { |
150 | cffc5818 | Blue Swirl | uint32_t ret = 0;
|
151 | cffc5818 | Blue Swirl | |
152 | cffc5818 | Blue Swirl | if (((src1 ^ src2 ^ -1) & (src1 ^ dst)) & (1ULL << 63)) { |
153 | cffc5818 | Blue Swirl | ret = PSR_OVF; |
154 | cffc5818 | Blue Swirl | } |
155 | cffc5818 | Blue Swirl | return ret;
|
156 | cffc5818 | Blue Swirl | } |
157 | cffc5818 | Blue Swirl | |
158 | c5f9864e | Andreas Färber | static uint32_t compute_all_add_xcc(CPUSPARCState *env)
|
159 | cffc5818 | Blue Swirl | { |
160 | cffc5818 | Blue Swirl | uint32_t ret; |
161 | cffc5818 | Blue Swirl | |
162 | cffc5818 | Blue Swirl | ret = get_NZ_xcc(CC_DST); |
163 | cffc5818 | Blue Swirl | ret |= get_C_add_xcc(CC_DST, CC_SRC); |
164 | cffc5818 | Blue Swirl | ret |= get_V_add_xcc(CC_DST, CC_SRC, CC_SRC2); |
165 | cffc5818 | Blue Swirl | return ret;
|
166 | cffc5818 | Blue Swirl | } |
167 | cffc5818 | Blue Swirl | |
168 | c5f9864e | Andreas Färber | static uint32_t compute_C_add_xcc(CPUSPARCState *env)
|
169 | cffc5818 | Blue Swirl | { |
170 | cffc5818 | Blue Swirl | return get_C_add_xcc(CC_DST, CC_SRC);
|
171 | cffc5818 | Blue Swirl | } |
172 | cffc5818 | Blue Swirl | #endif
|
173 | cffc5818 | Blue Swirl | |
174 | c5f9864e | Andreas Färber | static uint32_t compute_all_add(CPUSPARCState *env)
|
175 | cffc5818 | Blue Swirl | { |
176 | cffc5818 | Blue Swirl | uint32_t ret; |
177 | cffc5818 | Blue Swirl | |
178 | cffc5818 | Blue Swirl | ret = get_NZ_icc(CC_DST); |
179 | cffc5818 | Blue Swirl | ret |= get_C_add_icc(CC_DST, CC_SRC); |
180 | cffc5818 | Blue Swirl | ret |= get_V_add_icc(CC_DST, CC_SRC, CC_SRC2); |
181 | cffc5818 | Blue Swirl | return ret;
|
182 | cffc5818 | Blue Swirl | } |
183 | cffc5818 | Blue Swirl | |
184 | c5f9864e | Andreas Färber | static uint32_t compute_C_add(CPUSPARCState *env)
|
185 | cffc5818 | Blue Swirl | { |
186 | cffc5818 | Blue Swirl | return get_C_add_icc(CC_DST, CC_SRC);
|
187 | cffc5818 | Blue Swirl | } |
188 | cffc5818 | Blue Swirl | |
189 | cffc5818 | Blue Swirl | #ifdef TARGET_SPARC64
|
190 | c5f9864e | Andreas Färber | static uint32_t compute_all_addx_xcc(CPUSPARCState *env)
|
191 | cffc5818 | Blue Swirl | { |
192 | cffc5818 | Blue Swirl | uint32_t ret; |
193 | cffc5818 | Blue Swirl | |
194 | cffc5818 | Blue Swirl | ret = get_NZ_xcc(CC_DST); |
195 | cffc5818 | Blue Swirl | ret |= get_C_addx_xcc(CC_DST, CC_SRC, CC_SRC2); |
196 | cffc5818 | Blue Swirl | ret |= get_V_add_xcc(CC_DST, CC_SRC, CC_SRC2); |
197 | cffc5818 | Blue Swirl | return ret;
|
198 | cffc5818 | Blue Swirl | } |
199 | cffc5818 | Blue Swirl | |
200 | c5f9864e | Andreas Färber | static uint32_t compute_C_addx_xcc(CPUSPARCState *env)
|
201 | cffc5818 | Blue Swirl | { |
202 | cffc5818 | Blue Swirl | uint32_t ret; |
203 | cffc5818 | Blue Swirl | |
204 | cffc5818 | Blue Swirl | ret = get_C_addx_xcc(CC_DST, CC_SRC, CC_SRC2); |
205 | cffc5818 | Blue Swirl | return ret;
|
206 | cffc5818 | Blue Swirl | } |
207 | cffc5818 | Blue Swirl | #endif
|
208 | cffc5818 | Blue Swirl | |
209 | c5f9864e | Andreas Färber | static uint32_t compute_all_addx(CPUSPARCState *env)
|
210 | cffc5818 | Blue Swirl | { |
211 | cffc5818 | Blue Swirl | uint32_t ret; |
212 | cffc5818 | Blue Swirl | |
213 | cffc5818 | Blue Swirl | ret = get_NZ_icc(CC_DST); |
214 | cffc5818 | Blue Swirl | ret |= get_C_addx_icc(CC_DST, CC_SRC, CC_SRC2); |
215 | cffc5818 | Blue Swirl | ret |= get_V_add_icc(CC_DST, CC_SRC, CC_SRC2); |
216 | cffc5818 | Blue Swirl | return ret;
|
217 | cffc5818 | Blue Swirl | } |
218 | cffc5818 | Blue Swirl | |
219 | c5f9864e | Andreas Färber | static uint32_t compute_C_addx(CPUSPARCState *env)
|
220 | cffc5818 | Blue Swirl | { |
221 | cffc5818 | Blue Swirl | uint32_t ret; |
222 | cffc5818 | Blue Swirl | |
223 | cffc5818 | Blue Swirl | ret = get_C_addx_icc(CC_DST, CC_SRC, CC_SRC2); |
224 | cffc5818 | Blue Swirl | return ret;
|
225 | cffc5818 | Blue Swirl | } |
226 | cffc5818 | Blue Swirl | |
227 | cffc5818 | Blue Swirl | static inline uint32_t get_V_tag_icc(target_ulong src1, target_ulong src2) |
228 | cffc5818 | Blue Swirl | { |
229 | cffc5818 | Blue Swirl | uint32_t ret = 0;
|
230 | cffc5818 | Blue Swirl | |
231 | cffc5818 | Blue Swirl | if ((src1 | src2) & 0x3) { |
232 | cffc5818 | Blue Swirl | ret = PSR_OVF; |
233 | cffc5818 | Blue Swirl | } |
234 | cffc5818 | Blue Swirl | return ret;
|
235 | cffc5818 | Blue Swirl | } |
236 | cffc5818 | Blue Swirl | |
237 | c5f9864e | Andreas Färber | static uint32_t compute_all_tadd(CPUSPARCState *env)
|
238 | cffc5818 | Blue Swirl | { |
239 | cffc5818 | Blue Swirl | uint32_t ret; |
240 | cffc5818 | Blue Swirl | |
241 | cffc5818 | Blue Swirl | ret = get_NZ_icc(CC_DST); |
242 | cffc5818 | Blue Swirl | ret |= get_C_add_icc(CC_DST, CC_SRC); |
243 | cffc5818 | Blue Swirl | ret |= get_V_add_icc(CC_DST, CC_SRC, CC_SRC2); |
244 | cffc5818 | Blue Swirl | ret |= get_V_tag_icc(CC_SRC, CC_SRC2); |
245 | cffc5818 | Blue Swirl | return ret;
|
246 | cffc5818 | Blue Swirl | } |
247 | cffc5818 | Blue Swirl | |
248 | c5f9864e | Andreas Färber | static uint32_t compute_all_taddtv(CPUSPARCState *env)
|
249 | cffc5818 | Blue Swirl | { |
250 | cffc5818 | Blue Swirl | uint32_t ret; |
251 | cffc5818 | Blue Swirl | |
252 | cffc5818 | Blue Swirl | ret = get_NZ_icc(CC_DST); |
253 | cffc5818 | Blue Swirl | ret |= get_C_add_icc(CC_DST, CC_SRC); |
254 | cffc5818 | Blue Swirl | return ret;
|
255 | cffc5818 | Blue Swirl | } |
256 | cffc5818 | Blue Swirl | |
257 | cffc5818 | Blue Swirl | static inline uint32_t get_C_sub_icc(uint32_t src1, uint32_t src2) |
258 | cffc5818 | Blue Swirl | { |
259 | cffc5818 | Blue Swirl | uint32_t ret = 0;
|
260 | cffc5818 | Blue Swirl | |
261 | cffc5818 | Blue Swirl | if (src1 < src2) {
|
262 | cffc5818 | Blue Swirl | ret = PSR_CARRY; |
263 | cffc5818 | Blue Swirl | } |
264 | cffc5818 | Blue Swirl | return ret;
|
265 | cffc5818 | Blue Swirl | } |
266 | cffc5818 | Blue Swirl | |
267 | cffc5818 | Blue Swirl | static inline uint32_t get_C_subx_icc(uint32_t dst, uint32_t src1, |
268 | cffc5818 | Blue Swirl | uint32_t src2) |
269 | cffc5818 | Blue Swirl | { |
270 | cffc5818 | Blue Swirl | uint32_t ret = 0;
|
271 | cffc5818 | Blue Swirl | |
272 | cffc5818 | Blue Swirl | if (((~src1 & src2) | (dst & (~src1 | src2))) & (1U << 31)) { |
273 | cffc5818 | Blue Swirl | ret = PSR_CARRY; |
274 | cffc5818 | Blue Swirl | } |
275 | cffc5818 | Blue Swirl | return ret;
|
276 | cffc5818 | Blue Swirl | } |
277 | cffc5818 | Blue Swirl | |
278 | cffc5818 | Blue Swirl | static inline uint32_t get_V_sub_icc(uint32_t dst, uint32_t src1, |
279 | cffc5818 | Blue Swirl | uint32_t src2) |
280 | cffc5818 | Blue Swirl | { |
281 | cffc5818 | Blue Swirl | uint32_t ret = 0;
|
282 | cffc5818 | Blue Swirl | |
283 | cffc5818 | Blue Swirl | if (((src1 ^ src2) & (src1 ^ dst)) & (1U << 31)) { |
284 | cffc5818 | Blue Swirl | ret = PSR_OVF; |
285 | cffc5818 | Blue Swirl | } |
286 | cffc5818 | Blue Swirl | return ret;
|
287 | cffc5818 | Blue Swirl | } |
288 | cffc5818 | Blue Swirl | |
289 | cffc5818 | Blue Swirl | |
290 | cffc5818 | Blue Swirl | #ifdef TARGET_SPARC64
|
291 | cffc5818 | Blue Swirl | static inline uint32_t get_C_sub_xcc(target_ulong src1, target_ulong src2) |
292 | cffc5818 | Blue Swirl | { |
293 | cffc5818 | Blue Swirl | uint32_t ret = 0;
|
294 | cffc5818 | Blue Swirl | |
295 | cffc5818 | Blue Swirl | if (src1 < src2) {
|
296 | cffc5818 | Blue Swirl | ret = PSR_CARRY; |
297 | cffc5818 | Blue Swirl | } |
298 | cffc5818 | Blue Swirl | return ret;
|
299 | cffc5818 | Blue Swirl | } |
300 | cffc5818 | Blue Swirl | |
301 | cffc5818 | Blue Swirl | static inline uint32_t get_C_subx_xcc(target_ulong dst, target_ulong src1, |
302 | cffc5818 | Blue Swirl | target_ulong src2) |
303 | cffc5818 | Blue Swirl | { |
304 | cffc5818 | Blue Swirl | uint32_t ret = 0;
|
305 | cffc5818 | Blue Swirl | |
306 | cffc5818 | Blue Swirl | if (((~src1 & src2) | (dst & (~src1 | src2))) & (1ULL << 63)) { |
307 | cffc5818 | Blue Swirl | ret = PSR_CARRY; |
308 | cffc5818 | Blue Swirl | } |
309 | cffc5818 | Blue Swirl | return ret;
|
310 | cffc5818 | Blue Swirl | } |
311 | cffc5818 | Blue Swirl | |
312 | cffc5818 | Blue Swirl | static inline uint32_t get_V_sub_xcc(target_ulong dst, target_ulong src1, |
313 | cffc5818 | Blue Swirl | target_ulong src2) |
314 | cffc5818 | Blue Swirl | { |
315 | cffc5818 | Blue Swirl | uint32_t ret = 0;
|
316 | cffc5818 | Blue Swirl | |
317 | cffc5818 | Blue Swirl | if (((src1 ^ src2) & (src1 ^ dst)) & (1ULL << 63)) { |
318 | cffc5818 | Blue Swirl | ret = PSR_OVF; |
319 | cffc5818 | Blue Swirl | } |
320 | cffc5818 | Blue Swirl | return ret;
|
321 | cffc5818 | Blue Swirl | } |
322 | cffc5818 | Blue Swirl | |
323 | c5f9864e | Andreas Färber | static uint32_t compute_all_sub_xcc(CPUSPARCState *env)
|
324 | cffc5818 | Blue Swirl | { |
325 | cffc5818 | Blue Swirl | uint32_t ret; |
326 | cffc5818 | Blue Swirl | |
327 | cffc5818 | Blue Swirl | ret = get_NZ_xcc(CC_DST); |
328 | cffc5818 | Blue Swirl | ret |= get_C_sub_xcc(CC_SRC, CC_SRC2); |
329 | cffc5818 | Blue Swirl | ret |= get_V_sub_xcc(CC_DST, CC_SRC, CC_SRC2); |
330 | cffc5818 | Blue Swirl | return ret;
|
331 | cffc5818 | Blue Swirl | } |
332 | cffc5818 | Blue Swirl | |
333 | c5f9864e | Andreas Färber | static uint32_t compute_C_sub_xcc(CPUSPARCState *env)
|
334 | cffc5818 | Blue Swirl | { |
335 | cffc5818 | Blue Swirl | return get_C_sub_xcc(CC_SRC, CC_SRC2);
|
336 | cffc5818 | Blue Swirl | } |
337 | cffc5818 | Blue Swirl | #endif
|
338 | cffc5818 | Blue Swirl | |
339 | c5f9864e | Andreas Färber | static uint32_t compute_all_sub(CPUSPARCState *env)
|
340 | cffc5818 | Blue Swirl | { |
341 | cffc5818 | Blue Swirl | uint32_t ret; |
342 | cffc5818 | Blue Swirl | |
343 | cffc5818 | Blue Swirl | ret = get_NZ_icc(CC_DST); |
344 | cffc5818 | Blue Swirl | ret |= get_C_sub_icc(CC_SRC, CC_SRC2); |
345 | cffc5818 | Blue Swirl | ret |= get_V_sub_icc(CC_DST, CC_SRC, CC_SRC2); |
346 | cffc5818 | Blue Swirl | return ret;
|
347 | cffc5818 | Blue Swirl | } |
348 | cffc5818 | Blue Swirl | |
349 | c5f9864e | Andreas Färber | static uint32_t compute_C_sub(CPUSPARCState *env)
|
350 | cffc5818 | Blue Swirl | { |
351 | cffc5818 | Blue Swirl | return get_C_sub_icc(CC_SRC, CC_SRC2);
|
352 | cffc5818 | Blue Swirl | } |
353 | cffc5818 | Blue Swirl | |
354 | cffc5818 | Blue Swirl | #ifdef TARGET_SPARC64
|
355 | c5f9864e | Andreas Färber | static uint32_t compute_all_subx_xcc(CPUSPARCState *env)
|
356 | cffc5818 | Blue Swirl | { |
357 | cffc5818 | Blue Swirl | uint32_t ret; |
358 | cffc5818 | Blue Swirl | |
359 | cffc5818 | Blue Swirl | ret = get_NZ_xcc(CC_DST); |
360 | cffc5818 | Blue Swirl | ret |= get_C_subx_xcc(CC_DST, CC_SRC, CC_SRC2); |
361 | cffc5818 | Blue Swirl | ret |= get_V_sub_xcc(CC_DST, CC_SRC, CC_SRC2); |
362 | cffc5818 | Blue Swirl | return ret;
|
363 | cffc5818 | Blue Swirl | } |
364 | cffc5818 | Blue Swirl | |
365 | c5f9864e | Andreas Färber | static uint32_t compute_C_subx_xcc(CPUSPARCState *env)
|
366 | cffc5818 | Blue Swirl | { |
367 | cffc5818 | Blue Swirl | uint32_t ret; |
368 | cffc5818 | Blue Swirl | |
369 | cffc5818 | Blue Swirl | ret = get_C_subx_xcc(CC_DST, CC_SRC, CC_SRC2); |
370 | cffc5818 | Blue Swirl | return ret;
|
371 | cffc5818 | Blue Swirl | } |
372 | cffc5818 | Blue Swirl | #endif
|
373 | cffc5818 | Blue Swirl | |
374 | c5f9864e | Andreas Färber | static uint32_t compute_all_subx(CPUSPARCState *env)
|
375 | cffc5818 | Blue Swirl | { |
376 | cffc5818 | Blue Swirl | uint32_t ret; |
377 | cffc5818 | Blue Swirl | |
378 | cffc5818 | Blue Swirl | ret = get_NZ_icc(CC_DST); |
379 | cffc5818 | Blue Swirl | ret |= get_C_subx_icc(CC_DST, CC_SRC, CC_SRC2); |
380 | cffc5818 | Blue Swirl | ret |= get_V_sub_icc(CC_DST, CC_SRC, CC_SRC2); |
381 | cffc5818 | Blue Swirl | return ret;
|
382 | cffc5818 | Blue Swirl | } |
383 | cffc5818 | Blue Swirl | |
384 | c5f9864e | Andreas Färber | static uint32_t compute_C_subx(CPUSPARCState *env)
|
385 | cffc5818 | Blue Swirl | { |
386 | cffc5818 | Blue Swirl | uint32_t ret; |
387 | cffc5818 | Blue Swirl | |
388 | cffc5818 | Blue Swirl | ret = get_C_subx_icc(CC_DST, CC_SRC, CC_SRC2); |
389 | cffc5818 | Blue Swirl | return ret;
|
390 | cffc5818 | Blue Swirl | } |
391 | cffc5818 | Blue Swirl | |
392 | c5f9864e | Andreas Färber | static uint32_t compute_all_tsub(CPUSPARCState *env)
|
393 | cffc5818 | Blue Swirl | { |
394 | cffc5818 | Blue Swirl | uint32_t ret; |
395 | cffc5818 | Blue Swirl | |
396 | cffc5818 | Blue Swirl | ret = get_NZ_icc(CC_DST); |
397 | cffc5818 | Blue Swirl | ret |= get_C_sub_icc(CC_SRC, CC_SRC2); |
398 | cffc5818 | Blue Swirl | ret |= get_V_sub_icc(CC_DST, CC_SRC, CC_SRC2); |
399 | cffc5818 | Blue Swirl | ret |= get_V_tag_icc(CC_SRC, CC_SRC2); |
400 | cffc5818 | Blue Swirl | return ret;
|
401 | cffc5818 | Blue Swirl | } |
402 | cffc5818 | Blue Swirl | |
403 | c5f9864e | Andreas Färber | static uint32_t compute_all_tsubtv(CPUSPARCState *env)
|
404 | cffc5818 | Blue Swirl | { |
405 | cffc5818 | Blue Swirl | uint32_t ret; |
406 | cffc5818 | Blue Swirl | |
407 | cffc5818 | Blue Swirl | ret = get_NZ_icc(CC_DST); |
408 | cffc5818 | Blue Swirl | ret |= get_C_sub_icc(CC_SRC, CC_SRC2); |
409 | cffc5818 | Blue Swirl | return ret;
|
410 | cffc5818 | Blue Swirl | } |
411 | cffc5818 | Blue Swirl | |
412 | c5f9864e | Andreas Färber | static uint32_t compute_all_logic(CPUSPARCState *env)
|
413 | cffc5818 | Blue Swirl | { |
414 | cffc5818 | Blue Swirl | return get_NZ_icc(CC_DST);
|
415 | cffc5818 | Blue Swirl | } |
416 | cffc5818 | Blue Swirl | |
417 | c5f9864e | Andreas Färber | static uint32_t compute_C_logic(CPUSPARCState *env)
|
418 | cffc5818 | Blue Swirl | { |
419 | cffc5818 | Blue Swirl | return 0; |
420 | cffc5818 | Blue Swirl | } |
421 | cffc5818 | Blue Swirl | |
422 | cffc5818 | Blue Swirl | #ifdef TARGET_SPARC64
|
423 | c5f9864e | Andreas Färber | static uint32_t compute_all_logic_xcc(CPUSPARCState *env)
|
424 | cffc5818 | Blue Swirl | { |
425 | cffc5818 | Blue Swirl | return get_NZ_xcc(CC_DST);
|
426 | cffc5818 | Blue Swirl | } |
427 | cffc5818 | Blue Swirl | #endif
|
428 | cffc5818 | Blue Swirl | |
429 | cffc5818 | Blue Swirl | typedef struct CCTable { |
430 | c5f9864e | Andreas Färber | uint32_t (*compute_all)(CPUSPARCState *env); /* return all the flags */
|
431 | c5f9864e | Andreas Färber | uint32_t (*compute_c)(CPUSPARCState *env); /* return the C flag */
|
432 | cffc5818 | Blue Swirl | } CCTable; |
433 | cffc5818 | Blue Swirl | |
434 | cffc5818 | Blue Swirl | static const CCTable icc_table[CC_OP_NB] = { |
435 | cffc5818 | Blue Swirl | /* CC_OP_DYNAMIC should never happen */
|
436 | cffc5818 | Blue Swirl | [CC_OP_FLAGS] = { compute_all_flags, compute_C_flags }, |
437 | cffc5818 | Blue Swirl | [CC_OP_DIV] = { compute_all_div, compute_C_div }, |
438 | cffc5818 | Blue Swirl | [CC_OP_ADD] = { compute_all_add, compute_C_add }, |
439 | cffc5818 | Blue Swirl | [CC_OP_ADDX] = { compute_all_addx, compute_C_addx }, |
440 | cffc5818 | Blue Swirl | [CC_OP_TADD] = { compute_all_tadd, compute_C_add }, |
441 | cffc5818 | Blue Swirl | [CC_OP_TADDTV] = { compute_all_taddtv, compute_C_add }, |
442 | cffc5818 | Blue Swirl | [CC_OP_SUB] = { compute_all_sub, compute_C_sub }, |
443 | cffc5818 | Blue Swirl | [CC_OP_SUBX] = { compute_all_subx, compute_C_subx }, |
444 | cffc5818 | Blue Swirl | [CC_OP_TSUB] = { compute_all_tsub, compute_C_sub }, |
445 | cffc5818 | Blue Swirl | [CC_OP_TSUBTV] = { compute_all_tsubtv, compute_C_sub }, |
446 | cffc5818 | Blue Swirl | [CC_OP_LOGIC] = { compute_all_logic, compute_C_logic }, |
447 | cffc5818 | Blue Swirl | }; |
448 | cffc5818 | Blue Swirl | |
449 | cffc5818 | Blue Swirl | #ifdef TARGET_SPARC64
|
450 | cffc5818 | Blue Swirl | static const CCTable xcc_table[CC_OP_NB] = { |
451 | cffc5818 | Blue Swirl | /* CC_OP_DYNAMIC should never happen */
|
452 | cffc5818 | Blue Swirl | [CC_OP_FLAGS] = { compute_all_flags_xcc, compute_C_flags_xcc }, |
453 | cffc5818 | Blue Swirl | [CC_OP_DIV] = { compute_all_logic_xcc, compute_C_logic }, |
454 | cffc5818 | Blue Swirl | [CC_OP_ADD] = { compute_all_add_xcc, compute_C_add_xcc }, |
455 | cffc5818 | Blue Swirl | [CC_OP_ADDX] = { compute_all_addx_xcc, compute_C_addx_xcc }, |
456 | cffc5818 | Blue Swirl | [CC_OP_TADD] = { compute_all_add_xcc, compute_C_add_xcc }, |
457 | cffc5818 | Blue Swirl | [CC_OP_TADDTV] = { compute_all_add_xcc, compute_C_add_xcc }, |
458 | cffc5818 | Blue Swirl | [CC_OP_SUB] = { compute_all_sub_xcc, compute_C_sub_xcc }, |
459 | cffc5818 | Blue Swirl | [CC_OP_SUBX] = { compute_all_subx_xcc, compute_C_subx_xcc }, |
460 | cffc5818 | Blue Swirl | [CC_OP_TSUB] = { compute_all_sub_xcc, compute_C_sub_xcc }, |
461 | cffc5818 | Blue Swirl | [CC_OP_TSUBTV] = { compute_all_sub_xcc, compute_C_sub_xcc }, |
462 | cffc5818 | Blue Swirl | [CC_OP_LOGIC] = { compute_all_logic_xcc, compute_C_logic }, |
463 | cffc5818 | Blue Swirl | }; |
464 | cffc5818 | Blue Swirl | #endif
|
465 | cffc5818 | Blue Swirl | |
466 | c5f9864e | Andreas Färber | void helper_compute_psr(CPUSPARCState *env)
|
467 | cffc5818 | Blue Swirl | { |
468 | cffc5818 | Blue Swirl | uint32_t new_psr; |
469 | cffc5818 | Blue Swirl | |
470 | 2ffd9176 | Blue Swirl | new_psr = icc_table[CC_OP].compute_all(env); |
471 | cffc5818 | Blue Swirl | env->psr = new_psr; |
472 | cffc5818 | Blue Swirl | #ifdef TARGET_SPARC64
|
473 | 2ffd9176 | Blue Swirl | new_psr = xcc_table[CC_OP].compute_all(env); |
474 | cffc5818 | Blue Swirl | env->xcc = new_psr; |
475 | cffc5818 | Blue Swirl | #endif
|
476 | cffc5818 | Blue Swirl | CC_OP = CC_OP_FLAGS; |
477 | cffc5818 | Blue Swirl | } |
478 | cffc5818 | Blue Swirl | |
479 | c5f9864e | Andreas Färber | uint32_t helper_compute_C_icc(CPUSPARCState *env) |
480 | cffc5818 | Blue Swirl | { |
481 | cffc5818 | Blue Swirl | uint32_t ret; |
482 | cffc5818 | Blue Swirl | |
483 | 2ffd9176 | Blue Swirl | ret = icc_table[CC_OP].compute_c(env) >> PSR_CARRY_SHIFT; |
484 | cffc5818 | Blue Swirl | return ret;
|
485 | cffc5818 | Blue Swirl | } |