qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v6 3/4] tcg: Add type for vCPU pointers


From: Lluís Vilanova
Subject: Re: [Qemu-devel] [PATCH v6 3/4] tcg: Add type for vCPU pointers
Date: Wed, 10 Feb 2016 14:38:00 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Lluís Vilanova writes:

> Richard Henderson writes:
>> On 02/10/2016 08:14 AM, Lluís Vilanova wrote:
>>> Adds the 'TCGv_env' type for pointers to 'CPUArchState' objects. The
>>> tracing infrastructure later needs to differentiate between regular
>>> pointers and pointers to vCPUs.
>>> 
>>> Also changes all targets to use the new 'TCGv_cpu' type instead of the
>>> generic 'TCGv_ptr'. As of now, the change is merely cosmetic ('TCGv_env'
>>> translates into 'TCGv_ptr'), but that could change in the future to
>>> enforce the difference.

>> I suppose.

>> We won't be able distinguish TCGv_env from TCGv_ptr until env can be
>> auto-converted to ptr.  Which I can't imagine happening without switching to
>> C++.

> It's difficult to differenciate between TCGv_ptr and TCGv_env in 
> "tcg/tcg-op.h"
> unless an explicit operation is added to perform casts or to get a TCGv_ptr 
> from
> a TCGv_env+offset (e.g., add a tcg_gen_env_ld8u_i32 built on top of
> tcg_gen_ld8u_i32). That is, unless QEMU switches to C++.

> But types could be easily enforced in helper declarations, which can 
> internally
> cast to the pointer type.
[...]


BTW, type overload can also be achieved in C using GCC's
__builtin_types_compatible_p and __builtin_choose_expr intrinsics:

  http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html


Cheers,
  Lluis



reply via email to

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