Message ID | 1364291919-19563-3-git-send-email-pl@kamp.de |
---|---|
State | New |
Headers | show |
Il 26/03/2013 10:58, Peter Lieven ha scritto: > Signed-off-by: Peter Lieven <pl@kamp.de> > --- > include/qemu-common.h | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/include/qemu-common.h b/include/qemu-common.h > index d7ad3a7..9022646 100644 > --- a/include/qemu-common.h > +++ b/include/qemu-common.h > @@ -453,6 +453,7 @@ void hexdump(const char *buf, FILE *fp, const char *prefix, size_t size); > #include <altivec.h> > #define VECTYPE vector unsigned char > #define SPLAT(p) vec_splat(vec_ld(0, p), 0) > +#define ZERO_SPLAT vec_splat(vec_ld(0, 0), 0) > #define ALL_EQ(v1, v2) vec_all_eq(v1, v2) > /* altivec.h may redefine the bool macro as vector type. > * Reset it to POSIX semantics. */ > @@ -462,10 +463,12 @@ void hexdump(const char *buf, FILE *fp, const char *prefix, size_t size); > #include <emmintrin.h> > #define VECTYPE __m128i > #define SPLAT(p) _mm_set1_epi8(*(p)) > +#define ZERO_SPLAT _mm_setzero_si128() > #define ALL_EQ(v1, v2) (_mm_movemask_epi8(_mm_cmpeq_epi8(v1, v2)) == 0xFFFF) > #else > #define VECTYPE unsigned long > #define SPLAT(p) (*(p) * (~0UL / 255)) > +#define ZERO_SPLAT 0x0UL > #define ALL_EQ(v1, v2) ((v1) == (v2)) > #endif C trivia of the day: this can be written simply as (VECTYPE) {0} Yes, it works even with unsigned long. :) It is a C99 compound literal. Paolo
Am 26.03.2013 um 11:14 schrieb Paolo Bonzini <pbonzini@redhat.com>: > Il 26/03/2013 10:58, Peter Lieven ha scritto: >> Signed-off-by: Peter Lieven <pl@kamp.de> >> --- >> include/qemu-common.h | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/include/qemu-common.h b/include/qemu-common.h >> index d7ad3a7..9022646 100644 >> --- a/include/qemu-common.h >> +++ b/include/qemu-common.h >> @@ -453,6 +453,7 @@ void hexdump(const char *buf, FILE *fp, const char *prefix, size_t size); >> #include <altivec.h> >> #define VECTYPE vector unsigned char >> #define SPLAT(p) vec_splat(vec_ld(0, p), 0) >> +#define ZERO_SPLAT vec_splat(vec_ld(0, 0), 0) >> #define ALL_EQ(v1, v2) vec_all_eq(v1, v2) >> /* altivec.h may redefine the bool macro as vector type. >> * Reset it to POSIX semantics. */ >> @@ -462,10 +463,12 @@ void hexdump(const char *buf, FILE *fp, const char *prefix, size_t size); >> #include <emmintrin.h> >> #define VECTYPE __m128i >> #define SPLAT(p) _mm_set1_epi8(*(p)) >> +#define ZERO_SPLAT _mm_setzero_si128() >> #define ALL_EQ(v1, v2) (_mm_movemask_epi8(_mm_cmpeq_epi8(v1, v2)) == 0xFFFF) >> #else >> #define VECTYPE unsigned long >> #define SPLAT(p) (*(p) * (~0UL / 255)) >> +#define ZERO_SPLAT 0x0UL >> #define ALL_EQ(v1, v2) ((v1) == (v2)) >> #endif > > C trivia of the day: this can be written simply as > > (VECTYPE) {0} you are the first who mentions this ;-) respin? Peter
Il 26/03/2013 11:17, Peter Lieven ha scritto: >> > >> > C trivia of the day: this can be written simply as >> > >> > (VECTYPE) {0} > you are the first who mentions this ;-) > > respin? Yes, please. Paolo
Am 26.03.2013 um 11:17 schrieb Paolo Bonzini <pbonzini@redhat.com>: > Il 26/03/2013 11:17, Peter Lieven ha scritto: >>>> >>>> C trivia of the day: this can be written simply as >>>> >>>> (VECTYPE) {0} >> you are the first who mentions this ;-) >> >> respin? > > Yes, please. Ok, I wait if someone finds something else. Peter > > Paolo
diff --git a/include/qemu-common.h b/include/qemu-common.h index d7ad3a7..9022646 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -453,6 +453,7 @@ void hexdump(const char *buf, FILE *fp, const char *prefix, size_t size); #include <altivec.h> #define VECTYPE vector unsigned char #define SPLAT(p) vec_splat(vec_ld(0, p), 0) +#define ZERO_SPLAT vec_splat(vec_ld(0, 0), 0) #define ALL_EQ(v1, v2) vec_all_eq(v1, v2) /* altivec.h may redefine the bool macro as vector type. * Reset it to POSIX semantics. */ @@ -462,10 +463,12 @@ void hexdump(const char *buf, FILE *fp, const char *prefix, size_t size); #include <emmintrin.h> #define VECTYPE __m128i #define SPLAT(p) _mm_set1_epi8(*(p)) +#define ZERO_SPLAT _mm_setzero_si128() #define ALL_EQ(v1, v2) (_mm_movemask_epi8(_mm_cmpeq_epi8(v1, v2)) == 0xFFFF) #else #define VECTYPE unsigned long #define SPLAT(p) (*(p) * (~0UL / 255)) +#define ZERO_SPLAT 0x0UL #define ALL_EQ(v1, v2) ((v1) == (v2)) #endif
Signed-off-by: Peter Lieven <pl@kamp.de> --- include/qemu-common.h | 3 +++ 1 file changed, 3 insertions(+)