diff --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h b/clang/include/clang/Support/RISCVVIntrinsicUtils.h --- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h +++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h @@ -366,9 +366,6 @@ // Prototype for this intrinsic, index of RVVSignatureTable. uint16_t PrototypeIndex; - // Prototype for masked intrinsic, index of RVVSignatureTable. - uint16_t MaskedPrototypeIndex; - // Suffix of intrinsic name, index of RVVSignatureTable. uint16_t SuffixIndex; @@ -378,9 +375,6 @@ // Length of the prototype. uint8_t PrototypeLength; - // Length of prototype of masked intrinsic. - uint8_t MaskedPrototypeLength; - // Length of intrinsic name suffix. uint8_t SuffixLength; @@ -398,6 +392,10 @@ // Number of field, large than 1 if it's segment load/store. uint8_t NF; + + bool HasMasked : 1; + bool HasVL : 1; + bool HasMaskedOffOperand : 1; }; llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, diff --git a/clang/lib/Sema/SemaRVVLookup.cpp b/clang/lib/Sema/SemaRVVLookup.cpp --- a/clang/lib/Sema/SemaRVVLookup.cpp +++ b/clang/lib/Sema/SemaRVVLookup.cpp @@ -174,10 +174,17 @@ for (auto &Record : RVVIntrinsicRecords) { // Create Intrinsics for each type and LMUL. BasicType BaseType = BasicType::Unknown; - auto ProtoSeq = + auto BasicProtoSeq = ProtoSeq2ArrayRef(Record.PrototypeIndex, Record.PrototypeLength); - auto ProtoMaskSeq = ProtoSeq2ArrayRef(Record.MaskedPrototypeIndex, - Record.MaskedPrototypeLength); + + auto ProtoSeq = RVVIntrinsic::computeBuiltinTypes( + BasicProtoSeq, /*IsMasked=*/false, + /*HasMaskedOffOperand=*/false, Record.HasVL, Record.NF); + + auto ProtoMaskSeq = RVVIntrinsic::computeBuiltinTypes( + BasicProtoSeq, /*IsMasked=*/true, Record.HasMaskedOffOperand, + Record.HasVL, Record.NF); + auto SuffixProto = ProtoSeq2ArrayRef(Record.SuffixIndex, Record.SuffixLength); auto MangledSuffixProto = ProtoSeq2ArrayRef(Record.OverloadedSuffixIndex, @@ -232,9 +239,7 @@ // Create non-masked intrinsic. InitRVVIntrinsic(Record, SuffixStr, OverloadedSuffixStr, false, *Types); - bool HasMask = Record.MaskedPrototypeLength != 0; - - if (HasMask) { + if (Record.HasMasked) { // Create masked intrinsic. Optional MaskTypes = RVVType::computeTypes( BaseType, Log2LMUL, Record.NF, ProtoMaskSeq); diff --git a/clang/lib/Support/RISCVVIntrinsicUtils.cpp b/clang/lib/Support/RISCVVIntrinsicUtils.cpp --- a/clang/lib/Support/RISCVVIntrinsicUtils.cpp +++ b/clang/lib/Support/RISCVVIntrinsicUtils.cpp @@ -983,17 +983,18 @@ else OS << "\"" << Record.OverloadedName << "\","; OS << Record.PrototypeIndex << ","; - OS << Record.MaskedPrototypeIndex << ","; OS << Record.SuffixIndex << ","; OS << Record.OverloadedSuffixIndex << ","; OS << (int)Record.PrototypeLength << ","; - OS << (int)Record.MaskedPrototypeLength << ","; OS << (int)Record.SuffixLength << ","; OS << (int)Record.OverloadedSuffixSize << ","; OS << (int)Record.RequiredExtension << ","; OS << (int)Record.TypeRangeMask << ","; OS << (int)Record.Log2LMULMask << ","; OS << (int)Record.NF << ","; + OS << (int)Record.HasMasked << ","; + OS << (int)Record.HasVL << ","; + OS << (int)Record.HasMaskedOffOperand << ","; OS << "},\n"; return OS; } diff --git a/clang/utils/TableGen/RISCVVEmitter.cpp b/clang/utils/TableGen/RISCVVEmitter.cpp --- a/clang/utils/TableGen/RISCVVEmitter.cpp +++ b/clang/utils/TableGen/RISCVVEmitter.cpp @@ -50,9 +50,6 @@ // Prototype for this intrinsic. SmallVector Prototype; - // Prototype for masked intrinsic. - SmallVector MaskedPrototype; - // Suffix of intrinsic name. SmallVector Suffix; @@ -61,6 +58,10 @@ // Number of field, large than 1 if it's segment load/store. unsigned NF; + + bool HasMasked :1; + bool HasVL :1; + bool HasMaskedOffOperand :1; }; class RVVEmitter { @@ -478,11 +479,11 @@ } SR.NF = NF; + SR.HasMasked = HasMasked; + SR.HasVL = HasVL; + SR.HasMaskedOffOperand = HasMaskedOffOperand; - SR.Prototype = std::move(Prototype); - - if (HasMasked) - SR.MaskedPrototype = std::move(MaskedPrototype); + SR.Prototype = std::move(BasicPrototype); auto InitSuffixtype = [&](SmallVectorImpl &PS, StringRef Prototypes) { @@ -566,7 +567,6 @@ for (const auto &SemaRecord : SemaRecords) { InsertToSignatureSet(SemaRecord.Prototype); - InsertToSignatureSet(SemaRecord.MaskedPrototype); InsertToSignatureSet(SemaRecord.Suffix); InsertToSignatureSet(SemaRecord.OverloadedSuffix); } @@ -585,17 +585,18 @@ Record.Name = SR.Name.c_str(); Record.OverloadedName = SR.OverloadedName.c_str(); Record.PrototypeIndex = GetSemaSignatureIndex(SR.Prototype); - Record.MaskedPrototypeIndex = GetSemaSignatureIndex(SR.MaskedPrototype); Record.SuffixIndex = GetSemaSignatureIndex(SR.Suffix); Record.OverloadedSuffixIndex = GetSemaSignatureIndex(SR.OverloadedSuffix); Record.PrototypeLength = SR.Prototype.size(); - Record.MaskedPrototypeLength = SR.MaskedPrototype.size(); Record.SuffixLength = SR.Suffix.size(); Record.OverloadedSuffixSize = SR.OverloadedSuffix.size(); Record.RequiredExtension = SR.RequiredExtension; Record.TypeRangeMask = SR.TypeRangeMask; Record.Log2LMULMask = SR.Log2LMULMask; Record.NF = SR.NF; + Record.HasMasked = SR.HasMasked; + Record.HasVL = SR.HasVL; + Record.HasMaskedOffOperand = SR.HasMaskedOffOperand; Out.push_back(Record); } }