Skip to content

Commit 1c76740

Browse files
davemgreentru
authored andcommitted
[AArch64] Basic target(+crypto) handling
This adds some basic handling for target(+crypto) attributes. In this patch it just enabled aes and sha2 regardless of the architecture revision, which matches gccs implementation (and keeps the patch simple). Differential Revision: https://reviews.llvm.org/D142135 (cherry picked from commit 43aa293)
1 parent b5aa566 commit 1c76740

File tree

2 files changed

+54
-1
lines changed

2 files changed

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

llvm/include/llvm/TargetParser/AArch64TargetParser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ inline constexpr ExtensionInfo Extensions[] = {
177177
{"brbe", AArch64::AEK_BRBE, "+brbe", "-brbe", FEAT_MAX, "", 0},
178178
{"bti", AArch64::AEK_NONE, {}, {}, FEAT_BTI, "+bti", 510},
179179
{"crc", AArch64::AEK_CRC, "+crc", "-crc", FEAT_CRC, "+crc", 110},
180-
{"crypto", AArch64::AEK_CRYPTO, "+crypto", "-crypto", FEAT_MAX, "", 0},
180+
{"crypto", AArch64::AEK_CRYPTO, "+crypto", "-crypto", FEAT_MAX, "+aes,+sha2", 0},
181181
{"cssc", AArch64::AEK_CSSC, "+cssc", "-cssc", FEAT_MAX, "", 0},
182182
{"d128", AArch64::AEK_D128, "+d128", "-d128", FEAT_MAX, "", 0},
183183
{"dgh", AArch64::AEK_NONE, {}, {}, FEAT_DGH, "", 260},

0 commit comments

Comments
 (0)