xref: /llvm-project/clang/test/CodeGen/AArch64/targetattr-crypto.c (revision 207e5ccceec8d3cc3f32723e78f2a142bc61b07d)
1*207e5cccSFangrui Song // RUN: %clang_cc1 -triple aarch64 -target-feature +v8a -verify -S %s -o -
2*207e5cccSFangrui Song // REQUIRES: aarch64-registered-target
3*207e5cccSFangrui Song 
4*207e5cccSFangrui Song #include <arm_neon.h>
5*207e5cccSFangrui Song 
6*207e5cccSFangrui Song __attribute__((target("+crypto")))
7*207e5cccSFangrui Song void test_crypto(uint8x16_t data, uint8x16_t key)
8*207e5cccSFangrui Song {
9*207e5cccSFangrui Song   vaeseq_u8(data, key);
10*207e5cccSFangrui Song   vsha1su1q_u32(data, key);
11*207e5cccSFangrui Song }
12*207e5cccSFangrui Song 
13*207e5cccSFangrui Song __attribute__((target("crypto")))
14*207e5cccSFangrui Song void test_pluscrypto(uint8x16_t data, uint8x16_t key)
15*207e5cccSFangrui Song {
16*207e5cccSFangrui Song   vaeseq_u8(data, key);
17*207e5cccSFangrui Song   vsha1su1q_u32(data, key);
18*207e5cccSFangrui Song }
19*207e5cccSFangrui Song 
20*207e5cccSFangrui Song __attribute__((target("arch=armv8.2-a+crypto")))
21*207e5cccSFangrui Song void test_archcrypto(uint8x16_t data, uint8x16_t key)
22*207e5cccSFangrui Song {
23*207e5cccSFangrui Song   vaeseq_u8(data, key);
24*207e5cccSFangrui Song   vsha1su1q_u32(data, key);
25*207e5cccSFangrui Song }
26*207e5cccSFangrui Song 
27*207e5cccSFangrui Song // FIXME: This shouldn't need +crypto to be consistent with -mcpu options.
28*207e5cccSFangrui Song __attribute__((target("cpu=cortex-a55+crypto")))
29*207e5cccSFangrui Song void test_a55crypto(uint8x16_t data, uint8x16_t key)
30*207e5cccSFangrui Song {
31*207e5cccSFangrui Song   vaeseq_u8(data, key);
32*207e5cccSFangrui Song   vsha1su1q_u32(data, key);
33*207e5cccSFangrui Song }
34*207e5cccSFangrui Song 
35*207e5cccSFangrui Song __attribute__((target("cpu=cortex-a510+crypto")))
36*207e5cccSFangrui Song void test_a510crypto(uint8x16_t data, uint8x16_t key)
37*207e5cccSFangrui Song {
38*207e5cccSFangrui Song   vaeseq_u8(data, key);
39*207e5cccSFangrui Song   vsha1su1q_u32(data, key);
40*207e5cccSFangrui Song }
41*207e5cccSFangrui Song 
42*207e5cccSFangrui Song __attribute__((target("+sha2+aes")))
43*207e5cccSFangrui Song void test_sha2aes(uint8x16_t data, uint8x16_t key)
44*207e5cccSFangrui Song {
45*207e5cccSFangrui Song   vaeseq_u8(data, key);
46*207e5cccSFangrui Song   vsha1su1q_u32(data, key);
47*207e5cccSFangrui Song }
48*207e5cccSFangrui Song 
49*207e5cccSFangrui Song void test_errors(uint8x16_t data, uint8x16_t key)
50*207e5cccSFangrui Song {
51*207e5cccSFangrui Song   vaeseq_u8(data, key); // expected-error {{always_inline function 'vaeseq_u8' requires target feature 'aes'}}
52*207e5cccSFangrui Song   vsha1su1q_u32(data, key); // expected-error {{always_inline function 'vsha1su1q_u32' requires target feature 'sha2'}}
53*207e5cccSFangrui Song }
54