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 @@ -180,8 +180,7 @@ }; class RVVType; -using RVVTypePtr = RVVType *; -using RVVTypes = std::vector; +using RVVTypes = std::vector; // This class is compact representation of a valid and invalid RVVType. class RVVType { @@ -284,8 +283,8 @@ static llvm::Optional computeTypes(BasicType BT, int Log2LMUL, unsigned NF, llvm::ArrayRef Prototype); - static llvm::Optional computeType(BasicType BT, int Log2LMUL, - PrototypeDescriptor Proto); + static llvm::Optional computeType(BasicType BT, int Log2LMUL, + PrototypeDescriptor Proto); }; enum PolicyScheme : uint8_t { @@ -315,7 +314,7 @@ bool SupportOverloading; bool HasBuiltinAlias; std::string ManualCodegen; - RVVTypePtr OutputType; // Builtin output type + RVVType OutputType; // Builtin output type RVVTypes InputTypes; // Builtin input types // The types we use to obtain the specific LLVM intrinsic. They are index of // InputTypes. -1 means the return type. @@ -335,7 +334,7 @@ unsigned NF, Policy DefaultPolicy, bool IsPrototypeDefaultTU); ~RVVIntrinsic() = default; - RVVTypePtr getOutputType() const { return OutputType; } + RVVType getOutputType() const { return OutputType; } const RVVTypes &getInputTypes() const { return InputTypes; } llvm::StringRef getBuiltinName() const { return BuiltinName; } llvm::StringRef getName() const { return Name; } @@ -377,13 +376,13 @@ llvm::ArrayRef PrototypeDescriptors); static llvm::SmallVector - computeBuiltinTypes(llvm::ArrayRef Prototype, - bool IsMasked, bool HasMaskedOffOperand, bool HasVL, - unsigned NF, bool IsPrototypeDefaultTU, - PolicyScheme DefaultScheme, - Policy DefaultPolicy = Policy::PolicyNone); + computeBuiltinTypes(llvm::ArrayRef Prototype, + bool IsMasked, bool HasMaskedOffOperand, bool HasVL, + unsigned NF, bool IsPrototypeDefaultTU, + PolicyScheme DefaultScheme, + Policy DefaultPolicy = Policy::PolicyNone); static llvm::SmallVector - getSupportedMaskedPolicies(bool HasTailPolicy, bool HasMaskPolicy); + getSupportedMaskedPolicies(bool HasTailPolicy, bool HasMaskPolicy); static void updateNamesAndPolicy(bool IsMasked, bool HasPolicy, bool IsPrototypeDefaultTU, std::string &Name, diff --git a/clang/lib/Sema/SemaRISCVVectorLookup.cpp b/clang/lib/Sema/SemaRISCVVectorLookup.cpp --- a/clang/lib/Sema/SemaRISCVVectorLookup.cpp +++ b/clang/lib/Sema/SemaRISCVVectorLookup.cpp @@ -354,16 +354,15 @@ bool IsOverload) { ASTContext &Context = S.Context; RVVIntrinsicDef &IDef = IntrinsicList[Index]; - RVVTypes Sigs = IDef.Signature; + RVVTypes &Sigs = IDef.Signature; size_t SigLength = Sigs.size(); - RVVType *ReturnType = Sigs[0]; - QualType RetType = RVVType2Qual(Context, ReturnType); + QualType RetType = RVVType2Qual(Context, &Sigs[0]); SmallVector ArgTypes; QualType BuiltinFuncType; // Skip return type, and convert RVVType to QualType for arguments. for (size_t i = 1; i < SigLength; ++i) - ArgTypes.push_back(RVVType2Qual(Context, Sigs[i])); + ArgTypes.push_back(RVVType2Qual(Context, &Sigs[i])); FunctionProtoType::ExtProtoInfo PI( Context.getDefaultCallingConvention(false, false, true)); 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 @@ -803,42 +803,11 @@ return Types; } -// Compute the hash value of RVVType, used for cache the result of computeType. -static uint64_t computeRVVTypeHashValue(BasicType BT, int Log2LMUL, - PrototypeDescriptor Proto) { - // Layout of hash value: - // 0 8 16 24 32 40 - // | Log2LMUL + 3 | BT | Proto.PT | Proto.TM | Proto.VTM | - assert(Log2LMUL >= -3 && Log2LMUL <= 3); - return (Log2LMUL + 3) | (static_cast(BT) & 0xff) << 8 | - ((uint64_t)(Proto.PT & 0xff) << 16) | - ((uint64_t)(Proto.TM & 0xff) << 24) | - ((uint64_t)(Proto.VTM & 0xff) << 32); -} - -Optional RVVType::computeType(BasicType BT, int Log2LMUL, +Optional RVVType::computeType(BasicType BT, int Log2LMUL, PrototypeDescriptor Proto) { - // Concat BasicType, LMUL and Proto as key - static std::unordered_map LegalTypes; - static std::set IllegalTypes; - uint64_t Idx = computeRVVTypeHashValue(BT, Log2LMUL, Proto); - // Search first - auto It = LegalTypes.find(Idx); - if (It != LegalTypes.end()) - return &(It->second); - - if (IllegalTypes.count(Idx)) - return llvm::None; - - // Compute type and record the result. RVVType T(BT, Log2LMUL, Proto); - if (T.isValid()) { - // Record legal type index and value. - LegalTypes.insert({Idx, T}); - return &(LegalTypes[Idx]); - } - // Record illegal type index. - IllegalTypes.insert(Idx); + if (T.isValid()) + return T; return llvm::None; } @@ -892,9 +861,9 @@ std::string RVVIntrinsic::getBuiltinTypeStr() const { std::string S; - S += OutputType->getBuiltinStr(); + S += OutputType.getBuiltinStr(); for (const auto &T : InputTypes) { - S += T->getBuiltinStr(); + S += T.getBuiltinStr(); } return S; } @@ -905,7 +874,7 @@ SmallVector SuffixStrs; for (auto PD : PrototypeDescriptors) { auto T = RVVType::computeType(Type, Log2LMUL, PD); - SuffixStrs.push_back((*T)->getShortStr()); + SuffixStrs.push_back((*T).getShortStr()); } return join(SuffixStrs, "_"); } 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 @@ -177,7 +177,7 @@ // Cast pointer operand of vector load intrinsic. for (const auto &I : enumerate(RVVI->getInputTypes())) { - if (I.value()->isPointer()) { + if (I.value().isPointer()) { assert(RVVI->getIntrinsicTypes().front() == -1 && "RVVI should be vector load intrinsic."); OS << " Ops[" << I.index() << "] = Builder.CreateBitCast(Ops["; @@ -342,7 +342,7 @@ printHeaderCode(OS); auto printType = [&](auto T) { - OS << "typedef " << T->getClangBuiltinStr() << " " << T->getTypeStr() + OS << "typedef " << T.getClangBuiltinStr() << " " << T.getTypeStr() << ";\n"; };