File: aarch64-targetattr-crypto.c

package info (click to toggle)
llvm-toolchain-18 1%3A18.1.8-18
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,908,340 kB
  • sloc: cpp: 6,667,937; ansic: 1,440,452; asm: 883,619; python: 230,549; objc: 76,880; f90: 74,238; lisp: 35,989; pascal: 16,571; sh: 10,229; perl: 7,459; ml: 5,047; awk: 3,523; makefile: 2,987; javascript: 2,149; xml: 892; fortran: 649; cs: 573
file content (53 lines) | stat: -rw-r--r-- 1,415 bytes parent folder | download | duplicates (5)
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-eabi -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'}}
}