Author: Wang Pengcheng Date: 2025-04-14T12:56:33+08:00 New Revision: 21ff45dea1601d6d12438b5201ff09b8726899be
URL: https://github.com/llvm/llvm-project/commit/21ff45dea1601d6d12438b5201ff09b8726899be DIFF: https://github.com/llvm/llvm-project/commit/21ff45dea1601d6d12438b5201ff09b8726899be.diff LOG: Revert "[RISCV][NFC] Make generated intrinsic records more human-readable (#133710)" This reverts commit d0cf5cd5f9790dc21396936d076389c3be1a9599. Error: "declaration of ‘clang::RISCV::RequiredExtensions {anonymous}::SemaRecord::RequiredExtensions’ changes meaning of ‘RequiredExtensions’ [-fpermissive]" Added: Modified: clang/include/clang/Support/RISCVVIntrinsicUtils.h clang/lib/Sema/SemaRISCV.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 dd0817f225258..8f2a4f54a1b7f 100644 --- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h +++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h @@ -11,7 +11,6 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/BitmaskEnum.h" -#include "llvm/ADT/Bitset.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include <cstdint> @@ -377,8 +376,6 @@ enum PolicyScheme : uint8_t { HasPolicyOperand, }; -llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, enum PolicyScheme PS); - // TODO refactor RVVIntrinsic class design after support all intrinsic // combination. This represents an instantiation of an intrinsic with a // particular type and prototype @@ -510,23 +507,6 @@ enum RVVRequire { RVV_REQ_NUM, }; -llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, enum RVVRequire Require); - -struct RequiredExtensions { - llvm::Bitset<RVV_REQ_NUM> Bits; - RequiredExtensions() {} - RequiredExtensions(std::initializer_list<RVVRequire> Init) { - for (auto I : Init) - Bits.set(I); - } - - void set(unsigned I) { Bits.set(I); } - bool operator[](unsigned I) const { return Bits[I]; } -}; - -llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, - const RequiredExtensions &Exts); - // Raw RVV intrinsic info, used to expand later. // This struct is highly compact for minimized code size. struct RVVIntrinsicRecord { @@ -538,7 +518,7 @@ struct RVVIntrinsicRecord { const char *OverloadedName; // Required target features for this intrinsic. - RequiredExtensions RequiredExtensions; + uint32_t RequiredExtensions[(RVV_REQ_NUM + 31) / 32]; // Prototype for this intrinsic, index of RVVSignatureTable. uint16_t PrototypeIndex; diff --git a/clang/lib/Sema/SemaRISCV.cpp b/clang/lib/Sema/SemaRISCV.cpp index b9f843b1920a1..746609604d1ba 100644 --- a/clang/lib/Sema/SemaRISCV.cpp +++ b/clang/lib/Sema/SemaRISCV.cpp @@ -232,7 +232,8 @@ void RISCVIntrinsicManagerImpl::ConstructRVVIntrinsics( for (auto &Record : Recs) { // Check requirements. if (llvm::any_of(FeatureCheckList, [&](const auto &Item) { - return Record.RequiredExtensions[Item.second] && + return ((Record.RequiredExtensions[Item.second / 32] & + (1U << (Item.second % 32))) != 0) && !TI.hasFeature(Item.first); })) continue; diff --git a/clang/lib/Support/RISCVVIntrinsicUtils.cpp b/clang/lib/Support/RISCVVIntrinsicUtils.cpp index ee4d1e88e0ab8..e44fbb0181830 100644 --- a/clang/lib/Support/RISCVVIntrinsicUtils.cpp +++ b/clang/lib/Support/RISCVVIntrinsicUtils.cpp @@ -1196,91 +1196,36 @@ SmallVector<PrototypeDescriptor> parsePrototypes(StringRef Prototypes) { return PrototypeDescriptors; } -#define STRINGIFY(NAME) \ - case NAME: \ - OS << #NAME; \ - break; - -llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, enum PolicyScheme PS) { - switch (PS) { - STRINGIFY(SchemeNone) - STRINGIFY(HasPassthruOperand) - STRINGIFY(HasPolicyOperand) - } - return OS; -} - -llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, enum RVVRequire Require) { - switch (Require) { - STRINGIFY(RVV_REQ_RV64) - STRINGIFY(RVV_REQ_Zvfhmin) - STRINGIFY(RVV_REQ_Xsfvcp) - STRINGIFY(RVV_REQ_Xsfvfnrclipxfqf) - STRINGIFY(RVV_REQ_Xsfvfwmaccqqq) - STRINGIFY(RVV_REQ_Xsfvqmaccdod) - STRINGIFY(RVV_REQ_Xsfvqmaccqoq) - STRINGIFY(RVV_REQ_Zvbb) - STRINGIFY(RVV_REQ_Zvbc) - STRINGIFY(RVV_REQ_Zvkb) - STRINGIFY(RVV_REQ_Zvkg) - STRINGIFY(RVV_REQ_Zvkned) - STRINGIFY(RVV_REQ_Zvknha) - STRINGIFY(RVV_REQ_Zvknhb) - STRINGIFY(RVV_REQ_Zvksed) - STRINGIFY(RVV_REQ_Zvksh) - STRINGIFY(RVV_REQ_Zvfbfwma) - STRINGIFY(RVV_REQ_Zvfbfmin) - STRINGIFY(RVV_REQ_Zvfh) - STRINGIFY(RVV_REQ_Experimental) - default: - llvm_unreachable("Unsupported RVVRequire!"); - break; - } - return OS; -} - -#undef STRINGIFY - -llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, - const RequiredExtensions &Exts) { - OS << "{"; - ListSeparator LS; - for (unsigned I = 0; I < RVV_REQ_NUM; I++) - if (Exts[I]) - OS << LS << static_cast<RVVRequire>(I); - OS << "}"; - return OS; -} - raw_ostream &operator<<(raw_ostream &OS, const RVVIntrinsicRecord &Record) { OS << "{"; - OS << "/*Name=*/\"" << Record.Name << "\", "; + OS << "\"" << Record.Name << "\","; if (Record.OverloadedName == nullptr || StringRef(Record.OverloadedName).empty()) - OS << "/*OverloadedName=*/nullptr, "; + OS << "nullptr,"; else - OS << "/*OverloadedName=*/\"" << Record.OverloadedName << "\", "; - OS << "/*RequiredExtensions=*/" << Record.RequiredExtensions << ", "; - OS << "/*PrototypeIndex=*/" << Record.PrototypeIndex << ", "; - OS << "/*SuffixIndex=*/" << Record.SuffixIndex << ", "; - OS << "/*OverloadedSuffixIndex=*/" << Record.OverloadedSuffixIndex << ", "; - OS << "/*PrototypeLength=*/" << (int)Record.PrototypeLength << ", "; - OS << "/*SuffixLength=*/" << (int)Record.SuffixLength << ", "; - OS << "/*OverloadedSuffixSize=*/" << (int)Record.OverloadedSuffixSize << ", "; - OS << "/*TypeRangeMask=*/" << (int)Record.TypeRangeMask << ", "; - OS << "/*Log2LMULMask=*/" << (int)Record.Log2LMULMask << ", "; - OS << "/*NF=*/" << (int)Record.NF << ", "; - OS << "/*HasMasked=*/" << (int)Record.HasMasked << ", "; - OS << "/*HasVL=*/" << (int)Record.HasVL << ", "; - OS << "/*HasMaskedOffOperand=*/" << (int)Record.HasMaskedOffOperand << ", "; - OS << "/*HasTailPolicy=*/" << (int)Record.HasTailPolicy << ", "; - OS << "/*HasMaskPolicy=*/" << (int)Record.HasMaskPolicy << ", "; - OS << "/*HasFRMRoundModeOp=*/" << (int)Record.HasFRMRoundModeOp << ", "; - OS << "/*IsTuple=*/" << (int)Record.IsTuple << ", "; - OS << "/*UnMaskedPolicyScheme=*/" << (PolicyScheme)Record.UnMaskedPolicyScheme - << ", "; - OS << "/*MaskedPolicyScheme=*/" << (PolicyScheme)Record.MaskedPolicyScheme - << ", "; + OS << "\"" << Record.OverloadedName << "\","; + OS << "{"; + for (uint32_t Exts : Record.RequiredExtensions) + OS << Exts << ','; + OS << "},"; + OS << Record.PrototypeIndex << ","; + OS << Record.SuffixIndex << ","; + OS << Record.OverloadedSuffixIndex << ","; + OS << (int)Record.PrototypeLength << ","; + OS << (int)Record.SuffixLength << ","; + OS << (int)Record.OverloadedSuffixSize << ","; + 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 << (int)Record.HasTailPolicy << ","; + OS << (int)Record.HasMaskPolicy << ","; + OS << (int)Record.HasFRMRoundModeOp << ","; + OS << (int)Record.IsTuple << ","; + OS << (int)Record.UnMaskedPolicyScheme << ","; + OS << (int)Record.MaskedPolicyScheme << ","; OS << "},\n"; return OS; } diff --git a/clang/utils/TableGen/RISCVVEmitter.cpp b/clang/utils/TableGen/RISCVVEmitter.cpp index b264fb9d822ef..02e5e51f6d095 100644 --- a/clang/utils/TableGen/RISCVVEmitter.cpp +++ b/clang/utils/TableGen/RISCVVEmitter.cpp @@ -45,7 +45,7 @@ struct SemaRecord { unsigned Log2LMULMask; // Required extensions for this intrinsic. - RequiredExtensions RequiredExtensions; + uint32_t RequiredExtensions[(RVV_REQ_NUM + 31) / 32]; // Prototype for this intrinsic. SmallVector<PrototypeDescriptor> Prototype; @@ -769,6 +769,7 @@ void RVVEmitter::createRVVIntrinsics( SR.Log2LMULMask = Log2LMULMask; + memset(SR.RequiredExtensions, 0, sizeof(SR.RequiredExtensions)); for (auto RequiredFeature : RequiredFeatures) { unsigned RequireExt = StringSwitch<RVVRequire>(RequiredFeature) @@ -792,7 +793,7 @@ void RVVEmitter::createRVVIntrinsics( .Case("Zvfbfmin", RVV_REQ_Zvfbfmin) .Case("Zvfh", RVV_REQ_Zvfh) .Case("Experimental", RVV_REQ_Experimental); - SR.RequiredExtensions.set(RequireExt); + SR.RequiredExtensions[RequireExt / 32] |= 1U << (RequireExt % 32); } SR.NF = NF; @@ -836,7 +837,8 @@ void RVVEmitter::createRVVIntrinsicRecords(std::vector<RVVIntrinsicRecord> &Out, R.PrototypeLength = SR.Prototype.size(); R.SuffixLength = SR.Suffix.size(); R.OverloadedSuffixSize = SR.OverloadedSuffix.size(); - R.RequiredExtensions = SR.RequiredExtensions; + memcpy(R.RequiredExtensions, SR.RequiredExtensions, + sizeof(R.RequiredExtensions)); R.TypeRangeMask = SR.TypeRangeMask; R.Log2LMULMask = SR.Log2LMULMask; R.NF = SR.NF; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits