Statistics
| Branch: | Revision:

root / target-arm / op_helper.c @ c9c3c80a

History | View | Annotate | Download (9.6 kB)

1 b7bcbe95 bellard
/*
2 b7bcbe95 bellard
 *  ARM helper routines
3 5fafdf24 ths
 *
4 9ee6e8bb pbrook
 *  Copyright (c) 2005-2007 CodeSourcery, LLC
5 b7bcbe95 bellard
 *
6 b7bcbe95 bellard
 * This library is free software; you can redistribute it and/or
7 b7bcbe95 bellard
 * modify it under the terms of the GNU Lesser General Public
8 b7bcbe95 bellard
 * License as published by the Free Software Foundation; either
9 b7bcbe95 bellard
 * version 2 of the License, or (at your option) any later version.
10 b7bcbe95 bellard
 *
11 b7bcbe95 bellard
 * This library is distributed in the hope that it will be useful,
12 b7bcbe95 bellard
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 b7bcbe95 bellard
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 b7bcbe95 bellard
 * Lesser General Public License for more details.
15 b7bcbe95 bellard
 *
16 b7bcbe95 bellard
 * You should have received a copy of the GNU Lesser General Public
17 8167ee88 Blue Swirl
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 b7bcbe95 bellard
 */
19 3e457172 Blue Swirl
#include "cpu.h"
20 3e457172 Blue Swirl
#include "dyngen-exec.h"
21 7b59220e Lluís
#include "helper.h"
22 b7bcbe95 bellard
23 ad69471c pbrook
#define SIGNBIT (uint32_t)0x80000000
24 ad69471c pbrook
#define SIGNBIT64 ((uint64_t)1 << 63)
25 ad69471c pbrook
26 3e457172 Blue Swirl
#if !defined(CONFIG_USER_ONLY)
27 3e457172 Blue Swirl
static void raise_exception(int tt)
28 b7bcbe95 bellard
{
29 b7bcbe95 bellard
    env->exception_index = tt;
30 1162c041 Blue Swirl
    cpu_loop_exit(env);
31 b7bcbe95 bellard
}
32 3e457172 Blue Swirl
#endif
33 b7bcbe95 bellard
34 8f8e3aa4 pbrook
uint32_t HELPER(neon_tbl)(uint32_t ireg, uint32_t def,
35 8f8e3aa4 pbrook
                          uint32_t rn, uint32_t maxindex)
36 9ee6e8bb pbrook
{
37 9ee6e8bb pbrook
    uint32_t val;
38 9ee6e8bb pbrook
    uint32_t tmp;
39 9ee6e8bb pbrook
    int index;
40 9ee6e8bb pbrook
    int shift;
41 9ee6e8bb pbrook
    uint64_t *table;
42 9ee6e8bb pbrook
    table = (uint64_t *)&env->vfp.regs[rn];
43 9ee6e8bb pbrook
    val = 0;
44 9ee6e8bb pbrook
    for (shift = 0; shift < 32; shift += 8) {
45 8f8e3aa4 pbrook
        index = (ireg >> shift) & 0xff;
46 8f8e3aa4 pbrook
        if (index < maxindex) {
47 3018f259 pbrook
            tmp = (table[index >> 3] >> ((index & 7) << 3)) & 0xff;
48 9ee6e8bb pbrook
            val |= tmp << shift;
49 9ee6e8bb pbrook
        } else {
50 8f8e3aa4 pbrook
            val |= def & (0xff << shift);
51 9ee6e8bb pbrook
        }
52 9ee6e8bb pbrook
    }
53 8f8e3aa4 pbrook
    return val;
54 9ee6e8bb pbrook
}
55 9ee6e8bb pbrook
56 b5ff1b31 bellard
#if !defined(CONFIG_USER_ONLY)
57 b5ff1b31 bellard
58 3e457172 Blue Swirl
#include "softmmu_exec.h"
59 3e457172 Blue Swirl
60 b5ff1b31 bellard
#define MMUSUFFIX _mmu
61 b5ff1b31 bellard
62 b5ff1b31 bellard
#define SHIFT 0
63 b5ff1b31 bellard
#include "softmmu_template.h"
64 b5ff1b31 bellard
65 b5ff1b31 bellard
#define SHIFT 1
66 b5ff1b31 bellard
#include "softmmu_template.h"
67 b5ff1b31 bellard
68 b5ff1b31 bellard
#define SHIFT 2
69 b5ff1b31 bellard
#include "softmmu_template.h"
70 b5ff1b31 bellard
71 b5ff1b31 bellard
#define SHIFT 3
72 b5ff1b31 bellard
#include "softmmu_template.h"
73 b5ff1b31 bellard
74 b5ff1b31 bellard
/* try to fill the TLB and return an exception if error. If retaddr is
75 b5ff1b31 bellard
   NULL, it means that the function was called in C code (i.e. not
76 b5ff1b31 bellard
   from generated code or from helper.c) */
