Thumb shifter carry flag fixes.
[qemu/mini2440.git] / target-sparc / op_mem.h
bloba175d0d591e4433ebf86eecd099c409f09d430cd
1 /*** Integer load ***/
2 #define SPARC_LD_OP(name, qp) \
3 void OPPROTO glue(glue(op_, name), MEMSUFFIX)(void) \
4 { \
5 T1 = (target_ulong)glue(qp, MEMSUFFIX)(T0); \
8 #define SPARC_LD_OP_S(name, qp) \
9 void OPPROTO glue(glue(op_, name), MEMSUFFIX)(void) \
10 { \
11 T1 = (target_long)glue(qp, MEMSUFFIX)(T0); \
14 #define SPARC_ST_OP(name, op) \
15 void OPPROTO glue(glue(op_, name), MEMSUFFIX)(void) \
16 { \
17 glue(op, MEMSUFFIX)(T0, T1); \
20 SPARC_LD_OP(ld, ldl);
21 SPARC_LD_OP(ldub, ldub);
22 SPARC_LD_OP(lduh, lduw);
23 SPARC_LD_OP_S(ldsb, ldsb);
24 SPARC_LD_OP_S(ldsh, ldsw);
26 /*** Integer store ***/
27 SPARC_ST_OP(st, stl);
28 SPARC_ST_OP(stb, stb);
29 SPARC_ST_OP(sth, stw);
31 void OPPROTO glue(op_std, MEMSUFFIX)(void)
33 glue(stl, MEMSUFFIX)(T0, T1);
34 glue(stl, MEMSUFFIX)((T0 + 4), T2);
37 void OPPROTO glue(op_ldstub, MEMSUFFIX)(void)
39 T1 = glue(ldub, MEMSUFFIX)(T0);
40 glue(stb, MEMSUFFIX)(T0, 0xff); /* XXX: Should be Atomically */
43 void OPPROTO glue(op_swap, MEMSUFFIX)(void)
45 target_ulong tmp = glue(ldl, MEMSUFFIX)(T0);
46 glue(stl, MEMSUFFIX)(T0, T1); /* XXX: Should be Atomically */
47 T1 = tmp;
50 void OPPROTO glue(op_ldd, MEMSUFFIX)(void)
52 T1 = glue(ldl, MEMSUFFIX)(T0);
53 T0 = glue(ldl, MEMSUFFIX)((T0 + 4));
56 /*** Floating-point store ***/
57 void OPPROTO glue(op_stf, MEMSUFFIX) (void)
59 glue(stfl, MEMSUFFIX)(T0, FT0);
62 void OPPROTO glue(op_stdf, MEMSUFFIX) (void)
64 glue(stfq, MEMSUFFIX)(T0, DT0);
67 /*** Floating-point load ***/
68 void OPPROTO glue(op_ldf, MEMSUFFIX) (void)
70 FT0 = glue(ldfl, MEMSUFFIX)(T0);
73 void OPPROTO glue(op_lddf, MEMSUFFIX) (void)
75 DT0 = glue(ldfq, MEMSUFFIX)(T0);
78 #ifdef TARGET_SPARC64
79 /* XXX: Should be Atomically */
80 /* XXX: There are no cas[x] instructions, only cas[x]a */
81 void OPPROTO glue(op_cas, MEMSUFFIX)(void)
83 uint32_t tmp;
85 tmp = glue(ldl, MEMSUFFIX)(T0);
86 T2 &= 0xffffffffULL;
87 if (tmp == (T1 & 0xffffffffULL)) {
88 glue(stl, MEMSUFFIX)(T0, T2);
90 T2 = tmp;
93 void OPPROTO glue(op_casx, MEMSUFFIX)(void)
95 uint64_t tmp;
97 // XXX
98 tmp = (uint64_t)glue(ldl, MEMSUFFIX)(T0) << 32;
99 tmp |= glue(ldl, MEMSUFFIX)(T0);
100 if (tmp == T1) {
101 glue(stq, MEMSUFFIX)(T0, T2);
103 T2 = tmp;
106 void OPPROTO glue(op_lduw, MEMSUFFIX)(void)
108 T1 = (uint64_t)(glue(ldl, MEMSUFFIX)(T0) & 0xffffffff);
111 void OPPROTO glue(op_ldsw, MEMSUFFIX)(void)
113 T1 = (int64_t)(glue(ldl, MEMSUFFIX)(T0) & 0xffffffff);
116 SPARC_LD_OP(ldx, ldq);
117 SPARC_ST_OP(stx, stq);
118 #endif
119 #undef MEMSUFFIX