Revision 3b89f26c
b/target-sparc/helper.h | ||
---|---|---|
36 | 36 |
target_ulong do_trap); |
37 | 37 |
void TCG_HELPER_PROTO helper_debug(void); |
38 | 38 |
void TCG_HELPER_PROTO helper_flush(target_ulong addr); |
39 |
target_ulong TCG_HELPER_PROTO helper_udiv(target_ulong a, target_ulong b); |
|
40 |
target_ulong TCG_HELPER_PROTO helper_sdiv(target_ulong a, target_ulong b); |
|
39 | 41 |
uint64_t TCG_HELPER_PROTO helper_pack64(target_ulong high, target_ulong low); |
40 | 42 |
uint64_t TCG_HELPER_PROTO helper_ld_asi(target_ulong addr, int asi, |
41 | 43 |
int size, int sign); |
b/target-sparc/op.c | ||
---|---|---|
169 | 169 |
#include "fop_template.h" |
170 | 170 |
#endif |
171 | 171 |
|
172 |
#define FLAG_SET(x) ((env->psr&x)?1:0) |
|
173 |
|
|
174 |
void OPPROTO op_udiv_T1_T0(void) |
|
175 |
{ |
|
176 |
uint64_t x0; |
|
177 |
uint32_t x1; |
|
178 |
|
|
179 |
x0 = T0 | ((uint64_t) (env->y) << 32); |
|
180 |
x1 = T1; |
|
181 |
|
|
182 |
if (x1 == 0) { |
|
183 |
raise_exception(TT_DIV_ZERO); |
|
184 |
} |
|
185 |
|
|
186 |
x0 = x0 / x1; |
|
187 |
if (x0 > 0xffffffff) { |
|
188 |
T0 = 0xffffffff; |
|
189 |
T1 = 1; |
|
190 |
} else { |
|
191 |
T0 = x0; |
|
192 |
T1 = 0; |
|
193 |
} |
|
194 |
FORCE_RET(); |
|
195 |
} |
|
196 |
|
|
197 |
void OPPROTO op_sdiv_T1_T0(void) |
|
198 |
{ |
|
199 |
int64_t x0; |
|
200 |
int32_t x1; |
|
201 |
|
|
202 |
x0 = T0 | ((int64_t) (env->y) << 32); |
|
203 |
x1 = T1; |
|
204 |
|
|
205 |
if (x1 == 0) { |
|
206 |
raise_exception(TT_DIV_ZERO); |
|
207 |
} |
|
208 |
|
|
209 |
x0 = x0 / x1; |
|
210 |
if ((int32_t) x0 != x0) { |
|
211 |
T0 = x0 < 0? 0x80000000: 0x7fffffff; |
|
212 |
T1 = 1; |
|
213 |
} else { |
|
214 |
T0 = x0; |
|
215 |
T1 = 0; |
|
216 |
} |
|
217 |
FORCE_RET(); |
|
218 |
} |
|
219 |
|
|
220 | 172 |
/* Load and store */ |
221 | 173 |
#define MEMSUFFIX _raw |
222 | 174 |
#include "op_mem.h" |
b/target-sparc/op_helper.c | ||
---|---|---|
1582 | 1582 |
} |
1583 | 1583 |
#endif |
1584 | 1584 |
|
1585 |
target_ulong helper_udiv(target_ulong a, target_ulong b) |
|
1586 |
{ |
|
1587 |
uint64_t x0; |
|
1588 |
uint32_t x1; |
|
1589 |
|
|
1590 |
x0 = a | ((uint64_t) (env->y) << 32); |
|
1591 |
x1 = b; |
|
1592 |
|
|
1593 |
if (x1 == 0) { |
|
1594 |
raise_exception(TT_DIV_ZERO); |
|
1595 |
} |
|
1596 |
|
|
1597 |
x0 = x0 / x1; |
|
1598 |
if (x0 > 0xffffffff) { |
|
1599 |
env->cc_src2 = 1; |
|
1600 |
return 0xffffffff; |
|
1601 |
} else { |
|
1602 |
env->cc_src2 = 0; |
|
1603 |
return x0; |
|
1604 |
} |
|
1605 |
} |
|
1606 |
|
|
1607 |
target_ulong helper_sdiv(target_ulong a, target_ulong b) |
|
1608 |
{ |
|
1609 |
int64_t x0; |
|
1610 |
int32_t x1; |
|
1611 |
|
|
1612 |
x0 = a | ((int64_t) (env->y) << 32); |
|
1613 |
x1 = b; |
|
1614 |
|
|
1615 |
if (x1 == 0) { |
|
1616 |
raise_exception(TT_DIV_ZERO); |
|
1617 |
} |
|
1618 |
|
|
1619 |
x0 = x0 / x1; |
|
1620 |
if ((int32_t) x0 != x0) { |
|
1621 |
env->cc_src2 = 1; |
|
1622 |
return x0 < 0? 0x80000000: 0x7fffffff; |
|
1623 |
} else { |
|
1624 |
env->cc_src2 = 0; |
|
1625 |
return x0; |
|
1626 |
} |
|
1627 |
} |
|
1628 |
|
|
1585 | 1629 |
uint64_t helper_pack64(target_ulong high, target_ulong low) |
1586 | 1630 |
{ |
1587 | 1631 |
return ((uint64_t)high << 32) | (uint64_t)(low & 0xffffffff); |
b/target-sparc/translate.c | ||
---|---|---|
807 | 807 |
tcg_gen_discard_i64(r_temp2); |
808 | 808 |
} |
809 | 809 |
|
810 |
static inline void gen_op_udiv_T1_T0(void) |
|
811 |
{ |
|
812 |
tcg_gen_helper_1_2(helper_udiv, cpu_T[0], cpu_T[0], cpu_T[1]); |
|
813 |
} |
|
814 |
|
|
815 |
static inline void gen_op_sdiv_T1_T0(void) |
|
816 |
{ |
|
817 |
tcg_gen_helper_1_2(helper_sdiv, cpu_T[0], cpu_T[0], cpu_T[1]); |
|
818 |
} |
|
819 |
|
|
810 | 820 |
#ifdef TARGET_SPARC64 |
811 | 821 |
static inline void gen_trap_ifdivzero_i64(TCGv divisor) |
812 | 822 |
{ |
... | ... | |
842 | 852 |
gen_cc_clear(); |
843 | 853 |
gen_cc_NZ(cpu_T[0]); |
844 | 854 |
l1 = gen_new_label(); |
845 |
tcg_gen_brcond_i32(TCG_COND_EQ, cpu_T[1], tcg_const_i32(0), l1); |
|
855 |
tcg_gen_ld_tl(cpu_tmp0, cpu_env, offsetof(CPUSPARCState, cc_src2)); |
|
856 |
tcg_gen_brcond_tl(TCG_COND_EQ, cpu_tmp0, tcg_const_tl(0), l1); |
|
846 | 857 |
tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_OVF); |
847 | 858 |
gen_set_label(l1); |
848 | 859 |
} |
Also available in: Unified diff