static void test () { #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ vector unsigned long evul = {1,0}; vector double evd = {1.0,0.0}; #else vector unsigned long evul = {0,1}; vector double evd = {0.0,1.0}; #endif vector unsigned long vul; vector double vd; unsigned i; init (); vul = vec_ldl (0, (vector unsigned long *)svul); vd = vec_ldl (0, (vector double *)svd); for (i = 0; i < 2; ++i) { check (vul[i] == evul[i], "vul"); check (vd[i] == evd[i], "vd" ); } }
int main () { *vecfloat++ = vec_andc(vecint[0], vecfloat[1]); *vecfloat++ = vec_andc(vecfloat[0], vecint[1]); *vecfloat++ = vec_vxor(vecint[0], vecfloat[1]); *vecfloat++ = vec_vxor(vecfloat[0], vecint[1]); *varpixel++ = vec_packpx(vecuint[0], vecuint[1]); *varpixel++ = vec_vpkpx(vecuint[0], vecuint[1]); *vecshort++ = vec_vmulosb(vecchar[0], vecchar[1]); *vecint++ = vec_ld(var_int[0], longp[1]); *vecint++ = vec_lde(var_int[0], longp[1]); *vecint++ = vec_ldl(var_int[0], longp[1]); *vecint++ = vec_lvewx(var_int[0], longp[1]); *vecint++ = vec_unpackh(vecshort[0]); *vecint++ = vec_unpackl(vecshort[0]); *vecushort++ = vec_andc(vecshort[0], vecushort[1]); *vecushort++ = vec_andc(vecushort[0], vecshort[1]); *vecushort++ = vec_vxor(vecshort[0], vecushort[1]); *vecushort++ = vec_vxor(vecushort[0], vecshort[1]); *vecuint++ = vec_ld(var_int[0], ulongp[1]); *vecuint++ = vec_lvx(var_int[0], ulongp[1]); *vecuint++ = vec_vmsumubm(vecuchar[0], vecuchar[1], vecuint[2]); *vecuchar++ = vec_xor(vecuchar[0], vecchar[1]); return 0; }
void f22() { *var_vec_u32++ = vec_ld(var_int[0], var_unsigned_long_ptr[1]); *var_vec_u32++ = vec_lde(var_int[0], var_unsigned_long_ptr[1]); *var_vec_u32++ = vec_ldl(var_int[0], var_unsigned_long_ptr[1]); *var_vec_u32++ = vec_lvewx(var_int[0], var_unsigned_long_ptr[1]); *var_vec_u32++ = vec_lvx(var_int[0], var_unsigned_long_ptr[1]); *var_vec_u32++ = vec_lvxl(var_int[0], var_unsigned_long_ptr[1]); }
void f13() { *var_vec_s32++ = vec_ld(var_int[0], var_long_ptr[1]); *var_vec_s32++ = vec_lde(var_int[0], var_long_ptr[1]); *var_vec_s32++ = vec_ldl(var_int[0], var_long_ptr[1]); *var_vec_s32++ = vec_lvewx(var_int[0], var_long_ptr[1]); *var_vec_s32++ = vec_lvx(var_int[0], var_long_ptr[1]); *var_vec_s32++ = vec_lvxl(var_int[0], var_long_ptr[1]); }
static void test () { vector unsigned long long evul = {0,1}; vector double evd = {0.0,1.0}; vector unsigned long long vul; vector double vd; unsigned i; init (); vul = vec_ldl (0, (vector unsigned long long *)svul); vd = vec_ldl (0, (vector double *)svd); for (i = 0; i < 2; ++i) { check (vul[i] == evul[i], "vul"); check (vd[i] == evd[i], "vd" ); } }
void b() { z = vec_add (x, y); /* Make sure the predicates accept correct argument types. */ int1 = vec_all_in (f, g); int1 = vec_all_ge (f, g); int1 = vec_all_eq (c, d); int1 = vec_all_ne (s, t); int1 = vec_any_eq (i, j); int1 = vec_any_ge (f, g); int1 = vec_all_ngt (f, g); int1 = vec_any_ge (c, d); int1 = vec_any_ge (s, t); int1 = vec_any_ge (i, j); int1 = vec_any_ge (c, d); int1 = vec_any_ge (s, t); int1 = vec_any_ge (i, j); vec_mtvscr (i); vec_dssall (); s = (vector signed short) vec_mfvscr (); vec_dss (3); vec_dst (pi, int1 + int2, 3); vec_dstst (pi, int1 + int2, 3); vec_dststt (pi, int1 + int2, 3); vec_dstt (pi, int1 + int2, 3); uc = (vector unsigned char) vec_lvsl (int1 + 69, (signed int *) pi); uc = (vector unsigned char) vec_lvsr (int1 + 69, (signed int *) pi); c = vec_lde (int1, (signed char *) pi); s = vec_lde (int1, (signed short *) pi); i = vec_lde (int1, (signed int *) pi); i = vec_ldl (int1, pi); i = vec_ld (int1, pi); vec_st (i, int2, pi); vec_ste (c, int2, (signed char *) pi); vec_ste (s, int2, (signed short *) pi); vec_ste (i, int2, (signed int *) pi); vec_stl (i, int2, pi); }
void CDSPToolsOSX::Mul32(tfloat32* pDest, tfloat32 Src) { #ifdef _Mac_PowerPC vector float vSrc = (vector float)(Src, Src, Src, Src); vector float vDest = vec_ldl(0, pDest); vDest = vec_madd(vDest, vSrc, (vector float)(0, 0, 0, 0)); vec_st(vDest, 0, pDest); vDest = vec_ldl(4 * 4, pDest); vDest = vec_madd(vDest, vSrc, (vector float)(0, 0, 0, 0)); vec_st(vDest, 4 * 4, pDest); vDest = vec_ldl(8 * 4, pDest); vDest = vec_madd(vDest, vSrc, (vector float)(0, 0, 0, 0)); vec_st(vDest, 8 * 4, pDest); vDest = vec_ldl(12 * 4, pDest); vDest = vec_madd(vDest, vSrc, (vector float)(0, 0, 0, 0)); vec_st(vDest, 12 * 4, pDest); vDest = vec_ldl(16 * 4, pDest); vDest = vec_madd(vDest, vSrc, (vector float)(0, 0, 0, 0)); vec_st(vDest, 16 * 4, pDest); vDest = vec_ldl(20 * 4, pDest); vDest = vec_madd(vDest, vSrc, (vector float)(0, 0, 0, 0)); vec_st(vDest, 20 * 4, pDest); vDest = vec_ldl(24 * 4, pDest); vDest = vec_madd(vDest, vSrc, (vector float)(0, 0, 0, 0)); vec_st(vDest, 24 * 4, pDest); vDest = vec_ldl(28 * 4, pDest); vDest = vec_madd(vDest, vSrc, (vector float)(0, 0, 0, 0)); vec_st(vDest, 28 * 4, pDest); #else // _Mac_PowerPC CDSPTools::Mul32(pDest, Src); #endif // _Mac_PowerPC }
void CDSPToolsOSX::Copy32(tfloat32* pDest, const tfloat32* pSrc) { #ifdef _Mac_PowerPC vector int Value = vec_ldl(0, (int*)pSrc); vec_st(Value, 0, (int*)pDest); Value = vec_ldl(4 * 4, (int*)pSrc); vec_st(Value, 4 * 4, (int*)pDest); Value = vec_ldl(8 * 4, (int*)pSrc); vec_st(Value, 8 * 4, (int*)pDest); Value = vec_ldl(12 * 4, (int*)pSrc); vec_st(Value, 12 * 4, (int*)pDest); Value = vec_ldl(16 * 4, (int*)pSrc); vec_st(Value, 16 * 4, (int*)pDest); Value = vec_ldl(20 * 4, (int*)pSrc); vec_st(Value, 20 * 4, (int*)pDest); Value = vec_ldl(24 * 4, (int*)pSrc); vec_st(Value, 24 * 4, (int*)pDest); Value = vec_ldl(28 * 4, (int*)pSrc); vec_st(Value, 28 * 4, (int*)pDest); #else // _Mac_PowerPC CDSPTools::Copy32(pDest, pSrc); #endif // _Mac_PowerPC }
void *mem_searchrn(void *s, size_t len) { vector unsigned char v_cr; vector unsigned char v_nl; vector unsigned char v0; vector unsigned char v_perm; vector unsigned char c; vector bool char rr, rn; vector bool char last_rr; char *p; ssize_t k; size_t block_num; unsigned f; if(unlikely(!s || !len)) return NULL; /* only do one prefetch, this covers nearly 128k */ block_num = DIV_ROUNDUP(len, 512); f = block_num >= 256 ? 0 : block_num << 16; f |= 512; vec_dst((const unsigned char *)s, f, 2); v_cr = vec_splat_u8('\r'); v_nl = vec_splat_u8('\n'); v0 = vec_splat_u8(0); last_rr = (vector bool char)v0; k = SOVUC - ALIGN_DOWN_DIFF(s, SOVUC) - (ssize_t)len; p = (char *)ALIGN_DOWN(s, SOVUC); c = vec_ldl(0, (const vector unsigned char *)p); if(unlikely(k > 0)) goto K_SHIFT; v_perm = vec_lvsl(0, (unsigned char *)s); c = vec_perm(c, v0, v_perm); v_perm = vec_lvsr(0, (unsigned char *)s); c = vec_perm(v0, c, v_perm); rr = vec_cmpeq(c, v_cr); rn = vec_cmpeq(c, v_nl); k = -k; goto START_LOOP; do { p += SOVUC; c = vec_ldl(0, (const vector unsigned char *)p); k -= SOVUC; if(k > 0) { rr = vec_cmpeq(c, v_cr); rn = vec_cmpeq(c, v_nl); if(vec_any_eq(last_rr, rn)) { vec_dss(2); return p - 1; } START_LOOP: last_rr = (vector bool char)vec_sld(v0, (vector unsigned char)rr, 1); rn = (vector bool char)vec_sld(v0, (vector unsigned char)rn, 15); rr = vec_and(rr, rn); /* get mask */ if(vec_any_ne(rr, v0)) { vec_dss(2); return p + vec_zpos(rr); } } } while(k > 0); k = -k; K_SHIFT: vec_dss(2); v_perm = vec_lvsr(0, (unsigned char *)k); c = vec_perm(v0, c, v_perm); v_perm = vec_lvsl(0, (unsigned char *)k); c = vec_perm(c, v0, v_perm); rr = vec_cmpeq(c, v_cr); rn = vec_cmpeq(c, v_nl); if(vec_any_eq(last_rr, rn)) return p - 1; rn = (vector bool char)vec_sld(v0, (vector unsigned char)rn, 15); rr = vec_and(rr, rn); /* get mask */ if(vec_any_ne(rr, v0)) return p + vec_zpos(rr); return NULL; }
int main (int argc, char *argv[]) { vector long long int lv; vector unsigned long long int ulv; vector int iv; vector unsigned int uiv; vector short sv; vector unsigned short usv; vector signed char cv; vector unsigned char ucv; vector double dv; doInitialization (); /* Do vector of char. */ for (int i = 0; i < 16; i++) { /* Focus on ca[16] ... ca[31]. */ cv = vec_ldl (i+16, ca); /* compiler: invalid parameter combination */ if (cv[4] != ca[20]) abort (); /* Focus on uca[32] ... uca[47]. */ ucv = vec_ldl (i+32, uca); if (ucv[7] != uca[39]) abort (); /* Focus on ca[0] ... ca[15]. */ cv = vec_ldl (i, vcp); if (cv[3] != ca[3]) abort (); /* Focus on ca[0] ... ca[15] while i <= 8. Focus on ca[16] ... ca[31] while i > 8. */ ucv = vec_ldl (i+7, vucp); if ((i+7 > 15) && (ucv[13] != uca[29])) abort (); if ((i + 7 <= 15) && (ucv[13] != uca[13])) abort (); } /* Do vector of short. */ for (int i = 0; i < 16; i++) { /* Focus on sa[8] ... sa[15]. */ sv = vec_ldl (i+16, sa); if (sv[4] != sa[12]) abort (); /* Focus on usa[24] ... usa[31]. */ usv = vec_ldl (i+48, usa); if (usv[7] != usa[31]) abort (); /* Focus on sa[0] ... sa[7]. */ sv = vec_ldl (i, vsp); if (sv[3] != sa[3]) abort (); /* Focus on usa[0] ... usa[7] while i <= 8. Focus on usa[8] ... usa[15] while i > 8. */ usv = vec_ldl (i+7, vusp); if ((i+7 > 15) && (usv[5] != usa[13])) abort (); if ((i + 7 <= 15) && (usv[5] != usa[5])) abort (); } /* Do vector of int. */ for (int i = 0; i < 16; i++) { /* Focus on ia[8] ... ia[11]. */ iv = vec_ldl (i+32, ia); if (iv[3] != ia[11]) abort (); /* Focus on uia[12] ... uia[15]. */ uiv = vec_ldl (i+48, uia); if (uiv[2] != uia[14]) abort (); /* Focus on ia[0] ... ia[3]. */ iv = vec_ldl (i, vip); if (iv[3] != ia[3]) abort (); /* Focus on uia[0] ... uia[3] while i <= 8. Focus on uia[4] ... uia[7] while i > 8. */ uiv = vec_ldl (i+7, vuip); if ((i+7 > 15) && (uiv[1] != uia[5])) abort (); if ((i + 7 <= 15) && (uiv[1] != uia[1])) abort (); } /* Do vector of long long int. */ for (int i = 0; i < 16; i++) { /* Focus on la[4] ... la[5]. */ lv = vec_ldl (i+32, la); if (lv[1] != la[5]) abort (); /* Focus on ula[6] ... ula[7]. */ ulv = vec_ldl (i+48, ula); if (ulv[0] != uia[6]) abort (); /* Focus on la[0] ... la[1]. */ lv = vec_ldl (i, vlp); if (iv[1] != la[1]) abort (); /* Focus on ula[0] ... uia[1] while i <= 8. Focus on uia[2] ... uia[3] while i > 8. */ ulv = vec_ldl (i+7, vulp); if ((i+7 > 15) && (ulv[1] != ula[3])) abort (); if ((i + 7 <= 15) && (ulv[1] != ula[1])) abort (); } /* Do vector of double. */ for (int i = 0; i < 16; i++) { /* Focus on da[2] ... da[3]. */ dv = vec_ldl (i+16, da); if (dv[1] != da[3]) abort (); /* Focus on da[6] ... da[7]. */ dv = vec_ldl (i+48, vdp); if (dv[0] != da[6]) abort (); /* Focus on da[0] ... da[1]. */ dv = vec_ldl (i, da); if (dv[1] != da[1]) abort (); /* Focus on da[0] ... da[1] while i <= 8. Focus on da[2] ... da[3] while i > 8. */ dv = vec_ldl (i+7, vdp); if ((i+7 <= 15) && (dv[1] != da[1])) abort (); if ((i + 7 > 15) && (dv[1] != da[3])) abort (); } return 0; }
void CDSPToolsOSX::Add32(tfloat32* pDest, const tfloat32* pSrc) { #ifdef _Mac_PowerPC vector float vDest = vec_ldl(0, pDest); vector float vSrc = vec_ldl(0, pSrc); vDest = vec_add(vDest, vSrc); vec_st(vDest, 0, pDest); vDest = vec_ldl(4 * 4, pDest); vSrc = vec_ldl(4 * 4, pSrc); vDest = vec_add(vDest, vSrc); vec_st(vDest, 4 * 4, pDest); vDest = vec_ldl(8 * 4, pDest); vSrc = vec_ldl(8 * 4, pSrc); vDest = vec_add(vDest, vSrc); vec_st(vDest, 8 * 4, pDest); vDest = vec_ldl(12 * 4, pDest); vSrc = vec_ldl(12 * 4, pSrc); vDest = vec_add(vDest, vSrc); vec_st(vDest, 12 * 4, pDest); vDest = vec_ldl(16 * 4, pDest); vSrc = vec_ldl(16 * 4, pSrc); vDest = vec_add(vDest, vSrc); vec_st(vDest, 16 * 4, pDest); vDest = vec_ldl(20 * 4, pDest); vSrc = vec_ldl(20 * 4, pSrc); vDest = vec_add(vDest, vSrc); vec_st(vDest, 20 * 4, pDest); vDest = vec_ldl(24 * 4, pDest); vSrc = vec_ldl(24 * 4, pSrc); vDest = vec_add(vDest, vSrc); vec_st(vDest, 24 * 4, pDest); vDest = vec_ldl(28 * 4, pDest); vSrc = vec_ldl(28 * 4, pSrc); vDest = vec_add(vDest, vSrc); vec_st(vDest, 28 * 4, pDest); #else // _Mac_PowerPC CDSPTools::Add32(pDest, pSrc); #endif // _Mac_PowerPC }