Statistics
| Branch: | Revision:

root / target-arm / op_helper.c @ 9c17d615

History | View | Annotate | Download (9.5 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 7b59220e Lluís
#include "helper.h"
21 b7bcbe95 bellard
22 ad69471c pbrook
#define SIGNBIT (uint32_t)0x80000000
23 ad69471c pbrook
#define SIGNBIT64 ((uint64_t)1 << 63)
24 ad69471c pbrook
25 1ce94f81 Blue Swirl
static void raise_exception(CPUARMState *env, int tt)
26 b7bcbe95 bellard
{
27 b7bcbe95 bellard
    env->exception_index = tt;
28 1162c041 Blue Swirl
    cpu_loop_exit(env);
29 b7bcbe95 bellard
}
30 b7bcbe95 bellard
31 9ef39277 Blue Swirl
uint32_t HELPER(neon_tbl)(CPUARMState *env, uint32_t ireg, uint32_t def,
32 8f8e3aa4 pbrook
                          uint32_t rn, uint32_t maxindex)
33 9ee6e8bb pbrook
{
34 9ee6e8bb pbrook
    uint32_t val;
35 9ee6e8bb pbrook
    uint32_t tmp;
36 9ee6e8bb pbrook
    int index;
37 9ee6e8bb pbrook
    int shift;
38 9ee6e8bb pbrook
    uint64_t *table;
39 9ee6e8bb pbrook
    table = (uint64_t *)&env->vfp.regs[rn];
40 9ee6e8bb pbrook
    val = 0;
41 9ee6e8bb pbrook
    for (shift = 0; shift < 32; shift += 8) {
42 8f8e3aa4 pbrook
        index = (ireg >> shift) & 0xff;
43 8f8e3aa4 pbrook
        if (index < maxindex) {
44 3018f259 pbrook
            tmp = (table[index >> 3] >> ((index & 7) << 3)) & 0xff;
45 9ee6e8bb pbrook
            val |= tmp << shift;
46 9ee6e8bb pbrook
        } else {
47 8f8e3aa4 pbrook
            val |= def & (0xff << shift);
48 9ee6e8bb pbrook
        }
49 9ee6e8bb pbrook
    }
50 8f8e3aa4 pbrook
    return val;
51 9ee6e8bb pbrook
}
52 9ee6e8bb pbrook
53 b5ff1b31 bellard
#if !defined(CONFIG_USER_ONLY)
54 b5ff1b31 bellard
55 022c62cb Paolo Bonzini
#include "exec/softmmu_exec.h"
56 3e457172 Blue Swirl
57 b5ff1b31 bellard
#define MMUSUFFIX _mmu
58 b5ff1b31 bellard
59 b5ff1b31 bellard
#define SHIFT 0
60 022c62cb Paolo Bonzini
#include "exec/softmmu_template.h"
61 b5ff1b31 bellard
62 b5ff1b31 bellard
#define SHIFT 1
63 022c62cb Paolo Bonzini
#include "exec/softmmu_template.h"
64 b5ff1b31 bellard
65 b5ff1b31 bellard
#define SHIFT 2
66 022c62cb Paolo Bonzini
#include "exec/softmmu_template.h"
67 b5ff1b31 bellard
68 b5ff1b31 bellard
#define SHIFT 3
69 022c62cb Paolo Bonzini
#include "exec/softmmu_template.h"
70 b5ff1b31 bellard
71 b5ff1b31 bellard
/* try to fill the TLB and return an exception if error. If retaddr is
72 b5ff1b31 bellard
   NULL, it means that the function was called in C code (i.e. not
73 b5ff1b31 bellard
   from generated code or from helper.c) */
74 d31dd73e Blue Swirl
void tlb_fill(CPUARMState *env, target_ulong addr, int is_write, int mmu_idx,
75 20503968 Blue Swirl
              uintptr_t retaddr)
76 b5ff1b31 bellard
{
77 b5ff1b31 bellard
    int ret;
78 b5ff1b31 bellard
79 97b348e7 Blue Swirl
    ret = cpu_arm_handle_mmu_fault(env, addr, is_write, mmu_idx);
80 551bd27f ths
    if (unlikely(ret)) {
81 b5ff1b31 bellard
        if (retaddr) {
82 b5ff1b31 bellard
            /* now we have a real cpu fault */
83 a8a826a3 Blue Swirl
            cpu_restore_state(env, retaddr);
84 b5ff1b31 bellard
        }
85 1ce94f81 Blue Swirl
        raise_exception(env, env->exception_index);
86 b5ff1b31 bellard
    }
87 b5ff1b31 bellard
}
88 b5ff1b31 bellard
#endif
89 1497c961 pbrook
90 9ef39277 Blue Swirl
uint32_t HELPER(add_setq)(CPUARMState *env, uint32_t a, uint32_t b)
91 1497c961 pbrook
{
92 1497c961 pbrook
    uint32_t res = a + b;
93 1497c961 pbrook
    if (((res ^ a) & SIGNBIT) && !((a ^ b) & SIGNBIT))
94 1497c961 pbrook
        env->QF = 1;
95 1497c961 pbrook
    return res;
96 1497c961 pbrook
}
97 1497c961 pbrook
98 9ef39277 Blue Swirl
uint32_t HELPER(add_saturate)(CPUARMState *env, uint32_t a, uint32_t b)
99 1497c961 pbrook
{
100 1497c961 pbrook
    uint32_t res = a + b;
101 1497c961 pbrook
    if (((res ^ a) & SIGNBIT) && !((a ^ b) & SIGNBIT)) {
102 1497c961 pbrook
        env->QF = 1;
103 1497c961 pbrook
        res = ~(((int32_t)a >> 31) ^ SIGNBIT);
104 1497c961 pbrook
    }
105 1497c961 pbrook
    return res;
106 1497c961 pbrook
}
107 1497c961 pbrook
108 9ef39277 Blue Swirl
uint32_t HELPER(sub_saturate)(CPUARMState *env, 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
        res = ~(((int32_t)a >> 31) ^ SIGNBIT);
114 1497c961 pbrook
    }
115 1497c961 pbrook
    return res;
116 1497c961 pbrook
}
117 1497c961 pbrook
118 9ef39277 Blue Swirl
uint32_t HELPER(double_saturate)(CPUARMState *env, int32_t val)
119 1497c961 pbrook
{
120 1497c961 pbrook
    uint32_t res;
121 1497c961 pbrook
    if (val >= 0x40000000) {
122 1497c961 pbrook
        res = ~SIGNBIT;
123 1497c961 pbrook
        env->QF = 1;
124 1497c961 pbrook
    } else if (val <= (int32_t)0xc0000000) {
125 1497c961 pbrook
        res = SIGNBIT;
126 1497c961 pbrook
        env->QF = 1;
127 1497c961 pbrook
    } else {
128 1497c961 pbrook
        res = val << 1;
129 1497c961 pbrook
    }
130 1497c961 pbrook
    return res;
131 1497c961 pbrook
}
132 1497c961 pbrook
133 9ef39277 Blue Swirl
uint32_t HELPER(add_usaturate)(CPUARMState *env, uint32_t a, uint32_t b)
134 1497c961 pbrook
{
135 1497c961 pbrook
    uint32_t res = a + b;
136 1497c961 pbrook
    if (res < a) {
137 1497c961 pbrook
        env->QF = 1;
138 1497c961 pbrook
        res = ~0;
139 1497c961 pbrook
    }
140 1497c961 pbrook
    return res;
141 1497c961 pbrook
}
142 1497c961 pbrook
143 9ef39277 Blue Swirl
uint32_t HELPER(sub_usaturate)(CPUARMState *env, uint32_t a, uint32_t b)
144 1497c961 pbrook
{
145 1497c961 pbrook
    uint32_t res = a - b;
146 1497c961 pbrook
    if (res > a) {
147 1497c961 pbrook
        env->QF = 1;
148 1497c961 pbrook
        res = 0;
149 1497c961 pbrook
    }
150 1497c961 pbrook
    return res;
151 1497c961 pbrook
}
152 1497c961 pbrook
153 6ddbc6e4 pbrook
/* Signed saturation.  */
154 9ef39277 Blue Swirl
static inline uint32_t do_ssat(CPUARMState *env, int32_t val, int shift)
155 6ddbc6e4 pbrook
{
156 6ddbc6e4 pbrook
    int32_t top;
157 6ddbc6e4 pbrook
    uint32_t mask;
158 6ddbc6e4 pbrook
159 6ddbc6e4 pbrook
    top = val >> shift;
160 6ddbc6e4 pbrook
    mask = (1u << shift) - 1;
161 6ddbc6e4 pbrook
    if (top > 0) {
162 6ddbc6e4 pbrook
        env->QF = 1;
163 6ddbc6e4 pbrook
        return mask;
164 6ddbc6e4 pbrook
    } else if (top < -1) {
165 6ddbc6e4 pbrook
        env->QF = 1;
166 6ddbc6e4 pbrook
        return ~mask;
167 6ddbc6e4 pbrook
    }
168 6ddbc6e4 pbrook
    return val;
169 6ddbc6e4 pbrook
}
170 6ddbc6e4 pbrook
171 6ddbc6e4 pbrook
/* Unsigned saturation.  */
172 9ef39277 Blue Swirl
static inline uint32_t do_usat(CPUARMState *env, int32_t val, int shift)
173 6ddbc6e4 pbrook
{
174 6ddbc6e4 pbrook
    uint32_t max;
175 6ddbc6e4 pbrook
176 6ddbc6e4 pbrook
    max = (1u << shift) - 1;
177 6ddbc6e4 pbrook
    if (val < 0) {
178 6ddbc6e4 pbrook
        env->QF = 1;
179 6ddbc6e4 pbrook
        return 0;
180 6ddbc6e4 pbrook
    } else if (val > max) {
181 6ddbc6e4 pbrook
        env->QF = 1;
182 6ddbc6e4 pbrook
        return max;
183 6ddbc6e4 pbrook
    }
184 6ddbc6e4 pbrook
    return val;
185 6ddbc6e4 pbrook
}
186 6ddbc6e4 pbrook
187 6ddbc6e4 pbrook
/* Signed saturate.  */
188 9ef39277 Blue Swirl
uint32_t HELPER(ssat)(CPUARMState *env, uint32_t x, uint32_t shift)
189 6ddbc6e4 pbrook
{
190 9ef39277 Blue Swirl
    return do_ssat(env, x, shift);
191 6ddbc6e4 pbrook
}
192 6ddbc6e4 pbrook
193 6ddbc6e4 pbrook
/* Dual halfword signed saturate.  */
194 9ef39277 Blue Swirl
uint32_t HELPER(ssat16)(CPUARMState *env, uint32_t x, uint32_t shift)
195 6ddbc6e4 pbrook
{
196 6ddbc6e4 pbrook
    uint32_t res;
197 6ddbc6e4 pbrook
198 9ef39277 Blue Swirl
    res = (uint16_t)do_ssat(env, (int16_t)x, shift);
199 9ef39277 Blue Swirl
    res |= do_ssat(env, ((int32_t)x) >> 16, shift) << 16;
200 6ddbc6e4 pbrook
    return res;
201 6ddbc6e4 pbrook
}
202 6ddbc6e4 pbrook
203 6ddbc6e4 pbrook
/* Unsigned saturate.  */
204 9ef39277 Blue Swirl
uint32_t HELPER(usat)(CPUARMState *env, uint32_t x, uint32_t shift)
205 6ddbc6e4 pbrook
{
206 9ef39277 Blue Swirl
    return do_usat(env, x, shift);
207 6ddbc6e4 pbrook
}
208 6ddbc6e4 pbrook
209 6ddbc6e4 pbrook
/* Dual halfword unsigned saturate.  */
210 9ef39277 Blue Swirl
uint32_t HELPER(usat16)(CPUARMState *env, uint32_t x, uint32_t shift)
211 6ddbc6e4 pbrook
{
212 6ddbc6e4 pbrook
    uint32_t res;
213 6ddbc6e4 pbrook
214 9ef39277 Blue Swirl
    res = (uint16_t)do_usat(env, (int16_t)x, shift);
215 9ef39277 Blue Swirl
    res |= do_usat(env, ((int32_t)x) >> 16, shift) << 16;
216 6ddbc6e4 pbrook
    return res;
217 6ddbc6e4 pbrook
}
218 d9ba4830 pbrook
219 1ce94f81 Blue Swirl
void HELPER(wfi)(CPUARMState *env)
220 d9ba4830 pbrook
{
221 d9ba4830 pbrook
    env->exception_index = EXCP_HLT;
222 d9ba4830 pbrook
    env->halted = 1;
223 1162c041 Blue Swirl
    cpu_loop_exit(env);
224 d9ba4830 pbrook
}
225 d9ba4830 pbrook
226 1ce94f81 Blue Swirl
void HELPER(exception)(CPUARMState *env, uint32_t excp)
227 d9ba4830 pbrook
{
228 d9ba4830 pbrook
    env->exception_index = excp;
229 1162c041 Blue Swirl
    cpu_loop_exit(env);
230 d9ba4830 pbrook
}
231 d9ba4830 pbrook
232 9ef39277 Blue Swirl
uint32_t HELPER(cpsr_read)(CPUARMState *env)
233 d9ba4830 pbrook
{
234 d9ba4830 pbrook
    return cpsr_read(env) & ~CPSR_EXEC;
235 d9ba4830 pbrook
}
236 d9ba4830 pbrook
237 1ce94f81 Blue Swirl
void HELPER(cpsr_write)(CPUARMState *env, uint32_t val, uint32_t mask)
238 d9ba4830 pbrook
{
239 d9ba4830 pbrook
    cpsr_write(env, val, mask);
240 d9ba4830 pbrook
}
241 b0109805 pbrook
242 b0109805 pbrook
/* Access to user mode registers from privileged modes.  */
243 9ef39277 Blue Swirl
uint32_t HELPER(get_user_reg)(CPUARMState *env, uint32_t regno)
244 b0109805 pbrook
{
245 b0109805 pbrook
    uint32_t val;
246 b0109805 pbrook
247 b0109805 pbrook
    if (regno == 13) {
248 b0109805 pbrook
        val = env->banked_r13[0];
249 b0109805 pbrook
    } else if (regno == 14) {
250 b0109805 pbrook
        val = env->banked_r14[0];
251 b0109805 pbrook
    } else if (regno >= 8
252 b0109805 pbrook
               && (env->uncached_cpsr & 0x1f) == ARM_CPU_MODE_FIQ) {
253 b0109805 pbrook
        val = env->usr_regs[regno - 8];
254 b0109805 pbrook
    } else {
255 b0109805 pbrook
        val = env->regs[regno];
256 b0109805 pbrook
    }
257 b0109805 pbrook
    return val;
258 b0109805 pbrook
}
259 b0109805 pbrook
260 1ce94f81 Blue Swirl
void HELPER(set_user_reg)(CPUARMState *env, uint32_t regno, uint32_t val)
261 b0109805 pbrook
{
262 b0109805 pbrook
    if (regno == 13) {
263 b0109805 pbrook
        env->banked_r13[0] = val;
264 b0109805 pbrook
    } else if (regno == 14) {
265 b0109805 pbrook
        env->banked_r14[0] = val;
266 b0109805 pbrook
    } else if (regno >= 8
267 b0109805 pbrook
               && (env->uncached_cpsr & 0x1f) == ARM_CPU_MODE_FIQ) {
268 b0109805 pbrook
        env->usr_regs[regno - 8] = val;
269 b0109805 pbrook
    } else {
270 b0109805 pbrook
        env->regs[regno] = val;
271 b0109805 pbrook
    }
272 b0109805 pbrook
}
273 4b6a83fb Peter Maydell
274 4b6a83fb Peter Maydell
void HELPER(set_cp_reg)(CPUARMState *env, void *rip, uint32_t value)
275 4b6a83fb Peter Maydell
{
276 4b6a83fb Peter Maydell
    const ARMCPRegInfo *ri = rip;
277 4b6a83fb Peter Maydell
    int excp = ri->writefn(env, ri, value);
278 4b6a83fb Peter Maydell
    if (excp) {
279 1ce94f81 Blue Swirl
        raise_exception(env, excp);
280 4b6a83fb Peter Maydell
    }
281 4b6a83fb Peter Maydell
}
282 4b6a83fb Peter Maydell
283 4b6a83fb Peter Maydell
uint32_t HELPER(get_cp_reg)(CPUARMState *env, void *rip)
284 4b6a83fb Peter Maydell
{
285 4b6a83fb Peter Maydell
    const ARMCPRegInfo *ri = rip;
286 4b6a83fb Peter Maydell
    uint64_t value;
287 4b6a83fb Peter Maydell
    int excp = ri->readfn(env, ri, &value);
288 4b6a83fb Peter Maydell
    if (excp) {
289 1ce94f81 Blue Swirl
        raise_exception(env, excp);
290 4b6a83fb Peter Maydell
    }
291 4b6a83fb Peter Maydell
    return value;
292 4b6a83fb Peter Maydell
}
293 4b6a83fb Peter Maydell
294 4b6a83fb Peter Maydell
void HELPER(set_cp_reg64)(CPUARMState *env, void *rip, uint64_t value)
295 4b6a83fb Peter Maydell
{
296 4b6a83fb Peter Maydell
    const ARMCPRegInfo *ri = rip;
297 4b6a83fb Peter Maydell
    int excp = ri->writefn(env, ri, value);
298 4b6a83fb Peter Maydell
    if (excp) {
299 1ce94f81 Blue Swirl
        raise_exception(env, excp);
300 4b6a83fb Peter Maydell
    }
301 4b6a83fb Peter Maydell
}
302 4b6a83fb Peter Maydell
303 4b6a83fb Peter Maydell
uint64_t HELPER(get_cp_reg64)(CPUARMState *env, void *rip)
304 4b6a83fb Peter Maydell
{
305 4b6a83fb Peter Maydell
    const ARMCPRegInfo *ri = rip;
306 4b6a83fb Peter Maydell
    uint64_t value;
307 4b6a83fb Peter Maydell
    int excp = ri->readfn(env, ri, &value);
308 4b6a83fb Peter Maydell
    if (excp) {
309 1ce94f81 Blue Swirl
        raise_exception(env, excp);
310 4b6a83fb Peter Maydell
    }
311 4b6a83fb Peter Maydell
    return value;
312 4b6a83fb Peter Maydell
}
313 b0109805 pbrook
314 8984bd2e pbrook
/* ??? Flag setting arithmetic is awkward because we need to do comparisons.
315 8984bd2e pbrook
   The only way to do that in TCG is a conditional branch, which clobbers
316 8984bd2e pbrook
   all our temporaries.  For now implement these as helper functions.  */
