translate.c

来自「xen虚拟机源代码安装包」· C语言 代码 · 共 2,200 行 · 第 1/5 页

C
2,200
字号
    case 0xd:        gen_op_eval_fble(r_dst, cpu_fsr, offset);        break;    case 0xe:        gen_op_eval_fbule(r_dst, cpu_fsr, offset);        break;    case 0xf:        gen_op_eval_fbo(r_dst, cpu_fsr, offset);        break;    }}#ifdef TARGET_SPARC64// Inverted logicstatic const int gen_tcg_cond_reg[8] = {    -1,    TCG_COND_NE,    TCG_COND_GT,    TCG_COND_GE,    -1,    TCG_COND_EQ,    TCG_COND_LE,    TCG_COND_LT,};static inline void gen_cond_reg(TCGv r_dst, int cond, TCGv r_src){    int l1;    l1 = gen_new_label();    tcg_gen_movi_tl(r_dst, 0);    tcg_gen_brcond_tl(gen_tcg_cond_reg[cond], r_src, tcg_const_tl(0), l1);    tcg_gen_movi_tl(r_dst, 1);    gen_set_label(l1);}#endif/* XXX: potentially incorrect if dynamic npc */static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc,                      TCGv r_cond){    unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29));    target_ulong target = dc->pc + offset;    if (cond == 0x0) {        /* unconditional not taken */        if (a) {            dc->pc = dc->npc + 4;            dc->npc = dc->pc + 4;        } else {            dc->pc = dc->npc;            dc->npc = dc->pc + 4;        }    } else if (cond == 0x8) {        /* unconditional taken */        if (a) {            dc->pc = target;            dc->npc = dc->pc + 4;        } else {            dc->pc = dc->npc;            dc->npc = target;        }    } else {        flush_cond(dc, r_cond);        gen_cond(r_cond, cc, cond);        if (a) {            gen_branch_a(dc, target, dc->npc, r_cond);            dc->is_br = 1;        } else {            dc->pc = dc->npc;            dc->jump_pc[0] = target;            dc->jump_pc[1] = dc->npc + 4;            dc->npc = JUMP_PC;        }    }}/* XXX: potentially incorrect if dynamic npc */static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc,                      TCGv r_cond){    unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29));    target_ulong target = dc->pc + offset;    if (cond == 0x0) {        /* unconditional not taken */        if (a) {            dc->pc = dc->npc + 4;            dc->npc = dc->pc + 4;        } else {            dc->pc = dc->npc;            dc->npc = dc->pc + 4;        }    } else if (cond == 0x8) {        /* unconditional taken */        if (a) {            dc->pc = target;            dc->npc = dc->pc + 4;        } else {            dc->pc = dc->npc;            dc->npc = target;        }    } else {        flush_cond(dc, r_cond);        gen_fcond(r_cond, cc, cond);        if (a) {            gen_branch_a(dc, target, dc->npc, r_cond);            dc->is_br = 1;        } else {            dc->pc = dc->npc;            dc->jump_pc[0] = target;            dc->jump_pc[1] = dc->npc + 4;            dc->npc = JUMP_PC;        }    }}#ifdef TARGET_SPARC64/* XXX: potentially incorrect if dynamic npc */static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn,                          TCGv r_cond, TCGv r_reg){    unsigned int cond = GET_FIELD_SP(insn, 25, 27), a = (insn & (1 << 29));    target_ulong target = dc->pc + offset;    flush_cond(dc, r_cond);    gen_cond_reg(r_cond, cond, r_reg);    if (a) {        gen_branch_a(dc, target, dc->npc, r_cond);        dc->is_br = 1;    } else {        dc->pc = dc->npc;        dc->jump_pc[0] = target;        dc->jump_pc[1] = dc->npc + 4;        dc->npc = JUMP_PC;    }}static GenOpFunc * const gen_fcmps[4] = {    helper_fcmps,    helper_fcmps_fcc1,    helper_fcmps_fcc2,    helper_fcmps_fcc3,};static GenOpFunc * const gen_fcmpd[4] = {    helper_fcmpd,    helper_fcmpd_fcc1,    helper_fcmpd_fcc2,    helper_fcmpd_fcc3,};static GenOpFunc * const gen_fcmpq[4] = {    helper_fcmpq,    helper_fcmpq_fcc1,    helper_fcmpq_fcc2,    helper_fcmpq_fcc3,};static GenOpFunc * const gen_fcmpes[4] = {    helper_fcmpes,    helper_fcmpes_fcc1,    helper_fcmpes_fcc2,    helper_fcmpes_fcc3,};static GenOpFunc * const gen_fcmped[4] = {    helper_fcmped,    helper_fcmped_fcc1,    helper_fcmped_fcc2,    helper_fcmped_fcc3,};static GenOpFunc * const gen_fcmpeq[4] = {    helper_fcmpeq,    helper_fcmpeq_fcc1,    helper_fcmpeq_fcc2,    helper_fcmpeq_fcc3,};static inline void gen_op_fcmps(int fccno){    tcg_gen_helper_0_0(gen_fcmps[fccno]);}static inline void gen_op_fcmpd(int fccno){    tcg_gen_helper_0_0(gen_fcmpd[fccno]);}static inline void gen_op_fcmpq(int fccno){    tcg_gen_helper_0_0(gen_fcmpq[fccno]);}static inline void gen_op_fcmpes(int fccno){    tcg_gen_helper_0_0(gen_fcmpes[fccno]);}static inline void gen_op_fcmped(int fccno){    tcg_gen_helper_0_0(gen_fcmped[fccno]);}static inline void gen_op_fcmpeq(int fccno){    tcg_gen_helper_0_0(gen_fcmpeq[fccno]);}#elsestatic inline void gen_op_fcmps(int fccno){    tcg_gen_helper_0_0(helper_fcmps);}static inline void gen_op_fcmpd(int fccno){    tcg_gen_helper_0_0(helper_fcmpd);}static inline void gen_op_fcmpq(int fccno){    tcg_gen_helper_0_0(helper_fcmpq);}static inline void gen_op_fcmpes(int fccno){    tcg_gen_helper_0_0(helper_fcmpes);}static inline void gen_op_fcmped(int fccno){    tcg_gen_helper_0_0(helper_fcmped);}static inline void gen_op_fcmpeq(int fccno){    tcg_gen_helper_0_0(helper_fcmpeq);}#endifstatic inline void gen_op_fpexception_im(int fsr_flags){    tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~FSR_FTT_MASK);    tcg_gen_ori_tl(cpu_fsr, cpu_fsr, fsr_flags);    tcg_gen_helper_0_1(raise_exception, tcg_const_i32(TT_FP_EXCP));}static int gen_trap_ifnofpu(DisasContext *dc, TCGv r_cond){#if !defined(CONFIG_USER_ONLY)    if (!dc->fpu_enabled) {        save_state(dc, r_cond);        tcg_gen_helper_0_1(raise_exception, tcg_const_i32(TT_NFPU_INSN));        dc->is_br = 1;        return 1;    }#endif    return 0;}static inline void gen_op_clear_ieee_excp_and_FTT(void){    tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~(FSR_FTT_MASK | FSR_CEXC_MASK));}static inline void gen_clear_float_exceptions(void){    tcg_gen_helper_0_0(helper_clear_float_exceptions);}/* asi moves */#ifdef TARGET_SPARC64static inline TCGv gen_get_asi(int insn, TCGv r_addr){    int asi, offset;    TCGv r_asi;    if (IS_IMM) {        r_asi = tcg_temp_new(TCG_TYPE_I32);        offset = GET_FIELD(insn, 25, 31);        tcg_gen_addi_tl(r_addr, r_addr, offset);        tcg_gen_ld_i32(r_asi, cpu_env, offsetof(CPUSPARCState, asi));    } else {        asi = GET_FIELD(insn, 19, 26);        r_asi = tcg_const_i32(asi);    }    return r_asi;}static inline void gen_ld_asi(TCGv dst, TCGv addr, int insn, int size,                              int sign){    TCGv r_asi;    r_asi = gen_get_asi(insn, addr);    tcg_gen_helper_1_4(helper_ld_asi, dst, addr, r_asi,                       tcg_const_i32(size), tcg_const_i32(sign));}static inline void gen_st_asi(TCGv src, TCGv addr, int insn, int size){    TCGv r_asi;    r_asi = gen_get_asi(insn, addr);    tcg_gen_helper_0_4(helper_st_asi, addr, src, r_asi, tcg_const_i32(size));}static inline void gen_ldf_asi(TCGv addr, int insn, int size, int rd){    TCGv r_asi;    r_asi = gen_get_asi(insn, addr);    tcg_gen_helper_0_4(helper_ldf_asi, addr, r_asi, tcg_const_i32(size),                       tcg_const_i32(rd));}static inline void gen_stf_asi(TCGv addr, int insn, int size, int rd){    TCGv r_asi;    r_asi = gen_get_asi(insn, addr);    tcg_gen_helper_0_4(helper_stf_asi, addr, r_asi, tcg_const_i32(size),                       tcg_const_i32(rd));}static inline void gen_swap_asi(TCGv dst, TCGv addr, int insn){    TCGv r_temp, r_asi;    r_temp = tcg_temp_new(TCG_TYPE_I32);    r_asi = gen_get_asi(insn, addr);    tcg_gen_helper_1_4(helper_ld_asi, r_temp, addr, r_asi,                       tcg_const_i32(4), tcg_const_i32(0));    tcg_gen_helper_0_4(helper_st_asi, addr, dst, r_asi,                       tcg_const_i32(4));    tcg_gen_extu_i32_tl(dst, r_temp);}static inline void gen_ldda_asi(TCGv lo, TCGv hi, TCGv addr, int insn){    TCGv r_asi;    r_asi = gen_get_asi(insn, addr);    tcg_gen_helper_1_4(helper_ld_asi, cpu_tmp64, addr, r_asi,                       tcg_const_i32(8), tcg_const_i32(0));    tcg_gen_andi_i64(lo, cpu_tmp64, 0xffffffffULL);    tcg_gen_shri_i64(cpu_tmp64, cpu_tmp64, 32);    tcg_gen_andi_i64(hi, cpu_tmp64, 0xffffffffULL);}static inline void gen_stda_asi(TCGv hi, TCGv addr, int insn, int rd){    TCGv r_temp, r_asi;    r_temp = tcg_temp_new(TCG_TYPE_I32);    gen_movl_reg_TN(rd + 1, r_temp);    tcg_gen_helper_1_2(helper_pack64, cpu_tmp64, hi,                       r_temp);    r_asi = gen_get_asi(insn, addr);    tcg_gen_helper_0_4(helper_st_asi, addr, cpu_tmp64, r_asi,                       tcg_const_i32(8));}static inline void gen_cas_asi(TCGv dst, TCGv addr, TCGv val2, int insn,                               int rd){    TCGv r_val1, r_asi;    r_val1 = tcg_temp_new(TCG_TYPE_I32);    gen_movl_reg_TN(rd, r_val1);    r_asi = gen_get_asi(insn, addr);    tcg_gen_helper_1_4(helper_cas_asi, dst, addr, r_val1, val2, r_asi);}static inline void gen_casx_asi(TCGv dst, TCGv addr, TCGv val2, int insn,                                int rd){    TCGv r_asi;    gen_movl_reg_TN(rd, cpu_tmp64);    r_asi = gen_get_asi(insn, addr);    tcg_gen_helper_1_4(helper_casx_asi, dst, addr, cpu_tmp64, val2, r_asi);}#elif !defined(CONFIG_USER_ONLY)static inline void gen_ld_asi(TCGv dst, TCGv addr, int insn, int size,                              int sign){    int asi;    asi = GET_FIELD(insn, 19, 26);    tcg_gen_helper_1_4(helper_ld_asi, cpu_tmp64, addr, tcg_const_i32(asi),                       tcg_const_i32(size), tcg_const_i32(sign));    tcg_gen_trunc_i64_tl(dst, cpu_tmp64);}static inline void gen_st_asi(TCGv src, TCGv addr, int insn, int size){    int asi;    tcg_gen_extu_tl_i64(cpu_tmp64, src);    asi = GET_FIELD(insn, 19, 26);    tcg_gen_helper_0_4(helper_st_asi, addr, cpu_tmp64, tcg_const_i32(asi),                       tcg_const_i32(size));}static inline void gen_swap_asi(TCGv dst, TCGv addr, int insn){    int asi;    TCGv r_temp;    r_temp = tcg_temp_new(TCG_TYPE_I32);    asi = GET_FIELD(insn, 19, 26);    tcg_gen_helper_1_4(helper_ld_asi, r_temp, addr, tcg_const_i32(asi),                       tcg_const_i32(4), tcg_const_i32(0));    tcg_gen_helper_0_4(helper_st_asi, addr, dst, tcg_const_i32(asi),                       tcg_const_i32(4));    tcg_gen_extu_i32_tl(dst, r_temp);}static inline void gen_ldda_asi(TCGv lo, TCGv hi, TCGv addr, int insn){    int asi;    asi = GET_FIELD(insn, 19, 26);    tcg_gen_helper_1_4(helper_ld_asi, cpu_tmp64, addr, tcg_const_i32(asi),                       tcg_const_i32(8), tcg_const_i32(0));    tcg_gen_trunc_i64_tl(lo, cpu_tmp64);    tcg_gen_shri_i64(cpu_tmp64, cpu_tmp64, 32);    tcg_gen_trunc_i64_tl(hi, cpu_tmp64);}static inline void gen_stda_asi(TCGv hi, TCGv addr, int insn, int rd){    int asi;    TCGv r_temp;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?