Add Clang support for PPC cryptography builtins

Review: http://reviews.llvm.org/D7951

llvm-svn: 231291
This commit is contained in:
Nemanja Ivanovic 2015-03-04 21:48:22 +00:00
parent 77a4da1991
commit 55e757db4a
9 changed files with 602 additions and 1 deletions

View File

@ -204,6 +204,20 @@ BUILTIN(__builtin_altivec_vcmpgtsw_p, "iiV4SiV4Si", "")
BUILTIN(__builtin_altivec_vcmpgtuw_p, "iiV4UiV4Ui", "")
BUILTIN(__builtin_altivec_vcmpgtfp_p, "iiV4fV4f", "")
// P8 Crypto built-ins.
BUILTIN(__builtin_altivec_crypto_vsbox, "V2ULLiV2ULLi", "")
BUILTIN(__builtin_altivec_crypto_vpermxor, "V16UcV16UcV16UcV16Uc", "")
BUILTIN(__builtin_altivec_crypto_vshasigmaw, "V4UiV4UiIiIi", "")
BUILTIN(__builtin_altivec_crypto_vshasigmad, "V2ULLiV2ULLiIiIi", "")
BUILTIN(__builtin_altivec_crypto_vcipher, "V2ULLiV2ULLiV2ULLi", "")
BUILTIN(__builtin_altivec_crypto_vcipherlast, "V2ULLiV2ULLiV2ULLi", "")
BUILTIN(__builtin_altivec_crypto_vncipher, "V2ULLiV2ULLiV2ULLi", "")
BUILTIN(__builtin_altivec_crypto_vncipherlast, "V2ULLiV2ULLiV2ULLi", "")
BUILTIN(__builtin_altivec_crypto_vpmsumb, "V16UcV16UcV16Uc", "")
BUILTIN(__builtin_altivec_crypto_vpmsumh, "V8UsV8UsV8Us", "")
BUILTIN(__builtin_altivec_crypto_vpmsumw, "V4UiV4UiV4Ui", "")
BUILTIN(__builtin_altivec_crypto_vpmsumd, "V2ULLiV2ULLiV2ULLi", "")
// VSX built-ins.
BUILTIN(__builtin_vsx_lxvd2x, "V2divC*", "")

View File

@ -1250,6 +1250,10 @@ def mpower8_vector : Flag<["-"], "mpower8-vector">,
Group<m_ppc_Features_Group>;
def mno_power8_vector : Flag<["-"], "mno-power8-vector">,
Group<m_ppc_Features_Group>;
def mpower8_crypto : Flag<["-"], "mcrypto">,
Group<m_ppc_Features_Group>;
def mnopower8_crypto : Flag<["-"], "mno-crypto">,
Group<m_ppc_Features_Group>;
def mfprnd : Flag<["-"], "mfprnd">, Group<m_ppc_Features_Group>;
def mno_fprnd : Flag<["-"], "mno-fprnd">, Group<m_ppc_Features_Group>;
def mcmpb : Flag<["-"], "mcmpb">, Group<m_ppc_Features_Group>;

View File

