From: Chris Lattner Date: Wed, 14 Apr 2010 03:54:58 +0000 (+0000) Subject: implement altivec.h and a bunch of support code, patch by Anton Yartsev! X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dd17394d225b06376e9ae1d23f36cec463fdef01;p=clang implement altivec.h and a bunch of support code, patch by Anton Yartsev! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101215 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/BuiltinsPPC.def b/include/clang/Basic/BuiltinsPPC.def index 817a032d92..287bba96df 100644 --- a/include/clang/Basic/BuiltinsPPC.def +++ b/include/clang/Basic/BuiltinsPPC.def @@ -18,7 +18,97 @@ // 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_v4sf , "ii" , "nc") +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", "") +BUILTIN(__builtin_altivec_vaddubs, "V16UcV16UcV16Uc", "") +BUILTIN(__builtin_altivec_vaddshs, "V8SsV8SsV8Ss", "") +BUILTIN(__builtin_altivec_vadduhs, "V8UsV8UsV8Us", "") +BUILTIN(__builtin_altivec_vaddsws, "V4SiV4SiV4Si", "") +BUILTIN(__builtin_altivec_vadduws, "V4UiV4UiV4Ui", "") + +BUILTIN(__builtin_altivec_vsubsbs, "V16ScV16ScV16Sc", "") +BUILTIN(__builtin_altivec_vsububs, "V16UcV16UcV16Uc", "") +BUILTIN(__builtin_altivec_vsubshs, "V8SsV8SsV8Ss", "") +BUILTIN(__builtin_altivec_vsubuhs, "V8UsV8UsV8Us", "") +BUILTIN(__builtin_altivec_vsubsws, "V4SiV4SiV4Si", "") +BUILTIN(__builtin_altivec_vsubuws, "V4UiV4UiV4Ui", "") + +BUILTIN(__builtin_altivec_vavgsb, "V16ScV16ScV16Sc", "") +BUILTIN(__builtin_altivec_vavgub, "V16UcV16UcV16Uc", "") +BUILTIN(__builtin_altivec_vavgsh, "V8SsV8SsV8Ss", "") +BUILTIN(__builtin_altivec_vavguh, "V8UsV8UsV8Us", "") +BUILTIN(__builtin_altivec_vavgsw, "V4SiV4SiV4Si", "") +BUILTIN(__builtin_altivec_vavguw, "V4UiV4UiV4Ui", "") + +BUILTIN(__builtin_altivec_stvx, "vV4iiv*", "") +BUILTIN(__builtin_altivec_stvxl, "vV4iiv*", "") +BUILTIN(__builtin_altivec_stvebx, "vV16civ*", "") +BUILTIN(__builtin_altivec_stvehx, "vV8siv*", "") +BUILTIN(__builtin_altivec_stvewx, "vV4iiv*", "") + +BUILTIN(__builtin_altivec_vcmpbfp, "V4iV4fV4f", "") + +BUILTIN(__builtin_altivec_vcmpgefp, "V4iV4fV4f", "") + +BUILTIN(__builtin_altivec_vcmpequb, "V16cV16cV16c", "") +BUILTIN(__builtin_altivec_vcmpequh, "V8sV8sV8s", "") +BUILTIN(__builtin_altivec_vcmpequw, "V4iV4iV4i", "") +BUILTIN(__builtin_altivec_vcmpeqfp, "V4iV4fV4f", "") + +BUILTIN(__builtin_altivec_vcmpgtsb, "V16cV16ScV16Sc", "") +BUILTIN(__builtin_altivec_vcmpgtub, "V16cV16UcV16Uc", "") +BUILTIN(__builtin_altivec_vcmpgtsh, "V8sV8SsV8Ss", "") +BUILTIN(__builtin_altivec_vcmpgtuh, "V8sV8UsV8Us", "") +BUILTIN(__builtin_altivec_vcmpgtsw, "V4iV4SiV4Si", "") +BUILTIN(__builtin_altivec_vcmpgtuw, "V4iV4UiV4Ui", "") +BUILTIN(__builtin_altivec_vcmpgtfp, "V4iV4fV4f", "") + +BUILTIN(__builtin_altivec_vmaxsb, "V16ScV16ScV16Sc", "") +BUILTIN(__builtin_altivec_vmaxub, "V16UcV16UcV16Uc", "") +BUILTIN(__builtin_altivec_vmaxsh, "V8SsV8SsV8Ss", "") +BUILTIN(__builtin_altivec_vmaxuh, "V8UsV8UsV8Us", "") +BUILTIN(__builtin_altivec_vmaxsw, "V4SiV4SiV4Si", "") +BUILTIN(__builtin_altivec_vmaxuw, "V4UiV4UiV4Ui", "") +BUILTIN(__builtin_altivec_vmaxfp, "V4fV4fV4f", "") + +BUILTIN(__builtin_altivec_mfvscr, "V8Us", "") + +BUILTIN(__builtin_altivec_vminsb, "V16ScV16ScV16Sc", "") +BUILTIN(__builtin_altivec_vminub, "V16UcV16UcV16Uc", "") +BUILTIN(__builtin_altivec_vminsh, "V8SsV8SsV8Ss", "") +BUILTIN(__builtin_altivec_vminuh, "V8UsV8UsV8Us", "") +BUILTIN(__builtin_altivec_vminsw, "V4SiV4SiV4Si", "") +BUILTIN(__builtin_altivec_vminuw, "V4UiV4UiV4Ui", "") +BUILTIN(__builtin_altivec_vminfp, "V4fV4fV4f", "") + +BUILTIN(__builtin_altivec_mtvscr, "vV4i", "") + +BUILTIN(__builtin_altivec_vcmpbfp_p, "iiV4fV4f", "") + +BUILTIN(__builtin_altivec_vcmpgefp_p, "iiV4fV4f", "") + +BUILTIN(__builtin_altivec_vcmpequb_p, "iiV16cV16c", "") +BUILTIN(__builtin_altivec_vcmpequh_p, "iiV8sV8s", "") +BUILTIN(__builtin_altivec_vcmpequw_p, "iiV4iV4i", "") +BUILTIN(__builtin_altivec_vcmpeqfp_p, "iiV4fV4f", "") + +BUILTIN(__builtin_altivec_vcmpgtsb_p, "iiV16ScV16Sc", "") +BUILTIN(__builtin_altivec_vcmpgtub_p, "iiV16UcV16Uc", "") +BUILTIN(__builtin_altivec_vcmpgtsh_p, "iiV8SsV8Ss", "") +BUILTIN(__builtin_altivec_vcmpgtuh_p, "iiV8UsV8Us", "") +BUILTIN(__builtin_altivec_vcmpgtsw_p, "iiV4SiV4Si", "") +BUILTIN(__builtin_altivec_vcmpgtuw_p, "iiV4UiV4Ui", "") +BUILTIN(__builtin_altivec_vcmpgtfp_p, "iiV4fV4f", "") + // FIXME: Obviously incomplete. #undef BUILTIN diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index a46cc39efa..85ab1dceba 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -1024,5 +1024,49 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { + llvm::SmallVector Ops; + + for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) + Ops.push_back(EmitScalarExpr(E->getArg(i))); + + Intrinsic::ID ID = Intrinsic::not_intrinsic; + + switch (BuiltinID) { + default: return 0; + + // vec_st + case PPC::BI__builtin_altivec_stvx: + case PPC::BI__builtin_altivec_stvxl: + case PPC::BI__builtin_altivec_stvebx: + case PPC::BI__builtin_altivec_stvehx: + case PPC::BI__builtin_altivec_stvewx: + { + Ops[2] = Builder.CreateBitCast(Ops[2], llvm::Type::getInt8PtrTy(VMContext)); + Ops[1] = !isa(Ops[1]) || !cast(Ops[1])->isNullValue() + ? Builder.CreateGEP(Ops[2], Ops[1], "tmp") : Ops[2]; + Ops.pop_back(); + + switch (BuiltinID) { + default: assert(0 && "Unsupported vavg intrinsic!"); + case PPC::BI__builtin_altivec_stvx: + ID = Intrinsic::ppc_altivec_stvx; + break; + case PPC::BI__builtin_altivec_stvxl: + ID = Intrinsic::ppc_altivec_stvxl; + break; + case PPC::BI__builtin_altivec_stvebx: + ID = Intrinsic::ppc_altivec_stvebx; + break; + case PPC::BI__builtin_altivec_stvehx: + ID = Intrinsic::ppc_altivec_stvehx; + break; + case PPC::BI__builtin_altivec_stvewx: + ID = Intrinsic::ppc_altivec_stvewx; + break; + } + llvm::Function *F = CGM.getIntrinsic(ID); + return Builder.CreateCall(F, &Ops[0], &Ops[0] + Ops.size(), ""); + } + } return 0; } diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index d40f0bfd76..990371b214 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1278,6 +1278,10 @@ static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args, Opts.Includes.push_back(it->getValue(Args)); } + // Include 'altivec.h' if -faltivec option present + if (Args.hasArg(OPT_faltivec)) + Opts.Includes.push_back("altivec.h"); + for (arg_iterator it = Args.filtered_begin(OPT_remap_file), ie = Args.filtered_end(); it != ie; ++it) { std::pair Split = diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt index e63291b2af..4416302940 100644 --- a/lib/Headers/CMakeLists.txt +++ b/lib/Headers/CMakeLists.txt @@ -1,4 +1,5 @@ set(files + altivec.h emmintrin.h float.h iso646.h diff --git a/lib/Headers/altivec.h b/lib/Headers/altivec.h new file mode 100644 index 0000000000..d252920ccb --- /dev/null +++ b/lib/Headers/altivec.h @@ -0,0 +1,1632 @@ +/*===---- altivec.h - Standard header for type generic math ---------------===*\ + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * +\*===----------------------------------------------------------------------===*/ + +#ifndef __ALTIVEC_H +#define __ALTIVEC_H + +#ifndef __ALTIVEC__ +#error "AltiVec support not enabled" +#endif + +/* constants for mapping CR6 bits to predicate result. */ + +#define __CR6_EQ 0 +#define __CR6_EQ_REV 1 +#define __CR6_LT 2 +#define __CR6_LT_REV 3 + +#define _ATTRS_o_ai __attribute__((__overloadable__, __always_inline__)) + +/* 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 +vec_abs(vector signed char a) +{ + return __builtin_altivec_vmaxsb(a, -a); +} + +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 +vec_abs(vector signed int a) +{ + return __builtin_altivec_vmaxsw(a, -a); +} + +static vector float _ATTRS_o_ai +vec_abs(vector float a) +{ + return (vector unsigned int)a & + (vector unsigned int)(0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF); +} + +/* 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 +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)); +} + +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)); +} + +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)); +} + +/* 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 char _ATTRS_o_ai +vec_add(vector char a, vector char b) +{ + return a + b; +} + +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 +vec_add(vector unsigned char a, vector unsigned char b) +{ + return a + b; +} + +static vector short _ATTRS_o_ai +vec_add(vector short a, vector short b) +{ + return a + b; +} + +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 +vec_add(vector int a, vector int b) +{ + return a + b; +} + +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 +vec_add(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 + +/* 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 char _ATTRS_o_ai +vec_adds(vector char a, vector char b) +{ + return __builtin_altivec_vaddsbs(a, b); +} + +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 +vec_adds(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vaddubs(a, b); +} + +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 +vec_adds(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vadduhs(a, b); +} + +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 +vec_adds(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vadduws(a, b); +} + +/* vec_sub */ + +#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 char _ATTRS_o_ai +vec_sub(vector char a, vector char b) +{ + return a - b; +} + +static vector signed char _ATTRS_o_ai +vec_sub(vector signed char a, vector signed char b) +{ + return a - b; +} + +static vector unsigned char _ATTRS_o_ai +vec_sub(vector unsigned char a, vector unsigned char b) +{ + return a - b; +} + +static vector short _ATTRS_o_ai +vec_sub(vector short a, vector short b) +{ + return a - b; +} + +static vector unsigned short _ATTRS_o_ai +vec_sub(vector unsigned short a, vector unsigned short b) +{ + return a - b; +} + +static vector int _ATTRS_o_ai +vec_sub(vector int a, vector int b) +{ + return a - b; +} + +static vector unsigned int _ATTRS_o_ai +vec_sub(vector unsigned int a, vector unsigned int b) +{ + return a - b; +} + +static vector float _ATTRS_o_ai +vec_sub(vector float a, vector float b) +{ + return a - b; +} + +/* vec_subs */ + +#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 char _ATTRS_o_ai +vec_subs(vector char a, vector char b) +{ + return __builtin_altivec_vsubsbs(a, b); +} + +static vector signed char _ATTRS_o_ai +vec_subs(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vsubsbs(a, b); +} + +static vector unsigned char _ATTRS_o_ai +vec_subs(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vsububs(a, b); +} + +static vector short _ATTRS_o_ai +vec_subs(vector short a, vector short b) +{ + return __builtin_altivec_vsubshs(a, b); +} + +static vector unsigned short _ATTRS_o_ai +vec_subs(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vsubuhs(a, b); +} + +static vector int _ATTRS_o_ai +vec_subs(vector int a, vector int b) +{ + return __builtin_altivec_vsubsws(a, b); +} + +static vector unsigned int _ATTRS_o_ai +vec_subs(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vsubuws(a, b); +} + +/* vec_avg */ + +#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 char _ATTRS_o_ai +vec_avg(vector char a, vector char b) +{ + return __builtin_altivec_vavgsb(a, b); +} + +static vector signed char _ATTRS_o_ai +vec_avg(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vavgsb(a, b); +} + +static vector unsigned char _ATTRS_o_ai +vec_avg(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vavgub(a, b); +} + +static vector short _ATTRS_o_ai +vec_avg(vector short a, vector short b) +{ + return __builtin_altivec_vavgsh(a, b); +} + +static vector unsigned short _ATTRS_o_ai +vec_avg(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vavguh(a, b); +} + +static vector int _ATTRS_o_ai +vec_avg(vector int a, vector int b) +{ + return __builtin_altivec_vavgsw(a, b); +} + +static vector unsigned int _ATTRS_o_ai +vec_avg(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vavguw(a, b); +} + +/* vec_st */ + +#define __builtin_vec_st vec_st +#define vec_stvx vec_st + +static void _ATTRS_o_ai +vec_st(vector char a, int b, vector char *c) +{ + __builtin_altivec_stvx((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_st(vector signed char a, int b, vector signed char *c) +{ + __builtin_altivec_stvx((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_st(vector unsigned char a, int b, vector unsigned char *c) +{ + __builtin_altivec_stvx((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_st(vector short a, int b, vector short *c) +{ + __builtin_altivec_stvx((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_st(vector unsigned short a, int b, vector unsigned short *c) +{ + __builtin_altivec_stvx((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_st(vector int a, int b, vector int *c) +{ + __builtin_altivec_stvx(a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_st(vector unsigned int a, int b, vector unsigned int *c) +{ + __builtin_altivec_stvx((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_st(vector float a, int b, vector float *c) +{ + __builtin_altivec_stvx((vector int)a, b, (void *)c); +} + +/* vec_stl */ + +#define __builtin_vec_stl vec_stl +#define vec_stvxl vec_stl + +static void _ATTRS_o_ai +vec_stl(vector char a, int b, vector char *c) +{ + __builtin_altivec_stvxl((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_stl(vector signed char a, int b, vector signed char *c) +{ + __builtin_altivec_stvxl((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_stl(vector unsigned char a, int b, vector unsigned char *c) +{ + __builtin_altivec_stvxl((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_stl(vector short a, int b, vector short *c) +{ + __builtin_altivec_stvxl((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_stl(vector unsigned short a, int b, vector unsigned short *c) +{ + __builtin_altivec_stvxl((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_stl(vector int a, int b, vector int *c) +{ + __builtin_altivec_stvxl(a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_stl(vector unsigned int a, int b, vector unsigned int *c) +{ + __builtin_altivec_stvxl((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_stl(vector float a, int b, vector float *c) +{ + __builtin_altivec_stvxl((vector int)a, b, (void *)c); +} + +/* vec_ste */ + +#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 + +static void _ATTRS_o_ai +vec_ste(vector char a, int b, vector char *c) +{ + __builtin_altivec_stvebx((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_ste(vector signed char a, int b, vector signed char *c) +{ + __builtin_altivec_stvebx((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_ste(vector unsigned char a, int b, vector unsigned char *c) +{ + __builtin_altivec_stvebx((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_ste(vector short a, int b, vector short *c) +{ + __builtin_altivec_stvehx((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_ste(vector unsigned short a, int b, vector unsigned short *c) +{ + __builtin_altivec_stvehx((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_ste(vector int a, int b, vector int *c) +{ + __builtin_altivec_stvewx(a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_ste(vector unsigned int a, int b, vector unsigned int *c) +{ + __builtin_altivec_stvewx((vector int)a, b, (void *)c); +} + +static void _ATTRS_o_ai +vec_ste(vector float a, int b, vector float *c) +{ + __builtin_altivec_stvewx((vector int)a, b, (void *)c); +} + +/* vec_cmpb */ + +#define vec_cmpb __builtin_altivec_vcmpbfp +#define vec_vcmpbfp __builtin_altivec_vcmpbfp +#define __builtin_vec_cmpb __builtin_altivec_vcmpbfp + +/* vec_cmpeq */ + +#define __builtin_vec_cmpeq vec_cmpeq + +static vector char _ATTRS_o_ai +vec_cmpeq(vector char a, vector char b) +{ + return __builtin_altivec_vcmpequb(a, b); +} + +static vector char _ATTRS_o_ai +vec_cmpeq(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vcmpequb(a, b); +} + +static vector char _ATTRS_o_ai +vec_cmpeq(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vcmpequb(a, b); +} + +static vector short _ATTRS_o_ai +vec_cmpeq(vector short a, vector short b) +{ + return __builtin_altivec_vcmpequh(a, b); +} + +static vector short _ATTRS_o_ai +vec_cmpeq(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vcmpequh(a, b); +} + +static vector int _ATTRS_o_ai +vec_cmpeq(vector int a, vector int b) +{ + return __builtin_altivec_vcmpequw(a, b); +} + +static vector int _ATTRS_o_ai +vec_cmpeq(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vcmpequw(a, b); +} + +static vector int _ATTRS_o_ai +vec_cmpeq(vector float a, vector float b) +{ + return __builtin_altivec_vcmpeqfp(a, b); +} + +/* vec_cmpge */ + +#define vec_cmpge __builtin_altivec_vcmpgefp +#define vec_vcmpgefp __builtin_altivec_vcmpgefp +#define __builtin_vec_cmpge __builtin_altivec_vcmpgefp + +/* vec_cmpgt */ + +#define vec_vcmpgtsb __builtin_altivec_vcmpgtsb +#define vec_vcmpgtub __builtin_altivec_vcmpgtub +#define vec_vcmpgtsh __builtin_altivec_vcmpgtsh +#define vec_vcmpgtuh __builtin_altivec_vcmpgtuh +#define vec_vcmpgtsw __builtin_altivec_vcmpgtsw +#define vec_vcmpgtuw __builtin_altivec_vcmpgtuw +#define vec_vcmpgtfp __builtin_altivec_vcmpgtfp +#define __builtin_vec_vcmpgtsb __builtin_altivec_vcmpgtsb +#define __builtin_vec_vcmpgtub __builtin_altivec_vcmpgtub +#define __builtin_vec_vcmpgtsh __builtin_altivec_vcmpgtsh +#define __builtin_vec_vcmpgtuh __builtin_altivec_vcmpgtuh +#define __builtin_vec_vcmpgtsw __builtin_altivec_vcmpgtsw +#define __builtin_vec_vcmpgtuw __builtin_altivec_vcmpgtuw +#define __builtin_vec_vcmpgtfp __builtin_altivec_vcmpgtfp + +static vector char _ATTRS_o_ai +vec_cmpgt(vector char a, vector char b) +{ + return __builtin_altivec_vcmpgtsb(a, b); +} + +static vector char _ATTRS_o_ai +vec_cmpgt(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vcmpgtsb(a, b); +} + +static vector char _ATTRS_o_ai +vec_cmpgt(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vcmpgtub(a, b); +} + +static vector short _ATTRS_o_ai +vec_cmpgt(vector short a, vector short b) +{ + return __builtin_altivec_vcmpgtsh(a, b); +} + +static vector short _ATTRS_o_ai +vec_cmpgt(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vcmpgtuh(a, b); +} + +static vector int _ATTRS_o_ai +vec_cmpgt(vector int a, vector int b) +{ + return __builtin_altivec_vcmpgtsw(a, b); +} + +static vector int _ATTRS_o_ai +vec_cmpgt(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vcmpgtuw(a, b); +} + +static vector int _ATTRS_o_ai +vec_cmpgt(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgtfp(a, b); +} + +/* vec_cmple */ + +#define __builtin_vec_cmple vec_cmple + +static vector int __attribute__((__always_inline__)) +vec_cmple(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgefp(b, a); +} + +/* vec_cmplt */ + +#define __builtin_vec_cmplt vec_cmplt + +static vector char _ATTRS_o_ai +vec_cmplt(vector char a, vector char b) +{ + return __builtin_altivec_vcmpgtsb(b, a); +} + +static vector char _ATTRS_o_ai +vec_cmplt(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vcmpgtsb(b, a); +} + +static vector char _ATTRS_o_ai +vec_cmplt(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vcmpgtub(b, a); +} + +static vector short _ATTRS_o_ai +vec_cmplt(vector short a, vector short b) +{ + return __builtin_altivec_vcmpgtsh(b, a); +} + +static vector short _ATTRS_o_ai +vec_cmplt(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vcmpgtuh(b, a); +} + +static vector int _ATTRS_o_ai +vec_cmplt(vector int a, vector int b) +{ + return __builtin_altivec_vcmpgtsw(b, a); +} + +static vector int _ATTRS_o_ai +vec_cmplt(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vcmpgtuw(b, a); +} + +static vector int _ATTRS_o_ai +vec_cmplt(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgtfp(b, a); +} + +/* vec_max */ + +#define __builtin_vec_vmaxsb __builtin_altivec_vmaxsb +#define __builtin_vec_vmaxub __builtin_altivec_vmaxub +#define __builtin_vec_vmaxsh __builtin_altivec_vmaxsh +#define __builtin_vec_vmaxuh __builtin_altivec_vmaxuh +#define __builtin_vec_vmaxsw __builtin_altivec_vmaxsw +#define __builtin_vec_vmaxuw __builtin_altivec_vmaxuw +#define __builtin_vec_vmaxfp __builtin_altivec_vmaxfp +#define vec_vmaxsb __builtin_altivec_vmaxsb +#define vec_vmaxub __builtin_altivec_vmaxub +#define vec_vmaxsh __builtin_altivec_vmaxsh +#define vec_vmaxuh __builtin_altivec_vmaxuh +#define vec_vmaxsw __builtin_altivec_vmaxsw +#define vec_vmaxuw __builtin_altivec_vmaxuw +#define vec_vmaxfp __builtin_altivec_vmaxfp +#define __builtin_vec_max vec_max + +static vector char _ATTRS_o_ai +vec_max(vector char a, vector char b) +{ + return __builtin_altivec_vmaxsb(a, b); +} + +static vector signed char _ATTRS_o_ai +vec_max(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vmaxsb(a, b); +} + +static vector unsigned char _ATTRS_o_ai +vec_max(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vmaxub(a, b); +} + +static vector short _ATTRS_o_ai +vec_max(vector short a, vector short b) +{ + return __builtin_altivec_vmaxsh(a, b); +} + +static vector unsigned short _ATTRS_o_ai +vec_max(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vmaxuh(a, b); +} + +static vector int _ATTRS_o_ai +vec_max(vector int a, vector int b) +{ + return __builtin_altivec_vmaxsw(a, b); +} + +static vector unsigned int _ATTRS_o_ai +vec_max(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vmaxuw(a, b); +} + +static vector float _ATTRS_o_ai +vec_max(vector float a, vector float b) +{ + return __builtin_altivec_vmaxfp(a, b); +} + +/* vec_mfvscr */ + +#define __builtin_vec_mfvscr __builtin_altivec_mfvscr +#define vec_mfvscr __builtin_altivec_mfvscr + +/* vec_min */ + +#define __builtin_vec_vminsb __builtin_altivec_vminsb +#define __builtin_vec_vminub __builtin_altivec_vminub +#define __builtin_vec_vminsh __builtin_altivec_vminsh +#define __builtin_vec_vminuh __builtin_altivec_vminuh +#define __builtin_vec_vminsw __builtin_altivec_vminsw +#define __builtin_vec_vminuw __builtin_altivec_vminuw +#define __builtin_vec_vminfp __builtin_altivec_vminfp +#define vec_vminsb __builtin_altivec_vminsb +#define vec_vminub __builtin_altivec_vminub +#define vec_vminsh __builtin_altivec_vminsh +#define vec_vminuh __builtin_altivec_vminuh +#define vec_vminsw __builtin_altivec_vminsw +#define vec_vminuw __builtin_altivec_vminuw +#define vec_vminfp __builtin_altivec_vminfp +#define __builtin_vec_min vec_min + +static vector char _ATTRS_o_ai +vec_min(vector char a, vector char b) +{ + return __builtin_altivec_vminsb(a, b); +} + +static vector signed char _ATTRS_o_ai +vec_min(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vminsb(a, b); +} + +static vector unsigned char _ATTRS_o_ai +vec_min(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vminub(a, b); +} + +static vector short _ATTRS_o_ai +vec_min(vector short a, vector short b) +{ + return __builtin_altivec_vminsh(a, b); +} + +static vector unsigned short _ATTRS_o_ai +vec_min(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vminuh(a, b); +} + +static vector int _ATTRS_o_ai +vec_min(vector int a, vector int b) +{ + return __builtin_altivec_vminsw(a, b); +} + +static vector unsigned int _ATTRS_o_ai +vec_min(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vminuw(a, b); +} + +static vector float _ATTRS_o_ai +vec_min(vector float a, vector float b) +{ + return __builtin_altivec_vminfp(a, b); +} + +/* vec_mtvscr */ + +#define __builtin_vec_mtvscr __builtin_altivec_mtvscr +#define vec_mtvscr __builtin_altivec_mtvscr + +/* ------------------------------ predicates ------------------------------------ */ + +static int __attribute__((__always_inline__)) +__builtin_vec_vcmpeq_p(char CR6_param, vector float a, vector float b) +{ + return __builtin_altivec_vcmpeqfp_p(CR6_param, a, b); +} + +static int __attribute__((__always_inline__)) +__builtin_vec_vcmpge_p(char CR6_param, vector float a, vector float b) +{ + return __builtin_altivec_vcmpgefp_p(CR6_param, a, b); +} + +static int __attribute__((__always_inline__)) +__builtin_vec_vcmpgt_p(char CR6_param, vector float a, vector float b) +{ + return __builtin_altivec_vcmpgtfp_p(CR6_param, a, b); +} + +/* vec_all_eq */ + +static int _ATTRS_o_ai +vec_all_eq(vector char a, vector char b) +{ + return __builtin_altivec_vcmpequb_p(__CR6_LT, a, b); +} + +static int _ATTRS_o_ai +vec_all_eq(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vcmpequb_p(__CR6_LT, a, b); +} + +static int _ATTRS_o_ai +vec_all_eq(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vcmpequb_p(__CR6_LT, a, b); +} + +static int _ATTRS_o_ai +vec_all_eq(vector short a, vector short b) +{ + return __builtin_altivec_vcmpequh_p(__CR6_LT, a, b); +} + +static int _ATTRS_o_ai +vec_all_eq(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vcmpequh_p(__CR6_LT, a, b); +} + +static int _ATTRS_o_ai +vec_all_eq(vector int a, vector int b) +{ + return __builtin_altivec_vcmpequw_p(__CR6_LT, a, b); +} + +static int _ATTRS_o_ai +vec_all_eq(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vcmpequw_p(__CR6_LT, a, b); +} + +static int _ATTRS_o_ai +vec_all_eq(vector float a, vector float b) +{ + return __builtin_altivec_vcmpeqfp_p(__CR6_LT, a, b); +} + +/* vec_all_ge */ + +static int _ATTRS_o_ai +vec_all_ge(vector char a, vector char b) +{ + return __builtin_altivec_vcmpgtsb_p(__CR6_LT, b, a); +} + +static int _ATTRS_o_ai +vec_all_ge(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vcmpgtsb_p(__CR6_LT, b, a); +} + +static int _ATTRS_o_ai +vec_all_ge(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vcmpgtub_p(__CR6_LT, b, a); +} + +static int _ATTRS_o_ai +vec_all_ge(vector short a, vector short b) +{ + return __builtin_altivec_vcmpgtsh_p(__CR6_LT, b, a); +} + +static int _ATTRS_o_ai +vec_all_ge(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vcmpgtuh_p(__CR6_LT, b, a); +} + +static int _ATTRS_o_ai +vec_all_ge(vector int a, vector int b) +{ + return __builtin_altivec_vcmpgtsw_p(__CR6_LT, b, a); +} + +static int _ATTRS_o_ai +vec_all_ge(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vcmpgtuw_p(__CR6_LT, b, a); +} + +static int _ATTRS_o_ai +vec_all_ge(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgtfp_p(__CR6_LT, b, a); +} + +/* vec_all_gt */ + +static int _ATTRS_o_ai +vec_all_gt(vector char a, vector char b) +{ + return __builtin_altivec_vcmpgtsb_p(__CR6_LT, a, b); +} + +static int _ATTRS_o_ai +vec_all_gt(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vcmpgtsb_p(__CR6_LT, a, b); +} + +static int _ATTRS_o_ai +vec_all_gt(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vcmpgtub_p(__CR6_LT, a, b); +} + +static int _ATTRS_o_ai +vec_all_gt(vector short a, vector short b) +{ + return __builtin_altivec_vcmpgtsh_p(__CR6_LT, a, b); +} + +static int _ATTRS_o_ai +vec_all_gt(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vcmpgtuh_p(__CR6_LT, a, b); +} + +static int _ATTRS_o_ai +vec_all_gt(vector int a, vector int b) +{ + return __builtin_altivec_vcmpgtsw_p(__CR6_LT, a, b); +} + +static int _ATTRS_o_ai +vec_all_gt(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vcmpgtuw_p(__CR6_LT, a, b); +} + +static int _ATTRS_o_ai +vec_all_gt(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgtfp_p(__CR6_LT, a, b); +} + +/* vec_all_in */ + +static int __attribute__((__always_inline__)) +vec_all_in(vector float a, vector float b) +{ + return __builtin_altivec_vcmpbfp_p(__CR6_EQ, a, b); +} + +/* vec_all_le */ + +static int _ATTRS_o_ai +vec_all_le(vector char a, vector char b) +{ + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, a, b); +} + +static int _ATTRS_o_ai +vec_all_le(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, a, b); +} + +static int _ATTRS_o_ai +vec_all_le(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vcmpgtub_p(__CR6_EQ, a, b); +} + +static int _ATTRS_o_ai +vec_all_le(vector short a, vector short b) +{ + return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, a, b); +} + +static int _ATTRS_o_ai +vec_all_le(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, a, b); +} + +static int _ATTRS_o_ai +vec_all_le(vector int a, vector int b) +{ + return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, a, b); +} + +static int _ATTRS_o_ai +vec_all_le(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, a, b); +} + +static int _ATTRS_o_ai +vec_all_le(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, a, b); +} + +/* vec_all_lt */ + +static int _ATTRS_o_ai +vec_all_lt(vector char a, vector char b) +{ + return __builtin_altivec_vcmpgtsb_p(__CR6_LT, b, a); +} + +static int _ATTRS_o_ai +vec_all_lt(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vcmpgtsb_p(__CR6_LT, b, a); +} + +static int _ATTRS_o_ai +vec_all_lt(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vcmpgtub_p(__CR6_LT, b, a); +} + +static int _ATTRS_o_ai +vec_all_lt(vector short a, vector short b) +{ + return __builtin_altivec_vcmpgtsh_p(__CR6_LT, b, a); +} + +static int _ATTRS_o_ai +vec_all_lt(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vcmpgtuh_p(__CR6_LT, b, a); +} + +static int _ATTRS_o_ai +vec_all_lt(vector int a, vector int b) +{ + return __builtin_altivec_vcmpgtsw_p(__CR6_LT, b, a); +} + +static int _ATTRS_o_ai +vec_all_lt(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vcmpgtuw_p(__CR6_LT, b, a); +} + +static int _ATTRS_o_ai +vec_all_lt(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgtfp_p(__CR6_LT, b, a); +} + +/* vec_all_nan */ + +static int __attribute__((__always_inline__)) +vec_all_nan(vector float a) +{ + return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, a, a); +} + +/* vec_all_ne */ + +static int _ATTRS_o_ai +vec_all_ne(vector char a, vector char b) +{ + return __builtin_altivec_vcmpequb_p(__CR6_EQ, a, b); +} + +static int _ATTRS_o_ai +vec_all_ne(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vcmpequb_p(__CR6_EQ, a, b); +} + +static int _ATTRS_o_ai +vec_all_ne(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vcmpequb_p(__CR6_EQ, a, b); +} + +static int _ATTRS_o_ai +vec_all_ne(vector short a, vector short b) +{ + return __builtin_altivec_vcmpequh_p(__CR6_EQ, a, b); +} + +static int _ATTRS_o_ai +vec_all_ne(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vcmpequh_p(__CR6_EQ, a, b); +} + +static int _ATTRS_o_ai +vec_all_ne(vector int a, vector int b) +{ + return __builtin_altivec_vcmpequw_p(__CR6_EQ, a, b); +} + +static int _ATTRS_o_ai +vec_all_ne(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vcmpequw_p(__CR6_EQ, a, b); +} + +static int _ATTRS_o_ai +vec_all_ne(vector float a, vector float b) +{ + return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, a, b); +} + +/* vec_all_nge */ + +static int __attribute__((__always_inline__)) +vec_all_nge(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgefp_p(__CR6_EQ, a, b); +} + +/* vec_all_ngt */ + +static int __attribute__((__always_inline__)) +vec_all_ngt(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, a, b); +} + +/* vec_all_nle */ + +static int __attribute__((__always_inline__)) +vec_all_nle(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgefp_p(__CR6_EQ, b, a); +} + +/* vec_all_nlt */ + +static int __attribute__((__always_inline__)) +vec_all_nlt(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, b, a); +} + +/* vec_all_numeric */ + +static int __attribute__((__always_inline__)) +vec_all_numeric(vector float a) +{ + return __builtin_altivec_vcmpeqfp_p(__CR6_LT, a, a); +} + +/* vec_any_eq */ + +static int _ATTRS_o_ai +vec_any_eq(vector char a, vector char b) +{ + return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_eq(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_eq(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_eq(vector short a, vector short b) +{ + return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_eq(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_eq(vector int a, vector int b) +{ + return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_eq(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_eq(vector float a, vector float b) +{ + return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, a, b); +} + +/* vec_any_ge */ + +static int _ATTRS_o_ai +vec_any_ge(vector char a, vector char b) +{ + return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, b, a); +} + +static int _ATTRS_o_ai +vec_any_ge(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, b, a); +} + +static int _ATTRS_o_ai +vec_any_ge(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, b, a); +} + +static int _ATTRS_o_ai +vec_any_ge(vector short a, vector short b) +{ + return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, b, a); +} + +static int _ATTRS_o_ai +vec_any_ge(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, b, a); +} + +static int _ATTRS_o_ai +vec_any_ge(vector int a, vector int b) +{ + return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, b, a); +} + +static int _ATTRS_o_ai +vec_any_ge(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, b, a); +} + +static int _ATTRS_o_ai +vec_any_ge(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, b, a); +} + +/* vec_any_gt */ + +static int _ATTRS_o_ai +vec_any_gt(vector char a, vector char b) +{ + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_gt(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_gt(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_gt(vector short a, vector short b) +{ + return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_gt(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_gt(vector int a, vector int b) +{ + return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_gt(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_gt(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, a, b); +} + +/* vec_any_le */ + +static int _ATTRS_o_ai +vec_any_le(vector char a, vector char b) +{ + return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_le(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_le(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_le(vector short a, vector short b) +{ + return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_le(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_le(vector int a, vector int b) +{ + return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_le(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_le(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, a, b); +} + +/* vec_any_lt */ + +static int _ATTRS_o_ai +vec_any_lt(vector char a, vector char b) +{ + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, b, a); +} + +static int _ATTRS_o_ai +vec_any_lt(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, b, a); +} + +static int _ATTRS_o_ai +vec_any_lt(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, b, a); +} + +static int _ATTRS_o_ai +vec_any_lt(vector short a, vector short b) +{ + return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, b, a); +} + +static int _ATTRS_o_ai +vec_any_lt(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, b, a); +} + +static int _ATTRS_o_ai +vec_any_lt(vector int a, vector int b) +{ + return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, b, a); +} + +static int _ATTRS_o_ai +vec_any_lt(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, b, a); +} + +static int _ATTRS_o_ai +vec_any_lt(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, b, a); +} + +/* vec_any_nan */ + +static int __attribute__((__always_inline__)) +vec_any_nan(vector float a) +{ + return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, a, a); +} + +/* vec_any_ne */ + +static int _ATTRS_o_ai +vec_any_ne(vector char a, vector char b) +{ + return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_ne(vector signed char a, vector signed char b) +{ + return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_ne(vector unsigned char a, vector unsigned char b) +{ + return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_ne(vector short a, vector short b) +{ + return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_ne(vector unsigned short a, vector unsigned short b) +{ + return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_ne(vector int a, vector int b) +{ + return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_ne(vector unsigned int a, vector unsigned int b) +{ + return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, a, b); +} + +static int _ATTRS_o_ai +vec_any_ne(vector float a, vector float b) +{ + return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, a, b); +} + +/* vec_any_nge */ + +static int __attribute__((__always_inline__)) +vec_any_nge(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, a, b); +} + +/* vec_any_ngt */ + +static int __attribute__((__always_inline__)) +vec_any_ngt(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, a, b); +} + +/* vec_any_nle */ + +static int __attribute__((__always_inline__)) +vec_any_nle(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, b, a); +} + +/* vec_any_nlt */ + +static int __attribute__((__always_inline__)) +vec_any_nlt(vector float a, vector float b) +{ + return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, b, a); +} + +/* vec_any_numeric */ + +static int __attribute__((__always_inline__)) +vec_any_numeric(vector float a) +{ + return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, a, a); +} + +/* vec_any_out */ + +static int __attribute__((__always_inline__)) +vec_any_out(vector float a, vector float b) +{ + return __builtin_altivec_vcmpbfp_p(__CR6_EQ_REV, a, b); +} + +#undef _ATTRS_o_ai + +#endif /* __ALTIVEC_H */ diff --git a/test/CodeGen/builtins-ppc-altivec.c b/test/CodeGen/builtins-ppc-altivec.c new file mode 100644 index 0000000000..32693be714 --- /dev/null +++ b/test/CodeGen/builtins-ppc-altivec.c @@ -0,0 +1,333 @@ +// RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s + +#include "altivec.h" + +int main () +{ + vector char vc = { -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16 }; + vector signed char vsc = { 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16 }; + vector unsigned char vuc = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; + vector short vs = { -1, 2, -3, 4, -5, 6, -7, 8 }; + vector unsigned short vus = { 1, 2, 3, 4, 5, 6, 7, 8 }; + vector int vi = { -1, 2, -3, 4 }; + vector unsigned int vui = { 1, 2, 3, 4 }; + vector float vf = { -1.5, 2.5, -3.5, 4.5 }; + + vector char res_vc; + vector unsigned char res_vuc; + vector short res_vs; + vector unsigned short res_vus; + vector int res_vi; + vector unsigned int res_vui; + vector float res_vf; + + int param_i; + int res_i; + + /* vec_abs */ + vsc = vec_abs(vsc); // CHECK: sub <16 x i8> zeroinitializer + // CHECK: @llvm.ppc.altivec.vmaxsb + + vs = __builtin_vec_abs(vs); // CHECK: sub <8 x i16> zeroinitializer + // CHECK: @llvm.ppc.altivec.vmaxsh + + vi = vec_abs(vi); // CHECK: sub <4 x i32> zeroinitializer + // CHECK: @llvm.ppc.altivec.vmaxsw + + vf = vec_abs(vf); // CHECK: store <4 x i32> + // CHECK: and <4 x i32> + + /* vec_abs */ + vsc = vec_abss(vsc); // CHECK: @llvm.ppc.altivec.vsubsbs + // CHECK: @llvm.ppc.altivec.vmaxsb + + vs = __builtin_vec_abss(vs); // CHECK: @llvm.ppc.altivec.vsubshs + // CHECK: @llvm.ppc.altivec.vmaxsh + + vi = vec_abss(vi); // CHECK: @llvm.ppc.altivec.vsubsws + // CHECK: @llvm.ppc.altivec.vmaxsw + + /* vec_add */ + res_vc = vec_add(vc, vc); // CHECK: add nsw <16 x i8> + res_vuc = vec_vaddubm(vuc, vuc); // CHECK: add <16 x i8> + res_vs = __builtin_altivec_vadduhm(vs, vs); // CHECK: add nsw <8 x i16> + res_vus = vec_vadduhm(vus, vus); // CHECK: add <8 x i16> + res_vi = __builtin_vec_vadduwm(vi, vi); // CHECK: add nsw <4 x i32> + res_vui = vec_vadduwm(vui, vui); // CHECK: add <4 x i32> + res_vf = __builtin_vec_vaddfp(vf, vf); // CHECK: fadd <4 x float> + + /* vec_addc */ + res_vui = vec_vaddcuw(vui, vui); // HECK: @llvm.ppc.altivec.vaddcuw + + /* vec_adds */ + res_vc = vec_adds(vc, vc); // CHECK: @llvm.ppc.altivec.vaddsbs + res_vuc = vec_vaddubs(vuc, vuc); // CHECK: @llvm.ppc.altivec.vaddubs + res_vs = __builtin_vec_vaddshs(vs, vs); // CHECK: @llvm.ppc.altivec.vaddshs + res_vus = vec_vadduhs(vus, vus); // CHECK: @llvm.ppc.altivec.vadduhs + res_vi = __builtin_vec_vaddsws(vi, vi); // CHECK: @llvm.ppc.altivec.vaddsws + res_vui = vec_vadduws(vui, vui); // CHECK: @llvm.ppc.altivec.vadduws + + /* vec_sub */ + res_vc = vec_sub(vsc, vsc); // CHECK: sub nsw <16 x i8> + res_vuc = vec_vsububm(vuc, vuc); // CHECK: sub <16 x i8> + res_vs = __builtin_altivec_vsubuhm(vs, vs); // CHECK: sub nsw <8 x i16> + res_vus = vec_vsubuhm(vus, vus); // CHECK: sub <8 x i16> + res_vi = __builtin_vec_vsubuwm(vi, vi); // CHECK: sub nsw <4 x i32> + res_vui = vec_vsubuwm(vui, vui); // CHECK: sub <4 x i32> + res_vf = __builtin_vec_vsubfp(vf, vf); // CHECK: fsub <4 x float> + + /* vec_subs */ + res_vc = vec_subs(vc, vc); // CHECK: @llvm.ppc.altivec.vsubsbs + res_vuc = vec_vsububs(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsububs + res_vs = __builtin_vec_vsubshs(vs, vs); // CHECK: @llvm.ppc.altivec.vsubshs + res_vus = vec_vsubuhs(vus, vus); // CHECK: @llvm.ppc.altivec.vsubuhs + res_vi = __builtin_vec_vsubsws(vi, vi); // CHECK: @llvm.ppc.altivec.vsubsws + res_vui = vec_vsubuws(vui, vui); // CHECK: @llvm.ppc.altivec.vsubuws + + /* vec_avg */ + res_vc = vec_avg(vsc, vsc); // CHECK: @llvm.ppc.altivec.vavgsb + res_vuc = __builtin_vec_vavgub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vavgub + res_vs = vec_vavgsh(vs, vs); // CHECK: @llvm.ppc.altivec.vavgsh + res_vus = __builtin_vec_vavguh(vus, vus); // CHECK: @llvm.ppc.altivec.vavguh + res_vi = vec_vavgsw(vi, vi); // CHECK: @llvm.ppc.altivec.vavgsw + res_vui = __builtin_vec_vavguw(vui, vui); // CHECK: @llvm.ppc.altivec.vavguw + + /* vec_st */ + param_i = 5; + vec_st(vc, 0, &res_vc); // CHECK: @llvm.ppc.altivec.stvx + __builtin_vec_st(vuc, param_i, &res_vuc); // CHECK: @llvm.ppc.altivec.stvx + vec_stvx(vs, 1, &res_vs); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vus, 1000, &res_vus); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vi, 0, &res_vi); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vui, 0, &res_vui); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vf, 0, &res_vf); // CHECK: @llvm.ppc.altivec.stvx + + /* vec_stl */ + param_i = 10000; + vec_stl(vc, param_i, &res_vc); // CHECK: @llvm.ppc.altivec.stvxl + __builtin_vec_stl(vuc, 1, &res_vuc); // CHECK: @llvm.ppc.altivec.stvxl + vec_stvxl(vs, 0, &res_vs); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vus, 0, &res_vus); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vi, 0, &res_vi); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vui, 0, &res_vui); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vf, 0, &res_vf); // CHECK: @llvm.ppc.altivec.stvxl + + /* vec_ste */ + param_i = 10000; + vec_ste(vc, param_i, &res_vc); // CHECK: @llvm.ppc.altivec.stvebx + vec_stvebx(vuc, 1, &res_vuc); // CHECK: @llvm.ppc.altivec.stvebx + __builtin_vec_stvehx(vs, 0, &res_vs); // CHECK: @llvm.ppc.altivec.stvehx + vec_stvehx(vus, 0, &res_vus); // CHECK: @llvm.ppc.altivec.stvehx + vec_stvewx(vi, 0, &res_vi); // CHECK: @llvm.ppc.altivec.stvewx + __builtin_vec_stvewx(vui, 0, &res_vui); // CHECK: @llvm.ppc.altivec.stvewx + vec_stvewx(vf, 0, &res_vf); // CHECK: @llvm.ppc.altivec.stvewx + + /* vec_cmpb */ + res_vi = vec_vcmpbfp(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpbfp + + /* vec_cmpeq */ + res_vi = vec_cmpeq(vc, vc); // CHECK: @llvm.ppc.altivec.vcmpequb + res_vi = __builtin_vec_cmpeq(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb + res_vi = vec_cmpeq(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh + res_vi = vec_cmpeq(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh + res_vi = vec_cmpeq(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw + res_vi = vec_cmpeq(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw + res_vi = vec_cmpeq(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp + + /* vec_cmpge */ + res_vi = __builtin_vec_cmpge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp + + /* vec_cmpgt */ + res_vi = vec_cmpgt(vc, vc); // CHECK: @llvm.ppc.altivec.vcmpgtsb + res_vi = vec_vcmpgtub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub + res_vi = __builtin_vec_vcmpgtsh(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh + res_vi = vec_cmpgt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh + res_vi = vec_cmpgt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw + res_vi = vec_cmpgt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw + res_vi = vec_cmpgt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp + + /* vec_cmple */ + res_vi = __builtin_vec_cmple(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp + + /* vec_cmplt */ + res_vi = vec_cmplt(vc, vc); // CHECK: @llvm.ppc.altivec.vcmpgtsb + res_vi = __builtin_vec_cmplt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub + res_vi = vec_cmplt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh + res_vi = vec_cmplt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh + res_vi = vec_cmplt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw + res_vi = vec_cmplt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw + res_vi = vec_cmplt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp + + /* vec_max */ + res_vc = vec_max(vc, vc); // CHECK: @llvm.ppc.altivec.vmaxsb + res_vuc = __builtin_vec_vmaxub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vmaxub + res_vs = vec_vmaxsh(vs, vs); // CHECK: @llvm.ppc.altivec.vmaxsh + res_vus = vec_max(vus, vus); // CHECK: @llvm.ppc.altivec.vmaxuh + res_vi = __builtin_vec_vmaxsw(vi, vi); // CHECK: @llvm.ppc.altivec.vmaxsw + res_vui = vec_vmaxuw(vui, vui); // CHECK: @llvm.ppc.altivec.vmaxuw + res_vf = __builtin_vec_max(vf, vf); // CHECK: @llvm.ppc.altivec.vmaxfp + + /* vec_mfvscr */ + vf = vec_mfvscr(); // CHECK: @llvm.ppc.altivec.mfvscr + + /* vec_min */ + res_vc = vec_min(vc, vc); // CHECK: @llvm.ppc.altivec.vminsb + res_vuc = __builtin_vec_vminub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vminub + res_vs = vec_vminsh(vs, vs); // CHECK: @llvm.ppc.altivec.vminsh + res_vus = vec_min(vus, vus); // CHECK: @llvm.ppc.altivec.vminuh + res_vi = __builtin_vec_vminsw(vi, vi); // CHECK: @llvm.ppc.altivec.vminsw + res_vui = vec_vminuw(vui, vui); // CHECK: @llvm.ppc.altivec.vminuw + res_vf = __builtin_vec_min(vf, vf); // CHECK: @llvm.ppc.altivec.vminfp + + /* vec_mtvscr */ + vec_mtvscr(vc); // CHECK: @llvm.ppc.altivec.mtvscr + + /* ------------------------------ predicates -------------------------------------- */ + + res_i = __builtin_vec_vcmpeq_p(__CR6_EQ, vc, vui); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + res_i = __builtin_vec_vcmpge_p(__CR6_EQ, vs, vi); // CHECK: @llvm.ppc.altivec.vcmpgefp.p + res_i = __builtin_vec_vcmpgt_p(__CR6_EQ, vuc, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_all_eq */ + res_i = vec_all_eq(vc, vc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_eq(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_eq(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_eq(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_eq(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_eq(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_eq(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + + /* vec_all_ge */ + res_i = vec_all_ge(vc, vc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_all_ge(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_ge(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_all_ge(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_ge(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_all_ge(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_ge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_all_gt */ + res_i = vec_all_gt(vc, vc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_all_gt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_gt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_all_gt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_gt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_all_gt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_gt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_all_in */ + res_i = vec_all_in(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpbfp.p + + /* vec_all_le */ + res_i = vec_all_le(vc, vc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_all_le(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_le(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_all_le(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_le(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_all_le(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_le(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_all_nan */ + res_i = vec_all_nan(vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + + /* vec_all_ne */ + res_i = vec_all_ne(vc, vc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_ne(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_ne(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_ne(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_ne(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_ne(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_ne(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + + /* vec_all_nge */ + res_i = vec_all_nge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p + + /* vec_all_ngt */ + res_i = vec_all_ngt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_all_nle */ + res_i = vec_all_nle(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p + + /* vec_all_nlt */ + res_i = vec_all_nlt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_all_numeric */ + res_i = vec_all_numeric(vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + + /* vec_any_eq */ + res_i = vec_any_eq(vc, vc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_eq(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_eq(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_eq(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_eq(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_eq(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_eq(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + + /* vec_any_ge */ + res_i = vec_any_ge(vc, vc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_any_ge(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_ge(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_any_ge(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_ge(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_any_ge(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_ge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_any_gt */ + res_i = vec_any_gt(vc, vc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_any_gt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_gt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_any_gt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_gt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_any_gt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_gt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_any_le */ + res_i = vec_any_le(vc, vc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_any_le(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_le(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_any_le(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_le(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_any_le(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_le(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_any_lt */ + res_i = vec_any_lt(vc, vc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_any_lt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_lt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_any_lt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_lt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_any_lt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_lt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_any_nan */ + res_i = vec_any_nan(vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + + /* vec_any_ne */ + res_i = vec_any_ne(vc, vc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_ne(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_ne(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_ne(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_ne(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_ne(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_ne(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + + /* vec_any_nge */ + res_i = vec_any_nge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p + + /* vec_any_ngt */ + res_i = vec_any_ngt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_any_nle */ + res_i = vec_any_nle(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p + + /* vec_any_nlt */ + res_i = vec_any_nlt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_any_numeric */ + res_i = vec_any_numeric(vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + + /* vec_any_out */ + res_i = vec_any_out(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpbfp.p + + return 0; +} diff --git a/test/Parser/altivec.c b/test/Parser/altivec.c index 6c4601abe9..a3e8183f35 100644 --- a/test/Parser/altivec.c +++ b/test/Parser/altivec.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -faltivec -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -faltivec -fsyntax-only -verify %s __vector char vv_c; __vector signed char vv_sc; diff --git a/test/Parser/cxx-altivec.cpp b/test/Parser/cxx-altivec.cpp index 13a270b8e6..61ccecec22 100644 --- a/test/Parser/cxx-altivec.cpp +++ b/test/Parser/cxx-altivec.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -faltivec -fsyntax-only -verify %s - +// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -faltivec -fsyntax-only -verify %s +// XFAIL: * // This is the same as the C version: __vector char vv_c; diff --git a/test/Sema/altivec-init.c b/test/Sema/altivec-init.c index f22c1fc4db..1ace0c96c8 100644 --- a/test/Sema/altivec-init.c +++ b/test/Sema/altivec-init.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -faltivec -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 %s -triple=powerpc-apple-darwin8 -faltivec -verify -pedantic -fsyntax-only typedef int v4 __attribute((vector_size(16))); typedef short v8 __attribute((vector_size(16)));