bellard | e8af50a | 2004-09-30 21:55:55 +0000 | [diff] [blame] | 1 | /*** Integer load ***/ |
| 2 | #define SPARC_LD_OP(name, qp) \ |
| 3 | void OPPROTO glue(glue(op_, name), MEMSUFFIX)(void) \ |
| 4 | { \ |
bellard | 3475187 | 2005-07-02 14:31:34 +0000 | [diff] [blame] | 5 | T1 = (target_ulong)glue(qp, MEMSUFFIX)(T0); \ |
bellard | e8af50a | 2004-09-30 21:55:55 +0000 | [diff] [blame] | 6 | } |
| 7 | |
bellard | 3475187 | 2005-07-02 14:31:34 +0000 | [diff] [blame] | 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); \ |
| 12 | } |
| 13 | |
bellard | e8af50a | 2004-09-30 21:55:55 +0000 | [diff] [blame] | 14 | #define SPARC_ST_OP(name, op) \ |
| 15 | void OPPROTO glue(glue(op_, name), MEMSUFFIX)(void) \ |
| 16 | { \ |
bellard | 0fa85d4 | 2005-01-03 23:43:32 +0000 | [diff] [blame] | 17 | glue(op, MEMSUFFIX)(T0, T1); \ |
bellard | e8af50a | 2004-09-30 21:55:55 +0000 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | SPARC_LD_OP(ld, ldl); |
| 21 | SPARC_LD_OP(ldub, ldub); |
| 22 | SPARC_LD_OP(lduh, lduw); |
bellard | 3475187 | 2005-07-02 14:31:34 +0000 | [diff] [blame] | 23 | SPARC_LD_OP_S(ldsb, ldsb); |
| 24 | SPARC_LD_OP_S(ldsh, ldsw); |
bellard | e8af50a | 2004-09-30 21:55:55 +0000 | [diff] [blame] | 25 | |
| 26 | /*** Integer store ***/ |
| 27 | SPARC_ST_OP(st, stl); |
| 28 | SPARC_ST_OP(stb, stb); |
| 29 | SPARC_ST_OP(sth, stw); |
| 30 | |
| 31 | void OPPROTO glue(op_std, MEMSUFFIX)(void) |
| 32 | { |
bellard | 0fa85d4 | 2005-01-03 23:43:32 +0000 | [diff] [blame] | 33 | glue(stl, MEMSUFFIX)(T0, T1); |
| 34 | glue(stl, MEMSUFFIX)((T0 + 4), T2); |
bellard | e8af50a | 2004-09-30 21:55:55 +0000 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | void OPPROTO glue(op_ldstub, MEMSUFFIX)(void) |
| 38 | { |
bellard | 0fa85d4 | 2005-01-03 23:43:32 +0000 | [diff] [blame] | 39 | T1 = glue(ldub, MEMSUFFIX)(T0); |
| 40 | glue(stb, MEMSUFFIX)(T0, 0xff); /* XXX: Should be Atomically */ |
bellard | e8af50a | 2004-09-30 21:55:55 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | void OPPROTO glue(op_swap, MEMSUFFIX)(void) |
| 44 | { |
bellard | af7bf89 | 2005-01-30 22:39:04 +0000 | [diff] [blame] | 45 | target_ulong tmp = glue(ldl, MEMSUFFIX)(T0); |
bellard | 0fa85d4 | 2005-01-03 23:43:32 +0000 | [diff] [blame] | 46 | glue(stl, MEMSUFFIX)(T0, T1); /* XXX: Should be Atomically */ |
bellard | e8af50a | 2004-09-30 21:55:55 +0000 | [diff] [blame] | 47 | T1 = tmp; |
| 48 | } |
| 49 | |
| 50 | void OPPROTO glue(op_ldd, MEMSUFFIX)(void) |
| 51 | { |
bellard | 0fa85d4 | 2005-01-03 23:43:32 +0000 | [diff] [blame] | 52 | T1 = glue(ldl, MEMSUFFIX)(T0); |
| 53 | T0 = glue(ldl, MEMSUFFIX)((T0 + 4)); |
bellard | e8af50a | 2004-09-30 21:55:55 +0000 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | /*** Floating-point store ***/ |
| 57 | void OPPROTO glue(op_stf, MEMSUFFIX) (void) |
| 58 | { |
bellard | 0fa85d4 | 2005-01-03 23:43:32 +0000 | [diff] [blame] | 59 | glue(stfl, MEMSUFFIX)(T0, FT0); |
bellard | e8af50a | 2004-09-30 21:55:55 +0000 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | void OPPROTO glue(op_stdf, MEMSUFFIX) (void) |
| 63 | { |
bellard | 0fa85d4 | 2005-01-03 23:43:32 +0000 | [diff] [blame] | 64 | glue(stfq, MEMSUFFIX)(T0, DT0); |
bellard | e8af50a | 2004-09-30 21:55:55 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | /*** Floating-point load ***/ |
| 68 | void OPPROTO glue(op_ldf, MEMSUFFIX) (void) |
| 69 | { |
bellard | 0fa85d4 | 2005-01-03 23:43:32 +0000 | [diff] [blame] | 70 | FT0 = glue(ldfl, MEMSUFFIX)(T0); |
bellard | e8af50a | 2004-09-30 21:55:55 +0000 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | void OPPROTO glue(op_lddf, MEMSUFFIX) (void) |
| 74 | { |
bellard | 0fa85d4 | 2005-01-03 23:43:32 +0000 | [diff] [blame] | 75 | DT0 = glue(ldfq, MEMSUFFIX)(T0); |
bellard | e8af50a | 2004-09-30 21:55:55 +0000 | [diff] [blame] | 76 | } |
bellard | 3475187 | 2005-07-02 14:31:34 +0000 | [diff] [blame] | 77 | |
| 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) |
| 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 | |
| 93 | void 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 | |
| 106 | void OPPROTO glue(op_ldsw, MEMSUFFIX)(void) |
| 107 | { |
bellard | 8346901 | 2005-07-23 14:27:54 +0000 | [diff] [blame] | 108 | T1 = (int64_t)(glue(ldl, MEMSUFFIX)(T0) & 0xffffffff); |
bellard | 3475187 | 2005-07-02 14:31:34 +0000 | [diff] [blame] | 109 | } |
| 110 | |
bellard | 8346901 | 2005-07-23 14:27:54 +0000 | [diff] [blame] | 111 | SPARC_LD_OP(ldx, ldq); |
| 112 | SPARC_ST_OP(stx, stq); |
bellard | 3475187 | 2005-07-02 14:31:34 +0000 | [diff] [blame] | 113 | #endif |
bellard | e8af50a | 2004-09-30 21:55:55 +0000 | [diff] [blame] | 114 | #undef MEMSUFFIX |