qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/2] target-i386: MMReg struct cleanup
@ 2015-12-02 15:51 Eduardo Habkost
  2015-12-02 15:51 ` [Qemu-devel] [PATCH v2 1/2] target-i386: Define MMREG_UNION macro Eduardo Habkost
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Eduardo Habkost @ 2015-12-02 15:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Richard Henderson

Changes v1 -> v2:
* Other patches from v1 are already in x86-next branch
* MMREG_UNION argument is now the number of bits
* Removed [RFC] tag

Eduardo Habkost (2):
  target-i386: Define MMREG_UNION macro
  target-i386: Add suffixes to MMReg struct fields

 target-i386/cpu.h | 73 ++++++++++++++++++++++++++-----------------------------
 1 file changed, 34 insertions(+), 39 deletions(-)

-- 
2.1.0

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH v2 1/2] target-i386: Define MMREG_UNION macro
  2015-12-02 15:51 [Qemu-devel] [PATCH v2 0/2] target-i386: MMReg struct cleanup Eduardo Habkost
@ 2015-12-02 15:51 ` Eduardo Habkost
  2015-12-02 15:51 ` [Qemu-devel] [PATCH v2 2/2] target-i386: Add suffixes to MMReg struct fields Eduardo Habkost
  2015-12-02 16:45 ` [Qemu-devel] [PATCH v2 0/2] target-i386: MMReg struct cleanup Richard Henderson
  2 siblings, 0 replies; 5+ messages in thread
From: Eduardo Habkost @ 2015-12-02 15:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Richard Henderson

This will simplify the definitions of ZMMReg and MMXReg.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes v1 -> v2:
* Change MMREG_UNION argument to be number of bits
---
 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 e8e99e2..ab3ae5b 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(bits)       \
+    union {                     \
+        uint8_t  _b[(bits)/8];  \
+        uint16_t _w[(bits)/16]; \
+        uint32_t _l[(bits)/32]; \
+        uint64_t _q[(bits)/64]; \
+        float32  _s[(bits)/32]; \
+        float64  _d[(bits)/64]; \
+    }
 