@ -719,13 +719,15 @@ class PPCTargetInfo : public TargetInfo {
// Target cpu features.
bool HasVSX;
bool HasP8Vector;
bool HasP8Crypto;
protected:
std::string ABI;
public:
PPCTargetInfo(const llvm::Triple &Triple)
: TargetInfo(Triple), HasVSX(false), HasP8Vector(false) {
: TargetInfo(Triple), HasVSX(false), HasP8Vector(false),
HasP8Crypto(false) {
BigEndian = (Triple.getArch() != llvm::Triple::ppc64le);
LongDoubleWidth = LongDoubleAlign = 128;
LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble;
@ -986,6 +988,11 @@ bool PPCTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
continue;
}
if (Feature == "crypto") {
HasP8Crypto = true;
continue;
}
// TODO: Finish this list and add an assert that we've handled them
// all.
}
@ -1138,6 +1145,8 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__VSX__");
if (HasP8Vector)
Builder.defineMacro("__POWER8_VECTOR__");
if (HasP8Crypto)
Builder.defineMacro("__CRYPTO__");
// FIXME: The following are not yet generated here by Clang, but are
// generated by GCC:
@ -1176,6 +1185,14 @@ void PPCTargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const {
.Default(false);
Features["qpx"] = (CPU == "a2q");
Features["crypto"] = llvm::StringSwitch<bool>(CPU)
.Case("ppc64le", true)
.Case("pwr8", true)
.Default(false);
Features["power8-vector"] = llvm::StringSwitch<bool>(CPU)
.Case("ppc64le", true)
.Case("pwr8", true)
.Default(false);
}
bool PPCTargetInfo::hasFeature(StringRef Feature) const {
@ -1183,6 +1200,7 @@ bool PPCTargetInfo::hasFeature(StringRef Feature) const {
.Case("powerpc", true)
.Case("vsx", HasVSX)
.Case("power8-vector", HasP8Vector)
.Case("crypto", HasP8Crypto)
.Default(false);
}

View File

@ -6349,6 +6349,35 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
llvm::Function *F = CGM.getIntrinsic(ID);
return Builder.CreateCall(F, Ops, "");
}
// P8 Crypto builtins
case PPC::BI__builtin_altivec_crypto_vshasigmaw:
case PPC::BI__builtin_altivec_crypto_vshasigmad:
{
ConstantInt *CI1 = dyn_cast<ConstantInt>(Ops[1]);
ConstantInt *CI2 = dyn_cast<ConstantInt>(Ops[2]);
assert(CI1 && CI2);
if (CI1->getZExtValue() > 1) {
CGM.Error(E->getArg(1)->getExprLoc(),
"argument out of range (should be 0-1).");
return llvm::UndefValue::get(Ops[0]->getType());
}
if (CI2->getZExtValue() > 15) {
CGM.Error(E->getArg(2)->getExprLoc(),
"argument out of range (should be 0-15).");
return llvm::UndefValue::get(Ops[0]->getType());
}
switch (BuiltinID) {
default: llvm_unreachable("Unsupported sigma intrinsic!");
case PPC::BI__builtin_altivec_crypto_vshasigmaw:
ID = Intrinsic::ppc_altivec_crypto_vshasigmaw;
break;
case PPC::BI__builtin_altivec_crypto_vshasigmad:
ID = Intrinsic::ppc_altivec_crypto_vshasigmad;
break;
}
llvm::Function *F = CGM.getIntrinsic(ID);
return Builder.CreateCall(F, Ops, "");
}
}
}

View File

