qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Where is the definition of struct TCGv_i32_d?


From: Peter Maydell
Subject: Re: [Qemu-devel] Where is the definition of struct TCGv_i32_d?
Date: Thu, 24 Dec 2015 22:40:45 +0000

On 24 December 2015 at 22:19, farmdve <address@hidden> wrote:
> I've been looking and looking, but it must be defined via a macro,
> I wish to see it's members.

There is no such struct definition. The TCGv_i32, TCGv_i64, etc
types are defined as pointers to structs like this so that we
get some type-checking from the compiler that prevents
target-* code from accidentally passing a TCGv_i64 to a function
expecting a TCGv_i32 and so on. However the underlying
representation of a TCGv is just an integer (it's an index
into the TCG code generator's array of temporaries). Whenever
the TCG code hands out a TCGv it goes via one of the MAKE_TCGV*
functions which converts an integer into the appropriate type,
and when the target-* code passes it a TCGv_i32 etc type it
goes via one of the GET_TCGV_* functions to get it back as
an integer again. Since this small number is not a valid pointer
it's never valid to try to dereference a TCGv_.

The underlying representation of the TCGv* types is opaque
to the guest-cpu-specific code in target-*. We used to use
either (a) real plain integer types or (b) structs which
were different between the three types; the current approach
was introduced in commit b6c73a6d45b63926 and provides the
efficiency of handing around int types with the type checking
that the struct approach had. But most code never cared about
the representation; you can see that commit only really changed
the GET and MAKE functions.

thanks
-- PMM



reply via email to

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