77 b5ff1b31 bellard
/* XXX: fix it to restore all registers */
78 bccd9ec5 Blue Swirl
void tlb_fill(CPUState *env1, target_ulong addr, int is_write, int mmu_idx,
79 bccd9ec5 Blue Swirl
              void *retaddr)
80 b5ff1b31 bellard
{
81 b5ff1b31 bellard
    TranslationBlock *tb;
82 b5ff1b31 bellard
    CPUState *saved_env;
83 44f8625d bellard
    unsigned long pc;
84 b5ff1b31 bellard
    int ret;
85 b5ff1b31 bellard
86 b5ff1b31 bellard
    saved_env = env;
87 6e19a137 Blue Swirl
    env = env1;
88 97b348e7 Blue Swirl
    ret = cpu_arm_handle_mmu_fault(env, addr, is_write, mmu_idx);
89 551bd27f ths
    if (unlikely(ret)) {
90 b5ff1b31 bellard
        if (retaddr) {
91 b5ff1b31 bellard
            /* now we have a real cpu fault */
92 44f8625d bellard
            pc = (unsigned long)retaddr;
93 b5ff1b31 bellard
            tb = tb_find_pc(pc);
94 b5ff1b31 bellard
            if (tb) {
95 b5ff1b31 bellard
                /* the PC is inside the translated code. It means that we have
96 b5ff1b31 bellard
                   a virtual CPU fault */
97 618ba8e6 Stefan Weil
                cpu_restore_state(tb, env, pc);
98 b5ff1b31 bellard
            }
99 b5ff1b31 bellard
        }
100 b5ff1b31 bellard
        raise_exception(env->exception_index);
101 b5ff1b31 bellard
    }
102 b5ff1b31 bellard
    env = saved_env;
103 b5ff1b31 bellard
}
104 b5ff1b31 bellard
#endif
105 1497c961 pbrook
106 ad69471c pbrook
/* FIXME: Pass an axplicit pointer to QF to CPUState, and move saturating
107 ad69471c pbrook
   instructions into helper.c  */
