Author: Zakk Chen Date: 2022-07-26T10:15:04Z New Revision: 93f8657c743ba9ce9696e5f0c9487207cf8ccb6b
URL: https://github.com/llvm/llvm-project/commit/93f8657c743ba9ce9696e5f0c9487207cf8ccb6b DIFF: https://github.com/llvm/llvm-project/commit/93f8657c743ba9ce9696e5f0c9487207cf8ccb6b.diff LOG: [RISCV][Clang] Refactor RISCVVEmitter. (NFC) Remove MaskedPrototype and add several fields in RVVIntrinsicRecord, compute Prototype in runtime. Reviewed By: rogfer01 Differential Revision: https://reviews.llvm.org/D126741 Added: Modified: clang/include/clang/Support/RISCVVIntrinsicUtils.h clang/lib/Sema/SemaRISCVVectorLookup.cpp clang/lib/Support/RISCVVIntrinsicUtils.cpp clang/utils/TableGen/RISCVVEmitter.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h b/clang/include/clang/Support/RISCVVIntrinsicUtils.h index 44c4125a85da..7ee4896eea09 100644 --- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h +++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h @@ -371,9 +371,6 @@ struct RVVIntrinsicRecord { // 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; @@ -383,9 +380,6 @@ struct RVVIntrinsicRecord { // Length of the prototype. uint8_t PrototypeLength; - // Length of prototype of masked intrinsic. - uint8_t MaskedPrototypeLength; - // Length of intrinsic name suffix. uint8_t SuffixLength; @@ -403,6 +397,10 @@ struct RVVIntrinsicRecord { // Number of fields, greater 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/SemaRISCVVectorLookup.cpp b/clang/lib/Sema/SemaRISCVVectorLookup.cpp index 8306b40174f8..50fd841c231b 100644 --- a/clang/lib/Sema/SemaRISCVVectorLookup.cpp +++ b/clang/lib/Sema/SemaRISCVVectorLookup.cpp @@ -178,14 +178,23 @@ void RISCVIntrinsicManagerImpl::InitIntrinsicList() { for (auto &Record : RVVIntrinsicRecords) { // Create Intrinsics for each type and LMUL. BasicType BaseType = BasicType::Unknown; - ArrayRef<PrototypeDescriptor> ProtoSeq = + ArrayRef<PrototypeDescriptor> BasicProtoSeq = ProtoSeq2ArrayRef(Record.PrototypeIndex, Record.PrototypeLength); - ArrayRef<PrototypeDescriptor> ProtoMaskSeq = ProtoSeq2ArrayRef( - Record.MaskedPrototypeIndex, Record.MaskedPrototypeLength); ArrayRef<PrototypeDescriptor> SuffixProto = ProtoSeq2ArrayRef(Record.SuffixIndex, Record.SuffixLength); ArrayRef<PrototypeDescriptor> OverloadedSuffixProto = ProtoSeq2ArrayRef( Record.OverloadedSuffixIndex, Record.OverloadedSuffixSize); + + llvm::SmallVector<PrototypeDescriptor> ProtoSeq = + RVVIntrinsic::computeBuiltinTypes(BasicProtoSeq, /*IsMasked=*/false, + /*HasMaskedOffOperand=*/false, + Record.HasVL, Record.NF); + + llvm::SmallVector<PrototypeDescriptor> ProtoMaskSeq = + RVVIntrinsic::computeBuiltinTypes(BasicProtoSeq, /*IsMasked=*/true, + Record.HasMaskedOffOperand, + Record.HasVL, Record.NF); + for (unsigned int TypeRangeMaskShift = 0; TypeRangeMaskShift <= static_cast<unsigned int>(BasicType::MaxOffset); ++TypeRangeMaskShift) { @@ -235,7 +244,7 @@ void RISCVIntrinsicManagerImpl::InitIntrinsicList() { // Create non-masked intrinsic. InitRVVIntrinsic(Record, SuffixStr, OverloadedSuffixStr, false, *Types); - if (Record.MaskedPrototypeLength != 0) { + if (Record.HasMasked) { // Create masked intrinsic. Optional<RVVTypes> MaskTypes = RVVType::computeTypes( BaseType, Log2LMUL, Record.NF, ProtoMaskSeq); diff --git a/clang/lib/Support/RISCVVIntrinsicUtils.cpp b/clang/lib/Support/RISCVVIntrinsicUtils.cpp index be2cb380aeb5..513e6376f5ae 100644 --- a/clang/lib/Support/RISCVVIntrinsicUtils.cpp +++ b/clang/lib/Support/RISCVVIntrinsicUtils.cpp @@ -981,17 +981,18 @@ raw_ostream &operator<<(raw_ostream &OS, const RVVIntrinsicRecord &Record) { 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.RequiredExtensions << ","; 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 index a60954506bbc..fc5f705b7fd4 100644 --- a/clang/utils/TableGen/RISCVVEmitter.cpp +++ b/clang/utils/TableGen/RISCVVEmitter.cpp @@ -50,9 +50,6 @@ struct SemaRecord { // Prototype for this intrinsic. SmallVector<PrototypeDescriptor> Prototype; - // Prototype for masked intrinsic. - SmallVector<PrototypeDescriptor> MaskedPrototype; - // Suffix of intrinsic name. SmallVector<PrototypeDescriptor> Suffix; @@ -61,6 +58,10 @@ struct SemaRecord { // Number of field, large than 1 if it's segment load/store. unsigned NF; + + bool HasMasked :1; + bool HasVL :1; + bool HasMaskedOffOperand :1; }; // Compressed function signature table. @@ -241,7 +242,6 @@ void SemaSignatureTable::init(ArrayRef<SemaRecord> SemaRecords) { llvm::for_each(SemaRecords, [&](const SemaRecord &SR) { InsertToSignatureSet(SR.Prototype); - InsertToSignatureSet(SR.MaskedPrototype); InsertToSignatureSet(SR.Suffix); InsertToSignatureSet(SR.OverloadedSuffix); }); @@ -583,12 +583,10 @@ void RVVEmitter::createRVVIntrinsics( } SR.NF = NF; - - SR.Prototype = std::move(Prototype); - - if (HasMasked) - SR.MaskedPrototype = std::move(MaskedPrototype); - + SR.HasMasked = HasMasked; + SR.HasVL = HasVL; + SR.HasMaskedOffOperand = HasMaskedOffOperand; + SR.Prototype = std::move(BasicPrototype); SR.Suffix = parsePrototypes(SuffixProto); SR.OverloadedSuffix = parsePrototypes(OverloadedSuffixProto); @@ -616,22 +614,21 @@ void RVVEmitter::createRVVIntrinsicRecords(std::vector<RVVIntrinsicRecord> &Out, R.Name = SR.Name.c_str(); R.OverloadedName = SR.OverloadedName.c_str(); R.PrototypeIndex = SST.getIndex(SR.Prototype); - R.MaskedPrototypeIndex = SST.getIndex(SR.MaskedPrototype); R.SuffixIndex = SST.getIndex(SR.Suffix); R.OverloadedSuffixIndex = SST.getIndex(SR.OverloadedSuffix); R.PrototypeLength = SR.Prototype.size(); - R.MaskedPrototypeLength = SR.MaskedPrototype.size(); R.SuffixLength = SR.Suffix.size(); R.OverloadedSuffixSize = SR.OverloadedSuffix.size(); R.RequiredExtensions = SR.RequiredExtensions; R.TypeRangeMask = SR.TypeRangeMask; R.Log2LMULMask = SR.Log2LMULMask; R.NF = SR.NF; + R.HasMasked = SR.HasMasked; + R.HasVL = SR.HasVL; + R.HasMaskedOffOperand = SR.HasMaskedOffOperand; assert(R.PrototypeIndex != static_cast<uint16_t>(SemaSignatureTable::INVALID_INDEX)); - assert(R.MaskedPrototypeIndex != - static_cast<uint16_t>(SemaSignatureTable::INVALID_INDEX)); assert(R.SuffixIndex != static_cast<uint16_t>(SemaSignatureTable::INVALID_INDEX)); assert(R.OverloadedSuffixIndex != _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits