Revision d9bce9d9 target-ppc/op_helper_mem.h

b/target-ppc/op_helper_mem.h
1 1
/*
2 2
 *  PowerPC emulation micro-operations helpers for qemu.
3
 * 
3
 *
4 4
 *  Copyright (c) 2003-2007 Jocelyn Mayer
5 5
 *
6 6
 * This library is free software; you can redistribute it and/or
......
37 37
void glue(do_lmw, MEMSUFFIX) (int dst)
38 38
{
39 39
    for (; dst < 32; dst++, T0 += 4) {
40
        ugpr(dst) = glue(ldl, MEMSUFFIX)(T0);
40
        ugpr(dst) = glue(ldl, MEMSUFFIX)((uint32_t)T0);
41
    }
42
}
43

  
44
#if defined(TARGET_PPC64)
45
void glue(do_lmw_64, MEMSUFFIX) (int dst)
46
{
47
    for (; dst < 32; dst++, T0 += 4) {
48
        ugpr(dst) = glue(ldl, MEMSUFFIX)((uint64_t)T0);
41 49
    }
42 50
}
51
#endif
43 52

  
44 53
void glue(do_stmw, MEMSUFFIX) (int src)
45 54
{
46 55
    for (; src < 32; src++, T0 += 4) {
47
        glue(stl, MEMSUFFIX)(T0, ugpr(src));
56
        glue(stl, MEMSUFFIX)((uint32_t)T0, ugpr(src));
57
    }
58
}
59

  
60
#if defined(TARGET_PPC64)
61
void glue(do_stmw_64, MEMSUFFIX) (int src)
62
{
63
    for (; src < 32; src++, T0 += 4) {
64
        glue(stl, MEMSUFFIX)((uint64_t)T0, ugpr(src));
48 65
    }
49 66
}
67
#endif
50 68

  
51 69
void glue(do_lmw_le, MEMSUFFIX) (int dst)
52 70
{
53 71
    for (; dst < 32; dst++, T0 += 4) {
54
        ugpr(dst) = glue(ld32r, MEMSUFFIX)(T0);
72
        ugpr(dst) = glue(ld32r, MEMSUFFIX)((uint32_t)T0);
73
    }
74
}
75

  
76
#if defined(TARGET_PPC64)
77
void glue(do_lmw_le_64, MEMSUFFIX) (int dst)
78
{
79
    for (; dst < 32; dst++, T0 += 4) {
80
        ugpr(dst) = glue(ld32r, MEMSUFFIX)((uint64_t)T0);
55 81
    }
56 82
}
83
#endif
57 84

  
58 85
void glue(do_stmw_le, MEMSUFFIX) (int src)
59 86
{
60 87
    for (; src < 32; src++, T0 += 4) {
61
        glue(st32r, MEMSUFFIX)(T0, ugpr(src));
88
        glue(st32r, MEMSUFFIX)((uint32_t)T0, ugpr(src));
62 89
    }
63 90
}
64 91

  
92
#if defined(TARGET_PPC64)
93
void glue(do_stmw_le_64, MEMSUFFIX) (int src)
94
{
95
    for (; src < 32; src++, T0 += 4) {
96
        glue(st32r, MEMSUFFIX)((uint64_t)T0, ugpr(src));
97
    }
98
}
99
#endif
100

  
65 101
void glue(do_lsw, MEMSUFFIX) (int dst)
66 102
{
67 103
    uint32_t tmp;
68 104
    int sh;
69 105

  
70 106
    for (; T1 > 3; T1 -= 4, T0 += 4) {
71
        ugpr(dst++) = glue(ldl, MEMSUFFIX)(T0);
107
        ugpr(dst++) = glue(ldl, MEMSUFFIX)((uint32_t)T0);
72 108
        if (unlikely(dst == 32))
73 109
            dst = 0;
74 110
    }
75 111
    if (unlikely(T1 != 0)) {
76 112
        tmp = 0;
77 113
        for (sh = 24; T1 > 0; T1--, T0++, sh -= 8) {
78
            tmp |= glue(ldub, MEMSUFFIX)(T0) << sh;
114
            tmp |= glue(ldub, MEMSUFFIX)((uint32_t)T0) << sh;
79 115
        }
80 116
        ugpr(dst) = tmp;
81 117
    }
82 118
}
83 119

  
120
#if defined(TARGET_PPC64)
121
void glue(do_lsw_64, MEMSUFFIX) (int dst)
122
{
123
    uint32_t tmp;
124
    int sh;
125

  
126
    for (; T1 > 3; T1 -= 4, T0 += 4) {
127
        ugpr(dst++) = glue(ldl, MEMSUFFIX)((uint64_t)T0);
128
        if (unlikely(dst == 32))
129
            dst = 0;
130
    }
131
    if (unlikely(T1 != 0)) {
132
        tmp = 0;
133
        for (sh = 24; T1 > 0; T1--, T0++, sh -= 8) {
134
            tmp |= glue(ldub, MEMSUFFIX)((uint64_t)T0) << sh;
135
        }
136
        ugpr(dst) = tmp;
137
    }
138
}
139
#endif
140

  
84 141
void glue(do_stsw, MEMSUFFIX) (int src)
85 142
{
86 143
    int sh;
87 144

  
88 145
    for (; T1 > 3; T1 -= 4, T0 += 4) {
89
        glue(stl, MEMSUFFIX)(T0, ugpr(src++));
146
        glue(stl, MEMSUFFIX)((uint32_t)T0, ugpr(src++));
90 147
        if (unlikely(src == 32))
91 148
            src = 0;
92 149
    }
93 150
    if (unlikely(T1 != 0)) {
94 151
        for (sh = 24; T1 > 0; T1--, T0++, sh -= 8)
95
            glue(stb, MEMSUFFIX)(T0, (ugpr(src) >> sh) & 0xFF);
152
            glue(stb, MEMSUFFIX)((uint32_t)T0, (ugpr(src) >> sh) & 0xFF);
96 153
    }
97 154
}
98 155

  
156
#if defined(TARGET_PPC64)
157
void glue(do_stsw_64, MEMSUFFIX) (int src)
158
{
159
    int sh;
160

  
161
    for (; T1 > 3; T1 -= 4, T0 += 4) {
162
        glue(stl, MEMSUFFIX)((uint64_t)T0, ugpr(src++));
163
        if (unlikely(src == 32))
164
            src = 0;
165
    }
166
    if (unlikely(T1 != 0)) {
167
        for (sh = 24; T1 > 0; T1--, T0++, sh -= 8)
168
            glue(stb, MEMSUFFIX)((uint64_t)T0, (ugpr(src) >> sh) & 0xFF);
169
    }
170
}
171
#endif
172

  
99 173
void glue(do_lsw_le, MEMSUFFIX) (int dst)
100 174
{
101 175
    uint32_t tmp;
102 176
    int sh;
103 177

  
104 178
    for (; T1 > 3; T1 -= 4, T0 += 4) {
105
        ugpr(dst++) = glue(ld32r, MEMSUFFIX)(T0);
179
        ugpr(dst++) = glue(ld32r, MEMSUFFIX)((uint32_t)T0);
180
        if (unlikely(dst == 32))
181
            dst = 0;
182
    }
183
    if (unlikely(T1 != 0)) {
184
        tmp = 0;
185
        for (sh = 0; T1 > 0; T1--, T0++, sh += 8) {
186
            tmp |= glue(ldub, MEMSUFFIX)((uint32_t)T0) << sh;
187
        }
188
        ugpr(dst) = tmp;
189
    }
190
}
191

  
192
#if defined(TARGET_PPC64)
193
void glue(do_lsw_le_64, MEMSUFFIX) (int dst)
194
{
195
    uint32_t tmp;
196
    int sh;
197

  
198
    for (; T1 > 3; T1 -= 4, T0 += 4) {
199
        ugpr(dst++) = glue(ld32r, MEMSUFFIX)((uint64_t)T0);
106 200
        if (unlikely(dst == 32))
107 201
            dst = 0;
108 202
    }
109 203
    if (unlikely(T1 != 0)) {
110 204
        tmp = 0;
111 205
        for (sh = 0; T1 > 0; T1--, T0++, sh += 8) {
112
            tmp |= glue(ldub, MEMSUFFIX)(T0) << sh;
206
            tmp |= glue(ldub, MEMSUFFIX)((uint64_t)T0) << sh;
113 207
        }
114 208
        ugpr(dst) = tmp;
115 209
    }
116 210
}
211
#endif
117 212

  
118 213
void glue(do_stsw_le, MEMSUFFIX) (int src)
119 214
{
120 215
    int sh;
121 216

  
122 217
    for (; T1 > 3; T1 -= 4, T0 += 4) {
123
        glue(st32r, MEMSUFFIX)(T0, ugpr(src++));
218
        glue(st32r, MEMSUFFIX)((uint32_t)T0, ugpr(src++));
219
        if (unlikely(src == 32))
220
            src = 0;
221
    }
222
    if (unlikely(T1 != 0)) {
223
        for (sh = 0; T1 > 0; T1--, T0++, sh += 8)
224
            glue(stb, MEMSUFFIX)((uint32_t)T0, (ugpr(src) >> sh) & 0xFF);
225
    }
226
}
227

  
228
#if defined(TARGET_PPC64)
229
void glue(do_stsw_le_64, MEMSUFFIX) (int src)
230
{
231
    int sh;
232

  
233
    for (; T1 > 3; T1 -= 4, T0 += 4) {
234
        glue(st32r, MEMSUFFIX)((uint64_t)T0, ugpr(src++));
124 235
        if (unlikely(src == 32))
125 236
            src = 0;
126 237
    }
127 238
    if (unlikely(T1 != 0)) {
128 239
        for (sh = 0; T1 > 0; T1--, T0++, sh += 8)
129
            glue(stb, MEMSUFFIX)(T0, (ugpr(src) >> sh) & 0xFF);
240
            glue(stb, MEMSUFFIX)((uint64_t)T0, (ugpr(src) >> sh) & 0xFF);
130 241
    }
131 242
}
243
#endif
132 244

  
133 245
/* PPC 601 specific instructions (POWER bridge) */
134 246
// XXX: to be tested
......
139 251
    d = 24;