108 1497c961 pbrook
uint32_t HELPER(add_setq)(uint32_t a, uint32_t b)
109 1497c961 pbrook
{
110 1497c961 pbrook
    uint32_t res = a + b;
111 1497c961 pbrook
    if (((res ^ a) & SIGNBIT) && !((a ^ b) & SIGNBIT))
112 1497c961 pbrook
        env->QF = 1;
113 1497c961 pbrook
    return res;
114 1497c961 pbrook
}
115 1497c961 pbrook
116 1497c961 pbrook
uint32_t HELPER(add_saturate)(uint32_t a, uint32_t b)
117 1497c961 pbrook
{
118 1497c961 pbrook
    uint32_t res = a + b;
119 1497c961 pbrook
    if (((res ^ a) & SIGNBIT) && !((a ^ b) & SIGNBIT)) {
120 1497c961 pbrook
        env->QF = 1;
121 1497c961 pbrook
        res = ~(((int32_t)a >> 31) ^ SIGNBIT);
122 1497c961 pbrook
    }
123 1497c961 pbrook
    return res;
124 1497c961 pbrook
}
125 1497c961 pbrook
126 1497c961 pbrook
uint32_t HELPER(sub_saturate)(uint32_t a, uint32_t b)
127 1497c961 pbrook
{
128 1497c961 pbrook
    uint32_t res = a - b;
129 1497c961 pbrook
    if (((res ^ a) & SIGNBIT) && ((a ^ b) & SIGNBIT)) {
130 1497c961 pbrook
        env->QF = 1;
131 1497c961 pbrook
        res = ~(((int32_t)a >> 31) ^ SIGNBIT);
132 1497c961 pbrook
    }
133 1497c961 pbrook
    return res;
134 1497c961 pbrook
}
135 1497c961 pbrook
136 1497c961 pbrook
uint32_t HELPER(double_saturate)(int32_t val)
137 1497c961 pbrook
{
138 1497c961 pbrook
    uint32_t res;
139 1497c961 pbrook
    if (val >= 0x40000000) {
140 1497c961 pbrook
        res = ~SIGNBIT;
141 1497c961 pbrook
        env->QF = 1;
142 1497c961 pbrook
    } else if (val <= (int32_t)0xc0000000) {
143 1497c961 pbrook
        res = SIGNBIT;
144 1497c961 pbrook
        env->QF = 1;
145 1497c961 pbrook
    } else {
146 1497c961 pbrook
        res = val << 1;
147 1497c961 pbrook
    }
148 1497c961 pbrook
    return res;
149 1497c961 pbrook
}
150 1497c961 pbrook
151 1497c961 pbrook
uint32_t HELPER(add_usaturate)(uint32_t a, uint32_t b)
152 1497c961 pbrook
{
153 1497c961 pbrook
    uint32_t res = a + b;
154 1497c961 pbrook
    if (res < a) {
155 1497c961 pbrook
        env->QF = 1;
156 1497c961 pbrook
        res = ~0;
157 1497c961 pbrook
    }
158 1497c961 pbrook
    return res;
159 1497c961 pbrook
}
160 1497c961 pbrook
161 1497c961 pbrook
uint32_t HELPER(sub_usaturate)(uint32_t a, uint32_t b)
162 1497c961 pbrook
{
163 1497c961 pbrook
    uint32_t res = a - b;
164 1497c961 pbrook
    if (res > a) {
165 1497c961 pbrook
        env->QF = 1;
166 1497c961 pbrook
        res = 0;
167 1497c961 pbrook
    }
168 1497c961 pbrook
    return res;
169 1497c961 pbrook
}
170 1497c961 pbrook
171 6ddbc6e4 pbrook
/* Signed saturation.  */
172 6ddbc6e4 pbrook
static inline uint32_t do_ssat(int32_t val, int shift)
173 6ddbc6e4 pbrook
{
174 6ddbc6e4 pbrook
    int32_t top;
175 6ddbc6e4 pbrook
    uint32_t mask;
176 6ddbc6e4 pbrook
177 6ddbc6e4 pbrook
    top = val >> shift;
178 6ddbc6e4 pbrook
    mask = (1u << shift) - 1;
179 6ddbc6e4 pbrook
    if (top > 0) {
180 6ddbc6e4 pbrook
        env->QF = 1;
181 6ddbc6e4 pbrook
        return mask;
182 6ddbc6e4 pbrook
    } else if (top < -1) {
183 6ddbc6e4 pbrook
        env->QF = 1;
184 6ddbc6e4 pbrook
        return ~mask;
185 6ddbc6e4 pbrook
    }
186 6ddbc6e4 pbrook
    return val;
187 6ddbc6e4 pbrook
}
188 6ddbc6e4 pbrook
189 6ddbc6e4 pbrook
/* Unsigned saturation.  */
190 6ddbc6e4 pbrook
static inline uint32_t do_usat(int32_t val, int shift)
191 6ddbc6e4 pbrook
{
192 6ddbc6e4 pbrook
    uint32_t max;
193 6ddbc6e4 pbrook
194 6ddbc6e4 pbrook
    max = (1u << shift) - 1;
195 6ddbc6e4 pbrook
    if (val < 0) {
196 6ddbc6e4 pbrook
        env->QF = 1;
197 6ddbc6e4 pbrook
        return 0;
198 6ddbc6e4 pbrook
    } else if (val > max) {
199 6ddbc6e4 pbrook
        env->QF = 1;
200 6ddbc6e4 pbrook
        return max;
201 6ddbc6e4 pbrook
    }
202 6ddbc6e4 pbrook
    return val;
203 6ddbc6e4 pbrook
}
204 6ddbc6e4 pbrook
205 6ddbc6e4 pbrook
/* Signed saturate.  */
206 6ddbc6e4 pbrook
uint32_t HELPER(ssat)(uint32_t x, uint32_t shift)
207 6ddbc6e4 pbrook
{
208 6ddbc6e4 pbrook
    return do_ssat(x, shift);
209 6ddbc6e4 pbrook
}
210 6ddbc6e4 pbrook
211 6ddbc6e4 pbrook
/* Dual halfword signed saturate.  */
212 6ddbc6e4 pbrook
uint32_t HELPER(ssat16)(uint32_t x, uint32_t shift)
213 6ddbc6e4 pbrook
{
214 6ddbc6e4 pbrook
    uint32_t res;
215 6ddbc6e4 pbrook
216 6ddbc6e4 pbrook
    res = (uint16_t)do_ssat((int16_t)x, shift);
217 6ddbc6e4 pbrook
    res |= do_ssat(((int32_t)x) >> 16, shift) << 16;
218 6ddbc6e4 pbrook
    return res;
219 6ddbc6e4 pbrook
}
220 6ddbc6e4 pbrook
221 6ddbc6e4 pbrook
/* Unsigned saturate.  */
222 6ddbc6e4 pbrook
uint32_t HELPER(usat)(uint32_t x, uint32_t shift)
223 6ddbc6e4 pbrook
{
224 6ddbc6e4 pbrook
    return do_usat(x, shift);
225 6ddbc6e4 pbrook
}
226 6ddbc6e4 pbrook
227 6ddbc6e4 pbrook
/* Dual halfword unsigned saturate.  */
228 6ddbc6e4 pbrook
uint32_t HELPER(usat16)(uint32_t x, uint32_t shift)
229 6ddbc6e4 pbrook
{
230 6ddbc6e4 pbrook
    uint32_t res;
231 6ddbc6e4 pbrook
232 6ddbc6e4 pbrook
    res = (uint16_t)do_usat((int16_t)x, shift);
233 6ddbc6e4 pbrook
    res |= do_usat(((int32_t)x) >> 16, shift) << 16;
234 6ddbc6e4 pbrook
    return res;
235 6ddbc6e4 pbrook
}
236 d9ba4830 pbrook
237 d9ba4830 pbrook
void HELPER(wfi)(void)
238 d9ba4830 pbrook
{
239 d9ba4830 pbrook
    env->exception_index = EXCP_HLT;
240 d9ba4830 pbrook
    env->halted = 1;
241 1162c041 Blue Swirl
    cpu_loop_exit(env);
242 d9ba4830 pbrook
}
243 d9ba4830 pbrook
244 d9ba4830 pbrook
void HELPER(exception)(uint32_t excp)
245 d9ba4830 pbrook
{
246 d9ba4830 pbrook
    env->exception_index = excp;
247 1162c041 Blue Swirl
    cpu_loop_exit(env);
248 d9ba4830 pbrook
}
249 d9ba4830 pbrook
250 d9ba4830 pbrook
uint32_t HELPER(cpsr_read)(void)
251 d9ba4830 pbrook
{
252 d9ba4830 pbrook
    return cpsr_read(env) & ~CPSR_EXEC;
253 d9ba4830 pbrook
}
254 d9ba4830 pbrook
255 d9ba4830 pbrook
void HELPER(cpsr_write)(uint32_t val, uint32_t mask)
256 d9ba4830 pbrook
{
257 d9ba4830 pbrook
    cpsr_write(env, val, mask);
258 d9ba4830 pbrook
}
259 b0109805 pbrook
260 b0109805 pbrook
/* Access to user mode registers from privileged modes.  */
261 b0109805 pbrook
uint32_t HELPER(get_user_reg)(uint32_t regno)
262 b0109805 pbrook
{
263 b0109805 pbrook
    uint32_t val;
264 b0109805 pbrook
265 b0109805 pbrook
    if (regno == 13) {
266 b0109805 pbrook
        val = env->banked_r13[0];
267 b0109805 pbrook
    } else if (regno == 14) {
268 b0109805 pbrook
        val = env->banked_r14[0];
269 b0109805 pbrook
    } else if (regno >= 8
270 b0109805 pbrook
               && (env->uncached_cpsr & 0x1f) == ARM_CPU_MODE_FIQ) {
271 b0109805 pbrook
        val = env->usr_regs[regno - 8];
272 b0109805 pbrook
    } else {
273 b0109805 pbrook
        val = env->regs[regno];
274 b0109805 pbrook
    }
275 b0109805 pbrook
    return val;
276 b0109805 pbrook
}
277 b0109805 pbrook
278 b0109805 pbrook
void HELPER(set_user_reg)(uint32_t regno, uint32_t val)
279 b0109805 pbrook
{
280 b0109805 pbrook
    if (regno == 13) {
281 b0109805 pbrook
        env->banked_r13[0] = val;
282 b0109805 pbrook
    } else if (regno == 14) {
283 b0109805 pbrook
        env->banked_r14[0] = val;
284 b0109805 pbrook
    } else if (regno >= 8
285 b0109805 pbrook
               && (env->uncached_cpsr & 0x1f) == ARM_CPU_MODE_FIQ) {
286 b0109805 pbrook
        env->usr_regs[regno - 8] = val;
287 b0109805 pbrook
    } else {
288 b0109805 pbrook
        env->regs[regno] = val;
289 b0109805 pbrook
    }
290 b0109805 pbrook
}
291 b0109805 pbrook
292 8984bd2e pbrook
/* ??? Flag setting arithmetic is awkward because we need to do comparisons.
293 8984bd2e pbrook
   The only way to do that in TCG is a conditional branch, which clobbers
294 8984bd2e pbrook
   all our temporaries.  For now implement these as helper functions.  */
