[Pixman] [PATCH 01/12] vmx: add LOAD_VECTOR macro

Oded Gabbay oded.gabbay at gmail.com
Thu Jul 2 03:04:06 PDT 2015


This patch adds a macro for loading a single vector.
It also make the other LOAD_VECTORx macros use this macro as a base so
code would be re-used.

In addition, I fixed minor coding style issues.

Signed-off-by: Oded Gabbay <oded.gabbay at gmail.com>
---
 pixman/pixman-vmx.c | 50 ++++++++++++++++++++++++--------------------------
 1 file changed, 24 insertions(+), 26 deletions(-)

diff --git a/pixman/pixman-vmx.c b/pixman/pixman-vmx.c
index 1809790..15ea64e 100644
--- a/pixman/pixman-vmx.c
+++ b/pixman/pixman-vmx.c
@@ -169,33 +169,29 @@ over (vector unsigned int src,
     mask ## _mask = vec_lvsl (0, mask);					\
     source ## _mask = vec_lvsl (0, source);
 
-/* notice you have to declare temp vars...
- * Note: tmp3 and tmp4 must remain untouched!
- */
-
-#define LOAD_VECTORS(dest, source)			  \
-do {							  \
+#define LOAD_VECTOR(source)				  \
+do							  \
+{							  \
     vector unsigned char tmp1, tmp2;			  \
     tmp1 = (typeof(tmp1))vec_ld (0, source);		  \
     tmp2 = (typeof(tmp2))vec_ld (15, source);		  \
-    v ## source = (typeof(v ## source))			  \
+    v ## source = (typeof(v ## source)) 		  \
 	vec_perm (tmp1, tmp2, source ## _mask);		  \
+} while (0)
+
+#define LOAD_VECTORS(dest, source)			  \
+do							  \
+{							  \
+    LOAD_VECTOR(source);				  \
     v ## dest = (typeof(v ## dest))vec_ld (0, dest);	  \
-} while (0);
+} while (0)
 
 #define LOAD_VECTORSC(dest, source, mask)		  \
-do {							  \
-    vector unsigned char tmp1, tmp2;			  \
-    tmp1 = (typeof(tmp1))vec_ld (0, source);		  \
-    tmp2 = (typeof(tmp2))vec_ld (15, source);		  \
-    v ## source = (typeof(v ## source))			  \
-	vec_perm (tmp1, tmp2, source ## _mask);		  \
-    tmp1 = (typeof(tmp1))vec_ld (0, mask);		  \
-    v ## dest = (typeof(v ## dest))vec_ld (0, dest);	  \
-    tmp2 = (typeof(tmp2))vec_ld (15, mask);		  \
-    v ## mask = (typeof(v ## mask))			  \
-    vec_perm (tmp1, tmp2, mask ## _mask);		  \
-} while (0);
+do							  \
+{							  \
+    LOAD_VECTORS(dest, source); 			  \
+    LOAD_VECTOR(mask);					  \
+} while (0)
 
 #define DECLARE_SRC_MASK_VAR vector unsigned char src_mask
 #define DECLARE_MASK_MASK_VAR vector unsigned char mask_mask
@@ -213,14 +209,16 @@ do {							  \
 
 #define COMPUTE_SHIFT_MASKC(dest, source, mask)
 
+# define LOAD_VECTOR(source)				\
+    v ## source = *((typeof(v ## source)*)source);
+
 # define LOAD_VECTORS(dest, source)			\
-    v ## source = *((typeof(v ## source)*)source);	\
-    v ## dest = *((typeof(v ## dest)*)dest);
+    LOAD_VECTOR(source);				\
+    LOAD_VECTOR(dest);					\
 
 # define LOAD_VECTORSC(dest, source, mask)		\
-    v ## source = *((typeof(v ## source)*)source);	\
-    v ## dest = *((typeof(v ## dest)*)dest);		\
-    v ## mask = *((typeof(v ## mask)*)mask);
+    LOAD_VECTORS(dest, source); 			\
+    LOAD_VECTOR(mask);					\
 
 #define DECLARE_SRC_MASK_VAR
 #define DECLARE_MASK_MASK_VAR
@@ -228,7 +226,7 @@ do {							  \
 #endif /* WORDS_BIGENDIAN */
 
 #define LOAD_VECTORSM(dest, source, mask)				\
-    LOAD_VECTORSC (dest, source, mask)					\
+    LOAD_VECTORSC (dest, source, mask); 				\
     v ## source = pix_multiply (v ## source,				\
                                 splat_alpha (v ## mask));
 
-- 
2.4.3



More information about the Pixman mailing list