CRIS: Use a helper for lz.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6205 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
		
							parent
							
								
									85220fba35
								
							
						
					
					
						commit
						c38ac98da5
					
				@ -10,6 +10,7 @@ DEF_HELPER_0(rfn, void);
 | 
				
			|||||||
DEF_HELPER_2(movl_sreg_reg, void, i32, i32)
 | 
					DEF_HELPER_2(movl_sreg_reg, void, i32, i32)
 | 
				
			||||||
DEF_HELPER_2(movl_reg_sreg, void, i32, i32)
 | 
					DEF_HELPER_2(movl_reg_sreg, void, i32, i32)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DEF_HELPER_FLAGS_1(lz, TCG_CALL_PURE, i32, i32);
 | 
				
			||||||
DEF_HELPER_FLAGS_3(btst, TCG_CALL_PURE, i32, i32, i32, i32);
 | 
					DEF_HELPER_FLAGS_3(btst, TCG_CALL_PURE, i32, i32, i32, i32);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DEF_HELPER_0(evaluate_flags_muls, void)
 | 
					DEF_HELPER_0(evaluate_flags_muls, void)
 | 
				
			||||||
 | 
				
			|||||||
@ -23,6 +23,7 @@
 | 
				
			|||||||
#include "exec.h"
 | 
					#include "exec.h"
 | 
				
			||||||
#include "mmu.h"
 | 
					#include "mmu.h"
 | 
				
			||||||
#include "helper.h"
 | 
					#include "helper.h"
 | 
				
			||||||
 | 
					#include "host-utils.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define D(x)
 | 
					#define D(x)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -243,6 +244,11 @@ void helper_rfn(void)
 | 
				
			|||||||
    env->pregs[PR_CCS] |= M_FLAG;
 | 
					    env->pregs[PR_CCS] |= M_FLAG;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					uint32_t helper_lz(uint32_t t0)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return clz32(t0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint32_t helper_btst(uint32_t t0, uint32_t t1, uint32_t ccs)
 | 
					uint32_t helper_btst(uint32_t t0, uint32_t t1, uint32_t ccs)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/* FIXME: clean this up.  */
 | 
						/* FIXME: clean this up.  */
 | 
				
			||||||
 | 
				
			|||||||
@ -320,74 +320,6 @@ static void t_gen_mulu(TCGv d, TCGv d2, TCGv a, TCGv b)
 | 
				
			|||||||
	tcg_temp_free_i64(t1);
 | 
						tcg_temp_free_i64(t1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* 32bit branch-free binary search for counting leading zeros.  */
 | 
					 | 
				
			||||||
static void t_gen_lz_i32(TCGv d, TCGv x)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	TCGv_i32 y, m, n;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	y = tcg_temp_new_i32();
 | 
					 | 
				
			||||||
	m = tcg_temp_new_i32();
 | 
					 | 
				
			||||||
	n = tcg_temp_new_i32();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* y = -(x >> 16)  */
 | 
					 | 
				
			||||||
	tcg_gen_shri_i32(y, x, 16);
 | 
					 | 
				
			||||||
	tcg_gen_neg_i32(y, y);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* m = (y >> 16) & 16  */
 | 
					 | 
				
			||||||
	tcg_gen_sari_i32(m, y, 16);
 | 
					 | 
				
			||||||
	tcg_gen_andi_i32(m, m, 16);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* n = 16 - m  */
 | 
					 | 
				
			||||||
	tcg_gen_sub_i32(n, tcg_const_i32(16), m);
 | 
					 | 
				
			||||||
	/* x = x >> m  */
 | 
					 | 
				
			||||||
	tcg_gen_shr_i32(x, x, m);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* y = x - 0x100  */
 | 
					 | 
				
			||||||
	tcg_gen_subi_i32(y, x, 0x100);
 | 
					 | 
				
			||||||
	/* m = (y >> 16) & 8  */
 | 
					 | 
				
			||||||
	tcg_gen_sari_i32(m, y, 16);
 | 
					 | 
				
			||||||
	tcg_gen_andi_i32(m, m, 8);
 | 
					 | 
				
			||||||
	/* n = n + m  */
 | 
					 | 
				
			||||||
	tcg_gen_add_i32(n, n, m);
 | 
					 | 
				
			||||||
	/* x = x << m  */
 | 
					 | 
				
			||||||
	tcg_gen_shl_i32(x, x, m);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* y = x - 0x1000  */
 | 
					 | 
				
			||||||
	tcg_gen_subi_i32(y, x, 0x1000);
 | 
					 | 
				
			||||||
	/* m = (y >> 16) & 4  */
 | 
					 | 
				
			||||||
	tcg_gen_sari_i32(m, y, 16);
 | 
					 | 
				
			||||||
	tcg_gen_andi_i32(m, m, 4);
 | 
					 | 
				
			||||||
	/* n = n + m  */
 | 
					 | 
				
			||||||
	tcg_gen_add_i32(n, n, m);
 | 
					 | 
				
			||||||
	/* x = x << m  */
 | 
					 | 
				
			||||||
	tcg_gen_shl_i32(x, x, m);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* y = x - 0x4000  */
 | 
					 | 
				
			||||||
	tcg_gen_subi_i32(y, x, 0x4000);
 | 
					 | 
				
			||||||
	/* m = (y >> 16) & 2  */
 | 
					 | 
				
			||||||
	tcg_gen_sari_i32(m, y, 16);
 | 
					 | 
				
			||||||
	tcg_gen_andi_i32(m, m, 2);
 | 
					 | 
				
			||||||
	/* n = n + m  */
 | 
					 | 
				
			||||||
	tcg_gen_add_i32(n, n, m);
 | 
					 | 
				
			||||||
	/* x = x << m  */
 | 
					 | 
				
			||||||
	tcg_gen_shl_i32(x, x, m);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* y = x >> 14  */
 | 
					 | 
				
			||||||
	tcg_gen_shri_i32(y, x, 14);
 | 
					 | 
				
			||||||
	/* m = y & ~(y >> 1)  */
 | 
					 | 
				
			||||||
	tcg_gen_sari_i32(m, y, 1);
 | 
					 | 
				
			||||||
	tcg_gen_not_i32(m, m);
 | 
					 | 
				
			||||||
	tcg_gen_and_i32(m, m, y);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* d = n + 2 - m  */
 | 
					 | 
				
			||||||
	tcg_gen_addi_i32(d, n, 2);
 | 
					 | 
				
			||||||
	tcg_gen_sub_i32(d, d, m);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	tcg_temp_free(y);
 | 
					 | 
				
			||||||
	tcg_temp_free(m);
 | 
					 | 
				
			||||||
	tcg_temp_free(n);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void t_gen_cris_dstep(TCGv d, TCGv a, TCGv b)
 | 
					static void t_gen_cris_dstep(TCGv d, TCGv a, TCGv b)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int l1;
 | 
						int l1;
 | 
				
			||||||
@ -825,7 +757,7 @@ static void cris_alu_op_exec(DisasContext *dc, int op,
 | 
				
			|||||||
			t_gen_subx_carry(dc, dst);
 | 
								t_gen_subx_carry(dc, dst);
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case CC_OP_LZ:
 | 
							case CC_OP_LZ:
 | 
				
			||||||
			t_gen_lz_i32(dst, b);
 | 
								gen_helper_lz(dst, b);
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case CC_OP_MULS:
 | 
							case CC_OP_MULS:
 | 
				
			||||||
			t_gen_muls(dst, cpu_PR[PR_MOF], a, b);
 | 
								t_gen_muls(dst, cpu_PR[PR_MOF], a, b);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user