qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] cpu_regs in target-i386


From: Peter Maydell
Subject: Re: [Qemu-devel] cpu_regs in target-i386
Date: Sun, 27 Nov 2011 15:43:47 +0000

On 27 November 2011 15:23, Xin Tong <address@hidden> wrote:
>  cpu_regs[15] = tcg_global_mem_new_i64(TCG_AREG0,
>                                          offsetof(CPUState, regs[15]), "r15");
>  printf("offsetof(CPUState, regs[15]) is %ld\n", offsetof(CPUState, 
> regs[15]));

> output is cpu_regs[15] is 20, offsetof(CPUState, regs[15]) is 120,
> should not cpu_regs[15] == 120 ?

No. tcg_global_mem_new_i64() returns a TCGv, which is (as far as
code in translate.c is concerned) an opaque reference which can
be passed to other TCG functions to cause code to be emitted
which uses that value (eg "add this value to something else").
So conceptually it represents "the value at the memory location
at (TCG_AREG0 + some offset)". If you then use this TCGv in a
tcg_gen_add_i64() we will generate code to load the value from
memory and add it. (TCG values can also be "the value stored in
this fixed native register" (used basically only for the cpu_env
pointer itself) or "a temporary value which TCG is free to allocate
to a register as it likes" (the most common).)

[The implementation is that it is an index into an array of
all the TCGv values TCG knows about, which is why it's a small
integer.]

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]