-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(512) ZMMReg;
+typedef MMREG_UNION(64)  MMXReg;
 
 typedef struct BNDReg {
     uint64_t lb;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH v2 2/2] target-i386: Add suffixes to MMReg struct fields
  2015-12-02 15:51 [Qemu-devel] [PATCH v2 0/2] target-i386: MMReg struct cleanup Eduardo Habkost
  2015-12-02 15:51 ` [Qemu-devel] [PATCH v2 1/2] target-i386: Define MMREG_UNION macro Eduardo Habkost
@ 2015-12-02 15:51 ` Eduardo Habkost
  2015-12-02 16:45 ` [Qemu-devel] [PATCH v2 0/2] target-i386: MMReg struct cleanup Richard Henderson
  2 siblings, 0 replies; 5+ messages in thread
From: Eduardo Habkost @ 2015-12-02 15:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Richard Henderson

This will ensure we never use the MMX_* and ZMM_* macros with the
wrong struct type.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target-i386/cpu.h | 66 +++++++++++++++++++++++++++----------------------------
 1 file changed, 33 insertions(+), 33 deletions(-)

diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index ab3ae5b..278c724 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -725,18 +725,18 @@ typedef struct SegmentCache {
     uint32_t flags;
 } SegmentCache;
 
-#define MMREG_UNION(bits)       \
-    union {                     \
-        uint8_t  _b[(bits)/8];  \
-        uint16_t _w[(bits)/16]; \
-        uint32_t _l[(bits)/32]; \
-        uint64_t _q[(bits)/64]; \
-        float32  _s[(bits)/32]; \
-        float64  _d[(bits)/64]; \
+#define MMREG_UNION(n, bits)        \
+    union n {                       \
+        uint8_t  _b_##n[(bits)/8];  \
+        uint16_t _w_##n[(bits)/16]; \
+        uint32_t _l_##n[(bits)/32]; \
+        uint64_t _q_##n[(bits)/64]; \
+        float32  _s_##n[(bits)/32]; \
+        float64  _d_##n[(bits)/64]; \
     }
 
-typedef MMREG_UNION(512) ZMMReg;
-typedef MMREG_UNION(64)  MMXReg;
+typedef MMREG_UNION(ZMMReg, 512) ZMMReg;
+typedef MMREG_UNION(MMXReg, 64)  MMXReg;
 
 typedef struct BNDReg {
     uint64_t lb;
@@ -749,31 +749,31 @@ typedef struct BNDCSReg {
 } BNDCSReg;
 
 #ifdef HOST_WORDS_BIGENDIAN
-#define ZMM_B(n) _b[63 - (n)]
-#define ZMM_W(n) _w[31 - (n)]
-#define ZMM_L(n) _l[15 - (n)]
-#define ZMM_S(n) _s[15 - (n)]
-#define ZMM_Q(n) _q[7 - (n)]
-#define ZMM_D(n) _d[7 - (n)]
-
-#define MMX_B(n) _b[7 - (n)]
-#define MMX_W(n) _w[3 - (n)]
-#define MMX_L(n) _l[1 - (n)]
-#define MMX_S(n) _s[1 - (n)]
+#define ZMM_B(n) _b_ZMMReg[63 - (n)]
+#define ZMM_W(n) _w_ZMMReg[31 - (n)]
+#define ZMM_L(n) _l_ZMMReg[15 - (n)]
+#define ZMM_S(n) _s_ZMMReg[15 - (n)]
+#define ZMM_Q(n) _q_ZMMReg[7 - (n)]
+#define ZMM_D(n) _d_ZMMReg[7 - (n)]
+
+#define MMX_B(n) _b_MMXReg[7 - (n)]
+#define MMX_W(n) _w_MMXReg[3 - (n)]
+#define MMX_L(n) _l_MMXReg[1 - (n)]
+#define MMX_S(n) _s_MMXReg[1 - (n)]
 #else
-#define ZMM_B(n) _b[n]
-#define ZMM_W(n) _w[n]
-#define ZMM_L(n) _l[n]
-#define ZMM_S(n) _s[n]
-#define ZMM_Q(n) _q[n]
-#define ZMM_D(n) _d[n]
-
-#define MMX_B(n) _b[n]
-#define MMX_W(n) _w[n]
-#define MMX_L(n) _l[n]
-#define MMX_S(n) _s[n]
+#define ZMM_B(n) _b_ZMMReg[n]
+#define ZMM_W(n) _w_ZMMReg[n]
+#define ZMM_L(n) _l_ZMMReg[n]
+#define ZMM_S(n) _s_ZMMReg[n]
+#define ZMM_Q(n) _q_ZMMReg[n]
+#define ZMM_D(n) _d_ZMMReg[n]
+
+#define MMX_B(n) _b_MMXReg[n]
+#define MMX_W(n) _w_MMXReg[n]
+#define MMX_L(n) _l_MMXReg[n]
+#define MMX_S(n) _s_MMXReg[n]
 #endif
-#define MMX_Q(n) _q[n]
+#define MMX_Q(n) _q_MMXReg[n]
 
 typedef union {
     floatx80 d __attribute__((aligned(16)));
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/2] target-i386: MMReg struct cleanup
  2015-12-02 15:51 [Qemu-devel] [PATCH v2 0/2] target-i386: MMReg struct cleanup Eduardo Habkost
  2015-12-02 15:51 ` [Qemu-devel] [PATCH v2 1/2] target-i386: Define MMREG_UNION macro Eduardo Habkost
  2015-12-02 15:51 ` [Qemu-devel] [PATCH v2 2/2] target-i386: Add suffixes to MMReg struct fields Eduardo Habkost
@ 2015-12-02 16:45 ` Richard Henderson
  2015-12-03 18:20   ` Eduardo Habkost
  2 siblings, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2015-12-02 16:45 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel; +Cc: Paolo Bonzini

On 12/02/2015 07:51 AM, Eduardo Habkost wrote:
> Changes v1 -> v2:
> * Other patches from v1 are already in x86-next branch
> * MMREG_UNION argument is now the number of bits
> * Removed [RFC] tag
>
> Eduardo Habkost (2):
>    target-i386: Define MMREG_UNION macro
>    target-i386: Add suffixes to MMReg struct fields
>
>   target-i386/cpu.h | 73 ++++++++++++++++++++++++++-----------------------------
>   1 file changed, 34 insertions(+), 39 deletions(-)
>
> -- 2.1.0

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/2] target-i386: MMReg struct cleanup
  2015-12-02 16:45 ` [Qemu-devel] [PATCH v2 0/2] target-i386: MMReg struct cleanup Richard Henderson
@ 2015-12-03 18:20   ` Eduardo Habkost
  0 siblings, 0 replies; 5+ messages in thread
From: Eduardo Habkost @ 2015-12-03 18:20 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Paolo Bonzini, qemu-devel

On Wed, Dec 02, 2015 at 08:45:54AM -0800, Richard Henderson wrote:
> On 12/02/2015 07:51 AM, Eduardo Habkost wrote:
> >Changes v1 -> v2:
> >* Other patches from v1 are already in x86-next branch
> >* MMREG_UNION argument is now the number of bits
> >* Removed [RFC] tag
> >
> >Eduardo Habkost (2):
> >   target-i386: Define MMREG_UNION macro
> >   target-i386: Add suffixes to MMReg struct fields
> >
> >  target-i386/cpu.h | 73 ++++++++++++++++++++++++++-----------------------------
> >  1 file changed, 34 insertions(+), 39 deletions(-)
> >
> >-- 2.1.0
> 
> Reviewed-by: Richard Henderson <rth@twiddle.net>

Thanks! Applied to x86-next.

-- 
Eduardo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-12-03 18:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-02 15:51 [Qemu-devel] [PATCH v2 0/2] target-i386: MMReg struct cleanup Eduardo Habkost
2015-12-02 15:51 ` [Qemu-devel] [PATCH v2 1/2] target-i386: Define MMREG_UNION macro Eduardo Habkost
2015-12-02 15:51 ` [Qemu-devel] [PATCH v2 2/2] target-i386: Add suffixes to MMReg struct fields Eduardo Habkost
2015-12-02 16:45 ` [Qemu-devel] [PATCH v2 0/2] target-i386: MMReg struct cleanup Richard Henderson
2015-12-03 18:20   ` Eduardo Habkost

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).