140 252
    reg = dest;
141 253
    for (i = 0; i < T1; i++) {
142
        c = glue(ldub, MEMSUFFIX)(T0++);
254
        c = glue(ldub, MEMSUFFIX)((uint32_t)T0++);
143 255
        /* ra (if not 0) and rb are never modified */
144 256
        if (likely(reg != rb && (ra == 0 || reg != ra))) {
145 257
            ugpr(reg) = (ugpr(reg) & ~(0xFF << d)) | (c << d);
......
160 272
/* XXX: TAGs are not managed */
161 273
void glue(do_POWER2_lfq, MEMSUFFIX) (void)
162 274
{
163
    FT0 = glue(ldfq, MEMSUFFIX)(T0);
164
    FT1 = glue(ldfq, MEMSUFFIX)(T0 + 4);
275
    FT0 = glue(ldfq, MEMSUFFIX)((uint32_t)T0);
276
    FT1 = glue(ldfq, MEMSUFFIX)((uint32_t)(T0 + 4));
165 277
}
166 278

  
167 279
static inline double glue(ldfqr, MEMSUFFIX) (target_ulong EA)
......
186 298

  
187 299
void glue(do_POWER2_lfq_le, MEMSUFFIX) (void)
188 300
{
189
    FT0 = glue(ldfqr, MEMSUFFIX)(T0 + 4);
190
    FT1 = glue(ldfqr, MEMSUFFIX)(T0);
301
    FT0 = glue(ldfqr, MEMSUFFIX)((uint32_t)(T0 + 4));
302
    FT1 = glue(ldfqr, MEMSUFFIX)((uint32_t)T0);
191 303
}
192 304

  
193 305
void glue(do_POWER2_stfq, MEMSUFFIX) (void)
194 306
{
195
    glue(stfq, MEMSUFFIX)(T0, FT0);
196
    glue(stfq, MEMSUFFIX)(T0 + 4, FT1);
307
    glue(stfq, MEMSUFFIX)((uint32_t)T0, FT0);
308
    glue(stfq, MEMSUFFIX)((uint32_t)(T0 + 4), FT1);
197 309
}
198 310

  
199 311
static inline void glue(stfqr, MEMSUFFIX) (target_ulong EA, double d)
......
217 329

  
218 330
void glue(do_POWER2_stfq_le, MEMSUFFIX) (void)
219 331
{
220
    glue(stfqr, MEMSUFFIX)(T0 + 4, FT0);
221
    glue(stfqr, MEMSUFFIX)(T0, FT1);
332
    glue(stfqr, MEMSUFFIX)((uint32_t)(T0 + 4), FT0);
333
    glue(stfqr, MEMSUFFIX)((uint32_t)T0, FT1);
222 334
}
223 335

  
224 336
#undef MEMSUFFIX

Also available in: Unified diff