Skip to content

Commit 5eb371d

Browse files
authored
[CIR][CIRGen][Builtin][Neon] Lower neon_vaesmcq_u8 (#1072)
The test case is from [clang/test/CodeGen/neon-crypto.c](https://github.com/llvm/clangir/blob/dbf320e5c3db0410566ae561067c595308870bad/clang/test/CodeGen/neon-crypto.c#L28) Need a dedicated test file as RunOptions has crypto related target features.
1 parent 7522d50 commit 5eb371d

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2476,7 +2476,11 @@ mlir::Value CIRGenFunction::buildCommonNeonBuiltinExpr(
24762476
default:
24772477
llvm::errs() << getAArch64SIMDIntrinsicString(builtinID) << " ";
24782478
llvm_unreachable("NYI");
2479-
2479+
case NEON::BI__builtin_neon_vaesmcq_u8: {
2480+
intrincsName = "aarch64.crypto.aesmc";
2481+
argTypes.push_back(vTy);
2482+
break;
2483+
}
24802484
case NEON::BI__builtin_neon_vpadd_v:
24812485
case NEON::BI__builtin_neon_vpaddq_v: {
24822486
intrincsName = mlir::isa<mlir::FloatType>(vTy.getEltType())
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
2+
// RUN: -target-feature +sha2 -target-feature +aes \
3+
// RUN: -disable-O0-optnone -fclangir -emit-cir -o %t.cir %s
4+
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
5+
6+
// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
7+
// RUN: -target-feature +sha2 -target-feature +aes \
8+
// RUN: -disable-O0-optnone -emit-llvm -o - %s \
9+
// RUN: | opt -S -passes=mem2reg,simplifycfg -o %t.ll
10+
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
11+
12+
// REQUIRES: aarch64-registered-target || arm-registered-target
13+
14+
#include <arm_neon.h>
15+
16+
uint8x16_t test_vaesmcq_u8(uint8x16_t data) {
17+
return vaesmcq_u8(data);
18+
19+
// CIR-LABEL: vaesmcq_u8
20+
// {{%.*}} = cir.llvm.intrinsic "aarch64.crypto.aesmc" {{%.*}} : (!cir.vector<!u8i x 16>) -> !cir.vector<!u8i x 16>
21+
22+
// LLVM: {{.*}}vaesmcq_u8(<16 x i8>{{.*}}[[DATA:%.*]])
23+
// LLVM: [[RES:%.*]] = call <16 x i8> @llvm.aarch64.crypto.aesmc(<16 x i8> [[DATA]])
24+
// LLVM: ret <16 x i8> [[RES]]
25+
}

0 commit comments

Comments
 (0)