317 8984bd2e pbrook
318 9ef39277 Blue Swirl
uint32_t HELPER(adc_cc)(CPUARMState *env, uint32_t a, uint32_t b)
319 8984bd2e pbrook
{
320 8984bd2e pbrook
    uint32_t result;
321 8984bd2e pbrook
    if (!env->CF) {
322 8984bd2e pbrook
        result = a + b;
323 8984bd2e pbrook
        env->CF = result < a;
324 8984bd2e pbrook
    } else {
325 8984bd2e pbrook
        result = a + b + 1;
326 8984bd2e pbrook
        env->CF = result <= a;
327 8984bd2e pbrook
    }
328 8984bd2e pbrook
    env->VF = (a ^ b ^ -1) & (a ^ result);
329 6fbe23d5 pbrook
    env->NF = env->ZF = result;
330 8984bd2e pbrook
    return result;
331 8984bd2e pbrook
}
332 8984bd2e pbrook
333 9ef39277 Blue Swirl
uint32_t HELPER(sbc_cc)(CPUARMState *env, uint32_t a, uint32_t b)
334 8984bd2e pbrook
{
335 8984bd2e pbrook
    uint32_t result;
336 8984bd2e pbrook
    if (!env->CF) {
337 8984bd2e pbrook
        result = a - b - 1;
338 8984bd2e pbrook
        env->CF = a > b;
339 8984bd2e pbrook
    } else {
340 8984bd2e pbrook
        result = a - b;
341 8984bd2e pbrook
        env->CF = a >= b;
342 8984bd2e pbrook
    }
343 8984bd2e pbrook
    env->VF = (a ^ b) & (a ^ result);
344 6fbe23d5 pbrook
    env->NF = env->ZF = result;
345 8984bd2e pbrook
    return result;
346 8984bd2e pbrook
}
347 8984bd2e pbrook
348 8984bd2e pbrook
/* Similarly for variable shift instructions.  */
349 8984bd2e pbrook
350 9ef39277 Blue Swirl
uint32_t HELPER(shl_cc)(CPUARMState *env, uint32_t x, uint32_t i)
351 8984bd2e pbrook
{
352 8984bd2e pbrook
    int shift = i & 0xff;
353 8984bd2e pbrook
    if (shift >= 32) {
354 8984bd2e pbrook
        if (shift == 32)
355 8984bd2e pbrook
            env->CF = x & 1;
356 8984bd2e pbrook
        else
357 8984bd2e pbrook
            env->CF = 0;
358 8984bd2e pbrook
        return 0;
359 8984bd2e pbrook
    } else if (shift != 0) {
360 8984bd2e pbrook
        env->CF = (x >> (32 - shift)) & 1;
361 8984bd2e pbrook
        return x << shift;
362 8984bd2e pbrook
    }
363 8984bd2e pbrook
    return x;
364 8984bd2e pbrook
}
365 8984bd2e pbrook
366 9ef39277 Blue Swirl
uint32_t HELPER(shr_cc)(CPUARMState *env, uint32_t x, uint32_t i)
367 8984bd2e pbrook
{
368 8984bd2e pbrook
    int shift = i & 0xff;
369 8984bd2e pbrook
    if (shift >= 32) {
370 8984bd2e pbrook
        if (shift == 32)
371 8984bd2e pbrook
            env->CF = (x >> 31) & 1;
372 8984bd2e pbrook
        else
373 8984bd2e pbrook
            env->CF = 0;
374 8984bd2e pbrook
        return 0;
375 8984bd2e pbrook
    } else if (shift != 0) {
376 8984bd2e pbrook
        env->CF = (x >> (shift - 1)) & 1;
377 8984bd2e pbrook
        return x >> shift;
378 8984bd2e pbrook
    }
379 8984bd2e pbrook
    return x;
380 8984bd2e pbrook
}
381 8984bd2e pbrook
382 9ef39277 Blue Swirl
uint32_t HELPER(sar_cc)(CPUARMState *env, uint32_t x, uint32_t i)
383 8984bd2e pbrook
{
384 8984bd2e pbrook
    int shift = i & 0xff;
385 8984bd2e pbrook
    if (shift >= 32) {
386 8984bd2e pbrook
        env->CF = (x >> 31) & 1;
387 8984bd2e pbrook
        return (int32_t)x >> 31;
388 8984bd2e pbrook
    } else if (shift != 0) {
389 8984bd2e pbrook
        env->CF = (x >> (shift - 1)) & 1;
390 8984bd2e pbrook
        return (int32_t)x >> shift;
391 8984bd2e pbrook
    }
392 8984bd2e pbrook
    return x;
393 8984bd2e pbrook
}
394 8984bd2e pbrook
395 9ef39277 Blue Swirl
uint32_t HELPER(ror_cc)(CPUARMState *env, uint32_t x, uint32_t i)
396 8984bd2e pbrook
{
397 8984bd2e pbrook
    int shift1, shift;
398 8984bd2e pbrook
    shift1 = i & 0xff;
399 8984bd2e pbrook
    shift = shift1 & 0x1f;
400 8984bd2e pbrook
    if (shift == 0) {
401 8984bd2e pbrook
        if (shift1 != 0)
402 8984bd2e pbrook
            env->CF = (x >> 31) & 1;
403 8984bd2e pbrook
        return x;
404 8984bd2e pbrook
    } else {
405 8984bd2e pbrook
        env->CF = (x >> (shift - 1)) & 1;
406 8984bd2e pbrook
        return ((uint32_t)x >> shift) | (x << (32 - shift));
407 8984bd2e pbrook
    }
408 8984bd2e pbrook
}