@ -12661,6 +12661,133 @@ vec_any_out(vector float __a, vector float __b)
return __builtin_altivec_vcmpbfp_p(__CR6_EQ_REV, __a, __b);
}
/* Power 8 Crypto functions
Note: We diverge from the current GCC implementation with regard
to cryptography and related functions as follows:
- Only the SHA and AES instructions and builtins are disabled by -mno-crypto
- The remaining ones are only available on Power8 and up so
require -mpower8-vector
The justification for this is that export requirements require that
Category:Vector.Crypto is optional (i.e. compliant hardware may not provide
support). As a result, we need to be able to turn off support for those.
The remaining ones (currently controlled by -mcrypto for GCC) still
need to be provided on compliant hardware even if Vector.Crypto is not
provided.
FIXME: the naming convention for the builtins will be adjusted due
to the inconsistency (__builtin_crypto_ prefix on builtins that cannot be
removed with -mno-crypto). This is under development.
*/
#ifdef __CRYPTO__
static vector unsigned long long __attribute__((__always_inline__))
__builtin_crypto_vsbox (vector unsigned long long __a)
{
return __builtin_altivec_crypto_vsbox(__a);
}
static vector unsigned long long __attribute__((__always_inline__))
__builtin_crypto_vcipher (vector unsigned long long __a,
vector unsigned long long __b)
{
return __builtin_altivec_crypto_vcipher(__a, __b);
}
static vector unsigned long long __attribute__((__always_inline__))
__builtin_crypto_vcipherlast (vector unsigned long long __a,
vector unsigned long long __b)
{
return __builtin_altivec_crypto_vcipherlast(__a, __b);
}
static vector unsigned long long __attribute__((__always_inline__))
__builtin_crypto_vncipher (vector unsigned long long __a,
vector unsigned long long __b)
{
return __builtin_altivec_crypto_vncipher(__a, __b);
}
static vector unsigned long long __attribute__((__always_inline__))
__builtin_crypto_vncipherlast (vector unsigned long long __a,
vector unsigned long long __b)
{
return __builtin_altivec_crypto_vncipherlast(__a, __b);
}
#define __builtin_crypto_vshasigmad __builtin_altivec_crypto_vshasigmad
#define __builtin_crypto_vshasigmaw __builtin_altivec_crypto_vshasigmaw
#endif
#ifdef __POWER8_VECTOR__
static vector unsigned char __ATTRS_o_ai
__builtin_crypto_vpermxor (vector unsigned char __a,
vector unsigned char __b,
vector unsigned char __c)
{
return __builtin_altivec_crypto_vpermxor(__a, __b, __c);
}
static vector unsigned short __ATTRS_o_ai
__builtin_crypto_vpermxor (vector unsigned short __a,
vector unsigned short __b,
vector unsigned short __c)
{
return (vector unsigned short)
__builtin_altivec_crypto_vpermxor((vector unsigned char) __a,
(vector unsigned char) __b,
(vector unsigned char) __c);
}
static vector unsigned int __ATTRS_o_ai
__builtin_crypto_vpermxor (vector unsigned int __a,
vector unsigned int __b,
vector unsigned int __c)
{
return (vector unsigned int)
__builtin_altivec_crypto_vpermxor((vector unsigned char) __a,
(vector unsigned char) __b,
(vector unsigned char) __c);
}
static vector unsigned long long __ATTRS_o_ai
__builtin_crypto_vpermxor (vector unsigned long long __a,
vector unsigned long long __b,
vector unsigned long long __c)
{
return (vector unsigned long long)
__builtin_altivec_crypto_vpermxor((vector unsigned char) __a,
(vector unsigned char) __b,
(vector unsigned char) __c);
}
static vector unsigned char __ATTRS_o_ai
__builtin_crypto_vpmsumb (vector unsigned char __a,
vector unsigned char __b)
{
return __builtin_altivec_crypto_vpmsumb(__a, __b);
}
static vector unsigned short __ATTRS_o_ai
__builtin_crypto_vpmsumb (vector unsigned short __a,
vector unsigned short __b)
{
return __builtin_altivec_crypto_vpmsumh(__a, __b);
}
static vector unsigned int __ATTRS_o_ai
__builtin_crypto_vpmsumb (vector unsigned int __a,
vector unsigned int __b)
{
return __builtin_altivec_crypto_vpmsumw(__a, __b);
}
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);
}
#endif
#undef __ATTRS_o_ai
#endif /* __ALTIVEC_H */

View File

@ -0,0 +1,47 @@
// REQUIRES: powerpc-registered-target
// RUN: not %clang_cc1 -faltivec -triple powerpc64le-unknown-unknown -D_T1LW -target-feature +crypto -emit-llvm %s -o - 2>&1 | FileCheck %s -check-prefix=CHECK-T1
// RUN: not %clang_cc1 -faltivec -triple powerpc64le-unknown-unknown -D_T1MW -target-feature +crypto -emit-llvm %s -o - 2>&1 | FileCheck %s -check-prefix=CHECK-T1
// RUN: not %clang_cc1 -faltivec -triple powerpc64le-unknown-unknown -D_T2LW -target-feature +crypto -emit-llvm %s -o - 2>&1 | FileCheck %s -check-prefix=CHECK-T2
// RUN: not %clang_cc1 -faltivec -triple powerpc64le-unknown-unknown -D_T2MW -target-feature +crypto -emit-llvm %s -o - 2>&1 | FileCheck %s -check-prefix=CHECK-T2
// RUN: not %clang_cc1 -faltivec -triple powerpc64le-unknown-unknown -D_T1LD -target-feature +crypto -emit-llvm %s -o - 2>&1 | FileCheck %s -check-prefix=CHECK-T1
// RUN: not %clang_cc1 -faltivec -triple powerpc64le-unknown-unknown -D_T1MD -target-feature +crypto -emit-llvm %s -o - 2>&1 | FileCheck %s -check-prefix=CHECK-T1
// RUN: not %clang_cc1 -faltivec -triple powerpc64le-unknown-unknown -D_T2LD -target-feature +crypto -emit-llvm %s -o - 2>&1 | FileCheck %s -check-prefix=CHECK-T2
// RUN: not %clang_cc1 -faltivec -triple powerpc64le-unknown-unknown -D_T2MD -target-feature +crypto -emit-llvm %s -o - 2>&1 | FileCheck %s -check-prefix=CHECK-T2
#include <altivec.h>
#define W_INIT { 0x01020304, 0x05060708, \
0x090A0B0C, 0x0D0E0F10 };
#define D_INIT { 0x0102030405060708, \
0x090A0B0C0D0E0F10 };
vector unsigned int test_vshasigmaw_or(void)
{
vector unsigned int a = W_INIT
#ifdef _T1LW // Arg1 too large
vector unsigned int b = __builtin_crypto_vshasigmaw(a, 2, 15);
#elif defined(_T1MW) // Arg1 negative
vector unsigned int c = __builtin_crypto_vshasigmaw(a, -1, 15);
#elif defined(_T2LW) // Arg2 too large
vector unsigned int d = __builtin_crypto_vshasigmaw(a, 0, 85);
#elif defined(_T2MW) // Arg1 negative
vector unsigned int e = __builtin_crypto_vshasigmaw(a, 1, -15);
#endif
return __builtin_crypto_vshasigmaw(a, 1, 15);
}
vector unsigned long long test_vshasigmad_or(void)
{
vector unsigned long long a = D_INIT
#ifdef _T1LD // Arg1 too large
vector unsigned long long b = __builtin_crypto_vshasigmad(a, 2, 15);
#elif defined(_T1MD) // Arg1 negative
vector unsigned long long c = __builtin_crypto_vshasigmad(a, -1, 15);
#elif defined(_T2LD) // Arg2 too large
vector unsigned long long d = __builtin_crypto_vshasigmad(a, 0, 85);
#elif defined(_T2MD) // Arg1 negative
vector unsigned long long e = __builtin_crypto_vshasigmad(a, 1, -15);
#endif
return __builtin_crypto_vshasigmad(a, 0, 15);
}
// CHECK-T1: error: argument out of range (should be 0-1).
// CHECK-T2: error: argument out of range (should be 0-15).

