Revision 7a5e4488 target-sparc/op_helper.c

b/target-sparc/op_helper.c
2195 2195
}
2196 2196
#endif /* TARGET_SPARC64 */
2197 2197

  
2198
static target_ulong helper_udiv_common(target_ulong a, target_ulong b, int cc)
2199
{
2200
    int overflow = 0;
2201
    uint64_t x0;
2202
    uint32_t x1;
2203

  
2204
    x0 = (a & 0xffffffff) | ((int64_t) (env->y) << 32);
2205
    x1 = (b & 0xffffffff);
2206

  
2207
    if (x1 == 0) {
2208
        helper_raise_exception(env, TT_DIV_ZERO);
2209
    }
2210

  
2211
    x0 = x0 / x1;
2212
    if (x0 > 0xffffffff) {
2213
        x0 = 0xffffffff;
2214
        overflow = 1;
2215
    }
2216

  
2217
    if (cc) {
2218
        env->cc_dst = x0;
2219
        env->cc_src2 = overflow;
2220
        env->cc_op = CC_OP_DIV;
2221
    }
2222
    return x0;
2223
}
2224

  
2225
target_ulong helper_udiv(target_ulong a, target_ulong b)
2226
{
2227
    return helper_udiv_common(a, b, 0);
2228
}
2229

  
2230
target_ulong helper_udiv_cc(target_ulong a, target_ulong b)
2231
{
2232
    return helper_udiv_common(a, b, 1);
2233
}
2234

  
2235
static target_ulong helper_sdiv_common(target_ulong a, target_ulong b, int cc)
2236
{
2237
    int overflow = 0;
2238
    int64_t x0;
2239
    int32_t x1;
2240

  
2241
    x0 = (a & 0xffffffff) | ((int64_t) (env->y) << 32);
2242
    x1 = (b & 0xffffffff);
2243

  
2244
    if (x1 == 0) {
2245
        helper_raise_exception(env, TT_DIV_ZERO);
2246
    }
2247

  
2248
    x0 = x0 / x1;
2249
    if ((int32_t) x0 != x0) {
2250
        x0 = x0 < 0 ? 0x80000000 : 0x7fffffff;
2251
        overflow = 1;
2252
    }
2253

  
2254
    if (cc) {
2255
        env->cc_dst = x0;
2256
        env->cc_src2 = overflow;
2257
        env->cc_op = CC_OP_DIV;
2258
    }
2259
    return x0;
2260
}
2261

  
2262
target_ulong helper_sdiv(target_ulong a, target_ulong b)
2263
{
2264
    return helper_sdiv_common(a, b, 0);
2265
}
2266

  
2267
target_ulong helper_sdiv_cc(target_ulong a, target_ulong b)
2268
{
2269
    return helper_sdiv_common(a, b, 1);
2270
}
2271

  
2272 2198
void helper_stdf(target_ulong addr, int mem_idx)
2273 2199
{
2274 2200
    helper_check_align(addr, 7);

Also available in: Unified diff