From: Nemanja Ivanovic Date: Thu, 11 Jun 2015 06:25:36 +0000 (+0000) Subject: Clang support for vector quad bit permute and gather instructions through builtins X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b94be87f57994160549a2b7e3a3f3c06bdf50009;p=clang Clang support for vector quad bit permute and gather instructions through builtins This patch corresponds to review: http://reviews.llvm.org/D10095 This is for just two instructions and related builtins: vbpermq vgbbd git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239506 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/BuiltinsPPC.def b/include/clang/Basic/BuiltinsPPC.def index 57ae63e634..6f3bea887f 100644 --- a/include/clang/Basic/BuiltinsPPC.def +++ b/include/clang/Basic/BuiltinsPPC.def @@ -231,6 +231,9 @@ BUILTIN(__builtin_altivec_vcmpgtsd_p, "iiV2LLiV2LLi", "") BUILTIN(__builtin_altivec_vcmpgtud_p, "iiV2ULLiV2ULLi", "") BUILTIN(__builtin_altivec_vcmpgtfp_p, "iiV4fV4f", "") +BUILTIN(__builtin_altivec_vgbbd, "V16UcV16Uc", "") +BUILTIN(__builtin_altivec_vbpermq, "V2ULLiV16UcV16Uc", "") + // P8 Crypto built-ins. BUILTIN(__builtin_altivec_crypto_vsbox, "V2ULLiV2ULLi", "") BUILTIN(__builtin_altivec_crypto_vpermxor, "V16UcV16UcV16UcV16Uc", "") diff --git a/lib/Headers/altivec.h b/lib/Headers/altivec.h index 7427ed53fc..28df890572 100644 --- a/lib/Headers/altivec.h +++ b/lib/Headers/altivec.h @@ -12012,6 +12012,29 @@ static vector unsigned long long __ATTRS_o_ai __builtin_crypto_vpmsumb( vector unsigned long long __a, vector unsigned long long __b) { return __builtin_altivec_crypto_vpmsumd(__a, __b); } + +static vector signed char __ATTRS_o_ai vec_vgbbd (vector signed char __a) +{ + return __builtin_altivec_vgbbd((vector unsigned char) __a); +} + +static vector unsigned char __ATTRS_o_ai vec_vgbbd (vector unsigned char __a) +{ + return __builtin_altivec_vgbbd(__a); +} + +static vector long long __ATTRS_o_ai +vec_vbpermq (vector signed char __a, vector signed char __b) +{ + return __builtin_altivec_vbpermq((vector unsigned char) __a, + (vector unsigned char) __b); +} + +static vector long long __ATTRS_o_ai +vec_vbpermq (vector unsigned char __a, vector unsigned char __b) +{ + return __builtin_altivec_vbpermq(__a, __b); +} #endif #undef __ATTRS_o_ai diff --git a/test/CodeGen/builtins-ppc-p8vector.c b/test/CodeGen/builtins-ppc-p8vector.c index f74bbad9da..ac4079016a 100644 --- a/test/CodeGen/builtins-ppc-p8vector.c +++ b/test/CodeGen/builtins-ppc-p8vector.c @@ -3,6 +3,8 @@ // RUN: %clang_cc1 -faltivec -target-feature +power8-vector -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-LE // RUN: not %clang_cc1 -faltivec -triple powerpc64-unknown-unknown -emit-llvm %s -o - 2>&1 | FileCheck %s -check-prefix=CHECK-PPC +vector signed char vsc = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 }; +vector unsigned char vuc = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 }; vector int vi = { -1, 2, -3, 4 }; vector unsigned int vui = { 1, 2, 3, 4 }; vector bool int vbi = {0, -1, -1, 0}; @@ -11,6 +13,8 @@ vector signed long long vsll = { 1, 2 }; vector unsigned long long vull = { 1, 2 }; int res_i; +vector signed char res_vsc; +vector unsigned char res_vuc; vector int res_vi; vector unsigned int res_vui; vector bool int res_vbi; @@ -737,4 +741,23 @@ void test1() { // CHECK: @llvm.ppc.altivec.vminud // CHECK-LE: @llvm.ppc.altivec.vminud + /* vec_vbpermq */ + res_vsll = vec_vbpermq(vsc, vsc); +// CHECK: llvm.ppc.altivec.vbpermq +// CHECK-LE: llvm.ppc.altivec.vbpermq + + res_vull = vec_vbpermq(vuc, vuc); +// CHECK: llvm.ppc.altivec.vbpermq +// CHECK-LE: llvm.ppc.altivec.vbpermq +// CHECK-PPC: warning: implicit declaration of function 'vec_vbpermq' + + /* vec_vgbbd */ + res_vsc = vec_vgbbd(vsc); +// CHECK: llvm.ppc.altivec.vgbbd +// CHECK-LE: llvm.ppc.altivec.vgbbd + + res_vuc = vec_vgbbd(vuc); +// CHECK: llvm.ppc.altivec.vgbbd +// CHECK-LE: llvm.ppc.altivec.vgbbd +// CHECK-PPC: warning: implicit declaration of function 'vec_vgbbd' }