View File

@ -0,0 +1,53 @@
// REQUIRES: powerpc-registered-target
// RUN: not %clang_cc1 -faltivec -triple powerpc64le-unknown-unknown \
// RUN: -target-cpu pwr8 -target-feature -crypto -emit-llvm %s -o - 2>&1 \
// RUN: | FileCheck %s
// RUN: not %clang_cc1 -faltivec -triple powerpc64-unknown-unknown \
// RUN: -target-cpu pwr8 -target-feature -crypto -emit-llvm %s -o - 2>&1 \
// RUN: | FileCheck %s
// RUN: not %clang_cc1 -faltivec -triple powerpc64-unknown-unknown \
// RUN: -target-cpu pwr8 -target-feature -power8-vector \
// RUN: -target-feature -crypto -emit-llvm %s -o - 2>&1 \
// RUN: | FileCheck %s -check-prefix=CHECK-P8V
#include <altivec.h>
#define W_INIT1 { 0x01020304, 0x05060708, \
0x090A0B0C, 0x0D0E0F10 };
#define D_INIT1 { 0x0102030405060708, \
0x090A0B0C0D0E0F10 };
#define D_INIT2 { 0x7172737475767778, \
0x797A7B7C7D7E7F70 };
// Test cases for the builtins the way they are exposed to
// users through altivec.h
void call_crypto_intrinsics(void)
{
vector unsigned int aw = W_INIT1
vector unsigned long long ad = D_INIT1
vector unsigned long long bd = D_INIT2
vector unsigned long long cd = D_INIT2
vector unsigned long long r1 = __builtin_crypto_vsbox(ad);
vector unsigned long long r2 = __builtin_crypto_vcipher(ad, bd);
vector unsigned long long r3 = __builtin_crypto_vcipherlast(ad, bd);
vector unsigned long long r4 = __builtin_crypto_vncipher(ad, bd);
vector unsigned long long r5 = __builtin_crypto_vncipherlast(ad, bd);
vector unsigned int r6 = __builtin_crypto_vshasigmaw(aw, 1, 15);
vector unsigned long long r7 = __builtin_crypto_vshasigmad(ad, 0, 15);
// The ones that do not require -mcrypto, but require -mpower8-vector
vector unsigned long long r8 = __builtin_crypto_vpmsumb(ad, bd);
vector unsigned long long r9 = __builtin_crypto_vpermxor(ad, bd, cd);
}
// CHECK: use of unknown builtin '__builtin_crypto_vsbox'
// CHECK: use of unknown builtin '__builtin_crypto_vcipher'
// CHECK: use of unknown builtin '__builtin_crypto_vcipherlast'
// CHECK: use of unknown builtin '__builtin_crypto_vncipher'
// CHECK: use of unknown builtin '__builtin_crypto_vncipherlast'
// CHECK: use of unknown builtin '__builtin_crypto_vshasigmaw'
// CHECK: use of unknown builtin '__builtin_crypto_vshasigmad'
// CHECK-P8V: use of unknown builtin '__builtin_crypto_vpmsumb'
// CHECK-P8V: use of unknown builtin '__builtin_crypto_vpermxor'

