File: aarch64-targetattr-crypto.c

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (53 lines) | stat: -rw-r--r-- 1,410 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// RUN: %clang_cc1 -triple aarch64 -target-feature +v8a -verify -S %s -o -
// REQUIRES: aarch64-registered-target

#include <arm_neon.h>

__attribute__((target("+crypto")))
void test_crypto(uint8x16_t data, uint8x16_t key)
{
  vaeseq_u8(data, key);
  vsha1su1q_u32(data, key);
}

__attribute__((target("crypto")))
void test_pluscrypto(uint8x16_t data, uint8x16_t key)
{
  vaeseq_u8(data, key);
  vsha1su1q_u32(data, key);
}

__attribute__((target("arch=armv8.2-a+crypto")))
void test_archcrypto(uint8x16_t data, uint8x16_t key)
{
  vaeseq_u8(data, key);
  vsha1su1q_u32(data, key);
}

// FIXME: This shouldn't need +crypto to be consistent with -mcpu options.
__attribute__((target("cpu=cortex-a55+crypto")))
void test_a55crypto(uint8x16_t data, uint8x16_t key)
{
  vaeseq_u8(data, key);
  vsha1su1q_u32(data, key);
}

__attribute__((target("cpu=cortex-a510+crypto")))
void test_a510crypto(uint8x16_t data, uint8x16_t key)
{
  vaeseq_u8(data, key);
  vsha1su1q_u32(data, key);
}

__attribute__((target("+sha2+aes")))
void test_sha2aes(uint8x16_t data, uint8x16_t key)
{
  vaeseq_u8(data, key);
  vsha1su1q_u32(data, key);
}

void test_errors(uint8x16_t data, uint8x16_t key)
{
  vaeseq_u8(data, key); // expected-error {{always_inline function 'vaeseq_u8' requires target feature 'aes'}}
  vsha1su1q_u32(data, key); // expected-error {{always_inline function 'vsha1su1q_u32' requires target feature 'sha2'}}
}