[clang] fa9c8ba - [RISCV] Support k-ext clang intrinsics
Shao-Ce SUN via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 4 21:57:26 PST 2022
Author: Shao-Ce SUN
Date: 2022-03-05T13:57:18+08:00
New Revision: fa9c8bab0c7a7aed423191baa8a980533ae5602a
URL: https://github.com/llvm/llvm-project/commit/fa9c8bab0c7a7aed423191baa8a980533ae5602a
DIFF: https://github.com/llvm/llvm-project/commit/fa9c8bab0c7a7aed423191baa8a980533ae5602a.diff
LOG: [RISCV] Support k-ext clang intrinsics
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D112774
Added:
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkb.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkc.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkc.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c
clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zknd.c
clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zkne.c
clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zknh.c
clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zksed.c
clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zksh.c
clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd-zkne.c
clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zkne.c
clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksed.c
clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksh.c
Modified:
clang/include/clang/Basic/BuiltinsRISCV.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/Driver/riscv-arch.c
clang/test/Preprocessor/riscv-target-features.c
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/BuiltinsRISCV.def b/clang/include/clang/Basic/BuiltinsRISCV.def
index 495a036e576f8..73ec6eae7e955 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -19,11 +19,15 @@
TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "zbb")
TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "zbb,64bit")
-// Zbc extension
-TARGET_BUILTIN(__builtin_riscv_clmul, "LiLiLi", "nc", "zbc")
-TARGET_BUILTIN(__builtin_riscv_clmulh, "LiLiLi", "nc", "zbc")
+// Zbc or Zbkc extension
+TARGET_BUILTIN(__builtin_riscv_clmul, "LiLiLi", "nc", "zbc|zbkc")
+TARGET_BUILTIN(__builtin_riscv_clmulh, "LiLiLi", "nc", "zbc|zbkc")
TARGET_BUILTIN(__builtin_riscv_clmulr, "LiLiLi", "nc", "zbc")
+// Zbkx
+TARGET_BUILTIN(__builtin_riscv_xperm4, "LiLiLi", "nc", "zbkx")
+TARGET_BUILTIN(__builtin_riscv_xperm8, "LiLiLi", "nc", "zbkx")
+
// Zbe extension
TARGET_BUILTIN(__builtin_riscv_bcompress_32, "ZiZiZi", "nc", "experimental-zbe")
TARGET_BUILTIN(__builtin_riscv_bcompress_64, "WiWiWi", "nc",
@@ -67,5 +71,52 @@ TARGET_BUILTIN(__builtin_riscv_fsr_32, "LiLiLiLi", "nc", "experimental-zbt")
TARGET_BUILTIN(__builtin_riscv_fsl_64, "WiWiWiWi", "nc", "experimental-zbt,64bit")
TARGET_BUILTIN(__builtin_riscv_fsr_64, "WiWiWiWi", "nc", "experimental-zbt,64bit")
+// Zbkb extension
+TARGET_BUILTIN(__builtin_riscv_brev8, "LiLi", "nc", "zbkb")
+TARGET_BUILTIN(__builtin_riscv_zip_32, "ZiZi", "nc", "zbkb")
+TARGET_BUILTIN(__builtin_riscv_unzip_32, "ZiZi", "nc", "zbkb")
+
+// Zknd extension
+TARGET_BUILTIN(__builtin_riscv_aes32dsi_32, "ZiZiZiIUc", "nc", "zknd")
+TARGET_BUILTIN(__builtin_riscv_aes32dsmi_32, "ZiZiZiIUc", "nc", "zknd")
+TARGET_BUILTIN(__builtin_riscv_aes64ds_64, "WiWiWi", "nc", "zknd,64bit")
+TARGET_BUILTIN(__builtin_riscv_aes64dsm_64, "WiWiWi", "nc", "zknd,64bit")
+TARGET_BUILTIN(__builtin_riscv_aes64im_64, "WiWi", "nc", "zknd,64bit")
+
+// Zknd & zkne
+TARGET_BUILTIN(__builtin_riscv_aes64ks1i_64, "WiWiIUi", "nc", "zknd|zkne,64bit")
+TARGET_BUILTIN(__builtin_riscv_aes64ks2_64, "WiWiWi", "nc", "zknd|zkne,64bit")
+
+// Zkne extension
+TARGET_BUILTIN(__builtin_riscv_aes32esi_32, "ZiZiZiIUc", "nc", "zkne")
+TARGET_BUILTIN(__builtin_riscv_aes32esmi_32, "ZiZiZiIUc", "nc", "zkne")
+TARGET_BUILTIN(__builtin_riscv_aes64es_64, "WiWiWi", "nc", "zkne,64bit")
+TARGET_BUILTIN(__builtin_riscv_aes64esm_64, "WiWiWi", "nc", "zkne,64bit")
+
+// Zknh extension
+TARGET_BUILTIN(__builtin_riscv_sha256sig0, "LiLi", "nc", "zknh")
+TARGET_BUILTIN(__builtin_riscv_sha256sig1, "LiLi", "nc", "zknh")
+TARGET_BUILTIN(__builtin_riscv_sha256sum0, "LiLi", "nc", "zknh")
+TARGET_BUILTIN(__builtin_riscv_sha256sum1, "LiLi", "nc", "zknh")
+
+TARGET_BUILTIN(__builtin_riscv_sha512sig0h_32, "ZiZiZi", "nc", "zknh")
+TARGET_BUILTIN(__builtin_riscv_sha512sig0l_32, "ZiZiZi", "nc", "zknh")
+TARGET_BUILTIN(__builtin_riscv_sha512sig1h_32, "ZiZiZi", "nc", "zknh")
+TARGET_BUILTIN(__builtin_riscv_sha512sig1l_32, "ZiZiZi", "nc", "zknh")
+TARGET_BUILTIN(__builtin_riscv_sha512sum0r_32, "ZiZiZi", "nc", "zknh")
+TARGET_BUILTIN(__builtin_riscv_sha512sum1r_32, "ZiZiZi", "nc", "zknh")
+TARGET_BUILTIN(__builtin_riscv_sha512sig0_64, "WiWi", "nc", "zknh,64bit")
+TARGET_BUILTIN(__builtin_riscv_sha512sig1_64, "WiWi", "nc", "zknh,64bit")
+TARGET_BUILTIN(__builtin_riscv_sha512sum0_64, "WiWi", "nc", "zknh,64bit")
+TARGET_BUILTIN(__builtin_riscv_sha512sum1_64, "WiWi", "nc", "zknh,64bit")
+
+// Zksed extension
+TARGET_BUILTIN(__builtin_riscv_sm4ed, "LiLiLiIUc", "nc", "zksed")
+TARGET_BUILTIN(__builtin_riscv_sm4ks, "LiLiLiIUc", "nc", "zksed")
+
+// Zksh extension
+TARGET_BUILTIN(__builtin_riscv_sm3p0, "LiLi", "nc", "zksh")
+TARGET_BUILTIN(__builtin_riscv_sm3p1, "LiLi", "nc", "zksh")
+
#undef BUILTIN
#undef TARGET_BUILTIN
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 43993f092988e..5b917ead9cd9c 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18767,6 +18767,8 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned BuiltinID,
case RISCV::BI__builtin_riscv_shfl_64:
case RISCV::BI__builtin_riscv_unshfl_32:
case RISCV::BI__builtin_riscv_unshfl_64:
+ case RISCV::BI__builtin_riscv_xperm4:
+ case RISCV::BI__builtin_riscv_xperm8:
case RISCV::BI__builtin_riscv_xperm_n:
case RISCV::BI__builtin_riscv_xperm_b:
case RISCV::BI__builtin_riscv_xperm_h:
@@ -18782,7 +18784,10 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned BuiltinID,
case RISCV::BI__builtin_riscv_fsl_32:
case RISCV::BI__builtin_riscv_fsr_32:
case RISCV::BI__builtin_riscv_fsl_64:
- case RISCV::BI__builtin_riscv_fsr_64: {
+ case RISCV::BI__builtin_riscv_fsr_64:
+ case RISCV::BI__builtin_riscv_brev8:
+ case RISCV::BI__builtin_riscv_zip_32:
+ case RISCV::BI__builtin_riscv_unzip_32: {
switch (BuiltinID) {
default: llvm_unreachable("unexpected builtin ID");
// Zbb
@@ -18883,11 +18888,140 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned BuiltinID,
case RISCV::BI__builtin_riscv_fsr_64:
ID = Intrinsic::riscv_fsr;
break;
+
+ // Zbkx
+ case RISCV::BI__builtin_riscv_xperm8:
+ ID = Intrinsic::riscv_xperm8;
+ break;
+ case RISCV::BI__builtin_riscv_xperm4:
+ ID = Intrinsic::riscv_xperm4;
+ break;
+
+ // Zbkb
+ case RISCV::BI__builtin_riscv_brev8:
+ ID = Intrinsic::riscv_brev8;
+ break;
+ case RISCV::BI__builtin_riscv_zip_32:
+ ID = Intrinsic::riscv_zip;
+ break;
+ case RISCV::BI__builtin_riscv_unzip_32:
+ ID = Intrinsic::riscv_unzip;
+ break;
}
IntrinsicTypes = {ResultType};
break;
}
+
+ // Zk builtins
+
+ // Zknd
+ case RISCV::BI__builtin_riscv_aes32dsi_32:
+ ID = Intrinsic::riscv_aes32dsi;
+ break;
+ case RISCV::BI__builtin_riscv_aes32dsmi_32:
+ ID = Intrinsic::riscv_aes32dsmi;
+ break;
+ case RISCV::BI__builtin_riscv_aes64ds_64:
+ ID = Intrinsic::riscv_aes64ds;
+ break;
+ case RISCV::BI__builtin_riscv_aes64dsm_64:
+ ID = Intrinsic::riscv_aes64dsm;
+ break;
+ case RISCV::BI__builtin_riscv_aes64im_64:
+ ID = Intrinsic::riscv_aes64im;
+ break;
+
+ // Zkne
+ case RISCV::BI__builtin_riscv_aes32esi_32:
+ ID = Intrinsic::riscv_aes32esi;
+ break;
+ case RISCV::BI__builtin_riscv_aes32esmi_32:
+ ID = Intrinsic::riscv_aes32esmi;
+ break;
+ case RISCV::BI__builtin_riscv_aes64es_64:
+ ID = Intrinsic::riscv_aes64es;
+ break;
+ case RISCV::BI__builtin_riscv_aes64esm_64:
+ ID = Intrinsic::riscv_aes64esm;
+ break;
+
+ // Zknd & Zkne
+ case RISCV::BI__builtin_riscv_aes64ks1i_64:
+ ID = Intrinsic::riscv_aes64ks1i;
+ break;
+ case RISCV::BI__builtin_riscv_aes64ks2_64:
+ ID = Intrinsic::riscv_aes64ks2;
+ break;
+
+ // Zknh
+ case RISCV::BI__builtin_riscv_sha256sig0:
+ ID = Intrinsic::riscv_sha256sig0;
+ IntrinsicTypes = {ResultType};
+ break;
+ case RISCV::BI__builtin_riscv_sha256sig1:
+ ID = Intrinsic::riscv_sha256sig1;
+ IntrinsicTypes = {ResultType};
+ break;
+ case RISCV::BI__builtin_riscv_sha256sum0:
+ ID = Intrinsic::riscv_sha256sum0;
+ IntrinsicTypes = {ResultType};
+ break;
+ case RISCV::BI__builtin_riscv_sha256sum1:
+ ID = Intrinsic::riscv_sha256sum1;
+ IntrinsicTypes = {ResultType};
+ break;
+ case RISCV::BI__builtin_riscv_sha512sig0_64:
+ ID = Intrinsic::riscv_sha512sig0;
+ break;
+ case RISCV::BI__builtin_riscv_sha512sig0h_32:
+ ID = Intrinsic::riscv_sha512sig0h;
+ break;
+ case RISCV::BI__builtin_riscv_sha512sig0l_32:
+ ID = Intrinsic::riscv_sha512sig0l;
+ break;
+ case RISCV::BI__builtin_riscv_sha512sig1_64:
+ ID = Intrinsic::riscv_sha512sig1;
+ break;
+ case RISCV::BI__builtin_riscv_sha512sig1h_32:
+ ID = Intrinsic::riscv_sha512sig1h;
+ break;
+ case RISCV::BI__builtin_riscv_sha512sig1l_32:
+ ID = Intrinsic::riscv_sha512sig1l;
+ break;
+ case RISCV::BI__builtin_riscv_sha512sum0_64:
+ ID = Intrinsic::riscv_sha512sum0;
+ break;
+ case RISCV::BI__builtin_riscv_sha512sum0r_32:
+ ID = Intrinsic::riscv_sha512sum0r;
+ break;
+ case RISCV::BI__builtin_riscv_sha512sum1_64:
+ ID = Intrinsic::riscv_sha512sum1;
+ break;
+ case RISCV::BI__builtin_riscv_sha512sum1r_32:
+ ID = Intrinsic::riscv_sha512sum1r;
+ break;
+
+ // Zksed
+ case RISCV::BI__builtin_riscv_sm4ks:
+ ID = Intrinsic::riscv_sm4ks;
+ IntrinsicTypes = {ResultType};
+ break;
+ case RISCV::BI__builtin_riscv_sm4ed:
+ ID = Intrinsic::riscv_sm4ed;
+ IntrinsicTypes = {ResultType};
+ break;
+
+ // Zksh
+ case RISCV::BI__builtin_riscv_sm3p0:
+ ID = Intrinsic::riscv_sm3p0;
+ IntrinsicTypes = {ResultType};
+ break;
+ case RISCV::BI__builtin_riscv_sm3p1:
+ ID = Intrinsic::riscv_sm3p1;
+ IntrinsicTypes = {ResultType};
+ break;
+
// Vector builtins are handled from here.
#include "clang/Basic/riscv_vector_builtin_cg.inc"
}
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index cb65991cbe2e9..2bd0d113fc992 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3998,6 +3998,27 @@ bool Sema::CheckRISCVLMUL(CallExpr *TheCall, unsigned ArgNum) {
<< Arg->getSourceRange();
}
+static bool isRISCV32Builtin(unsigned BuiltinID) {
+ // These builtins only work on riscv32 targets.
+ switch (BuiltinID) {
+ case RISCV::BI__builtin_riscv_zip_32:
+ case RISCV::BI__builtin_riscv_unzip_32:
+ case RISCV::BI__builtin_riscv_aes32dsi_32:
+ case RISCV::BI__builtin_riscv_aes32dsmi_32:
+ case RISCV::BI__builtin_riscv_aes32esi_32:
+ case RISCV::BI__builtin_riscv_aes32esmi_32:
+ case RISCV::BI__builtin_riscv_sha512sig0h_32:
+ case RISCV::BI__builtin_riscv_sha512sig0l_32:
+ case RISCV::BI__builtin_riscv_sha512sig1h_32:
+ case RISCV::BI__builtin_riscv_sha512sig1l_32:
+ case RISCV::BI__builtin_riscv_sha512sum0r_32:
+ case RISCV::BI__builtin_riscv_sha512sum1r_32:
+ return true;
+ }
+
+ return false;
+}
+
bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo &TI,
unsigned BuiltinID,
CallExpr *TheCall) {
@@ -4008,6 +4029,12 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo &TI,
StringRef Features = Context.BuiltinInfo.getRequiredFeatures(BuiltinID);
Features.split(ReqFeatures, ',');
+ // Check for 32-bit only builtins on a 64-bit target.
+ const llvm::Triple &TT = TI.getTriple();
+ if (TT.getArch() != llvm::Triple::riscv32 && isRISCV32Builtin(BuiltinID))
+ return Diag(TheCall->getCallee()->getBeginLoc(),
+ diag::err_32_bit_builtin_64_bit_tgt);
+
// Check if each required feature is included
for (StringRef F : ReqFeatures) {
SmallVector<StringRef> ReqOpFeatures;
@@ -4055,6 +4082,17 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo &TI,
case RISCVVector::BI__builtin_rvv_vsetvlimax:
return SemaBuiltinConstantArgRange(TheCall, 0, 0, 3) ||
CheckRISCVLMUL(TheCall, 1);
+ // Check if byteselect is in [0, 3]
+ case RISCV::BI__builtin_riscv_aes32dsi_32:
+ case RISCV::BI__builtin_riscv_aes32dsmi_32:
+ case RISCV::BI__builtin_riscv_aes32esi_32:
+ case RISCV::BI__builtin_riscv_aes32esmi_32:
+ case RISCV::BI__builtin_riscv_sm4ks:
+ case RISCV::BI__builtin_riscv_sm4ed:
+ return SemaBuiltinConstantArgRange(TheCall, 2, 0, 3);
+ // Check if rnum is in [0, 10]
+ case RISCV::BI__builtin_riscv_aes64ks1i_64:
+ return SemaBuiltinConstantArgRange(TheCall, 1, 0, 10);
}
return false;
diff --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkb.c b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkb.c
new file mode 100644
index 0000000000000..3a61ef7e6723a
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkb.c
@@ -0,0 +1,42 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -target-feature +zbkb -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV32ZBKB
+
+// RV32ZBKB-LABEL: @brev8(
+// RV32ZBKB-NEXT: entry:
+// RV32ZBKB-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBKB-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZBKB-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZBKB-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.brev8.i32(i32 [[TMP0]])
+// RV32ZBKB-NEXT: ret i32 [[TMP1]]
+//
+long brev8(long rs1)
+{
+ return __builtin_riscv_brev8(rs1);
+}
+
+// RV32ZBKB-LABEL: @zip(
+// RV32ZBKB-NEXT: entry:
+// RV32ZBKB-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBKB-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZBKB-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZBKB-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.zip.i32(i32 [[TMP0]])
+// RV32ZBKB-NEXT: ret i32 [[TMP1]]
+//
+int zip(int rs1)
+{
+ return __builtin_riscv_zip_32(rs1);
+}
+
+// RV32ZBKB-LABEL: @unzip(
+// RV32ZBKB-NEXT: entry:
+// RV32ZBKB-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBKB-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZBKB-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZBKB-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.unzip.i32(i32 [[TMP0]])
+// RV32ZBKB-NEXT: ret i32 [[TMP1]]
+//
+int unzip(int rs1)
+{
+ return __builtin_riscv_unzip_32(rs1);
+}
diff --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkc.c b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkc.c
new file mode 100644
index 0000000000000..1181098a8c088
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkc.c
@@ -0,0 +1,33 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -target-feature +zbkc -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV32ZBKC
+
+// RV32ZBKC-LABEL: @clmul(
+// RV32ZBKC-NEXT: entry:
+// RV32ZBKC-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBKC-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBKC-NEXT: store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV32ZBKC-NEXT: store i32 [[B:%.*]], i32* [[B_ADDR]], align 4
+// RV32ZBKC-NEXT: [[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV32ZBKC-NEXT: [[TMP1:%.*]] = load i32, i32* [[B_ADDR]], align 4
+// RV32ZBKC-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.clmul.i32(i32 [[TMP0]], i32 [[TMP1]])
+// RV32ZBKC-NEXT: ret i32 [[TMP2]]
+//
+long clmul(long a, long b) {
+ return __builtin_riscv_clmul(a, b);
+}
+
+// RV32ZBKC-LABEL: @clmulh(
+// RV32ZBKC-NEXT: entry:
+// RV32ZBKC-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBKC-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBKC-NEXT: store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV32ZBKC-NEXT: store i32 [[B:%.*]], i32* [[B_ADDR]], align 4
+// RV32ZBKC-NEXT: [[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV32ZBKC-NEXT: [[TMP1:%.*]] = load i32, i32* [[B_ADDR]], align 4
+// RV32ZBKC-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.clmulh.i32(i32 [[TMP0]], i32 [[TMP1]])
+// RV32ZBKC-NEXT: ret i32 [[TMP2]]
+//
+long clmulh(long a, long b) {
+ return __builtin_riscv_clmulh(a, b);
+}
diff --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c
new file mode 100644
index 0000000000000..a9c82ec75740e
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbkx.c
@@ -0,0 +1,35 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -target-feature +zbkx -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV32ZBKX
+
+// RV32ZBKX-LABEL: @xperm8(
+// RV32ZBKX-NEXT: entry:
+// RV32ZBKX-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBKX-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBKX-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZBKX-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV32ZBKX-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZBKX-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV32ZBKX-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.xperm8.i32(i32 [[TMP0]], i32 [[TMP1]])
+// RV32ZBKX-NEXT: ret i32 [[TMP2]]
+//
+long xperm8(long rs1, long rs2)
+{
+ return __builtin_riscv_xperm8(rs1, rs2);
+}
+
+// RV32ZBKX-LABEL: @xperm4(
+// RV32ZBKX-NEXT: entry:
+// RV32ZBKX-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBKX-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBKX-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZBKX-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV32ZBKX-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZBKX-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV32ZBKX-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.xperm4.i32(i32 [[TMP0]], i32 [[TMP1]])
+// RV32ZBKX-NEXT: ret i32 [[TMP2]]
+//
+long xperm4(long rs1, long rs2)
+{
+ return __builtin_riscv_xperm4(rs1, rs2);
+}
diff --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c
new file mode 100644
index 0000000000000..5ae4043debae8
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb.c
@@ -0,0 +1,16 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zbkb -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV64ZBKB
+
+// RV64ZBKB-LABEL: @brev8(
+// RV64ZBKB-NEXT: entry:
+// RV64ZBKB-NEXT: [[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZBKB-NEXT: store i64 [[RS1:%.*]], i64* [[RS1_ADDR]], align 8
+// RV64ZBKB-NEXT: [[TMP0:%.*]] = load i64, i64* [[RS1_ADDR]], align 8
+// RV64ZBKB-NEXT: [[TMP1:%.*]] = call i64 @llvm.riscv.brev8.i64(i64 [[TMP0]])
+// RV64ZBKB-NEXT: ret i64 [[TMP1]]
+//
+long brev8(long rs1)
+{
+ return __builtin_riscv_brev8(rs1);
+}
diff --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkc.c b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkc.c
new file mode 100644
index 0000000000000..fa6bb89f62d5f
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkc.c
@@ -0,0 +1,33 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zbkc -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV64ZBKC
+
+// RV64ZBKC-LABEL: @clmul(
+// RV64ZBKC-NEXT: entry:
+// RV64ZBKC-NEXT: [[A_ADDR:%.*]] = alloca i64, align 8
+// RV64ZBKC-NEXT: [[B_ADDR:%.*]] = alloca i64, align 8
+// RV64ZBKC-NEXT: store i64 [[A:%.*]], i64* [[A_ADDR]], align 8
+// RV64ZBKC-NEXT: store i64 [[B:%.*]], i64* [[B_ADDR]], align 8
+// RV64ZBKC-NEXT: [[TMP0:%.*]] = load i64, i64* [[A_ADDR]], align 8
+// RV64ZBKC-NEXT: [[TMP1:%.*]] = load i64, i64* [[B_ADDR]], align 8
+// RV64ZBKC-NEXT: [[TMP2:%.*]] = call i64 @llvm.riscv.clmul.i64(i64 [[TMP0]], i64 [[TMP1]])
+// RV64ZBKC-NEXT: ret i64 [[TMP2]]
+//
+long clmul(long a, long b) {
+ return __builtin_riscv_clmul(a, b);
+}
+
+// RV64ZBKC-LABEL: @clmulh(
+// RV64ZBKC-NEXT: entry:
+// RV64ZBKC-NEXT: [[A_ADDR:%.*]] = alloca i64, align 8
+// RV64ZBKC-NEXT: [[B_ADDR:%.*]] = alloca i64, align 8
+// RV64ZBKC-NEXT: store i64 [[A:%.*]], i64* [[A_ADDR]], align 8
+// RV64ZBKC-NEXT: store i64 [[B:%.*]], i64* [[B_ADDR]], align 8
+// RV64ZBKC-NEXT: [[TMP0:%.*]] = load i64, i64* [[A_ADDR]], align 8
+// RV64ZBKC-NEXT: [[TMP1:%.*]] = load i64, i64* [[B_ADDR]], align 8
+// RV64ZBKC-NEXT: [[TMP2:%.*]] = call i64 @llvm.riscv.clmulh.i64(i64 [[TMP0]], i64 [[TMP1]])
+// RV64ZBKC-NEXT: ret i64 [[TMP2]]
+//
+long clmulh(long a, long b) {
+ return __builtin_riscv_clmulh(a, b);
+}
diff --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c
new file mode 100644
index 0000000000000..50c98a6ce0d97
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkx.c
@@ -0,0 +1,35 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zbkx -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV64ZBKX
+
+// RV64ZBKX-LABEL: @xperm8(
+// RV64ZBKX-NEXT: entry:
+// RV64ZBKX-NEXT: [[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZBKX-NEXT: [[RS2_ADDR:%.*]] = alloca i64, align 8
+// RV64ZBKX-NEXT: store i64 [[RS1:%.*]], i64* [[RS1_ADDR]], align 8
+// RV64ZBKX-NEXT: store i64 [[RS2:%.*]], i64* [[RS2_ADDR]], align 8
+// RV64ZBKX-NEXT: [[TMP0:%.*]] = load i64, i64* [[RS1_ADDR]], align 8
+// RV64ZBKX-NEXT: [[TMP1:%.*]] = load i64, i64* [[RS2_ADDR]], align 8
+// RV64ZBKX-NEXT: [[TMP2:%.*]] = call i64 @llvm.riscv.xperm8.i64(i64 [[TMP0]], i64 [[TMP1]])
+// RV64ZBKX-NEXT: ret i64 [[TMP2]]
+//
+long xperm8(long rs1, long rs2)
+{
+ return __builtin_riscv_xperm8(rs1, rs2);
+}
+
+// RV64ZBKX-LABEL: @xperm4(
+// RV64ZBKX-NEXT: entry:
+// RV64ZBKX-NEXT: [[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZBKX-NEXT: [[RS2_ADDR:%.*]] = alloca i64, align 8
+// RV64ZBKX-NEXT: store i64 [[RS1:%.*]], i64* [[RS1_ADDR]], align 8
+// RV64ZBKX-NEXT: store i64 [[RS2:%.*]], i64* [[RS2_ADDR]], align 8
+// RV64ZBKX-NEXT: [[TMP0:%.*]] = load i64, i64* [[RS1_ADDR]], align 8
+// RV64ZBKX-NEXT: [[TMP1:%.*]] = load i64, i64* [[RS2_ADDR]], align 8
+// RV64ZBKX-NEXT: [[TMP2:%.*]] = call i64 @llvm.riscv.xperm4.i64(i64 [[TMP0]], i64 [[TMP1]])
+// RV64ZBKX-NEXT: ret i64 [[TMP2]]
+//
+long xperm4(long rs1, long rs2)
+{
+ return __builtin_riscv_xperm4(rs1, rs2);
+}
diff --git a/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zknd.c b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zknd.c
new file mode 100644
index 0000000000000..2d85ae62829fd
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zknd.c
@@ -0,0 +1,33 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -target-feature +zknd -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV32ZKND
+
+// RV32ZKND-LABEL: @aes32dsi(
+// RV32ZKND-NEXT: entry:
+// RV32ZKND-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKND-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKND-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKND-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV32ZKND-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKND-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV32ZKND-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.aes32dsi(i32 [[TMP0]], i32 [[TMP1]], i8 3)
+// RV32ZKND-NEXT: ret i32 [[TMP2]]
+//
+int aes32dsi(int rs1, int rs2) {
+ return __builtin_riscv_aes32dsi_32(rs1, rs2, 3);
+}
+
+// RV32ZKND-LABEL: @aes32dsmi(
+// RV32ZKND-NEXT: entry:
+// RV32ZKND-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKND-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKND-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKND-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV32ZKND-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKND-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV32ZKND-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.aes32dsmi(i32 [[TMP0]], i32 [[TMP1]], i8 3)
+// RV32ZKND-NEXT: ret i32 [[TMP2]]
+//
+int aes32dsmi(int rs1, int rs2) {
+ return __builtin_riscv_aes32dsmi_32(rs1, rs2, 3);
+}
diff --git a/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zkne.c b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zkne.c
new file mode 100644
index 0000000000000..5e8dad57d162b
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zkne.c
@@ -0,0 +1,33 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -target-feature +zkne -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV32ZKNE
+
+// RV32ZKNE-LABEL: @aes32esi(
+// RV32ZKNE-NEXT: entry:
+// RV32ZKNE-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNE-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNE-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKNE-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV32ZKNE-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKNE-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV32ZKNE-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.aes32esi(i32 [[TMP0]], i32 [[TMP1]], i8 3)
+// RV32ZKNE-NEXT: ret i32 [[TMP2]]
+//
+int aes32esi(int rs1, int rs2) {
+ return __builtin_riscv_aes32esi_32(rs1, rs2, 3);
+}
+
+// RV32ZKNE-LABEL: @aes32esmi(
+// RV32ZKNE-NEXT: entry:
+// RV32ZKNE-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNE-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNE-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKNE-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV32ZKNE-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKNE-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV32ZKNE-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.aes32esmi(i32 [[TMP0]], i32 [[TMP1]], i8 3)
+// RV32ZKNE-NEXT: ret i32 [[TMP2]]
+//
+int aes32esmi(int rs1, int rs2) {
+ return __builtin_riscv_aes32esmi_32(rs1, rs2, 3);
+}
diff --git a/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zknh.c b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zknh.c
new file mode 100644
index 0000000000000..fd47348a17b48
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zknh.c
@@ -0,0 +1,141 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -target-feature +zknh -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV32ZKNH
+
+// RV32ZKNH-LABEL: @sha256sig0(
+// RV32ZKNH-NEXT: entry:
+// RV32ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.sha256sig0.i32(i32 [[TMP0]])
+// RV32ZKNH-NEXT: ret i32 [[TMP1]]
+//
+long sha256sig0(long rs1) {
+ return __builtin_riscv_sha256sig0(rs1);
+}
+
+// RV32ZKNH-LABEL: @sha256sig1(
+// RV32ZKNH-NEXT: entry:
+// RV32ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.sha256sig1.i32(i32 [[TMP0]])
+// RV32ZKNH-NEXT: ret i32 [[TMP1]]
+//
+long sha256sig1(long rs1) {
+ return __builtin_riscv_sha256sig1(rs1);
+}
+
+// RV32ZKNH-LABEL: @sha256sum0(
+// RV32ZKNH-NEXT: entry:
+// RV32ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.sha256sum0.i32(i32 [[TMP0]])
+// RV32ZKNH-NEXT: ret i32 [[TMP1]]
+//
+long sha256sum0(long rs1) {
+ return __builtin_riscv_sha256sum0(rs1);
+}
+
+// RV32ZKNH-LABEL: @sha256sum1(
+// RV32ZKNH-NEXT: entry:
+// RV32ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.sha256sum1.i32(i32 [[TMP0]])
+// RV32ZKNH-NEXT: ret i32 [[TMP1]]
+//
+long sha256sum1(long rs1) {
+ return __builtin_riscv_sha256sum1(rs1);
+}
+
+// RV32ZKNH-LABEL: @sha512sig0h(
+// RV32ZKNH-NEXT: entry:
+// RV32ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNH-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.sha512sig0h(i32 [[TMP0]], i32 [[TMP1]])
+// RV32ZKNH-NEXT: ret i32 [[TMP2]]
+//
+int sha512sig0h(int rs1, int rs2) {
+ return __builtin_riscv_sha512sig0h_32(rs1, rs2);
+}
+
+// RV32ZKNH-LABEL: @sha512sig0l(
+// RV32ZKNH-NEXT: entry:
+// RV32ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNH-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.sha512sig0l(i32 [[TMP0]], i32 [[TMP1]])
+// RV32ZKNH-NEXT: ret i32 [[TMP2]]
+//
+int sha512sig0l(int rs1, int rs2) {
+ return __builtin_riscv_sha512sig0l_32(rs1, rs2);
+}
+
+// RV32ZKNH-LABEL: @sha512sig1h(
+// RV32ZKNH-NEXT: entry:
+// RV32ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNH-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.sha512sig1h(i32 [[TMP0]], i32 [[TMP1]])
+// RV32ZKNH-NEXT: ret i32 [[TMP2]]
+//
+int sha512sig1h(int rs1, int rs2) {
+ return __builtin_riscv_sha512sig1h_32(rs1, rs2);
+}
+
+// RV32ZKNH-LABEL: @sha512sig1l(
+// RV32ZKNH-NEXT: entry:
+// RV32ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNH-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.sha512sig1l(i32 [[TMP0]], i32 [[TMP1]])
+// RV32ZKNH-NEXT: ret i32 [[TMP2]]
+//
+int sha512sig1l(int rs1, int rs2) {
+ return __builtin_riscv_sha512sig1l_32(rs1, rs2);
+}
+
+// RV32ZKNH-LABEL: @sha512sum0r(
+// RV32ZKNH-NEXT: entry:
+// RV32ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNH-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.sha512sum0r(i32 [[TMP0]], i32 [[TMP1]])
+// RV32ZKNH-NEXT: ret i32 [[TMP2]]
+//
+int sha512sum0r(int rs1, int rs2) {
+ return __builtin_riscv_sha512sum0r_32(rs1, rs2);
+}
+
+// RV32ZKNH-LABEL: @sha512sum1r(
+// RV32ZKNH-NEXT: entry:
+// RV32ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNH-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKNH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV32ZKNH-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.sha512sum1r(i32 [[TMP0]], i32 [[TMP1]])
+// RV32ZKNH-NEXT: ret i32 [[TMP2]]
+//
+int sha512sum1r(int rs1, int rs2) {
+ return __builtin_riscv_sha512sum1r_32(rs1, rs2);
+}
diff --git a/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zksed.c b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zksed.c
new file mode 100644
index 0000000000000..4625f27fbbe3d
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zksed.c
@@ -0,0 +1,34 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -target-feature +zksed -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV32ZKSED
+
+// RV32ZKSED-LABEL: @sm4ks(
+// RV32ZKSED-NEXT: entry:
+// RV32ZKSED-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKSED-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKSED-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKSED-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV32ZKSED-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKSED-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV32ZKSED-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.sm4ks.i32(i32 [[TMP0]], i32 [[TMP1]], i8 0)
+// RV32ZKSED-NEXT: ret i32 [[TMP2]]
+//
+long sm4ks(long rs1, long rs2) {
+ return __builtin_riscv_sm4ks(rs1, rs2, 0);
+}
+
+
+// RV32ZKSED-LABEL: @sm4ed(
+// RV32ZKSED-NEXT: entry:
+// RV32ZKSED-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKSED-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKSED-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKSED-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV32ZKSED-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKSED-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV32ZKSED-NEXT: [[TMP2:%.*]] = call i32 @llvm.riscv.sm4ed.i32(i32 [[TMP0]], i32 [[TMP1]], i8 0)
+// RV32ZKSED-NEXT: ret i32 [[TMP2]]
+//
+long sm4ed(long rs1, long rs2) {
+ return __builtin_riscv_sm4ed(rs1, rs2, 0);
+}
diff --git a/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zksh.c b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zksh.c
new file mode 100644
index 0000000000000..1cced71d2e409
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv32-zksh.c
@@ -0,0 +1,28 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -target-feature +zksh -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV32ZKSH
+
+// RV32ZKSH-LABEL: @sm3p0(
+// RV32ZKSH-NEXT: entry:
+// RV32ZKSH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKSH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKSH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKSH-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.sm3p0.i32(i32 [[TMP0]])
+// RV32ZKSH-NEXT: ret i32 [[TMP1]]
+//
+long sm3p0(long rs1)
+{
+ return __builtin_riscv_sm3p0(rs1);
+}
+
+// RV32ZKSH-LABEL: @sm3p1(
+// RV32ZKSH-NEXT: entry:
+// RV32ZKSH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV32ZKSH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV32ZKSH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV32ZKSH-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.sm3p1.i32(i32 [[TMP0]])
+// RV32ZKSH-NEXT: ret i32 [[TMP1]]
+//
+long sm3p1(long rs1) {
+ return __builtin_riscv_sm3p1(rs1);
+}
diff --git a/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd-zkne.c b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd-zkne.c
new file mode 100644
index 0000000000000..d349df19a3177
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd-zkne.c
@@ -0,0 +1,38 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zknd -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV64ZKND-ZKNE
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zkne -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV64ZKND-ZKNE
+
+// RV64ZKND-ZKNE-LABEL: @aes64ks1i(
+// RV64ZKND-ZKNE-NEXT: entry:
+// RV64ZKND-ZKNE-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV64ZKND-ZKNE-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV64ZKND-ZKNE-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV64ZKND-ZKNE-NEXT: [[CONV:%.*]] = sext i32 [[TMP0]] to i64
+// RV64ZKND-ZKNE-NEXT: [[TMP1:%.*]] = call i64 @llvm.riscv.aes64ks1i(i64 [[CONV]], i32 0)
+// RV64ZKND-ZKNE-NEXT: [[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
+// RV64ZKND-ZKNE-NEXT: ret i32 [[CONV1]]
+//
+int aes64ks1i(int rs1) {
+ return __builtin_riscv_aes64ks1i_64(rs1, 0);
+}
+
+// RV64ZKND-ZKNE-LABEL: @aes64ks2(
+// RV64ZKND-ZKNE-NEXT: entry:
+// RV64ZKND-ZKNE-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV64ZKND-ZKNE-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV64ZKND-ZKNE-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV64ZKND-ZKNE-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV64ZKND-ZKNE-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV64ZKND-ZKNE-NEXT: [[CONV:%.*]] = sext i32 [[TMP0]] to i64
+// RV64ZKND-ZKNE-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV64ZKND-ZKNE-NEXT: [[CONV1:%.*]] = sext i32 [[TMP1]] to i64
+// RV64ZKND-ZKNE-NEXT: [[TMP2:%.*]] = call i64 @llvm.riscv.aes64ks2(i64 [[CONV]], i64 [[CONV1]])
+// RV64ZKND-ZKNE-NEXT: [[CONV2:%.*]] = trunc i64 [[TMP2]] to i32
+// RV64ZKND-ZKNE-NEXT: ret i32 [[CONV2]]
+//
+int aes64ks2(int rs1, int rs2) {
+ return __builtin_riscv_aes64ks2_64(rs1, rs2);
+}
diff --git a/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
new file mode 100644
index 0000000000000..f008671a8dec9
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknd.c
@@ -0,0 +1,56 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zknd -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV64ZKND
+
+
+// RV64ZKND-LABEL: @aes64dsm(
+// RV64ZKND-NEXT: entry:
+// RV64ZKND-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV64ZKND-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV64ZKND-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV64ZKND-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV64ZKND-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV64ZKND-NEXT: [[CONV:%.*]] = sext i32 [[TMP0]] to i64
+// RV64ZKND-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV64ZKND-NEXT: [[CONV1:%.*]] = sext i32 [[TMP1]] to i64
+// RV64ZKND-NEXT: [[TMP2:%.*]] = call i64 @llvm.riscv.aes64dsm(i64 [[CONV]], i64 [[CONV1]])
+// RV64ZKND-NEXT: [[CONV2:%.*]] = trunc i64 [[TMP2]] to i32
+// RV64ZKND-NEXT: ret i32 [[CONV2]]
+//
+int aes64dsm(int rs1, int rs2) {
+ return __builtin_riscv_aes64dsm_64(rs1, rs2);
+}
+
+
+// RV64ZKND-LABEL: @aes64ds(
+// RV64ZKND-NEXT: entry:
+// RV64ZKND-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV64ZKND-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV64ZKND-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV64ZKND-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV64ZKND-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV64ZKND-NEXT: [[CONV:%.*]] = sext i32 [[TMP0]] to i64
+// RV64ZKND-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV64ZKND-NEXT: [[CONV1:%.*]] = sext i32 [[TMP1]] to i64
+// RV64ZKND-NEXT: [[TMP2:%.*]] = call i64 @llvm.riscv.aes64ds(i64 [[CONV]], i64 [[CONV1]])
+// RV64ZKND-NEXT: [[CONV2:%.*]] = trunc i64 [[TMP2]] to i32
+// RV64ZKND-NEXT: ret i32 [[CONV2]]
+//
+int aes64ds(int rs1, int rs2) {
+ return __builtin_riscv_aes64ds_64(rs1, rs2);
+}
+
+
+// RV64ZKND-LABEL: @aes64im(
+// RV64ZKND-NEXT: entry:
+// RV64ZKND-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV64ZKND-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV64ZKND-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV64ZKND-NEXT: [[CONV:%.*]] = sext i32 [[TMP0]] to i64
+// RV64ZKND-NEXT: [[TMP1:%.*]] = call i64 @llvm.riscv.aes64im(i64 [[CONV]])
+// RV64ZKND-NEXT: [[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
+// RV64ZKND-NEXT: ret i32 [[CONV1]]
+//
+int aes64im(int rs1) {
+ return __builtin_riscv_aes64im_64(rs1);
+}
diff --git a/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zkne.c b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zkne.c
new file mode 100644
index 0000000000000..ce9a383d7581a
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zkne.c
@@ -0,0 +1,41 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zkne -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV64ZKNE
+
+
+// RV64ZKNE-LABEL: @aes64es(
+// RV64ZKNE-NEXT: entry:
+// RV64ZKNE-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV64ZKNE-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV64ZKNE-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV64ZKNE-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV64ZKNE-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV64ZKNE-NEXT: [[CONV:%.*]] = sext i32 [[TMP0]] to i64
+// RV64ZKNE-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV64ZKNE-NEXT: [[CONV1:%.*]] = sext i32 [[TMP1]] to i64
+// RV64ZKNE-NEXT: [[TMP2:%.*]] = call i64 @llvm.riscv.aes64es(i64 [[CONV]], i64 [[CONV1]])
+// RV64ZKNE-NEXT: [[CONV2:%.*]] = trunc i64 [[TMP2]] to i32
+// RV64ZKNE-NEXT: ret i32 [[CONV2]]
+//
+int aes64es(int rs1, int rs2) {
+ return __builtin_riscv_aes64es_64(rs1, rs2);
+}
+
+
+// RV64ZKNE-LABEL: @aes64esm(
+// RV64ZKNE-NEXT: entry:
+// RV64ZKNE-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV64ZKNE-NEXT: [[RS2_ADDR:%.*]] = alloca i32, align 4
+// RV64ZKNE-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV64ZKNE-NEXT: store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
+// RV64ZKNE-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV64ZKNE-NEXT: [[CONV:%.*]] = sext i32 [[TMP0]] to i64
+// RV64ZKNE-NEXT: [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
+// RV64ZKNE-NEXT: [[CONV1:%.*]] = sext i32 [[TMP1]] to i64
+// RV64ZKNE-NEXT: [[TMP2:%.*]] = call i64 @llvm.riscv.aes64esm(i64 [[CONV]], i64 [[CONV1]])
+// RV64ZKNE-NEXT: [[CONV2:%.*]] = trunc i64 [[TMP2]] to i32
+// RV64ZKNE-NEXT: ret i32 [[CONV2]]
+//
+int aes64esm(int rs1, int rs2) {
+ return __builtin_riscv_aes64esm_64(rs1, rs2);
+}
diff --git a/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
new file mode 100644
index 0000000000000..fddbac2c7b66f
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zknh.c
@@ -0,0 +1,113 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zknh -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV64ZKNH
+
+
+// RV64ZKNH-LABEL: @sha512sig0(
+// RV64ZKNH-NEXT: entry:
+// RV64ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV64ZKNH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV64ZKNH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV64ZKNH-NEXT: [[CONV:%.*]] = sext i32 [[TMP0]] to i64
+// RV64ZKNH-NEXT: [[TMP1:%.*]] = call i64 @llvm.riscv.sha512sig0(i64 [[CONV]])
+// RV64ZKNH-NEXT: [[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
+// RV64ZKNH-NEXT: ret i32 [[CONV1]]
+//
+int sha512sig0(int rs1) {
+ return __builtin_riscv_sha512sig0_64(rs1);
+}
+
+
+// RV64ZKNH-LABEL: @sha512sig1(
+// RV64ZKNH-NEXT: entry:
+// RV64ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV64ZKNH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV64ZKNH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV64ZKNH-NEXT: [[CONV:%.*]] = sext i32 [[TMP0]] to i64
+// RV64ZKNH-NEXT: [[TMP1:%.*]] = call i64 @llvm.riscv.sha512sig1(i64 [[CONV]])
+// RV64ZKNH-NEXT: [[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
+// RV64ZKNH-NEXT: ret i32 [[CONV1]]
+//
+int sha512sig1(int rs1) {
+ return __builtin_riscv_sha512sig1_64(rs1);
+}
+
+
+// RV64ZKNH-LABEL: @sha512sum0(
+// RV64ZKNH-NEXT: entry:
+// RV64ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV64ZKNH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV64ZKNH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV64ZKNH-NEXT: [[CONV:%.*]] = sext i32 [[TMP0]] to i64
+// RV64ZKNH-NEXT: [[TMP1:%.*]] = call i64 @llvm.riscv.sha512sum0(i64 [[CONV]])
+// RV64ZKNH-NEXT: [[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
+// RV64ZKNH-NEXT: ret i32 [[CONV1]]
+//
+int sha512sum0(int rs1) {
+ return __builtin_riscv_sha512sum0_64(rs1);
+}
+
+
+// RV64ZKNH-LABEL: @sha512sum1(
+// RV64ZKNH-NEXT: entry:
+// RV64ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
+// RV64ZKNH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
+// RV64ZKNH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
+// RV64ZKNH-NEXT: [[CONV:%.*]] = sext i32 [[TMP0]] to i64
+// RV64ZKNH-NEXT: [[TMP1:%.*]] = call i64 @llvm.riscv.sha512sum1(i64 [[CONV]])
+// RV64ZKNH-NEXT: [[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
+// RV64ZKNH-NEXT: ret i32 [[CONV1]]
+//
+int sha512sum1(int rs1) {
+ return __builtin_riscv_sha512sum1_64(rs1);
+}
+
+
+// RV64ZKNH-LABEL: @sha256sig0(
+// RV64ZKNH-NEXT: entry:
+// RV64ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNH-NEXT: store i64 [[RS1:%.*]], i64* [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT: [[TMP0:%.*]] = load i64, i64* [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT: [[TMP1:%.*]] = call i64 @llvm.riscv.sha256sig0.i64(i64 [[TMP0]])
+// RV64ZKNH-NEXT: ret i64 [[TMP1]]
+//
+long sha256sig0(long rs1) {
+ return __builtin_riscv_sha256sig0(rs1);
+}
+
+// RV64ZKNH-LABEL: @sha256sig1(
+// RV64ZKNH-NEXT: entry:
+// RV64ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNH-NEXT: store i64 [[RS1:%.*]], i64* [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT: [[TMP0:%.*]] = load i64, i64* [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT: [[TMP1:%.*]] = call i64 @llvm.riscv.sha256sig1.i64(i64 [[TMP0]])
+// RV64ZKNH-NEXT: ret i64 [[TMP1]]
+//
+long sha256sig1(long rs1) {
+ return __builtin_riscv_sha256sig1(rs1);
+}
+
+
+// RV64ZKNH-LABEL: @sha256sum0(
+// RV64ZKNH-NEXT: entry:
+// RV64ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNH-NEXT: store i64 [[RS1:%.*]], i64* [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT: [[TMP0:%.*]] = load i64, i64* [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT: [[TMP1:%.*]] = call i64 @llvm.riscv.sha256sum0.i64(i64 [[TMP0]])
+// RV64ZKNH-NEXT: ret i64 [[TMP1]]
+//
+long sha256sum0(long rs1) {
+ return __builtin_riscv_sha256sum0(rs1);
+}
+
+// RV64ZKNH-LABEL: @sha256sum1(
+// RV64ZKNH-NEXT: entry:
+// RV64ZKNH-NEXT: [[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKNH-NEXT: store i64 [[RS1:%.*]], i64* [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT: [[TMP0:%.*]] = load i64, i64* [[RS1_ADDR]], align 8
+// RV64ZKNH-NEXT: [[TMP1:%.*]] = call i64 @llvm.riscv.sha256sum1.i64(i64 [[TMP0]])
+// RV64ZKNH-NEXT: ret i64 [[TMP1]]
+//
+long sha256sum1(long rs1) {
+ return __builtin_riscv_sha256sum1(rs1);
+}
diff --git a/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksed.c b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksed.c
new file mode 100644
index 0000000000000..988a379130685
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksed.c
@@ -0,0 +1,33 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zksed -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV64ZKSED
+
+// RV64ZKSED-LABEL: @sm4ks(
+// RV64ZKSED-NEXT: entry:
+// RV64ZKSED-NEXT: [[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKSED-NEXT: [[RS2_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKSED-NEXT: store i64 [[RS1:%.*]], i64* [[RS1_ADDR]], align 8
+// RV64ZKSED-NEXT: store i64 [[RS2:%.*]], i64* [[RS2_ADDR]], align 8
+// RV64ZKSED-NEXT: [[TMP0:%.*]] = load i64, i64* [[RS1_ADDR]], align 8
+// RV64ZKSED-NEXT: [[TMP1:%.*]] = load i64, i64* [[RS2_ADDR]], align 8
+// RV64ZKSED-NEXT: [[TMP2:%.*]] = call i64 @llvm.riscv.sm4ks.i64(i64 [[TMP0]], i64 [[TMP1]], i8 0)
+// RV64ZKSED-NEXT: ret i64 [[TMP2]]
+//
+long sm4ks(long rs1, long rs2) {
+ return __builtin_riscv_sm4ks(rs1, rs2, 0);
+}
+
+// RV64ZKSED-LABEL: @sm4ed(
+// RV64ZKSED-NEXT: entry:
+// RV64ZKSED-NEXT: [[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKSED-NEXT: [[RS2_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKSED-NEXT: store i64 [[RS1:%.*]], i64* [[RS1_ADDR]], align 8
+// RV64ZKSED-NEXT: store i64 [[RS2:%.*]], i64* [[RS2_ADDR]], align 8
+// RV64ZKSED-NEXT: [[TMP0:%.*]] = load i64, i64* [[RS1_ADDR]], align 8
+// RV64ZKSED-NEXT: [[TMP1:%.*]] = load i64, i64* [[RS2_ADDR]], align 8
+// RV64ZKSED-NEXT: [[TMP2:%.*]] = call i64 @llvm.riscv.sm4ed.i64(i64 [[TMP0]], i64 [[TMP1]], i8 0)
+// RV64ZKSED-NEXT: ret i64 [[TMP2]]
+//
+long sm4ed(long rs1, long rs2) {
+ return __builtin_riscv_sm4ed(rs1, rs2, 0);
+}
diff --git a/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksh.c b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksh.c
new file mode 100644
index 0000000000000..5dc965f820e52
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvk-intrinsics/riscv64-zksh.c
@@ -0,0 +1,28 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zksh -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix=RV64ZKSH
+
+// RV64ZKSH-LABEL: @sm3p0(
+// RV64ZKSH-NEXT: entry:
+// RV64ZKSH-NEXT: [[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKSH-NEXT: store i64 [[RS1:%.*]], i64* [[RS1_ADDR]], align 8
+// RV64ZKSH-NEXT: [[TMP0:%.*]] = load i64, i64* [[RS1_ADDR]], align 8
+// RV64ZKSH-NEXT: [[TMP1:%.*]] = call i64 @llvm.riscv.sm3p0.i64(i64 [[TMP0]])
+// RV64ZKSH-NEXT: ret i64 [[TMP1]]
+//
+long sm3p0(long rs1) {
+ return __builtin_riscv_sm3p0(rs1);
+}
+
+
+// RV64ZKSH-LABEL: @sm3p1(
+// RV64ZKSH-NEXT: entry:
+// RV64ZKSH-NEXT: [[RS1_ADDR:%.*]] = alloca i64, align 8
+// RV64ZKSH-NEXT: store i64 [[RS1:%.*]], i64* [[RS1_ADDR]], align 8
+// RV64ZKSH-NEXT: [[TMP0:%.*]] = load i64, i64* [[RS1_ADDR]], align 8
+// RV64ZKSH-NEXT: [[TMP1:%.*]] = call i64 @llvm.riscv.sm3p1.i64(i64 [[TMP0]])
+// RV64ZKSH-NEXT: ret i64 [[TMP1]]
+//
+long sm3p1(long rs1) {
+ return __builtin_riscv_sm3p1(rs1);
+}
diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index e81dc7b700ada..88dd7bb9fe7e5 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -414,3 +414,47 @@
// RUN: %clang -target riscv32-unknown-elf -march=rv32iv1p0_zvl32b1p0 -### %s -c 2>&1 | \
// RUN: FileCheck -check-prefix=RV32-ZVL-GOODVERS %s
// RV32-ZVL-GOODVERS: "-target-feature" "+zvl32b"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izbkc1p0 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZBKC %s
+// RV32-ZBKC: "-target-feature" "+zbkc"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izbkx1p0 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZBKX %s
+// RV32-ZBKX: "-target-feature" "+zbkx"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izbkb1p0 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZBKB %s
+// RV32-ZBKB: "-target-feature" "+zbkb"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izknd1p0 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZKND %s
+// RV32-ZKND: "-target-feature" "+zknd"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izkne1p0 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZKNE %s
+// RV32-ZKNE: "-target-feature" "+zkne"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izknh1p0 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZKNH %s
+// RV32-ZKNH: "-target-feature" "+zknh"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izksed1p0 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZKSED %s
+// RV32-ZKSED: "-target-feature" "+zksed"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izksh1p0 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZKSH %s
+// RV32-ZKSH: "-target-feature" "+zksh"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izkr1p0 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZKR %s
+// RV32-ZKR: "-target-feature" "+zkr"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izkt1p0 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZKT %s
+// RV32-ZKT: "-target-feature" "+zkt"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izk1p0 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZK %s
+// RV32-ZK: "-target-feature" "+zk"
diff --git a/clang/test/Preprocessor/riscv-target-features.c b/clang/test/Preprocessor/riscv-target-features.c
index 24f2bd1a4d0b3..bbef6ce742d9f 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -31,6 +31,17 @@
// CHECK-NOT: __riscv_zfh
// CHECK-NOT: __riscv_v
// CHECK-NOT: __riscv_vector
+// CHECK-NOT: __riscv_zbkc
+// CHECK-NOT: __riscv_zbkx
+// CHECK-NOT: __riscv_zbkb
+// CHECK-NOT: __riscv_zkne
+// CHECK-NOT: __riscv_zknd
+// CHECK-NOT: __riscv_zknh
+// CHECK-NOT: __riscv_zksh
+// CHECK-NOT: __riscv_zksed
+// CHECK-NOT: __riscv_zkr
+// CHECK-NOT: __riscv_zkt
+// CHECK-NOT: __riscv_zk
// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32im -x c -E -dM %s \
// RUN: -o - | FileCheck --check-prefix=CHECK-M-EXT %s
@@ -343,3 +354,58 @@
// CHECK-ZVE32X-EXT: __riscv_v_min_vlen 32
// CHECK-ZVE32X-EXT: __riscv_vector 1
// CHECK-ZVE32X-EXT: __riscv_zve32x 1000000{{$}}
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izbkc1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZBKC-EXT %s
+// CHECK-ZBKC-EXT: __riscv_zbkc
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izbkx1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZBKX-EXT %s
+// CHECK-ZBKX-EXT: __riscv_zbkx
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izbkb1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZBKB-EXT %s
+// CHECK-ZBKB-EXT: __riscv_zbkb
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izknd1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKND-EXT %s
+// CHECK-ZKND-EXT: __riscv_zknd
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izkne1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKNE-EXT %s
+// CHECK-ZKNE-EXT: __riscv_zkne
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izknh1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKNH-EXT %s
+// CHECK-ZKNH-EXT: __riscv_zknh
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izksh1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKSH-EXT %s
+// CHECK-ZKSH-EXT: __riscv_zksh
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izksed1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKSED-EXT %s
+// CHECK-ZKSED-EXT: __riscv_zksed
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izkr1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKR-EXT %s
+// CHECK-ZKR-EXT: __riscv_zkr
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izkt1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZKT-EXT %s
+// CHECK-ZKT-EXT: __riscv_zkt
+
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izk1p0 -x c -E -dM %s -o - \
+// RUN: | FileCheck --check-prefix=CHECK-ZK-EXT %s
+// CHECK-ZK-EXT: __riscv_zk
More information about the cfe-commits
mailing list