diff options
| author | Nemanja Ivanovic <nemanja.i.ibm@gmail.com> | 2015-03-04 21:48:22 +0000 |
|---|---|---|
| committer | Nemanja Ivanovic <nemanja.i.ibm@gmail.com> | 2015-03-04 21:48:22 +0000 |
| commit | 55e757db4a53ff13195e97b271fff691a43b1ddc (patch) | |
| tree | c64b4d56e226c7db220ac4da81c12caff6767609 /clang/test/CodeGen | |
| parent | 77a4da19914c84e07a82dc22bbbf28540f90ca31 (diff) | |
| download | bcm5719-llvm-55e757db4a53ff13195e97b271fff691a43b1ddc.tar.gz bcm5719-llvm-55e757db4a53ff13195e97b271fff691a43b1ddc.zip | |
Add Clang support for PPC cryptography builtins
Review: http://reviews.llvm.org/D7951
llvm-svn: 231291
Diffstat (limited to 'clang/test/CodeGen')
| -rw-r--r-- | clang/test/CodeGen/builtins-ppc-crypto-diag.c | 47 | ||||
| -rw-r--r-- | clang/test/CodeGen/builtins-ppc-crypto-disabled.c | 53 | ||||
| -rw-r--r-- | clang/test/CodeGen/builtins-ppc-crypto.c | 303 |
3 files changed, 403 insertions, 0 deletions
diff --git a/clang/test/CodeGen/builtins-ppc-crypto-diag.c b/clang/test/CodeGen/builtins-ppc-crypto-diag.c new file mode 100644 index 00000000000..4408ab48a11 --- /dev/null +++ b/clang/test/CodeGen/builtins-ppc-crypto-diag.c @@ -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). diff --git a/clang/test/CodeGen/builtins-ppc-crypto-disabled.c b/clang/test/CodeGen/builtins-ppc-crypto-disabled.c new file mode 100644 index 00000000000..e6a8a9337aa --- /dev/null +++ b/clang/test/CodeGen/builtins-ppc-crypto-disabled.c @@ -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' diff --git a/clang/test/CodeGen/builtins-ppc-crypto.c b/clang/test/CodeGen/builtins-ppc-crypto.c new file mode 100644 index 00000000000..0ade413cb6a --- /dev/null +++ b/clang/test/CodeGen/builtins-ppc-crypto.c @@ -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 +} + |

