Revision 2958620f target-alpha/op_helper.c

b/target-alpha/op_helper.c
43 43
#endif
44 44
}
45 45

  
46
uint64_t helper_addqv (uint64_t op1, uint64_t op2)
47
{
48
    uint64_t tmp = op1;
49
    op1 += op2;
50
    if (unlikely((tmp ^ op2 ^ (-1ULL)) & (tmp ^ op1) & (1ULL << 63))) {
51
        arith_excp(env, GETPC(), EXC_M_IOV, 0);
52
    }
53
    return op1;
54
}
55

  
56
uint64_t helper_addlv (uint64_t op1, uint64_t op2)
57
{
58
    uint64_t tmp = op1;
59
    op1 = (uint32_t)(op1 + op2);
60
    if (unlikely((tmp ^ op2 ^ (-1UL)) & (tmp ^ op1) & (1UL << 31))) {
61
        arith_excp(env, GETPC(), EXC_M_IOV, 0);
62
    }
63
    return op1;
64
}
65

  
66
uint64_t helper_subqv (uint64_t op1, uint64_t op2)
67
{
68
    uint64_t res;
69
    res = op1 - op2;
70
    if (unlikely((op1 ^ op2) & (res ^ op1) & (1ULL << 63))) {
71
        arith_excp(env, GETPC(), EXC_M_IOV, 0);
72
    }
73
    return res;
74
}
75

  
76
uint64_t helper_sublv (uint64_t op1, uint64_t op2)
77
{
78
    uint32_t res;
79
    res = op1 - op2;
80
    if (unlikely((op1 ^ op2) & (res ^ op1) & (1UL << 31))) {
81
        arith_excp(env, GETPC(), EXC_M_IOV, 0);
82
    }
83
    return res;
84
}
85

  
86
uint64_t helper_mullv (uint64_t op1, uint64_t op2)
87
{
88
    int64_t res = (int64_t)op1 * (int64_t)op2;
89

  
90
    if (unlikely((int32_t)res != res)) {
91
        arith_excp(env, GETPC(), EXC_M_IOV, 0);
92
    }
93
    return (int64_t)((int32_t)res);
94
}
95

  
96
uint64_t helper_mulqv (uint64_t op1, uint64_t op2)
97
{
98
    uint64_t tl, th;
99

  
100
    muls64(&tl, &th, op1, op2);
101
    /* If th != 0 && th != -1, then we had an overflow */
102
    if (unlikely((th + 1) > 1)) {
103
        arith_excp(env, GETPC(), EXC_M_IOV, 0);
104
    }
105
    return tl;
106
}
107

  
108 46
/* PALcode support special instructions */
109 47
#if !defined (CONFIG_USER_ONLY)
110 48
void helper_hw_ret (uint64_t a)

Also available in: Unified diff