translate.c
来自「xen虚拟机源代码安装包」· C语言 代码 · 共 2,286 行 · 第 1/5 页
C
2,286 行
static inline void gen_movl_reg_T0(DisasContext *s, int reg){ gen_movl_reg_TN(s, reg, 0);}static inline void gen_movl_reg_T1(DisasContext *s, int reg){ gen_movl_reg_TN(s, reg, 1);}/* Force a TB lookup after an instruction that changes the CPU state. */static inline void gen_lookup_tb(DisasContext *s){ gen_op_movl_T0_im(s->pc); gen_movl_reg_T0(s, 15); s->is_jmp = DISAS_UPDATE;}static inline void gen_add_data_offset(DisasContext *s, unsigned int insn, TCGv var){ int val, rm, shift, shiftop; TCGv offset; if (!(insn & (1 << 25))) { /* immediate */ val = insn & 0xfff; if (!(insn & (1 << 23))) val = -val; if (val != 0) tcg_gen_addi_i32(var, var, val); } else { /* shift/register */ rm = (insn) & 0xf; shift = (insn >> 7) & 0x1f; shiftop = (insn >> 5) & 3; offset = load_reg(s, rm); gen_arm_shift_im(offset, shiftop, shift, 0); if (!(insn & (1 << 23))) tcg_gen_sub_i32(var, var, offset); else tcg_gen_add_i32(var, var, offset); dead_tmp(offset); }}static inline void gen_add_datah_offset(DisasContext *s, unsigned int insn, int extra, TCGv var){ int val, rm; TCGv offset; if (insn & (1 << 22)) { /* immediate */ val = (insn & 0xf) | ((insn >> 4) & 0xf0); if (!(insn & (1 << 23))) val = -val; val += extra; if (val != 0) tcg_gen_addi_i32(var, var, val); } else { /* register */ if (extra) tcg_gen_addi_i32(var, var, extra); rm = (insn) & 0xf; offset = load_reg(s, rm); if (!(insn & (1 << 23))) tcg_gen_sub_i32(var, var, offset); else tcg_gen_add_i32(var, var, offset); dead_tmp(offset); }}#define VFP_OP2(name) \static inline void gen_vfp_##name(int dp) \{ \ if (dp) \ gen_helper_vfp_##name##d(cpu_F0d, cpu_F0d, cpu_F1d, cpu_env); \ else \ gen_helper_vfp_##name##s(cpu_F0s, cpu_F0s, cpu_F1s, cpu_env); \}#define VFP_OP1(name) \static inline void gen_vfp_##name(int dp, int arg) \{ \ if (dp) \ gen_op_vfp_##name##d(arg); \ else \ gen_op_vfp_##name##s(arg); \}VFP_OP2(add)VFP_OP2(sub)VFP_OP2(mul)VFP_OP2(div)#undef VFP_OP2static inline void gen_vfp_abs(int dp){ if (dp) gen_helper_vfp_absd(cpu_F0d, cpu_F0d); else gen_helper_vfp_abss(cpu_F0s, cpu_F0s);}static inline void gen_vfp_neg(int dp){ if (dp) gen_helper_vfp_negd(cpu_F0d, cpu_F0d); else gen_helper_vfp_negs(cpu_F0s, cpu_F0s);}static inline void gen_vfp_sqrt(int dp){ if (dp) gen_helper_vfp_sqrtd(cpu_F0d, cpu_F0d, cpu_env); else gen_helper_vfp_sqrts(cpu_F0s, cpu_F0s, cpu_env);}static inline void gen_vfp_cmp(int dp){ if (dp) gen_helper_vfp_cmpd(cpu_F0d, cpu_F1d, cpu_env); else gen_helper_vfp_cmps(cpu_F0s, cpu_F1s, cpu_env);}static inline void gen_vfp_cmpe(int dp){ if (dp) gen_helper_vfp_cmped(cpu_F0d, cpu_F1d, cpu_env); else gen_helper_vfp_cmpes(cpu_F0s, cpu_F1s, cpu_env);}static inline void gen_vfp_F1_ld0(int dp){ if (dp) tcg_gen_movi_i64(cpu_F1d, 0); else tcg_gen_movi_i32(cpu_F1s, 0);}static inline void gen_vfp_uito(int dp){ if (dp) gen_helper_vfp_uitod(cpu_F0d, cpu_F0s, cpu_env); else gen_helper_vfp_uitos(cpu_F0s, cpu_F0s, cpu_env);}static inline void gen_vfp_sito(int dp){ if (dp) gen_helper_vfp_sitod(cpu_F0d, cpu_F0s, cpu_env); else gen_helper_vfp_sitos(cpu_F0s, cpu_F0s, cpu_env);}static inline void gen_vfp_toui(int dp){ if (dp) gen_helper_vfp_touid(cpu_F0s, cpu_F0d, cpu_env); else gen_helper_vfp_touis(cpu_F0s, cpu_F0s, cpu_env);}static inline void gen_vfp_touiz(int dp){ if (dp) gen_helper_vfp_touizd(cpu_F0s, cpu_F0d, cpu_env); else gen_helper_vfp_touizs(cpu_F0s, cpu_F0s, cpu_env);}static inline void gen_vfp_tosi(int dp){ if (dp) gen_helper_vfp_tosid(cpu_F0s, cpu_F0d, cpu_env); else gen_helper_vfp_tosis(cpu_F0s, cpu_F0s, cpu_env);}static inline void gen_vfp_tosiz(int dp){ if (dp) gen_helper_vfp_tosizd(cpu_F0s, cpu_F0d, cpu_env); else gen_helper_vfp_tosizs(cpu_F0s, cpu_F0s, cpu_env);}#define VFP_GEN_FIX(name) \static inline void gen_vfp_##name(int dp, int shift) \{ \ if (dp) \ gen_helper_vfp_##name##d(cpu_F0d, cpu_F0d, tcg_const_i32(shift), cpu_env);\ else \ gen_helper_vfp_##name##s(cpu_F0s, cpu_F0s, tcg_const_i32(shift), cpu_env);\}VFP_GEN_FIX(tosh)VFP_GEN_FIX(tosl)VFP_GEN_FIX(touh)VFP_GEN_FIX(toul)VFP_GEN_FIX(shto)VFP_GEN_FIX(slto)VFP_GEN_FIX(uhto)VFP_GEN_FIX(ulto)#undef VFP_GEN_FIXstatic inline void gen_vfp_ld(DisasContext *s, int dp){ if (dp) tcg_gen_qemu_ld64(cpu_F0d, cpu_T[1], IS_USER(s)); else tcg_gen_qemu_ld32u(cpu_F0s, cpu_T[1], IS_USER(s));}static inline void gen_vfp_st(DisasContext *s, int dp){ if (dp) tcg_gen_qemu_st64(cpu_F0d, cpu_T[1], IS_USER(s)); else tcg_gen_qemu_st32(cpu_F0s, cpu_T[1], IS_USER(s));}static inline longvfp_reg_offset (int dp, int reg){ if (dp) return offsetof(CPUARMState, vfp.regs[reg]); else if (reg & 1) { return offsetof(CPUARMState, vfp.regs[reg >> 1]) + offsetof(CPU_DoubleU, l.upper); } else { return offsetof(CPUARMState, vfp.regs[reg >> 1]) + offsetof(CPU_DoubleU, l.lower); }}/* Return the offset of a 32-bit piece of a NEON register. zero is the least significant end of the register. */static inline longneon_reg_offset (int reg, int n){ int sreg; sreg = reg * 2 + n; return vfp_reg_offset(0, sreg);}/* FIXME: Remove these. */#define neon_T0 cpu_T[0]#define neon_T1 cpu_T[1]#define NEON_GET_REG(T, reg, n) \ tcg_gen_ld_i32(neon_##T, cpu_env, neon_reg_offset(reg, n))#define NEON_SET_REG(T, reg, n) \ tcg_gen_st_i32(neon_##T, cpu_env, neon_reg_offset(reg, n))static TCGv neon_load_reg(int reg, int pass){ TCGv tmp = new_tmp(); tcg_gen_ld_i32(tmp, cpu_env, neon_reg_offset(reg, pass)); return tmp;}static void neon_store_reg(int reg, int pass, TCGv var){ tcg_gen_st_i32(var, cpu_env, neon_reg_offset(reg, pass)); dead_tmp(var);}static inline void neon_load_reg64(TCGv var, int reg){ tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(1, reg));}static inline void neon_store_reg64(TCGv var, int reg){ tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(1, reg));}#define tcg_gen_ld_f32 tcg_gen_ld_i32#define tcg_gen_ld_f64 tcg_gen_ld_i64#define tcg_gen_st_f32 tcg_gen_st_i32#define tcg_gen_st_f64 tcg_gen_st_i64static inline void gen_mov_F0_vreg(int dp, int reg){ if (dp) tcg_gen_ld_f64(cpu_F0d, cpu_env, vfp_reg_offset(dp, reg)); else tcg_gen_ld_f32(cpu_F0s, cpu_env, vfp_reg_offset(dp, reg));}static inline void gen_mov_F1_vreg(int dp, int reg){ if (dp) tcg_gen_ld_f64(cpu_F1d, cpu_env, vfp_reg_offset(dp, reg)); else tcg_gen_ld_f32(cpu_F1s, cpu_env, vfp_reg_offset(dp, reg));}static inline void gen_mov_vreg_F0(int dp, int reg){ if (dp) tcg_gen_st_f64(cpu_F0d, cpu_env, vfp_reg_offset(dp, reg)); else tcg_gen_st_f32(cpu_F0s, cpu_env, vfp_reg_offset(dp, reg));}#define ARM_CP_RW_BIT (1 << 20)static inline void iwmmxt_load_reg(TCGv var, int reg){ tcg_gen_ld_i64(var, cpu_env, offsetof(CPUState, iwmmxt.regs[reg]));}static inline void iwmmxt_store_reg(TCGv var, int reg){ tcg_gen_st_i64(var, cpu_env, offsetof(CPUState, iwmmxt.regs[reg]));}static inline void gen_op_iwmmxt_movl_wCx_T0(int reg){ tcg_gen_st_i32(cpu_T[0], cpu_env, offsetof(CPUState, iwmmxt.cregs[reg]));}static inline void gen_op_iwmmxt_movl_T0_wCx(int reg){ tcg_gen_ld_i32(cpu_T[0], cpu_env, offsetof(CPUState, iwmmxt.cregs[reg]));}static inline void gen_op_iwmmxt_movl_T1_wCx(int reg){ tcg_gen_ld_i32(cpu_T[1], cpu_env, offsetof(CPUState, iwmmxt.cregs[reg]));}static inline void gen_op_iwmmxt_movq_wRn_M0(int rn){ iwmmxt_store_reg(cpu_M0, rn);}static inline void gen_op_iwmmxt_movq_M0_wRn(int rn){ iwmmxt_load_reg(cpu_M0, rn);}static inline void gen_op_iwmmxt_orq_M0_wRn(int rn){ iwmmxt_load_reg(cpu_V1, rn); tcg_gen_or_i64(cpu_M0, cpu_M0, cpu_V1);}static inline void gen_op_iwmmxt_andq_M0_wRn(int rn){ iwmmxt_load_reg(cpu_V1, rn); tcg_gen_and_i64(cpu_M0, cpu_M0, cpu_V1);}static inline void gen_op_iwmmxt_xorq_M0_wRn(int rn){ iwmmxt_load_reg(cpu_V1, rn); tcg_gen_xor_i64(cpu_M0, cpu_M0, cpu_V1);}#define IWMMXT_OP(name) \static inline void gen_op_iwmmxt_##name##_M0_wRn(int rn) \{ \ iwmmxt_load_reg(cpu_V1, rn); \ gen_helper_iwmmxt_##name(cpu_M0, cpu_M0, cpu_V1); \}#define IWMMXT_OP_ENV(name) \static inline void gen_op_iwmmxt_##name##_M0_wRn(int rn) \{ \ iwmmxt_load_reg(cpu_V1, rn); \ gen_helper_iwmmxt_##name(cpu_M0, cpu_env, cpu_M0, cpu_V1); \}#define IWMMXT_OP_ENV_SIZE(name) \IWMMXT_OP_ENV(name##b) \IWMMXT_OP_ENV(name##w) \IWMMXT_OP_ENV(name##l)#define IWMMXT_OP_ENV1(name) \static inline void gen_op_iwmmxt_##name##_M0(void) \{ \ gen_helper_iwmmxt_##name(cpu_M0, cpu_env, cpu_M0); \}IWMMXT_OP(maddsq)IWMMXT_OP(madduq)IWMMXT_OP(sadb)IWMMXT_OP(sadw)IWMMXT_OP(mulslw)IWMMXT_OP(mulshw)IWMMXT_OP(mululw)IWMMXT_OP(muluhw)IWMMXT_OP(macsw)IWMMXT_OP(macuw)IWMMXT_OP_ENV_SIZE(unpackl)IWMMXT_OP_ENV_SIZE(unpackh)IWMMXT_OP_ENV1(unpacklub)IWMMXT_OP_ENV1(unpackluw)IWMMXT_OP_ENV1(unpacklul)IWMMXT_OP_ENV1(unpackhub)IWMMXT_OP_ENV1(unpackhuw)IWMMXT_OP_ENV1(unpackhul)IWMMXT_OP_ENV1(unpacklsb)IWMMXT_OP_ENV1(unpacklsw)IWMMXT_OP_ENV1(unpacklsl)IWMMXT_OP_ENV1(unpackhsb)IWMMXT_OP_ENV1(unpackhsw)IWMMXT_OP_ENV1(unpackhsl)IWMMXT_OP_ENV_SIZE(cmpeq)IWMMXT_OP_ENV_SIZE(cmpgtu)IWMMXT_OP_ENV_SIZE(cmpgts)IWMMXT_OP_ENV_SIZE(mins)IWMMXT_OP_ENV_SIZE(minu)IWMMXT_OP_ENV_SIZE(maxs)IWMMXT_OP_ENV_SIZE(maxu)IWMMXT_OP_ENV_SIZE(subn)IWMMXT_OP_ENV_SIZE(addn)IWMMXT_OP_ENV_SIZE(subu)IWMMXT_OP_ENV_SIZE(addu)IWMMXT_OP_ENV_SIZE(subs)IWMMXT_OP_ENV_SIZE(adds)IWMMXT_OP_ENV(avgb0)IWMMXT_OP_ENV(avgb1)IWMMXT_OP_ENV(avgw0)IWMMXT_OP_ENV(avgw1)IWMMXT_OP(msadb)IWMMXT_OP_ENV(packuw)IWMMXT_OP_ENV(packul)IWMMXT_OP_ENV(packuq)IWMMXT_OP_ENV(packsw)IWMMXT_OP_ENV(packsl)IWMMXT_OP_ENV(packsq)static inline void gen_op_iwmmxt_muladdsl_M0_T0_T1(void){ gen_helper_iwmmxt_muladdsl(cpu_M0, cpu_M0, cpu_T[0], cpu_T[1]);}static inline void gen_op_iwmmxt_muladdsw_M0_T0_T1(void){
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?