Commit 3b89f26c11e4060a203518d8bc203b6fb0b6cf96

Authored by blueswir1
1 parent 2483386a

Convert udiv and sdiv ops to TCG


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4088 c046a42c-6fe2-441c-8c8c-71466251a162
target-sparc/helper.h
@@ -36,6 +36,8 @@ void TCG_HELPER_PROTO helper_trapcc(target_ulong nb_trap, @@ -36,6 +36,8 @@ void TCG_HELPER_PROTO helper_trapcc(target_ulong nb_trap,
36 target_ulong do_trap); 36 target_ulong do_trap);
37 void TCG_HELPER_PROTO helper_debug(void); 37 void TCG_HELPER_PROTO helper_debug(void);
38 void TCG_HELPER_PROTO helper_flush(target_ulong addr); 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 uint64_t TCG_HELPER_PROTO helper_pack64(target_ulong high, target_ulong low); 41 uint64_t TCG_HELPER_PROTO helper_pack64(target_ulong high, target_ulong low);
40 uint64_t TCG_HELPER_PROTO helper_ld_asi(target_ulong addr, int asi, 42 uint64_t TCG_HELPER_PROTO helper_ld_asi(target_ulong addr, int asi,
41 int size, int sign); 43 int size, int sign);
target-sparc/op.c
@@ -169,54 +169,6 @@ @@ -169,54 +169,6 @@
169 #include "fop_template.h" 169 #include "fop_template.h"
170 #endif 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 /* Load and store */ 172 /* Load and store */
221 #define MEMSUFFIX _raw 173 #define MEMSUFFIX _raw
222 #include "op_mem.h" 174 #include "op_mem.h"
target-sparc/op_helper.c
@@ -1582,6 +1582,50 @@ void helper_rett(void) @@ -1582,6 +1582,50 @@ void helper_rett(void)
1582 } 1582 }
1583 #endif 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 uint64_t helper_pack64(target_ulong high, target_ulong low) 1629 uint64_t helper_pack64(target_ulong high, target_ulong low)
1586 { 1630 {
1587 return ((uint64_t)high << 32) | (uint64_t)(low & 0xffffffff); 1631 return ((uint64_t)high << 32) | (uint64_t)(low & 0xffffffff);
target-sparc/translate.c
@@ -807,6 +807,16 @@ static inline void gen_op_smul_T1_T0(void) @@ -807,6 +807,16 @@ static inline void gen_op_smul_T1_T0(void)
807 tcg_gen_discard_i64(r_temp2); 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 #ifdef TARGET_SPARC64 820 #ifdef TARGET_SPARC64
811 static inline void gen_trap_ifdivzero_i64(TCGv divisor) 821 static inline void gen_trap_ifdivzero_i64(TCGv divisor)
812 { 822 {
@@ -842,7 +852,8 @@ static inline void gen_op_div_cc(void) @@ -842,7 +852,8 @@ static inline void gen_op_div_cc(void)
842 gen_cc_clear(); 852 gen_cc_clear();
843 gen_cc_NZ(cpu_T[0]); 853 gen_cc_NZ(cpu_T[0]);
844 l1 = gen_new_label(); 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 tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_OVF); 857 tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_OVF);
847 gen_set_label(l1); 858 gen_set_label(l1);
848 } 859 }