View File

@ -0,0 +1,303 @@
// REQUIRES: powerpc-registered-target
// RUN: %clang_cc1 -faltivec -triple powerpc64le-unknown-unknown \
// RUN: -target-feature +crypto -target-feature +power8-vector \
// RUN: -emit-llvm %s -o - | FileCheck %s
// RUN: %clang_cc1 -faltivec -triple powerpc64-unknown-unknown \
// RUN: -target-feature +crypto -target-feature +power8-vector \
// RUN: -emit-llvm %s -o - | FileCheck %s
// RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown \
// RUN: -target-feature +crypto -target-feature +power8-vector \
// RUN: -emit-llvm %s -o - | FileCheck %s
#include <altivec.h>
#define B_INIT1 { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, \
0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10 };
#define B_INIT2 { 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, \
0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x70 };
#define H_INIT1 { 0x0102, 0x0304, 0x0506, 0x0708, \
0x090A, 0x0B0C, 0x0D0E, 0x0F10 };
#define H_INIT2 { 0x7172, 0x7374, 0x7576, 0x7778, \
0x797A, 0x7B7C, 0x7D7E, 0x7F70 };
#define W_INIT1 { 0x01020304, 0x05060708, \
0x090A0B0C, 0x0D0E0F10 };
#define W_INIT2 { 0x71727374, 0x75767778, \
0x797A7B7C, 0x7D7E7F70 };
#define D_INIT1 { 0x0102030405060708, \
0x090A0B0C0D0E0F10 };
#define D_INIT2 { 0x7172737475767778, \
0x797A7B7C7D7E7F70 };
// CHECK-LABEL: define <16 x i8> @test_vpmsumb
vector unsigned char test_vpmsumb(void)
{
vector unsigned char a = B_INIT1
vector unsigned char b = B_INIT2
return __builtin_altivec_crypto_vpmsumb(a, b);
// CHECK @llvm.ppc.altivec.crypto.vpmsumb
}
// CHECK-LABEL: define <8 x i16> @test_vpmsumh
vector unsigned short test_vpmsumh(void)
{
vector unsigned short a = H_INIT1
vector unsigned short b = H_INIT2
return __builtin_altivec_crypto_vpmsumh(a, b);
// CHECK @llvm.ppc.altivec.crypto.vpmsumh
}
// CHECK-LABEL: define <4 x i32> @test_vpmsumw
vector unsigned int test_vpmsumw(void)
{
vector unsigned int a = W_INIT1
vector unsigned int b = W_INIT2
return __builtin_altivec_crypto_vpmsumw(a, b);
// CHECK @llvm.ppc.altivec.crypto.vpmsumw
}
// CHECK-LABEL: define <2 x i64> @test_vpmsumd
vector unsigned long long test_vpmsumd(void)
{
vector unsigned long long a = D_INIT1
vector unsigned long long b = D_INIT2
return __builtin_altivec_crypto_vpmsumd(a, b);
// CHECK @llvm.ppc.altivec.crypto.vpmsumd
}
// CHECK-LABEL: define <2 x i64> @test_vsbox
vector unsigned long long test_vsbox(void)
{
vector unsigned long long a = D_INIT1
return __builtin_altivec_crypto_vsbox(a);
// CHECK: @llvm.ppc.altivec.crypto.vsbox
}
// CHECK-LABEL: define <16 x i8> @test_vpermxorb
vector unsigned char test_vpermxorb(void)
{
vector unsigned char a = B_INIT1
vector unsigned char b = B_INIT2
vector unsigned char c = B_INIT2
return __builtin_altivec_crypto_vpermxor(a, b, c);
// CHECK: @llvm.ppc.altivec.crypto.vpermxor
}
// CHECK-LABEL: define <8 x i16> @test_vpermxorh
vector unsigned short test_vpermxorh(void)
{
vector unsigned short a = H_INIT1
vector unsigned short b = H_INIT2
vector unsigned short c = H_INIT2
return __builtin_altivec_crypto_vpermxor(a, b, c);
// CHECK: @llvm.ppc.altivec.crypto.vpermxor
}
// CHECK-LABEL: define <4 x i32> @test_vpermxorw
vector unsigned int test_vpermxorw(void)
{
vector unsigned int a = W_INIT1
vector unsigned int b = W_INIT2
vector unsigned int c = W_INIT2
return __builtin_altivec_crypto_vpermxor(a, b, c);
// CHECK: @llvm.ppc.altivec.crypto.vpermxor
}
// CHECK-LABEL: define <2 x i64> @test_vpermxord
vector unsigned long long test_vpermxord(void)
{
vector unsigned long long a = D_INIT1
vector unsigned long long b = D_INIT2
vector unsigned long long c = D_INIT2
return __builtin_altivec_crypto_vpermxor(a, b, c);
// CHECK: @llvm.ppc.altivec.crypto.vpermxor
}
// CHECK-LABEL: define <2 x i64> @test_vcipher
vector unsigned long long test_vcipher(void)
{
vector unsigned long long a = D_INIT1
vector unsigned long long b = D_INIT2
return __builtin_altivec_crypto_vcipher(a, b);
// CHECK: @llvm.ppc.altivec.crypto.vcipher
}
// CHECK-LABEL: define <2 x i64> @test_vcipherlast
vector unsigned long long test_vcipherlast(void)
{
vector unsigned long long a = D_INIT1
vector unsigned long long b = D_INIT2
return __builtin_altivec_crypto_vcipherlast(a, b);
// CHECK: @llvm.ppc.altivec.crypto.vcipherlast
}
// CHECK: @llvm.ppc.altivec.crypto.vncipher
vector unsigned long long test_vncipher(void)
{
vector unsigned long long a = D_INIT1
vector unsigned long long b = D_INIT2
return __builtin_altivec_crypto_vncipher(a, b);
// CHECK: @llvm.ppc.altivec.crypto.vncipher
}
// CHECK-LABEL: define <2 x i64> @test_vncipherlast
vector unsigned long long test_vncipherlast(void)
{
vector unsigned long long a = D_INIT1
vector unsigned long long b = D_INIT2
return __builtin_altivec_crypto_vncipherlast(a, b);
// CHECK: @llvm.ppc.altivec.crypto.vncipherlast
}
// CHECK-LABEL: define <4 x i32> @test_vshasigmaw
vector unsigned int test_vshasigmaw(void)
{
vector unsigned int a = W_INIT1
return __builtin_altivec_crypto_vshasigmaw(a, 1, 15);
// CHECK: @llvm.ppc.altivec.crypto.vshasigmaw
}
// CHECK-LABEL: define <2 x i64> @test_vshasigmad
vector unsigned long long test_vshasigmad(void)
{
vector unsigned long long a = D_INIT2
return __builtin_altivec_crypto_vshasigmad(a, 1, 15);
// CHECK: @llvm.ppc.altivec.crypto.vshasigmad
}
// Test cases for the builtins the way they are exposed to
// users through altivec.h
// CHECK-LABEL: define <16 x i8> @test_vpmsumb_e
vector unsigned char test_vpmsumb_e(void)
{
vector unsigned char a = B_INIT1
vector unsigned char b = B_INIT2
return __builtin_crypto_vpmsumb(a, b);
// CHECK @llvm.ppc.altivec.crypto.vpmsumb
}
// CHECK-LABEL: define <8 x i16> @test_vpmsumh_e
vector unsigned short test_vpmsumh_e(void)
{
vector unsigned short a = H_INIT1
vector unsigned short b = H_INIT2
return __builtin_crypto_vpmsumb(a, b);
// CHECK @llvm.ppc.altivec.crypto.vpmsumh
}
// CHECK-LABEL: define <4 x i32> @test_vpmsumw_e
vector unsigned int test_vpmsumw_e(void)
{
vector unsigned int a = W_INIT1
vector unsigned int b = W_INIT2
return __builtin_crypto_vpmsumb(a, b);
// CHECK @llvm.ppc.altivec.crypto.vpmsumw
}
// CHECK-LABEL: define <2 x i64> @test_vpmsumd_e
vector unsigned long long test_vpmsumd_e(void)
{
vector unsigned long long a = D_INIT1
vector unsigned long long b = D_INIT2
return __builtin_crypto_vpmsumb(a, b);
// CHECK @llvm.ppc.altivec.crypto.vpmsumd
}
// CHECK-LABEL: define <2 x i64> @test_vsbox_e
vector unsigned long long test_vsbox_e(void)
{
vector unsigned long long a = D_INIT1
return __builtin_crypto_vsbox(a);
// CHECK: @llvm.ppc.altivec.crypto.vsbox
}
// CHECK-LABEL: define <16 x i8> @test_vpermxorb_e
vector unsigned char test_vpermxorb_e(void)
{
vector unsigned char a = B_INIT1
vector unsigned char b = B_INIT2
vector unsigned char c = B_INIT2
return __builtin_crypto_vpermxor(a, b, c);
// CHECK: @llvm.ppc.altivec.crypto.vpermxor
}
// CHECK-LABEL: define <8 x i16> @test_vpermxorh_e
vector unsigned short test_vpermxorh_e(void)
{
vector unsigned short a = H_INIT1
vector unsigned short b = H_INIT2
vector unsigned short c = H_INIT2
return __builtin_crypto_vpermxor(a, b, c);
}
// CHECK-LABEL: define <4 x i32> @test_vpermxorw_e
vector unsigned int test_vpermxorw_e(void)
{
vector unsigned int a = W_INIT1
vector unsigned int b = W_INIT2
vector unsigned int c = W_INIT2
return __builtin_crypto_vpermxor(a, b, c);
// CHECK: @llvm.ppc.altivec.crypto.vpermxor
}
// CHECK-LABEL: define <2 x i64> @test_vpermxord_e
vector unsigned long long test_vpermxord_e(void)
{
vector unsigned long long a = D_INIT1
vector unsigned long long b = D_INIT2
vector unsigned long long c = D_INIT2
return __builtin_crypto_vpermxor(a, b, c);
// CHECK: @llvm.ppc.altivec.crypto.vpermxor
}
// CHECK-LABEL: define <2 x i64> @test_vcipher_e
vector unsigned long long test_vcipher_e(void)
{
vector unsigned long long a = D_INIT1
vector unsigned long long b = D_INIT2
return __builtin_crypto_vcipher(a, b);
// CHECK: @llvm.ppc.altivec.crypto.vcipher
}
// CHECK-LABEL: define <2 x i64> @test_vcipherlast_e
vector unsigned long long test_vcipherlast_e(void)
{
vector unsigned long long a = D_INIT1
vector unsigned long long b = D_INIT2
return __builtin_crypto_vcipherlast(a, b);
// CHECK: @llvm.ppc.altivec.crypto.vcipherlast
}
// CHECK-LABEL: define <2 x i64> @test_vncipher_e
vector unsigned long long test_vncipher_e(void)
{
vector unsigned long long a = D_INIT1
vector unsigned long long b = D_INIT2
return __builtin_crypto_vncipher(a, b);
// CHECK: @llvm.ppc.altivec.crypto.vncipher
}
// CHECK-LABEL: define <2 x i64> @test_vncipherlast_e
vector unsigned long long test_vncipherlast_e(void)
{
vector unsigned long long a = D_INIT1
vector unsigned long long b = D_INIT2
return __builtin_crypto_vncipherlast(a, b);
// CHECK: @llvm.ppc.altivec.crypto.vncipherlast
}
// CHECK-LABEL: define <4 x i32> @test_vshasigmaw_e
vector unsigned int test_vshasigmaw_e(void)
{
vector unsigned int a = W_INIT1
return __builtin_crypto_vshasigmaw(a, 1, 15);
// CHECK: @llvm.ppc.altivec.crypto.vshasigmaw
}
// CHECK-LABEL: define <2 x i64> @test_vshasigmad_e
vector unsigned long long test_vshasigmad_e(void)
{
vector unsigned long long a = D_INIT2
return __builtin_crypto_vshasigmad(a, 0, 15);
// CHECK: @llvm.ppc.altivec.crypto.vshasigmad
}

View File

@ -1669,3 +1669,9 @@
//
// CHECK_PPC_POWER8_VECTOR_M64: #define __POWER8_VECTOR__
//
// RUN: %clang -mcrypto -E -dM %s -o - 2>&1 \
// RUN: -target powerpc64-unknown-linux \
// RUN: | FileCheck %s -check-prefix=CHECK_PPC_CRYPTO_M64
//
// CHECK_PPC_CRYPTO_M64: #define __CRYPTO__
//