| 1 | // REQUIRES: powerpc-registered-target |
| 2 | // RUN: not %clang_cc1 -target-feature +altivec -triple powerpc64le-unknown-unknown \ |
| 3 | // RUN: -target-cpu pwr8 -target-feature -crypto -emit-llvm %s -o - 2>&1 \ |
| 4 | // RUN: | FileCheck %s |
| 5 | |
| 6 | // RUN: not %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown \ |
| 7 | // RUN: -target-cpu pwr8 -target-feature -crypto -emit-llvm %s -o - 2>&1 \ |
| 8 | // RUN: | FileCheck %s |
| 9 | |
| 10 | // RUN: not %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown \ |
| 11 | // RUN: -target-cpu pwr8 -target-feature -power8-vector \ |
| 12 | // RUN: -target-feature -crypto -emit-llvm %s -o - 2>&1 \ |
| 13 | // RUN: | FileCheck %s -check-prefix=CHECK-P8V |
| 14 | #include <altivec.h> |
| 15 | |
| 16 | #define W_INIT1 { 0x01020304, 0x05060708, \ |
| 17 | 0x090A0B0C, 0x0D0E0F10 }; |
| 18 | #define D_INIT1 { 0x0102030405060708, \ |
| 19 | 0x090A0B0C0D0E0F10 }; |
| 20 | #define D_INIT2 { 0x7172737475767778, \ |
| 21 | 0x797A7B7C7D7E7F70 }; |
| 22 | |
| 23 | // Test cases for the builtins the way they are exposed to |
| 24 | // users through altivec.h |
| 25 | void call_crypto_intrinsics(void) |
| 26 | { |
| 27 | vector unsigned int aw = W_INIT1 |
| 28 | vector unsigned long long ad = D_INIT1 |
| 29 | vector unsigned long long bd = D_INIT2 |
| 30 | vector unsigned long long cd = D_INIT2 |
| 31 | |
| 32 | vector unsigned long long r1 = __builtin_crypto_vsbox(ad); |
| 33 | vector unsigned long long r2 = __builtin_crypto_vcipher(ad, bd); |
| 34 | vector unsigned long long r3 = __builtin_crypto_vcipherlast(ad, bd); |
| 35 | vector unsigned long long r4 = __builtin_crypto_vncipher(ad, bd); |
| 36 | vector unsigned long long r5 = __builtin_crypto_vncipherlast(ad, bd); |
| 37 | vector unsigned int r6 = __builtin_crypto_vshasigmaw(aw, 1, 15); |
| 38 | vector unsigned long long r7 = __builtin_crypto_vshasigmad(ad, 0, 15); |
| 39 | |
| 40 | // The ones that do not require -mcrypto, but require -mpower8-vector |
| 41 | vector unsigned long long r8 = __builtin_crypto_vpmsumb(ad, bd); |
| 42 | vector unsigned long long r9 = __builtin_crypto_vpermxor(ad, bd, cd); |
| 43 | } |
| 44 | |
| 45 | // CHECK: use of unknown builtin '__builtin_crypto_vsbox' |
| 46 | // CHECK: use of unknown builtin '__builtin_crypto_vcipher' |
| 47 | // CHECK: use of unknown builtin '__builtin_crypto_vcipherlast' |
| 48 | // CHECK: use of unknown builtin '__builtin_crypto_vncipher' |
| 49 | // CHECK: use of unknown builtin '__builtin_crypto_vncipherlast' |
| 50 | // CHECK: use of unknown builtin '__builtin_crypto_vshasigmaw' |
| 51 | // CHECK: use of unknown builtin '__builtin_crypto_vshasigmad' |
| 52 | // CHECK-P8V: use of unknown builtin '__builtin_crypto_vpmsumb' |
| 53 | // CHECK-P8V: use of unknown builtin '__builtin_crypto_vpermxor' |
| 54 | |