295 8984bd2e pbrook
296 8984bd2e pbrook
uint32_t HELPER (add_cc)(uint32_t a, uint32_t b)
297 8984bd2e pbrook
{
298 8984bd2e pbrook
    uint32_t result;
299 37f9ba46 aurel32
    result = a + b;
300 6fbe23d5 pbrook
    env->NF = env->ZF = result;
301 8984bd2e pbrook
    env->CF = result < a;
302 8984bd2e pbrook
    env->VF = (a ^ b ^ -1) & (a ^ result);
303 8984bd2e pbrook
    return result;
304 8984bd2e pbrook
}
305 8984bd2e pbrook
306 8984bd2e pbrook
uint32_t HELPER(adc_cc)(uint32_t a, uint32_t b)
307 8984bd2e pbrook
{
308 8984bd2e pbrook
    uint32_t result;
309 8984bd2e pbrook
    if (!env->CF) {
310 8984bd2e pbrook
        result = a + b;
311 8984bd2e pbrook
        env->CF = result < a;
312 8984bd2e pbrook
    } else {
313 8984bd2e pbrook
        result = a + b + 1;
314 8984bd2e pbrook
        env->CF = result <= a;
315 8984bd2e pbrook
    }
316 8984bd2e pbrook
    env->VF = (a ^ b ^ -1) & (a ^ result);
317 6fbe23d5 pbrook
    env->NF = env->ZF = result;
318 8984bd2e pbrook
    return result;
319 8984bd2e pbrook
}
320 8984bd2e pbrook
321 8984bd2e pbrook
uint32_t HELPER(sub_cc)(uint32_t a, uint32_t b)
322 8984bd2e pbrook
{
323 8984bd2e pbrook
    uint32_t result;
324 8984bd2e pbrook
    result = a - b;
325 6fbe23d5 pbrook
    env->NF = env->ZF = result;
326 8984bd2e pbrook
    env->CF = a >= b;
327 8984bd2e pbrook
    env->VF = (a ^ b) & (a ^ result);
328 8984bd2e pbrook
    return result;
329 8984bd2e pbrook
}
330 8984bd2e pbrook
331 8984bd2e pbrook
uint32_t HELPER(sbc_cc)(uint32_t a, uint32_t b)
332 8984bd2e pbrook
{
333 8984bd2e pbrook
    uint32_t result;
334 8984bd2e pbrook
    if (!env->CF) {
335 8984bd2e pbrook
        result = a - b - 1;
336 8984bd2e pbrook
        env->CF = a > b;
337 8984bd2e pbrook
    } else {
338 8984bd2e pbrook
        result = a - b;
339 8984bd2e pbrook
        env->CF = a >= b;
340 8984bd2e pbrook
    }
341 8984bd2e pbrook
    env->VF = (a ^ b) & (a ^ result);
342 6fbe23d5 pbrook
    env->NF = env->ZF = result;
343 8984bd2e pbrook
    return result;
344 8984bd2e pbrook
}
345 8984bd2e pbrook
346 8984bd2e pbrook
/* Similarly for variable shift instructions.  */
347 8984bd2e pbrook
348 8984bd2e pbrook
uint32_t HELPER(shl)(uint32_t x, uint32_t i)
349 8984bd2e pbrook
{
350 8984bd2e pbrook
    int shift = i & 0xff;
351 8984bd2e pbrook
    if (shift >= 32)
352 8984bd2e pbrook
        return 0;
353 8984bd2e pbrook
    return x << shift;
354 8984bd2e pbrook
}
355 8984bd2e pbrook
356 8984bd2e pbrook
uint32_t HELPER(shr)(uint32_t x, uint32_t i)
357 8984bd2e pbrook
{
358 8984bd2e pbrook
    int shift = i & 0xff;
359 8984bd2e pbrook
    if (shift >= 32)
360 8984bd2e pbrook
        return 0;
361 8984bd2e pbrook
    return (uint32_t)x >> shift;
362 8984bd2e pbrook
}
363 8984bd2e pbrook
364 8984bd2e pbrook
uint32_t HELPER(sar)(uint32_t x, uint32_t i)
365 8984bd2e pbrook
{
366 8984bd2e pbrook
    int shift = i & 0xff;
367 8984bd2e pbrook
    if (shift >= 32)
368 8984bd2e pbrook
        shift = 31;
369 8984bd2e pbrook
    return (int32_t)x >> shift;
370 8984bd2e pbrook
}
371 8984bd2e pbrook
372 8984bd2e pbrook
uint32_t HELPER(shl_cc)(uint32_t x, uint32_t i)
373 8984bd2e pbrook
{
374 8984bd2e pbrook
    int shift = i & 0xff;
375 8984bd2e pbrook
    if (shift >= 32) {
376 8984bd2e pbrook
        if (shift == 32)
377 8984bd2e pbrook
            env->CF = x & 1;
378 8984bd2e pbrook
        else
379 8984bd2e pbrook
            env->CF = 0;
380 8984bd2e pbrook
        return 0;
381 8984bd2e pbrook
    } else if (shift != 0) {
382 8984bd2e pbrook
        env->CF = (x >> (32 - shift)) & 1;
383 8984bd2e pbrook
        return x << shift;
384 8984bd2e pbrook
    }
385 8984bd2e pbrook
    return x;
386 8984bd2e pbrook
}
387 8984bd2e pbrook
388 8984bd2e pbrook
uint32_t HELPER(shr_cc)(uint32_t x, uint32_t i)
389 8984bd2e pbrook
{
390 8984bd2e pbrook
    int shift = i & 0xff;
391 8984bd2e pbrook
    if (shift >= 32) {
392 8984bd2e pbrook
        if (shift == 32)
393 8984bd2e pbrook
            env->CF = (x >> 31) & 1;
394 8984bd2e pbrook
        else
395 8984bd2e pbrook
            env->CF = 0;
396 8984bd2e pbrook
        return 0;
397 8984bd2e pbrook
    } else if (shift != 0) {
398 8984bd2e pbrook
        env->CF = (x >> (shift - 1)) & 1;
399 8984bd2e pbrook
        return x >> shift;
400 8984bd2e pbrook
    }
401 8984bd2e pbrook
    return x;
402 8984bd2e pbrook
}
403 8984bd2e pbrook
404 8984bd2e pbrook
uint32_t HELPER(sar_cc)(uint32_t x, uint32_t i)
405 8984bd2e pbrook
{
406 8984bd2e pbrook
    int shift = i & 0xff;
407 8984bd2e pbrook
    if (shift >= 32) {
408 8984bd2e pbrook
        env->CF = (x >> 31) & 1;
409 8984bd2e pbrook
        return (int32_t)x >> 31;
410 8984bd2e pbrook
    } else if (shift != 0) {
411 8984bd2e pbrook
        env->CF = (x >> (shift - 1)) & 1;
412 8984bd2e pbrook
        return (int32_t)x >> shift;
413 8984bd2e pbrook
    }
414 8984bd2e pbrook
    return x;
415 8984bd2e pbrook
}
416 8984bd2e pbrook
417 8984bd2e pbrook
uint32_t HELPER(ror_cc)(uint32_t x, uint32_t i)
418 8984bd2e pbrook
{
419 8984bd2e pbrook
    int shift1, shift;
420 8984bd2e pbrook
    shift1 = i & 0xff;
421 8984bd2e pbrook
    shift = shift1 & 0x1f;
422 8984bd2e pbrook
    if (shift == 0) {
423 8984bd2e pbrook
        if (shift1 != 0)
424 8984bd2e pbrook
            env->CF = (x >> 31) & 1;
425 8984bd2e pbrook
        return x;
426 8984bd2e pbrook
    } else {
427 8984bd2e pbrook
        env->CF = (x >> (shift - 1)) & 1;
428 8984bd2e pbrook
        return ((uint32_t)x >> shift) | (x << (32 - shift));
429 8984bd2e pbrook
    }
430 8984bd2e pbrook
}