On 11/24/21 11:22 AM, gaosong wrote:
I see that kernel define the fcc used type uint64_t, and used movgr2cf/movcf2gr
save and restore the fcc0-fcc7.
but qemu define fcc0-fcc7 as bool cf[8] at target/loongarch/cpu.h, how qemu can
save/restore fcc, Do you have any idea?
Does we can define the fcc as bool cf[8] at struct target_sigcontext?
No, you need to leave the declaration the same.
To create the uint64_t, you do what the kernel does in sc_save_fcc: insert each bit into
the first bit of each byte.
static uint64_t read_all_fcc(CPULoongArchState *env)
{
uint64_t ret = 0;
for (int i = 0; i < 8; ++i) {
ret |= (uint64_t)env->cf[i] << (i * 8);
}
return ret;
}
And similarly from sc_restore_fcc:
static void write_all_fcc(CPULoongArchState *env, uint64_t val)
{
for (int i = 0; i < 8; ++i) {
env->cf[i] = (val >> (i * 8)) & 1;
}
}
Remembering that movcf2gr copies the least significant bit.
r~