unicorn_aarch64: Use aa64_vfp_qreg instead of aa32_vfp_dreg

This commit is contained in:
MerryMage 2018-09-03 07:47:40 +01:00
parent 896a8e1320
commit a13d51f756

View file

@ -63,22 +63,21 @@ int arm64_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int co
*(int32_t *)value = READ_DWORD(state->xregs[regid - UC_ARM64_REG_W0]); *(int32_t *)value = READ_DWORD(state->xregs[regid - UC_ARM64_REG_W0]);
} else if (regid >= UC_ARM64_REG_Q0 && regid <= UC_ARM64_REG_Q31) { } else if (regid >= UC_ARM64_REG_Q0 && regid <= UC_ARM64_REG_Q31) {
float64 *dst = (float64*) value; float64 *dst = (float64*) value;
const uint32_t reg_index = regid - UC_ARM64_REG_Q0; const float64 *q_reg = aa64_vfp_qreg(state, regid - UC_ARM64_REG_Q0);
const float64 *q_reg = aa64_vfp_qreg(state, reg_index);
dst[0] = q_reg[0]; dst[0] = q_reg[0];
dst[1] = q_reg[1]; dst[1] = q_reg[1];
} else if (regid >= UC_ARM64_REG_D0 && regid <= UC_ARM64_REG_D31) { } else if (regid >= UC_ARM64_REG_D0 && regid <= UC_ARM64_REG_D31) {
const float64 *d_reg = aa32_vfp_dreg(state, 2 * (regid - UC_ARM64_REG_D0)); const float64 *q_reg = aa64_vfp_qreg(state, regid - UC_ARM64_REG_D0);
*(float64*)value = *d_reg; *(float64*)value = *q_reg;
} else if (regid >= UC_ARM64_REG_S0 && regid <= UC_ARM64_REG_S31) { } else if (regid >= UC_ARM64_REG_S0 && regid <= UC_ARM64_REG_S31) {
const float64 *d_reg = aa32_vfp_dreg(state, 2 * (regid - UC_ARM64_REG_S0)); const float64 *q_reg = aa64_vfp_qreg(state, regid - UC_ARM64_REG_S0);
*(int32_t*)value = READ_DWORD(*d_reg); *(int32_t*)value = READ_DWORD(*q_reg);
} else if (regid >= UC_ARM64_REG_H0 && regid <= UC_ARM64_REG_H31) { } else if (regid >= UC_ARM64_REG_H0 && regid <= UC_ARM64_REG_H31) {
const float64 *d_reg = aa32_vfp_dreg(state, 2 * (regid - UC_ARM64_REG_H0)); const float64 *q_reg = aa64_vfp_qreg(state, regid - UC_ARM64_REG_H0);
*(int16_t*)value = READ_WORD(*d_reg); *(int16_t*)value = READ_WORD(*q_reg);
} else if (regid >= UC_ARM64_REG_B0 && regid <= UC_ARM64_REG_B31) { } else if (regid >= UC_ARM64_REG_B0 && regid <= UC_ARM64_REG_B31) {
const float64 *d_reg = aa32_vfp_dreg(state, 2 * (regid - UC_ARM64_REG_B0)); const float64 *q_reg = aa64_vfp_qreg(state, regid - UC_ARM64_REG_B0);
*(int8_t*)value = READ_BYTE_L(*d_reg); *(int8_t*)value = READ_BYTE_L(*q_reg);
} else { } else {
switch(regid) { switch(regid) {
default: break; default: break;
@ -146,22 +145,21 @@ int arm64_reg_write(struct uc_struct *uc, unsigned int *regs, void* const* vals,
WRITE_DWORD(state->xregs[regid - UC_ARM64_REG_W0], *(uint32_t *)value); WRITE_DWORD(state->xregs[regid - UC_ARM64_REG_W0], *(uint32_t *)value);
} else if (regid >= UC_ARM64_REG_Q0 && regid <= UC_ARM64_REG_Q31) { } else if (regid >= UC_ARM64_REG_Q0 && regid <= UC_ARM64_REG_Q31) {
const float64 *src = (const float64*) value; const float64 *src = (const float64*) value;
const uint32_t reg_index = regid - UC_ARM64_REG_Q0; float64 *q_reg = aa64_vfp_qreg(state, regid - UC_ARM64_REG_Q0);
float64 *q_reg = aa64_vfp_qreg(state, reg_index);
q_reg[0] = src[0]; q_reg[0] = src[0];
q_reg[1] = src[1]; q_reg[1] = src[1];
} else if (regid >= UC_ARM64_REG_D0 && regid <= UC_ARM64_REG_D31) { } else if (regid >= UC_ARM64_REG_D0 && regid <= UC_ARM64_REG_D31) {
float64 *d_reg = aa32_vfp_dreg(state, 2 * (regid - UC_ARM64_REG_D0)); float64 *q_reg = aa64_vfp_qreg(state, regid - UC_ARM64_REG_D0);
*d_reg = *(float64*) value; *q_reg = *(float64*) value;
} else if (regid >= UC_ARM64_REG_S0 && regid <= UC_ARM64_REG_S31) { } else if (regid >= UC_ARM64_REG_S0 && regid <= UC_ARM64_REG_S31) {
float64 *d_reg = aa32_vfp_dreg(state, 2 * (regid - UC_ARM64_REG_S0)); float64 *q_reg = aa64_vfp_qreg(state, regid - UC_ARM64_REG_S0);
WRITE_DWORD(*d_reg, *(int32_t*) value); WRITE_DWORD(*q_reg, *(int32_t*) value);
} else if (regid >= UC_ARM64_REG_H0 && regid <= UC_ARM64_REG_H31) { } else if (regid >= UC_ARM64_REG_H0 && regid <= UC_ARM64_REG_H31) {
float64 *d_reg = aa32_vfp_dreg(state, 2 * (regid - UC_ARM64_REG_H0)); float64 *q_reg = aa64_vfp_qreg(state, regid - UC_ARM64_REG_H0);
WRITE_WORD(*d_reg, *(int16_t*) value); WRITE_WORD(*q_reg, *(int16_t*) value);
} else if (regid >= UC_ARM64_REG_B0 && regid <= UC_ARM64_REG_B31) { } else if (regid >= UC_ARM64_REG_B0 && regid <= UC_ARM64_REG_B31) {
float64 *d_reg = aa32_vfp_dreg(state, 2 * (regid - UC_ARM64_REG_B0)); float64 *q_reg = aa64_vfp_qreg(state, regid - UC_ARM64_REG_B0);
WRITE_BYTE_L(*d_reg, *(int8_t*) value); WRITE_BYTE_L(*q_reg, *(int8_t*) value);
} else { } else {
switch(regid) { switch(regid) {
default: break; default: break;