qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 6/7] [RFC] target-i386: Define MMREG_UNION macro


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 6/7] [RFC] target-i386: Define MMREG_UNION macro
Date: Tue, 1 Dec 2015 12:00:33 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0


On 30/11/2015 19:21, Eduardo Habkost wrote:
> This will simplify the definitions of ZMMReg and MMXReg.
> 
> Signed-off-by: Eduardo Habkost <address@hidden>
> ---
>  target-i386/cpu.h | 27 +++++++++++----------------
>  1 file changed, 11 insertions(+), 16 deletions(-)
> 
> diff --git a/target-i386/cpu.h b/target-i386/cpu.h
> index 7519023..b189748 100644
> --- a/target-i386/cpu.h
> +++ b/target-i386/cpu.h
> @@ -725,23 +725,18 @@ typedef struct SegmentCache {
>      uint32_t flags;
>  } SegmentCache;
>  
> -typedef union {
> -    uint8_t _b[64];
> -    uint16_t _w[32];
> -    uint32_t _l[16];
> -    uint64_t _q[8];
> -    float32 _s[16];
> -    float64 _d[8];
> -} ZMMReg;
> +#define MMREG_UNION(q)      \
> +    union {                 \
> +        uint8_t _b[(q)*8];  \
> +        uint16_t _w[(q)*4]; \
> +        uint32_t _l[(q)*2]; \
> +        uint64_t _q[(q)];   \
> +        float32 _s[(q)*2];  \
> +        float64 _d[(q)];    \
> +    }
>  
> -typedef union {
> -    uint8_t _b[8];
> -    uint16_t _w[4];
> -    uint32_t _l[2];
> -    uint64_t _q[1];
> -    float32 _s[2];
> -    float64 _d[1];
> -} MMXReg;
> +typedef MMREG_UNION(8) ZMMReg;
> +typedef MMREG_UNION(1) MMXReg;

Since you are at it, perhaps the argument to MMREG_UNION can be in bits.
 Otherwise really no comment, it's a nice improvement in type-safety.

Paolo

>  typedef struct BNDReg {
>      uint64_t lb;
> 



reply via email to

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