diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2010-06-19 09:47:18 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2010-06-19 09:47:18 +0000 |
commit | 4d3a7b0a0608febe3cdac68f6121546672ca875e (patch) | |
tree | 21d373ed1ece6c97c8bae99c2e49a9140fb83675 | |
parent | c56bc31138e2ae327cdc5039a664cae1570fe24f (diff) |
More AltiVec support.
Patch by Anton Yartsev!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106387 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/BuiltinsPPC.def | 111 | ||||
-rw-r--r-- | lib/CodeGen/CGBuiltin.cpp | 47 | ||||
-rw-r--r-- | lib/Headers/altivec.h | 5317 | ||||
-rw-r--r-- | test/CodeGen/builtins-ppc-altivec.c | 1127 |
4 files changed, 6040 insertions, 562 deletions
diff --git a/include/clang/Basic/BuiltinsPPC.def b/include/clang/Basic/BuiltinsPPC.def index 287bba96df..e0518dcdb6 100644 --- a/include/clang/Basic/BuiltinsPPC.def +++ b/include/clang/Basic/BuiltinsPPC.def @@ -18,14 +18,6 @@ // The format of this database matches clang/Basic/Builtins.def. // This is just a placeholder, the types and attributes are wrong. -BUILTIN(__builtin_altivec_abs_v16qi, "V16UcV16Sc", "") -BUILTIN(__builtin_altivec_abs_v8hi, "V8UsV8Ss", "") -BUILTIN(__builtin_altivec_abs_v4si, "V4UiV4Si", "") - -BUILTIN(__builtin_altivec_abss_v16qi, "V16UcV16Sc", "") -BUILTIN(__builtin_altivec_abss_v8hi, "V8UsV8Ss", "") -BUILTIN(__builtin_altivec_abss_v4si, "V4UiV4Si", "") - BUILTIN(__builtin_altivec_vaddcuw, "V4UiV4UiV4Ui", "") BUILTIN(__builtin_altivec_vaddsbs, "V16ScV16ScV16Sc", "") @@ -49,6 +41,67 @@ BUILTIN(__builtin_altivec_vavguh, "V8UsV8UsV8Us", "") BUILTIN(__builtin_altivec_vavgsw, "V4SiV4SiV4Si", "") BUILTIN(__builtin_altivec_vavguw, "V4UiV4UiV4Ui", "") +BUILTIN(__builtin_altivec_vrfip, "V4fV4f", "") + +BUILTIN(__builtin_altivec_vcfsx, "V4fV4ii", "") +BUILTIN(__builtin_altivec_vcfux, "V4fV4ii", "") +BUILTIN(__builtin_altivec_vctsxs, "V4SiV4fi", "") +BUILTIN(__builtin_altivec_vctuxs, "V4UiV4fi", "") + +BUILTIN(__builtin_altivec_dss, "vUi", "") +BUILTIN(__builtin_altivec_dssall, "v", "") +BUILTIN(__builtin_altivec_dst, "vv*iUi", "") +BUILTIN(__builtin_altivec_dstt, "vv*iUi", "") +BUILTIN(__builtin_altivec_dstst, "vv*iUi", "") +BUILTIN(__builtin_altivec_dststt, "vv*iUi", "") + +BUILTIN(__builtin_altivec_vexptefp, "V4fV4f", "") + +BUILTIN(__builtin_altivec_vrfim, "V4fV4f", "") + +BUILTIN(__builtin_altivec_lvx, "V4iiv*", "") +BUILTIN(__builtin_altivec_lvxl, "V4iiv*", "") +BUILTIN(__builtin_altivec_lvebx, "V16civ*", "") +BUILTIN(__builtin_altivec_lvehx, "V8siv*", "") +BUILTIN(__builtin_altivec_lvewx, "V4iiv*", "") + +BUILTIN(__builtin_altivec_vlogefp, "V4fV4f", "") + +BUILTIN(__builtin_altivec_lvsl, "V16cUcv*", "") +BUILTIN(__builtin_altivec_lvsr, "V16cUcv*", "") + +BUILTIN(__builtin_altivec_vmaddfp, "V4fV4fV4fV4f", "") +BUILTIN(__builtin_altivec_vmhaddshs, "V8sV8sV8sV8s", "") +BUILTIN(__builtin_altivec_vmhraddshs, "V8sV8sV8sV8s", "") + +BUILTIN(__builtin_altivec_vmsumubm, "V4UiV16UcV16UcV4Ui", "") +BUILTIN(__builtin_altivec_vmsummbm, "V4SiV16ScV16UcV4Si", "") +BUILTIN(__builtin_altivec_vmsumuhm, "V4UiV8UsV8UsV4Ui", "") +BUILTIN(__builtin_altivec_vmsumshm, "V4SiV8SsV8SsV4Si", "") +BUILTIN(__builtin_altivec_vmsumuhs, "V4UiV8UsV8UsV4Ui", "") +BUILTIN(__builtin_altivec_vmsumshs, "V4SiV8SsV8SsV4Si", "") + +BUILTIN(__builtin_altivec_vmuleub, "V8UsV16UcV16Uc", "") +BUILTIN(__builtin_altivec_vmulesb, "V8SsV16ScV16Sc", "") +BUILTIN(__builtin_altivec_vmuleuh, "V4UiV8UsV8Us", "") +BUILTIN(__builtin_altivec_vmulesh, "V4SiV8SsV8Ss", "") +BUILTIN(__builtin_altivec_vmuloub, "V8UsV16UcV16Uc", "") +BUILTIN(__builtin_altivec_vmulosb, "V8SsV16ScV16Sc", "") +BUILTIN(__builtin_altivec_vmulouh, "V4UiV8UsV8Us", "") +BUILTIN(__builtin_altivec_vmulosh, "V4SiV8SsV8Ss", "") + +BUILTIN(__builtin_altivec_vnmsubfp, "V4fV4fV4fV4f", "") + +BUILTIN(__builtin_altivec_vpkpx, "V8sV4UiV4Ui", "") +BUILTIN(__builtin_altivec_vpkuhus, "V16UcV8UsV8Us", "") +BUILTIN(__builtin_altivec_vpkshss, "V16ScV8SsV8Ss", "") +BUILTIN(__builtin_altivec_vpkuwus, "V8UsV4UiV4Ui", "") +BUILTIN(__builtin_altivec_vpkswss, "V8SsV4SiV4Si", "") +BUILTIN(__builtin_altivec_vpkshus, "V16UcV8SsV8Ss", "") +BUILTIN(__builtin_altivec_vpkswus, "V8UsV4SiV4Si", "") + +BUILTIN(__builtin_altivec_vperm_4si, "V4iV4iV4iV16Uc", "") + BUILTIN(__builtin_altivec_stvx, "vV4iiv*", "") BUILTIN(__builtin_altivec_stvxl, "vV4iiv*", "") BUILTIN(__builtin_altivec_stvebx, "vV16civ*", "") @@ -92,6 +145,48 @@ BUILTIN(__builtin_altivec_vminfp, "V4fV4fV4f", "") BUILTIN(__builtin_altivec_mtvscr, "vV4i", "") +BUILTIN(__builtin_altivec_vrefp, "V4fV4f", "") + +BUILTIN(__builtin_altivec_vrlb, "V16cV16cV16Uc", "") +BUILTIN(__builtin_altivec_vrlh, "V8sV8sV8Us", "") +BUILTIN(__builtin_altivec_vrlw, "V4iV4iV4Ui", "") + +BUILTIN(__builtin_altivec_vsel_4si, "V4iV4iV4iV4Ui", "") + +BUILTIN(__builtin_altivec_vsl, "V4iV4iV4i", "") +BUILTIN(__builtin_altivec_vslo, "V4iV4iV4i", "") + +BUILTIN(__builtin_altivec_vsrab, "V16cV16cV16Uc", "") +BUILTIN(__builtin_altivec_vsrah, "V8sV8sV8Us", "") +BUILTIN(__builtin_altivec_vsraw, "V4iV4iV4Ui", "") + +BUILTIN(__builtin_altivec_vsr, "V4iV4iV4i", "") +BUILTIN(__builtin_altivec_vsro, "V4iV4iV4i", "") + +BUILTIN(__builtin_altivec_vrfin, "V4fV4f", "") + +BUILTIN(__builtin_altivec_vrsqrtefp, "V4fV4f", "") + +BUILTIN(__builtin_altivec_vsubcuw, "V4UiV4UiV4Ui", "") + +BUILTIN(__builtin_altivec_vsum4sbs, "V4SiV16ScV4Si", "") +BUILTIN(__builtin_altivec_vsum4ubs, "V4UiV16UcV4Ui", "") +BUILTIN(__builtin_altivec_vsum4shs, "V4SiV8SsV4Si", "") + +BUILTIN(__builtin_altivec_vsum2sws, "V4SiV4SiV4Si", "") + +BUILTIN(__builtin_altivec_vsumsws, "V4SiV4SiV4Si", "") + +BUILTIN(__builtin_altivec_vrfiz, "V4fV4f", "") + +BUILTIN(__builtin_altivec_vupkhsb, "V8sV16c", "") +BUILTIN(__builtin_altivec_vupkhpx, "V4UiV8s", "") +BUILTIN(__builtin_altivec_vupkhsh, "V4iV8s", "") + +BUILTIN(__builtin_altivec_vupklsb, "V8sV16c", "") +BUILTIN(__builtin_altivec_vupklpx, "V4UiV8s", "") +BUILTIN(__builtin_altivec_vupklsh, "V4iV8s", "") + BUILTIN(__builtin_altivec_vcmpbfp_p, "iiV4fV4f", "") BUILTIN(__builtin_altivec_vcmpgefp_p, "iiV4fV4f", "") diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index b9ee902002..4c6a9b2316 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -1772,6 +1772,48 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID, switch (BuiltinID) { default: return 0; + // vec_ld, vec_lvsl, vec_lvsr + case PPC::BI__builtin_altivec_lvx: + case PPC::BI__builtin_altivec_lvxl: + case PPC::BI__builtin_altivec_lvebx: + case PPC::BI__builtin_altivec_lvehx: + case PPC::BI__builtin_altivec_lvewx: + case PPC::BI__builtin_altivec_lvsl: + case PPC::BI__builtin_altivec_lvsr: + { + Ops[1] = Builder.CreateBitCast(Ops[1], llvm::Type::getInt8PtrTy(VMContext)); + + Ops[0] = Builder.CreateGEP(Ops[1], Ops[0], "tmp"); + Ops.pop_back(); + + switch (BuiltinID) { + default: assert(0 && "Unsupported ld/lvsl/lvsr intrinsic!"); + case PPC::BI__builtin_altivec_lvx: + ID = Intrinsic::ppc_altivec_lvx; + break; + case PPC::BI__builtin_altivec_lvxl: + ID = Intrinsic::ppc_altivec_lvxl; + break; + case PPC::BI__builtin_altivec_lvebx: + ID = Intrinsic::ppc_altivec_lvebx; + break; + case PPC::BI__builtin_altivec_lvehx: + ID = Intrinsic::ppc_altivec_lvehx; + break; + case PPC::BI__builtin_altivec_lvewx: + ID = Intrinsic::ppc_altivec_lvewx; + break; + case PPC::BI__builtin_altivec_lvsl: + ID = Intrinsic::ppc_altivec_lvsl; + break; + case PPC::BI__builtin_altivec_lvsr: + ID = Intrinsic::ppc_altivec_lvsr; + break; + } + llvm::Function *F = CGM.getIntrinsic(ID); + return Builder.CreateCall(F, &Ops[0], &Ops[0] + Ops.size(), ""); + } + // vec_st case PPC::BI__builtin_altivec_stvx: case PPC::BI__builtin_altivec_stvxl: @@ -1780,12 +1822,11 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID, case PPC::BI__builtin_altivec_stvewx: { Ops[2] = Builder.CreateBitCast(Ops[2], llvm::Type::getInt8PtrTy(VMContext)); - Ops[1] = !isa<Constant>(Ops[1]) || !cast<Constant>(Ops[1])->isNullValue() - ? Builder.CreateGEP(Ops[2], Ops[1], "tmp") : Ops[2]; + Ops[1] = Builder.CreateGEP(Ops[2], Ops[1], "tmp"); Ops.pop_back(); switch (BuiltinID) { - default: assert(0 && "Unsupported vavg intrinsic!"); + default: assert(0 && "Unsupported st intrinsic!"); case PPC::BI__builtin_altivec_stvx: ID = Intrinsic::ppc_altivec_stvx; break; diff --git a/lib/Headers/altivec.h b/lib/Headers/altivec.h index 1cd0db8e4b..d3d5ad90ae 100644 --- a/lib/Headers/altivec.h +++ b/lib/Headers/altivec.h @@ -20,6 +20,9 @@ * \*===----------------------------------------------------------------------===*/ +// TODO: add functions for 'vector bool ..' and 'vector pixel' argument types according to +// the 'AltiVec Technology Programming Interface Manual' + #ifndef __ALTIVEC_H #define __ALTIVEC_H @@ -34,534 +37,629 @@ #define __CR6_LT 2 #define __CR6_LT_REV 3 -#define _ATTRS_o_ai __attribute__((__overloadable__, __always_inline__)) +#define __ATTRS_o_ai __attribute__((__overloadable__, __always_inline__)) + +static vector signed char __ATTRS_o_ai +vec_perm(vector signed char a, vector signed char b, vector unsigned char c); + +static vector unsigned char __ATTRS_o_ai +vec_perm(vector unsigned char a, vector unsigned char b, vector unsigned char c); + +static vector short __ATTRS_o_ai +vec_perm(vector short a, vector short b, vector unsigned char c); + +static vector unsigned short __ATTRS_o_ai +vec_perm(vector unsigned short a, vector unsigned short b, vector unsigned char c); + +static vector int __ATTRS_o_ai +vec_perm(vector int a, vector int b, vector unsigned char c); + +static vector unsigned int __ATTRS_o_ai +vec_perm(vector unsigned int a, vector unsigned int b, vector unsigned char c); + +static vector float __ATTRS_o_ai +vec_perm(vector float a, vector float b, vector unsigned char c); /* vec_abs */ -#define __builtin_vec_abs vec_abs #define __builtin_altivec_abs_v16qi vec_abs #define __builtin_altivec_abs_v8hi vec_abs #define __builtin_altivec_abs_v4si vec_abs -static vector signed char _ATTRS_o_ai +static vector signed char __ATTRS_o_ai vec_abs(vector signed char a) { return __builtin_altivec_vmaxsb(a, -a); } -static vector signed short _ATTRS_o_ai +static vector signed short __ATTRS_o_ai vec_abs(vector signed short a) { return __builtin_altivec_vmaxsh(a, -a); } -static vector signed int _ATTRS_o_ai +static vector signed int __ATTRS_o_ai vec_abs(vector signed int a) { return __builtin_altivec_vmaxsw(a, -a); } -static vector float _ATTRS_o_ai +static vector float __ATTRS_o_ai vec_abs(vector float a) { - vector unsigned int res = (vector unsigned int)a & - (vector unsigned int)(0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF); + vector unsigned int res = (vector unsigned int)a & (vector unsigned int)(0x7FFFFFFF); return (vector float)res; } /* vec_abss */ -#define __builtin_vec_abss vec_abss #define __builtin_altivec_abss_v16qi vec_abss #define __builtin_altivec_abss_v8hi vec_abss #define __builtin_altivec_abss_v4si vec_abss -static vector signed char _ATTRS_o_ai +static vector signed char __ATTRS_o_ai vec_abss(vector signed char a) { - return __builtin_altivec_vmaxsb(a, __builtin_altivec_vsubsbs( - (vector signed char)(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), a)); + return __builtin_altivec_vmaxsb(a, __builtin_altivec_vsubsbs((vector signed char)(0), a)); } -static vector signed short _ATTRS_o_ai +static vector signed short __ATTRS_o_ai vec_abss(vector signed short a) { - return __builtin_altivec_vmaxsh(a, __builtin_altivec_vsubshs( - (vector signed short)(0, 0, 0, 0, 0, 0, 0, 0), a)); + return __builtin_altivec_vmaxsh(a, __builtin_altivec_vsubshs((vector signed short)(0), a)); } -static vector signed int _ATTRS_o_ai +static vector signed int __ATTRS_o_ai vec_abss(vector signed int a) { - return __builtin_altivec_vmaxsw(a, __builtin_altivec_vsubsws( - (vector signed int)(0, 0, 0, 0), a)); + return __builtin_altivec_vmaxsw(a, __builtin_altivec_vsubsws((vector signed int)(0), a)); } /* vec_add */ -#define __builtin_altivec_vaddubm vec_add -#define __builtin_altivec_vadduhm vec_add -#define __builtin_altivec_vadduwm vec_add -#define __builtin_altivec_vaddfp vec_add -#define __builtin_vec_vaddubm vec_add -#define __builtin_vec_vadduhm vec_add -#define __builtin_vec_vadduwm vec_add -#define __builtin_vec_vaddfp vec_add -#define vec_vaddubm vec_add -#define vec_vadduhm vec_add -#define vec_vadduwm vec_add -#define vec_vaddfp vec_add - -static vector signed char _ATTRS_o_ai +static vector signed char __ATTRS_o_ai vec_add(vector signed char a, vector signed char b) { return a + b; } -static vector unsigned char _ATTRS_o_ai +static vector unsigned char __ATTRS_o_ai vec_add(vector unsigned char a, vector unsigned char b) { return a + b; } -static vector short _ATTRS_o_ai +static vector short __ATTRS_o_ai vec_add(vector short a, vector short b) { return a + b; } -static vector unsigned short _ATTRS_o_ai +static vector unsigned short __ATTRS_o_ai vec_add(vector unsigned short a, vector unsigned short b) { return a + b; } -static vector int _ATTRS_o_ai +static vector int __ATTRS_o_ai vec_add(vector int a, vector int b) { return a + b; } -static vector unsigned int _ATTRS_o_ai +static vector unsigned int __ATTRS_o_ai vec_add(vector unsigned int a, vector unsigned int b) { return a + b; } -static vector float _ATTRS_o_ai +static vector float __ATTRS_o_ai vec_add(vector float a, vector float b) { return a + b; } +/* vec_vaddubm */ + +#define __builtin_altivec_vaddubm vec_vaddubm + +static vector signed char __ATTRS_o_ai +vec_vaddubm(vector signed char a, vector signed char b) +{ + return a + b; +} + +static vector unsigned char __ATTRS_o_ai +vec_vaddubm(vector unsigned char a, vector unsigned char b) +{ + return a + b; +} + +/* vec_vadduhm */ + +#define __builtin_altivec_vadduhm vec_vadduhm + +static vector short __ATTRS_o_ai +vec_vadduhm(vector short a, vector short b) +{ + return a + b; +} + +static vector unsigned short __ATTRS_o_ai +vec_vadduhm(vector unsigned short a, vector unsigned short b) +{ + return a + b; +} + +/* vec_vadduwm */ + +#define __builtin_altivec_vadduwm vec_vadduwm + +static vector int __ATTRS_o_ai +vec_vadduwm(vector int a, vector int b) +{ + return a + b; +} + +static vector unsigned int __ATTRS_o_ai +vec_vadduwm(vector unsigned int a, vector unsigned int b) +{ + return a + b; +} + +/* vec_vaddfp */ + +#define __builtin_altivec_vaddfp vec_vaddfp + +static vector float __attribute__((__always_inline__)) +vec_vaddfp(vector float a, vector float b) +{ + return a + b; +} + /* vec_addc */ -#define __builtin_vec_addc __builtin_altivec_vaddcuw -#define vec_vaddcuw __builtin_altivec_vaddcuw -#define vec_addc __builtin_altivec_vaddcuw +static vector unsigned int __attribute__((__always_inline__)) +vec_addc(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vaddcuw(a, b); +} + +/* vec_vaddcuw */ + +static vector unsigned int __attribute__((__always_inline__)) +vec_vaddcuw(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vaddcuw(a, b); +} /* vec_adds */ -#define __builtin_vec_vaddsbs __builtin_altivec_vaddsbs -#define __builtin_vec_vaddubs __builtin_altivec_vaddubs -#define __builtin_vec_vaddshs __builtin_altivec_vaddshs -#define __builtin_vec_vadduhs __builtin_altivec_vadduhs -#define __builtin_vec_vaddsws __builtin_altivec_vaddsws -#define __builtin_vec_vadduws __builtin_altivec_vadduws -#define vec_vaddsbs __builtin_altivec_vaddsbs -#define vec_vaddubs __builtin_altivec_vaddubs -#define vec_vaddshs __builtin_altivec_vaddshs -#define vec_vadduhs __builtin_altivec_vadduhs -#define vec_vaddsws __builtin_altivec_vaddsws -#define vec_vadduws __builtin_altivec_vadduws - -static vector signed char _ATTRS_o_ai +static vector signed char __ATTRS_o_ai vec_adds(vector signed char a, vector signed char b) { return __builtin_altivec_vaddsbs(a, b); } -static vector unsigned char _ATTRS_o_ai +static vector unsigned char __ATTRS_o_ai vec_adds(vector unsigned char a, vector unsigned char b) { return __builtin_altivec_vaddubs(a, b); } -static vector short _ATTRS_o_ai +static vector short __ATTRS_o_ai vec_adds(vector short a, vector short b) { return __builtin_altivec_vaddshs(a, b); } -static vector unsigned short _ATTRS_o_ai +static vector unsigned short __ATTRS_o_ai vec_adds(vector unsigned short a, vector unsigned short b) { return __builtin_altivec_vadduhs(a, b); } -static vector int _ATTRS_o_ai +static vector int __ATTRS_o_ai vec_adds(vector int a, vector int b) { return __builtin_altivec_vaddsws(a, b); } -static vector unsigned int _ATTRS_o_ai +static vector unsigned int __ATTRS_o_ai vec_adds(vector unsigned int a, vector unsigned int b) { return __builtin_altivec_vadduws(a, b); } -/* vec_sub */ +/* vec_vaddsbs */ -#define __builtin_altivec_vsububm vec_sub -#define __builtin_altivec_vsubuhm vec_sub -#define __builtin_altivec_vsubuwm vec_sub -#define __builtin_altivec_vsubfp vec_sub -#define __builtin_vec_vsububm vec_sub -#define __builtin_vec_vsubuhm vec_sub -#define __builtin_vec_vsubuwm vec_sub -#define __builtin_vec_vsubfp vec_sub -#define vec_vsububm vec_sub -#define vec_vsubuhm vec_sub -#define vec_vsubuwm vec_sub -#define vec_vsubfp vec_sub - -static vector signed char _ATTRS_o_ai -vec_sub(vector signed char a, vector signed char b) +static vector signed char __attribute__((__always_inline__)) +vec_vaddsbs(vector signed char a, vector signed char b) { - return a - b; + return __builtin_altivec_vaddsbs(a, b); } -static vector unsigned char _ATTRS_o_ai -vec_sub(vector unsigned char a, vector unsigned char b) +/* vec_vaddubs */ + +static vector unsigned char __attribute__((__always_inline__)) +vec_vaddubs(vector unsigned char a, vector unsigned char b) { - return a - b; + return __builtin_altivec_vaddubs(a, b); } -static vector short _ATTRS_o_ai -vec_sub(vector short a, vector short b) +/* vec_vaddshs */ + +static vector short __attribute__((__always_inline__)) +vec_vaddshs(vector short a, vector short b) { - return a - b; + return __builtin_altivec_vaddshs(a, b); } -static vector unsigned short _ATTRS_o_ai -vec_sub(vector unsigned short a, vector unsigned short b) +/* vec_vadduhs */ + +static vector unsigned short __attribute__((__always_inline__)) +vec_vadduhs(vector unsigned short a, vector unsigned short b) { - return a - b; + return __builtin_altivec_vadduhs(a, b); } -static vector int _ATTRS_o_ai -vec_sub(vector int a, vector int b) +/* vec_vaddsws */ + +static vector int __attribute__((__always_inline__)) +vec_vaddsws(vector int a, vector int b) { - return a - b; + return __builtin_altivec_vaddsws(a, b); } -static vector unsigned int _ATTRS_o_ai -vec_sub(vector unsigned int a, vector unsigned int b) +/* vec_vadduws */ + +static vector unsigned int __attribute__((__always_inline__)) +vec_vadduws(vector unsigned int a, vector unsigned int b) { - return a - b; + return __builtin_altivec_vadduws(a, b); } -static vector float _ATTRS_o_ai -vec_sub(vector float a, vector float b) +/* vec_and */ + +#define __builtin_altivec_vand vec_and + +static vector signed char __ATTRS_o_ai +vec_and(vector signed char a, vector signed char b) { - return a - b; + return a & b; } -/* vec_subs */ +static vector unsigned char __ATTRS_o_ai +vec_and(vector unsigned char a, vector unsigned char b) +{ + return a & b; +} -#define __builtin_vec_vsubsbs __builtin_altivec_vsubsbs -#define __builtin_vec_vsububs __builtin_altivec_vsububs -#define __builtin_vec_vsubshs __builtin_altivec_vsubshs -#define __builtin_vec_vsubuhs __builtin_altivec_vsubuhs -#define __builtin_vec_vsubsws __builtin_altivec_vsubsws -#define __builtin_vec_vsubuws __builtin_altivec_vsubuws -#define vec_vsubsbs __builtin_altivec_vsubsbs -#define vec_vsububs __builtin_altivec_vsububs -#define vec_vsubshs __builtin_altivec_vsubshs -#define vec_vsubuhs __builtin_altivec_vsubuhs -#define vec_vsubsws __builtin_altivec_vsubsws -#define vec_vsubuws __builtin_altivec_vsubuws - -static vector signed char _ATTRS_o_ai -vec_subs(vector signed char a, vector signed char b) +static vector short __ATTRS_o_ai +vec_and(vector short a, vector short b) { - return __builtin_altivec_vsubsbs(a, b); + return a & b; } -static vector unsigned char _ATTRS_o_ai -vec_subs(vector unsigned char a, vector unsigned char b) +static vector unsigned short __ATTRS_o_ai +vec_and(vector unsigned short a, vector unsigned short b) { - return __builtin_altivec_vsububs(a, b); + return a & b; } -static vector short _ATTRS_o_ai -vec_subs(vector short a, vector short b) +static vector int __ATTRS_o_ai +vec_and(vector int a, vector int b) { - return __builtin_altivec_vsubshs(a, b); + return a & b; } -static vector unsigned short _ATTRS_o_ai -vec_subs(vector unsigned short a, vector unsigned short b) +static vector unsigned int __ATTRS_o_ai +vec_and(vector unsigned int a, vector unsigned int b) { - return __builtin_altivec_vsubuhs(a, b); + return a & b; } -static vector int _ATTRS_o_ai -vec_subs(vector int a, vector int b) +static vector float __ATTRS_o_ai +vec_and(vector float a, vector float b) { - return __builtin_altivec_vsubsws(a, b); + vector unsigned int res = (vector unsigned int)a & (vector unsigned int)b; + return (vector float)res; } -static vector unsigned int _ATTRS_o_ai -vec_subs(vector unsigned int a, vector unsigned int b) +/* vec_vand */ + +static vector signed char __ATTRS_o_ai +vec_vand(vector signed char a, vector signed char b) { - return __builtin_altivec_vsubuws(a, b); + return a & b; } -/* vec_avg */ +static vector unsigned char __ATTRS_o_ai +vec_vand(vector unsigned char a, vector unsigned char b) +{ + return a & b; +} -#define __builtin_vec_vavgsb __builtin_altivec_vavgsb -#define __builtin_vec_vavgub __builtin_altivec_vavgub -#define __builtin_vec_vavgsh __builtin_altivec_vavgsh -#define __builtin_vec_vavguh __builtin_altivec_vavguh -#define __builtin_vec_vavgsw __builtin_altivec_vavgsw -#define __builtin_vec_vavguw __builtin_altivec_vavguw -#define vec_vavgsb __builtin_altivec_vavgsb -#define vec_vavgub __builtin_altivec_vavgub -#define vec_vavgsh __builtin_altivec_vavgsh -#define vec_vavguh __builtin_altivec_vavguh -#define vec_vavgsw __builtin_altivec_vavgsw -#define vec_vavguw __builtin_altivec_vavguw - -static vector signed char _ATTRS_o_ai -vec_avg(vector signed char a, vector signed char b) +static vector short __ATTRS_o_ai +vec_vand(vector short a, vector short b) { - return __builtin_altivec_vavgsb(a, b); + return a & b; } -static vector unsigned char _ATTRS_o_ai -vec_avg(vector unsigned char a, vector unsigned char b) +static vector unsigned short __ATTRS_o_ai +vec_vand(vector unsigned short a, vector unsigned short b) { - return __builtin_altivec_vavgub(a, b); + return a & b; } -static vector short _ATTRS_o_ai -vec_avg(vector short a, vector short b) +static vector int __ATTRS_o_ai +vec_vand(vector int a, vector int b) { - return __builtin_altivec_vavgsh(a, b); + return a & b; } -static vector unsigned short _ATTRS_o_ai -vec_avg(vector unsigned short a, vector unsigned short b) +static vector unsigned int __ATTRS_o_ai +vec_vand(vector unsigned int a, vector unsigned int b) { - return __builtin_altivec_vavguh(a, b); + return a & b; } -static vector int _ATTRS_o_ai -vec_avg(vector int a, vector int b) +static vector float __ATTRS_o_ai +vec_vand(vector float a, vector float b) { - return __builtin_altivec_vavgsw(a, b); + vector unsigned int res = (vector unsigned int)a & (vector unsigned int)b; + return (vector float)res; } -static vector unsigned int _ATTRS_o_ai -vec_avg(vector unsigned int a, vector unsigned int b) +/* vec_andc */ + +#define __builtin_altivec_vandc vec_andc + +static vector signed char __ATTRS_o_ai +vec_andc(vector signed char a, vector signed char b) { - return __builtin_altivec_vavguw(a, b); + return a & ~b; } -/* vec_st */ +static vector unsigned char __ATTRS_o_ai +vec_andc(vector unsigned char a, vector unsigned char b) +{ + return a & ~b; +} -#define __builtin_vec_st vec_st -#define vec_stvx vec_st +static vector short __ATTRS_o_ai +vec_andc(vector short a, vector short b) +{ + return a & ~b; +} -static void _ATTRS_o_ai -vec_st(vector signed char a, int b, vector signed char *c) +static vector unsigned short __ATTRS_o_ai +vec_andc(vector unsigned short a, vector unsigned short b) { - __builtin_altivec_stvx((vector int)a, b, (void *)c); + return a & ~b; } -static void _ATTRS_o_ai -vec_st(vector unsigned char a, int b, vector unsigned char *c) +static vector int __ATTRS_o_ai +vec_andc(vector int a, vector int b) { - __builtin_altivec_stvx((vector int)a, b, (void *)c); + return a & ~b; } -static void _ATTRS_o_ai -vec_st(vector short a, int b, vector short *c) +static vector unsigned int __ATTRS_o_ai +vec_andc(vector unsigned int a, vector unsigned int b) { - __builtin_altivec_stvx((vector int)a, b, (void *)c); + return a & ~b; } -static void _ATTRS_o_ai -vec_st(vector unsigned short a, int b, vector unsigned short *c) +static vector float __ATTRS_o_ai +vec_andc(vector float a, vector float b) { - __builtin_altivec_stvx((vector int)a, b, (void *)c); + vector unsigned int res = (vector unsigned int)a & ~(vector unsigned int)b; + return (vector float)res; } -static void _ATTRS_o_ai -vec_st(vector int a, int b, vector int *c) +/* vec_vandc */ + +static vector signed char __ATTRS_o_ai +vec_vandc(vector signed char a, vector signed char b) { - __builtin_altivec_stvx(a, b, (void *)c); + return a & ~b; } -static void _ATTRS_o_ai -vec_st(vector unsigned int a, int b, vector unsigned int *c) +static vector unsigned char __ATTRS_o_ai +vec_vandc(vector unsigned char a, vector unsigned char b) { - __builtin_altivec_stvx((vector int)a, b, (void *)c); + return a & ~b; } -static void _ATTRS_o_ai -vec_st(vector float a, int b, vector float *c) +static vector short __ATTRS_o_ai +vec_vandc(vector short a, vector short b) { - __builtin_altivec_stvx((vector int)a, b, (void *)c); + return a & ~b; } -/* vec_stl */ +static vector unsigned short __ATTRS_o_ai +vec_vandc(vector unsigned short a, vector unsigned short b) +{ + return a & ~b; +} -#define __builtin_vec_stl vec_stl -#define vec_stvxl vec_stl +static vector int __ATTRS_o_ai +vec_vandc(vector int a, vector int b) +{ + return a & ~b; +} -static void _ATTRS_o_ai -vec_stl(vector signed char a, int b, vector signed char *c) +static vector unsigned int __ATTRS_o_ai +vec_vandc(vector unsigned int a, vector unsigned int b) { - __builtin_altivec_stvxl((vector int)a, b, (void *)c); + return a & ~b; } -static void _ATTRS_o_ai -vec_stl(vector unsigned char a, int b, vector unsigned char *c) +static vector float __ATTRS_o_ai +vec_vandc(vector float a, vector float b) { - __builtin_altivec_stvxl((vector int)a, b, (void *)c); + vector unsigned int res = (vector unsigned int)a & ~(vector unsigned int)b; + return (vector float)res; } -static void _ATTRS_o_ai -vec_stl(vector short a, int b, vector short *c) +/* vec_avg */ + +static vector signed char __ATTRS_o_ai +vec_avg(vector signed char a, vector signed char b) { - __builtin_altivec_stvxl((vector int)a, b, (void *)c); + return __builtin_altivec_vavgsb(a, b); } -static void _ATTRS_o_ai -vec_stl(vector unsigned short a, int b, vector unsigned short *c) +static vector unsigned char __ATTRS_o_ai +vec_avg(vector unsigned char a, vector unsigned char b) { - __builtin_altivec_stvxl((vector int)a, b, (void *)c); + return __builtin_altivec_vavgub(a, b); } -static void _ATTRS_o_ai -vec_stl(vector int a, int b, vector int *c) +static vector short __ATTRS_o_ai +vec_avg(vector short a, vector short b) { - __builtin_altivec_stvxl(a, b, (void *)c); + return __builtin_altivec_vavgsh(a, b); } -static void _ATTRS_o_ai -vec_stl(vector unsigned int a, int b, vector unsigned int *c) +static vector unsigned short __ATTRS_o_ai +vec_avg(vector unsigned short a, vector unsigned short b) { - __builtin_altivec_stvxl((vector int)a, b, (void *)c); + return __builtin_altivec_vavguh(a, b); } -static void _ATTRS_o_ai -vec_stl(vector float a, int b, vector float *c) +static vector int __ATTRS_o_ai +vec_avg(vector int a, vector int b) { - __builtin_altivec_stvxl((vector int)a, b, (void *)c); + return __builtin_altivec_vavgsw(a, b); } -/* vec_ste */ +static vector unsigned int __ATTRS_o_ai +vec_avg(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vavguw(a, b); +} -#define __builtin_vec_stvebx __builtin_altivec_stvebx -#define __builtin_vec_stvehx __builtin_altivec_stvehx -#define __builtin_vec_stvewx __builtin_altivec_stvewx -#define vec_stvebx __builtin_altivec_stvebx -#define vec_stvehx __builtin_altivec_stvehx -#define vec_stvewx __builtin_altivec_stvewx +/* vec_vavgsb */ -static void _ATTRS_o_ai -vec_ste(vector signed char a, int b, vector signed char *c) +static vector signed char __attribute__((__always_inline__)) +vec_vavgsb(vector signed char a, vector signed char b) { - __builtin_altivec_stvebx((vector char)a, b, (void *)c); + return __builtin_altivec_vavgsb(a, b); } -static void _ATTRS_o_ai -vec_ste(vector unsigned char a, int b, vector unsigned char *c) +/* vec_vavgub */ + +static vector unsigned char __attribute__((__always_inline__)) +vec_vavgub(vector unsigned char a, vector unsigned char b) { - __builtin_altivec_stvebx((vector char)a, b, (void *)c); + return __builtin_altivec_vavgub(a, b); } -static void _ATTRS_o_ai -vec_ste(vector short a, int b, vector short *c) +/* vec_vavgsh */ + +static vector short __attribute__((__always_inline__)) +vec_vavgsh(vector short a, vector short b) { - __builtin_altivec_stvehx(a, b, (void *)c); + return __builtin_altivec_vavgsh(a, b); } -static void _ATTRS_o_ai -vec_ste(vector unsigned short a, int b, vector unsigned short *c) +/* vec_vavguh */ + +static vector unsigned short __attribute__((__always_inline__)) +vec_vavguh(vector unsigned short a, vector unsigned short b) { - __builtin_altivec_stvehx((vector short)a, b, (void *)c); + return __builtin_altivec_vavguh(a, b); } -static void _ATTRS_o_ai -vec_ste(vector int a, int b, vector int *c) +/* vec_vavgsw */ + +static vector int __attribute__((__always_inline__)) +vec_vavgsw(vector int a, vector int b) +{ + return __builtin_altivec_vavgsw(a, b); +} + +/* vec_vavguw */ + +static vector unsigned int __attribute__((__always_inline__)) +vec_vavguw(vector unsigned int a, vector unsigned int b) { - __builtin_altivec_stvewx(a, b, (void *)c); + return __builtin_altivec_vavguw(a, b); } -static void _ATTRS_o_ai -vec_ste(vector unsigned int a, int b, vector unsigned int *c) +/* vec_ceil */ + +static vector float __attribute__((__always_inline__)) +vec_ceil(vector float a) { - __builtin_altivec_stvewx((vector int)a, b, (void *)c); + return __builtin_altivec_vrfip(a); } -static void _ATTRS_o_ai -vec_ste(vector float a, int b, vector float *c) +/* vec_vrfip */ + +static vector float __attribute__((__always_inline__)) +vec_vrfip(vector float a) { - __builtin_altivec_stvewx((vector int)a, b, (void *)c); + return __builtin_altivec_vrfip(a); } /* vec_cmpb */ -#define vec_cmpb __builtin_altivec_vcmpbfp -#define vec_vcmpbfp __builtin_altivec_vcmpbfp -#define __builtin_vec_cmpb __builtin_altivec_vcmpbfp +static vector int __attribute__((__always_inline__)) +vec_cmpb(vector float a, vector float b) +{ + return __builtin_altivec_vcmpbfp(a, b); +} + +/* vec_vcmpbfp */ -/* vec_cmpeq */ +static vector int __attribute__((__always_inline__)) +vec_vcmpbfp(vector float a, vector float b) +{ + return __builtin_altivec_vcmpbfp(a, b); +} -#define __builtin_vec_cmpeq vec_cmpeq +/* vec_cmpeq */ -static vector /*bool*/ char _ATTRS_o_ai +static vector /*bool*/ char __ATTRS_o_ai vec_cmpeq(vector signed char a, vector signed char b) { return __builtin_altivec_vcmpequb((vector char)a, (vector char)b); } -static vector /*bool*/ char _ATTRS_o_ai +static vector /*bool*/ char __ATTRS_o_ai vec_cmpeq(vector unsigned char a, vector unsigned char b) { return __builtin_altivec_vcmpequb((vector char)a, (vector char)b); } -static vector /*bool*/ short _ATTRS_o_ai +static vector /*bool*/ short __ATTRS_o_ai vec_cmpeq(vector short a, vector short b) { return __builtin_altivec_vcmpequh(a, b); } -static vector /*bool*/ short _ATTRS_o_ai +static vector /*bool*/ short __ATTRS_o_ai vec_cmpeq(vector unsigned short a, vector unsigned short b) { return __builtin_altivec_vcmpequh((vector short)a, (vector short)b); } -static vector /*bool*/ int _ATTRS_o_ai +static vector /*bool*/ int __ATTRS_o_ai vec_cmpeq(vector int a, vector int b) { return __builtin_altivec_vcmpequw(a, b); } -static vector /*bool*/ int _ATTRS_o_ai +static vector /*bool*/ int __ATTRS_o_ai vec_cmpeq(vector unsigned int a, vector unsigned int b) { return __builtin_altivec_vcmpequw((vector int)a, (vector int)b); } -static vector /*bool*/ int _ATTRS_o_ai +static vector /*bool*/ int __ATTRS_o_ai vec_cmpeq(vector float a, vector float b) { return __builtin_altivec_vcmpeqfp(a, b); @@ -569,72 +667,121 @@ vec_cmpeq(vector float a, vector float b) /* vec_cmpge */ -#define vec_cmpge __builtin_altivec_vcmpgefp -#define vec_vcmpgefp __builtin_altivec_vcmpgefp -#define __b |