Skip to content

Commit

Permalink
[RISCV] Remove experimental from Vector Crypto extensions (#74213)
Browse files Browse the repository at this point in the history
The RISC-V vector crypto extensions have been ratified. This patch
updates the Clang and LLVM support for these extensions to be
non-experimental, while leaving the C intrinsics as experimental since
the C intrinsics are not yet standardized.

Co-authored-by: Brandon Wu <brandon.wu@sifive.com>
  • Loading branch information
ebiggers and 4vtomat committed Dec 19, 2023
1 parent 108989b commit 0905865
Show file tree
Hide file tree
Showing 201 changed files with 1,512 additions and 1,064 deletions.
18 changes: 9 additions & 9 deletions clang/include/clang/Basic/riscv_vector.td
Original file line number Diff line number Diff line change
Expand Up @@ -2540,7 +2540,7 @@ multiclass RVVSignedWidenBinBuiltinSetVwsll

let UnMaskedPolicyScheme = HasPassthruOperand in {
// zvkb
let RequiredFeatures = ["Zvkb"] in {
let RequiredFeatures = ["Zvkb", "Experimental"] in {
defm vandn : RVVUnsignedBinBuiltinSet;
defm vbrev8 : RVVOutBuiltinSetZvbb;
defm vrev8 : RVVOutBuiltinSetZvbb;
Expand All @@ -2549,7 +2549,7 @@ let UnMaskedPolicyScheme = HasPassthruOperand in {
}

// zvbb
let RequiredFeatures = ["Zvbb"] in {
let RequiredFeatures = ["Zvbb", "Experimental"] in {
defm vbrev : RVVOutBuiltinSetZvbb;
defm vclz : RVVOutBuiltinSetZvbb;
defm vctz : RVVOutBuiltinSetZvbb;
Expand All @@ -2559,21 +2559,21 @@ let UnMaskedPolicyScheme = HasPassthruOperand in {
}

// zvbc
let RequiredFeatures = ["Zvbc"] in {
let RequiredFeatures = ["Zvbc", "Experimental"] in {
defm vclmul : RVVInt64BinBuiltinSet;
defm vclmulh : RVVInt64BinBuiltinSet;
}
}

let UnMaskedPolicyScheme = HasPolicyOperand, HasMasked = false in {
// zvkg
let RequiredFeatures = ["Zvkg"] in {
let RequiredFeatures = ["Zvkg", "Experimental"] in {
defm vghsh : RVVOutOp2BuiltinSetVVZvk;
defm vgmul : RVVOutBuiltinSetZvk<HasVV=1, HasVS=0>;
}

// zvkned
let RequiredFeatures = ["Zvkned"] in {
let RequiredFeatures = ["Zvkned", "Experimental"] in {
defm vaesdf : RVVOutBuiltinSetZvk;
defm vaesdm : RVVOutBuiltinSetZvk;
defm vaesef : RVVOutBuiltinSetZvk;
Expand All @@ -2585,28 +2585,28 @@ let UnMaskedPolicyScheme = HasPolicyOperand, HasMasked = false in {
}

// zvknha
let RequiredFeatures = ["Zvknha"] in {
let RequiredFeatures = ["Zvknha", "Experimental"] in {
defm vsha2ch : RVVOutOp2BuiltinSetVVZvk<"i">;
defm vsha2cl : RVVOutOp2BuiltinSetVVZvk<"i">;
defm vsha2ms : RVVOutOp2BuiltinSetVVZvk<"i">;
}

// zvknhb
let RequiredFeatures = ["Zvknhb"] in {
let RequiredFeatures = ["Zvknhb", "Experimental"] in {
defm vsha2ch : RVVOutOp2BuiltinSetVVZvk<"il">;
defm vsha2cl : RVVOutOp2BuiltinSetVVZvk<"il">;
defm vsha2ms : RVVOutOp2BuiltinSetVVZvk<"il">;
}

// zvksed
let RequiredFeatures = ["Zvksed"] in {
let RequiredFeatures = ["Zvksed", "Experimental"] in {
let UnMaskedPolicyScheme = HasPassthruOperand in
defm vsm4k : RVVOutOp1BuiltinSet<"vsm4k", "i", [["vi", "Uv", "UvUvKz"]]>;
defm vsm4r : RVVOutBuiltinSetZvk;
}

// zvksh
let RequiredFeatures = ["Zvksh"] in {
let RequiredFeatures = ["Zvksh", "Experimental"] in {
defm vsm3c : RVVOutOp2BuiltinSetVIZvk;
let UnMaskedPolicyScheme = HasPassthruOperand in
defm vsm3me : RVVOutOp1BuiltinSet<"vsm3me", "i", [["vv", "Uv", "UvUvUv"]]>;
Expand Down
7 changes: 4 additions & 3 deletions clang/include/clang/Support/RISCVVIntrinsicUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ class RVVIntrinsic {

// RVVRequire should be sync'ed with target features, but only
// required features used in riscv_vector.td.
enum RVVRequire : uint16_t {
enum RVVRequire : uint32_t {
RVV_REQ_None = 0,
RVV_REQ_RV64 = 1 << 0,
RVV_REQ_ZvfhminOrZvfh = 1 << 1,
Expand All @@ -503,8 +503,9 @@ enum RVVRequire : uint16_t {
RVV_REQ_Zvknhb = 1 << 13,
RVV_REQ_Zvksed = 1 << 14,
RVV_REQ_Zvksh = 1 << 15,
RVV_REQ_Experimental = 1 << 16,

LLVM_MARK_AS_BITMASK_ENUM(RVV_REQ_Zvksh)
LLVM_MARK_AS_BITMASK_ENUM(RVV_REQ_Experimental)
};

// Raw RVV intrinsic info, used to expand later.
Expand Down Expand Up @@ -536,7 +537,7 @@ struct RVVIntrinsicRecord {
uint8_t OverloadedSuffixSize;

// Required target features for this intrinsic.
uint16_t RequiredExtensions;
uint32_t RequiredExtensions;

// Supported type, mask of BasicType.
uint8_t TypeRangeMask;
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Basic/Targets/RISCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ bool RISCVTargetInfo::hasFeature(StringRef Feature) const {
.Case("riscv64", Is64Bit)
.Case("32bit", !Is64Bit)
.Case("64bit", Is64Bit)
.Case("experimental", HasExperimental)
.Default(std::nullopt);
if (Result)
return *Result;
Expand Down Expand Up @@ -382,6 +383,9 @@ bool RISCVTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,

FastUnalignedAccess = llvm::is_contained(Features, "+fast-unaligned-access");

if (llvm::is_contained(Features, "+experimental"))
HasExperimental = true;

return true;
}

Expand Down
1 change: 1 addition & 0 deletions clang/lib/Basic/Targets/RISCV.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class RISCVTargetInfo : public TargetInfo {

private:
bool FastUnalignedAccess;
bool HasExperimental = false;

public:
RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Driver/ToolChains/Arch/RISCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ static bool getArchFeatures(const Driver &D, StringRef Arch,
(*ISAInfo)->toFeatures(
Features, [&Args](const Twine &Str) { return Args.MakeArgString(Str); },
/*AddAllExtensions=*/true);

if (EnableExperimentalExtensions)
Features.push_back(Args.MakeArgString("+experimental"));

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaChecking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5389,7 +5389,7 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo &TI,
QualType Op2Type = TheCall->getArg(1)->getType();
QualType Op3Type = TheCall->getArg(2)->getType();
uint64_t ElemSize = Op1Type->isRVVType(32, false) ? 32 : 64;
if (ElemSize == 64 && !TI.hasFeature("experimental-zvknhb"))
if (ElemSize == 64 && !TI.hasFeature("zvknhb"))
return Diag(TheCall->getBeginLoc(),
diag::err_riscv_type_requires_extension)
<< Op1Type << "zvknhb";
Expand Down
19 changes: 10 additions & 9 deletions clang/lib/Sema/SemaRISCVVectorLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,16 @@ void RISCVIntrinsicManagerImpl::ConstructRVVIntrinsics(
{"xsfvfwmaccqqq", RVV_REQ_Xsfvfwmaccqqq},
{"xsfvqmaccdod", RVV_REQ_Xsfvqmaccdod},
{"xsfvqmaccqoq", RVV_REQ_Xsfvqmaccqoq},
{"experimental-zvbb", RVV_REQ_Zvbb},
{"experimental-zvbc", RVV_REQ_Zvbc},
{"experimental-zvkb", RVV_REQ_Zvkb},
{"experimental-zvkg", RVV_REQ_Zvkg},
{"experimental-zvkned", RVV_REQ_Zvkned},
{"experimental-zvknha", RVV_REQ_Zvknha},
{"experimental-zvknhb", RVV_REQ_Zvknhb},
{"experimental-zvksed", RVV_REQ_Zvksed},
{"experimental-zvksh", RVV_REQ_Zvksh}};
{"zvbb", RVV_REQ_Zvbb},
{"zvbc", RVV_REQ_Zvbc},
{"zvkb", RVV_REQ_Zvkb},
{"zvkg", RVV_REQ_Zvkg},
{"zvkned", RVV_REQ_Zvkned},
{"zvknha", RVV_REQ_Zvknha},
{"zvknhb", RVV_REQ_Zvknhb},
{"zvksed", RVV_REQ_Zvksed},
{"zvksh", RVV_REQ_Zvksh},
{"experimental", RVV_REQ_Experimental}};

// Construction of RVVIntrinsicRecords need to sync with createRVVIntrinsics
// in RISCVVEmitter.cpp.
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Support/RISCVVIntrinsicUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ raw_ostream &operator<<(raw_ostream &OS, const RVVIntrinsicRecord &Record) {
OS << (int)Record.PrototypeLength << ",";
OS << (int)Record.SuffixLength << ",";
OS << (int)Record.OverloadedSuffixSize << ",";
OS << (int)Record.RequiredExtensions << ",";
OS << Record.RequiredExtensions << ",";
OS << (int)Record.TypeRangeMask << ",";
OS << (int)Record.Log2LMULMask << ",";
OS << (int)Record.NF << ",";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
// REQUIRES: riscv-registered-target
// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zvl512b \
// RUN: -target-feature +experimental-zvbb \
// RUN: -target-feature +experimental-zvbc \
// RUN: -target-feature +experimental-zvkg \
// RUN: -target-feature +experimental-zvkned \
// RUN: -target-feature +experimental-zvknhb \
// RUN: -target-feature +experimental-zvksed \
// RUN: -target-feature +experimental-zvksh -disable-O0-optnone \
// RUN: -target-feature +zvbb \
// RUN: -target-feature +zvbc \
// RUN: -target-feature +zvkb \
// RUN: -target-feature +zvkg \
// RUN: -target-feature +zvkned \
// RUN: -target-feature +zvknhb \
// RUN: -target-feature +zvksed \
// RUN: -target-feature +zvksh \
// RUN: -target-feature +experimental \
// RUN: -disable-O0-optnone \
// RUN: -emit-llvm %s -o - | opt -S -passes=mem2reg | \
// RUN: FileCheck --check-prefix=CHECK-RV64 %s

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
// REQUIRES: riscv-registered-target
// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zvl512b \
// RUN: -target-feature +experimental-zvbb \
// RUN: -target-feature +experimental-zvbc \
// RUN: -target-feature +experimental-zvkg \
// RUN: -target-feature +experimental-zvkned \
// RUN: -target-feature +experimental-zvknhb \
// RUN: -target-feature +experimental-zvksed \
// RUN: -target-feature +experimental-zvksh -disable-O0-optnone \
// RUN: -target-feature +zvbb \
// RUN: -target-feature +zvbc \
// RUN: -target-feature +zvkb \
// RUN: -target-feature +zvkg \
// RUN: -target-feature +zvkned \
// RUN: -target-feature +zvknhb \
// RUN: -target-feature +zvksed \
// RUN: -target-feature +zvksh \
// RUN: -target-feature +experimental \
// RUN: -disable-O0-optnone \
// RUN: -emit-llvm %s -o - | opt -S -passes=mem2reg | \
// RUN: FileCheck --check-prefix=CHECK-RV64 %s

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
// REQUIRES: riscv-registered-target
// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zvl512b \
// RUN: -target-feature +experimental-zvbb \
// RUN: -target-feature +experimental-zvbc \
// RUN: -target-feature +experimental-zvkg \
// RUN: -target-feature +experimental-zvkned \
// RUN: -target-feature +experimental-zvknhb \
// RUN: -target-feature +experimental-zvksed \
// RUN: -target-feature +experimental-zvksh -disable-O0-optnone \
// RUN: -target-feature +zvbb \
// RUN: -target-feature +zvbc \
// RUN: -target-feature +zvkb \
// RUN: -target-feature +zvkg \
// RUN: -target-feature +zvkned \
// RUN: -target-feature +zvknhb \
// RUN: -target-feature +zvksed \
// RUN: -target-feature +zvksh \
// RUN: -target-feature +experimental \
// RUN: -disable-O0-optnone \
// RUN: -emit-llvm %s -o - | opt -S -passes=mem2reg | \
// RUN: FileCheck --check-prefix=CHECK-RV64 %s

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
// REQUIRES: riscv-registered-target
// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zvl512b \
// RUN: -target-feature +experimental-zvbb \
// RUN: -target-feature +experimental-zvbc \
// RUN: -target-feature +experimental-zvkg \
// RUN: -target-feature +experimental-zvkned \
// RUN: -target-feature +experimental-zvknhb \
// RUN: -target-feature +experimental-zvksed \
// RUN: -target-feature +experimental-zvksh -disable-O0-optnone \
// RUN: -target-feature +zvbb \
// RUN: -target-feature +zvbc \
// RUN: -target-feature +zvkb \
// RUN: -target-feature +zvkg \
// RUN: -target-feature +zvkned \
// RUN: -target-feature +zvknhb \
// RUN: -target-feature +zvksed \
// RUN: -target-feature +zvksh \
// RUN: -target-feature +experimental \
// RUN: -disable-O0-optnone \
// RUN: -emit-llvm %s -o - | opt -S -passes=mem2reg | \
// RUN: FileCheck --check-prefix=CHECK-RV64 %s

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
// REQUIRES: riscv-registered-target
// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zvl512b \
// RUN: -target-feature +experimental-zvbb \
// RUN: -target-feature +experimental-zvbc \
// RUN: -target-feature +experimental-zvkg \
// RUN: -target-feature +experimental-zvkned \
// RUN: -target-feature +experimental-zvknhb \
// RUN: -target-feature +experimental-zvksed \
// RUN: -target-feature +experimental-zvksh -disable-O0-optnone \
// RUN: -target-feature +zvbb \
// RUN: -target-feature +zvbc \
// RUN: -target-feature +zvkb \
// RUN: -target-feature +zvkg \
// RUN: -target-feature +zvkned \
// RUN: -target-feature +zvknhb \
// RUN: -target-feature +zvksed \
// RUN: -target-feature +zvksh \
// RUN: -target-feature +experimental \
// RUN: -disable-O0-optnone \
// RUN: -emit-llvm %s -o - | opt -S -passes=mem2reg | \
// RUN: FileCheck --check-prefix=CHECK-RV64 %s

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
// REQUIRES: riscv-registered-target
// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zvl512b \
// RUN: -target-feature +experimental-zvbb \
// RUN: -target-feature +experimental-zvbc \
// RUN: -target-feature +experimental-zvkg \
// RUN: -target-feature +experimental-zvkned \
// RUN: -target-feature +experimental-zvknhb \
// RUN: -target-feature +experimental-zvksed \
// RUN: -target-feature +experimental-zvksh -disable-O0-optnone \
// RUN: -target-feature +zvbb \
// RUN: -target-feature +zvbc \
// RUN: -target-feature +zvkb \
// RUN: -target-feature +zvkg \
// RUN: -target-feature +zvkned \
// RUN: -target-feature +zvknhb \
// RUN: -target-feature +zvksed \
// RUN: -target-feature +zvksh \
// RUN: -target-feature +experimental \
// RUN: -disable-O0-optnone \
// RUN: -emit-llvm %s -o - | opt -S -passes=mem2reg | \
// RUN: FileCheck --check-prefix=CHECK-RV64 %s

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
// REQUIRES: riscv-registered-target
// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zvl512b \
// RUN: -target-feature +experimental-zvbb \
// RUN: -target-feature +experimental-zvbc \
// RUN: -target-feature +experimental-zvkg \
// RUN: -target-feature +experimental-zvkned \
// RUN: -target-feature +experimental-zvknhb \
// RUN: -target-feature +experimental-zvksed \
// RUN: -target-feature +experimental-zvksh -disable-O0-optnone \
// RUN: -target-feature +zvbb \
// RUN: -target-feature +zvbc \
// RUN: -target-feature +zvkb \
// RUN: -target-feature +zvkg \
// RUN: -target-feature +zvkned \
// RUN: -target-feature +zvknhb \
// RUN: -target-feature +zvksed \
// RUN: -target-feature +zvksh \
// RUN: -target-feature +experimental \
// RUN: -disable-O0-optnone \
// RUN: -emit-llvm %s -o - | opt -S -passes=mem2reg | \
// RUN: FileCheck --check-prefix=CHECK-RV64 %s

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
// REQUIRES: riscv-registered-target
// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zvl512b \
// RUN: -target-feature +experimental-zvbb \
// RUN: -target-feature +experimental-zvbc \
// RUN: -target-feature +experimental-zvkb \
// RUN: -target-feature +experimental-zvkg \
// RUN: -target-feature +experimental-zvkned \
// RUN: -target-feature +experimental-zvknhb \
// RUN: -target-feature +experimental-zvksed \
// RUN: -target-feature +experimental-zvksh -disable-O0-optnone \
// RUN: -target-feature +zvbb \
// RUN: -target-feature +zvbc \
// RUN: -target-feature +zvkb \
// RUN: -target-feature +zvkg \
// RUN: -target-feature +zvkned \
// RUN: -target-feature +zvknhb \
// RUN: -target-feature +zvksed \
// RUN: -target-feature +zvksh \
// RUN: -target-feature +experimental \
// RUN: -disable-O0-optnone \
// RUN: -emit-llvm %s -o - | opt -S -passes=mem2reg | \
// RUN: FileCheck --check-prefix=CHECK-RV64 %s

Expand Down
Loading

0 comments on commit 0905865

Please sign in to comment.