blob: f5dbd2605f2de858093b4c3122eee23ffd9fcbcb [file] [log] [blame]
bellarde8af50a2004-09-30 21:55:55 +00001/*** Integer load ***/
2#define SPARC_LD_OP(name, qp) \
3void OPPROTO glue(glue(op_, name), MEMSUFFIX)(void) \
4{ \
bellard34751872005-07-02 14:31:34 +00005 T1 = (target_ulong)glue(qp, MEMSUFFIX)(T0); \
bellarde8af50a2004-09-30 21:55:55 +00006}
7
bellard34751872005-07-02 14:31:34 +00008#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); \
12 }
13
bellarde8af50a2004-09-30 21:55:55 +000014#define SPARC_ST_OP(name, op) \
15void OPPROTO glue(glue(op_, name), MEMSUFFIX)(void) \
16{ \
bellard0fa85d42005-01-03 23:43:32 +000017 glue(op, MEMSUFFIX)(T0, T1); \
bellarde8af50a2004-09-30 21:55:55 +000018}
19
20SPARC_LD_OP(ld, ldl);
21SPARC_LD_OP(ldub, ldub);
22SPARC_LD_OP(lduh, lduw);
bellard34751872005-07-02 14:31:34 +000023SPARC_LD_OP_S(ldsb, ldsb);
24SPARC_LD_OP_S(ldsh, ldsw);
bellarde8af50a2004-09-30 21:55:55 +000025
26/*** Integer store ***/
27SPARC_ST_OP(st, stl);
28SPARC_ST_OP(stb, stb);
29SPARC_ST_OP(sth, stw);
30
31void OPPROTO glue(op_std, MEMSUFFIX)(void)
32{
bellard0fa85d42005-01-03 23:43:32 +000033 glue(stl, MEMSUFFIX)(T0, T1);
34 glue(stl, MEMSUFFIX)((T0 + 4), T2);
bellarde8af50a2004-09-30 21:55:55 +000035}
36
37void OPPROTO glue(op_ldstub, MEMSUFFIX)(void)
38{
bellard0fa85d42005-01-03 23:43:32 +000039 T1 = glue(ldub, MEMSUFFIX)(T0);
40 glue(stb, MEMSUFFIX)(T0, 0xff); /* XXX: Should be Atomically */
bellarde8af50a2004-09-30 21:55:55 +000041}
42
43void OPPROTO glue(op_swap, MEMSUFFIX)(void)
44{
bellardaf7bf892005-01-30 22:39:04 +000045 target_ulong tmp = glue(ldl, MEMSUFFIX)(T0);
bellard0fa85d42005-01-03 23:43:32 +000046 glue(stl, MEMSUFFIX)(T0, T1); /* XXX: Should be Atomically */
bellarde8af50a2004-09-30 21:55:55 +000047 T1 = tmp;
48}
49
50void OPPROTO glue(op_ldd, MEMSUFFIX)(void)
51{
bellard0fa85d42005-01-03 23:43:32 +000052 T1 = glue(ldl, MEMSUFFIX)(T0);
53 T0 = glue(ldl, MEMSUFFIX)((T0 + 4));
bellarde8af50a2004-09-30 21:55:55 +000054}
55
56/*** Floating-point store ***/
57void OPPROTO glue(op_stf, MEMSUFFIX) (void)
58{
bellard0fa85d42005-01-03 23:43:32 +000059 glue(stfl, MEMSUFFIX)(T0, FT0);
bellarde8af50a2004-09-30 21:55:55 +000060}
61
62void OPPROTO glue(op_stdf, MEMSUFFIX) (void)
63{
bellard0fa85d42005-01-03 23:43:32 +000064 glue(stfq, MEMSUFFIX)(T0, DT0);
bellarde8af50a2004-09-30 21:55:55 +000065}
66
67/*** Floating-point load ***/
68void OPPROTO glue(op_ldf, MEMSUFFIX) (void)
69{
bellard0fa85d42005-01-03 23:43:32 +000070 FT0 = glue(ldfl, MEMSUFFIX)(T0);
bellarde8af50a2004-09-30 21:55:55 +000071}
72
73void OPPROTO glue(op_lddf, MEMSUFFIX) (void)
74{
bellard0fa85d42005-01-03 23:43:32 +000075 DT0 = glue(ldfq, MEMSUFFIX)(T0);
bellarde8af50a2004-09-30 21:55:55 +000076}
bellard34751872005-07-02 14:31:34 +000077
78#ifdef TARGET_SPARC64
79/* XXX: Should be Atomically */
80/* XXX: There are no cas[x] instructions, only cas[x]a */
81void OPPROTO glue(op_cas, MEMSUFFIX)(void)
82{
83 uint32_t tmp;
84
85 tmp = glue(ldl, MEMSUFFIX)(T0);
86 T2 &= 0xffffffffULL;
87 if (tmp == (T1 & 0xffffffffULL)) {
88 glue(stl, MEMSUFFIX)(T0, T2);
89 }
90 T2 = tmp;
91}
92
93void OPPROTO glue(op_casx, MEMSUFFIX)(void)
94{
95 uint64_t tmp;
96
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);
102 }
103 T2 = tmp;
104}
105
106void OPPROTO glue(op_ldsw, MEMSUFFIX)(void)
107{
bellard83469012005-07-23 14:27:54 +0000108 T1 = (int64_t)(glue(ldl, MEMSUFFIX)(T0) & 0xffffffff);
bellard34751872005-07-02 14:31:34 +0000109}
110
bellard83469012005-07-23 14:27:54 +0000111SPARC_LD_OP(ldx, ldq);
112SPARC_ST_OP(stx, stq);
bellard34751872005-07-02 14:31:34 +0000113#endif
bellarde8af50a2004-09-30 21:55:55 +0000114#undef MEMSUFFIX