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: Xin Tong
Subject: Re: [Qemu-devel] cpu_regs in target-i386
Date: Sun, 27 Nov 2011 11:17:54 -0500

So the offset value (120) is really encapsulated in the TCGv
structure. and when we need the offset, we just call GET_TCGV_IA64
like what it is doing here

 static inline void tcg_gen_op3_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2,
                                   TCGv_i64 arg3)
{
    *gen_opc_ptr++ = opc;
    *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
    *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
}


Thanks

Xin


On Sun, Nov 27, 2011 at 10:43 AM, Peter Maydell
<address@hidden> wrote:
> 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]