diff options
Diffstat (limited to 'clang/include/clang')
233 files changed, 15709 insertions, 6467 deletions
diff --git a/clang/include/clang/AST/ASTConcept.h b/clang/include/clang/AST/ASTConcept.h index 71bf14a87865..d0526f4fa5c5 100644 --- a/clang/include/clang/AST/ASTConcept.h +++ b/clang/include/clang/AST/ASTConcept.h @@ -14,12 +14,13 @@ #ifndef LLVM_CLANG_AST_ASTCONCEPT_H #define LLVM_CLANG_AST_ASTCONCEPT_H + #include "clang/AST/Expr.h" #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/SmallVector.h" -#include <string> #include <utility> + namespace clang { class ConceptDecl; class ConceptSpecializationExpr; diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index ce47d54e44b0..34299581d89d 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -34,12 +34,13 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/LangOptions.h" #include "clang/Basic/Linkage.h" +#include "clang/Basic/NoSanitizeList.h" #include "clang/Basic/OperatorKinds.h" #include "clang/Basic/PartialDiagnostic.h" #include "clang/Basic/ProfileList.h" -#include "clang/Basic/SanitizerBlacklist.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/Specifiers.h" +#include "clang/Basic/TargetCXXABI.h" #include "clang/Basic/XRayLists.h" #include "llvm/ADT/APSInt.h" #include "llvm/ADT/ArrayRef.h" @@ -102,6 +103,7 @@ class DynTypedNode; class DynTypedNodeList; class Expr; class GlobalDecl; +class ItaniumMangleContext; class MangleContext; class MangleNumberingContext; class MaterializeTemporaryExpr; @@ -299,6 +301,10 @@ class ASTContext : public RefCountedBase<ASTContext> { /// This is lazily created. This is intentionally not serialized. mutable llvm::StringMap<StringLiteral *> StringLiteralCache; + /// MD5 hash of CUID. It is calculated when first used and cached by this + /// data member. + mutable std::string CUIDHash; + /// Representation of a "canonical" template template parameter that /// is used in canonical template names. class CanonicalTemplateTemplateParm : public llvm::FoldingSetNode { @@ -453,6 +459,7 @@ private: friend class ASTWriter; template <class> friend class serialization::AbstractTypeReader; friend class CXXRecordDecl; + friend class IncrementalParser; /// A mapping to contain the template or declaration that /// a variable declaration describes or was instantiated from, @@ -512,6 +519,17 @@ private: /// B<int> to the UnresolvedUsingDecl in B<T>. llvm::DenseMap<NamedDecl *, NamedDecl *> InstantiatedFromUsingDecl; + /// Like InstantiatedFromUsingDecl, but for using-enum-declarations. Maps + /// from the instantiated using-enum to the templated decl from whence it + /// came. + /// Note that using-enum-declarations cannot be dependent and + /// thus will never be instantiated from an "unresolved" + /// version thereof (as with using-declarations), so each mapping is from + /// a (resolved) UsingEnumDecl to a (resolved) UsingEnumDecl. + llvm::DenseMap<UsingEnumDecl *, UsingEnumDecl *> + InstantiatedFromUsingEnumDecl; + + /// Simlarly maps instantiated UsingShadowDecls to their origin. llvm::DenseMap<UsingShadowDecl*, UsingShadowDecl*> InstantiatedFromUsingShadowDecl; @@ -538,6 +556,9 @@ private: /// need them (like static local vars). llvm::MapVector<const NamedDecl *, unsigned> MangleNumbers; llvm::MapVector<const VarDecl *, unsigned> StaticLocalNumbers; + /// Mapping the associated device lambda mangling number if present. + mutable llvm::DenseMap<const CXXRecordDecl *, unsigned> + DeviceLambdaManglingNumbers; /// Mapping that stores parameterIndex values for ParmVarDecls when /// that value exceeds the bitfield size of ParmVarDeclBits.ParameterIndex. @@ -547,7 +568,7 @@ private: ImportDecl *FirstLocalImport = nullptr; ImportDecl *LastLocalImport = nullptr; - TranslationUnitDecl *TUDecl; + TranslationUnitDecl *TUDecl = nullptr; mutable ExternCContextDecl *ExternCContext = nullptr; mutable BuiltinTemplateDecl *MakeIntegerSeqDecl = nullptr; mutable BuiltinTemplateDecl *TypePackElementDecl = nullptr; @@ -559,9 +580,9 @@ private: /// this ASTContext object. LangOptions &LangOpts; - /// Blacklist object that is used by sanitizers to decide which + /// NoSanitizeList object that is used by sanitizers to decide which /// entities should not be instrumented. - std::unique_ptr<SanitizerBlacklist> SanitizerBL; + std::unique_ptr<NoSanitizeList> NoSanitizeL; /// Function filtering mechanism to determine whether a given function /// should be imbued with the XRay "always" or "never" attributes. @@ -597,10 +618,14 @@ private: std::unique_ptr<interp::Context> InterpContext; std::unique_ptr<ParentMapContext> ParentMapCtx; + /// Keeps track of the deallocated DeclListNodes for future reuse. + DeclListNode *ListNodeFreeList = nullptr; + public: IdentifierTable &Idents; SelectorTable &Selectors; Builtin::Context &BuiltinInfo; + const TranslationUnitKind TUKind; mutable DeclarationNameTable DeclarationNames; IntrusiveRefCntPtr<ExternalASTSource> ExternalSource; ASTMutationListener *Listener = nullptr; @@ -612,11 +637,22 @@ public: ParentMapContext &getParentMapContext(); // A traversal scope limits the parts of the AST visible to certain analyses. - // RecursiveASTVisitor::TraverseAST will only visit reachable nodes, and + // RecursiveASTVisitor only visits specified children of TranslationUnitDecl. // getParents() will only observe reachable parent edges. // - // The scope is defined by a set of "top-level" declarations. - // Initially, it is the entire TU: {getTranslationUnitDecl()}. + // The scope is defined by a set of "top-level" declarations which will be + // visible under the TranslationUnitDecl. + // Initially, it is the entire TU, represented by {getTranslationUnitDecl()}. + // + // After setTraversalScope({foo, bar}), the exposed AST looks like: + // TranslationUnitDecl + // - foo + // - ... + // - bar + // - ... + // All other siblings of foo and bar are pruned from the tree. + // (However they are still accessible via TranslationUnitDecl->decls()) + // // Changing the scope clears the parent cache, which is expensive to rebuild. std::vector<Decl *> getTraversalScope() const { return TraversalScope; } void setTraversalScope(const std::vector<Decl *> &); @@ -648,6 +684,24 @@ public: } void Deallocate(void *Ptr) const {} + /// Allocates a \c DeclListNode or returns one from the \c ListNodeFreeList + /// pool. + DeclListNode *AllocateDeclListNode(clang::NamedDecl *ND) { + if (DeclListNode *Alloc = ListNodeFreeList) { + ListNodeFreeList = Alloc->Rest.dyn_cast<DeclListNode*>(); + Alloc->D = ND; + Alloc->Rest = nullptr; + return Alloc; + } + return new (*this) DeclListNode(ND); + } + /// Deallcates a \c DeclListNode by returning it to the \c ListNodeFreeList + /// pool. + void DeallocateDeclListNode(DeclListNode *N) { + N->Rest = ListNodeFreeList; + ListNodeFreeList = N; + } + /// Return the total amount of physical memory allocated for representing /// AST nodes and type information. size_t getASTAllocatedMemory() const { @@ -688,9 +742,7 @@ public: return LangOpts.CPlusPlus || LangOpts.RecoveryAST; } - const SanitizerBlacklist &getSanitizerBlacklist() const { - return *SanitizerBL; - } + const NoSanitizeList &getNoSanitizeList() const { return *NoSanitizeL; } const XRayFunctionFilter &getXRayFilter() const { return *XRayFilter; @@ -704,6 +756,11 @@ public: return FullSourceLoc(Loc,SourceMgr); } + /// Return the C++ ABI kind that should be used. The C++ ABI can be overriden + /// at compile time with `-fc++-abi=`. If this is not provided, we instead use + /// the default ABI set by the target. + TargetCXXABI::Kind getCXXABIKind() const; + /// All comments in this translation unit. RawCommentList Comments; @@ -853,30 +910,38 @@ public: MemberSpecializationInfo *getInstantiatedFromStaticDataMember( const VarDecl *Var); - TemplateOrSpecializationInfo - getTemplateOrSpecializationInfo(const VarDecl *Var); - /// Note that the static data member \p Inst is an instantiation of /// the static data member template \p Tmpl of a class template. void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl, TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation = SourceLocation()); + TemplateOrSpecializationInfo + getTemplateOrSpecializationInfo(const VarDecl *Var); + void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI); - /// If the given using decl \p Inst is an instantiation of a - /// (possibly unresolved) using decl from a template instantiation, - /// return it. + /// If the given using decl \p Inst is an instantiation of + /// another (possibly unresolved) using decl, return it. NamedDecl *getInstantiatedFromUsingDecl(NamedDecl *Inst); /// Remember that the using decl \p Inst is an instantiation /// of the using decl \p Pattern of a class template. void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern); + /// If the given using-enum decl \p Inst is an instantiation of + /// another using-enum decl, return it. + UsingEnumDecl *getInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst); + + /// Remember that the using enum decl \p Inst is an instantiation + /// of the using enum decl \p Pattern of a class template. + void setInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst, + UsingEnumDecl *Pattern); + + UsingShadowDecl *getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst); void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern); - UsingShadowDecl *getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst); FieldDecl *getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field); @@ -959,7 +1024,18 @@ public: /// Get the initializations to perform when importing a module, if any. ArrayRef<Decl*> getModuleInitializers(Module *M); - TranslationUnitDecl *getTranslationUnitDecl() const { return TUDecl; } + TranslationUnitDecl *getTranslationUnitDecl() const { + return TUDecl->getMostRecentDecl(); + } + void addTranslationUnitDecl() { + assert(!TUDecl || TUKind == TU_Incremental); + TranslationUnitDecl *NewTUDecl = TranslationUnitDecl::Create(*this); + if (TraversalScope.empty() || TraversalScope.back() == TUDecl) + TraversalScope = {NewTUDecl}; + if (TUDecl) + NewTUDecl->setPreviousDecl(TUDecl); + TUDecl = NewTUDecl; + } ExternCContextDecl *getExternCContextDecl() const; BuiltinTemplateDecl *getMakeIntegerSeqDecl() const; @@ -1017,6 +1093,9 @@ public: #define PPC_VECTOR_TYPE(Name, Id, Size) \ CanQualType Id##Ty; #include "clang/Basic/PPCTypes.def" +#define RVV_TYPE(Name, Id, SingletonId) \ + CanQualType SingletonId; +#include "clang/Basic/RISCVVTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. @@ -1029,11 +1108,12 @@ public: // Implicitly-declared type 'struct _GUID'. mutable TagDecl *MSGuidTagDecl = nullptr; - /// Keep track of CUDA/HIP static device variables referenced by host code. - llvm::DenseSet<const VarDecl *> CUDAStaticDeviceVarReferencedByHost; + /// Keep track of CUDA/HIP device-side variables ODR-used by host code. + llvm::DenseSet<const VarDecl *> CUDADeviceVarODRUsedByHost; ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents, - SelectorTable &sels, Builtin::Context &builtins); + SelectorTable &sels, Builtin::Context &builtins, + TranslationUnitKind TUKind); ASTContext(const ASTContext &) = delete; ASTContext &operator=(const ASTContext &) = delete; ~ASTContext(); @@ -2320,6 +2400,12 @@ public: /// If \p T is null pointer, assume the target in ASTContext. MangleContext *createMangleContext(const TargetInfo *T = nullptr); + /// Creates a device mangle context to correctly mangle lambdas in a mixed + /// architecture compile by setting the lambda mangling number source to the + /// DeviceLambdaManglingNumber. Currently this asserts that the TargetInfo + /// (from the AuxTargetInfo) is a an itanium target. + MangleContext *createDeviceMangleContext(const TargetInfo &T); + void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass, SmallVectorImpl<const ObjCIvarDecl*> &Ivars) const; @@ -2420,7 +2506,7 @@ public: const ObjCMethodDecl *MethodImp); bool UnwrapSimilarTypes(QualType &T1, QualType &T2); - bool UnwrapSimilarArrayTypes(QualType &T1, QualType &T2); + void UnwrapSimilarArrayTypes(QualType &T1, QualType &T2); /// Determine if two types are similar, according to the C++ rules. That is, /// determine if they are the same other than qualifiers on the initial @@ -2719,6 +2805,14 @@ public: // a given fixed point type. QualType getCorrespondingUnsignedType(QualType T) const; + // Per C99 6.2.5p6, for every signed integer type, there is a corresponding + // unsigned integer type. This method takes an unsigned type, and returns the + // corresponding signed integer type. + // With the introduction of fixed point types in ISO N1169, this method also + // accepts fixed point types and returns the corresponding signed type for + // a given fixed point type. + QualType getCorrespondingSignedType(QualType T) const; + // Per ISO N1169, this method accepts fixed point types and returns the // corresponding saturated type for a given fixed point type. QualType getCorrespondingSaturatedType(QualType Ty) const; @@ -3113,10 +3207,33 @@ public: /// Whether a C++ static variable should be externalized. bool shouldExternalizeStaticVar(const Decl *D) const; + StringRef getCUIDHash() const; + + void AddSYCLKernelNamingDecl(const CXXRecordDecl *RD); + bool IsSYCLKernelNamingDecl(const NamedDecl *RD) const; + unsigned GetSYCLKernelNamingIndex(const NamedDecl *RD); + /// A SourceLocation to store whether we have evaluated a kernel name already, + /// and where it happened. If so, we need to diagnose an illegal use of the + /// builtin. + llvm::MapVector<const SYCLUniqueStableNameExpr *, std::string> + SYCLUniqueStableNameEvaluatedValues; + private: /// All OMPTraitInfo objects live in this collection, one per /// `pragma omp [begin] declare variant` directive. SmallVector<std::unique_ptr<OMPTraitInfo>, 4> OMPTraitInfoVector; + + /// A list of the (right now just lambda decls) declarations required to + /// name all the SYCL kernels in the translation unit, so that we can get the + /// correct kernel name, as well as implement + /// __builtin_sycl_unique_stable_name. + llvm::DenseMap<const DeclContext *, + llvm::SmallPtrSet<const CXXRecordDecl *, 4>> + SYCLKernelNamingTypes; + std::unique_ptr<ItaniumMangleContext> SYCLKernelFilterContext; + void FilterSYCLKernelNamingDecls( + const CXXRecordDecl *RD, + llvm::SmallVectorImpl<const CXXRecordDecl *> &Decls); }; /// Insertion operator for diagnostics. diff --git a/clang/include/clang/AST/ASTImporter.h b/clang/include/clang/AST/ASTImporter.h index a6d822ba2ea6..17e673a8471a 100644 --- a/clang/include/clang/AST/ASTImporter.h +++ b/clang/include/clang/AST/ASTImporter.h @@ -93,8 +93,6 @@ class TypeSourceInfo; using NonEquivalentDeclSet = llvm::DenseSet<std::pair<Decl *, Decl *>>; using ImportedCXXBaseSpecifierMap = llvm::DenseMap<const CXXBaseSpecifier *, CXXBaseSpecifier *>; - using FileIDImportHandlerType = - std::function<void(FileID /*ToID*/, FileID /*FromID*/)>; enum class ODRHandlingType { Conservative, Liberal }; @@ -220,8 +218,6 @@ class TypeSourceInfo; }; private: - FileIDImportHandlerType FileIDImportHandler; - std::shared_ptr<ASTImporterSharedState> SharedState = nullptr; /// The path which we go through during the import of a given AST node. @@ -324,14 +320,6 @@ class TypeSourceInfo; virtual ~ASTImporter(); - /// Set a callback function for FileID import handling. - /// The function is invoked when a FileID is imported from the From context. - /// The imported FileID in the To context and the original FileID in the - /// From context is passed to it. - void setFileIDImportHandler(FileIDImportHandlerType H) { - FileIDImportHandler = H; - } - /// Whether the importer will perform a minimal import, creating /// to-be-completed forward declarations when possible. bool isMinimalImport() const { return Minimal; } @@ -356,6 +344,12 @@ class TypeSourceInfo; Import(ExprWithCleanups::CleanupObject From); /// Import the given type from the "from" context into the "to" + /// context. + /// + /// \returns The equivalent type in the "to" context, or the import error. + llvm::Expected<const Type *> Import(const Type *FromT); + + /// Import the given qualified type from the "from" context into the "to" /// context. A null type is imported as a null type (no error). /// /// \returns The equivalent type in the "to" context, or the import error. diff --git a/clang/include/clang/AST/ASTImporterLookupTable.h b/clang/include/clang/AST/ASTImporterLookupTable.h index 407478a51058..47dca2033839 100644 --- a/clang/include/clang/AST/ASTImporterLookupTable.h +++ b/clang/include/clang/AST/ASTImporterLookupTable.h @@ -63,8 +63,24 @@ public: ASTImporterLookupTable(TranslationUnitDecl &TU); void add(NamedDecl *ND); void remove(NamedDecl *ND); + // Sometimes a declaration is created first with a temporarily value of decl + // context (often the translation unit) and later moved to the final context. + // This happens for declarations that are created before the final declaration + // context. In such cases the lookup table needs to be updated. + // (The declaration is in these cases not added to the temporary decl context, + // only its parent is set.) + // FIXME: It would be better to not add the declaration to the temporary + // context at all in the lookup table, but this requires big change in + // ASTImporter. + // The function should be called when the old context is definitely different + // from the new. + void update(NamedDecl *ND, DeclContext *OldDC); using LookupResult = DeclList; LookupResult lookup(DeclContext *DC, DeclarationName Name) const; + // Check if the `ND` is within the lookup table (with its current name) in + // context `DC`. This is intended for debug purposes when the DeclContext of a + // NamedDecl is changed. + bool contains(DeclContext *DC, NamedDecl *ND) const; void dump(DeclContext *DC) const; void dump() const; }; diff --git a/clang/include/clang/AST/ASTNodeTraverser.h b/clang/include/clang/AST/ASTNodeTraverser.h index bb5b0c73f028..18e7f491f222 100644 --- a/clang/include/clang/AST/ASTNodeTraverser.h +++ b/clang/include/clang/AST/ASTNodeTraverser.h @@ -53,6 +53,7 @@ struct { void Visit(const OMPClause *C); void Visit(const BlockDecl::Capture &C); void Visit(const GenericSelectionExpr::ConstAssociation &A); + void Visit(const concepts::Requirement *R); void Visit(const APValue &Value, QualType Ty); }; */ @@ -141,7 +142,8 @@ public: ConstStmtVisitor<Derived>::Visit(S); // Some statements have custom mechanisms for dumping their children. - if (isa<DeclStmt>(S) || isa<GenericSelectionExpr>(S)) + if (isa<DeclStmt>(S) || isa<GenericSelectionExpr>(S) || + isa<RequiresExpr>(S)) return; if (Traversal == TK_IgnoreUnlessSpelledInSource && @@ -228,6 +230,28 @@ public: }); } + void Visit(const concepts::Requirement *R) { + getNodeDelegate().AddChild([=] { + getNodeDelegate().Visit(R); + if (!R) + return; + if (auto *TR = dyn_cast<concepts::TypeRequirement>(R)) { + if (!TR->isSubstitutionFailure()) + Visit(TR->getType()->getType().getTypePtr()); + } else if (auto *ER = dyn_cast<concepts::ExprRequirement>(R)) { + if (!ER->isExprSubstitutionFailure()) + Visit(ER->getExpr()); + if (!ER->getReturnTypeRequirement().isEmpty()) + Visit(ER->getReturnTypeRequirement() + .getTypeConstraint() + ->getImmediatelyDeclaredConstraint()); + } else if (auto *NR = dyn_cast<concepts::NestedRequirement>(R)) { + if (!NR->isSubstitutionFailure()) + Visit(NR->getConstraintExpr()); + } + }); + } + void Visit(const APValue &Value, QualType Ty) { getNodeDelegate().AddChild([=] { getNodeDelegate().Visit(Value, Ty); }); } @@ -438,6 +462,8 @@ public: } void VisitBindingDecl(const BindingDecl *D) { + if (Traversal == TK_IgnoreUnlessSpelledInSource) + return; if (const auto *E = D->getBinding()) Visit(E); } @@ -687,6 +713,13 @@ public: } } + void VisitRequiresExpr(const RequiresExpr *E) { + for (auto *D : E->getLocalParameters()) + Visit(D); + for (auto *R : E->getRequirements()) + Visit(R); + } + void VisitLambdaExpr(const LambdaExpr *Node) { if (Traversal == TK_IgnoreUnlessSpelledInSource) { for (unsigned I = 0, N = Node->capture_size(); I != N; ++I) { diff --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h index e453733ab92c..dbfecc125049 100644 --- a/clang/include/clang/AST/Attr.h +++ b/clang/include/clang/AST/Attr.h @@ -208,6 +208,8 @@ public: switch (getKind()) { case attr::SwiftContext: return ParameterABI::SwiftContext; + case attr::SwiftAsyncContext: + return ParameterABI::SwiftAsyncContext; case attr::SwiftErrorResult: return ParameterABI::SwiftErrorResult; case attr::SwiftIndirectResult: diff --git a/clang/include/clang/AST/CXXInheritance.h b/clang/include/clang/AST/CXXInheritance.h index 709f08bff82a..946b9e318baa 100644 --- a/clang/include/clang/AST/CXXInheritance.h +++ b/clang/include/clang/AST/CXXInheritance.h @@ -76,9 +76,8 @@ public: CXXBasePath() = default; - /// The set of declarations found inside this base class - /// subobject. - DeclContext::lookup_result Decls; + /// The declarations found inside this base class subobject. + DeclContext::lookup_iterator Decls; void clear() { SmallVectorImpl<CXXBasePathElement>::clear(); diff --git a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def index d15d6698860f..9b270682f8cf 100644 --- a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def +++ b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def @@ -242,4 +242,8 @@ FIELD(HasDeclaredCopyConstructorWithConstParam, 1, MERGE_OR) /// const-qualified reference parameter or a non-reference parameter. FIELD(HasDeclaredCopyAssignmentWithConstParam, 1, MERGE_OR) +/// Whether the destructor is no-return. Either explicitly, or if any +/// base classes or fields have a no-return destructor +FIELD(IsAnyDestructorNoReturn, 1, NO_MERGE) + #undef FIELD diff --git a/clang/include/clang/AST/ComparisonCategories.h b/clang/include/clang/AST/ComparisonCategories.h index 70a78964b8a0..b41e934142ee 100644 --- a/clang/include/clang/AST/ComparisonCategories.h +++ b/clang/include/clang/AST/ComparisonCategories.h @@ -19,6 +19,7 @@ #include "llvm/ADT/DenseMap.h" #include <array> #include <cassert> +#include <vector> namespace llvm { class StringRef; diff --git a/clang/include/clang/AST/ComputeDependence.h b/clang/include/clang/AST/ComputeDependence.h index 04e8e2c7d2cc..8db09e6b57d0 100644 --- a/clang/include/clang/AST/ComputeDependence.h +++ b/clang/include/clang/AST/ComputeDependence.h @@ -71,6 +71,7 @@ class OverloadExpr; class DependentScopeDeclRefExpr; class CXXConstructExpr; class CXXDefaultInitExpr; +class CXXDefaultArgExpr; class LambdaExpr; class CXXUnresolvedConstructExpr; class CXXDependentScopeMemberExpr; @@ -78,6 +79,7 @@ class MaterializeTemporaryExpr; class CXXFoldExpr; class TypeTraitExpr; class ConceptSpecializationExpr; +class SYCLUniqueStableNameExpr; class PredefinedExpr; class CallExpr; class OffsetOfExpr; @@ -155,6 +157,7 @@ ExprDependence computeDependence(OverloadExpr *E, bool KnownDependent, ExprDependence computeDependence(DependentScopeDeclRefExpr *E); ExprDependence computeDependence(CXXConstructExpr *E); ExprDependence computeDependence(CXXDefaultInitExpr *E); +ExprDependence computeDependence(CXXDefaultArgExpr *E); ExprDependence computeDependence(LambdaExpr *E, bool ContainsUnexpandedParameterPack); ExprDependence computeDependence(CXXUnresolvedConstructExpr *E); @@ -165,6 +168,7 @@ ExprDependence computeDependence(TypeTraitExpr *E); ExprDependence computeDependence(ConceptSpecializationExpr *E, bool ValueDependent); +ExprDependence computeDependence(SYCLUniqueStableNameExpr *E); ExprDependence computeDependence(PredefinedExpr *E); ExprDependence computeDependence(CallExpr *E, llvm::ArrayRef<Expr *> PreArgs); ExprDependence computeDependence(OffsetOfExpr *E); diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 47c282f0a63d..510bf8978985 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -79,7 +79,23 @@ class UnresolvedSetImpl; class VarTemplateDecl; /// The top declaration context. -class TranslationUnitDecl : public Decl, public DeclContext { +class TranslationUnitDecl : public Decl, + public DeclContext, + public Redeclarable<TranslationUnitDecl> { + using redeclarable_base = Redeclarable<TranslationUnitDecl>; + + TranslationUnitDecl *getNextRedeclarationImpl() override { + return getNextRedeclaration(); + } + + TranslationUnitDecl *getPreviousDeclImpl() override { + return getPreviousDecl(); + } + + TranslationUnitDecl *getMostRecentDeclImpl() override { + return getMostRecentDecl(); + } + ASTContext &Ctx; /// The (most recently entered) anonymous namespace for this @@ -91,6 +107,16 @@ class TranslationUnitDecl : public Decl, public DeclContext { virtual void anchor(); public: + using redecl_range = redeclarable_base::redecl_range; + using redecl_iterator = redeclarable_base::redecl_iterator; + + using redeclarable_base::getMostRecentDecl; + using redeclarable_base::getPreviousDecl; + using redeclarable_base::isFirstDecl; + using redeclarable_base::redecls; + using redeclarable_base::redecls_begin; + using redeclarable_base::redecls_end; + ASTContext &getASTContext() const { return Ctx; } NamespaceDecl *getAnonymousNamespace() const { return AnonymousNamespace; } @@ -356,6 +382,10 @@ public: /// a C++ class. bool isCXXInstanceMember() const; + /// Determine if the declaration obeys the reserved identifier rules of the + /// given language. + ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const; + /// Determine what kind of linkage this entity has. /// /// This is not the linkage as defined by the standard or the codegen notion @@ -579,6 +609,16 @@ public: AnonOrFirstNamespaceAndInline.setInt(Inline); } + /// Returns true if the inline qualifier for \c Name is redundant. + bool isRedundantInlineQualifierFor(DeclarationName Name) const { + if (!isInline()) + return false; + auto X = lookup(Name); + auto Y = getParent()->lookup(Name); + return std::distance(X.begin(), X.end()) == + std::distance(Y.begin(), Y.end()); + } + /// Get the original (first) namespace declaration. NamespaceDecl *getOriginalNamespace(); @@ -1480,6 +1520,9 @@ public: NonParmVarDeclBits.EscapingByref = true; } + /// Determines if this variable's alignment is dependent. + bool hasDependentAlignment() const; + /// Retrieve the variable declaration from which this variable could /// be instantiated, if it is an instantiation (rather than a non-template). VarDecl *getTemplateInstantiationPattern() const; diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index 15eb29f72539..482d2889a25a 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -1220,65 +1220,110 @@ public: void print(raw_ostream &OS) const override; }; +} // namespace clang -/// The results of name lookup within a DeclContext. This is either a -/// single result (with no stable storage) or a collection of results (with -/// stable storage provided by the lookup table). -class DeclContextLookupResult { - using ResultTy = ArrayRef<NamedDecl *>; - - ResultTy Result; - - // If there is only one lookup result, it would be invalidated by - // reallocations of the name table, so store it separately. - NamedDecl *Single = nullptr; - - static NamedDecl *const SingleElementDummyList; +// Required to determine the layout of the PointerUnion<NamedDecl*> before +// seeing the NamedDecl definition being first used in DeclListNode::operator*. +namespace llvm { + template <> struct PointerLikeTypeTraits<::clang::NamedDecl *> { + static inline void *getAsVoidPointer(::clang::NamedDecl *P) { return P; } + static inline ::clang::NamedDecl *getFromVoidPointer(void *P) { + return static_cast<::clang::NamedDecl *>(P); + } + static constexpr int NumLowBitsAvailable = 3; + }; +} +namespace clang { +/// A list storing NamedDecls in the lookup tables. +class DeclListNode { + friend class ASTContext; // allocate, deallocate nodes. + friend class StoredDeclsList; public: - DeclContextLookupResult() = default; - DeclContextLookupResult(ArrayRef<NamedDecl *> Result) - : Result(Result) {} - DeclContextLookupResult(NamedDecl *Single) - : Result(SingleElementDummyList), Single(Single) {} - - class iterator; - - using IteratorBase = - llvm::iterator_adaptor_base<iterator, ResultTy::iterator, - std::random_access_iterator_tag, NamedDecl *>; - - class iterator : public IteratorBase { - value_type SingleElement; + using Decls = llvm::PointerUnion<NamedDecl*, DeclListNode*>; + class iterator { + friend class DeclContextLookupResult; + friend class StoredDeclsList; + Decls Ptr; + iterator(Decls Node) : Ptr(Node) { } public: - explicit iterator(pointer Pos, value_type Single = nullptr) - : IteratorBase(Pos), SingleElement(Single) {} + using difference_type = ptrdiff_t; + using value_type = NamedDecl*; + using pointer = void; + using reference = value_type; + using iterator_category = std::forward_iterator_tag; + + iterator() = default; reference operator*() const { - return SingleElement ? SingleElement : IteratorBase::operator*(); + assert(Ptr && "dereferencing end() iterator"); + if (DeclListNode *CurNode = Ptr.dyn_cast<DeclListNode*>()) + return CurNode->D; + return Ptr.get<NamedDecl*>(); + } + void operator->() const { } // Unsupported. + bool operator==(const iterator &X) const { return Ptr == X.Ptr; } + bool operator!=(const iterator &X) const { return Ptr != X.Ptr; } + inline iterator &operator++() { // ++It + assert(!Ptr.isNull() && "Advancing empty iterator"); + + if (DeclListNode *CurNode = Ptr.dyn_cast<DeclListNode*>()) + Ptr = CurNode->Rest; + else + Ptr = nullptr; + return *this; + } + iterator operator++(int) { // It++ + iterator temp = *this; + ++(*this); + return temp; } + // Enables the pattern for (iterator I =..., E = I.end(); I != E; ++I) + iterator end() { return iterator(); } }; +private: + NamedDecl *D = nullptr; + Decls Rest = nullptr; + DeclListNode(NamedDecl *ND) : D(ND) {} +}; +/// The results of name lookup within a DeclContext. +class DeclContextLookupResult { + using Decls = DeclListNode::Decls; + + /// When in collection form, this is what the Data pointer points to. + Decls Result; + +public: + DeclContextLookupResult() = default; + DeclContextLookupResult(Decls Result) : Result(Result) {} + + using iterator = DeclListNode::iterator; using const_iterator = iterator; - using pointer = iterator::pointer; using reference = iterator::reference; - iterator begin() const { return iterator(Result.begin(), Single); } - iterator end() const { return iterator(Result.end(), Single); } + iterator begin() { return iterator(Result); } + iterator end() { return iterator(); } + const_iterator begin() const { + return const_cast<DeclContextLookupResult*>(this)->begin(); + } + const_iterator end() const { return iterator(); } + + bool empty() const { return Result.isNull(); } + bool isSingleResult() const { return Result.dyn_cast<NamedDecl*>(); } + reference front() const { return *begin(); } - bool empty() const { return Result.empty(); } - pointer data() const { return Single ? &Single : Result.data(); } - size_t size() const { return Single ? 1 : Result.size(); } - reference front() const { return Single ? Single : Result.front(); } - reference back() const { return Single ? Single : Result.back(); } - reference operator[](size_t N) const { return Single ? Single : Result[N]; } + // Find the first declaration of the given type in the list. Note that this + // is not in general the earliest-declared declaration, and should only be + // used when it's not possible for there to be more than one match or where + // it doesn't matter which one is found. + template<class T> T *find_first() const { + for (auto *D : *this) + if (T *Decl = dyn_cast<T>(D)) + return Decl; - // FIXME: Remove this from the interface - DeclContextLookupResult slice(size_t N) const { - DeclContextLookupResult Sliced = Result.slice(N); - Sliced.Single = Single; - return Sliced; + return nullptr; } }; @@ -2333,7 +2378,7 @@ public: using udir_iterator_base = llvm::iterator_adaptor_base<udir_iterator, lookup_iterator, - std::random_access_iterator_tag, + typename lookup_iterator::iterator_category, UsingDirectiveDecl *>; struct udir_iterator : udir_iterator_base { diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index e32101bb2276..0d5ad40fc19e 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -69,6 +69,7 @@ class FriendDecl; class FunctionTemplateDecl; class IdentifierInfo; class MemberSpecializationInfo; +class BaseUsingDecl; class TemplateDecl; class TemplateParameterList; class UsingDecl; @@ -1479,7 +1480,7 @@ public: /// Returns true if the class destructor, or any implicitly invoked /// destructors are marked noreturn. - bool isAnyDestructorNoReturn() const; + bool isAnyDestructorNoReturn() const { return data().IsAnyDestructorNoReturn; } /// If the class is a local class [class.local], returns /// the enclosing function declaration. @@ -1735,6 +1736,12 @@ public: getLambdaData().HasKnownInternalLinkage = HasKnownInternalLinkage; } + /// Set the device side mangling number. + void setDeviceLambdaManglingNumber(unsigned Num) const; + + /// Retrieve the device side mangling number. + unsigned getDeviceLambdaManglingNumber() const; + /// Returns the inheritance model used for this record. MSInheritanceModel getMSInheritanceModel() const; @@ -1780,6 +1787,7 @@ public: static bool classofKind(Kind K) { return K >= firstCXXRecord && K <= lastCXXRecord; } + void markAbstract() { data().Abstract = true; } }; /// Store information needed for an explicit specifier. @@ -1846,15 +1854,17 @@ private: CXXDeductionGuideDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T, - TypeSourceInfo *TInfo, SourceLocation EndLocation) + TypeSourceInfo *TInfo, SourceLocation EndLocation, + CXXConstructorDecl *Ctor) : FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo, SC_None, false, ConstexprSpecKind::Unspecified), - ExplicitSpec(ES) { + Ctor(Ctor), ExplicitSpec(ES) { if (EndLocation.isValid()) setRangeEnd(EndLocation); setIsCopyDeductionCandidate(false); } + CXXConstructorDecl *Ctor; ExplicitSpecifier ExplicitSpec; void setExplicitSpecifier(ExplicitSpecifier ES) { ExplicitSpec = ES; } @@ -1865,7 +1875,8 @@ public: static CXXDeductionGuideDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T, - TypeSourceInfo *TInfo, SourceLocation EndLocation); + TypeSourceInfo *TInfo, SourceLocation EndLocation, + CXXConstructorDecl *Ctor = nullptr); static CXXDeductionGuideDecl *CreateDeserialized(ASTContext &C, unsigned ID); @@ -1880,6 +1891,12 @@ public: return getDeclName().getCXXDeductionGuideTemplate(); } + /// Get the constructor from which this deduction guide was generated, if + /// this is an implicit deduction guide. + CXXConstructorDecl *getCorrespondingConstructor() const { + return Ctor; + } + void setIsCopyDeductionCandidate(bool isCDC = true) { FunctionDeclBits.IsCopyDeductionCandidate = isCDC; } @@ -2160,6 +2177,10 @@ class CXXCtorInitializer final { llvm::PointerUnion<TypeSourceInfo *, FieldDecl *, IndirectFieldDecl *> Initializee; + /// The argument used to initialize the base or member, which may + /// end up constructing an object (when multiple arguments are involved). + Stmt *Init; + /// The source location for the field name or, for a base initializer /// pack expansion, the location of the ellipsis. /// @@ -2168,10 +2189,6 @@ class CXXCtorInitializer final { /// Initializee points to the CXXConstructorDecl (to allow loop detection). SourceLocation MemberOrEllipsisLocation; - /// The argument used to initialize the base or member, which may - /// end up constructing an object (when multiple arguments are involved). - Stmt *Init; - /// Location of the left paren of the ctor-initializer. SourceLocation LParenLoc; @@ -2261,7 +2278,8 @@ public: // For a pack expansion, returns the location of the ellipsis. SourceLocation getEllipsisLoc() const { - assert(isPackExpansion() && "Initializer is not a pack expansion"); + if (!isPackExpansion()) + return {}; return MemberOrEllipsisLocation; } @@ -2418,12 +2436,12 @@ class CXXConstructorDecl final : ExplicitSpecKind::ResolvedFalse); } - enum TraillingAllocKind { + enum TrailingAllocKind { TAKInheritsConstructor = 1, TAKHasTailExplicit = 1 << 1, }; - uint64_t getTraillingAllocKind() const { + uint64_t getTrailingAllocKind() const { return numTrailingObjects(OverloadToken<InheritedConstructor>()) | (numTrailingObjects(OverloadToken<ExplicitSpecifier>()) << 1); } @@ -3146,21 +3164,27 @@ public: } }; -/// Represents a shadow declaration introduced into a scope by a -/// (resolved) using declaration. +/// Represents a shadow declaration implicitly introduced into a scope by a +/// (resolved) using-declaration or using-enum-declaration to achieve +/// the desired lookup semantics. /// -/// For example, +/// For example: /// \code /// namespace A { /// void foo(); +/// void foo(int); +/// struct foo {}; +/// enum bar { bar1, bar2 }; /// } /// namespace B { -/// using A::foo; // <- a UsingDecl -/// // Also creates a UsingShadowDecl for A::foo() in B +/// // add a UsingDecl and three UsingShadowDecls (named foo) to B. +/// using A::foo; +/// // adds UsingEnumDecl and two UsingShadowDecls (named bar1 and bar2) to B. +/// using enum A::bar; /// } /// \endcode class UsingShadowDecl : public NamedDecl, public Redeclarable<UsingShadowDecl> { - friend class UsingDecl; + friend class BaseUsingDecl; /// The referenced declaration. NamedDecl *Underlying = nullptr; @@ -3187,7 +3211,8 @@ class UsingShadowDecl : public NamedDecl, public Redeclarable<UsingShadowDecl> { protected: UsingShadowDecl(Kind K, ASTContext &C, DeclContext *DC, SourceLocation Loc, - UsingDecl *Using, NamedDecl *Target); + DeclarationName Name, BaseUsingDecl *Introducer, + NamedDecl *Target); UsingShadowDecl(Kind K, ASTContext &C, EmptyShell); public: @@ -3195,9 +3220,10 @@ public: friend class ASTDeclWriter; static UsingShadowDecl *Create(ASTContext &C, DeclContext *DC, - SourceLocation Loc, UsingDecl *Using, - NamedDecl *Target) { - return new (C, DC) UsingShadowDecl(UsingShadow, C, DC, Loc, Using, Target); + SourceLocation Loc, DeclarationName Name, + BaseUsingDecl *Introducer, NamedDecl *Target) { + return new (C, DC) + UsingShadowDecl(UsingShadow, C, DC, Loc, Name, Introducer, Target); } static UsingShadowDecl *CreateDeserialized(ASTContext &C, unsigned ID); @@ -3235,8 +3261,9 @@ public: ~(IDNS_OrdinaryFriend | IDNS_TagFriend | IDNS_LocalExtern); } - /// Gets the using declaration to which this declaration is tied. - UsingDecl *getUsingDecl() const; + /// Gets the (written or instantiated) using declaration that introduced this + /// declaration. + BaseUsingDecl *getIntroducer() const; /// The next using shadow declaration contained in the shadow decl /// chain of the using declaration which introduced this decl. @@ -3250,6 +3277,180 @@ public: } }; +/// Represents a C++ declaration that introduces decls from somewhere else. It +/// provides a set of the shadow decls so introduced. + +class BaseUsingDecl : public NamedDecl { + /// The first shadow declaration of the shadow decl chain associated + /// with this using declaration. + /// + /// The bool member of the pair is a bool flag a derived type may use + /// (UsingDecl makes use of it). + llvm::PointerIntPair<UsingShadowDecl *, 1, bool> FirstUsingShadow; + +protected: + BaseUsingDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N) + : NamedDecl(DK, DC, L, N), FirstUsingShadow(nullptr, 0) {} + +private: + void anchor() override; + +protected: + /// A bool flag for use by a derived type + bool getShadowFlag() const { return FirstUsingShadow.getInt(); } + + /// A bool flag a derived type may set + void setShadowFlag(bool V) { FirstUsingShadow.setInt(V); } + +public: + friend class ASTDeclReader; + friend class ASTDeclWriter; + + /// Iterates through the using shadow declarations associated with + /// this using declaration. + class shadow_iterator { + /// The current using shadow declaration. + UsingShadowDecl *Current = nullptr; + + public: + using value_type = UsingShadowDecl *; + using reference = UsingShadowDecl *; + using pointer = UsingShadowDecl *; + using iterator_category = std::forward_iterator_tag; + using difference_type = std::ptrdiff_t; + + shadow_iterator() = default; + explicit shadow_iterator(UsingShadowDecl *C) : Current(C) {} + + reference operator*() const { return Current; } + pointer operator->() const { return Current; } + + shadow_iterator &operator++() { + Current = Current->getNextUsingShadowDecl(); + return *this; + } + + shadow_iterator operator++(int) { + shadow_iterator tmp(*this); + ++(*this); + return tmp; + } + + friend bool operator==(shadow_iterator x, shadow_iterator y) { + return x.Current == y.Current; + } + friend bool operator!=(shadow_iterator x, shadow_iterator y) { + return x.Current != y.Current; + } + }; + + using shadow_range = llvm::iterator_range<shadow_iterator>; + + shadow_range shadows() const { + return shadow_range(shadow_begin(), shadow_end()); + } + + shadow_iterator shadow_begin() const { + return shadow_iterator(FirstUsingShadow.getPointer()); + } + + shadow_iterator shadow_end() const { return shadow_iterator(); } + + /// Return the number of shadowed declarations associated with this + /// using declaration. + unsigned shadow_size() const { + return std::distance(shadow_begin(), shadow_end()); + } + + void addShadowDecl(UsingShadowDecl *S); + void removeShadowDecl(UsingShadowDecl *S); + + static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K == Using || K == UsingEnum; } +}; + +/// Represents a C++ using-declaration. +/// +/// For example: +/// \code +/// using someNameSpace::someIdentifier; +/// \endcode +class UsingDecl : public BaseUsingDecl, public Mergeable<UsingDecl> { + /// The source location of the 'using' keyword itself. + SourceLocation UsingLocation; + + /// The nested-name-specifier that precedes the name. + NestedNameSpecifierLoc QualifierLoc; + + /// Provides source/type location info for the declaration name + /// embedded in the ValueDecl base class. + DeclarationNameLoc DNLoc; + + UsingDecl(DeclContext *DC, SourceLocation UL, + NestedNameSpecifierLoc QualifierLoc, + const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword) + : BaseUsingDecl(Using, DC, NameInfo.getLoc(), NameInfo.getName()), + UsingLocation(UL), QualifierLoc(QualifierLoc), + DNLoc(NameInfo.getInfo()) { + setShadowFlag(HasTypenameKeyword); + } + + void anchor() override; + +public: + friend class ASTDeclReader; + friend class ASTDeclWriter; + + /// Return the source location of the 'using' keyword. + SourceLocation getUsingLoc() const { return UsingLocation; } + + /// Set the source location of the 'using' keyword. + void setUsingLoc(SourceLocation L) { UsingLocation = L; } + + /// Retrieve the nested-name-specifier that qualifies the name, + /// with source-location information. + NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } + + /// Retrieve the nested-name-specifier that qualifies the name. + NestedNameSpecifier *getQualifier() const { + return QualifierLoc.getNestedNameSpecifier(); + } + + DeclarationNameInfo getNameInfo() const { + return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc); + } + + /// Return true if it is a C++03 access declaration (no 'using'). + bool isAccessDeclaration() const { return UsingLocation.isInvalid(); } + + /// Return true if the using declaration has 'typename'. + bool hasTypename() const { return getShadowFlag(); } + + /// Sets whether the using declaration has 'typename'. + void setTypename(bool TN) { setShadowFlag(TN); } + + static UsingDecl *Create(ASTContext &C, DeclContext *DC, + SourceLocation UsingL, + NestedNameSpecifierLoc QualifierLoc, + const DeclarationNameInfo &NameInfo, + bool HasTypenameKeyword); + + static UsingDecl *CreateDeserialized(ASTContext &C, unsigned ID); + + SourceRange getSourceRange() const override LLVM_READONLY; + + /// Retrieves the canonical declaration of this declaration. + UsingDecl *getCanonicalDecl() override { + return cast<UsingDecl>(getFirstDecl()); + } + const UsingDecl *getCanonicalDecl() const { + return cast<UsingDecl>(getFirstDecl()); + } + + static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K == Using; } +}; + /// Represents a shadow constructor declaration introduced into a /// class by a C++11 using-declaration that names a constructor. /// @@ -3280,7 +3481,8 @@ class ConstructorUsingShadowDecl final : public UsingShadowDecl { ConstructorUsingShadowDecl(ASTContext &C, DeclContext *DC, SourceLocation Loc, UsingDecl *Using, NamedDecl *Target, bool TargetInVirtualBase) - : UsingShadowDecl(ConstructorUsingShadow, C, DC, Loc, Using, + : UsingShadowDecl(ConstructorUsingShadow, C, DC, Loc, + Using->getDeclName(), Using, Target->getUnderlyingDecl()), NominatedBaseClassShadowDecl( dyn_cast<ConstructorUsingShadowDecl>(Target)), @@ -3313,6 +3515,12 @@ public: static ConstructorUsingShadowDecl *CreateDeserialized(ASTContext &C, unsigned ID); + /// Override the UsingShadowDecl's getIntroducer, returning the UsingDecl that + /// introduced this. + UsingDecl *getIntroducer() const { + return cast<UsingDecl>(UsingShadowDecl::getIntroducer()); + } + /// Returns the parent of this using shadow declaration, which /// is the class in which this is declared. //@{ @@ -3360,37 +3568,27 @@ public: static bool classofKind(Kind K) { return K == ConstructorUsingShadow; } }; -/// Represents a C++ using-declaration. +/// Represents a C++ using-enum-declaration. /// /// For example: /// \code -/// using someNameSpace::someIdentifier; +/// using enum SomeEnumTag ; /// \endcode -class UsingDecl : public NamedDecl, public Mergeable<UsingDecl> { + +class UsingEnumDecl : public BaseUsingDecl, public Mergeable<UsingEnumDecl> { /// The source location of the 'using' keyword itself. SourceLocation UsingLocation; - /// The nested-name-specifier that precedes the name. - NestedNameSpecifierLoc QualifierLoc; - - /// Provides source/type location info for the declaration name - /// embedded in the ValueDecl base class. - DeclarationNameLoc DNLoc; + /// Location of the 'enum' keyword. + SourceLocation EnumLocation; - /// The first shadow declaration of the shadow decl chain associated - /// with this using declaration. - /// - /// The bool member of the pair store whether this decl has the \c typename - /// keyword. - llvm::PointerIntPair<UsingShadowDecl *, 1, bool> FirstUsingShadow; + /// The enum + EnumDecl *Enum; - UsingDecl(DeclContext *DC, SourceLocation UL, - NestedNameSpecifierLoc QualifierLoc, - const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword) - : NamedDecl(Using, DC, NameInfo.getLoc(), NameInfo.getName()), - UsingLocation(UL), QualifierLoc(QualifierLoc), - DNLoc(NameInfo.getInfo()), FirstUsingShadow(nullptr, HasTypenameKeyword) { - } + UsingEnumDecl(DeclContext *DC, DeclarationName DN, SourceLocation UL, + SourceLocation EL, SourceLocation NL, EnumDecl *ED) + : BaseUsingDecl(UsingEnum, DC, NL, DN), UsingLocation(UL), + EnumLocation(EL), Enum(ED) {} void anchor() override; @@ -3398,109 +3596,35 @@ public: friend class ASTDeclReader; friend class ASTDeclWriter; - /// Return the source location of the 'using' keyword. + /// The source location of the 'using' keyword. SourceLocation getUsingLoc() const { return UsingLocation; } - - /// Set the source location of the 'using' keyword. void setUsingLoc(SourceLocation L) { UsingLocation = L; } - /// Retrieve the nested-name-specifier that qualifies the name, - /// with source-location information. - NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } - - /// Retrieve the nested-name-specifier that qualifies the name. - NestedNameSpecifier *getQualifier() const { - return QualifierLoc.getNestedNameSpecifier(); - } - - DeclarationNameInfo getNameInfo() const { - return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc); - } - - /// Return true if it is a C++03 access declaration (no 'using'). - bool isAccessDeclaration() const { return UsingLocation.isInvalid(); } - - /// Return true if the using declaration has 'typename'. - bool hasTypename() const { return FirstUsingShadow.getInt(); } - - /// Sets whether the using declaration has 'typename'. - void setTypename(bool TN) { FirstUsingShadow.setInt(TN); } - - /// Iterates through the using shadow declarations associated with - /// this using declaration. - class shadow_iterator { - /// The current using shadow declaration. - UsingShadowDecl *Current = nullptr; - - public: - using value_type = UsingShadowDecl *; - using reference = UsingShadowDecl *; - using pointer = UsingShadowDecl *; - using iterator_category = std::forward_iterator_tag; - using difference_type = std::ptrdiff_t; - - shadow_iterator() = default; - explicit shadow_iterator(UsingShadowDecl *C) : Current(C) {} - - reference operator*() const { return Current; } - pointer operator->() const { return Current; } - - shadow_iterator& operator++() { - Current = Current->getNextUsingShadowDecl(); - return *this; - } - - shadow_iterator operator++(int) { - shadow_iterator tmp(*this); - ++(*this); - return tmp; - } - - friend bool operator==(shadow_iterator x, shadow_iterator y) { - return x.Current == y.Current; - } - friend bool operator!=(shadow_iterator x, shadow_iterator y) { - return x.Current != y.Current; - } - }; - - using shadow_range = llvm::iterator_range<shadow_iterator>; - - shadow_range shadows() const { - return shadow_range(shadow_begin(), shadow_end()); - } + /// The source location of the 'enum' keyword. + SourceLocation getEnumLoc() const { return EnumLocation; } + void setEnumLoc(SourceLocation L) { EnumLocation = L; } - shadow_iterator shadow_begin() const { - return shadow_iterator(FirstUsingShadow.getPointer()); - } - - shadow_iterator shadow_end() const { return shadow_iterator(); } +public: + EnumDecl *getEnumDecl() const { return Enum; } - /// Return the number of shadowed declarations associated with this - /// using declaration. - unsigned shadow_size() const { - return std::distance(shadow_begin(), shadow_end()); - } + static UsingEnumDecl *Create(ASTContext &C, DeclContext *DC, + SourceLocation UsingL, SourceLocation EnumL, + SourceLocation NameL, EnumDecl *ED); - void addShadowDecl(UsingShadowDecl *S); - void removeShadowDecl(UsingShadowDecl *S); - - static UsingDecl *Create(ASTContext &C, DeclContext *DC, - SourceLocation UsingL, - NestedNameSpecifierLoc QualifierLoc, - const DeclarationNameInfo &NameInfo, - bool HasTypenameKeyword); - - static UsingDecl *CreateDeserialized(ASTContext &C, unsigned ID); + static UsingEnumDecl *CreateDeserialized(ASTContext &C, unsigned ID); SourceRange getSourceRange() const override LLVM_READONLY; /// Retrieves the canonical declaration of this declaration. - UsingDecl *getCanonicalDecl() override { return getFirstDecl(); } - const UsingDecl *getCanonicalDecl() const { return getFirstDecl(); } + UsingEnumDecl *getCanonicalDecl() override { + return cast<UsingEnumDecl>(getFirstDecl()); + } + const UsingEnumDecl *getCanonicalDecl() const { + return cast<UsingEnumDecl>(getFirstDecl()); + } static bool classof(const Decl *D) { return classofKind(D->getKind()); } - static bool classofKind(Kind K) { return K == Using; } + static bool classofKind(Kind K) { return K == UsingEnum; } }; /// Represents a pack of using declarations that a single @@ -3759,6 +3883,28 @@ public: static bool classofKind(Kind K) { return K == UnresolvedUsingTypename; } }; +/// This node is generated when a using-declaration that was annotated with +/// __attribute__((using_if_exists)) failed to resolve to a known declaration. +/// In that case, Sema builds a UsingShadowDecl whose target is an instance of +/// this declaration, adding it to the current scope. Referring to this +/// declaration in any way is an error. +class UnresolvedUsingIfExistsDecl final : public NamedDecl { + UnresolvedUsingIfExistsDecl(DeclContext *DC, SourceLocation Loc, + DeclarationName Name); + + void anchor() override; + +public: + static UnresolvedUsingIfExistsDecl *Create(ASTContext &Ctx, DeclContext *DC, + SourceLocation Loc, + DeclarationName Name); + static UnresolvedUsingIfExistsDecl *CreateDeserialized(ASTContext &Ctx, + unsigned ID); + + static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K == Decl::UnresolvedUsingIfExists; } +}; + /// Represents a C++11 static_assert declaration. class StaticAssertDecl : public Decl { llvm::PointerIntPair<Expr *, 1, bool> AssertExprAndFailed; @@ -3811,7 +3957,7 @@ public: /// DecompositionDecl of type 'int (&)[3]'. class BindingDecl : public ValueDecl { /// The declaration that this binding binds to part of. - LazyDeclPtr Decomp; + ValueDecl *Decomp; /// The binding represented by this declaration. References to this /// declaration are effectively equivalent to this expression (except /// that it is only evaluated once at the point of declaration of the @@ -3837,7 +3983,7 @@ public: /// Get the decomposition declaration that this binding represents a /// decomposition of. - ValueDecl *getDecomposedDecl() const; + ValueDecl *getDecomposedDecl() const { return Decomp; } /// Get the variable (if any) that holds the value of evaluating the binding. /// Only present for user-defined bindings for tuple-like types. diff --git a/clang/include/clang/AST/DeclContextInternals.h b/clang/include/clang/AST/DeclContextInternals.h index e6a4cd4381e4..2eef2343b750 100644 --- a/clang/include/clang/AST/DeclContextInternals.h +++ b/clang/include/clang/AST/DeclContextInternals.h @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_AST_DECLCONTEXTINTERNALS_H #define LLVM_CLANG_AST_DECLCONTEXTINTERNALS_H +#include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclBase.h" #include "clang/AST/DeclCXX.h" @@ -21,8 +22,6 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerUnion.h" -#include "llvm/ADT/SmallVector.h" -#include <algorithm> #include <cassert> namespace clang { @@ -31,231 +30,287 @@ class DependentDiagnostic; /// An array of decls optimized for the common case of only containing /// one entry. -struct StoredDeclsList { - /// When in vector form, this is what the Data pointer points to. - using DeclsTy = SmallVector<NamedDecl *, 4>; +class StoredDeclsList { + using Decls = DeclListNode::Decls; /// A collection of declarations, with a flag to indicate if we have /// further external declarations. - using DeclsAndHasExternalTy = llvm::PointerIntPair<DeclsTy *, 1, bool>; + using DeclsAndHasExternalTy = llvm::PointerIntPair<Decls, 1, bool>; /// The stored data, which will be either a pointer to a NamedDecl, - /// or a pointer to a vector with a flag to indicate if there are further + /// or a pointer to a list with a flag to indicate if there are further /// external declarations. - llvm::PointerUnion<NamedDecl *, DeclsAndHasExternalTy> Data; + DeclsAndHasExternalTy Data; + + template<typename Fn> + void erase_if(Fn ShouldErase) { + Decls List = Data.getPointer(); + if (!List) + return; + ASTContext &C = getASTContext(); + DeclListNode::Decls NewHead = nullptr; + DeclListNode::Decls *NewLast = nullptr; + DeclListNode::Decls *NewTail = &NewHead; + while (true) { + if (!ShouldErase(*DeclListNode::iterator(List))) { + NewLast = NewTail; + *NewTail = List; + if (auto *Node = List.dyn_cast<DeclListNode*>()) { + NewTail = &Node->Rest; + List = Node->Rest; + } else { + break; + } + } else if (DeclListNode *N = List.dyn_cast<DeclListNode*>()) { + List = N->Rest; + C.DeallocateDeclListNode(N); + } else { + // We're discarding the last declaration in the list. The last node we + // want to keep (if any) will be of the form DeclListNode(D, <rest>); + // replace it with just D. + if (NewLast) { + DeclListNode *Node = NewLast->get<DeclListNode*>(); + *NewLast = Node->D; + C.DeallocateDeclListNode(Node); + } + break; + } + } + Data.setPointer(NewHead); + + assert(llvm::find_if(getLookupResult(), ShouldErase) == + getLookupResult().end() && "Still exists!"); + } + + void erase(NamedDecl *ND) { + erase_if([ND](NamedDecl *D) { return D == ND; }); + } public: StoredDeclsList() = default; StoredDeclsList(StoredDeclsList &&RHS) : Data(RHS.Data) { - RHS.Data = (NamedDecl *)nullptr; + RHS.Data.setPointer(nullptr); + RHS.Data.setInt(0); + } + + void MaybeDeallocList() { + if (isNull()) + return; + // If this is a list-form, free the list. + ASTContext &C = getASTContext(); + Decls List = Data.getPointer(); + while (DeclListNode *ToDealloc = List.dyn_cast<DeclListNode *>()) { + List = ToDealloc->Rest; + C.DeallocateDeclListNode(ToDealloc); + } } ~StoredDeclsList() { - // If this is a vector-form, free the vector. - if (DeclsTy *Vector = getAsVector()) - delete Vector; + MaybeDeallocList(); } StoredDeclsList &operator=(StoredDeclsList &&RHS) { - if (DeclsTy *Vector = getAsVector()) - delete Vector; + MaybeDeallocList(); + Data = RHS.Data; - RHS.Data = (NamedDecl *)nullptr; + RHS.Data.setPointer(nullptr); + RHS.Data.setInt(0); return *this; } - bool isNull() const { return Data.isNull(); } + bool isNull() const { return Data.getPointer().isNull(); } - NamedDecl *getAsDecl() const { - return Data.dyn_cast<NamedDecl *>(); + ASTContext &getASTContext() { + assert(!isNull() && "No ASTContext."); + if (NamedDecl *ND = getAsDecl()) + return ND->getASTContext(); + return getAsList()->D->getASTContext(); } - DeclsAndHasExternalTy getAsVectorAndHasExternal() const { - return Data.dyn_cast<DeclsAndHasExternalTy>(); + DeclsAndHasExternalTy getAsListAndHasExternal() const { return Data; } + + NamedDecl *getAsDecl() const { + return getAsListAndHasExternal().getPointer().dyn_cast<NamedDecl *>(); } - DeclsTy *getAsVector() const { - return getAsVectorAndHasExternal().getPointer(); + DeclListNode *getAsList() const { + return getAsListAndHasExternal().getPointer().dyn_cast<DeclListNode*>(); } bool hasExternalDecls() const { - return getAsVectorAndHasExternal().getInt(); + return getAsListAndHasExternal().getInt(); } void setHasExternalDecls() { - if (DeclsTy *Vec = getAsVector()) - Data = DeclsAndHasExternalTy(Vec, true); - else { - DeclsTy *VT = new DeclsTy(); - if (NamedDecl *OldD = getAsDecl()) - VT->push_back(OldD); - Data = DeclsAndHasExternalTy(VT, true); - } - } - - void setOnlyValue(NamedDecl *ND) { - assert(!getAsVector() && "Not inline"); - Data = ND; - // Make sure that Data is a plain NamedDecl* so we can use its address - // at getLookupResult. - assert(*(NamedDecl **)&Data == ND && - "PointerUnion mangles the NamedDecl pointer!"); + Data.setInt(1); } void remove(NamedDecl *D) { assert(!isNull() && "removing from empty list"); - if (NamedDecl *Singleton = getAsDecl()) { - assert(Singleton == D && "list is different singleton"); - (void)Singleton; - Data = (NamedDecl *)nullptr; - return; - } - - DeclsTy &Vec = *getAsVector(); - DeclsTy::iterator I = llvm::find(Vec, D); - assert(I != Vec.end() && "list does not contain decl"); - Vec.erase(I); - - assert(llvm::find(Vec, D) == Vec.end() && "list still contains decl"); + erase(D); } - /// Remove any declarations which were imported from an external - /// AST source. + /// Remove any declarations which were imported from an external AST source. void removeExternalDecls() { - if (isNull()) { - // Nothing to do. - } else if (NamedDecl *Singleton = getAsDecl()) { - if (Singleton->isFromASTFile()) - *this = StoredDeclsList(); - } else { - DeclsTy &Vec = *getAsVector(); - Vec.erase(std::remove_if(Vec.begin(), Vec.end(), - [](Decl *D) { return D->isFromASTFile(); }), - Vec.end()); - // Don't have any external decls any more. - Data = DeclsAndHasExternalTy(&Vec, false); - } + erase_if([](NamedDecl *ND) { return ND->isFromASTFile(); }); + + // Don't have any pending external decls any more. + Data.setInt(0); } - /// getLookupResult - Return an array of all the decls that this list - /// represents. - DeclContext::lookup_result getLookupResult() { - if (isNull()) - return DeclContext::lookup_result(); + void replaceExternalDecls(ArrayRef<NamedDecl*> Decls) { + // Remove all declarations that are either external or are replaced with + // external declarations. + erase_if([Decls](NamedDecl *ND) { + if (ND->isFromASTFile()) + return true; + for (NamedDecl *D : Decls) + if (D->declarationReplaces(ND, /*IsKnownNewer=*/false)) + return true; + return false; + }); - // If we have a single NamedDecl, return it. - if (NamedDecl *ND = getAsDecl()) { - assert(!isNull() && "Empty list isn't allowed"); + // Don't have any pending external decls any more. + Data.setInt(0); + + if (Decls.empty()) + return; + + // Convert Decls into a list, in order. + ASTContext &C = Decls.front()->getASTContext(); + DeclListNode::Decls DeclsAsList = Decls.back(); + for (size_t I = Decls.size() - 1; I != 0; --I) { + DeclListNode *Node = C.AllocateDeclListNode(Decls[I - 1]); + Node->Rest = DeclsAsList; + DeclsAsList = Node; + } - // Data is a raw pointer to a NamedDecl*, return it. - return DeclContext::lookup_result(ND); + DeclListNode::Decls Head = Data.getPointer(); + if (Head.isNull()) { + Data.setPointer(DeclsAsList); + return; } - assert(getAsVector() && "Must have a vector at this point"); - DeclsTy &Vector = *getAsVector(); + // Find the end of the existing list. + // FIXME: It would be possible to preserve information from erase_if to + // avoid this rescan looking for the end of the list. + DeclListNode::Decls *Tail = &Head; + while (DeclListNode *Node = Tail->dyn_cast<DeclListNode *>()) + Tail = &Node->Rest; + + // Append the Decls. + DeclListNode *Node = C.AllocateDeclListNode(Tail->get<NamedDecl *>()); + Node->Rest = DeclsAsList; + *Tail = Node; + Data.setPointer(Head); + } - // Otherwise, we have a range result. - return DeclContext::lookup_result(Vector); + /// Return an array of all the decls that this list represents. + DeclContext::lookup_result getLookupResult() const { + return DeclContext::lookup_result(Data.getPointer()); } - /// HandleRedeclaration - If this is a redeclaration of an existing decl, - /// replace the old one with D and return true. Otherwise return false. - bool HandleRedeclaration(NamedDecl *D, bool IsKnownNewer) { + /// If this is a redeclaration of an existing decl, replace the old one with + /// D. Otherwise, append D. + void addOrReplaceDecl(NamedDecl *D) { + const bool IsKnownNewer = true; + + if (isNull()) { + Data.setPointer(D); + return; + } + // Most decls only have one entry in their list, special case it. if (NamedDecl *OldD = getAsDecl()) { - if (!D->declarationReplaces(OldD, IsKnownNewer)) - return false; - setOnlyValue(D); - return true; + if (D->declarationReplaces(OldD, IsKnownNewer)) { + Data.setPointer(D); + return; + } + + // Add D after OldD. + ASTContext &C = D->getASTContext(); + DeclListNode *Node = C.AllocateDeclListNode(OldD); + Node->Rest = D; + Data.setPointer(Node); + return; } + // FIXME: Move the assert before the single decl case when we fix the + // duplication coming from the ASTReader reading builtin types. + assert(!llvm::is_contained(getLookupResult(), D) && "Already exists!"); // Determine if this declaration is actually a redeclaration. - DeclsTy &Vec = *getAsVector(); - for (DeclsTy::iterator OD = Vec.begin(), ODEnd = Vec.end(); - OD != ODEnd; ++OD) { - NamedDecl *OldD = *OD; - if (D->declarationReplaces(OldD, IsKnownNewer)) { - *OD = D; - return true; + for (DeclListNode *N = getAsList(); /*return in loop*/; + N = N->Rest.dyn_cast<DeclListNode *>()) { + if (D->declarationReplaces(N->D, IsKnownNewer)) { + N->D = D; + return; + } + if (auto *ND = N->Rest.dyn_cast<NamedDecl *>()) { + if (D->declarationReplaces(ND, IsKnownNewer)) { + N->Rest = D; + return; + } + + // Add D after ND. + ASTContext &C = D->getASTContext(); + DeclListNode *Node = C.AllocateDeclListNode(ND); + N->Rest = Node; + Node->Rest = D; + return; } } - - return false; } - /// AddSubsequentDecl - This is called on the second and later decl when it is - /// not a redeclaration to merge it into the appropriate place in our list. - void AddSubsequentDecl(NamedDecl *D) { - assert(!isNull() && "don't AddSubsequentDecl when we have no decls"); + /// Add a declaration to the list without checking if it replaces anything. + void prependDeclNoReplace(NamedDecl *D) { + if (isNull()) { + Data.setPointer(D); + return; + } - // If this is the second decl added to the list, convert this to vector - // form. - if (NamedDecl *OldD = getAsDecl()) { - DeclsTy *VT = new DeclsTy(); - VT->push_back(OldD); - Data = DeclsAndHasExternalTy(VT, false); + ASTContext &C = D->getASTContext(); + DeclListNode *Node = C.AllocateDeclListNode(D); + Node->Rest = Data.getPointer(); + Data.setPointer(Node); + } + + LLVM_DUMP_METHOD void dump() const { + Decls D = Data.getPointer(); + if (!D) { + llvm::errs() << "<null>\n"; + return; } - DeclsTy &Vec = *getAsVector(); - - // Using directives end up in a special entry which contains only - // other using directives, so all this logic is wasted for them. - // But avoiding the logic wastes time in the far-more-common case - // that we're *not* adding a new using directive. - - // Tag declarations always go at the end of the list so that an - // iterator which points at the first tag will start a span of - // decls that only contains tags. - if (D->hasTagIdentifierNamespace()) - Vec.push_back(D); - - // Resolved using declarations go at the front of the list so that - // they won't show up in other lookup results. Unresolved using - // declarations (which are always in IDNS_Using | IDNS_Ordinary) - // follow that so that the using declarations will be contiguous. - else if (D->getIdentifierNamespace() & Decl::IDNS_Using) { - DeclsTy::iterator I = Vec.begin(); - if (D->getIdentifierNamespace() != Decl::IDNS_Using) { - while (I != Vec.end() && - (*I)->getIdentifierNamespace() == Decl::IDNS_Using) - ++I; + while (true) { + if (auto *Node = D.dyn_cast<DeclListNode*>()) { + llvm::errs() << '[' << Node->D << "] -> "; + D = Node->Rest; + } else { + llvm::errs() << '[' << D.get<NamedDecl*>() << "]\n"; + return; } - Vec.insert(I, D); - - // All other declarations go at the end of the list, but before any - // tag declarations. But we can be clever about tag declarations - // because there can only ever be one in a scope. - } else if (!Vec.empty() && Vec.back()->hasTagIdentifierNamespace()) { - NamedDecl *TagD = Vec.back(); - Vec.back() = D; - Vec.push_back(TagD); - } else - Vec.push_back(D); + } } }; class StoredDeclsMap : public llvm::SmallDenseMap<DeclarationName, StoredDeclsList, 4> { -public: - static void DestroyAll(StoredDeclsMap *Map, bool Dependent); - -private: friend class ASTContext; // walks the chain deleting these friend class DeclContext; llvm::PointerIntPair<StoredDeclsMap*, 1> Previous; +public: + static void DestroyAll(StoredDeclsMap *Map, bool Dependent); }; class DependentStoredDeclsMap : public StoredDeclsMap { -public: - DependentStoredDeclsMap() = default; - -private: friend class DeclContext; // iterates over diagnostics friend class DependentDiagnostic; DependentDiagnostic *FirstDiagnostic = nullptr; +public: + DependentStoredDeclsMap() = default; }; } // namespace clang diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h index b1bce069920c..6bb9cdf67034 100644 --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/include/clang/AST/DeclObjC.h @@ -852,9 +852,7 @@ public: bool isClassProperty() const { return PropertyAttributes & ObjCPropertyAttribute::kind_class; } - bool isDirectProperty() const { - return PropertyAttributes & ObjCPropertyAttribute::kind_direct; - } + bool isDirectProperty() const; ObjCPropertyQueryKind getQueryKind() const { return isClassProperty() ? ObjCPropertyQueryKind::OBJC_PR_query_class : diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 7fbf6294970e..cbaa287f225a 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -160,9 +160,7 @@ public: /// Determine whether this template parameter list contains an /// unexpanded parameter pack. - bool containsUnexpandedParameterPack() const { - return ContainsUnexpandedParameterPack; - } + bool containsUnexpandedParameterPack() const; /// Determine whether this template parameter list contains a parameter pack. bool hasParameterPack() const { @@ -204,6 +202,9 @@ public: bool OmitTemplateKW = false) const; void print(raw_ostream &Out, const ASTContext &Context, const PrintingPolicy &Policy, bool OmitTemplateKW = false) const; + + static bool shouldIncludeTypeForArgument(const TemplateParameterList *TPL, + unsigned Idx); }; /// Stores a list of template parameters and the associated diff --git a/clang/include/clang/AST/DeclarationName.h b/clang/include/clang/AST/DeclarationName.h index 3cb0a02ff49b..38da6fc727fb 100644 --- a/clang/include/clang/AST/DeclarationName.h +++ b/clang/include/clang/AST/DeclarationName.h @@ -647,7 +647,7 @@ public: /// DeclarationNameLoc - Additional source/type location info /// for a declaration name. Needs a DeclarationName in order /// to be interpreted correctly. -struct DeclarationNameLoc { +class DeclarationNameLoc { // The source location for identifier stored elsewhere. // struct {} Identifier; @@ -660,13 +660,13 @@ struct DeclarationNameLoc { // The location (if any) of the operator keyword is stored elsewhere. struct CXXOpName { - unsigned BeginOpNameLoc; - unsigned EndOpNameLoc; + SourceLocation::UIntTy BeginOpNameLoc; + SourceLocation::UIntTy EndOpNameLoc; }; // The location (if any) of the operator keyword is stored elsewhere. struct CXXLitOpName { - unsigned OpNameLoc; + SourceLocation::UIntTy OpNameLoc; }; // struct {} CXXUsingDirective; @@ -679,10 +679,78 @@ struct DeclarationNameLoc { struct CXXLitOpName CXXLiteralOperatorName; }; - DeclarationNameLoc(DeclarationName Name); + void setNamedTypeLoc(TypeSourceInfo *TInfo) { NamedType.TInfo = TInfo; } + + void setCXXOperatorNameRange(SourceRange Range) { + CXXOperatorName.BeginOpNameLoc = Range.getBegin().getRawEncoding(); + CXXOperatorName.EndOpNameLoc = Range.getEnd().getRawEncoding(); + } + void setCXXLiteralOperatorNameLoc(SourceLocation Loc) { + CXXLiteralOperatorName.OpNameLoc = Loc.getRawEncoding(); + } + +public: + DeclarationNameLoc(DeclarationName Name); // FIXME: this should go away once all DNLocs are properly initialized. DeclarationNameLoc() { memset((void*) this, 0, sizeof(*this)); } + + /// Returns the source type info. Assumes that the object stores location + /// information of a constructor, destructor or conversion operator. + TypeSourceInfo *getNamedTypeInfo() const { return NamedType.TInfo; } + + /// Return the beginning location of the getCXXOperatorNameRange() range. + SourceLocation getCXXOperatorNameBeginLoc() const { + return SourceLocation::getFromRawEncoding(CXXOperatorName.BeginOpNameLoc); + } + + /// Return the end location of the getCXXOperatorNameRange() range. + SourceLocation getCXXOperatorNameEndLoc() const { + return SourceLocation::getFromRawEncoding(CXXOperatorName.EndOpNameLoc); + } + + /// Return the range of the operator name (without the operator keyword). + /// Assumes that the object stores location information of a (non-literal) + /// operator. + SourceRange getCXXOperatorNameRange() const { + return SourceRange(getCXXOperatorNameBeginLoc(), + getCXXOperatorNameEndLoc()); + } + + /// Return the location of the literal operator name (without the operator + /// keyword). Assumes that the object stores location information of a literal + /// operator. + SourceLocation getCXXLiteralOperatorNameLoc() const { + return SourceLocation::getFromRawEncoding(CXXLiteralOperatorName.OpNameLoc); + } + + /// Construct location information for a constructor, destructor or conversion + /// operator. + static DeclarationNameLoc makeNamedTypeLoc(TypeSourceInfo *TInfo) { + DeclarationNameLoc DNL; + DNL.setNamedTypeLoc(TInfo); + return DNL; + } + + /// Construct location information for a non-literal C++ operator. + static DeclarationNameLoc makeCXXOperatorNameLoc(SourceLocation BeginLoc, + SourceLocation EndLoc) { + return makeCXXOperatorNameLoc(SourceRange(BeginLoc, EndLoc)); + } + + /// Construct location information for a non-literal C++ operator. + static DeclarationNameLoc makeCXXOperatorNameLoc(SourceRange Range) { + DeclarationNameLoc DNL; + DNL.setCXXOperatorNameRange(Range); + return DNL; + } + + /// Construct location information for a literal C++ operator. + static DeclarationNameLoc makeCXXLiteralOperatorNameLoc(SourceLocation Loc) { + DeclarationNameLoc DNL; + DNL.setCXXLiteralOperatorNameLoc(Loc); + return DNL; + } }; /// DeclarationNameInfo - A collector data type for bundling together @@ -722,7 +790,6 @@ public: void setLoc(SourceLocation L) { NameLoc = L; } const DeclarationNameLoc &getInfo() const { return LocInfo; } - DeclarationNameLoc &getInfo() { return LocInfo; } void setInfo(const DeclarationNameLoc &Info) { LocInfo = Info; } /// getNamedTypeInfo - Returns the source type info associated to @@ -732,7 +799,7 @@ public: Name.getNameKind() != DeclarationName::CXXDestructorName && Name.getNameKind() != DeclarationName::CXXConversionFunctionName) return nullptr; - return LocInfo.NamedType.TInfo; + return LocInfo.getNamedTypeInfo(); } /// setNamedTypeInfo - Sets the source type info associated to @@ -741,7 +808,7 @@ public: assert(Name.getNameKind() == DeclarationName::CXXConstructorName || Name.getNameKind() == DeclarationName::CXXDestructorName || Name.getNameKind() == DeclarationName::CXXConversionFunctionName); - LocInfo.NamedType.TInfo = TInfo; + LocInfo = DeclarationNameLoc::makeNamedTypeLoc(TInfo); } /// getCXXOperatorNameRange - Gets the range of the operator name @@ -749,18 +816,14 @@ public: SourceRange getCXXOperatorNameRange() const { if (Name.getNameKind() != DeclarationName::CXXOperatorName) return SourceRange(); - return SourceRange( - SourceLocation::getFromRawEncoding(LocInfo.CXXOperatorName.BeginOpNameLoc), - SourceLocation::getFromRawEncoding(LocInfo.CXXOperatorName.EndOpNameLoc) - ); + return LocInfo.getCXXOperatorNameRange(); } /// setCXXOperatorNameRange - Sets the range of the operator name /// (without the operator keyword). Assumes it is a C++ operator. void setCXXOperatorNameRange(SourceRange R) { assert(Name.getNameKind() == DeclarationName::CXXOperatorName); - LocInfo.CXXOperatorName.BeginOpNameLoc = R.getBegin().getRawEncoding(); - LocInfo.CXXOperatorName.EndOpNameLoc = R.getEnd().getRawEncoding(); + LocInfo = DeclarationNameLoc::makeCXXOperatorNameLoc(R); } /// getCXXLiteralOperatorNameLoc - Returns the location of the literal @@ -769,8 +832,7 @@ public: SourceLocation getCXXLiteralOperatorNameLoc() const { if (Name.getNameKind() != DeclarationName::CXXLiteralOperatorName) return SourceLocation(); - return SourceLocation:: - getFromRawEncoding(LocInfo.CXXLiteralOperatorName.OpNameLoc); + return LocInfo.getCXXLiteralOperatorNameLoc(); } /// setCXXLiteralOperatorNameLoc - Sets the location of the literal @@ -778,7 +840,7 @@ public: /// Assumes it is a literal operator. void setCXXLiteralOperatorNameLoc(SourceLocation Loc) { assert(Name.getNameKind() == DeclarationName::CXXLiteralOperatorName); - LocInfo.CXXLiteralOperatorName.OpNameLoc = Loc.getRawEncoding(); + LocInfo = DeclarationNameLoc::makeCXXLiteralOperatorNameLoc(Loc); } /// Determine whether this name involves a template parameter. diff --git a/clang/include/clang/AST/DependenceFlags.h b/clang/include/clang/AST/DependenceFlags.h index ca96b65574bd..62efdb4ce6e4 100644 --- a/clang/include/clang/AST/DependenceFlags.h +++ b/clang/include/clang/AST/DependenceFlags.h @@ -128,6 +128,9 @@ public: // Type depends on a runtime value (variable-length array). VariablyModified = 32, + // Dependence that is propagated syntactically, regardless of semantics. + Syntactic = UnexpandedPack | Instantiation | Error, + LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/VariablyModified) }; @@ -165,6 +168,13 @@ public: translate(D, TNDependence::Dependent, Dependent) | translate(D, TNDependence::Error, Error)) {} + /// Extract only the syntactic portions of this type's dependence. + Dependence syntactic() { + Dependence Result = *this; + Result.V &= Syntactic; + return Result; + } + TypeDependence type() const { return translate(V, UnexpandedPack, TypeDependence::UnexpandedPack) | translate(V, Instantiation, TypeDependence::Instantiation) | @@ -256,6 +266,10 @@ inline TypeDependence toTypeDependence(TemplateArgumentDependence D) { return Dependence(D).type(); } +inline TypeDependence toSyntacticDependence(TypeDependence D) { + return Dependence(D).syntactic().type(); +} + inline NestedNameSpecifierDependence toNestedNameSpecifierDependendence(TypeDependence D) { return Dependence(D).nestedNameSpecifier(); diff --git a/clang/include/clang/AST/EvaluatedExprVisitor.h b/clang/include/clang/AST/EvaluatedExprVisitor.h index 2f6c314b4111..2991f2859ac4 100644 --- a/clang/include/clang/AST/EvaluatedExprVisitor.h +++ b/clang/include/clang/AST/EvaluatedExprVisitor.h @@ -32,6 +32,9 @@ protected: const ASTContext &Context; public: + // Return whether this visitor should recurse into discarded statements for a + // 'constexpr-if'. + bool shouldVisitDiscardedStmt() const { return true; } #define PTR(CLASS) typename Ptr<CLASS>::type explicit EvaluatedExprVisitorBase(const ASTContext &Context) : Context(Context) { } @@ -83,7 +86,7 @@ public: void VisitCallExpr(PTR(CallExpr) CE) { if (!CE->isUnevaluatedBuiltinCall(Context)) - return static_cast<ImplClass*>(this)->VisitExpr(CE); + return getDerived().VisitExpr(CE); } void VisitLambdaExpr(PTR(LambdaExpr) LE) { @@ -103,6 +106,20 @@ public: this->Visit(SubStmt); } + void VisitIfStmt(PTR(IfStmt) If) { + if (!getDerived().shouldVisitDiscardedStmt()) { + if (auto SubStmt = If->getNondiscardedCase(Context)) { + if (*SubStmt) + this->Visit(*SubStmt); + return; + } + } + + getDerived().VisitStmt(If); + } + + ImplClass &getDerived() { return *static_cast<ImplClass *>(this); } + #undef PTR }; diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index a44d06967431..06164411cc2d 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -266,13 +266,11 @@ public: /// C++11 divides the concept of "r-value" into pure r-values /// ("pr-values") and so-called expiring values ("x-values"), which /// identify specific objects that can be safely cannibalized for - /// their resources. This is an unfortunate abuse of terminology on - /// the part of the C++ committee. In Clang, when we say "r-value", - /// we generally mean a pr-value. + /// their resources. bool isLValue() const { return getValueKind() == VK_LValue; } - bool isRValue() const { return getValueKind() == VK_RValue; } + bool isPRValue() const { return getValueKind() == VK_PRValue; } bool isXValue() const { return getValueKind() == VK_XValue; } - bool isGLValue() const { return getValueKind() != VK_RValue; } + bool isGLValue() const { return getValueKind() != VK_PRValue; } enum LValueClassification { LV_Valid, @@ -425,7 +423,7 @@ public: ? VK_LValue : (RT->getPointeeType()->isFunctionType() ? VK_LValue : VK_XValue)); - return VK_RValue; + return VK_PRValue; } /// getValueKind - The value kind that this expression produces. @@ -1588,8 +1586,8 @@ public: // type should be IntTy CharacterLiteral(unsigned value, CharacterKind kind, QualType type, SourceLocation l) - : Expr(CharacterLiteralClass, type, VK_RValue, OK_Ordinary), Value(value), - Loc(l) { + : Expr(CharacterLiteralClass, type, VK_PRValue, OK_Ordinary), + Value(value), Loc(l) { CharacterLiteralBits.Kind = kind; setDependence(ExprDependence::None); } @@ -1615,6 +1613,8 @@ public: return T->getStmtClass() == CharacterLiteralClass; } + static void print(unsigned val, CharacterKind Kind, raw_ostream &OS); + // Iterators child_range children() { return child_range(child_iterator(), child_iterator()); @@ -1707,7 +1707,7 @@ class ImaginaryLiteral : public Expr { Stmt *Val; public: ImaginaryLiteral(Expr *val, QualType Ty) - : Expr(ImaginaryLiteralClass, Ty, VK_RValue, OK_Ordinary), Val(val) { + : Expr(ImaginaryLiteralClass, Ty, VK_PRValue, OK_Ordinary), Val(val) { setDependence(ExprDependence::None); } @@ -2037,6 +2037,64 @@ public: } }; +// This represents a use of the __builtin_sycl_unique_stable_name, which takes a +// type-id, and at CodeGen time emits a unique string representation of the +// type in a way that permits us to properly encode information about the SYCL +// kernels. +class SYCLUniqueStableNameExpr final : public Expr { + friend class ASTStmtReader; + SourceLocation OpLoc, LParen, RParen; + TypeSourceInfo *TypeInfo; + + SYCLUniqueStableNameExpr(EmptyShell Empty, QualType ResultTy); + SYCLUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, + SourceLocation RParen, QualType ResultTy, + TypeSourceInfo *TSI); + + void setTypeSourceInfo(TypeSourceInfo *Ty) { TypeInfo = Ty; } + + void setLocation(SourceLocation L) { OpLoc = L; } + void setLParenLocation(SourceLocation L) { LParen = L; } + void setRParenLocation(SourceLocation L) { RParen = L; } + +public: + TypeSourceInfo *getTypeSourceInfo() { return TypeInfo; } + + const TypeSourceInfo *getTypeSourceInfo() const { return TypeInfo; } + + static SYCLUniqueStableNameExpr * + Create(const ASTContext &Ctx, SourceLocation OpLoc, SourceLocation LParen, + SourceLocation RParen, TypeSourceInfo *TSI); + + static SYCLUniqueStableNameExpr *CreateEmpty(const ASTContext &Ctx); + + SourceLocation getBeginLoc() const { return getLocation(); } + SourceLocation getEndLoc() const { return RParen; } + SourceLocation getLocation() const { return OpLoc; } + SourceLocation getLParenLocation() const { return LParen; } + SourceLocation getRParenLocation() const { return RParen; } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == SYCLUniqueStableNameExprClass; + } + + // Iterators + child_range children() { + return child_range(child_iterator(), child_iterator()); + } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + + // Convenience function to generate the name of the currently stored type. + std::string ComputeName(ASTContext &Context) const; + + // Get the generated name of the type. Note that this only works after all + // kernels have been instantiated. + static std::string ComputeName(ASTContext &Context, QualType Ty); +}; + /// ParenExpr - This represents a parethesized expression, e.g. "(1)". This /// AST node is only formed if full location information is requested. class ParenExpr : public Expr { @@ -2487,7 +2545,8 @@ public: UnaryExprOrTypeTraitExpr(UnaryExprOrTypeTrait ExprKind, TypeSourceInfo *TInfo, QualType resultType, SourceLocation op, SourceLocation rp) - : Expr(UnaryExprOrTypeTraitExprClass, resultType, VK_RValue, OK_Ordinary), + : Expr(UnaryExprOrTypeTraitExprClass, resultType, VK_PRValue, + OK_Ordinary), OpLoc(op), RParenLoc(rp) { assert(ExprKind <= UETT_Last && "invalid enum value!"); UnaryExprOrTypeTraitExprBits.Kind = ExprKind; @@ -2928,11 +2987,22 @@ public: } /// setArg - Set the specified argument. + /// ! the dependence bits might be stale after calling this setter, it is + /// *caller*'s responsibility to recompute them by calling + /// computeDependence(). void setArg(unsigned Arg, Expr *ArgExpr) { assert(Arg < getNumArgs() && "Arg access out of range!"); getArgs()[Arg] = ArgExpr; } + /// Compute and set dependence bits. + void computeDependence() { + setDependence(clang::computeDependence( + this, llvm::makeArrayRef( + reinterpret_cast<Expr **>(getTrailingStmts() + PREARGS_START), + getNumPreArgs()))); + } + /// Reduce the number of arguments in this call expression. This is used for /// example during error recovery to drop extra arguments. There is no way /// to perform the opposite because: 1.) We don't track how much storage @@ -4227,7 +4297,7 @@ class AddrLabelExpr : public Expr { public: AddrLabelExpr(SourceLocation AALoc, SourceLocation LLoc, LabelDecl *L, QualType t) - : Expr(AddrLabelExprClass, t, VK_RValue, OK_Ordinary), AmpAmpLoc(AALoc), + : Expr(AddrLabelExprClass, t, VK_PRValue, OK_Ordinary), AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) { setDependence(ExprDependence::None); } @@ -4272,7 +4342,7 @@ class StmtExpr : public Expr { public: StmtExpr(CompoundStmt *SubStmt, QualType T, SourceLocation LParenLoc, SourceLocation RParenLoc, unsigned TemplateDepth) - : Expr(StmtExprClass, T, VK_RValue, OK_Ordinary), SubStmt(SubStmt), + : Expr(StmtExprClass, T, VK_PRValue, OK_Ordinary), SubStmt(SubStmt), LParenLoc(LParenLoc), RParenLoc(RParenLoc) { setDependence(computeDependence(this, TemplateDepth)); // FIXME: A templated statement expression should have an associated @@ -4522,7 +4592,7 @@ class GNUNullExpr : public Expr { public: GNUNullExpr(QualType Ty, SourceLocation Loc) - : Expr(GNUNullExprClass, Ty, VK_RValue, OK_Ordinary), TokenLoc(Loc) { + : Expr(GNUNullExprClass, Ty, VK_PRValue, OK_Ordinary), TokenLoc(Loc) { setDependence(ExprDependence::None); } @@ -4557,7 +4627,7 @@ class VAArgExpr : public Expr { public: VAArgExpr(SourceLocation BLoc, Expr *e, TypeSourceInfo *TInfo, SourceLocation RPLoc, QualType t, bool IsMS) - : Expr(VAArgExprClass, t, VK_RValue, OK_Ordinary), Val(e), + : Expr(VAArgExprClass, t, VK_PRValue, OK_Ordinary), Val(e), TInfo(TInfo, IsMS), BuiltinLoc(BLoc), RParenLoc(RPLoc) { setDependence(computeDependence(this)); } @@ -5249,7 +5319,7 @@ public: class NoInitExpr : public Expr { public: explicit NoInitExpr(QualType ty) - : Expr(NoInitExprClass, ty, VK_RValue, OK_Ordinary) { + : Expr(NoInitExprClass, ty, VK_PRValue, OK_Ordinary) { setDependence(computeDependence(this)); } @@ -5345,7 +5415,7 @@ class ArrayInitLoopExpr : public Expr { public: explicit ArrayInitLoopExpr(QualType T, Expr *CommonInit, Expr *ElementInit) - : Expr(ArrayInitLoopExprClass, T, VK_RValue, OK_Ordinary), + : Expr(ArrayInitLoopExprClass, T, VK_PRValue, OK_Ordinary), SubExprs{CommonInit, ElementInit} { setDependence(computeDependence(this)); } @@ -5396,7 +5466,7 @@ class ArrayInitIndexExpr : public Expr { public: explicit ArrayInitIndexExpr(QualType T) - : Expr(ArrayInitIndexExprClass, T, VK_RValue, OK_Ordinary) { + : Expr(ArrayInitIndexExprClass, T, VK_PRValue, OK_Ordinary) { setDependence(ExprDependence::None); } @@ -5429,7 +5499,7 @@ public: class ImplicitValueInitExpr : public Expr { public: explicit ImplicitValueInitExpr(QualType ty) - : Expr(ImplicitValueInitExprClass, ty, VK_RValue, OK_Ordinary) { + : Expr(ImplicitValueInitExprClass, ty, VK_PRValue, OK_Ordinary) { setDependence(computeDependence(this)); } @@ -5834,7 +5904,7 @@ public: ExtVectorElementExpr(QualType ty, ExprValueKind VK, Expr *base, IdentifierInfo &accessor, SourceLocation loc) : Expr(ExtVectorElementExprClass, ty, VK, - (VK == VK_RValue ? OK_Ordinary : OK_VectorComponent)), + (VK == VK_PRValue ? OK_Ordinary : OK_VectorComponent)), Base(base), Accessor(&accessor), AccessorLoc(loc) { setDependence(computeDependence(this)); } @@ -5891,7 +5961,7 @@ protected: BlockDecl *TheBlock; public: BlockExpr(BlockDecl *BD, QualType ty) - : Expr(BlockExprClass, ty, VK_RValue, OK_Ordinary), TheBlock(BD) { + : Expr(BlockExprClass, ty, VK_PRValue, OK_Ordinary), TheBlock(BD) { setDependence(computeDependence(this)); } diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index fbeeb4004f7d..161287adce4c 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -721,7 +721,7 @@ public: class CXXBoolLiteralExpr : public Expr { public: CXXBoolLiteralExpr(bool Val, QualType Ty, SourceLocation Loc) - : Expr(CXXBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary) { + : Expr(CXXBoolLiteralExprClass, Ty, VK_PRValue, OK_Ordinary) { CXXBoolLiteralExprBits.Value = Val; CXXBoolLiteralExprBits.Loc = Loc; setDependence(ExprDependence::None); @@ -759,7 +759,7 @@ public: class CXXNullPtrLiteralExpr : public Expr { public: CXXNullPtrLiteralExpr(QualType Ty, SourceLocation Loc) - : Expr(CXXNullPtrLiteralExprClass, Ty, VK_RValue, OK_Ordinary) { + : Expr(CXXNullPtrLiteralExprClass, Ty, VK_PRValue, OK_Ordinary) { CXXNullPtrLiteralExprBits.Loc = Loc; setDependence(ExprDependence::None); } @@ -799,7 +799,7 @@ public: friend class ASTStmtReader; CXXStdInitializerListExpr(QualType Ty, Expr *SubExpr) - : Expr(CXXStdInitializerListExprClass, Ty, VK_RValue, OK_Ordinary), + : Expr(CXXStdInitializerListExprClass, Ty, VK_PRValue, OK_Ordinary), SubExpr(SubExpr) { setDependence(computeDependence(this)); } @@ -1142,7 +1142,7 @@ public: class CXXThisExpr : public Expr { public: CXXThisExpr(SourceLocation L, QualType Ty, bool IsImplicit) - : Expr(CXXThisExprClass, Ty, VK_RValue, OK_Ordinary) { + : Expr(CXXThisExprClass, Ty, VK_PRValue, OK_Ordinary) { CXXThisExprBits.IsImplicit = IsImplicit; CXXThisExprBits.Loc = L; setDependence(computeDependence(this)); @@ -1191,7 +1191,7 @@ public: // null if not present. CXXThrowExpr(Expr *Operand, QualType Ty, SourceLocation Loc, bool IsThrownVariableInScope) - : Expr(CXXThrowExprClass, Ty, VK_RValue, OK_Ordinary), Operand(Operand) { + : Expr(CXXThrowExprClass, Ty, VK_PRValue, OK_Ordinary), Operand(Operand) { CXXThrowExprBits.ThrowLoc = Loc; CXXThrowExprBits.IsThrownVariableInScope = IsThrownVariableInScope; setDependence(computeDependence(this)); @@ -1257,7 +1257,7 @@ class CXXDefaultArgExpr final : public Expr { Param->getDefaultArg()->getObjectKind()), Param(Param), UsedContext(UsedContext) { CXXDefaultArgExprBits.Loc = Loc; - setDependence(ExprDependence::None); + setDependence(computeDependence(this)); } public: @@ -1414,7 +1414,7 @@ class CXXBindTemporaryExpr : public Expr { Stmt *SubExpr = nullptr; CXXBindTemporaryExpr(CXXTemporary *temp, Expr *SubExpr) - : Expr(CXXBindTemporaryExprClass, SubExpr->getType(), VK_RValue, + : Expr(CXXBindTemporaryExprClass, SubExpr->getType(), VK_PRValue, OK_Ordinary), Temp(temp), SubExpr(SubExpr) { setDependence(computeDependence(this)); @@ -1669,7 +1669,7 @@ public: CXXInheritedCtorInitExpr(SourceLocation Loc, QualType T, CXXConstructorDecl *Ctor, bool ConstructsVirtualBase, bool InheritedFromVirtualBase) - : Expr(CXXInheritedCtorInitExprClass, T, VK_RValue, OK_Ordinary), + : Expr(CXXInheritedCtorInitExprClass, T, VK_PRValue, OK_Ordinary), Constructor(Ctor), Loc(Loc), ConstructsVirtualBase(ConstructsVirtualBase), InheritedFromVirtualBase(InheritedFromVirtualBase) { @@ -2100,7 +2100,7 @@ public: /// expression. CXXScalarValueInitExpr(QualType Type, TypeSourceInfo *TypeInfo, SourceLocation RParenLoc) - : Expr(CXXScalarValueInitExprClass, Type, VK_RValue, OK_Ordinary), + : Expr(CXXScalarValueInitExprClass, Type, VK_PRValue, OK_Ordinary), TypeInfo(TypeInfo) { CXXScalarValueInitExprBits.RParenLoc = RParenLoc; setDependence(computeDependence(this)); @@ -2408,7 +2408,7 @@ public: CXXDeleteExpr(QualType Ty, bool GlobalDelete, bool ArrayForm, bool ArrayFormAsWritten, bool UsualArrayDeleteWantsSize, FunctionDecl *OperatorDelete, Expr *Arg, SourceLocation Loc) - : Expr(CXXDeleteExprClass, Ty, VK_RValue, OK_Ordinary), + : Expr(CXXDeleteExprClass, Ty, VK_PRValue, OK_Ordinary), OperatorDelete(OperatorDelete), Argument(Arg) { CXXDeleteExprBits.GlobalDelete = GlobalDelete; CXXDeleteExprBits.ArrayForm = ArrayForm; @@ -2775,7 +2775,7 @@ public: ArrayTypeTraitExpr(SourceLocation loc, ArrayTypeTrait att, TypeSourceInfo *queried, uint64_t value, Expr *dimension, SourceLocation rparen, QualType ty) - : Expr(ArrayTypeTraitExprClass, ty, VK_RValue, OK_Ordinary), ATT(att), + : Expr(ArrayTypeTraitExprClass, ty, VK_PRValue, OK_Ordinary), ATT(att), Value(value), Dimension(dimension), Loc(loc), RParen(rparen), QueriedType(queried) { assert(att <= ATT_Last && "invalid enum value!"); @@ -2841,7 +2841,7 @@ public: ExpressionTraitExpr(SourceLocation loc, ExpressionTrait et, Expr *queried, bool value, SourceLocation rparen, QualType resultType) - : Expr(ExpressionTraitExprClass, resultType, VK_RValue, OK_Ordinary), + : Expr(ExpressionTraitExprClass, resultType, VK_PRValue, OK_Ordinary), ET(et), Value(value), Loc(loc), RParen(rparen), QueriedExpression(queried) { assert(et <= ET_Last && "invalid enum value!"); @@ -4003,7 +4003,7 @@ class CXXNoexceptExpr : public Expr { public: CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val, SourceLocation Keyword, SourceLocation RParen) - : Expr(CXXNoexceptExprClass, Ty, VK_RValue, OK_Ordinary), + : Expr(CXXNoexceptExprClass, Ty, VK_PRValue, OK_Ordinary), Operand(Operand), Range(Keyword, RParen) { CXXNoexceptExprBits.Value = Val == CT_Cannot; setDependence(computeDependence(this, Val)); @@ -4161,7 +4161,7 @@ class SizeOfPackExpr final SourceLocation PackLoc, SourceLocation RParenLoc, Optional<unsigned> Length, ArrayRef<TemplateArgument> PartialArgs) - : Expr(SizeOfPackExprClass, SizeType, VK_RValue, OK_Ordinary), + : Expr(SizeOfPackExprClass, SizeType, VK_PRValue, OK_Ordinary), OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc), Length(Length ? *Length : PartialArgs.size()), Pack(Pack) { assert((!Length || PartialArgs.empty()) && @@ -4528,9 +4528,7 @@ public: /// Determine whether this materialized temporary is bound to an /// lvalue reference; otherwise, it's bound to an rvalue reference. - bool isBoundToLvalueReference() const { - return getValueKind() == VK_LValue; - } + bool isBoundToLvalueReference() const { return isLValue(); } /// Determine whether this temporary object is usable in constant /// expressions, as specified in C++20 [expr.const]p4. @@ -4593,8 +4591,8 @@ public: SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Opcode, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, Optional<unsigned> NumExpansions) - : Expr(CXXFoldExprClass, T, VK_RValue, OK_Ordinary), LParenLoc(LParenLoc), - EllipsisLoc(EllipsisLoc), RParenLoc(RParenLoc), + : Expr(CXXFoldExprClass, T, VK_PRValue, OK_Ordinary), + LParenLoc(LParenLoc), EllipsisLoc(EllipsisLoc), RParenLoc(RParenLoc), NumExpansions(NumExpansions ? *NumExpansions + 1 : 0), Opcode(Opcode) { SubExprs[SubExpr::Callee] = Callee; SubExprs[SubExpr::LHS] = LHS; @@ -4704,7 +4702,7 @@ public: CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, QualType Ty, Expr *Common) - : Expr(SC, Ty, VK_RValue, OK_Ordinary), KeywordLoc(KeywordLoc) { + : Expr(SC, Ty, VK_PRValue, OK_Ordinary), KeywordLoc(KeywordLoc) { assert(Common->isTypeDependent() && Ty->isDependentType() && "wrong constructor for non-dependent co_await/co_yield expression"); SubExprs[SubExpr::Common] = Common; @@ -4808,7 +4806,7 @@ class DependentCoawaitExpr : public Expr { public: DependentCoawaitExpr(SourceLocation KeywordLoc, QualType Ty, Expr *Op, UnresolvedLookupExpr *OpCoawait) - : Expr(DependentCoawaitExprClass, Ty, VK_RValue, OK_Ordinary), + : Expr(DependentCoawaitExprClass, Ty, VK_PRValue, OK_Ordinary), KeywordLoc(KeywordLoc) { // NOTE: A co_await expression is dependent on the coroutines promise // type and may be dependent even when the `Op` expression is not. diff --git a/clang/include/clang/AST/ExprObjC.h b/clang/include/clang/AST/ExprObjC.h index 17eec5172697..b0f057dbaa02 100644 --- a/clang/include/clang/AST/ExprObjC.h +++ b/clang/include/clang/AST/ExprObjC.h @@ -55,7 +55,7 @@ class ObjCStringLiteral : public Expr { public: ObjCStringLiteral(StringLiteral *SL, QualType T, SourceLocation L) - : Expr(ObjCStringLiteralClass, T, VK_RValue, OK_Ordinary), String(SL), + : Expr(ObjCStringLiteralClass, T, VK_PRValue, OK_Ordinary), String(SL), AtLoc(L) { setDependence(ExprDependence::None); } @@ -91,7 +91,7 @@ class ObjCBoolLiteralExpr : public Expr { public: ObjCBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) - : Expr(ObjCBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary), Value(val), + : Expr(ObjCBoolLiteralExprClass, Ty, VK_PRValue, OK_Ordinary), Value(val), Loc(l) { setDependence(ExprDependence::None); } @@ -134,7 +134,7 @@ public: friend class ASTStmtReader; ObjCBoxedExpr(Expr *E, QualType T, ObjCMethodDecl *method, SourceRange R) - : Expr(ObjCBoxedExprClass, T, VK_RValue, OK_Ordinary), SubExpr(E), + : Expr(ObjCBoxedExprClass, T, VK_PRValue, OK_Ordinary), SubExpr(E), BoxingMethod(method), Range(R) { setDependence(computeDependence(this)); } @@ -458,7 +458,7 @@ class ObjCSelectorExpr : public Expr { public: ObjCSelectorExpr(QualType T, Selector selInfo, SourceLocation at, SourceLocation rp) - : Expr(ObjCSelectorExprClass, T, VK_RValue, OK_Ordinary), + : Expr(ObjCSelectorExprClass, T, VK_PRValue, OK_Ordinary), SelName(selInfo), AtLoc(at), RParenLoc(rp) { setDependence(ExprDependence::None); } @@ -511,7 +511,7 @@ public: ObjCProtocolExpr(QualType T, ObjCProtocolDecl *protocol, SourceLocation at, SourceLocation protoLoc, SourceLocation rp) - : Expr(ObjCProtocolExprClass, T, VK_RValue, OK_Ordinary), + : Expr(ObjCProtocolExprClass, T, VK_PRValue, OK_Ordinary), TheProtocol(protocol), AtLoc(at), ProtoLoc(protoLoc), RParenLoc(rp) { setDependence(ExprDependence::None); } @@ -1638,8 +1638,8 @@ public: ObjCBridgedCastExpr(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, CastKind CK, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *Operand) - : ExplicitCastExpr(ObjCBridgedCastExprClass, TSInfo->getType(), VK_RValue, - CK, Operand, 0, false, TSInfo), + : ExplicitCastExpr(ObjCBridgedCastExprClass, TSInfo->getType(), + VK_PRValue, CK, Operand, 0, false, TSInfo), LParenLoc(LParenLoc), BridgeKeywordLoc(BridgeKeywordLoc), Kind(Kind) {} /// Construct an empty Objective-C bridged cast. @@ -1692,7 +1692,7 @@ class ObjCAvailabilityCheckExpr : public Expr { public: ObjCAvailabilityCheckExpr(VersionTuple VersionToCheck, SourceLocation AtLoc, SourceLocation RParen, QualType Ty) - : Expr(ObjCAvailabilityCheckExprClass, Ty, VK_RValue, OK_Ordinary), + : Expr(ObjCAvailabilityCheckExprClass, Ty, VK_PRValue, OK_Ordinary), VersionToCheck(VersionToCheck), AtLoc(AtLoc), RParen(RParen) { setDependence(ExprDependence::None); } diff --git a/clang/include/clang/AST/ExternalASTSource.h b/clang/include/clang/AST/ExternalASTSource.h index caae0770931b..b1851afcda37 100644 --- a/clang/include/clang/AST/ExternalASTSource.h +++ b/clang/include/clang/AST/ExternalASTSource.h @@ -24,14 +24,12 @@ #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" #include "llvm/ADT/iterator.h" #include "llvm/Support/PointerLikeTypeTraits.h" #include <cassert> #include <cstddef> #include <cstdint> #include <iterator> -#include <string> #include <utility> namespace clang { @@ -462,10 +460,10 @@ public: } // namespace clang -/// Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be -/// placed into a PointerUnion. namespace llvm { +/// Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be +/// placed into a PointerUnion. template<typename Owner, typename T, void (clang::ExternalASTSource::*Update)(Owner)> struct PointerLikeTypeTraits< diff --git a/clang/include/clang/AST/IgnoreExpr.h b/clang/include/clang/AST/IgnoreExpr.h index 1c2b538e5b63..a7e9b07bef6c 100644 --- a/clang/include/clang/AST/IgnoreExpr.h +++ b/clang/include/clang/AST/IgnoreExpr.h @@ -41,7 +41,7 @@ template <typename... FnTys> Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) { template <typename... FnTys> const Expr *IgnoreExprNodes(const Expr *E, FnTys &&...Fns) { - return const_cast<Expr *>(IgnoreExprNodes(E, std::forward<FnTys>(Fns)...)); + return IgnoreExprNodes(const_cast<Expr *>(E), std::forward<FnTys>(Fns)...); } inline Expr *IgnoreImplicitCastsSingleStep(Expr *E) { @@ -121,6 +121,18 @@ inline Expr *IgnoreImplicitSingleStep(Expr *E) { return E; } +inline Expr *IgnoreElidableImplicitConstructorSingleStep(Expr *E) { + auto *CCE = dyn_cast<CXXConstructExpr>(E); + if (CCE && CCE->isElidable() && !isa<CXXTemporaryObjectExpr>(CCE)) { + unsigned NumArgs = CCE->getNumArgs(); + if ((NumArgs == 1 || + (NumArgs > 1 && CCE->getArg(1)->isDefaultArgument())) && + !CCE->getArg(0)->isDefaultArgument() && !CCE->isListInitialization()) + return CCE->getArg(0); + } + return E; +} + inline Expr *IgnoreImplicitAsWrittenSingleStep(Expr *E) { if (auto *ICE = dyn_cast<ImplicitCastExpr>(E)) return ICE->getSubExprAsWritten(); diff --git a/clang/include/clang/AST/JSONNodeDumper.h b/clang/include/clang/AST/JSONNodeDumper.h index 4e7162992418..a96e21993e20 100644 --- a/clang/include/clang/AST/JSONNodeDumper.h +++ b/clang/include/clang/AST/JSONNodeDumper.h @@ -21,6 +21,7 @@ #include "clang/AST/AttrVisitor.h" #include "clang/AST/CommentCommandTraits.h" #include "clang/AST/CommentVisitor.h" +#include "clang/AST/ExprConcepts.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/Mangle.h" #include "clang/AST/Type.h" @@ -204,6 +205,7 @@ public: void Visit(const OMPClause *C); void Visit(const BlockDecl::Capture &C); void Visit(const GenericSelectionExpr::ConstAssociation &A); + void Visit(const concepts::Requirement *R); void Visit(const APValue &Value, QualType Ty); void VisitTypedefType(const TypedefType *TT); @@ -234,6 +236,7 @@ public: void VisitUsingDirectiveDecl(const UsingDirectiveDecl *UDD); void VisitNamespaceAliasDecl(const NamespaceAliasDecl *NAD); void VisitUsingDecl(const UsingDecl *UD); + void VisitUsingEnumDecl(const UsingEnumDecl *UED); void VisitUsingShadowDecl(const UsingShadowDecl *USD); void VisitVarDecl(const VarDecl *VD); void VisitFieldDecl(const FieldDecl *FD); @@ -263,6 +266,7 @@ public: void VisitBlockDecl(const BlockDecl *D); void VisitDeclRefExpr(const DeclRefExpr *DRE); + void VisitSYCLUniqueStableNameExpr(const SYCLUniqueStableNameExpr *E); void VisitPredefinedExpr(const PredefinedExpr *PE); void VisitUnaryOperator(const UnaryOperator *UO); void VisitBinaryOperator(const BinaryOperator *BO); @@ -288,6 +292,7 @@ public: void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *BTE); void VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *MTE); void VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *ME); + void VisitRequiresExpr(const RequiresExpr *RE); void VisitObjCEncodeExpr(const ObjCEncodeExpr *OEE); void VisitObjCMessageExpr(const ObjCMessageExpr *OME); diff --git a/clang/include/clang/AST/Mangle.h b/clang/include/clang/AST/Mangle.h index 0e8d6dd53d8a..7d02f08e0120 100644 --- a/clang/include/clang/AST/Mangle.h +++ b/clang/include/clang/AST/Mangle.h @@ -89,6 +89,17 @@ public: return Result.first->second; } + uint64_t getAnonymousStructIdForDebugInfo(const NamedDecl *D) { + llvm::DenseMap<const NamedDecl *, uint64_t>::iterator Result = + AnonStructIds.find(D); + // The decl should already be inserted, but return 0 in case it is not. + if (Result == AnonStructIds.end()) + return 0; + return Result->second; + } + + virtual std::string getLambdaString(const CXXRecordDecl *Lambda) = 0; + /// @name Mangler Entry Points /// @{ @@ -96,6 +107,12 @@ public: virtual bool shouldMangleCXXName(const NamedDecl *D) = 0; virtual bool shouldMangleStringLiteral(const StringLiteral *SL) = 0; + virtual bool isUniqueInternalLinkageDecl(const NamedDecl *ND) { + return false; + } + + virtual void needsUniqueInternalLinkageNames() { } + // FIXME: consider replacing raw_ostream & with something like SmallString &. void mangleName(GlobalDecl GD, raw_ostream &); virtual void mangleCXXName(GlobalDecl GD, raw_ostream &) = 0; @@ -153,6 +170,8 @@ public: class ItaniumMangleContext : public MangleContext { public: + using DiscriminatorOverrideTy = + llvm::Optional<unsigned> (*)(ASTContext &, const NamedDecl *); explicit ItaniumMangleContext(ASTContext &C, DiagnosticsEngine &D) : MangleContext(C, D, MK_Itanium) {} @@ -175,12 +194,18 @@ public: virtual void mangleDynamicStermFinalizer(const VarDecl *D, raw_ostream &) = 0; + // This has to live here, otherwise the CXXNameMangler won't have access to + // it. + virtual DiscriminatorOverrideTy getDiscriminatorOverride() const = 0; static bool classof(const MangleContext *C) { return C->getKind() == MK_Itanium; } static ItaniumMangleContext *create(ASTContext &Context, DiagnosticsEngine &Diags); + static ItaniumMangleContext *create(ASTContext &Context, + DiagnosticsEngine &Diags, + DiscriminatorOverrideTy Discriminator); }; class MicrosoftMangleContext : public MangleContext { diff --git a/clang/include/clang/AST/MangleNumberingContext.h b/clang/include/clang/AST/MangleNumberingContext.h index f1ca6a05dbaf..eb33759682d6 100644 --- a/clang/include/clang/AST/MangleNumberingContext.h +++ b/clang/include/clang/AST/MangleNumberingContext.h @@ -52,6 +52,11 @@ public: /// this context. virtual unsigned getManglingNumber(const TagDecl *TD, unsigned MSLocalManglingNumber) = 0; + + /// Retrieve the mangling number of a new lambda expression with the + /// given call operator within the device context. No device number is + /// assigned if there's no device numbering context is associated. + virtual unsigned getDeviceManglingNumber(const CXXMethodDecl *) { return 0; } }; } // end namespace clang diff --git a/clang/include/clang/AST/OpenMPClause.h b/clang/include/clang/AST/OpenMPClause.h index 877c1d87d8ac..aaddcfa307da 100644 --- a/clang/include/clang/AST/OpenMPClause.h +++ b/clang/include/clang/AST/OpenMPClause.h @@ -794,6 +794,208 @@ public: } }; +/// This represents the 'sizes' clause in the '#pragma omp tile' directive. +/// +/// \code +/// #pragma omp tile sizes(5,5) +/// for (int i = 0; i < 64; ++i) +/// for (int j = 0; j < 64; ++j) +/// \endcode +class OMPSizesClause final + : public OMPClause, + private llvm::TrailingObjects<OMPSizesClause, Expr *> { + friend class OMPClauseReader; + friend class llvm::TrailingObjects<OMPSizesClause, Expr *>; + + /// Location of '('. + SourceLocation LParenLoc; + + /// Number of tile sizes in the clause. + unsigned NumSizes; + + /// Build an empty clause. + explicit OMPSizesClause(int NumSizes) + : OMPClause(llvm::omp::OMPC_sizes, SourceLocation(), SourceLocation()), + NumSizes(NumSizes) {} + +public: + /// Build a 'sizes' AST node. + /// + /// \param C Context of the AST. + /// \param StartLoc Location of the 'sizes' identifier. + /// \param LParenLoc Location of '('. + /// \param EndLoc Location of ')'. + /// \param Sizes Content of the clause. + static OMPSizesClause *Create(const ASTContext &C, SourceLocation StartLoc, + SourceLocation LParenLoc, SourceLocation EndLoc, + ArrayRef<Expr *> Sizes); + + /// Build an empty 'sizes' AST node for deserialization. + /// + /// \param C Context of the AST. + /// \param NumSizes Number of items in the clause. + static OMPSizesClause *CreateEmpty(const ASTContext &C, unsigned NumSizes); + + /// Sets the location of '('. + void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } + + /// Returns the location of '('. + SourceLocation getLParenLoc() const { return LParenLoc; } + + /// Returns the number of list items. + unsigned getNumSizes() const { return NumSizes; } + + /// Returns the tile size expressions. + MutableArrayRef<Expr *> getSizesRefs() { + return MutableArrayRef<Expr *>(static_cast<OMPSizesClause *>(this) + ->template getTrailingObjects<Expr *>(), + NumSizes); + } + ArrayRef<Expr *> getSizesRefs() const { + return ArrayRef<Expr *>(static_cast<const OMPSizesClause *>(this) + ->template getTrailingObjects<Expr *>(), + NumSizes); + } + + /// Sets the tile size expressions. + void setSizesRefs(ArrayRef<Expr *> VL) { + assert(VL.size() == NumSizes); + std::copy(VL.begin(), VL.end(), + static_cast<OMPSizesClause *>(this) + ->template getTrailingObjects<Expr *>()); + } + + child_range children() { + MutableArrayRef<Expr *> Sizes = getSizesRefs(); + return child_range(reinterpret_cast<Stmt **>(Sizes.begin()), + reinterpret_cast<Stmt **>(Sizes.end())); + } + const_child_range children() const { + ArrayRef<Expr *> Sizes = getSizesRefs(); + return const_child_range(reinterpret_cast<Stmt *const *>(Sizes.begin()), + reinterpret_cast<Stmt *const *>(Sizes.end())); + } + + child_range used_children() { + return child_range(child_iterator(), child_iterator()); + } + const_child_range used_children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + + static bool classof(const OMPClause *T) { + return T->getClauseKind() == llvm::omp::OMPC_sizes; + } +}; + +/// Representation of the 'full' clause of the '#pragma omp unroll' directive. +/// +/// \code +/// #pragma omp unroll full +/// for (int i = 0; i < 64; ++i) +/// \endcode +class OMPFullClause final : public OMPClause { + friend class OMPClauseReader; + + /// Build an empty clause. + explicit OMPFullClause() : OMPClause(llvm::omp::OMPC_full, {}, {}) {} + +public: + /// Build an AST node for a 'full' clause. + /// + /// \param C Context of the AST. + /// \param StartLoc Starting location of the clause. + /// \param EndLoc Ending location of the clause. + static OMPFullClause *Create(const ASTContext &C, SourceLocation StartLoc, + SourceLocation EndLoc); + + /// Build an empty 'full' AST node for deserialization. + /// + /// \param C Context of the AST. + static OMPFullClause *CreateEmpty(const ASTContext &C); + + child_range children() { return {child_iterator(), child_iterator()}; } + const_child_range children() const { + return {const_child_iterator(), const_child_iterator()}; + } + + child_range used_children() { + return child_range(child_iterator(), child_iterator()); + } + const_child_range used_children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + + static bool classof(const OMPClause *T) { + return T->getClauseKind() == llvm::omp::OMPC_full; + } +}; + +/// Representation of the 'partial' clause of the '#pragma omp unroll' +/// directive. +/// +/// \code +/// #pragma omp unroll partial(4) +/// for (int i = start; i < end; ++i) +/// \endcode +class OMPPartialClause final : public OMPClause { + friend class OMPClauseReader; + + /// Location of '('. + SourceLocation LParenLoc; + + /// Optional argument to the clause (unroll factor). + Stmt *Factor; + + /// Build an empty clause. + explicit OMPPartialClause() : OMPClause(llvm::omp::OMPC_partial, {}, {}) {} + + /// Set the unroll factor. + void setFactor(Expr *E) { Factor = E; } + + /// Sets the location of '('. + void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } + +public: + /// Build an AST node for a 'partial' clause. + /// + /// \param C Context of the AST. + /// \param StartLoc Location of the 'partial' identifier. + /// \param LParenLoc Location of '('. + /// \param EndLoc Location of ')'. + /// \param Factor Clause argument. + static OMPPartialClause *Create(const ASTContext &C, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc, Expr *Factor); + + /// Build an empty 'partial' AST node for deserialization. + /// + /// \param C Context of the AST. + static OMPPartialClause *CreateEmpty(const ASTContext &C); + + /// Returns the location of '('. + SourceLocation getLParenLoc() const { return LParenLoc; } + + /// Returns the argument of the clause or nullptr if not set. + Expr *getFactor() const { return cast_or_null<Expr>(Factor); } + + child_range children() { return child_range(&Factor, &Factor + 1); } + const_child_range children() const { + return const_child_range(&Factor, &Factor + 1); + } + + child_range used_children() { + return child_range(child_iterator(), child_iterator()); + } + const_child_range used_children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + + static bool classof(const OMPClause *T) { + return T->getClauseKind() == llvm::omp::OMPC_partial; + } +}; + /// This represents 'collapse' clause in the '#pragma omp ...' /// directive. /// @@ -5261,14 +5463,14 @@ public: if (!(--RemainingLists)) { ++DeclCur; ++NumListsCur; - if (SupportsMapper) - ++MapperCur; RemainingLists = *NumListsCur; assert(RemainingLists && "No lists in the following declaration??"); } } ++ListSizeCur; + if (SupportsMapper) + ++MapperCur; return *this; } }; @@ -7272,15 +7474,244 @@ public: } }; +/// This represents the 'init' clause in '#pragma omp ...' directives. +/// +/// \code +/// #pragma omp interop init(target:obj) +/// \endcode +class OMPInitClause final + : public OMPVarListClause<OMPInitClause>, + private llvm::TrailingObjects<OMPInitClause, Expr *> { + friend class OMPClauseReader; + friend OMPVarListClause; + friend TrailingObjects; + + /// Location of interop variable. + SourceLocation VarLoc; + + bool IsTarget = false; + bool IsTargetSync = false; + + void setInteropVar(Expr *E) { varlist_begin()[0] = E; } + + void setIsTarget(bool V) { IsTarget = V; } + + void setIsTargetSync(bool V) { IsTargetSync = V; } + + /// Sets the location of the interop variable. + void setVarLoc(SourceLocation Loc) { VarLoc = Loc; } + + /// Build 'init' clause. + /// + /// \param IsTarget Uses the 'target' interop-type. + /// \param IsTargetSync Uses the 'targetsync' interop-type. + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param VarLoc Location of the interop variable. + /// \param EndLoc Ending location of the clause. + /// \param N Number of expressions. + OMPInitClause(bool IsTarget, bool IsTargetSync, SourceLocation StartLoc, + SourceLocation LParenLoc, SourceLocation VarLoc, + SourceLocation EndLoc, unsigned N) + : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, StartLoc, + LParenLoc, EndLoc, N), + VarLoc(VarLoc), IsTarget(IsTarget), IsTargetSync(IsTargetSync) {} + + /// Build an empty clause. + OMPInitClause(unsigned N) + : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, SourceLocation(), + SourceLocation(), SourceLocation(), N) { + } + +public: + /// Creates a fully specified clause. + /// + /// \param C AST context. + /// \param InteropVar The interop variable. + /// \param PrefExprs The list of preference expressions. + /// \param IsTarget Uses the 'target' interop-type. + /// \param IsTargetSync Uses the 'targetsync' interop-type. + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param VarLoc Location of the interop variable. + /// \param EndLoc Ending location of the clause. + static OMPInitClause *Create(const ASTContext &C, Expr *InteropVar, + ArrayRef<Expr *> PrefExprs, bool IsTarget, + bool IsTargetSync, SourceLocation StartLoc, + SourceLocation LParenLoc, SourceLocation VarLoc, + SourceLocation EndLoc); + + /// Creates an empty clause with \a N expressions. + /// + /// \param C AST context. + /// \param N Number of expression items. + static OMPInitClause *CreateEmpty(const ASTContext &C, unsigned N); + + /// Returns the location of the interop variable. + SourceLocation getVarLoc() const { return VarLoc; } + + /// Returns the interop variable. + Expr *getInteropVar() { return varlist_begin()[0]; } + const Expr *getInteropVar() const { return varlist_begin()[0]; } + + /// Returns true is interop-type 'target' is used. + bool getIsTarget() const { return IsTarget; } + + /// Returns true is interop-type 'targetsync' is used. + bool getIsTargetSync() const { return IsTargetSync; } + + child_range children() { + return child_range(reinterpret_cast<Stmt **>(varlist_begin()), + reinterpret_cast<Stmt **>(varlist_end())); + } + + const_child_range children() const { + auto Children = const_cast<OMPInitClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + + child_range used_children() { + return child_range(child_iterator(), child_iterator()); + } + const_child_range used_children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + + using prefs_iterator = MutableArrayRef<Expr *>::iterator; + using const_prefs_iterator = ArrayRef<const Expr *>::iterator; + using prefs_range = llvm::iterator_range<prefs_iterator>; + using const_prefs_range = llvm::iterator_range<const_prefs_iterator>; + + prefs_range prefs() { + return prefs_range(reinterpret_cast<Expr **>(std::next(varlist_begin())), + reinterpret_cast<Expr **>(varlist_end())); + } + + const_prefs_range prefs() const { + auto Prefs = const_cast<OMPInitClause *>(this)->prefs(); + return const_prefs_range(Prefs.begin(), Prefs.end()); + } + + static bool classof(const OMPClause *T) { + return T->getClauseKind() == llvm::omp::OMPC_init; + } +}; + +/// This represents the 'use' clause in '#pragma omp ...' directives. +/// +/// \code +/// #pragma omp interop use(obj) +/// \endcode +class OMPUseClause final : public OMPClause { + friend class OMPClauseReader; + + /// Location of '('. + SourceLocation LParenLoc; + + /// Location of interop variable. + SourceLocation VarLoc; + + /// The interop variable. + Stmt *InteropVar = nullptr; + + /// Set the interop variable. + void setInteropVar(Expr *E) { InteropVar = E; } + + /// Sets the location of '('. + void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } + + /// Sets the location of the interop variable. + void setVarLoc(SourceLocation Loc) { VarLoc = Loc; } + +public: + /// Build 'use' clause with and interop variable expression \a InteropVar. + /// + /// \param InteropVar The interop variable. + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param VarLoc Location of the interop variable. + /// \param EndLoc Ending location of the clause. + OMPUseClause(Expr *InteropVar, SourceLocation StartLoc, + SourceLocation LParenLoc, SourceLocation VarLoc, + SourceLocation EndLoc) + : OMPClause(llvm::omp::OMPC_use, StartLoc, EndLoc), LParenLoc(LParenLoc), + VarLoc(VarLoc), InteropVar(InteropVar) {} + + /// Build an empty clause. + OMPUseClause() + : OMPClause(llvm::omp::OMPC_use, SourceLocation(), SourceLocation()) {} + + /// Returns the location of '('. + SourceLocation getLParenLoc() const { return LParenLoc; } + + /// Returns the location of the interop variable. + SourceLocation getVarLoc() const { return VarLoc; } + + /// Returns the interop variable. + Expr *getInteropVar() const { return cast<Expr>(InteropVar); } + + child_range children() { return child_range(&InteropVar, &InteropVar + 1); } + + const_child_range children() const { + return const_child_range(&InteropVar, &InteropVar + 1); + } + + child_range used_children() { + return child_range(child_iterator(), child_iterator()); + } + const_child_range used_children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + + static bool classof(const OMPClause *T) { + return T->getClauseKind() == llvm::omp::OMPC_use; + } +}; + /// This represents 'destroy' clause in the '#pragma omp depobj' -/// directive. +/// directive or the '#pragma omp interop' directive.. /// /// \code /// #pragma omp depobj(a) destroy +/// #pragma omp interop destroy(obj) /// \endcode -/// In this example directive '#pragma omp depobj' has 'destroy' clause. +/// In these examples directive '#pragma omp depobj' and '#pragma omp interop' +/// have a 'destroy' clause. The 'interop' directive includes an object. class OMPDestroyClause final : public OMPClause { + friend class OMPClauseReader; + + /// Location of '('. + SourceLocation LParenLoc; + + /// Location of interop variable. + SourceLocation VarLoc; + + /// The interop variable. + Stmt *InteropVar = nullptr; + + /// Set the interop variable. + void setInteropVar(Expr *E) { InteropVar = E; } + + /// Sets the location of '('. + void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } + + /// Sets the location of the interop variable. + void setVarLoc(SourceLocation Loc) { VarLoc = Loc; } + public: + /// Build 'destroy' clause with an interop variable expression \a InteropVar. + /// + /// \param InteropVar The interop variable. + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param VarLoc Location of the interop variable. + /// \param EndLoc Ending location of the clause. + OMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, + SourceLocation LParenLoc, SourceLocation VarLoc, + SourceLocation EndLoc) + : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc), + LParenLoc(LParenLoc), VarLoc(VarLoc), InteropVar(InteropVar) {} + /// Build 'destroy' clause. /// /// \param StartLoc Starting location of the clause. @@ -7293,11 +7724,24 @@ public: : OMPClause(llvm::omp::OMPC_destroy, SourceLocation(), SourceLocation()) { } + /// Returns the location of '('. + SourceLocation getLParenLoc() const { return LParenLoc; } + + /// Returns the location of the interop variable. + SourceLocation getVarLoc() const { return VarLoc; } + + /// Returns the interop variable. + Expr *getInteropVar() const { return cast_or_null<Expr>(InteropVar); } + child_range children() { + if (InteropVar) + return child_range(&InteropVar, &InteropVar + 1); return child_range(child_iterator(), child_iterator()); } const_child_range children() const { + if (InteropVar) + return const_child_range(&InteropVar, &InteropVar + 1); return const_child_range(const_child_iterator(), const_child_iterator()); } @@ -7313,6 +7757,146 @@ public: } }; +/// This represents 'novariants' clause in the '#pragma omp ...' directive. +/// +/// \code +/// #pragma omp dispatch novariants(a > 5) +/// \endcode +/// In this example directive '#pragma omp dispatch' has simple 'novariants' +/// clause with condition 'a > 5'. +class OMPNovariantsClause final : public OMPClause, + public OMPClauseWithPreInit { + friend class OMPClauseReader; + + /// Location of '('. + SourceLocation LParenLoc; + + /// Condition of the 'if' clause. + Stmt *Condition = nullptr; + + /// Set condition. + void setCondition(Expr *Cond) { Condition = Cond; } + + /// Sets the location of '('. + void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } + +public: + /// Build 'novariants' clause with condition \a Cond. + /// + /// \param Cond Condition of the clause. + /// \param HelperCond Helper condition for the construct. + /// \param CaptureRegion Innermost OpenMP region where expressions in this + /// clause must be captured. + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param EndLoc Ending location of the clause. + OMPNovariantsClause(Expr *Cond, Stmt *HelperCond, + OpenMPDirectiveKind CaptureRegion, + SourceLocation StartLoc, SourceLocation LParenLoc, + SourceLocation EndLoc) + : OMPClause(llvm::omp::OMPC_novariants, StartLoc, EndLoc), + OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Condition(Cond) { + setPreInitStmt(HelperCond, CaptureRegion); + } + + /// Build an empty clause. + OMPNovariantsClause() + : OMPClause(llvm::omp::OMPC_novariants, SourceLocation(), + SourceLocation()), + OMPClauseWithPreInit(this) {} + + /// Returns the location of '('. + SourceLocation getLParenLoc() const { return LParenLoc; } + + /// Returns condition. + Expr *getCondition() const { return cast_or_null<Expr>(Condition); } + + child_range children() { return child_range(&Condition, &Condition + 1); } + + const_child_range children() const { + return const_child_range(&Condition, &Condition + 1); + } + + child_range used_children(); + const_child_range used_children() const { + auto Children = const_cast<OMPNovariantsClause *>(this)->used_children(); + return const_child_range(Children.begin(), Children.end()); + } + + static bool classof(const OMPClause *T) { + return T->getClauseKind() == llvm::omp::OMPC_novariants; + } +}; + +/// This represents 'nocontext' clause in the '#pragma omp ...' directive. +/// +/// \code +/// #pragma omp dispatch nocontext(a > 5) +/// \endcode +/// In this example directive '#pragma omp dispatch' has simple 'nocontext' +/// clause with condition 'a > 5'. +class OMPNocontextClause final : public OMPClause, public OMPClauseWithPreInit { + friend class OMPClauseReader; + + /// Location of '('. + SourceLocation LParenLoc; + + /// Condition of the 'if' clause. + Stmt *Condition = nullptr; + + /// Set condition. + void setCondition(Expr *Cond) { Condition = Cond; } + + /// Sets the location of '('. + void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } + +public: + /// Build 'nocontext' clause with condition \a Cond. + /// + /// \param Cond Condition of the clause. + /// \param HelperCond Helper condition for the construct. + /// \param CaptureRegion Innermost OpenMP region where expressions in this + /// clause must be captured. + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param EndLoc Ending location of the clause. + OMPNocontextClause(Expr *Cond, Stmt *HelperCond, + OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, + SourceLocation LParenLoc, SourceLocation EndLoc) + : OMPClause(llvm::omp::OMPC_nocontext, StartLoc, EndLoc), + OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Condition(Cond) { + setPreInitStmt(HelperCond, CaptureRegion); + } + + /// Build an empty clause. + OMPNocontextClause() + : OMPClause(llvm::omp::OMPC_nocontext, SourceLocation(), + SourceLocation()), + OMPClauseWithPreInit(this) {} + + /// Returns the location of '('. + SourceLocation getLParenLoc() const { return LParenLoc; } + + /// Returns condition. + Expr *getCondition() const { return cast_or_null<Expr>(Condition); } + + child_range children() { return child_range(&Condition, &Condition + 1); } + + const_child_range children() const { + return const_child_range(&Condition, &Condition + 1); + } + + child_range used_children(); + const_child_range used_children() const { + auto Children = const_cast<OMPNocontextClause *>(this)->used_children(); + return const_child_range(Children.begin(), Children.end()); + } + + static bool classof(const OMPClause *T) { + return T->getClauseKind() == llvm::omp::OMPC_nocontext; + } +}; + /// This represents 'detach' clause in the '#pragma omp task' directive. /// /// \code @@ -7749,6 +8333,77 @@ public: } }; +/// This represents 'filter' clause in the '#pragma omp ...' directive. +/// +/// \code +/// #pragma omp masked filter(tid) +/// \endcode +/// In this example directive '#pragma omp masked' has 'filter' clause with +/// thread id. +class OMPFilterClause final : public OMPClause, public OMPClauseWithPreInit { + friend class OMPClauseReader; + + /// Location of '('. + SourceLocation LParenLoc; + + /// Express of the 'filter' clause. + Stmt *ThreadID = nullptr; + + /// Sets the thread identifier. + void setThreadID(Expr *TID) { ThreadID = TID; } + + /// Sets the location of '('. + void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } + +public: + /// Build 'filter' clause with thread-id \a ThreadID. + /// + /// \param ThreadID Thread identifier. + /// \param HelperE Helper expression associated with this clause. + /// \param CaptureRegion Innermost OpenMP region where expressions in this + /// clause must be captured. + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param EndLoc Ending location of the clause. + OMPFilterClause(Expr *ThreadID, Stmt *HelperE, + OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, + SourceLocation LParenLoc, SourceLocation EndLoc) + : OMPClause(llvm::omp::OMPC_filter, StartLoc, EndLoc), + OMPClauseWithPreInit(this), LParenLoc(LParenLoc), ThreadID(ThreadID) { + setPreInitStmt(HelperE, CaptureRegion); + } + + /// Build an empty clause. + OMPFilterClause() + : OMPClause(llvm::omp::OMPC_filter, SourceLocation(), SourceLocation()), + OMPClauseWithPreInit(this) {} + /// Returns the location of '('. + SourceLocation getLParenLoc() const { return LParenLoc; } + + /// Return thread identifier. + Expr *getThreadID() { return cast<Expr>(ThreadID); } + + /// Return thread identifier. + Expr *getThreadID() const { return cast<Expr>(ThreadID); } + + child_range children() { return child_range(&ThreadID, &ThreadID + 1); } + + const_child_range children() const { + return const_child_range(&ThreadID, &ThreadID + 1); + } + + child_range used_children() { + return child_range(child_iterator(), child_iterator()); + } + const_child_range used_children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + + static bool classof(const OMPClause *T) { + return T->getClauseKind() == llvm::omp::OMPC_filter; + } +}; + /// This class implements a simple visitor for OMPClause /// subclasses. template<class ImplClass, template <typename> class Ptr, typename RetTy> diff --git a/clang/include/clang/AST/OperationKinds.def b/clang/include/clang/AST/OperationKinds.def index 7c82ab6e57ef..b05b9d81569e 100644 --- a/clang/include/clang/AST/OperationKinds.def +++ b/clang/include/clang/AST/OperationKinds.def @@ -181,6 +181,9 @@ CAST_OPERATION(PointerToBoolean) /// (void) malloc(2048) CAST_OPERATION(ToVoid) +/// CK_MatrixCast - A cast between matrix types of the same dimensions. +CAST_OPERATION(MatrixCast) + /// CK_VectorSplat - A conversion from an arithmetic type to a /// vector of that element type. Fills all elements ("splats") with /// the source value. diff --git a/clang/include/clang/AST/ParentMapContext.h b/clang/include/clang/AST/ParentMapContext.h index a0412380a864..2edbc987850d 100644 --- a/clang/include/clang/AST/ParentMapContext.h +++ b/clang/include/clang/AST/ParentMapContext.h @@ -64,9 +64,10 @@ public: Expr *traverseIgnored(Expr *E) const; DynTypedNode traverseIgnored(const DynTypedNode &N) const; + class ParentMap; + private: ASTContext &ASTCtx; - class ParentMap; TraversalKind Traversal = TK_AsIs; std::unique_ptr<ParentMap> Parents; }; diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index 505ea700fd0e..9bfa5b9c2326 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -186,17 +186,18 @@ public: /// code, e.g., implicit constructors and destructors. bool shouldVisitImplicitCode() const { return false; } + /// Return whether this visitor should recurse into lambda body + bool shouldVisitLambdaBody() const { return true; } + /// Return whether this visitor should traverse post-order. bool shouldTraversePostOrder() const { return false; } - /// Recursively visits an entire AST, starting from the top-level Decls - /// in the AST traversal scope (by default, the TranslationUnitDecl). + /// Recursively visits an entire AST, starting from the TranslationUnitDecl. /// \returns false if visitation was terminated early. bool TraverseAST(ASTContext &AST) { - for (Decl *D : AST.getTraversalScope()) - if (!getDerived().TraverseDecl(D)) - return false; - return true; + // Currently just an alias for TraverseDecl(TUDecl), but kept in case + // we change the implementation again. + return getDerived().TraverseDecl(AST.getTranslationUnitDecl()); } /// Recursively visit a statement or expression, by @@ -478,6 +479,8 @@ private: template <typename T> bool TraverseDeclTemplateParameterLists(T *D); + bool TraverseTemplateTypeParamDeclConstraints(const TemplateTypeParmDecl *D); + bool TraverseTemplateArgumentLocsHelper(const TemplateArgumentLoc *TAL, unsigned Count); bool TraverseArrayTypeLocHelper(ArrayTypeLoc TL); @@ -655,8 +658,14 @@ bool RecursiveASTVisitor<Derived>::TraverseDecl(Decl *D) { // As a syntax visitor, by default we want to ignore declarations for // implicit declarations (ones not typed explicitly by the user). - if (!getDerived().shouldVisitImplicitCode() && D->isImplicit()) + if (!getDerived().shouldVisitImplicitCode() && D->isImplicit()) { + // For an implicit template type parameter, its type constraints are not + // implicit and are not represented anywhere else. We still need to visit + // them. + if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(D)) + return TraverseTemplateTypeParamDeclConstraints(TTPD); return true; + } switch (D->getKind()) { #define ABSTRACT_DECL(DECL) @@ -1484,12 +1493,24 @@ DEF_TRAVERSE_DECL(StaticAssertDecl, { TRY_TO(TraverseStmt(D->getMessage())); }) -DEF_TRAVERSE_DECL( - TranslationUnitDecl, - {// Code in an unnamed namespace shows up automatically in - // decls_begin()/decls_end(). Thus we don't need to recurse on - // D->getAnonymousNamespace(). - }) +DEF_TRAVERSE_DECL(TranslationUnitDecl, { + // Code in an unnamed namespace shows up automatically in + // decls_begin()/decls_end(). Thus we don't need to recurse on + // D->getAnonymousNamespace(). + + // If the traversal scope is set, then consider them to be the children of + // the TUDecl, rather than traversing (and loading?) all top-level decls. + auto Scope = D->getASTContext().getTraversalScope(); + bool HasLimitedScope = + Scope.size() != 1 || !isa<TranslationUnitDecl>(Scope.front()); + if (HasLimitedScope) { + ShouldVisitChildren = false; // we'll do that here instead + for (auto *Child : Scope) { + if (!canIgnoreChildDeclWhileTraversingDeclContext(Child)) + TRY_TO(TraverseDecl(Child)); + } + } +}) DEF_TRAVERSE_DECL(PragmaCommentDecl, {}) @@ -1582,6 +1603,8 @@ DEF_TRAVERSE_DECL(UsingDecl, { TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo())); }) +DEF_TRAVERSE_DECL(UsingEnumDecl, {}) + DEF_TRAVERSE_DECL(UsingPackDecl, {}) DEF_TRAVERSE_DECL(UsingDirectiveDecl, { @@ -1776,10 +1799,9 @@ DEF_TRAVERSE_DECL(BuiltinTemplateDecl, { TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); }) -DEF_TRAVERSE_DECL(TemplateTypeParmDecl, { - // D is the "T" in something like "template<typename T> class vector;" - if (D->getTypeForDecl()) - TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0))); +template <typename Derived> +bool RecursiveASTVisitor<Derived>::TraverseTemplateTypeParamDeclConstraints( + const TemplateTypeParmDecl *D) { if (const auto *TC = D->getTypeConstraint()) { if (Expr *IDC = TC->getImmediatelyDeclaredConstraint()) { TRY_TO(TraverseStmt(IDC)); @@ -1791,6 +1813,14 @@ DEF_TRAVERSE_DECL(TemplateTypeParmDecl, { TRY_TO(TraverseConceptReference(*TC)); } } + return true; +} + +DEF_TRAVERSE_DECL(TemplateTypeParmDecl, { + // D is the "T" in something like "template<typename T> class vector;" + if (D->getTypeForDecl()) + TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0))); + TRY_TO(TraverseTemplateTypeParamDeclConstraints(D)); if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) TRY_TO(TraverseTypeLoc(D->getDefaultArgumentInfo()->getTypeLoc())); }) @@ -1828,6 +1858,8 @@ DEF_TRAVERSE_DECL(UnresolvedUsingTypenameDecl, { // source. }) +DEF_TRAVERSE_DECL(UnresolvedUsingIfExistsDecl, {}) + DEF_TRAVERSE_DECL(EnumDecl, { TRY_TO(TraverseDeclTemplateParameterLists(D)); @@ -2057,6 +2089,15 @@ bool RecursiveASTVisitor<Derived>::TraverseFunctionHelper(FunctionDecl *D) { // by clang. (!D->isDefaulted() || getDerived().shouldVisitImplicitCode()); + if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) { + if (const CXXRecordDecl *RD = MD->getParent()) { + if (RD->isLambda() && + declaresSameEntity(RD->getLambdaCallOperator(), MD)) { + VisitBody = VisitBody && getDerived().shouldVisitLambdaBody(); + } + } + } + if (VisitBody) { TRY_TO(TraverseStmt(D->getBody())); // Function body. } @@ -2611,7 +2652,16 @@ DEF_TRAVERSE_STMT(ObjCMessageExpr, { TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc())); }) -DEF_TRAVERSE_STMT(ObjCPropertyRefExpr, {}) +DEF_TRAVERSE_STMT(ObjCPropertyRefExpr, { + if (S->isClassReceiver()) { + ObjCInterfaceDecl *IDecl = S->getClassReceiver(); + QualType Type = IDecl->getASTContext().getObjCInterfaceType(IDecl); + ObjCInterfaceLocInfo Data; + Data.NameLoc = S->getReceiverLocation(); + Data.NameEndLoc = Data.NameLoc; + TRY_TO(TraverseTypeLoc(TypeLoc(Type, &Data))); + } +}) DEF_TRAVERSE_STMT(ObjCSubscriptRefExpr, {}) DEF_TRAVERSE_STMT(ObjCProtocolExpr, {}) DEF_TRAVERSE_STMT(ObjCSelectorExpr, {}) @@ -2624,6 +2674,9 @@ DEF_TRAVERSE_STMT(ObjCBridgedCastExpr, { DEF_TRAVERSE_STMT(ObjCAvailabilityCheckExpr, {}) DEF_TRAVERSE_STMT(ParenExpr, {}) DEF_TRAVERSE_STMT(ParenListExpr, {}) +DEF_TRAVERSE_STMT(SYCLUniqueStableNameExpr, { + TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc())); +}) DEF_TRAVERSE_STMT(PredefinedExpr, {}) DEF_TRAVERSE_STMT(ShuffleVectorExpr, {}) DEF_TRAVERSE_STMT(ConvertVectorExpr, {}) @@ -2775,6 +2828,14 @@ bool RecursiveASTVisitor<Derived>::TraverseOMPExecutableDirective( return true; } +DEF_TRAVERSE_STMT(OMPCanonicalLoop, { + if (!getDerived().shouldVisitImplicitCode()) { + // Visit only the syntactical loop. + TRY_TO(TraverseStmt(S->getLoopStmt())); + ShouldVisitChildren = false; + } +}) + template <typename Derived> bool RecursiveASTVisitor<Derived>::TraverseOMPLoopDirective(OMPLoopDirective *S) { @@ -2787,6 +2848,12 @@ DEF_TRAVERSE_STMT(OMPParallelDirective, DEF_TRAVERSE_STMT(OMPSimdDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) +DEF_TRAVERSE_STMT(OMPTileDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + +DEF_TRAVERSE_STMT(OMPUnrollDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + DEF_TRAVERSE_STMT(OMPForDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) @@ -2945,6 +3012,15 @@ DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeParallelForSimdDirective, DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeSimdDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) +DEF_TRAVERSE_STMT(OMPInteropDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + +DEF_TRAVERSE_STMT(OMPDispatchDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + +DEF_TRAVERSE_STMT(OMPMaskedDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + // OpenMP clauses. template <typename Derived> bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) { @@ -3028,6 +3104,24 @@ bool RecursiveASTVisitor<Derived>::VisitOMPSimdlenClause(OMPSimdlenClause *C) { } template <typename Derived> +bool RecursiveASTVisitor<Derived>::VisitOMPSizesClause(OMPSizesClause *C) { + for (Expr *E : C->getSizesRefs()) + TRY_TO(TraverseStmt(E)); + return true; +} + +template <typename Derived> +bool RecursiveASTVisitor<Derived>::VisitOMPFullClause(OMPFullClause *C) { + return true; +} + +template <typename Derived> +bool RecursiveASTVisitor<Derived>::VisitOMPPartialClause(OMPPartialClause *C) { + TRY_TO(TraverseStmt(C->getFactor())); + return true; +} + +template <typename Derived> bool RecursiveASTVisitor<Derived>::VisitOMPCollapseClause(OMPCollapseClause *C) { TRY_TO(TraverseStmt(C->getNumForLoops())); @@ -3165,7 +3259,36 @@ bool RecursiveASTVisitor<Derived>::VisitOMPNogroupClause(OMPNogroupClause *) { } template <typename Derived> -bool RecursiveASTVisitor<Derived>::VisitOMPDestroyClause(OMPDestroyClause *) { +bool RecursiveASTVisitor<Derived>::VisitOMPInitClause(OMPInitClause *C) { + TRY_TO(VisitOMPClauseList(C)); + return true; +} + +template <typename Derived> +bool RecursiveASTVisitor<Derived>::VisitOMPUseClause(OMPUseClause *C) { + TRY_TO(TraverseStmt(C->getInteropVar())); + return true; +} + +template <typename Derived> +bool RecursiveASTVisitor<Derived>::VisitOMPDestroyClause(OMPDestroyClause *C) { + TRY_TO(TraverseStmt(C->getInteropVar())); + return true; +} + +template <typename Derived> +bool RecursiveASTVisitor<Derived>::VisitOMPNovariantsClause( + OMPNovariantsClause *C) { + TRY_TO(VisitOMPClauseWithPreInit(C)); + TRY_TO(TraverseStmt(C->getCondition())); + return true; +} + +template <typename Derived> +bool RecursiveASTVisitor<Derived>::VisitOMPNocontextClause( + OMPNocontextClause *C) { + TRY_TO(VisitOMPClauseWithPreInit(C)); + TRY_TO(TraverseStmt(C->getCondition())); return true; } @@ -3544,6 +3667,13 @@ bool RecursiveASTVisitor<Derived>::VisitOMPAffinityClause( return true; } +template <typename Derived> +bool RecursiveASTVisitor<Derived>::VisitOMPFilterClause(OMPFilterClause *C) { + TRY_TO(VisitOMPClauseWithPreInit(C)); + TRY_TO(TraverseStmt(C->getThreadID())); + return true; +} + // FIXME: look at the following tricky-seeming exprs to see if we // need to recurse on anything. These are ones that have methods // returning decls or qualtypes or nestednamespecifier -- though I'm diff --git a/clang/include/clang/AST/Redeclarable.h b/clang/include/clang/AST/Redeclarable.h index 87252337a0f4..77b827c52bfb 100644 --- a/clang/include/clang/AST/Redeclarable.h +++ b/clang/include/clang/AST/Redeclarable.h @@ -193,6 +193,7 @@ protected: public: friend class ASTDeclReader; friend class ASTDeclWriter; + friend class IncrementalParser; Redeclarable(const ASTContext &Ctx) : RedeclLink(LatestDeclLink(Ctx)), diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h index c2e69a91e55d..8e1d7df97096 100644 --- a/clang/include/clang/AST/Stmt.h +++ b/clang/include/clang/AST/Stmt.h @@ -518,7 +518,7 @@ protected: unsigned : NumExprBits; - unsigned Kind : 6; + unsigned Kind : 7; unsigned PartOfExplicitCast : 1; // Only set for ImplicitCastExpr. /// True if the call expression has some floating-point features. @@ -1798,6 +1798,7 @@ public: class LabelStmt : public ValueStmt { LabelDecl *TheDecl; Stmt *SubStmt; + bool SideEntry = false; public: /// Build a label statement. @@ -1833,6 +1834,8 @@ public: static bool classof(const Stmt *T) { return T->getStmtClass() == LabelStmtClass; } + bool isSideEntry() const { return SideEntry; } + void setSideEntry(bool SE) { SideEntry = SE; } }; /// Represents an attribute applied to a statement. @@ -2080,6 +2083,7 @@ public: /// If this is an 'if constexpr', determine which substatement will be taken. /// Otherwise, or if the condition is value-dependent, returns None. Optional<const Stmt*> getNondiscardedCase(const ASTContext &Ctx) const; + Optional<Stmt *> getNondiscardedCase(const ASTContext &Ctx); bool isObjCAvailabilityCheck() const; @@ -2119,7 +2123,7 @@ class SwitchStmt final : public Stmt, friend TrailingObjects; /// Points to a linked list of case and default statements. - SwitchCase *FirstCase; + SwitchCase *FirstCase = nullptr; // SwitchStmt is followed by several trailing objects, // some of which optional. Note that it would be more convenient to diff --git a/clang/include/clang/AST/StmtDataCollectors.td b/clang/include/clang/AST/StmtDataCollectors.td index 7cb9f16fbce2..922dd2a20d59 100644 --- a/clang/include/clang/AST/StmtDataCollectors.td +++ b/clang/include/clang/AST/StmtDataCollectors.td @@ -51,7 +51,7 @@ class CallExpr { // Print all template arguments into ArgString llvm::raw_string_ostream OS(ArgString); for (unsigned i = 0; i < Args->size(); ++i) { - Args->get(i).print(Context.getLangOpts(), OS); + Args->get(i).print(Context.getLangOpts(), OS, /*IncludeType*/ true); // Add a padding character so that 'foo<X, XX>()' != 'foo<XX, X>()'. OS << '\n'; } diff --git a/clang/include/clang/AST/StmtIterator.h b/clang/include/clang/AST/StmtIterator.h index bcdb0df829fb..e98408c51a50 100644 --- a/clang/include/clang/AST/StmtIterator.h +++ b/clang/include/clang/AST/StmtIterator.h @@ -74,14 +74,17 @@ protected: }; template <typename DERIVED, typename REFERENCE> -class StmtIteratorImpl : public StmtIteratorBase, - public std::iterator<std::forward_iterator_tag, - REFERENCE, ptrdiff_t, - REFERENCE, REFERENCE> { +class StmtIteratorImpl : public StmtIteratorBase { protected: StmtIteratorImpl(const StmtIteratorBase& RHS) : StmtIteratorBase(RHS) {} public: + using iterator_category = std::forward_iterator_tag; + using value_type = REFERENCE; + using difference_type = std::ptrdiff_t; + using pointer = REFERENCE; + using reference = REFERENCE; + StmtIteratorImpl() = default; StmtIteratorImpl(Stmt **s) : StmtIteratorBase(s) {} StmtIteratorImpl(Decl **dgi, Decl **dge) : StmtIteratorBase(dgi, dge) {} diff --git a/clang/include/clang/AST/StmtOpenMP.h b/clang/include/clang/AST/StmtOpenMP.h index b7bbf15949a0..9c85df741f48 100644 --- a/clang/include/clang/AST/StmtOpenMP.h +++ b/clang/include/clang/AST/StmtOpenMP.h @@ -28,6 +28,238 @@ namespace clang { // AST classes for directives. //===----------------------------------------------------------------------===// +/// Representation of an OpenMP canonical loop. +/// +/// OpenMP 1.0 C/C++, section 2.4.1 for Construct; canonical-shape +/// OpenMP 2.0 C/C++, section 2.4.1 for Construct; canonical-shape +/// OpenMP 2.5, section 2.5.1 Loop Construct; canonical form +/// OpenMP 3.1, section 2.5.1 Loop Construct; canonical form +/// OpenMP 4.0, section 2.6 Canonical Loop Form +/// OpenMP 4.5, section 2.6 Canonical Loop Form +/// OpenMP 5.0, section 2.9.1 Canonical Loop Form +/// OpenMP 5.1, section 2.11.1 Canonical Loop Nest Form +/// +/// An OpenMP canonical loop is a for-statement or range-based for-statement +/// with additional requirements that ensure that the number of iterations is +/// known before entering the loop and allow skipping to an arbitrary iteration. +/// The OMPCanonicalLoop AST node wraps a ForStmt or CXXForRangeStmt that is +/// known to fulfill OpenMP's canonical loop requirements because of being +/// associated to an OMPLoopBasedDirective. That is, the general structure is: +/// +/// OMPLoopBasedDirective +/// [`- CapturedStmt ] +/// [ `- CapturedDecl] +/// ` OMPCanonicalLoop +/// `- ForStmt/CXXForRangeStmt +/// `- Stmt +/// +/// One or multiple CapturedStmt/CapturedDecl pairs may be inserted by some +/// directives such as OMPParallelForDirective, but others do not need them +/// (such as OMPTileDirective). In The OMPCanonicalLoop and +/// ForStmt/CXXForRangeStmt pair is repeated for loop associated with the +/// directive. A OMPCanonicalLoop must not appear in the AST unless associated +/// with a OMPLoopBasedDirective. In an imperfectly nested loop nest, the +/// OMPCanonicalLoop may also be wrapped in a CompoundStmt: +/// +/// [...] +/// ` OMPCanonicalLoop +/// `- ForStmt/CXXForRangeStmt +/// `- CompoundStmt +/// |- Leading in-between code (if any) +/// |- OMPCanonicalLoop +/// | `- ForStmt/CXXForRangeStmt +/// | `- ... +/// `- Trailing in-between code (if any) +/// +/// The leading/trailing in-between code must not itself be a OMPCanonicalLoop +/// to avoid confusion which loop belongs to the nesting. +/// +/// There are three different kinds of iteration variables for different +/// purposes: +/// * Loop user variable: The user-accessible variable with different value for +/// each iteration. +/// * Loop iteration variable: The variable used to identify a loop iteration; +/// for range-based for-statement, this is the hidden iterator '__begin'. For +/// other loops, it is identical to the loop user variable. Must be a +/// random-access iterator, pointer or integer type. +/// * Logical iteration counter: Normalized loop counter starting at 0 and +/// incrementing by one at each iteration. Allows abstracting over the type +/// of the loop iteration variable and is always an unsigned integer type +/// appropriate to represent the range of the loop iteration variable. Its +/// value corresponds to the logical iteration number in the OpenMP +/// specification. +/// +/// This AST node provides two captured statements: +/// * The distance function which computes the number of iterations. +/// * The loop user variable function that computes the loop user variable when +/// given a logical iteration number. +/// +/// These captured statements provide the link between C/C++ semantics and the +/// logical iteration counters used by the OpenMPIRBuilder which is +/// language-agnostic and therefore does not know e.g. how to advance a +/// random-access iterator. The OpenMPIRBuilder will use this information to +/// apply simd, workshare-loop, distribute, taskloop and loop directives to the +/// loop. For compatibility with the non-OpenMPIRBuilder codegen path, an +/// OMPCanonicalLoop can itself also be wrapped into the CapturedStmts of an +/// OMPLoopDirective and skipped when searching for the associated syntactical +/// loop. +/// +/// Example: +/// <code> +/// std::vector<std::string> Container{1,2,3}; +/// for (std::string Str : Container) +/// Body(Str); +/// </code> +/// which is syntactic sugar for approximately: +/// <code> +/// auto &&__range = Container; +/// auto __begin = std::begin(__range); +/// auto __end = std::end(__range); +/// for (; __begin != __end; ++__begin) { +/// std::String Str = *__begin; +/// Body(Str); +/// } +/// </code> +/// In this example, the loop user variable is `Str`, the loop iteration +/// variable is `__begin` of type `std::vector<std::string>::iterator` and the +/// logical iteration number type is `size_t` (unsigned version of +/// `std::vector<std::string>::iterator::difference_type` aka `ptrdiff_t`). +/// Therefore, the distance function will be +/// <code> +/// [&](size_t &Result) { Result = __end - __begin; } +/// </code> +/// and the loop variable function is +/// <code> +/// [&,__begin](std::vector<std::string>::iterator &Result, size_t Logical) { +/// Result = __begin + Logical; +/// } +/// </code> +/// The variable `__begin`, aka the loop iteration variable, is captured by +/// value because it is modified in the loop body, but both functions require +/// the initial value. The OpenMP specification explicitly leaves unspecified +/// when the loop expressions are evaluated such that a capture by reference is +/// sufficient. +class OMPCanonicalLoop : public Stmt { + friend class ASTStmtReader; + friend class ASTStmtWriter; + + /// Children of this AST node. + enum { + LOOP_STMT, + DISTANCE_FUNC, + LOOPVAR_FUNC, + LOOPVAR_REF, + LastSubStmt = LOOPVAR_REF + }; + +private: + /// This AST node's children. + Stmt *SubStmts[LastSubStmt + 1] = {}; + + OMPCanonicalLoop() : Stmt(StmtClass::OMPCanonicalLoopClass) {} + +public: + /// Create a new OMPCanonicalLoop. + static OMPCanonicalLoop *create(const ASTContext &Ctx, Stmt *LoopStmt, + CapturedStmt *DistanceFunc, + CapturedStmt *LoopVarFunc, + DeclRefExpr *LoopVarRef) { + OMPCanonicalLoop *S = new (Ctx) OMPCanonicalLoop(); + S->setLoopStmt(LoopStmt); + S->setDistanceFunc(DistanceFunc); + S->setLoopVarFunc(LoopVarFunc); + S->setLoopVarRef(LoopVarRef); + return S; + } + + /// Create an empty OMPCanonicalLoop for deserialization. + static OMPCanonicalLoop *createEmpty(const ASTContext &Ctx) { + return new (Ctx) OMPCanonicalLoop(); + } + + static bool classof(const Stmt *S) { + return S->getStmtClass() == StmtClass::OMPCanonicalLoopClass; + } + + SourceLocation getBeginLoc() const { return getLoopStmt()->getBeginLoc(); } + SourceLocation getEndLoc() const { return getLoopStmt()->getEndLoc(); } + + /// Return this AST node's children. + /// @{ + child_range children() { + return child_range(&SubStmts[0], &SubStmts[0] + LastSubStmt + 1); + } + const_child_range children() const { + return const_child_range(&SubStmts[0], &SubStmts[0] + LastSubStmt + 1); + } + /// @} + + /// The wrapped syntactic loop statement (ForStmt or CXXForRangeStmt). + /// @{ + Stmt *getLoopStmt() { return SubStmts[LOOP_STMT]; } + const Stmt *getLoopStmt() const { return SubStmts[LOOP_STMT]; } + void setLoopStmt(Stmt *S) { + assert((isa<ForStmt>(S) || isa<CXXForRangeStmt>(S)) && + "Canonical loop must be a for loop (range-based or otherwise)"); + SubStmts[LOOP_STMT] = S; + } + /// @} + + /// The function that computes the number of loop iterations. Can be evaluated + /// before entering the loop but after the syntactical loop's init + /// statement(s). + /// + /// Function signature: void(LogicalTy &Result) + /// Any values necessary to compute the distance are captures of the closure. + /// @{ + CapturedStmt *getDistanceFunc() { + return cast<CapturedStmt>(SubStmts[DISTANCE_FUNC]); + } + const CapturedStmt *getDistanceFunc() const { + return cast<CapturedStmt>(SubStmts[DISTANCE_FUNC]); + } + void setDistanceFunc(CapturedStmt *S) { + assert(S && "Expected non-null captured statement"); + SubStmts[DISTANCE_FUNC] = S; + } + /// @} + + /// The function that computes the loop user variable from a logical iteration + /// counter. Can be evaluated as first statement in the loop. + /// + /// Function signature: void(LoopVarTy &Result, LogicalTy Number) + /// Any other values required to compute the loop user variable (such as start + /// value, step size) are captured by the closure. In particular, the initial + /// value of loop iteration variable is captured by value to be unaffected by + /// previous iterations. + /// @{ + CapturedStmt *getLoopVarFunc() { + return cast<CapturedStmt>(SubStmts[LOOPVAR_FUNC]); + } + const CapturedStmt *getLoopVarFunc() const { + return cast<CapturedStmt>(SubStmts[LOOPVAR_FUNC]); + } + void setLoopVarFunc(CapturedStmt *S) { + assert(S && "Expected non-null captured statement"); + SubStmts[LOOPVAR_FUNC] = S; + } + /// @} + + /// Reference to the loop user variable as accessed in the loop body. + /// @{ + DeclRefExpr *getLoopVarRef() { + return cast<DeclRefExpr>(SubStmts[LOOPVAR_REF]); + } + const DeclRefExpr *getLoopVarRef() const { + return cast<DeclRefExpr>(SubStmts[LOOPVAR_REF]); + } + void setLoopVarRef(DeclRefExpr *E) { + assert(E && "Expected non-null loop variable"); + SubStmts[LOOPVAR_REF] = E; + } + /// @} +}; + /// This is a basic class for representing single OpenMP executable /// directive. /// @@ -228,17 +460,22 @@ public: /// directive). Returns nullptr if no clause of this kind is associated with /// the directive. template <typename SpecificClause> - const SpecificClause *getSingleClause() const { - auto Clauses = getClausesOfKind<SpecificClause>(); + static const SpecificClause *getSingleClause(ArrayRef<OMPClause *> Clauses) { + auto ClausesOfKind = getClausesOfKind<SpecificClause>(Clauses); - if (Clauses.begin() != Clauses.end()) { - assert(std::next(Clauses.begin()) == Clauses.end() && + if (ClausesOfKind.begin() != ClausesOfKind.end()) { + assert(std::next(ClausesOfKind.begin()) == ClausesOfKind.end() && "There are at least 2 clauses of the specified kind"); - return *Clauses.begin(); + return *ClausesOfKind.begin(); } return nullptr; } + template <typename SpecificClause> + const SpecificClause *getSingleClause() const { + return getSingleClause<SpecificClause>(clauses()); + } + /// Returns true if the current directive has one or more clauses of a /// specific kind. template <typename SpecificClause> @@ -440,13 +677,288 @@ public: } }; +/// The base class for all loop-based directives, including loop transformation +/// directives. +class OMPLoopBasedDirective : public OMPExecutableDirective { + friend class ASTStmtReader; + +protected: + /// Number of collapsed loops as specified by 'collapse' clause. + unsigned NumAssociatedLoops = 0; + + /// Build instance of loop directive of class \a Kind. + /// + /// \param SC Statement class. + /// \param Kind Kind of OpenMP directive. + /// \param StartLoc Starting location of the directive (directive keyword). + /// \param EndLoc Ending location of the directive. + /// \param NumAssociatedLoops Number of loops associated with the construct. + /// + OMPLoopBasedDirective(StmtClass SC, OpenMPDirectiveKind Kind, + SourceLocation StartLoc, SourceLocation EndLoc, + unsigned NumAssociatedLoops) + : OMPExecutableDirective(SC, Kind, StartLoc, EndLoc), + NumAssociatedLoops(NumAssociatedLoops) {} + +public: + /// The expressions built to support OpenMP loops in combined/composite + /// pragmas (e.g. pragma omp distribute parallel for) + struct DistCombinedHelperExprs { + /// DistributeLowerBound - used when composing 'omp distribute' with + /// 'omp for' in a same construct. + Expr *LB; + /// DistributeUpperBound - used when composing 'omp distribute' with + /// 'omp for' in a same construct. + Expr *UB; + /// DistributeEnsureUpperBound - used when composing 'omp distribute' + /// with 'omp for' in a same construct, EUB depends on DistUB + Expr *EUB; + /// Distribute loop iteration variable init used when composing 'omp + /// distribute' + /// with 'omp for' in a same construct + Expr *Init; + /// Distribute Loop condition used when composing 'omp distribute' + /// with 'omp for' in a same construct + Expr *Cond; + /// Update of LowerBound for statically scheduled omp loops for + /// outer loop in combined constructs (e.g. 'distribute parallel for') + Expr *NLB; + /// Update of UpperBound for statically scheduled omp loops for + /// outer loop in combined constructs (e.g. 'distribute parallel for') + Expr *NUB; + /// Distribute Loop condition used when composing 'omp distribute' + /// with 'omp for' in a same construct when schedule is chunked. + Expr *DistCond; + /// 'omp parallel for' loop condition used when composed with + /// 'omp distribute' in the same construct and when schedule is + /// chunked and the chunk size is 1. + Expr *ParForInDistCond; + }; + + /// The expressions built for the OpenMP loop CodeGen for the + /// whole collapsed loop nest. + struct HelperExprs { + /// Loop iteration variable. + Expr *IterationVarRef; + /// Loop last iteration number. + Expr *LastIteration; + /// Loop number of iterations. + Expr *NumIterations; + /// Calculation of last iteration. + Expr *CalcLastIteration; + /// Loop pre-condition. + Expr *PreCond; + /// Loop condition. + Expr *Cond; + /// Loop iteration variable init. + Expr *Init; + /// Loop increment. + Expr *Inc; + /// IsLastIteration - local flag variable passed to runtime. + Expr *IL; + /// LowerBound - local variable passed to runtime. + Expr *LB; + /// UpperBound - local variable passed to runtime. + Expr *UB; + /// Stride - local variable passed to runtime. + Expr *ST; + /// EnsureUpperBound -- expression UB = min(UB, NumIterations). + Expr *EUB; + /// Update of LowerBound for statically scheduled 'omp for' loops. + Expr *NLB; + /// Update of UpperBound for statically scheduled 'omp for' loops. + Expr *NUB; + /// PreviousLowerBound - local variable passed to runtime in the + /// enclosing schedule or null if that does not apply. + Expr *PrevLB; + /// PreviousUpperBound - local variable passed to runtime in the + /// enclosing schedule or null if that does not apply. + Expr *PrevUB; + /// DistInc - increment expression for distribute loop when found + /// combined with a further loop level (e.g. in 'distribute parallel for') + /// expression IV = IV + ST + Expr *DistInc; + /// PrevEUB - expression similar to EUB but to be used when loop + /// scheduling uses PrevLB and PrevUB (e.g. in 'distribute parallel for' + /// when ensuring that the UB is either the calculated UB by the runtime or + /// the end of the assigned distribute chunk) + /// expression UB = min (UB, PrevUB) + Expr *PrevEUB; + /// Counters Loop counters. + SmallVector<Expr *, 4> Counters; + /// PrivateCounters Loop counters. + SmallVector<Expr *, 4> PrivateCounters; + /// Expressions for loop counters inits for CodeGen. + SmallVector<Expr *, 4> Inits; + /// Expressions for loop counters update for CodeGen. + SmallVector<Expr *, 4> Updates; + /// Final loop counter values for GodeGen. + SmallVector<Expr *, 4> Finals; + /// List of counters required for the generation of the non-rectangular + /// loops. + SmallVector<Expr *, 4> DependentCounters; + /// List of initializers required for the generation of the non-rectangular + /// loops. + SmallVector<Expr *, 4> DependentInits; + /// List of final conditions required for the generation of the + /// non-rectangular loops. + SmallVector<Expr *, 4> FinalsConditions; + /// Init statement for all captured expressions. + Stmt *PreInits; + + /// Expressions used when combining OpenMP loop pragmas + DistCombinedHelperExprs DistCombinedFields; + + /// Check if all the expressions are built (does not check the + /// worksharing ones). + bool builtAll() { + return IterationVarRef != nullptr && LastIteration != nullptr && + NumIterations != nullptr && PreCond != nullptr && + Cond != nullptr && Init != nullptr && Inc != nullptr; + } + + /// Initialize all the fields to null. + /// \param Size Number of elements in the + /// counters/finals/updates/dependent_counters/dependent_inits/finals_conditions + /// arrays. + void clear(unsigned Size) { + IterationVarRef = nullptr; + LastIteration = nullptr; + CalcLastIteration = nullptr; + PreCond = nullptr; + Cond = nullptr; + Init = nullptr; + Inc = nullptr; + IL = nullptr; + LB = nullptr; + UB = nullptr; + ST = nullptr; + EUB = nullptr; + NLB = nullptr; + NUB = nullptr; + NumIterations = nullptr; + PrevLB = nullptr; + PrevUB = nullptr; + DistInc = nullptr; + PrevEUB = nullptr; + Counters.resize(Size); + PrivateCounters.resize(Size); + Inits.resize(Size); + Updates.resize(Size); + Finals.resize(Size); + DependentCounters.resize(Size); + DependentInits.resize(Size); + FinalsConditions.resize(Size); + for (unsigned I = 0; I < Size; ++I) { + Counters[I] = nullptr; + PrivateCounters[I] = nullptr; + Inits[I] = nullptr; + Updates[I] = nullptr; + Finals[I] = nullptr; + DependentCounters[I] = nullptr; + DependentInits[I] = nullptr; + FinalsConditions[I] = nullptr; + } + PreInits = nullptr; + DistCombinedFields.LB = nullptr; + DistCombinedFields.UB = nullptr; + DistCombinedFields.EUB = nullptr; + DistCombinedFields.Init = nullptr; + DistCombinedFields.Cond = nullptr; + DistCombinedFields.NLB = nullptr; + DistCombinedFields.NUB = nullptr; + DistCombinedFields.DistCond = nullptr; + DistCombinedFields.ParForInDistCond = nullptr; + } + }; + + /// Get number of collapsed loops. + unsigned getLoopsNumber() const { return NumAssociatedLoops; } + + /// Try to find the next loop sub-statement in the specified statement \p + /// CurStmt. + /// \param TryImperfectlyNestedLoops true, if we need to try to look for the + /// imperfectly nested loop. + static Stmt *tryToFindNextInnerLoop(Stmt *CurStmt, + bool TryImperfectlyNestedLoops); + static const Stmt *tryToFindNextInnerLoop(const Stmt *CurStmt, + bool TryImperfectlyNestedLoops) { + return tryToFindNextInnerLoop(const_cast<Stmt *>(CurStmt), + TryImperfectlyNestedLoops); + } + + /// Calls the specified callback function for all the loops in \p CurStmt, + /// from the outermost to the innermost. + static bool doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops, + unsigned NumLoops, + llvm::function_ref<bool(unsigned, Stmt *)> Callback, + llvm::function_ref<void(OMPLoopBasedDirective *)> + OnTransformationCallback); + static bool + doForAllLoops(const Stmt *CurStmt, bool TryImperfectlyNestedLoops, + unsigned NumLoops, + llvm::function_ref<bool(unsigned, const Stmt *)> Callback, + llvm::function_ref<void(const OMPLoopBasedDirective *)> + OnTransformationCallback) { + auto &&NewCallback = [Callback](unsigned Cnt, Stmt *CurStmt) { + return Callback(Cnt, CurStmt); + }; + auto &&NewTransformCb = + [OnTransformationCallback](OMPLoopBasedDirective *A) { + OnTransformationCallback(A); + }; + return doForAllLoops(const_cast<Stmt *>(CurStmt), TryImperfectlyNestedLoops, + NumLoops, NewCallback, NewTransformCb); + } + + /// Calls the specified callback function for all the loops in \p CurStmt, + /// from the outermost to the innermost. + static bool + doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops, + unsigned NumLoops, + llvm::function_ref<bool(unsigned, Stmt *)> Callback) { + auto &&TransformCb = [](OMPLoopBasedDirective *) {}; + return doForAllLoops(CurStmt, TryImperfectlyNestedLoops, NumLoops, Callback, + TransformCb); + } + static bool + doForAllLoops(const Stmt *CurStmt, bool TryImperfectlyNestedLoops, + unsigned NumLoops, + llvm::function_ref<bool(unsigned, const Stmt *)> Callback) { + auto &&NewCallback = [Callback](unsigned Cnt, const Stmt *CurStmt) { + return Callback(Cnt, CurStmt); + }; + return doForAllLoops(const_cast<Stmt *>(CurStmt), TryImperfectlyNestedLoops, + NumLoops, NewCallback); + } + + /// Calls the specified callback function for all the loop bodies in \p + /// CurStmt, from the outermost loop to the innermost. + static void doForAllLoopsBodies( + Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops, + llvm::function_ref<void(unsigned, Stmt *, Stmt *)> Callback); + static void doForAllLoopsBodies( + const Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops, + llvm::function_ref<void(unsigned, const Stmt *, const Stmt *)> Callback) { + auto &&NewCallback = [Callback](unsigned Cnt, Stmt *Loop, Stmt *Body) { + Callback(Cnt, Loop, Body); + }; + doForAllLoopsBodies(const_cast<Stmt *>(CurStmt), TryImperfectlyNestedLoops, + NumLoops, NewCallback); + } + + static bool classof(const Stmt *T) { + if (auto *D = dyn_cast<OMPExecutableDirective>(T)) + return isOpenMPLoopDirective(D->getDirectiveKind()); + return false; + } +}; + /// This is a common base class for loop directives ('omp simd', 'omp /// for', 'omp for simd' etc.). It is responsible for the loop code generation. /// -class OMPLoopDirective : public OMPExecutableDirective { +class OMPLoopDirective : public OMPLoopBasedDirective { friend class ASTStmtReader; - /// Number of collapsed loops as specified by 'collapse' clause. - unsigned CollapsedNum = 0; /// Offsets to the stored exprs. /// This enumeration contains offsets to all the pointers to children @@ -454,7 +966,7 @@ class OMPLoopDirective : public OMPExecutableDirective { /// The first 9 children are necessary for all the loop directives, /// the next 8 are specific to the worksharing ones, and the next 11 are /// used for combined constructs containing two pragmas associated to loops. - /// After the fixed children, three arrays of length CollapsedNum are + /// After the fixed children, three arrays of length NumAssociatedLoops are /// allocated: loop counters, their updates and final values. /// PrevLowerBound and PrevUpperBound are used to communicate blocking /// information in composite constructs which require loop blocking @@ -512,63 +1024,63 @@ class OMPLoopDirective : public OMPExecutableDirective { MutableArrayRef<Expr *> getCounters() { auto **Storage = reinterpret_cast<Expr **>( &Data->getChildren()[getArraysOffset(getDirectiveKind())]); - return llvm::makeMutableArrayRef(Storage, CollapsedNum); + return llvm::makeMutableArrayRef(Storage, getLoopsNumber()); } /// Get the private counters storage. MutableArrayRef<Expr *> getPrivateCounters() { auto **Storage = reinterpret_cast<Expr **>( &Data->getChildren()[getArraysOffset(getDirectiveKind()) + - CollapsedNum]); - return llvm::makeMutableArrayRef(Storage, CollapsedNum); + getLoopsNumber()]); + return llvm::makeMutableArrayRef(Storage, getLoopsNumber()); } /// Get the updates storage. MutableArrayRef<Expr *> getInits() { auto **Storage = reinterpret_cast<Expr **>( &Data->getChildren()[getArraysOffset(getDirectiveKind()) + - 2 * CollapsedNum]); - return llvm::makeMutableArrayRef(Storage, CollapsedNum); + 2 * getLoopsNumber()]); + return llvm::makeMutableArrayRef(Storage, getLoopsNumber()); } /// Get the updates storage. MutableArrayRef<Expr *> getUpdates() { auto **Storage = reinterpret_cast<Expr **>( &Data->getChildren()[getArraysOffset(getDirectiveKind()) + - 3 * CollapsedNum]); - return llvm::makeMutableArrayRef(Storage, CollapsedNum); + 3 * getLoopsNumber()]); + return llvm::makeMutableArrayRef(Storage, getLoopsNumber()); } /// Get the final counter updates storage. MutableArrayRef<Expr *> getFinals() { auto **Storage = reinterpret_cast<Expr **>( &Data->getChildren()[getArraysOffset(getDirectiveKind()) + - 4 * CollapsedNum]); - return llvm::makeMutableArrayRef(Storage, CollapsedNum); + 4 * getLoopsNumber()]); + return llvm::makeMutableArrayRef(Storage, getLoopsNumber()); } /// Get the dependent counters storage. MutableArrayRef<Expr *> getDependentCounters() { auto **Storage = reinterpret_cast<Expr **>( &Data->getChildren()[getArraysOffset(getDirectiveKind()) + - 5 * CollapsedNum]); - return llvm::makeMutableArrayRef(Storage, CollapsedNum); + 5 * getLoopsNumber()]); + return llvm::makeMutableArrayRef(Storage, getLoopsNumber()); } /// Get the dependent inits storage. MutableArrayRef<Expr *> getDependentInits() { auto **Storage = reinterpret_cast<Expr **>( &Data->getChildren()[getArraysOffset(getDirectiveKind()) + - 6 * CollapsedNum]); - return llvm::makeMutableArrayRef(Storage, CollapsedNum); + 6 * getLoopsNumber()]); + return llvm::makeMutableArrayRef(Storage, getLoopsNumber()); } /// Get the finals conditions storage. MutableArrayRef<Expr *> getFinalsConditions() { auto **Storage = reinterpret_cast<Expr **>( &Data->getChildren()[getArraysOffset(getDirectiveKind()) + - 7 * CollapsedNum]); - return llvm::makeMutableArrayRef(Storage, CollapsedNum); + 7 * getLoopsNumber()]); + return llvm::makeMutableArrayRef(Storage, getLoopsNumber()); } protected: @@ -583,8 +1095,7 @@ protected: OMPLoopDirective(StmtClass SC, OpenMPDirectiveKind Kind, SourceLocation StartLoc, SourceLocation EndLoc, unsigned CollapsedNum) - : OMPExecutableDirective(SC, Kind, StartLoc, EndLoc), - CollapsedNum(CollapsedNum) {} + : OMPLoopBasedDirective(SC, Kind, StartLoc, EndLoc, CollapsedNum) {} /// Offset to the start of children expression arrays. static unsigned getArraysOffset(OpenMPDirectiveKind Kind) { @@ -753,180 +1264,6 @@ protected: void setFinalsConditions(ArrayRef<Expr *> A); public: - /// The expressions built to support OpenMP loops in combined/composite - /// pragmas (e.g. pragma omp distribute parallel for) - struct DistCombinedHelperExprs { - /// DistributeLowerBound - used when composing 'omp distribute' with - /// 'omp for' in a same construct. - Expr *LB; - /// DistributeUpperBound - used when composing 'omp distribute' with - /// 'omp for' in a same construct. - Expr *UB; - /// DistributeEnsureUpperBound - used when composing 'omp distribute' - /// with 'omp for' in a same construct, EUB depends on DistUB - Expr *EUB; - /// Distribute loop iteration variable init used when composing 'omp - /// distribute' - /// with 'omp for' in a same construct - Expr *Init; - /// Distribute Loop condition used when composing 'omp distribute' - /// with 'omp for' in a same construct - Expr *Cond; - /// Update of LowerBound for statically scheduled omp loops for - /// outer loop in combined constructs (e.g. 'distribute parallel for') - Expr *NLB; - /// Update of UpperBound for statically scheduled omp loops for - /// outer loop in combined constructs (e.g. 'distribute parallel for') - Expr *NUB; - /// Distribute Loop condition used when composing 'omp distribute' - /// with 'omp for' in a same construct when schedule is chunked. - Expr *DistCond; - /// 'omp parallel for' loop condition used when composed with - /// 'omp distribute' in the same construct and when schedule is - /// chunked and the chunk size is 1. - Expr *ParForInDistCond; - }; - - /// The expressions built for the OpenMP loop CodeGen for the - /// whole collapsed loop nest. - struct HelperExprs { - /// Loop iteration variable. - Expr *IterationVarRef; - /// Loop last iteration number. - Expr *LastIteration; - /// Loop number of iterations. - Expr *NumIterations; - /// Calculation of last iteration. - Expr *CalcLastIteration; - /// Loop pre-condition. - Expr *PreCond; - /// Loop condition. - Expr *Cond; - /// Loop iteration variable init. - Expr *Init; - /// Loop increment. - Expr *Inc; - /// IsLastIteration - local flag variable passed to runtime. - Expr *IL; - /// LowerBound - local variable passed to runtime. - Expr *LB; - /// UpperBound - local variable passed to runtime. - Expr *UB; - /// Stride - local variable passed to runtime. - Expr *ST; - /// EnsureUpperBound -- expression UB = min(UB, NumIterations). - Expr *EUB; - /// Update of LowerBound for statically scheduled 'omp for' loops. - Expr *NLB; - /// Update of UpperBound for statically scheduled 'omp for' loops. - Expr *NUB; - /// PreviousLowerBound - local variable passed to runtime in the - /// enclosing schedule or null if that does not apply. - Expr *PrevLB; - /// PreviousUpperBound - local variable passed to runtime in the - /// enclosing schedule or null if that does not apply. - Expr *PrevUB; - /// DistInc - increment expression for distribute loop when found - /// combined with a further loop level (e.g. in 'distribute parallel for') - /// expression IV = IV + ST - Expr *DistInc; - /// PrevEUB - expression similar to EUB but to be used when loop - /// scheduling uses PrevLB and PrevUB (e.g. in 'distribute parallel for' - /// when ensuring that the UB is either the calculated UB by the runtime or - /// the end of the assigned distribute chunk) - /// expression UB = min (UB, PrevUB) - Expr *PrevEUB; - /// Counters Loop counters. - SmallVector<Expr *, 4> Counters; - /// PrivateCounters Loop counters. - SmallVector<Expr *, 4> PrivateCounters; - /// Expressions for loop counters inits for CodeGen. - SmallVector<Expr *, 4> Inits; - /// Expressions for loop counters update for CodeGen. - SmallVector<Expr *, 4> Updates; - /// Final loop counter values for GodeGen. - SmallVector<Expr *, 4> Finals; - /// List of counters required for the generation of the non-rectangular - /// loops. - SmallVector<Expr *, 4> DependentCounters; - /// List of initializers required for the generation of the non-rectangular - /// loops. - SmallVector<Expr *, 4> DependentInits; - /// List of final conditions required for the generation of the - /// non-rectangular loops. - SmallVector<Expr *, 4> FinalsConditions; - /// Init statement for all captured expressions. - Stmt *PreInits; - - /// Expressions used when combining OpenMP loop pragmas - DistCombinedHelperExprs DistCombinedFields; - - /// Check if all the expressions are built (does not check the - /// worksharing ones). - bool builtAll() { - return IterationVarRef != nullptr && LastIteration != nullptr && - NumIterations != nullptr && PreCond != nullptr && - Cond != nullptr && Init != nullptr && Inc != nullptr; - } - - /// Initialize all the fields to null. - /// \param Size Number of elements in the - /// counters/finals/updates/dependent_counters/dependent_inits/finals_conditions - /// arrays. - void clear(unsigned Size) { - IterationVarRef = nullptr; - LastIteration = nullptr; - CalcLastIteration = nullptr; - PreCond = nullptr; - Cond = nullptr; - Init = nullptr; - Inc = nullptr; - IL = nullptr; - LB = nullptr; - UB = nullptr; - ST = nullptr; - EUB = nullptr; - NLB = nullptr; - NUB = nullptr; - NumIterations = nullptr; - PrevLB = nullptr; - PrevUB = nullptr; - DistInc = nullptr; - PrevEUB = nullptr; - Counters.resize(Size); - PrivateCounters.resize(Size); - Inits.resize(Size); - Updates.resize(Size); - Finals.resize(Size); - DependentCounters.resize(Size); - DependentInits.resize(Size); - FinalsConditions.resize(Size); - for (unsigned i = 0; i < Size; ++i) { - Counters[i] = nullptr; - PrivateCounters[i] = nullptr; - Inits[i] = nullptr; - Updates[i] = nullptr; - Finals[i] = nullptr; - DependentCounters[i] = nullptr; - DependentInits[i] = nullptr; - FinalsConditions[i] = nullptr; - } - PreInits = nullptr; - DistCombinedFields.LB = nullptr; - DistCombinedFields.UB = nullptr; - DistCombinedFields.EUB = nullptr; - DistCombinedFields.Init = nullptr; - DistCombinedFields.Cond = nullptr; - DistCombinedFields.NLB = nullptr; - DistCombinedFields.NUB = nullptr; - DistCombinedFields.DistCond = nullptr; - DistCombinedFields.ParForInDistCond = nullptr; - } - }; - - /// Get number of collapsed loops. - unsigned getCollapsedNumber() const { return CollapsedNum; } - Expr *getIterationVariable() const { return cast<Expr>(Data->getChildren()[IterationVariableOffset]); } @@ -1067,17 +1404,6 @@ public: "expected loop bound distribute sharing directive"); return cast<Expr>(Data->getChildren()[CombinedParForInDistConditionOffset]); } - /// Try to find the next loop sub-statement in the specified statement \p - /// CurStmt. - /// \param TryImperfectlyNestedLoops true, if we need to try to look for the - /// imperfectly nested loop. - static Stmt *tryToFindNextInnerLoop(Stmt *CurStmt, - bool TryImperfectlyNestedLoops); - static const Stmt *tryToFindNextInnerLoop(const Stmt *CurStmt, - bool TryImperfectlyNestedLoops) { - return tryToFindNextInnerLoop(const_cast<Stmt *>(CurStmt), - TryImperfectlyNestedLoops); - } Stmt *getBody(); const Stmt *getBody() const { return const_cast<OMPLoopDirective *>(this)->getBody(); @@ -1263,7 +1589,7 @@ class OMPForDirective : public OMPLoopDirective { /// Sets special task reduction descriptor. void setTaskReductionRefExpr(Expr *E) { - Data->getChildren()[numLoopChildren(getCollapsedNumber(), + Data->getChildren()[numLoopChildren(getLoopsNumber(), llvm::omp::OMPD_for)] = E; } @@ -1303,7 +1629,7 @@ public: /// Returns special task reduction reference expression. Expr *getTaskReductionRefExpr() { return cast_or_null<Expr>(Data->getChildren()[numLoopChildren( - getCollapsedNumber(), llvm::omp::OMPD_for)]); + getLoopsNumber(), llvm::omp::OMPD_for)]); } const Expr *getTaskReductionRefExpr() const { return const_cast<OMPForDirective *>(this)->getTaskReductionRefExpr(); @@ -1728,7 +2054,7 @@ class OMPParallelForDirective : public OMPLoopDirective { /// Sets special task reduction descriptor. void setTaskReductionRefExpr(Expr *E) { - Data->getChildren()[numLoopChildren(getCollapsedNumber(), + Data->getChildren()[numLoopChildren(getLoopsNumber(), llvm::omp::OMPD_parallel_for)] = E; } @@ -1770,7 +2096,7 @@ public: /// Returns special task reduction reference expression. Expr *getTaskReductionRefExpr() { return cast_or_null<Expr>(Data->getChildren()[numLoopChildren( - getCollapsedNumber(), llvm::omp::OMPD_parallel_for)]); + getLoopsNumber(), llvm::omp::OMPD_parallel_for)]); } const Expr *getTaskReductionRefExpr() const { return const_cast<OMPParallelForDirective *>(this) @@ -2884,7 +3210,7 @@ class OMPTargetParallelForDirective : public OMPLoopDirective { /// Sets special task reduction descriptor. void setTaskReductionRefExpr(Expr *E) { Data->getChildren()[numLoopChildren( - getCollapsedNumber(), llvm::omp::OMPD_target_parallel_for)] = E; + getLoopsNumber(), llvm::omp::OMPD_target_parallel_for)] = E; } /// Set cancel state. @@ -2925,7 +3251,7 @@ public: /// Returns special task reduction reference expression. Expr *getTaskReductionRefExpr() { return cast_or_null<Expr>(Data->getChildren()[numLoopChildren( - getCollapsedNumber(), llvm::omp::OMPD_target_parallel_for)]); + getLoopsNumber(), llvm::omp::OMPD_target_parallel_for)]); } const Expr *getTaskReductionRefExpr() const { return const_cast<OMPTargetParallelForDirective *>(this) @@ -3696,7 +4022,7 @@ class OMPDistributeParallelForDirective : public OMPLoopDirective { /// Sets special task reduction descriptor. void setTaskReductionRefExpr(Expr *E) { Data->getChildren()[numLoopChildren( - getCollapsedNumber(), llvm::omp::OMPD_distribute_parallel_for)] = E; + getLoopsNumber(), llvm::omp::OMPD_distribute_parallel_for)] = E; } /// Set cancel state. @@ -3737,7 +4063,7 @@ public: /// Returns special task reduction reference expression. Expr *getTaskReductionRefExpr() { return cast_or_null<Expr>(Data->getChildren()[numLoopChildren( - getCollapsedNumber(), llvm::omp::OMPD_distribute_parallel_for)]); + getLoopsNumber(), llvm::omp::OMPD_distribute_parallel_for)]); } const Expr *getTaskReductionRefExpr() const { return const_cast<OMPDistributeParallelForDirective *>(this) @@ -4255,8 +4581,7 @@ class OMPTeamsDistributeParallelForDirective final : public OMPLoopDirective { /// Sets special task reduction descriptor. void setTaskReductionRefExpr(Expr *E) { Data->getChildren()[numLoopChildren( - getCollapsedNumber(), llvm::omp::OMPD_teams_distribute_parallel_for)] = - E; + getLoopsNumber(), llvm::omp::OMPD_teams_distribute_parallel_for)] = E; } /// Set cancel state. @@ -4295,7 +4620,7 @@ public: /// Returns special task reduction reference expression. Expr *getTaskReductionRefExpr() { return cast_or_null<Expr>(Data->getChildren()[numLoopChildren( - getCollapsedNumber(), llvm::omp::OMPD_teams_distribute_parallel_for)]); + getLoopsNumber(), llvm::omp::OMPD_teams_distribute_parallel_for)]); } const Expr *getTaskReductionRefExpr() const { return const_cast<OMPTeamsDistributeParallelForDirective *>(this) @@ -4472,7 +4797,7 @@ class OMPTargetTeamsDistributeParallelForDirective final /// Sets special task reduction descriptor. void setTaskReductionRefExpr(Expr *E) { Data->getChildren()[numLoopChildren( - getCollapsedNumber(), + getLoopsNumber(), llvm::omp::OMPD_target_teams_distribute_parallel_for)] = E; } @@ -4512,7 +4837,7 @@ public: /// Returns special task reduction reference expression. Expr *getTaskReductionRefExpr() { return cast_or_null<Expr>(Data->getChildren()[numLoopChildren( - getCollapsedNumber(), + getLoopsNumber(), llvm::omp::OMPD_target_teams_distribute_parallel_for)]); } const Expr *getTaskReductionRefExpr() const { @@ -4666,6 +4991,154 @@ public: } }; +/// This represents the '#pragma omp tile' loop transformation directive. +class OMPTileDirective final : public OMPLoopBasedDirective { + friend class ASTStmtReader; + friend class OMPExecutableDirective; + + /// Default list of offsets. + enum { + PreInitsOffset = 0, + TransformedStmtOffset, + }; + + explicit OMPTileDirective(SourceLocation StartLoc, SourceLocation EndLoc, + unsigned NumLoops) + : OMPLoopBasedDirective(OMPTileDirectiveClass, llvm::omp::OMPD_tile, + StartLoc, EndLoc, NumLoops) {} + + void setPreInits(Stmt *PreInits) { + Data->getChildren()[PreInitsOffset] = PreInits; + } + + void setTransformedStmt(Stmt *S) { + Data->getChildren()[TransformedStmtOffset] = S; + } + +public: + /// Create a new AST node representation for '#pragma omp tile'. + /// + /// \param C Context of the AST. + /// \param StartLoc Location of the introducer (e.g. the 'omp' token). + /// \param EndLoc Location of the directive's end (e.g. the tok::eod). + /// \param Clauses The directive's clauses. + /// \param NumLoops Number of associated loops (number of items in the + /// 'sizes' clause). + /// \param AssociatedStmt The outermost associated loop. + /// \param TransformedStmt The loop nest after tiling, or nullptr in + /// dependent contexts. + /// \param PreInits Helper preinits statements for the loop nest. + static OMPTileDirective *Create(const ASTContext &C, SourceLocation StartLoc, + SourceLocation EndLoc, + ArrayRef<OMPClause *> Clauses, + unsigned NumLoops, Stmt *AssociatedStmt, + Stmt *TransformedStmt, Stmt *PreInits); + + /// Build an empty '#pragma omp tile' AST node for deserialization. + /// + /// \param C Context of the AST. + /// \param NumClauses Number of clauses to allocate. + /// \param NumLoops Number of associated loops to allocate. + static OMPTileDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses, + unsigned NumLoops); + + unsigned getNumAssociatedLoops() const { return getLoopsNumber(); } + + /// Gets/sets the associated loops after tiling. + /// + /// This is in de-sugared format stored as a CompoundStmt. + /// + /// \code + /// for (...) + /// ... + /// \endcode + /// + /// Note that if the generated loops a become associated loops of another + /// directive, they may need to be hoisted before them. + Stmt *getTransformedStmt() const { + return Data->getChildren()[TransformedStmtOffset]; + } + + /// Return preinits statement. + Stmt *getPreInits() const { return Data->getChildren()[PreInitsOffset]; } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPTileDirectiveClass; + } +}; + +/// This represents the '#pragma omp unroll' loop transformation directive. +/// +/// \code +/// #pragma omp unroll +/// for (int i = 0; i < 64; ++i) +/// \endcode +class OMPUnrollDirective final : public OMPLoopBasedDirective { + friend class ASTStmtReader; + friend class OMPExecutableDirective; + + /// Default list of offsets. + enum { + PreInitsOffset = 0, + TransformedStmtOffset, + }; + + explicit OMPUnrollDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPLoopBasedDirective(OMPUnrollDirectiveClass, llvm::omp::OMPD_unroll, + StartLoc, EndLoc, 1) {} + + /// Set the pre-init statements. + void setPreInits(Stmt *PreInits) { + Data->getChildren()[PreInitsOffset] = PreInits; + } + + /// Set the de-sugared statement. + void setTransformedStmt(Stmt *S) { + Data->getChildren()[TransformedStmtOffset] = S; + } + +public: + /// Create a new AST node representation for '#pragma omp unroll'. + /// + /// \param C Context of the AST. + /// \param StartLoc Location of the introducer (e.g. the 'omp' token). + /// \param EndLoc Location of the directive's end (e.g. the tok::eod). + /// \param Clauses The directive's clauses. + /// \param AssociatedStmt The outermost associated loop. + /// \param TransformedStmt The loop nest after tiling, or nullptr in + /// dependent contexts. + /// \param PreInits Helper preinits statements for the loop nest. + static OMPUnrollDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, + Stmt *TransformedStmt, Stmt *PreInits); + + /// Build an empty '#pragma omp unroll' AST node for deserialization. + /// + /// \param C Context of the AST. + /// \param NumClauses Number of clauses to allocate. + static OMPUnrollDirective *CreateEmpty(const ASTContext &C, + unsigned NumClauses); + + /// Get the de-sugared associated loops after unrolling. + /// + /// This is only used if the unrolled loop becomes an associated loop of + /// another directive, otherwise the loop is emitted directly using loop + /// transformation metadata. When the unrolled loop cannot be used by another + /// directive (e.g. because of the full clause), the transformed stmt can also + /// be nullptr. + Stmt *getTransformedStmt() const { + return Data->getChildren()[TransformedStmtOffset]; + } + + /// Return the pre-init statements. + Stmt *getPreInits() const { return Data->getChildren()[PreInitsOffset]; } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPUnrollDirectiveClass; + } +}; + /// This represents '#pragma omp scan' directive. /// /// \code @@ -4718,6 +5191,175 @@ public: } }; +/// This represents '#pragma omp interop' directive. +/// +/// \code +/// #pragma omp interop init(target:obj) device(x) depend(inout:y) nowait +/// \endcode +/// In this example directive '#pragma omp interop' has +/// clauses 'init', 'device', 'depend' and 'nowait'. +/// +class OMPInteropDirective final : public OMPExecutableDirective { + friend class ASTStmtReader; + friend class OMPExecutableDirective; + + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive. + /// \param EndLoc Ending location of the directive. + /// + OMPInteropDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPInteropDirectiveClass, + llvm::omp::OMPD_interop, StartLoc, EndLoc) {} + + /// Build an empty directive. + /// + explicit OMPInteropDirective() + : OMPExecutableDirective(OMPInteropDirectiveClass, + llvm::omp::OMPD_interop, SourceLocation(), + SourceLocation()) {} + +public: + /// Creates directive. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive. + /// \param EndLoc Ending Location of the directive. + /// \param Clauses The directive's clauses. + /// + static OMPInteropDirective *Create(const ASTContext &C, + SourceLocation StartLoc, + SourceLocation EndLoc, + ArrayRef<OMPClause *> Clauses); + + /// Creates an empty directive. + /// + /// \param C AST context. + /// + static OMPInteropDirective *CreateEmpty(const ASTContext &C, + unsigned NumClauses, EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPInteropDirectiveClass; + } +}; + +/// This represents '#pragma omp dispatch' directive. +/// +/// \code +/// #pragma omp dispatch device(dnum) +/// \endcode +/// This example shows a directive '#pragma omp dispatch' with a +/// device clause with variable 'dnum'. +/// +class OMPDispatchDirective final : public OMPExecutableDirective { + friend class ASTStmtReader; + friend class OMPExecutableDirective; + + /// The location of the target-call. + SourceLocation TargetCallLoc; + + /// Set the location of the target-call. + void setTargetCallLoc(SourceLocation Loc) { TargetCallLoc = Loc; } + + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// + OMPDispatchDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPDispatchDirectiveClass, + llvm::omp::OMPD_dispatch, StartLoc, EndLoc) {} + + /// Build an empty directive. + /// + explicit OMPDispatchDirective() + : OMPExecutableDirective(OMPDispatchDirectiveClass, + llvm::omp::OMPD_dispatch, SourceLocation(), + SourceLocation()) {} + +public: + /// Creates directive with a list of \a Clauses. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// \param Clauses List of clauses. + /// \param AssociatedStmt Statement, associated with the directive. + /// \param TargetCallLoc Location of the target-call. + /// + static OMPDispatchDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, + SourceLocation TargetCallLoc); + + /// Creates an empty directive with the place for \a NumClauses + /// clauses. + /// + /// \param C AST context. + /// \param NumClauses Number of clauses. + /// + static OMPDispatchDirective *CreateEmpty(const ASTContext &C, + unsigned NumClauses, EmptyShell); + + /// Return location of target-call. + SourceLocation getTargetCallLoc() const { return TargetCallLoc; } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPDispatchDirectiveClass; + } +}; + +/// This represents '#pragma omp masked' directive. +/// \code +/// #pragma omp masked filter(tid) +/// \endcode +/// This example shows a directive '#pragma omp masked' with a filter clause +/// with variable 'tid'. +/// +class OMPMaskedDirective final : public OMPExecutableDirective { + friend class ASTStmtReader; + friend class OMPExecutableDirective; + + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// + OMPMaskedDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPMaskedDirectiveClass, llvm::omp::OMPD_masked, + StartLoc, EndLoc) {} + + /// Build an empty directive. + /// + explicit OMPMaskedDirective() + : OMPExecutableDirective(OMPMaskedDirectiveClass, llvm::omp::OMPD_masked, + SourceLocation(), SourceLocation()) {} + +public: + /// Creates directive. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// \param AssociatedStmt Statement, associated with the directive. + /// + static OMPMaskedDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt); + + /// Creates an empty directive. + /// + /// \param C AST context. + /// + static OMPMaskedDirective *CreateEmpty(const ASTContext &C, + unsigned NumClauses, EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPMaskedDirectiveClass; + } +}; + } // end namespace clang #endif diff --git a/clang/include/clang/AST/TemplateBase.h b/clang/include/clang/AST/TemplateBase.h index 1671637521e2..fa27a12cfbb9 100644 --- a/clang/include/clang/AST/TemplateBase.h +++ b/clang/include/clang/AST/TemplateBase.h @@ -389,7 +389,8 @@ public: TemplateArgument getPackExpansionPattern() const; /// Print this template argument to the given output stream. - void print(const PrintingPolicy &Policy, raw_ostream &Out) const; + void print(const PrintingPolicy &Policy, raw_ostream &Out, + bool IncludeType) const; /// Debugging aid that dumps the template argument. void dump(raw_ostream &Out) const; @@ -512,7 +513,8 @@ public: } TypeSourceInfo *getTypeSourceInfo() const { - assert(Argument.getKind() == TemplateArgument::Type); + if (Argument.getKind() != TemplateArgument::Type) + return nullptr; return LocInfo.getAsTypeSourceInfo(); } diff --git a/clang/include/clang/AST/TextNodeDumper.h b/clang/include/clang/AST/TextNodeDumper.h index 15ca348f4766..0eb0031de11f 100644 --- a/clang/include/clang/AST/TextNodeDumper.h +++ b/clang/include/clang/AST/TextNodeDumper.h @@ -19,6 +19,7 @@ #include "clang/AST/CommentCommandTraits.h" #include "clang/AST/CommentVisitor.h" #include "clang/AST/DeclVisitor.h" +#include "clang/AST/ExprConcepts.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/StmtVisitor.h" #include "clang/AST/TemplateArgumentVisitor.h" @@ -69,10 +70,8 @@ public: return; } - // We need to capture an owning-string in the lambda because the lambda - // is invoked in a deferred manner. - std::string LabelStr(Label); - auto DumpWithIndent = [this, DoAddChild, LabelStr](bool IsLastChild) { + auto DumpWithIndent = [this, DoAddChild, + Label(Label.str())](bool IsLastChild) { // Print out the appropriate tree structure and work out the prefix for // children of this node. For instance: // @@ -89,8 +88,8 @@ public: OS << '\n'; ColorScope Color(OS, ShowColors, IndentColor); OS << Prefix << (IsLastChild ? '`' : '|') << '-'; - if (!LabelStr.empty()) - OS << LabelStr << ": "; + if (!Label.empty()) + OS << Label << ": "; this->Prefix.push_back(IsLastChild ? ' ' : '|'); this->Prefix.push_back(' '); @@ -190,6 +189,8 @@ public: void Visit(const GenericSelectionExpr::ConstAssociation &A); + void Visit(const concepts::Requirement *R); + void Visit(const APValue &Value, QualType Ty); void dumpPointer(const void *Ptr); @@ -251,6 +252,7 @@ public: void VisitCastExpr(const CastExpr *Node); void VisitImplicitCastExpr(const ImplicitCastExpr *Node); void VisitDeclRefExpr(const DeclRefExpr *Node); + void VisitSYCLUniqueStableNameExpr(const SYCLUniqueStableNameExpr *Node); void VisitPredefinedExpr(const PredefinedExpr *Node); void VisitCharacterLiteral(const CharacterLiteral *Node); void VisitIntegerLiteral(const IntegerLiteral *Node); @@ -297,6 +299,7 @@ public: void VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node); void VisitOMPIteratorExpr(const OMPIteratorExpr *Node); void VisitConceptSpecializationExpr(const ConceptSpecializationExpr *Node); + void VisitRequiresExpr(const RequiresExpr *Node); void VisitRValueReferenceType(const ReferenceType *T); void VisitArrayType(const ArrayType *T); @@ -352,6 +355,7 @@ public: void VisitUsingDecl(const UsingDecl *D); void VisitUnresolvedUsingTypenameDecl(const UnresolvedUsingTypenameDecl *D); void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D); + void VisitUsingEnumDecl(const UsingEnumDecl *D); void VisitUsingShadowDecl(const UsingShadowDecl *D); void VisitConstructorUsingShadowDecl(const ConstructorUsingShadowDecl *D); void VisitLinkageSpecDecl(const LinkageSpecDecl *D); diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 319d3850346b..9f46d5337897 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -486,9 +486,16 @@ public: // allocated on device, which are a subset of __global. (A == LangAS::opencl_global && (B == LangAS::opencl_global_device || B == LangAS::opencl_global_host)) || + (A == LangAS::sycl_global && (B == LangAS::sycl_global_device || + B == LangAS::sycl_global_host)) || // Consider pointer size address spaces to be equivalent to default. ((isPtrSizeAddressSpace(A) || A == LangAS::Default) && - (isPtrSizeAddressSpace(B) || B == LangAS::Default)); + (isPtrSizeAddressSpace(B) || B == LangAS::Default)) || + // Default is a superset of SYCL address spaces. + (A == LangAS::Default && + (B == LangAS::sycl_private || B == LangAS::sycl_local || + B == LangAS::sycl_global || B == LangAS::sycl_global_device || + B == LangAS::sycl_global_host)); } /// Returns true if the address space in these qualifiers is equal to or @@ -2492,6 +2499,9 @@ public: // PPC MMA Types #define PPC_VECTOR_TYPE(Name, Id, Size) Id, #include "clang/Basic/PPCTypes.def" +// RVV Types +#define RVV_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/RISCVVTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id @@ -5412,8 +5422,13 @@ class ElaboratedType final ElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, QualType CanonType, TagDecl *OwnedTagDecl) : TypeWithKeyword(Keyword, Elaborated, CanonType, + // Any semantic dependence on the qualifier will have + // been incorporated into NamedType. We still need to + // track syntactic (instantiation / error / pack) + // dependence on the qualifier. NamedType->getDependence() | - (NNS ? toTypeDependence(NNS->getDependence()) + (NNS ? toSyntacticDependence( + toTypeDependence(NNS->getDependence())) : TypeDependence::None)), NNS(NNS), NamedType(NamedType) { ElaboratedTypeBits.HasOwnedTagDecl = false; diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index ffcc8290938f..438d5af5a2e2 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -769,6 +769,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.ID##Ty; #include "clang/Basic/PPCTypes.def" +#define RVV_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/RISCVVTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/AST/VTableBuilder.h b/clang/include/clang/AST/VTableBuilder.h index 241dd13f903e..e451f3f861b7 100644 --- a/clang/include/clang/AST/VTableBuilder.h +++ b/clang/include/clang/AST/VTableBuilder.h @@ -18,6 +18,7 @@ #include "clang/AST/GlobalDecl.h" #include "clang/AST/RecordLayout.h" #include "clang/Basic/ABI.h" +#include "clang/Basic/Thunk.h" #include "llvm/ADT/DenseMap.h" #include <memory> #include <utility> diff --git a/clang/include/clang/ASTMatchers/ASTMatchFinder.h b/clang/include/clang/ASTMatchers/ASTMatchFinder.h index 81125ad8d96d..91024f9425e0 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchFinder.h +++ b/clang/include/clang/ASTMatchers/ASTMatchFinder.h @@ -110,6 +110,12 @@ public: /// This id is used, for example, for the profiling output. /// It defaults to "<unknown>". virtual StringRef getID() const; + + /// TraversalKind to use while matching and processing + /// the result nodes. This API is temporary to facilitate + /// third parties porting existing code to the default + /// behavior of clang-tidy. + virtual llvm::Optional<TraversalKind> getCheckTraversalKind() const; }; /// Called when parsing is finished. Intended for testing only. @@ -280,6 +286,11 @@ public: void run(const MatchFinder::MatchResult &Result) override { Nodes.push_back(Result.Nodes); } + + llvm::Optional<TraversalKind> getCheckTraversalKind() const override { + return llvm::None; + } + SmallVector<BoundNodes, 1> Nodes; }; } diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h index 6f6dfab59a39..8e3ee6cb9e7e 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -144,6 +144,7 @@ using TypeMatcher = internal::Matcher<QualType>; using TypeLocMatcher = internal::Matcher<TypeLoc>; using NestedNameSpecifierMatcher = internal::Matcher<NestedNameSpecifier>; using NestedNameSpecifierLocMatcher = internal::Matcher<NestedNameSpecifierLoc>; +using CXXBaseSpecifierMatcher = internal::Matcher<CXXBaseSpecifier>; using CXXCtorInitializerMatcher = internal::Matcher<CXXCtorInitializer>; using TemplateArgumentMatcher = internal::Matcher<TemplateArgument>; using TemplateArgumentLocMatcher = internal::Matcher<TemplateArgumentLoc>; @@ -344,9 +345,19 @@ extern const internal::VariadicAllOfMatcher<Decl> decl; /// int number = 42; /// auto [foo, bar] = std::make_pair{42, 42}; /// \endcode -extern const internal::VariadicAllOfMatcher<DecompositionDecl> +extern const internal::VariadicDynCastAllOfMatcher<Decl, DecompositionDecl> decompositionDecl; +/// Matches binding declarations +/// Example matches \c foo and \c bar +/// (matcher = bindingDecl() +/// +/// \code +/// auto [foo, bar] = std::make_pair{42, 42}; +/// \endcode +extern const internal::VariadicDynCastAllOfMatcher<Decl, BindingDecl> + bindingDecl; + /// Matches a declaration of a linkage specification. /// /// Given @@ -506,6 +517,15 @@ extern const internal::VariadicDynCastAllOfMatcher<Decl, ParmVarDecl> extern const internal::VariadicDynCastAllOfMatcher<Decl, AccessSpecDecl> accessSpecDecl; +/// Matches class bases. +/// +/// Examples matches \c public virtual B. +/// \code +/// class B {}; +/// class C : public virtual B {}; +/// \endcode +extern const internal::VariadicAllOfMatcher<CXXBaseSpecifier> cxxBaseSpecifier; + /// Matches constructor initializers. /// /// Examples matches \c i(42). @@ -825,26 +845,16 @@ traverse(TraversalKind TK, const internal::ArgumentAdaptingMatcherFuncAdaptor< ToTypes>>(TK, InnerMatcher); } -template <template <typename T, typename P1> class MatcherT, typename P1, +template <template <typename T, typename... P> class MatcherT, typename... P, typename ReturnTypesF> internal::TraversalWrapper< - internal::PolymorphicMatcherWithParam1<MatcherT, P1, ReturnTypesF>> -traverse(TraversalKind TK, const internal::PolymorphicMatcherWithParam1< - MatcherT, P1, ReturnTypesF> &InnerMatcher) { - return internal::TraversalWrapper< - internal::PolymorphicMatcherWithParam1<MatcherT, P1, ReturnTypesF>>( - TK, InnerMatcher); -} - -template <template <typename T, typename P1, typename P2> class MatcherT, - typename P1, typename P2, typename ReturnTypesF> -internal::TraversalWrapper< - internal::PolymorphicMatcherWithParam2<MatcherT, P1, P2, ReturnTypesF>> -traverse(TraversalKind TK, const internal::PolymorphicMatcherWithParam2< - MatcherT, P1, P2, ReturnTypesF> &InnerMatcher) { + internal::PolymorphicMatcher<MatcherT, ReturnTypesF, P...>> +traverse(TraversalKind TK, + const internal::PolymorphicMatcher<MatcherT, ReturnTypesF, P...> + &InnerMatcher) { return internal::TraversalWrapper< - internal::PolymorphicMatcherWithParam2<MatcherT, P1, P2, ReturnTypesF>>( - TK, InnerMatcher); + internal::PolymorphicMatcher<MatcherT, ReturnTypesF, P...>>(TK, + InnerMatcher); } template <typename... T> @@ -903,7 +913,7 @@ AST_MATCHER_P(Expr, ignoringImplicit, internal::Matcher<Expr>, /// varDecl(hasInitializer(integerLiteral())) /// varDecl(hasInitializer(declRefExpr())) /// \endcode -/// only match the declarations for b, c, and d. +/// only match the declarations for a. AST_MATCHER_P(Expr, ignoringImpCasts, internal::Matcher<Expr>, InnerMatcher) { return InnerMatcher.matches(*Node.IgnoreImpCasts(), Finder, Builder); @@ -1203,7 +1213,7 @@ AST_MATCHER_P(TemplateArgument, equalsIntegralValue, std::string, Value) { if (Node.getKind() != TemplateArgument::Integral) return false; - return Node.getAsIntegral().toString(10) == Value; + return toString(Node.getAsIntegral(), 10) == Value; } /// Matches an Objective-C autorelease pool statement. @@ -1742,6 +1752,18 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, /// matches \code using X::x \endcode extern const internal::VariadicDynCastAllOfMatcher<Decl, UsingDecl> usingDecl; +/// Matches using-enum declarations. +/// +/// Given +/// \code +/// namespace X { enum x {...}; } +/// using enum X::x; +/// \endcode +/// usingEnumDecl() +/// matches \code using enum X::x \endcode +extern const internal::VariadicDynCastAllOfMatcher<Decl, UsingEnumDecl> + usingEnumDecl; + /// Matches using namespace declarations. /// /// Given @@ -2162,6 +2184,17 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, BreakStmt> breakStmt; extern const internal::VariadicDynCastAllOfMatcher<Stmt, ContinueStmt> continueStmt; +/// Matches co_return statements. +/// +/// Given +/// \code +/// while (true) { co_return; } +/// \endcode +/// coreturnStmt() +/// matches 'co_return' +extern const internal::VariadicDynCastAllOfMatcher<Stmt, CoreturnStmt> + coreturnStmt; + /// Matches return statements. /// /// Given @@ -2379,6 +2412,30 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, UserDefinedLiteral> extern const internal::VariadicDynCastAllOfMatcher<Stmt, CompoundLiteralExpr> compoundLiteralExpr; +/// Matches co_await expressions. +/// +/// Given +/// \code +/// co_await 1; +/// \endcode +/// coawaitExpr() +/// matches 'co_await 1' +extern const internal::VariadicDynCastAllOfMatcher<Stmt, CoawaitExpr> + coawaitExpr; +/// Matches co_await expressions where the type of the promise is dependent +extern const internal::VariadicDynCastAllOfMatcher<Stmt, DependentCoawaitExpr> + dependentCoawaitExpr; +/// Matches co_yield expressions. +/// +/// Given +/// \code +/// co_yield 1; +/// \endcode +/// coyieldExpr() +/// matches 'co_yield 1' +extern const internal::VariadicDynCastAllOfMatcher<Stmt, CoyieldExpr> + coyieldExpr; + /// Matches nullptr literal. extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNullPtrLiteralExpr> cxxNullPtrLiteralExpr; @@ -2829,6 +2886,42 @@ extern const internal::MapAnyOfMatcher<BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator> binaryOperation; +/// Matches function calls and constructor calls +/// +/// Because CallExpr and CXXConstructExpr do not share a common +/// base class with API accessing arguments etc, AST Matchers for code +/// which should match both are typically duplicated. This matcher +/// removes the need for duplication. +/// +/// Given code +/// \code +/// struct ConstructorTakesInt +/// { +/// ConstructorTakesInt(int i) {} +/// }; +/// +/// void callTakesInt(int i) +/// { +/// } +/// +/// void doCall() +/// { +/// callTakesInt(42); +/// } +/// +/// void doConstruct() +/// { +/// ConstructorTakesInt cti(42); +/// } +/// \endcode +/// +/// The matcher +/// \code +/// invocation(hasArgument(0, integerLiteral(equals(42)))) +/// \endcode +/// matches the expression in both doCall and doConstruct +extern const internal::MapAnyOfMatcher<CallExpr, CXXConstructExpr> invocation; + /// Matches unary expressions that have a specific type of argument. /// /// Given @@ -2950,14 +3043,15 @@ AST_MATCHER_REGEX(NamedDecl, matchesName, RegExp) { /// matches the declaration of \c A. /// /// Usable as: Matcher<CXXOperatorCallExpr>, Matcher<FunctionDecl> -inline internal::PolymorphicMatcherWithParam1< - internal::HasOverloadedOperatorNameMatcher, std::vector<std::string>, - AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)> +inline internal::PolymorphicMatcher< + internal::HasOverloadedOperatorNameMatcher, + AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl), + std::vector<std::string>> hasOverloadedOperatorName(StringRef Name) { - return internal::PolymorphicMatcherWithParam1< - internal::HasOverloadedOperatorNameMatcher, std::vector<std::string>, - AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)>( - {std::string(Name)}); + return internal::PolymorphicMatcher< + internal::HasOverloadedOperatorNameMatcher, + AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl), + std::vector<std::string>>({std::string(Name)}); } /// Matches overloaded operator names. @@ -2969,9 +3063,10 @@ hasOverloadedOperatorName(StringRef Name) { /// Is equivalent to /// anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-")) extern const internal::VariadicFunction< - internal::PolymorphicMatcherWithParam1< - internal::HasOverloadedOperatorNameMatcher, std::vector<std::string>, - AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)>, + internal::PolymorphicMatcher<internal::HasOverloadedOperatorNameMatcher, + AST_POLYMORPHIC_SUPPORTED_TYPES( + CXXOperatorCallExpr, FunctionDecl), + std::vector<std::string>>, StringRef, internal::hasAnyOverloadedOperatorNameFunc> hasAnyOverloadedOperatorName; @@ -3460,13 +3555,14 @@ extern const internal::VariadicOperatorMatcherFunc<1, 1> unless; /// Matcher<TagType>, Matcher<TemplateSpecializationType>, /// Matcher<TemplateTypeParmType>, Matcher<TypedefType>, /// Matcher<UnresolvedUsingType> -inline internal::PolymorphicMatcherWithParam1< - internal::HasDeclarationMatcher, internal::Matcher<Decl>, - void(internal::HasDeclarationSupportedTypes)> +inline internal::PolymorphicMatcher< + internal::HasDeclarationMatcher, + void(internal::HasDeclarationSupportedTypes), internal::Matcher<Decl>> hasDeclaration(const internal::Matcher<Decl> &InnerMatcher) { - return internal::PolymorphicMatcherWithParam1< - internal::HasDeclarationMatcher, internal::Matcher<Decl>, - void(internal::HasDeclarationSupportedTypes)>(InnerMatcher); + return internal::PolymorphicMatcher< + internal::HasDeclarationMatcher, + void(internal::HasDeclarationSupportedTypes), internal::Matcher<Decl>>( + InnerMatcher); } /// Matches a \c NamedDecl whose underlying declaration matches the given @@ -3751,16 +3847,19 @@ AST_MATCHER_P_OVERLOAD(CallExpr, callee, internal::Matcher<Decl>, InnerMatcher, /// and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) /// and U (matcher = typedefDecl(hasType(asString("int"))) /// and friend class X (matcher = friendDecl(hasType("X")) +/// and public virtual X (matcher = cxxBaseSpecifier(hasType( +/// asString("class X"))) /// \code /// class X {}; /// void y(X &x) { x; X z; } /// typedef int U; /// class Y { friend class X; }; +/// class Z : public virtual X {}; /// \endcode AST_POLYMORPHIC_MATCHER_P_OVERLOAD( hasType, AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, TypedefNameDecl, - ValueDecl), + ValueDecl, CXXBaseSpecifier), internal::Matcher<QualType>, InnerMatcher, 0) { QualType QT = internal::getUnderlyingType(Node); if (!QT.isNull()) @@ -3780,10 +3879,13 @@ AST_POLYMORPHIC_MATCHER_P_OVERLOAD( /// Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) /// and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) /// and friend class X (matcher = friendDecl(hasType("X")) +/// and public virtual X (matcher = cxxBaseSpecifier(hasType( +/// cxxRecordDecl(hasName("X")))) /// \code /// class X {}; /// void y(X &x) { x; X z; } /// class Y { friend class X; }; +/// class Z : public virtual X {}; /// \endcode /// /// Example matches class Derived @@ -3806,20 +3908,51 @@ AST_POLYMORPHIC_MATCHER_P_OVERLOAD( return false; } -/// Matches if the type location of the declarator decl's type matches -/// the inner matcher. +/// Matches if the type location of a node matches the inner matcher. /// -/// Given +/// Examples: /// \code /// int x; /// \endcode /// declaratorDecl(hasTypeLoc(loc(asString("int")))) /// matches int x -AST_MATCHER_P(DeclaratorDecl, hasTypeLoc, internal::Matcher<TypeLoc>, Inner) { - if (!Node.getTypeSourceInfo()) +/// +/// \code +/// auto x = int(3); +/// \code +/// cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) +/// matches int(3) +/// +/// \code +/// struct Foo { Foo(int, int); }; +/// auto x = Foo(1, 2); +/// \code +/// cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) +/// matches Foo(1, 2) +/// +/// Usable as: Matcher<BlockDecl>, Matcher<CXXBaseSpecifier>, +/// Matcher<CXXCtorInitializer>, Matcher<CXXFunctionalCastExpr>, +/// Matcher<CXXNewExpr>, Matcher<CXXTemporaryObjectExpr>, +/// Matcher<CXXUnresolvedConstructExpr>, +/// Matcher<ClassTemplateSpecializationDecl>, Matcher<CompoundLiteralExpr>, +/// Matcher<DeclaratorDecl>, Matcher<ExplicitCastExpr>, +/// Matcher<ObjCPropertyDecl>, Matcher<TemplateArgumentLoc>, +/// Matcher<TypedefNameDecl> +AST_POLYMORPHIC_MATCHER_P( + hasTypeLoc, + AST_POLYMORPHIC_SUPPORTED_TYPES( + BlockDecl, CXXBaseSpecifier, CXXCtorInitializer, CXXFunctionalCastExpr, + CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr, + ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl, + ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, + TypedefNameDecl), + internal::Matcher<TypeLoc>, Inner) { + TypeSourceInfo *source = internal::GetTypeSourceInfo(Node); + if (source == nullptr) { // This happens for example for implicit destructors. return false; - return Inner.matches(Node.getTypeSourceInfo()->getTypeLoc(), Finder, Builder); + } + return Inner.matches(source->getTypeLoc(), Finder, Builder); } /// Matches if the matched type is represented by the given string. @@ -4667,8 +4800,11 @@ AST_POLYMORPHIC_MATCHER_P2(forEachArgumentWithParamType, int ParamIndex = 0; bool Matched = false; + unsigned NumArgs = Node.getNumArgs(); + if (FProto && FProto->isVariadic()) + NumArgs = std::min(NumArgs, FProto->getNumParams()); - for (; ArgIndex < Node.getNumArgs(); ++ArgIndex, ++ParamIndex) { + for (; ArgIndex < NumArgs; ++ArgIndex, ++ParamIndex) { BoundNodesTreeBuilder ArgMatches(*Builder); if (ArgMatcher.matches(*(Node.getArg(ArgIndex)->IgnoreParenCasts()), Finder, &ArgMatches)) { @@ -5178,7 +5314,7 @@ AST_POLYMORPHIC_MATCHER_P(hasBody, /// void f() {} /// void g(); /// \endcode -/// hasAnyBody(functionDecl()) +/// functionDecl(hasAnyBody(compoundStmt())) /// matches both 'void f();' /// and 'void f() {}' /// with compoundStmt() @@ -5253,11 +5389,12 @@ AST_MATCHER_P(CompoundStmt, statementCountIs, unsigned, N) { /// Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteralExpr>, /// Matcher<FloatingLiteral>, Matcher<IntegerLiteral> template <typename ValueT> -internal::PolymorphicMatcherWithParam1<internal::ValueEqualsMatcher, ValueT> +internal::PolymorphicMatcher<internal::ValueEqualsMatcher, + void(internal::AllNodeBaseTypes), ValueT> equals(const ValueT &Value) { - return internal::PolymorphicMatcherWithParam1< - internal::ValueEqualsMatcher, - ValueT>(Value); + return internal::PolymorphicMatcher<internal::ValueEqualsMatcher, + void(internal::AllNodeBaseTypes), ValueT>( + Value); } AST_POLYMORPHIC_MATCHER_P_OVERLOAD(equals, @@ -5312,11 +5449,11 @@ AST_POLYMORPHIC_MATCHER_P( /// Is equivalent to /// anyOf(hasOperatorName("+"), hasOperatorName("-")) extern const internal::VariadicFunction< - internal::PolymorphicMatcherWithParam1< - internal::HasAnyOperatorNameMatcher, std::vector<std::string>, - AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr, - CXXRewrittenBinaryOperator, - UnaryOperator)>, + internal::PolymorphicMatcher<internal::HasAnyOperatorNameMatcher, + AST_POLYMORPHIC_SUPPORTED_TYPES( + BinaryOperator, CXXOperatorCallExpr, + CXXRewrittenBinaryOperator, UnaryOperator), + std::vector<std::string>>, StringRef, internal::hasAnyOperatorNameFunc> hasAnyOperatorName; @@ -6072,7 +6209,7 @@ AST_POLYMORPHIC_MATCHER_P( /// \endcode /// usingDecl(hasAnyUsingShadowDecl(hasName("b")))) /// matches \code using X::b \endcode -AST_MATCHER_P(UsingDecl, hasAnyUsingShadowDecl, +AST_MATCHER_P(BaseUsingDecl, hasAnyUsingShadowDecl, internal::Matcher<UsingShadowDecl>, InnerMatcher) { return matchesFirstInPointerRange(InnerMatcher, Node.shadow_begin(), Node.shadow_end(), Finder, @@ -7338,12 +7475,92 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, CUDAKernelCallExpr> /// expr(nullPointerConstant()) /// matches the initializer for v1, v2, v3, cp, and ip. Does not match the /// initializer for i. -AST_MATCHER(Expr, nullPointerConstant) { - return Node.isNullPointerConstant(Finder->getASTContext(), - Expr::NPC_ValueDependentIsNull); +AST_MATCHER_FUNCTION(internal::Matcher<Expr>, nullPointerConstant) { + return anyOf( + gnuNullExpr(), cxxNullPtrLiteralExpr(), + integerLiteral(equals(0), hasParent(expr(hasType(pointerType()))))); +} + +/// Matches the DecompositionDecl the binding belongs to. +/// +/// For example, in: +/// \code +/// void foo() +/// { +/// int arr[3]; +/// auto &[f, s, t] = arr; +/// +/// f = 42; +/// } +/// \endcode +/// The matcher: +/// \code +/// bindingDecl(hasName("f"), +/// forDecomposition(decompositionDecl()) +/// \endcode +/// matches 'f' in 'auto &[f, s, t]'. +AST_MATCHER_P(BindingDecl, forDecomposition, internal::Matcher<ValueDecl>, + InnerMatcher) { + if (const ValueDecl *VD = Node.getDecomposedDecl()) + return InnerMatcher.matches(*VD, Finder, Builder); + return false; } -/// Matches declaration of the function the statement belongs to +/// Matches the Nth binding of a DecompositionDecl. +/// +/// For example, in: +/// \code +/// void foo() +/// { +/// int arr[3]; +/// auto &[f, s, t] = arr; +/// +/// f = 42; +/// } +/// \endcode +/// The matcher: +/// \code +/// decompositionDecl(hasBinding(0, +/// bindingDecl(hasName("f").bind("fBinding")))) +/// \endcode +/// matches the decomposition decl with 'f' bound to "fBinding". +AST_MATCHER_P2(DecompositionDecl, hasBinding, unsigned, N, + internal::Matcher<BindingDecl>, InnerMatcher) { + if (Node.bindings().size() <= N) + return false; + return InnerMatcher.matches(*Node.bindings()[N], Finder, Builder); +} + +/// Matches any binding of a DecompositionDecl. +/// +/// For example, in: +/// \code +/// void foo() +/// { +/// int arr[3]; +/// auto &[f, s, t] = arr; +/// +/// f = 42; +/// } +/// \endcode +/// The matcher: +/// \code +/// decompositionDecl(hasAnyBinding(bindingDecl(hasName("f").bind("fBinding")))) +/// \endcode +/// matches the decomposition decl with 'f' bound to "fBinding". +AST_MATCHER_P(DecompositionDecl, hasAnyBinding, internal::Matcher<BindingDecl>, + InnerMatcher) { + return llvm::any_of(Node.bindings(), [&](const auto *Binding) { + return InnerMatcher.matches(*Binding, Finder, Builder); + }); +} + +/// Matches declaration of the function the statement belongs to. +/// +/// Deprecated. Use forCallable() to correctly handle the situation when +/// the declaration is not a function (but a block or an Objective-C method). +/// forFunction() not only fails to take non-functions into account but also +/// may match the wrong declaration in their presence. /// /// Given: /// \code @@ -7360,20 +7577,79 @@ AST_MATCHER_P(Stmt, forFunction, internal::Matcher<FunctionDecl>, const auto &Parents = Finder->getASTContext().getParents(Node); llvm::SmallVector<DynTypedNode, 8> Stack(Parents.begin(), Parents.end()); - while(!Stack.empty()) { + while (!Stack.empty()) { const auto &CurNode = Stack.back(); Stack.pop_back(); - if(const auto *FuncDeclNode = CurNode.get<FunctionDecl>()) { - if(InnerMatcher.matches(*FuncDeclNode, Finder, Builder)) { + if (const auto *FuncDeclNode = CurNode.get<FunctionDecl>()) { + if (InnerMatcher.matches(*FuncDeclNode, Finder, Builder)) { + return true; + } + } else if (const auto *LambdaExprNode = CurNode.get<LambdaExpr>()) { + if (InnerMatcher.matches(*LambdaExprNode->getCallOperator(), Finder, + Builder)) { + return true; + } + } else { + for (const auto &Parent : Finder->getASTContext().getParents(CurNode)) + Stack.push_back(Parent); + } + } + return false; +} + +/// Matches declaration of the function, method, or block the statement +/// belongs to. +/// +/// Given: +/// \code +/// F& operator=(const F& o) { +/// std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; }); +/// return *this; +/// } +/// \endcode +/// returnStmt(forCallable(functionDecl(hasName("operator=")))) +/// matches 'return *this' +/// but does not match 'return v > 0' +/// +/// Given: +/// \code +/// -(void) foo { +/// int x = 1; +/// dispatch_sync(queue, ^{ int y = 2; }); +/// } +/// \endcode +/// declStmt(forCallable(objcMethodDecl())) +/// matches 'int x = 1' +/// but does not match 'int y = 2'. +/// whereas declStmt(forCallable(blockDecl())) +/// matches 'int y = 2' +/// but does not match 'int x = 1'. +AST_MATCHER_P(Stmt, forCallable, internal::Matcher<Decl>, InnerMatcher) { + const auto &Parents = Finder->getASTContext().getParents(Node); + + llvm::SmallVector<DynTypedNode, 8> Stack(Parents.begin(), Parents.end()); + while (!Stack.empty()) { + const auto &CurNode = Stack.back(); + Stack.pop_back(); + if (const auto *FuncDeclNode = CurNode.get<FunctionDecl>()) { + if (InnerMatcher.matches(*FuncDeclNode, Finder, Builder)) { + return true; + } + } else if (const auto *LambdaExprNode = CurNode.get<LambdaExpr>()) { + if (InnerMatcher.matches(*LambdaExprNode->getCallOperator(), Finder, + Builder)) { + return true; + } + } else if (const auto *ObjCMethodDeclNode = CurNode.get<ObjCMethodDecl>()) { + if (InnerMatcher.matches(*ObjCMethodDeclNode, Finder, Builder)) { return true; } - } else if(const auto *LambdaExprNode = CurNode.get<LambdaExpr>()) { - if(InnerMatcher.matches(*LambdaExprNode->getCallOperator(), - Finder, Builder)) { + } else if (const auto *BlockDeclNode = CurNode.get<BlockDecl>()) { + if (InnerMatcher.matches(*BlockDeclNode, Finder, Builder)) { return true; } } else { - for(const auto &Parent: Finder->getASTContext().getParents(CurNode)) + for (const auto &Parent : Finder->getASTContext().getParents(CurNode)) Stack.push_back(Parent); } } diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h index 2af4e6e88109..71f4f2d17ae3 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h +++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h @@ -83,6 +83,37 @@ class BoundNodes; namespace internal { +/// A type-list implementation. +/// +/// A "linked list" of types, accessible by using the ::head and ::tail +/// typedefs. +template <typename... Ts> struct TypeList {}; // Empty sentinel type list. + +template <typename T1, typename... Ts> struct TypeList<T1, Ts...> { + /// The first type on the list. + using head = T1; + + /// A sublist with the tail. ie everything but the head. + /// + /// This type is used to do recursion. TypeList<>/EmptyTypeList indicates the + /// end of the list. + using tail = TypeList<Ts...>; +}; + +/// The empty type list. +using EmptyTypeList = TypeList<>; + +/// Helper meta-function to determine if some type \c T is present or +/// a parent type in the list. +template <typename AnyTypeList, typename T> struct TypeListContainsSuperOf { + static const bool value = + std::is_base_of<typename AnyTypeList::head, T>::value || + TypeListContainsSuperOf<typename AnyTypeList::tail, T>::value; +}; +template <typename T> struct TypeListContainsSuperOf<EmptyTypeList, T> { + static const bool value = false; +}; + /// Variadic function object. /// /// Most of the functions below that use VariadicFunction could be implemented @@ -135,6 +166,35 @@ inline QualType getUnderlyingType(const CXXBaseSpecifier &Node) { return Node.getType(); } +/// Unifies obtaining a `TypeSourceInfo` from different node types. +template <typename T, + std::enable_if_t<TypeListContainsSuperOf< + TypeList<CXXBaseSpecifier, CXXCtorInitializer, + CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr, + CompoundLiteralExpr, DeclaratorDecl, ObjCPropertyDecl, + TemplateArgumentLoc, TypedefNameDecl>, + T>::value> * = nullptr> +inline TypeSourceInfo *GetTypeSourceInfo(const T &Node) { + return Node.getTypeSourceInfo(); +} +template <typename T, + std::enable_if_t<TypeListContainsSuperOf< + TypeList<CXXFunctionalCastExpr, ExplicitCastExpr>, T>::value> * = + nullptr> +inline TypeSourceInfo *GetTypeSourceInfo(const T &Node) { + return Node.getTypeInfoAsWritten(); +} +inline TypeSourceInfo *GetTypeSourceInfo(const BlockDecl &Node) { + return Node.getSignatureAsWritten(); +} +inline TypeSourceInfo *GetTypeSourceInfo(const CXXNewExpr &Node) { + return Node.getAllocatedTypeSourceInfo(); +} +inline TypeSourceInfo * +GetTypeSourceInfo(const ClassTemplateSpecializationDecl &Node) { + return Node.getTypeAsWritten(); +} + /// Unifies obtaining the FunctionProtoType pointer from both /// FunctionProtoType and FunctionDecl nodes.. inline const FunctionProtoType * @@ -541,12 +601,18 @@ public: /// Convert \c this into a \c Matcher<T> by applying dyn_cast<> to the /// argument. /// \c To must be a base class of \c T. - template <typename To> - Matcher<To> dynCastTo() const { + template <typename To> Matcher<To> dynCastTo() const LLVM_LVALUE_FUNCTION { static_assert(std::is_base_of<To, T>::value, "Invalid dynCast call."); return Matcher<To>(Implementation); } +#if LLVM_HAS_RVALUE_REFERENCE_THIS + template <typename To> Matcher<To> dynCastTo() && { + static_assert(std::is_base_of<To, T>::value, "Invalid dynCast call."); + return Matcher<To>(std::move(Implementation)); + } +#endif + /// Forwards the call to the underlying MatcherInterface<T> pointer. bool matches(const T &Node, ASTMatchFinder *Finder, @@ -563,7 +629,13 @@ public: /// /// The returned matcher keeps the same restrictions as \c this and remembers /// that it is meant to support nodes of type \c T. - operator DynTypedMatcher() const { return Implementation; } + operator DynTypedMatcher() const LLVM_LVALUE_FUNCTION { + return Implementation; + } + +#if LLVM_HAS_RVALUE_REFERENCE_THIS + operator DynTypedMatcher() && { return std::move(Implementation); } +#endif /// Allows the conversion of a \c Matcher<Type> to a \c /// Matcher<QualType>. @@ -836,7 +908,7 @@ public: /// Matches overloaded operators with a specific name. /// /// The type argument ArgT is not used by this matcher but is used by -/// PolymorphicMatcherWithParam1 and should be StringRef. +/// PolymorphicMatcher and should be StringRef. template <typename T, typename ArgT> class HasOverloadedOperatorNameMatcher : public SingleNodeMatcherInterface<T> { static_assert(std::is_same<T, CXXOperatorCallExpr>::value || @@ -870,7 +942,7 @@ private: Names, getOperatorSpelling(Node.getOverloadedOperator())); } - const std::vector<std::string> Names; + std::vector<std::string> Names; }; /// Matches named declarations with a specific name. @@ -904,8 +976,8 @@ class HasNameMatcher : public SingleNodeMatcherInterface<NamedDecl> { /// It is slower but simple and works on all cases. bool matchesNodeFullSlow(const NamedDecl &Node) const; - const bool UseUnqualifiedMatch; - const std::vector<std::string> Names; + bool UseUnqualifiedMatch; + std::vector<std::string> Names; }; /// Trampoline function to use VariadicFunction<> to construct a @@ -919,14 +991,14 @@ Matcher<ObjCMessageExpr> hasAnySelectorFunc( /// Matches declarations for QualType and CallExpr. /// -/// Type argument DeclMatcherT is required by PolymorphicMatcherWithParam1 but +/// Type argument DeclMatcherT is required by PolymorphicMatcher but /// not actually used. template <typename T, typename DeclMatcherT> class HasDeclarationMatcher : public MatcherInterface<T> { static_assert(std::is_same<DeclMatcherT, Matcher<Decl>>::value, "instantiated with wrong types"); - const DynTypedMatcher InnerMatcher; + DynTypedMatcher InnerMatcher; public: explicit HasDeclarationMatcher(const Matcher<Decl> &InnerMatcher) @@ -1108,39 +1180,6 @@ struct IsBaseType { template <typename T> const bool IsBaseType<T>::value; -/// A type-list implementation. -/// -/// A "linked list" of types, accessible by using the ::head and ::tail -/// typedefs. -template <typename... Ts> struct TypeList {}; // Empty sentinel type list. - -template <typename T1, typename... Ts> struct TypeList<T1, Ts...> { - /// The first type on the list. - using head = T1; - - /// A sublist with the tail. ie everything but the head. - /// - /// This type is used to do recursion. TypeList<>/EmptyTypeList indicates the - /// end of the list. - using tail = TypeList<Ts...>; -}; - -/// The empty type list. -using EmptyTypeList = TypeList<>; - -/// Helper meta-function to determine if some type \c T is present or -/// a parent type in the list. -template <typename AnyTypeList, typename T> -struct TypeListContainsSuperOf { - static const bool value = - std::is_base_of<typename AnyTypeList::head, T>::value || - TypeListContainsSuperOf<typename AnyTypeList::tail, T>::value; -}; -template <typename T> -struct TypeListContainsSuperOf<EmptyTypeList, T> { - static const bool value = false; -}; - /// A "type list" that contains all types. /// /// Useful for matchers like \c anything and \c unless. @@ -1157,6 +1196,18 @@ template <class T> struct ExtractFunctionArgMeta<void(T)> { using type = T; }; +template <class T, class Tuple, std::size_t... I> +constexpr T *new_from_tuple_impl(Tuple &&t, std::index_sequence<I...>) { + return new T(std::get<I>(std::forward<Tuple>(t))...); +} + +template <class T, class Tuple> constexpr T *new_from_tuple(Tuple &&t) { + return new_from_tuple_impl<T>( + std::forward<Tuple>(t), + std::make_index_sequence< + std::tuple_size<std::remove_reference_t<Tuple>>::value>{}); +} + /// Default type lists for ArgumentAdaptingMatcher matchers. using AdaptativeDefaultFromTypes = AllNodeBaseTypes; using AdaptativeDefaultToTypes = @@ -1303,20 +1354,36 @@ public: VariadicOperatorMatcher(DynTypedMatcher::VariadicOperator Op, Ps &&... Params) : Op(Op), Params(std::forward<Ps>(Params)...) {} - template <typename T> operator Matcher<T>() const { + template <typename T> operator Matcher<T>() const LLVM_LVALUE_FUNCTION { return DynTypedMatcher::constructVariadic( Op, ASTNodeKind::getFromNodeKind<T>(), getMatchers<T>(std::index_sequence_for<Ps...>())) .template unconditionalConvertTo<T>(); } +#if LLVM_HAS_RVALUE_REFERENCE_THIS + template <typename T> operator Matcher<T>() && { + return DynTypedMatcher::constructVariadic( + Op, ASTNodeKind::getFromNodeKind<T>(), + getMatchers<T>(std::index_sequence_for<Ps...>())) + .template unconditionalConvertTo<T>(); + } +#endif private: // Helper method to unpack the tuple into a vector. template <typename T, std::size_t... Is> - std::vector<DynTypedMatcher> getMatchers(std::index_sequence<Is...>) const { + std::vector<DynTypedMatcher> + getMatchers(std::index_sequence<Is...>) const LLVM_LVALUE_FUNCTION { return {Matcher<T>(std::get<Is>(Params))...}; } +#if LLVM_HAS_RVALUE_REFERENCE_THIS + template <typename T, std::size_t... Is> + std::vector<DynTypedMatcher> getMatchers(std::index_sequence<Is...>) && { + return {Matcher<T>(std::get<Is>(std::move(Params)))...}; + } +#endif + const DynTypedMatcher::VariadicOperator Op; std::tuple<Ps...> Params; }; @@ -1374,8 +1441,7 @@ struct MapAnyOfMatcherImpl { internal::DynTypedMatcher::VO_AnyOf}, applyMatcher( [&](auto... Matcher) { - return std::make_tuple(Matcher( - std::forward<decltype(InnerMatcher)>(InnerMatcher)...)...); + return std::make_tuple(Matcher(InnerMatcher...)...); }, std::tuple< VariadicDynCastAllOfMatcher<CladeType, MatcherTypes>...>()))); @@ -1406,12 +1472,18 @@ public: using ReturnTypes = ToTypes; - template <typename To> operator Matcher<To>() const { + template <typename To> operator Matcher<To>() const LLVM_LVALUE_FUNCTION { return Matcher<To>(new ArgumentAdapterT<To, T>(InnerMatcher)); } +#if LLVM_HAS_RVALUE_REFERENCE_THIS + template <typename To> operator Matcher<To>() && { + return Matcher<To>(new ArgumentAdapterT<To, T>(std::move(InnerMatcher))); + } +#endif + private: - const Matcher<T> InnerMatcher; + Matcher<T> InnerMatcher; }; /// Converts a \c Matcher<T> to a matcher of desired type \c To by @@ -1426,7 +1498,7 @@ private: /// \c HasMatcher<To, T>(InnerMatcher). /// /// If a matcher does not need knowledge about the inner type, prefer to use -/// PolymorphicMatcherWithParam1. +/// PolymorphicMatcher. template <template <typename ToArg, typename FromArg> class ArgumentAdapterT, typename FromTypes = AdaptativeDefaultFromTypes, typename ToTypes = AdaptativeDefaultToTypes> @@ -1453,7 +1525,7 @@ struct ArgumentAdaptingMatcherFunc { }; template <typename T> class TraversalMatcher : public MatcherInterface<T> { - const DynTypedMatcher InnerMatcher; + DynTypedMatcher InnerMatcher; clang::TraversalKind Traversal; public: @@ -1479,85 +1551,64 @@ public: TraversalWrapper(TraversalKind TK, const MatcherType &InnerMatcher) : TK(TK), InnerMatcher(InnerMatcher) {} - template <typename T> operator Matcher<T>() const { + template <typename T> operator Matcher<T>() const LLVM_LVALUE_FUNCTION { return internal::DynTypedMatcher::constructRestrictedWrapper( new internal::TraversalMatcher<T>(TK, InnerMatcher), ASTNodeKind::getFromNodeKind<T>()) .template unconditionalConvertTo<T>(); } +#if LLVM_HAS_RVALUE_REFERENCE_THIS + template <typename T> operator Matcher<T>() && { + return internal::DynTypedMatcher::constructRestrictedWrapper( + new internal::TraversalMatcher<T>(TK, std::move(InnerMatcher)), + ASTNodeKind::getFromNodeKind<T>()) + .template unconditionalConvertTo<T>(); + } +#endif + private: TraversalKind TK; MatcherType InnerMatcher; }; -/// A PolymorphicMatcherWithParamN<MatcherT, P1, ..., PN> object can be +/// A PolymorphicMatcher<MatcherT, P1, ..., PN> object can be /// created from N parameters p1, ..., pN (of type P1, ..., PN) and /// used as a Matcher<T> where a MatcherT<T, P1, ..., PN>(p1, ..., pN) /// can be constructed. /// /// For example: -/// - PolymorphicMatcherWithParam0<IsDefinitionMatcher>() +/// - PolymorphicMatcher<IsDefinitionMatcher>() /// creates an object that can be used as a Matcher<T> for any type T /// where an IsDefinitionMatcher<T>() can be constructed. -/// - PolymorphicMatcherWithParam1<ValueEqualsMatcher, int>(42) +/// - PolymorphicMatcher<ValueEqualsMatcher, int>(42) /// creates an object that can be used as a Matcher<T> for any type T /// where a ValueEqualsMatcher<T, int>(42) can be constructed. -template <template <typename T> class MatcherT, - typename ReturnTypesF = void(AllNodeBaseTypes)> -class PolymorphicMatcherWithParam0 { +template <template <typename T, typename... Params> class MatcherT, + typename ReturnTypesF, typename... ParamTypes> +class PolymorphicMatcher { public: - using ReturnTypes = typename ExtractFunctionArgMeta<ReturnTypesF>::type; - - template <typename T> - operator Matcher<T>() const { - static_assert(TypeListContainsSuperOf<ReturnTypes, T>::value, - "right polymorphic conversion"); - return Matcher<T>(new MatcherT<T>()); - } -}; - -template <template <typename T, typename P1> class MatcherT, - typename P1, - typename ReturnTypesF = void(AllNodeBaseTypes)> -class PolymorphicMatcherWithParam1 { -public: - explicit PolymorphicMatcherWithParam1(const P1 &Param1) - : Param1(Param1) {} + PolymorphicMatcher(const ParamTypes &... Params) : Params(Params...) {} using ReturnTypes = typename ExtractFunctionArgMeta<ReturnTypesF>::type; - template <typename T> - operator Matcher<T>() const { + template <typename T> operator Matcher<T>() const LLVM_LVALUE_FUNCTION { static_assert(TypeListContainsSuperOf<ReturnTypes, T>::value, "right polymorphic conversion"); - return Matcher<T>(new MatcherT<T, P1>(Param1)); + return Matcher<T>(new_from_tuple<MatcherT<T, ParamTypes...>>(Params)); } -private: - const P1 Param1; -}; - -template <template <typename T, typename P1, typename P2> class MatcherT, - typename P1, typename P2, - typename ReturnTypesF = void(AllNodeBaseTypes)> -class PolymorphicMatcherWithParam2 { -public: - PolymorphicMatcherWithParam2(const P1 &Param1, const P2 &Param2) - : Param1(Param1), Param2(Param2) {} - - using ReturnTypes = typename ExtractFunctionArgMeta<ReturnTypesF>::type; - - template <typename T> - operator Matcher<T>() const { +#if LLVM_HAS_RVALUE_REFERENCE_THIS + template <typename T> operator Matcher<T>() && { static_assert(TypeListContainsSuperOf<ReturnTypes, T>::value, "right polymorphic conversion"); - return Matcher<T>(new MatcherT<T, P1, P2>(Param1, Param2)); + return Matcher<T>( + new_from_tuple<MatcherT<T, ParamTypes...>>(std::move(Params))); } +#endif private: - const P1 Param1; - const P2 Param2; + std::tuple<ParamTypes...> Params; }; /// Matches nodes of type T that have child nodes of type ChildT for @@ -1566,7 +1617,7 @@ private: /// ChildT must be an AST base type. template <typename T, typename ChildT> class HasMatcher : public MatcherInterface<T> { - const DynTypedMatcher InnerMatcher; + DynTypedMatcher InnerMatcher; public: explicit HasMatcher(const Matcher<ChildT> &InnerMatcher) @@ -1589,7 +1640,7 @@ class ForEachMatcher : public MatcherInterface<T> { static_assert(IsBaseType<ChildT>::value, "for each only accepts base type matcher"); - const DynTypedMatcher InnerMatcher; + DynTypedMatcher InnerMatcher; public: explicit ForEachMatcher(const Matcher<ChildT> &InnerMatcher) @@ -1619,7 +1670,7 @@ class HasDescendantMatcher : public MatcherInterface<T> { static_assert(IsBaseType<DescendantT>::value, "has descendant only accepts base type matcher"); - const DynTypedMatcher DescendantMatcher; + DynTypedMatcher DescendantMatcher; public: explicit HasDescendantMatcher(const Matcher<DescendantT> &DescendantMatcher) @@ -1641,7 +1692,7 @@ class HasParentMatcher : public MatcherInterface<T> { static_assert(IsBaseType<ParentT>::value, "has parent only accepts base type matcher"); - const DynTypedMatcher ParentMatcher; + DynTypedMatcher ParentMatcher; public: explicit HasParentMatcher(const Matcher<ParentT> &ParentMatcher) @@ -1663,7 +1714,7 @@ class HasAncestorMatcher : public MatcherInterface<T> { static_assert(IsBaseType<AncestorT>::value, "has ancestor only accepts base type matcher"); - const DynTypedMatcher AncestorMatcher; + DynTypedMatcher AncestorMatcher; public: explicit HasAncestorMatcher(const Matcher<AncestorT> &AncestorMatcher) @@ -1687,7 +1738,7 @@ class ForEachDescendantMatcher : public MatcherInterface<T> { static_assert(IsBaseType<DescendantT>::value, "for each descendant only accepts base type matcher"); - const DynTypedMatcher DescendantMatcher; + DynTypedMatcher DescendantMatcher; public: explicit ForEachDescendantMatcher( @@ -1720,7 +1771,7 @@ public: } private: - const ValueT ExpectedValue; + ValueT ExpectedValue; }; /// Template specializations to easily write matchers for floating point @@ -1753,7 +1804,7 @@ inline bool ValueEqualsMatcher<FloatingLiteral, llvm::APFloat>::matchesNode( /// \c Matcher<T> matches. template <typename TLoc, typename T> class LocMatcher : public MatcherInterface<TLoc> { - const DynTypedMatcher InnerMatcher; + DynTypedMatcher InnerMatcher; public: explicit LocMatcher(const Matcher<T> &InnerMatcher) @@ -1777,7 +1828,7 @@ private: /// /// Used to implement the \c loc() matcher. class TypeLocTypeMatcher : public MatcherInterface<TypeLoc> { - const DynTypedMatcher InnerMatcher; + DynTypedMatcher InnerMatcher; public: explicit TypeLocTypeMatcher(const Matcher<QualType> &InnerMatcher) @@ -1796,7 +1847,7 @@ public: /// another node of type \c T that can be reached using a given traverse /// function. template <typename T> class TypeTraverseMatcher : public MatcherInterface<T> { - const DynTypedMatcher InnerMatcher; + DynTypedMatcher InnerMatcher; public: explicit TypeTraverseMatcher(const Matcher<QualType> &InnerMatcher, @@ -1821,7 +1872,7 @@ private: /// given traverse function. template <typename T> class TypeLocTraverseMatcher : public MatcherInterface<T> { - const DynTypedMatcher InnerMatcher; + DynTypedMatcher InnerMatcher; public: explicit TypeLocTraverseMatcher(const Matcher<TypeLoc> &InnerMatcher, @@ -1876,7 +1927,7 @@ public: }; private: - const Matcher<InnerTBase> InnerMatcher; + Matcher<InnerTBase> InnerMatcher; }; /// A simple memoizer of T(*)() functions. @@ -2039,7 +2090,8 @@ equivalentUnaryOperator(const NodeType &Node) { template <> inline Optional<UnaryOperatorKind> equivalentUnaryOperator<CXXOperatorCallExpr>(const CXXOperatorCallExpr &Node) { - if (Node.getNumArgs() != 1) + if (Node.getNumArgs() != 1 && Node.getOperator() != OO_PlusPlus && + Node.getOperator() != OO_MinusMinus) return None; switch (Node.getOperator()) { default: @@ -2050,6 +2102,8 @@ equivalentUnaryOperator<CXXOperatorCallExpr>(const CXXOperatorCallExpr &Node) { return UO_Minus; case OO_Amp: return UO_AddrOf; + case OO_Star: + return UO_Deref; case OO_Tilde: return UO_Not; case OO_Exclaim: @@ -2173,7 +2227,7 @@ inline Optional<StringRef> getOpName(const CXXOperatorCallExpr &Node) { /// Matches overloaded operators with a specific name. /// /// The type argument ArgT is not used by this matcher but is used by -/// PolymorphicMatcherWithParam1 and should be std::vector<std::string>>. +/// PolymorphicMatcher and should be std::vector<std::string>>. template <typename T, typename ArgT = std::vector<std::string>> class HasAnyOperatorNameMatcher : public SingleNodeMatcherInterface<T> { static_assert(std::is_same<T, BinaryOperator>::value || @@ -2219,19 +2273,22 @@ private: return BinaryOperator::getOpcodeStr(*optBinaryOpcode); } - const std::vector<std::string> Names; + std::vector<std::string> Names; }; -using HasOpNameMatcher = PolymorphicMatcherWithParam1< - HasAnyOperatorNameMatcher, std::vector<std::string>, - void(TypeList<BinaryOperator, CXXOperatorCallExpr, - CXXRewrittenBinaryOperator, UnaryOperator>)>; +using HasOpNameMatcher = + PolymorphicMatcher<HasAnyOperatorNameMatcher, + void( + TypeList<BinaryOperator, CXXOperatorCallExpr, + CXXRewrittenBinaryOperator, UnaryOperator>), + std::vector<std::string>>; HasOpNameMatcher hasAnyOperatorNameFunc(ArrayRef<const StringRef *> NameRefs); -using HasOverloadOpNameMatcher = PolymorphicMatcherWithParam1< - HasOverloadedOperatorNameMatcher, std::vector<std::string>, - void(TypeList<CXXOperatorCallExpr, FunctionDecl>)>; +using HasOverloadOpNameMatcher = + PolymorphicMatcher<HasOverloadedOperatorNameMatcher, + void(TypeList<CXXOperatorCallExpr, FunctionDecl>), + std::vector<std::string>>; HasOverloadOpNameMatcher hasAnyOverloadedOperatorNameFunc(ArrayRef<const StringRef *> NameRefs); diff --git a/clang/include/clang/ASTMatchers/ASTMatchersMacros.h b/clang/include/clang/ASTMatchers/ASTMatchersMacros.h index 7e01ab0c6ee9..592a3898a295 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchersMacros.h +++ b/clang/include/clang/ASTMatchers/ASTMatchersMacros.h @@ -143,7 +143,7 @@ *Builder) const override; \ \ private: \ - ParamType const Param; \ + ParamType Param; \ }; \ } \ inline ::clang::ast_matchers::internal::Matcher<Type> DefineMatcher( \ @@ -151,7 +151,7 @@ return ::clang::ast_matchers::internal::makeMatcher( \ new internal::matcher_##DefineMatcher##OverloadId##Matcher(Param)); \ } \ - typedef ::clang::ast_matchers::internal::Matcher<Type>( \ + typedef ::clang::ast_matchers::internal::Matcher<Type> ( \ &DefineMatcher##_Type##OverloadId)(ParamType const &Param); \ inline bool internal::matcher_##DefineMatcher##OverloadId##Matcher::matches( \ const Type &Node, \ @@ -192,8 +192,8 @@ *Builder) const override; \ \ private: \ - ParamType1 const Param1; \ - ParamType2 const Param2; \ + ParamType1 Param1; \ + ParamType2 Param2; \ }; \ } \ inline ::clang::ast_matchers::internal::Matcher<Type> DefineMatcher( \ @@ -202,7 +202,7 @@ new internal::matcher_##DefineMatcher##OverloadId##Matcher(Param1, \ Param2)); \ } \ - typedef ::clang::ast_matchers::internal::Matcher<Type>( \ + typedef ::clang::ast_matchers::internal::Matcher<Type> ( \ &DefineMatcher##_Type##OverloadId)(ParamType1 const &Param1, \ ParamType2 const &Param2); \ inline bool internal::matcher_##DefineMatcher##OverloadId##Matcher::matches( \ @@ -239,10 +239,10 @@ *Builder) const override; \ }; \ } \ - inline ::clang::ast_matchers::internal::PolymorphicMatcherWithParam0< \ + inline ::clang::ast_matchers::internal::PolymorphicMatcher< \ internal::matcher_##DefineMatcher##Matcher, ReturnTypesF> \ DefineMatcher() { \ - return ::clang::ast_matchers::internal::PolymorphicMatcherWithParam0< \ + return ::clang::ast_matchers::internal::PolymorphicMatcher< \ internal::matcher_##DefineMatcher##Matcher, ReturnTypesF>(); \ } \ template <typename NodeType> \ @@ -281,21 +281,20 @@ *Builder) const override; \ \ private: \ - ParamType const Param; \ + ParamType Param; \ }; \ } \ - inline ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1< \ - internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType, \ - ReturnTypesF> \ + inline ::clang::ast_matchers::internal::PolymorphicMatcher< \ + internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \ + ParamType> \ DefineMatcher(ParamType const &Param) { \ - return ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1< \ - internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType, \ - ReturnTypesF>(Param); \ + return ::clang::ast_matchers::internal::PolymorphicMatcher< \ + internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \ + ParamType>(Param); \ } \ - typedef ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1< \ - internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType, \ - ReturnTypesF>(&DefineMatcher##_Type##OverloadId)( \ - ParamType const &Param); \ + typedef ::clang::ast_matchers::internal::PolymorphicMatcher< \ + internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \ + ParamType> (&DefineMatcher##_Type##OverloadId)(ParamType const &Param); \ template <typename NodeType, typename ParamT> \ bool internal:: \ matcher_##DefineMatcher##OverloadId##Matcher<NodeType, ParamT>::matches( \ @@ -334,21 +333,21 @@ *Builder) const override; \ \ private: \ - ParamType1 const Param1; \ - ParamType2 const Param2; \ + ParamType1 Param1; \ + ParamType2 Param2; \ }; \ } \ - inline ::clang::ast_matchers::internal::PolymorphicMatcherWithParam2< \ - internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType1, \ - ParamType2, ReturnTypesF> \ + inline ::clang::ast_matchers::internal::PolymorphicMatcher< \ + internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \ + ParamType1, ParamType2> \ DefineMatcher(ParamType1 const &Param1, ParamType2 const &Param2) { \ - return ::clang::ast_matchers::internal::PolymorphicMatcherWithParam2< \ - internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType1, \ - ParamType2, ReturnTypesF>(Param1, Param2); \ + return ::clang::ast_matchers::internal::PolymorphicMatcher< \ + internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \ + ParamType1, ParamType2>(Param1, Param2); \ } \ - typedef ::clang::ast_matchers::internal::PolymorphicMatcherWithParam2< \ - internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType1, \ - ParamType2, ReturnTypesF>(&DefineMatcher##_Type##OverloadId)( \ + typedef ::clang::ast_matchers::internal::PolymorphicMatcher< \ + internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \ + ParamType1, ParamType2> (&DefineMatcher##_Type##OverloadId)( \ ParamType1 const &Param1, ParamType2 const &Param2); \ template <typename NodeType, typename ParamT1, typename ParamT2> \ bool internal::matcher_##DefineMatcher##OverloadId##Matcher< \ @@ -470,7 +469,7 @@ *Builder) const override; \ \ private: \ - std::shared_ptr<llvm::Regex> const Param; \ + std::shared_ptr<llvm::Regex> Param; \ }; \ } \ inline ::clang::ast_matchers::internal::Matcher<Type> DefineMatcher( \ @@ -522,34 +521,34 @@ *Builder) const override; \ \ private: \ - std::shared_ptr<llvm::Regex> const Param; \ + std::shared_ptr<llvm::Regex> Param; \ }; \ } \ - inline ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1< \ - internal::matcher_##DefineMatcher##OverloadId##Matcher, \ - std::shared_ptr<llvm::Regex>, ReturnTypesF> \ + inline ::clang::ast_matchers::internal::PolymorphicMatcher< \ + internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \ + std::shared_ptr<llvm::Regex>> \ DefineMatcher(llvm::StringRef Param, llvm::Regex::RegexFlags RegexFlags) { \ - return ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1< \ - internal::matcher_##DefineMatcher##OverloadId##Matcher, \ - std::shared_ptr<llvm::Regex>, ReturnTypesF>( \ + return ::clang::ast_matchers::internal::PolymorphicMatcher< \ + internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \ + std::shared_ptr<llvm::Regex>>( \ ::clang::ast_matchers::internal::createAndVerifyRegex( \ Param, RegexFlags, #DefineMatcher)); \ } \ - inline ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1< \ - internal::matcher_##DefineMatcher##OverloadId##Matcher, \ - std::shared_ptr<llvm::Regex>, ReturnTypesF> \ + inline ::clang::ast_matchers::internal::PolymorphicMatcher< \ + internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \ + std::shared_ptr<llvm::Regex>> \ DefineMatcher(llvm::StringRef Param) { \ return DefineMatcher(Param, llvm::Regex::NoFlags); \ } \ - typedef ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1< \ - internal::matcher_##DefineMatcher##OverloadId##Matcher, \ - std::shared_ptr<llvm::Regex>, ReturnTypesF> ( \ + typedef ::clang::ast_matchers::internal::PolymorphicMatcher< \ + internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \ + std::shared_ptr<llvm::Regex>> ( \ &DefineMatcher##_Type##OverloadId##Flags)( \ llvm::StringRef Param, llvm::Regex::RegexFlags RegexFlags); \ - typedef ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1< \ - internal::matcher_##DefineMatcher##OverloadId##Matcher, \ - std::shared_ptr<llvm::Regex>, ReturnTypesF> ( \ - &DefineMatcher##_Type##OverloadId)(llvm::StringRef Param); \ + typedef ::clang::ast_matchers::internal::PolymorphicMatcher< \ + internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \ + std::shared_ptr<llvm::Regex>> (&DefineMatcher##_Type##OverloadId)( \ + llvm::StringRef Param); \ template <typename NodeType, typename ParamT> \ bool internal:: \ matcher_##DefineMatcher##OverloadId##Matcher<NodeType, ParamT>::matches( \ diff --git a/clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h b/clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h index f095dcdd60b0..10625311c1a5 100644 --- a/clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h +++ b/clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h @@ -66,6 +66,8 @@ public: ET_RegistryAmbiguousOverload = 5, ET_RegistryValueNotFound = 6, ET_RegistryUnknownEnumWithReplace = 7, + ET_RegistryNonNodeMatcher = 8, + ET_RegistryMatcherNoWithSupport = 9, ET_ParserStringError = 100, ET_ParserNoOpenParen = 101, @@ -77,7 +79,9 @@ public: ET_ParserMalformedBindExpr = 107, ET_ParserTrailingCode = 108, ET_ParserNumberError = 109, - ET_ParserOverloadedType = 110 + ET_ParserOverloadedType = 110, + ET_ParserMalformedChainedExpr = 111, + ET_ParserFailedToBuildMatcher = 112 }; /// Helper stream class. diff --git a/clang/include/clang/ASTMatchers/Dynamic/Parser.h b/clang/include/clang/ASTMatchers/Dynamic/Parser.h index 70bbe816accd..af370d83782a 100644 --- a/clang/include/clang/ASTMatchers/Dynamic/Parser.h +++ b/clang/include/clang/ASTMatchers/Dynamic/Parser.h @@ -100,6 +100,14 @@ public: virtual llvm::Optional<MatcherCtor> lookupMatcherCtor(StringRef MatcherName) = 0; + virtual bool isBuilderMatcher(MatcherCtor) const = 0; + + virtual ASTNodeKind nodeMatcherType(MatcherCtor) const = 0; + + virtual internal::MatcherDescriptorPtr + buildMatcherCtor(MatcherCtor, SourceRange NameRange, + ArrayRef<ParserValue> Args, Diagnostics *Error) const = 0; + /// Compute the list of completion types for \p Context. /// /// Each element of \p Context represents a matcher invocation, going from @@ -142,6 +150,15 @@ public: std::vector<ArgKind> getAcceptedCompletionTypes( llvm::ArrayRef<std::pair<MatcherCtor, unsigned>> Context) override; + bool isBuilderMatcher(MatcherCtor Ctor) const override; + + ASTNodeKind nodeMatcherType(MatcherCtor) const override; + + internal::MatcherDescriptorPtr + buildMatcherCtor(MatcherCtor, SourceRange NameRange, + ArrayRef<ParserValue> Args, + Diagnostics *Error) const override; + std::vector<MatcherCompletion> getMatcherCompletions(llvm::ArrayRef<ArgKind> AcceptedTypes) override; }; @@ -233,7 +250,11 @@ private: bool parseBindID(std::string &BindID); bool parseExpressionImpl(VariantValue *Value); + bool parseMatcherBuilder(MatcherCtor Ctor, const TokenInfo &NameToken, + const TokenInfo &OpenToken, VariantValue *Value); bool parseMatcherExpressionImpl(const TokenInfo &NameToken, + const TokenInfo &OpenToken, + llvm::Optional<MatcherCtor> Ctor, VariantValue *Value); bool parseIdentifierPrefixImpl(VariantValue *Value); diff --git a/clang/include/clang/ASTMatchers/Dynamic/Registry.h b/clang/include/clang/ASTMatchers/Dynamic/Registry.h index 215206b2f50c..f91f5fe01c4e 100644 --- a/clang/include/clang/ASTMatchers/Dynamic/Registry.h +++ b/clang/include/clang/ASTMatchers/Dynamic/Registry.h @@ -33,6 +33,23 @@ namespace internal { class MatcherDescriptor; +/// A smart (owning) pointer for MatcherDescriptor. We can't use unique_ptr +/// because MatcherDescriptor is forward declared +class MatcherDescriptorPtr { +public: + explicit MatcherDescriptorPtr(MatcherDescriptor *); + ~MatcherDescriptorPtr(); + MatcherDescriptorPtr(MatcherDescriptorPtr &&) = default; + MatcherDescriptorPtr &operator=(MatcherDescriptorPtr &&) = default; + MatcherDescriptorPtr(const MatcherDescriptorPtr &) = delete; + MatcherDescriptorPtr &operator=(const MatcherDescriptorPtr &) = delete; + + MatcherDescriptor *get() { return Ptr; } + +private: + MatcherDescriptor *Ptr; +}; + } // namespace internal using MatcherCtor = const internal::MatcherDescriptor *; @@ -66,6 +83,14 @@ class Registry { public: Registry() = delete; + static ASTNodeKind nodeMatcherType(MatcherCtor); + + static bool isBuilderMatcher(MatcherCtor Ctor); + + static internal::MatcherDescriptorPtr + buildMatcherCtor(MatcherCtor, SourceRange NameRange, + ArrayRef<ParserValue> Args, Diagnostics *Error); + /// Look up a matcher in the registry by name, /// /// \return An opaque value which may be used to refer to the matcher diff --git a/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h b/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h index fa033f49bc90..5b3f8a7ca5eb 100644 --- a/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h +++ b/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h @@ -35,6 +35,7 @@ class ArgKind { public: enum Kind { AK_Matcher, + AK_Node, AK_Boolean, AK_Double, AK_Unsigned, @@ -44,12 +45,22 @@ class ArgKind { ArgKind(Kind K) : K(K) { assert(K != AK_Matcher); } /// Constructor for matcher types. - ArgKind(ASTNodeKind MatcherKind) : K(AK_Matcher), MatcherKind(MatcherKind) {} + static ArgKind MakeMatcherArg(ASTNodeKind MatcherKind) { + return ArgKind{AK_Matcher, MatcherKind}; + } + + static ArgKind MakeNodeArg(ASTNodeKind MatcherKind) { + return ArgKind{AK_Node, MatcherKind}; + } Kind getArgKind() const { return K; } ASTNodeKind getMatcherKind() const { assert(K == AK_Matcher); - return MatcherKind; + return NodeKind; + } + ASTNodeKind getNodeKind() const { + assert(K == AK_Node); + return NodeKind; } /// Determines if this type can be converted to \p To. @@ -61,8 +72,9 @@ class ArgKind { bool isConvertibleTo(ArgKind To, unsigned *Specificity) const; bool operator<(const ArgKind &Other) const { - if (K == AK_Matcher && Other.K == AK_Matcher) - return MatcherKind < Other.MatcherKind; + if ((K == AK_Matcher && Other.K == AK_Matcher) || + (K == AK_Node && Other.K == AK_Node)) + return NodeKind < Other.NodeKind; return K < Other.K; } @@ -70,8 +82,9 @@ class ArgKind { std::string asString() const; private: + ArgKind(Kind K, ASTNodeKind NK) : K(K), NodeKind(NK) {} Kind K; - ASTNodeKind MatcherKind; + ASTNodeKind NodeKind; }; using ast_matchers::internal::DynTypedMatcher; diff --git a/clang/include/clang/ASTMatchers/GtestMatchers.h b/clang/include/clang/ASTMatchers/GtestMatchers.h index 4f8addcf744a..e19d91a674f2 100644 --- a/clang/include/clang/ASTMatchers/GtestMatchers.h +++ b/clang/include/clang/ASTMatchers/GtestMatchers.h @@ -16,6 +16,7 @@ #include "clang/AST/Stmt.h" #include "clang/ASTMatchers/ASTMatchers.h" +#include "llvm/ADT/StringRef.h" namespace clang { namespace ast_matchers { @@ -30,14 +31,55 @@ enum class GtestCmp { Lt, }; -/// Matcher for gtest's ASSERT_... macros. +/// This enum indicates whether the mock method in the matched ON_CALL or +/// EXPECT_CALL macro has arguments. For example, `None` can be used to match +/// `ON_CALL(mock, TwoParamMethod)` whereas `Some` can be used to match +/// `ON_CALL(mock, TwoParamMethod(m1, m2))`. +enum class MockArgs { + None, + Some, +}; + +/// Matcher for gtest's ASSERT comparison macros including ASSERT_EQ, ASSERT_NE, +/// ASSERT_GE, ASSERT_GT, ASSERT_LE and ASSERT_LT. internal::BindableMatcher<Stmt> gtestAssert(GtestCmp Cmp, StatementMatcher Left, StatementMatcher Right); -/// Matcher for gtest's EXPECT_... macros. +/// Matcher for gtest's ASSERT_THAT macro. +internal::BindableMatcher<Stmt> gtestAssertThat(StatementMatcher Actual, + StatementMatcher Matcher); + +/// Matcher for gtest's EXPECT comparison macros including EXPECT_EQ, EXPECT_NE, +/// EXPECT_GE, EXPECT_GT, EXPECT_LE and EXPECT_LT. internal::BindableMatcher<Stmt> gtestExpect(GtestCmp Cmp, StatementMatcher Left, StatementMatcher Right); +/// Matcher for gtest's EXPECT_THAT macro. +internal::BindableMatcher<Stmt> gtestExpectThat(StatementMatcher Actual, + StatementMatcher Matcher); + +/// Matcher for gtest's EXPECT_CALL macro. `MockObject` matches the mock +/// object and `MockMethodName` is the name of the method invoked on the mock +/// object. +internal::BindableMatcher<Stmt> gtestExpectCall(StatementMatcher MockObject, + llvm::StringRef MockMethodName, + MockArgs Args); + +/// Matcher for gtest's EXPECT_CALL macro. `MockCall` matches the whole mock +/// member method call. This API is more flexible but requires more knowledge of +/// the AST structure of EXPECT_CALL macros. +internal::BindableMatcher<Stmt> gtestExpectCall(StatementMatcher MockCall, + MockArgs Args); + +/// Like the first `gtestExpectCall` overload but for `ON_CALL`. +internal::BindableMatcher<Stmt> gtestOnCall(StatementMatcher MockObject, + llvm::StringRef MockMethodName, + MockArgs Args); + +/// Like the second `gtestExpectCall` overload but for `ON_CALL`. +internal::BindableMatcher<Stmt> gtestOnCall(StatementMatcher MockCall, + MockArgs Args); + } // namespace ast_matchers } // namespace clang diff --git a/clang/include/clang/Analysis/Analyses/CalledOnceCheck.h b/clang/include/clang/Analysis/Analyses/CalledOnceCheck.h index fc574c680a44..a0c767bf92d2 100644 --- a/clang/include/clang/Analysis/Analyses/CalledOnceCheck.h +++ b/clang/include/clang/Analysis/Analyses/CalledOnceCheck.h @@ -17,6 +17,7 @@ namespace clang { class AnalysisDeclContext; +class BlockDecl; class CFG; class Decl; class DeclContext; @@ -79,6 +80,7 @@ public: /// the path containing the call and not containing the call. This helps us /// to pinpoint a bad path for the user. /// \param Parameter -- parameter that should be called once. + /// \param Function -- function declaration where the problem occured. /// \param Where -- the least common ancestor statement. /// \param Reason -- a reason describing the path without a call. /// \param IsCalledDirectly -- true, if parameter actually gets called on @@ -86,9 +88,22 @@ public: /// collection, passed as a parameter, etc.). /// \param IsCompletionHandler -- true, if parameter is a completion handler. virtual void handleNeverCalled(const ParmVarDecl *Parameter, - const Stmt *Where, NeverCalledReason Reason, + const Decl *Function, const Stmt *Where, + NeverCalledReason Reason, bool IsCalledDirectly, bool IsCompletionHandler) {} + + /// Called when the block is guaranteed to be called exactly once. + /// It means that we can be stricter with what we report on that block. + /// \param Block -- block declaration that is known to be called exactly once. + virtual void + handleBlockThatIsGuaranteedToBeCalledOnce(const BlockDecl *Block) {} + + /// Called when the block has no guarantees about how many times it can get + /// called. + /// It means that we should be more lenient with reporting warnings in it. + /// \param Block -- block declaration in question. + virtual void handleBlockWithNoGuarantees(const BlockDecl *Block) {} }; /// Check given CFG for 'called once' parameter violations. diff --git a/clang/include/clang/Analysis/AnalysisDeclContext.h b/clang/include/clang/Analysis/AnalysisDeclContext.h index d12582f4f329..102970a1d55e 100644 --- a/clang/include/clang/Analysis/AnalysisDeclContext.h +++ b/clang/include/clang/Analysis/AnalysisDeclContext.h @@ -200,6 +200,8 @@ public: /// \returns Whether the root namespace of \p D is the \c std C++ namespace. static bool isInStdNamespace(const Decl *D); + static std::string getFunctionName(const Decl *D); + private: std::unique_ptr<ManagedAnalysis> &getAnalysisImpl(const void *tag); diff --git a/clang/include/clang/Analysis/AnyCall.h b/clang/include/clang/Analysis/AnyCall.h index 16371eb1da18..846ff7719ce1 100644 --- a/clang/include/clang/Analysis/AnyCall.h +++ b/clang/include/clang/Analysis/AnyCall.h @@ -107,8 +107,8 @@ public: } - /// If {@code E} is a generic call (to ObjC method /function/block/etc), - /// return a constructed {@code AnyCall} object. Return None otherwise. + /// If @c E is a generic call (to ObjC method /function/block/etc), + /// return a constructed @c AnyCall object. Return None otherwise. static Optional<AnyCall> forExpr(const Expr *E) { if (const auto *ME = dyn_cast<ObjCMessageExpr>(E)) { return AnyCall(ME); @@ -127,8 +127,8 @@ public: } } - /// If {@code D} is a callable (Objective-C method or a function), return - /// a constructed {@code AnyCall} object. Return None otherwise. + /// If @c D is a callable (Objective-C method or a function), return + /// a constructed @c AnyCall object. Return None otherwise. // FIXME: block support. static Optional<AnyCall> forDecl(const Decl *D) { if (const auto *FD = dyn_cast<FunctionDecl>(D)) { @@ -186,7 +186,7 @@ public: } /// \returns Function identifier if it is a named declaration, - /// {@code nullptr} otherwise. + /// @c nullptr otherwise. const IdentifierInfo *getIdentifier() const { if (const auto *ND = dyn_cast_or_null<NamedDecl>(D)) return ND->getIdentifier(); diff --git a/clang/include/clang/Analysis/CFG.h b/clang/include/clang/Analysis/CFG.h index 43fb523c863a..9e32eb8e066a 100644 --- a/clang/include/clang/Analysis/CFG.h +++ b/clang/include/clang/Analysis/CFG.h @@ -1307,6 +1307,12 @@ public: iterator nodes_begin() { return iterator(Blocks.begin()); } iterator nodes_end() { return iterator(Blocks.end()); } + + llvm::iterator_range<iterator> nodes() { return {begin(), end()}; } + llvm::iterator_range<const_iterator> const_nodes() const { + return {begin(), end()}; + } + const_iterator nodes_begin() const { return const_iterator(Blocks.begin()); } const_iterator nodes_end() const { return const_iterator(Blocks.end()); } @@ -1315,6 +1321,13 @@ public: const_reverse_iterator rbegin() const { return Blocks.rbegin(); } const_reverse_iterator rend() const { return Blocks.rend(); } + llvm::iterator_range<reverse_iterator> reverse_nodes() { + return {rbegin(), rend()}; + } + llvm::iterator_range<const_reverse_iterator> const_reverse_nodes() const { + return {rbegin(), rend()}; + } + CFGBlock & getEntry() { return *Entry; } const CFGBlock & getEntry() const { return *Entry; } CFGBlock & getExit() { return *Exit; } @@ -1376,13 +1389,12 @@ public: // Member templates useful for various batch operations over CFGs. //===--------------------------------------------------------------------===// - template <typename CALLBACK> - void VisitBlockStmts(CALLBACK& O) const { + template <typename Callback> void VisitBlockStmts(Callback &O) const { for (const_iterator I = begin(), E = end(); I != E; ++I) for (CFGBlock::const_iterator BI = (*I)->begin(), BE = (*I)->end(); BI != BE; ++BI) { if (Optional<CFGStmt> stmt = BI->getAs<CFGStmt>()) - O(const_cast<Stmt*>(stmt->getStmt())); + O(const_cast<Stmt *>(stmt->getStmt())); } } diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowValues.h b/clang/include/clang/Analysis/FlowSensitive/DataflowValues.h index 68d935c6a400..ab96cd5169a2 100644 --- a/clang/include/clang/Analysis/FlowSensitive/DataflowValues.h +++ b/clang/include/clang/Analysis/FlowSensitive/DataflowValues.h @@ -19,13 +19,14 @@ #include "clang/Analysis/ProgramPoint.h" #include "llvm/ADT/DenseMap.h" +namespace clang { + //===----------------------------------------------------------------------===// /// Dataflow Directional Tag Classes. These are used for tag dispatching /// within the dataflow solver/transfer functions to determine what direction /// a dataflow analysis flows. //===----------------------------------------------------------------------===// -namespace clang { namespace dataflow { struct forward_analysis_tag {}; struct backward_analysis_tag {}; diff --git a/clang/include/clang/Analysis/MacroExpansionContext.h b/clang/include/clang/Analysis/MacroExpansionContext.h new file mode 100644 index 000000000000..57934bfc09d9 --- /dev/null +++ b/clang/include/clang/Analysis/MacroExpansionContext.h @@ -0,0 +1,127 @@ +//===- MacroExpansionContext.h - Macro expansion information ----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_ANALYSIS_MACROEXPANSIONCONTEXT_H +#define LLVM_CLANG_ANALYSIS_MACROEXPANSIONCONTEXT_H + +#include "clang/Basic/LangOptions.h" +#include "clang/Basic/SourceLocation.h" +#include "clang/Lex/Preprocessor.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/ADT/SmallVector.h" + +namespace clang { + +namespace detail { +class MacroExpansionRangeRecorder; +} // namespace detail + +/// MacroExpansionContext tracks the macro expansions processed by the +/// Preprocessor. It means that it can track source locations from a single +/// translation unit. For every macro expansion it can tell you what text will +/// be substituted. +/// +/// It was designed to deal with: +/// - regular macros +/// - macro functions +/// - variadic macros +/// - transitive macro expansions +/// - macro redefinition +/// - unbalanced parenthesis +/// +/// \code{.c} +/// void bar(); +/// #define retArg(x) x +/// #define retArgUnclosed retArg(bar() +/// #define BB CC +/// #define applyInt BB(int) +/// #define CC(x) retArgUnclosed +/// +/// void unbalancedMacros() { +/// applyInt ); +/// //^~~~~~~~~~^ is the substituted range +/// // Substituted text is "applyInt )" +/// // Expanded text is "bar()" +/// } +/// +/// #define expandArgUnclosedCommaExpr(x) (x, bar(), 1 +/// #define f expandArgUnclosedCommaExpr +/// +/// void unbalancedMacros2() { +/// int x = f(f(1)) )); // Look at the parenthesis! +/// // ^~~~~~^ is the substituted range +/// // Substituted text is "f(f(1))" +/// // Expanded text is "((1,bar(),1,bar(),1" +/// } +/// \endcode +/// \remark Currently we don't respect the whitespaces between expanded tokens, +/// so the output for this example might differ from the -E compiler +/// invocation. +/// \remark All whitespaces are consumed while constructing the expansion. +/// After all identifier a single space inserted to produce a valid C +/// code even if identifier follows an other identifiers such as +/// variable declarations. +/// \remark MacroExpansionContext object must outlive the Preprocessor +/// parameter. +class MacroExpansionContext { +public: + /// Creates a MacroExpansionContext. + /// \remark You must call registerForPreprocessor to set the required + /// onTokenLexed callback and the PPCallbacks. + explicit MacroExpansionContext(const LangOptions &LangOpts); + + /// Register the necessary callbacks to the Preprocessor to record the + /// expansion events and the generated tokens. Must ensure that this object + /// outlives the given Preprocessor. + void registerForPreprocessor(Preprocessor &PP); + + /// \param MacroExpansionLoc Must be the expansion location of a macro. + /// \return The textual representation of the token sequence which was + /// substituted in place of the macro after the preprocessing. + /// If no macro was expanded at that location, returns llvm::None. + Optional<StringRef> getExpandedText(SourceLocation MacroExpansionLoc) const; + + /// \param MacroExpansionLoc Must be the expansion location of a macro. + /// \return The text from the original source code which were substituted by + /// the macro expansion chain from the given location. + /// If no macro was expanded at that location, returns llvm::None. + Optional<StringRef> getOriginalText(SourceLocation MacroExpansionLoc) const; + + LLVM_DUMP_METHOD void dumpExpansionRangesToStream(raw_ostream &OS) const; + LLVM_DUMP_METHOD void dumpExpandedTextsToStream(raw_ostream &OS) const; + LLVM_DUMP_METHOD void dumpExpansionRanges() const; + LLVM_DUMP_METHOD void dumpExpandedTexts() const; + +private: + friend class detail::MacroExpansionRangeRecorder; + using MacroExpansionText = SmallString<40>; + using ExpansionMap = llvm::DenseMap<SourceLocation, MacroExpansionText>; + using ExpansionRangeMap = llvm::DenseMap<SourceLocation, SourceLocation>; + + /// Associates the textual representation of the expanded tokens at the given + /// macro expansion location. + ExpansionMap ExpandedTokens; + + /// Tracks which source location was the last affected by any macro + /// substitution starting from a given macro expansion location. + ExpansionRangeMap ExpansionRanges; + + Preprocessor *PP = nullptr; + SourceManager *SM = nullptr; + const LangOptions &LangOpts; + + /// This callback is called by the preprocessor. + /// It stores the textual representation of the expanded token sequence for a + /// macro expansion location. + void onTokenLexed(const Token &Tok); +}; +} // end namespace clang + +#endif // LLVM_CLANG_ANALYSIS_MACROEXPANSIONCONTEXT_H diff --git a/clang/include/clang/Analysis/RetainSummaryManager.h b/clang/include/clang/Analysis/RetainSummaryManager.h index 6acefb563d8c..b7ccb0317830 100644 --- a/clang/include/clang/Analysis/RetainSummaryManager.h +++ b/clang/include/clang/Analysis/RetainSummaryManager.h @@ -613,8 +613,8 @@ class RetainSummaryManager { const FunctionType *FT, bool &AllowAnnotations); - /// Apply the annotation of {@code pd} in function {@code FD} - /// to the resulting summary stored in out-parameter {@code Template}. + /// Apply the annotation of @c pd in function @c FD + /// to the resulting summary stored in out-parameter @c Template. /// \return whether an annotation was applied. bool applyParamAnnotationEffect(const ParmVarDecl *pd, unsigned parm_idx, const NamedDecl *FD, @@ -715,8 +715,8 @@ private: /// Set argument types for arguments which are not doing anything. void updateSummaryForArgumentTypes(const AnyCall &C, const RetainSummary *&RS); - /// Determine whether a declaration {@code D} of correspondent type (return - /// type for functions/methods) {@code QT} has any of the given attributes, + /// Determine whether a declaration @c D of correspondent type (return + /// type for functions/methods) @c QT has any of the given attributes, /// provided they pass necessary validation checks AND tracking the given /// attribute is enabled. /// Returns the object kind corresponding to the present attribute, or None, diff --git a/clang/include/clang/Basic/ABI.h b/clang/include/clang/Basic/ABI.h index 2401ffa20494..231bad799a42 100644 --- a/clang/include/clang/Basic/ABI.h +++ b/clang/include/clang/Basic/ABI.h @@ -37,174 +37,6 @@ enum CXXDtorType { Dtor_Comdat ///< The COMDAT used for dtors }; -/// A return adjustment. -struct ReturnAdjustment { - /// The non-virtual adjustment from the derived object to its - /// nearest virtual base. - int64_t NonVirtual; - - /// Holds the ABI-specific information about the virtual return - /// adjustment, if needed. - union VirtualAdjustment { - // Itanium ABI - struct { - /// The offset (in bytes), relative to the address point - /// of the virtual base class offset. - int64_t VBaseOffsetOffset; - } Itanium; - - // Microsoft ABI - struct { - /// The offset (in bytes) of the vbptr, relative to the beginning - /// of the derived class. - uint32_t VBPtrOffset; - - /// Index of the virtual base in the vbtable. - uint32_t VBIndex; - } Microsoft; - - VirtualAdjustment() { - memset(this, 0, sizeof(*this)); - } - - bool Equals(const VirtualAdjustment &Other) const { - return memcmp(this, &Other, sizeof(Other)) == 0; - } - - bool isEmpty() const { - VirtualAdjustment Zero; - return Equals(Zero); - } - - bool Less(const VirtualAdjustment &RHS) const { - return memcmp(this, &RHS, sizeof(RHS)) < 0; - } - } Virtual; - - ReturnAdjustment() : NonVirtual(0) {} - - bool isEmpty() const { return !NonVirtual && Virtual.isEmpty(); } - - friend bool operator==(const ReturnAdjustment &LHS, - const ReturnAdjustment &RHS) { - return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Equals(RHS.Virtual); - } - - friend bool operator!=(const ReturnAdjustment &LHS, const ReturnAdjustment &RHS) { - return !(LHS == RHS); - } - - friend bool operator<(const ReturnAdjustment &LHS, - const ReturnAdjustment &RHS) { - if (LHS.NonVirtual < RHS.NonVirtual) - return true; - - return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Less(RHS.Virtual); - } -}; - -/// A \c this pointer adjustment. -struct ThisAdjustment { - /// The non-virtual adjustment from the derived object to its - /// nearest virtual base. - int64_t NonVirtual; - - /// Holds the ABI-specific information about the virtual this - /// adjustment, if needed. - union VirtualAdjustment { - // Itanium ABI - struct { - /// The offset (in bytes), relative to the address point, - /// of the virtual call offset. - int64_t VCallOffsetOffset; - } Itanium; - - struct { - /// The offset of the vtordisp (in bytes), relative to the ECX. - int32_t VtordispOffset; - - /// The offset of the vbptr of the derived class (in bytes), - /// relative to the ECX after vtordisp adjustment. - int32_t VBPtrOffset; - - /// The offset (in bytes) of the vbase offset in the vbtable. - int32_t VBOffsetOffset; - } Microsoft; - - VirtualAdjustment() { - memset(this, 0, sizeof(*this)); - } - - bool Equals(const VirtualAdjustment &Other) const { - return memcmp(this, &Other, sizeof(Other)) == 0; - } - - bool isEmpty() const { - VirtualAdjustment Zero; - return Equals(Zero); - } - - bool Less(const VirtualAdjustment &RHS) const { - return memcmp(this, &RHS, sizeof(RHS)) < 0; - } - } Virtual; - - ThisAdjustment() : NonVirtual(0) { } - - bool isEmpty() const { return !NonVirtual && Virtual.isEmpty(); } - - friend bool operator==(const ThisAdjustment &LHS, - const ThisAdjustment &RHS) { - return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Equals(RHS.Virtual); - } - - friend bool operator!=(const ThisAdjustment &LHS, const ThisAdjustment &RHS) { - return !(LHS == RHS); - } - - friend bool operator<(const ThisAdjustment &LHS, - const ThisAdjustment &RHS) { - if (LHS.NonVirtual < RHS.NonVirtual) - return true; - - return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Less(RHS.Virtual); - } -}; - -class CXXMethodDecl; - -/// The \c this pointer adjustment as well as an optional return -/// adjustment for a thunk. -struct ThunkInfo { - /// The \c this pointer adjustment. - ThisAdjustment This; - - /// The return adjustment. - ReturnAdjustment Return; - - /// Holds a pointer to the overridden method this thunk is for, - /// if needed by the ABI to distinguish different thunks with equal - /// adjustments. Otherwise, null. - /// CAUTION: In the unlikely event you need to sort ThunkInfos, consider using - /// an ABI-specific comparator. - const CXXMethodDecl *Method; - - ThunkInfo() : Method(nullptr) { } - - ThunkInfo(const ThisAdjustment &This, const ReturnAdjustment &Return, - const CXXMethodDecl *Method = nullptr) - : This(This), Return(Return), Method(Method) {} - - friend bool operator==(const ThunkInfo &LHS, const ThunkInfo &RHS) { - return LHS.This == RHS.This && LHS.Return == RHS.Return && - LHS.Method == RHS.Method; - } - - bool isEmpty() const { - return This.isEmpty() && Return.isEmpty() && Method == nullptr; - } -}; - } // end namespace clang #endif diff --git a/clang/include/clang/Basic/AddressSpaces.h b/clang/include/clang/Basic/AddressSpaces.h index a9db52dfcc9c..99bb67fd26d1 100644 --- a/clang/include/clang/Basic/AddressSpaces.h +++ b/clang/include/clang/Basic/AddressSpaces.h @@ -44,6 +44,13 @@ enum class LangAS : unsigned { cuda_constant, cuda_shared, + // SYCL specific address spaces. + sycl_global, + sycl_global_device, + sycl_global_host, + sycl_local, + sycl_private, + // Pointer size and extension address spaces. ptr32_sptr, ptr32_uptr, diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index bfd50f6a6779..12d09181a2ea 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -368,6 +368,7 @@ def TargetBPF : TargetArch<["bpfel", "bpfeb"]>; def TargetMips32 : TargetArch<["mips", "mipsel"]>; def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>; def TargetMSP430 : TargetArch<["msp430"]>; +def TargetM68k : TargetArch<["m68k"]>; def TargetRISCV : TargetArch<["riscv32", "riscv64"]>; def TargetX86 : TargetArch<["x86"]>; def TargetAnyX86 : TargetArch<["x86", "x86_64"]>; @@ -553,6 +554,11 @@ class Attr { list<Documentation> Documentation; } +/// Used to define a set of mutually exclusive attributes. +class MutualExclusions<list<Attr> Ex> { + list<Attr> Exclusions = Ex; +} + /// A type attribute is not processed on a declaration or a statement. class TypeAttr : Attr; @@ -636,6 +642,15 @@ def Alias : Attr { let Documentation = [Undocumented]; } +def BuiltinAlias : Attr { + let Spellings = [CXX11<"clang", "builtin_alias">, + C2x<"clang", "builtin_alias">, + GNU<"clang_builtin_alias">]; + let Args = [IdentifierArgument<"BuiltinName">]; + let Subjects = SubjectList<[Function], ErrorDiag>; + let Documentation = [BuiltinAliasDocs]; +} + def ArmBuiltinAlias : InheritableAttr, TargetSpecificAttr<TargetAnyArm> { let Spellings = [Clang<"__clang_arm_builtin_alias">]; let Args = [IdentifierArgument<"BuiltinName">]; @@ -729,7 +744,8 @@ def XRayLogArgs : InheritableAttr { def PatchableFunctionEntry : InheritableAttr, - TargetSpecificAttr<TargetArch<["aarch64", "aarch64_be", "x86", "x86_64"]>> { + TargetSpecificAttr<TargetArch< + ["aarch64", "aarch64_be", "riscv32", "riscv64", "x86", "x86_64"]>> { let Spellings = [GCC<"patchable_function_entry">]; let Subjects = SubjectList<[Function, ObjCMethod]>; let Args = [UnsignedArgument<"Count">, DefaultIntArgument<"Offset", 0>]; @@ -772,8 +788,9 @@ def Annotate : InheritableParamAttr { } def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> { - // NOTE: If you add any additional spellings, MSP430Interrupt's, - // MipsInterrupt's and AnyX86Interrupt's spellings must match. + // NOTE: If you add any additional spellings, M68kInterrupt's, + // MSP430Interrupt's, MipsInterrupt's and AnyX86Interrupt's spellings + // must match. let Spellings = [GCC<"interrupt">]; let Args = [EnumArgument<"Interrupt", "InterruptType", ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""], @@ -839,6 +856,8 @@ def Availability : InheritableAttr { .Case("macos_app_extension", "macOS (App Extension)") .Case("tvos_app_extension", "tvOS (App Extension)") .Case("watchos_app_extension", "watchOS (App Extension)") + .Case("maccatalyst", "macCatalyst") + .Case("maccatalyst_app_extension", "macCatalyst (App Extension)") .Case("swift", "Swift") .Default(llvm::StringRef()); } @@ -852,6 +871,8 @@ static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) { .Case("macos_app_extension", "macOSApplicationExtension") .Case("tvos_app_extension", "tvOSApplicationExtension") .Case("watchos_app_extension", "watchOSApplicationExtension") + .Case("maccatalyst", "macCatalyst") + .Case("maccatalyst_app_extension", "macCatalystApplicationExtension") .Case("zos", "z/OS") .Default(Platform); } @@ -865,6 +886,8 @@ static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) { .Case("macOSApplicationExtension", "macos_app_extension") .Case("tvOSApplicationExtension", "tvos_app_extension") .Case("watchOSApplicationExtension", "watchos_app_extension") + .Case("macCatalyst", "maccatalyst") + .Case("macCatalystApplicationExtension", "maccatalyst_app_extension") .Default(Platform); } }]; let HasCustomParsing = 1; @@ -915,6 +938,7 @@ def CFAuditedTransfer : InheritableAttr { let Spellings = [Clang<"cf_audited_transfer">]; let Subjects = SubjectList<[Function], ErrorDiag>; let Documentation = [Undocumented]; + let SimpleHandler = 1; } // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer. @@ -924,7 +948,9 @@ def CFUnknownTransfer : InheritableAttr { let Spellings = [Clang<"cf_unknown_transfer">]; let Subjects = SubjectList<[Function], ErrorDiag>; let Documentation = [Undocumented]; + let SimpleHandler = 1; } +def : MutualExclusions<[CFAuditedTransfer, CFUnknownTransfer]>; def CFReturnsRetained : InheritableAttr { let Spellings = [Clang<"cf_returns_retained">]; @@ -1006,6 +1032,7 @@ def Cold : InheritableAttr { let Spellings = [GCC<"cold">]; let Subjects = SubjectList<[Function]>; let Documentation = [Undocumented]; + let SimpleHandler = 1; } def Common : InheritableAttr { @@ -1091,6 +1118,7 @@ def CUDADeviceBuiltinSurfaceType : InheritableAttr { let Subjects = SubjectList<[CXXRecord]>; let Documentation = [CUDADeviceBuiltinSurfaceTypeDocs]; let MeaningfulToClassTemplateDefinition = 1; + let SimpleHandler = 1; } def CUDADeviceBuiltinTextureType : InheritableAttr { @@ -1100,7 +1128,10 @@ def CUDADeviceBuiltinTextureType : InheritableAttr { let Subjects = SubjectList<[CXXRecord]>; let Documentation = [CUDADeviceBuiltinTextureTypeDocs]; let MeaningfulToClassTemplateDefinition = 1; + let SimpleHandler = 1; } +def : MutualExclusions<[CUDADeviceBuiltinSurfaceType, + CUDADeviceBuiltinTextureType]>; def CUDAGlobal : InheritableAttr { let Spellings = [GNU<"global">, Declspec<"__global__">]; @@ -1108,13 +1139,16 @@ def CUDAGlobal : InheritableAttr { let LangOpts = [CUDA]; let Documentation = [Undocumented]; } +def : MutualExclusions<[CUDADevice, CUDAGlobal]>; def CUDAHost : InheritableAttr { let Spellings = [GNU<"host">, Declspec<"__host__">]; let Subjects = SubjectList<[Function]>; let LangOpts = [CUDA]; let Documentation = [Undocumented]; + let SimpleHandler = 1; } +def : MutualExclusions<[CUDAGlobal, CUDAHost]>; def HIPManaged : InheritableAttr { let Spellings = [GNU<"managed">, Declspec<"__managed__">]; @@ -1147,6 +1181,7 @@ def CUDAShared : InheritableAttr { let LangOpts = [CUDA]; let Documentation = [Undocumented]; } +def : MutualExclusions<[CUDAConstant, CUDAShared, HIPManaged]>; def SYCLKernel : InheritableAttr { let Spellings = [Clang<"sycl_kernel">]; @@ -1178,9 +1213,11 @@ def OpenCLKernel : InheritableAttr { let SimpleHandler = 1; } -def OpenCLUnrollHint : InheritableAttr { +def OpenCLUnrollHint : StmtAttr { let Spellings = [GNU<"opencl_unroll_hint">]; - let Args = [UnsignedArgument<"UnrollHint">]; + let Subjects = SubjectList<[ForStmt, CXXForRangeStmt, WhileStmt, DoStmt], + ErrorDiag, "'for', 'while', and 'do' statements">; + let Args = [UnsignedArgument<"UnrollHint", /*opt*/1>]; let Documentation = [OpenCLUnrollHintDocs]; } @@ -1286,7 +1323,7 @@ def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> { def AllocSize : InheritableAttr { let Spellings = [GCC<"alloc_size">]; - let Subjects = SubjectList<[Function]>; + let Subjects = SubjectList<[HasFunctionProto]>; let Args = [ParamIdxArgument<"ElemSizeParam">, ParamIdxArgument<"NumElemsParam", /*opt*/ 1>]; let TemplateDependent = 1; @@ -1321,7 +1358,10 @@ def FallThrough : StmtAttr { let Spellings = [CXX11<"", "fallthrough", 201603>, C2x<"", "fallthrough", 201904>, CXX11<"clang", "fallthrough">, GCC<"fallthrough">]; -// let Subjects = [NullStmt]; + // The attribute only applies to a NullStmt, but we have special fix-it + // behavior if applied to a case label. + let Subjects = SubjectList<[NullStmt, SwitchCase], ErrorDiag, + "empty statements">; let Documentation = [FallthroughDocs]; } @@ -1334,15 +1374,23 @@ def Unlikely : StmtAttr { let Spellings = [CXX11<"", "unlikely", 201803>, C2x<"clang", "unlikely">]; let Documentation = [LikelihoodDocs]; } +def : MutualExclusions<[Likely, Unlikely]>; def NoMerge : DeclOrStmtAttr { let Spellings = [Clang<"nomerge">]; let Documentation = [NoMergeDocs]; let InheritEvenIfAlreadyPresent = 1; - let Subjects = SubjectList<[Function], ErrorDiag, "functions and statements">; + let Subjects = SubjectList<[Function, Stmt], ErrorDiag, + "functions and statements">; let SimpleHandler = 1; } +def MustTail : StmtAttr { + let Spellings = [Clang<"musttail">]; + let Documentation = [MustTailDocs]; + let Subjects = SubjectList<[ReturnStmt], ErrorDiag, "return statements">; +} + def FastCall : DeclOrTypeAttr { let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">, Keyword<"_fastcall">]; @@ -1424,7 +1472,9 @@ def Hot : InheritableAttr { // An AST node is created for this attribute, but not actually used beyond // semantic checking for mutual exclusion with the Cold attribute. let Documentation = [Undocumented]; + let SimpleHandler = 1; } +def : MutualExclusions<[Hot, Cold]>; def IBAction : InheritableAttr { let Spellings = [Clang<"ibaction">]; @@ -1459,7 +1509,7 @@ def IFunc : Attr, TargetSpecificAttr<TargetELF> { def Restrict : InheritableAttr { let Spellings = [Declspec<"restrict">, GCC<"malloc">]; let Subjects = SubjectList<[Function]>; - let Documentation = [Undocumented]; + let Documentation = [RestrictDocs]; } def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> { @@ -1522,8 +1572,8 @@ def MSABI : DeclOrTypeAttr { } def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> { - // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's - // and AnyX86Interrupt's spellings must match. + // NOTE: If you add any additional spellings, ARMInterrupt's, M68kInterrupt's, + // MipsInterrupt's and AnyX86Interrupt's spellings must match. let Spellings = [GCC<"interrupt">]; let Args = [UnsignedArgument<"Number">]; let ParseKind = "Interrupt"; @@ -1535,11 +1585,13 @@ def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> { let Spellings = [GCC<"mips16">]; let Subjects = SubjectList<[Function], ErrorDiag>; let Documentation = [Undocumented]; + let SimpleHandler = 1; } def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips32> { // NOTE: If you add any additional spellings, ARMInterrupt's, - // MSP430Interrupt's and AnyX86Interrupt's spellings must match. + // M68kInterrupt's, MSP430Interrupt's and AnyX86Interrupt's spellings + // must match. let Spellings = [GCC<"interrupt">]; let Subjects = SubjectList<[Function]>; let Args = [EnumArgument<"Interrupt", "InterruptType", @@ -1552,23 +1604,39 @@ def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips32> { let ParseKind = "Interrupt"; let Documentation = [MipsInterruptDocs]; } +def : MutualExclusions<[Mips16, MipsInterrupt]>; def MicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> { let Spellings = [GCC<"micromips">]; let Subjects = SubjectList<[Function], ErrorDiag>; let Documentation = [MicroMipsDocs]; + let SimpleHandler = 1; } +def : MutualExclusions<[Mips16, MicroMips]>; def MipsLongCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> { let Spellings = [GCC<"long_call">, GCC<"far">]; let Subjects = SubjectList<[Function]>; let Documentation = [MipsLongCallStyleDocs]; + let SimpleHandler = 1; } def MipsShortCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> { let Spellings = [GCC<"short_call">, GCC<"near">]; let Subjects = SubjectList<[Function]>; let Documentation = [MipsShortCallStyleDocs]; + let SimpleHandler = 1; +} +def : MutualExclusions<[MipsLongCall, MipsShortCall]>; + +def M68kInterrupt : InheritableAttr, TargetSpecificAttr<TargetM68k> { + // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's + // MSP430Interrupt's and AnyX86Interrupt's spellings must match. + let Spellings = [GNU<"interrupt">]; + let Args = [UnsignedArgument<"Number">]; + let ParseKind = "Interrupt"; + let HasCustomParsing = 1; + let Documentation = [Undocumented]; } def Mode : Attr { @@ -1636,7 +1704,9 @@ def DisableTailCalls : InheritableAttr { let Spellings = [Clang<"disable_tail_calls">]; let Subjects = SubjectList<[Function, ObjCMethod]>; let Documentation = [DisableTailCallsDocs]; + let SimpleHandler = 1; } +def : MutualExclusions<[Naked, DisableTailCalls]>; def NoAlias : InheritableAttr { let Spellings = [Declspec<"noalias">]; @@ -1658,6 +1728,14 @@ def NoDebug : InheritableAttr { let Documentation = [NoDebugDocs]; } +def StandaloneDebug : InheritableAttr { + let Spellings = [Clang<"standalone_debug", /*allowInC =*/0>]; + let Subjects = SubjectList<[CXXRecord]>; + let Documentation = [StandaloneDebugDocs]; + let SimpleHandler = 1; + let LangOpts = [CPlusPlus]; +} + def NoDuplicate : InheritableAttr { let Spellings = [Clang<"noduplicate">]; let Subjects = SubjectList<[Function]>; @@ -1898,11 +1976,20 @@ def NoInstrumentFunction : InheritableAttr { let SimpleHandler = 1; } +def NoProfileFunction : InheritableAttr { + let Spellings = [GCC<"no_profile_instrument_function">]; + let Subjects = SubjectList<[Function]>; + let Documentation = [NoProfileInstrumentFunctionDocs]; + let SimpleHandler = 1; +} + def NotTailCalled : InheritableAttr { let Spellings = [Clang<"not_tail_called">]; let Subjects = SubjectList<[Function]>; let Documentation = [NotTailCalledDocs]; + let SimpleHandler = 1; } +def : MutualExclusions<[AlwaysInline, NotTailCalled]>; def NoStackProtector : InheritableAttr { let Spellings = [Clang<"no_stack_protector">]; @@ -2085,6 +2172,7 @@ def ObjCNonRuntimeProtocol : Attr { let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>; let LangOpts = [ObjC]; let Documentation = [ObjCNonRuntimeProtocolDocs]; + let SimpleHandler = 1; } def ObjCRuntimeName : Attr { @@ -2219,12 +2307,14 @@ def SwiftBridgedTypedef : InheritableAttr { let Spellings = [GNU<"swift_bridged_typedef">]; let Subjects = SubjectList<[TypedefName], ErrorDiag>; let Documentation = [SwiftBridgedTypedefDocs]; + let SimpleHandler = 1; } def SwiftObjCMembers : Attr { let Spellings = [GNU<"swift_objc_members">]; let Subjects = SubjectList<[ObjCInterface], ErrorDiag>; let Documentation = [SwiftObjCMembersDocs]; + let SimpleHandler = 1; } def SwiftError : InheritableAttr { @@ -2256,6 +2346,7 @@ def SwiftNewType : InheritableAttr { def SwiftPrivate : InheritableAttr { let Spellings = [GNU<"swift_private">]; let Documentation = [SwiftPrivateDocs]; + let SimpleHandler = 1; } def NoDeref : TypeAttr { @@ -2374,11 +2465,21 @@ def SwiftCall : DeclOrTypeAttr { let Documentation = [SwiftCallDocs]; } +def SwiftAsyncCall : DeclOrTypeAttr { + let Spellings = [Clang<"swiftasynccall">]; + let Documentation = [SwiftAsyncCallDocs]; +} + def SwiftContext : ParameterABIAttr { let Spellings = [Clang<"swift_context">]; let Documentation = [SwiftContextDocs]; } +def SwiftAsyncContext : ParameterABIAttr { + let Spellings = [Clang<"swift_async_context">]; + let Documentation = [SwiftAsyncContextDocs]; +} + def SwiftErrorResult : ParameterABIAttr { let Spellings = [Clang<"swift_error_result">]; let Documentation = [SwiftErrorResultDocs]; @@ -2399,6 +2500,16 @@ def SwiftAsync : InheritableAttr { let Documentation = [SwiftAsyncDocs]; } +def SwiftAsyncError : InheritableAttr { + let Spellings = [Clang<"swift_async_error">]; + let Subjects = SubjectList<[Function, ObjCMethod]>; + let Args = [EnumArgument<"Convention", "ConventionKind", + ["none", "nonnull_error", "zero_argument", "nonzero_argument"], + ["None", "NonNullError", "ZeroArgument", "NonZeroArgument"]>, + UnsignedArgument<"HandlerParamIdx", /*opt=*/1>]; + let Documentation = [SwiftAsyncErrorDocs]; +} + def Suppress : StmtAttr { let Spellings = [CXX11<"gsl", "suppress">]; let Args = [VariadicStringArgument<"DiagnosticIdentifiers">]; @@ -2636,7 +2747,14 @@ def Unused : InheritableAttr { def Used : InheritableAttr { let Spellings = [GCC<"used">]; let Subjects = SubjectList<[NonLocalVar, Function, ObjCMethod]>; - let Documentation = [Undocumented]; + let Documentation = [UsedDocs]; + let SimpleHandler = 1; +} + +def Retain : InheritableAttr { + let Spellings = [GCC<"retain">]; + let Subjects = SubjectList<[NonLocalVar, Function, ObjCMethod]>; + let Documentation = [RetainDocs]; let SimpleHandler = 1; } @@ -2758,7 +2876,7 @@ def LTOVisibilityPublic : InheritableAttr { def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr<TargetAnyX86> { // NOTE: If you add any additional spellings, ARMInterrupt's, - // MSP430Interrupt's and MipsInterrupt's spellings must match. + // M68kInterrupt's, MSP430Interrupt's and MipsInterrupt's spellings must match. let Spellings = [GCC<"interrupt">]; let Subjects = SubjectList<[HasFunctionProto]>; let ParseKind = "Interrupt"; @@ -2802,6 +2920,10 @@ def NoSanitize : InheritableAttr { } return Mask; } + + bool hasCoverage() const { + return llvm::is_contained(sanitizers(), "coverage"); + } }]; } @@ -3199,6 +3321,7 @@ def Pointer : InheritableAttr { let Args = [TypeArgument<"DerefType", /*opt=*/1>]; let Documentation = [LifetimePointerDocs]; } +def : MutualExclusions<[Owner, Pointer]>; // Microsoft-related attributes @@ -3426,6 +3549,7 @@ def LoopHint : Attr { }]; let Documentation = [LoopHintDocs, UnrollHintDocs]; + let HasCustomParsing = 1; } def CapturedRecord : InheritableAttr { @@ -3509,6 +3633,7 @@ def OMPDeclareTargetDecl : InheritableAttr { void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const; static llvm::Optional<MapTypeTy> isDeclareTargetDeclaration(const ValueDecl *VD); + static llvm::Optional<OMPDeclareTargetDeclAttr*> getActiveAttr(const ValueDecl *VD); static llvm::Optional<DevTypeTy> getDeviceType(const ValueDecl *VD); static llvm::Optional<SourceLocation> getLocation(const ValueDecl *VD); }]; @@ -3570,6 +3695,7 @@ def InternalLinkage : InheritableAttr { let Subjects = SubjectList<[Var, Function, CXXRecord]>; let Documentation = [InternalLinkageDocs]; } +def : MutualExclusions<[Common, InternalLinkage]>; def ExcludeFromExplicitInstantiation : InheritableAttr { let Spellings = [Clang<"exclude_from_explicit_instantiation">]; @@ -3597,18 +3723,22 @@ def AlwaysDestroy : InheritableAttr { let Subjects = SubjectList<[Var]>; let Documentation = [AlwaysDestroyDocs]; } +def : MutualExclusions<[NoDestroy, AlwaysDestroy]>; def SpeculativeLoadHardening : InheritableAttr { let Spellings = [Clang<"speculative_load_hardening">]; let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; let Documentation = [SpeculativeLoadHardeningDocs]; + let SimpleHandler = 1; } def NoSpeculativeLoadHardening : InheritableAttr { let Spellings = [Clang<"no_speculative_load_hardening">]; let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; let Documentation = [NoSpeculativeLoadHardeningDocs]; + let SimpleHandler = 1; } +def : MutualExclusions<[SpeculativeLoadHardening, NoSpeculativeLoadHardening]>; def Uninitialized : InheritableAttr { let Spellings = [Clang<"uninitialized", 0>]; @@ -3621,6 +3751,7 @@ def LoaderUninitialized : Attr { let Spellings = [Clang<"loader_uninitialized">]; let Subjects = SubjectList<[GlobalVar]>; let Documentation = [LoaderUninitializedDocs]; + let SimpleHandler = 1; } def ObjCExternallyRetained : InheritableAttr { @@ -3637,6 +3768,14 @@ def NoBuiltin : Attr { let Documentation = [NoBuiltinDocs]; } +def UsingIfExists : InheritableAttr { + let Spellings = [Clang<"using_if_exists", 0>]; + let Subjects = SubjectList<[Using, + UnresolvedUsingTypename, + UnresolvedUsingValue], ErrorDiag>; + let Documentation = [UsingIfExistsDocs]; +} + // FIXME: This attribute is not inheritable, it will not be propagated to // redecls. [[clang::lifetimebound]] has the same problems. This should be // fixed in TableGen (by probably adding a new inheritable flag). diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 170a0fe3d4c4..c265a877e3b1 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -57,6 +57,55 @@ global variable or function should be in after translation. let Heading = "section, __declspec(allocate)"; } +def UsedDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +This attribute, when attached to a function or variable definition, indicates +that there may be references to the entity which are not apparent in the source +code. For example, it may be referenced from inline ``asm``, or it may be +found through a dynamic symbol or section lookup. + +The compiler must emit the definition even if it appears to be unused, and it +must not apply optimizations which depend on fully understanding how the entity +is used. + +Whether this attribute has any effect on the linker depends on the target and +the linker. Most linkers support the feature of section garbage collection +(``--gc-sections``), also known as "dead stripping" (``ld64 -dead_strip``) or +discarding unreferenced sections (``link.exe /OPT:REF``). On COFF and Mach-O +targets (Windows and Apple platforms), the `used` attribute prevents symbols +from being removed by linker section GC. On ELF targets, it has no effect on its +own, and the linker may remove the definition if it is not otherwise referenced. +This linker GC can be avoided by also adding the ``retain`` attribute. Note +that ``retain`` requires special support from the linker; see that attribute's +documentation for further information. + }]; +} + +def RetainDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +This attribute, when attached to a function or variable definition, prevents +section garbage collection in the linker. It does not prevent other discard +mechanisms, such as archive member selection, and COMDAT group resolution. + +If the compiler does not emit the definition, e.g. because it was not used in +the translation unit or the compiler was able to eliminate all of the uses, +this attribute has no effect. This attribute is typically combined with the +``used`` attribute to force the definition to be emitted and preserved into the +final linked image. + +This attribute is only necessary on ELF targets; other targets prevent section +garbage collection by the linker when using the ``used`` attribute alone. +Using the attributes together should result in consistent behavior across +targets. + +This attribute requires the linker to support the ``SHF_GNU_RETAIN`` extension. +This support is available in GNU ``ld`` and ``gold`` as of binutils 2.36, as +well as in ``ld.lld`` 13. + }]; +} + def InitPriorityDocs : Documentation { let Category = DocCatVariable; let Content = [{ @@ -394,6 +443,32 @@ calls. }]; } +def MustTailDocs : Documentation { + let Category = DocCatStmt; + let Content = [{ +If a ``return`` statement is marked ``musttail``, this indicates that the +compiler must generate a tail call for the program to be correct, even when +optimizations are disabled. This guarantees that the call will not cause +unbounded stack growth if it is part of a recursive cycle in the call graph. + +If the callee is a virtual function that is implemented by a thunk, there is +no guarantee in general that the thunk tail-calls the implementation of the +virtual function, so such a call in a recursive cycle can still result in +unbounded stack growth. + +``clang::musttail`` can only be applied to a ``return`` statement whose value +is the result of a function call (even functions returning void must use +``return``, although no value is returned). The target function must have the +same number of arguments as the caller. The types of the return value and all +arguments must be similar according to C++ rules (differing only in cv +qualifiers or array size), including the implicit "this" argument, if any. +Any variables in scope, including all arguments to the function and the +return value must be trivially destructible. The calling convention of the +caller and callee must match, and they must not be variadic functions or have +old style K&R C function declarations. + }]; +} + def AssertCapabilityDocs : Documentation { let Category = DocCatFunction; let Heading = "assert_capability, assert_shared_capability"; @@ -1048,8 +1123,18 @@ def NoDebugDocs : Documentation { let Category = DocCatVariable; let Content = [{ The ``nodebug`` attribute allows you to suppress debugging information for a -function or method, or for a variable that is not a parameter or a non-static -data member. +function or method, for a variable that is not a parameter or a non-static +data member, or for a typedef or using declaration. + }]; +} + +def StandaloneDebugDocs : Documentation { + let Category = DocCatVariable; + let Content = [{ +The ``standalone_debug`` attribute causes debug info to be emitted for a record +type regardless of the debug info optimizations that are enabled with +-fno-standalone-debug. This attribute only has an effect when debug info +optimizations are enabled (e.g. with -fno-standalone-debug), and is C++-only. }]; } @@ -2474,17 +2559,33 @@ This attribute accepts a single parameter that must be one of the following: }]; } +def NoProfileInstrumentFunctionDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +Use the ``no_profile_instrument_function`` attribute on a function declaration +to denote that the compiler should not instrument the function with +profile-related instrumentation, such as via the +``-fprofile-generate`` / ``-fprofile-instr-generate`` / +``-fcs-profile-generate`` / ``-fprofile-arcs`` flags. +}]; +} + def NoSanitizeDocs : Documentation { let Category = DocCatFunction; let Content = [{ Use the ``no_sanitize`` attribute on a function or a global variable declaration to specify that a particular instrumentation or set of -instrumentations should not be applied. The attribute takes a list of -string literals, which have the same meaning as values accepted by the -``-fno-sanitize=`` flag. For example, -``__attribute__((no_sanitize("address", "thread")))`` specifies that -AddressSanitizer and ThreadSanitizer should not be applied to the -function or variable. +instrumentations should not be applied. + +The attribute takes a list of string literals with the following accepted +values: +* all values accepted by ``-fno-sanitize=``; +* ``coverage``, to disable SanitizerCoverage instrumentation. + +For example, ``__attribute__((no_sanitize("address", "thread")))`` specifies +that AddressSanitizer and ThreadSanitizer should not be applied to the function +or variable. Using ``__attribute__((no_sanitize("coverage")))`` specifies that +SanitizerCoverage should not be applied to the function. See :ref:`Controlling Code Generation <controlling-code-generation>` for a full list of supported sanitizer flags. @@ -2967,16 +3068,55 @@ It is only supported when using the Microsoft C++ ABI. def LifetimeBoundDocs : Documentation { let Category = DocCatFunction; let Content = [{ -The ``lifetimebound`` attribute indicates that a resource owned by -a function parameter or implicit object parameter -is retained by the return value of the annotated function -(or, for a parameter of a constructor, in the value of the constructed object). -It is only supported in C++. +The ``lifetimebound`` attribute on a function parameter or implicit object +parameter indicates that objects that are referred to by that parameter may +also be referred to by the return value of the annotated function (or, for a +parameter of a constructor, by the value of the constructed object). It is only +supported in C++. + +By default, a reference is considered to refer to its referenced object, a +pointer is considered to refer to its pointee, a ``std::initializer_list<T>`` +is considered to refer to its underlying array, and aggregates (arrays and +simple ``struct``\s) are considered to refer to all objects that their +transitive subobjects refer to. + +Clang warns if it is able to detect that an object or reference refers to +another object with a shorter lifetime. For example, Clang will warn if a +function returns a reference to a local variable, or if a reference is bound to +a temporary object whose lifetime is not extended. By using the +``lifetimebound`` attribute, this determination can be extended to look through +user-declared functions. For example: + +.. code-block:: c++ + + // Returns m[key] if key is present, or default_value if not. + template<typename T, typename U> + const U &get_or_default(const std::map<T, U> &m [[clang::lifetimebound]], + const T &key, /* note, not lifetimebound */ + const U &default_value [[clang::lifetimebound]]); + + std::map<std::string, std::string> m; + // warning: temporary "bar"s that might be bound to local reference 'val' + // will be destroyed at the end of the full-expression + const std::string &val = get_or_default(m, "foo"s, "bar"s); + + // No warning in this case. + std::string def_val = "bar"s; + const std::string &val = get_or_default(m, "foo"s, def_val); + +The attribute can be applied to the implicit ``this`` parameter of a member +function by writing the attribute after the function type: + +.. code-block:: c++ -This attribute provides an experimental implementation of the facility -described in the C++ committee paper `P0936R0 <http://wg21.link/p0936r0>`_, -and is subject to change as the design of the corresponding functionality -changes. + struct string { + // The returned pointer should not outlive ``*this``. + const char *data() const [[clang::lifetimebound]]; + }; + +This attribute is inspired by the C++ committee paper `P0936R0 +<http://wg21.link/p0936r0>`_, but does not affect whether temporary objects +have their lifetimes extended. }]; } @@ -3119,7 +3259,9 @@ def UnrollHintDocs : Documentation { let Content = [{ Loop unrolling optimization hints can be specified with ``#pragma unroll`` and ``#pragma nounroll``. The pragma is placed immediately before a for, while, -do-while, or c++11 range-based for loop. +do-while, or c++11 range-based for loop. GCC's loop unrolling hints +``#pragma GCC unroll`` and ``#pragma GCC nounroll`` are also supported and have +identical semantics to ``#pragma unroll`` and ``#pragma nounroll``. Specifying ``#pragma unroll`` without a parameter directs the loop unroller to attempt to fully unroll the loop if the trip count is known at compile time and @@ -3586,6 +3728,16 @@ system) and does not imply undefined behavior, making it more widely applicable. }]; } +def RestrictDocs : Documentation { + let Category = DocCatFunction; + let Heading = "malloc"; + let Content = [{ +The ``malloc`` attribute indicates that the function acts like a system memory +allocation function, returning a pointer to allocated storage disjoint from the +storage for any other object accessible to the caller. + }]; +} + def ReturnsNonNullDocs : Documentation { let Category = NullabilityDocs; let Content = [{ @@ -4057,9 +4209,8 @@ def NotTailCalledDocs : Documentation { let Category = DocCatFunction; let Content = [{ The ``not_tail_called`` attribute prevents tail-call optimization on statically -bound calls. It has no effect on indirect calls. Virtual functions, objective-c -methods, and functions marked as ``always_inline`` cannot be marked as -``not_tail_called``. +bound calls. Objective-c methods, and functions marked as ``always_inline`` +cannot be marked as ``not_tail_called``. For example, it prevents tail-call optimization in the following case: @@ -4085,28 +4236,25 @@ However, it doesn't prevent tail-call optimization in this case: return (*fn)(a); } -Marking virtual functions as ``not_tail_called`` is an error: +Generally, marking an overriding virtual function as ``not_tail_called`` is +not useful, because this attribute is a property of the static type. Calls +made through a pointer or reference to the base class type will respect +the ``not_tail_called`` attribute of the base class's member function, +regardless of the runtime destination of the call: .. code-block:: c++ - class Base { - public: - // not_tail_called on a virtual function is an error. - [[clang::not_tail_called]] virtual int foo1(); - - virtual int foo2(); - - // Non-virtual functions can be marked ``not_tail_called``. - [[clang::not_tail_called]] int foo3(); - }; - - class Derived1 : public Base { - public: - int foo1() override; - - // not_tail_called on a virtual function is an error. - [[clang::not_tail_called]] int foo2() override; + struct Foo { virtual void f(); }; + struct Bar : Foo { + [[clang::not_tail_called]] void f() override; }; + void callera(Bar& bar) { + Foo& foo = bar; + // not_tail_called has no effect on here, even though the + // underlying method is f from Bar. + foo.f(); + bar.f(); // No tail-call optimization on here. + } }]; } @@ -4379,7 +4527,8 @@ def SwiftContextDocs : Documentation { let Category = DocCatVariable; let Content = [{ The ``swift_context`` attribute marks a parameter of a ``swiftcall`` -function as having the special context-parameter ABI treatment. +or ``swiftasynccall`` function as having the special context-parameter +ABI treatment. This treatment generally passes the context value in a special register which is normally callee-preserved. @@ -4392,6 +4541,47 @@ A context parameter must have pointer or reference type. }]; } +def SwiftAsyncCallDocs : Documentation { + let Category = DocCatVariable; + let Content = [{ +The ``swiftasynccall`` attribute indicates that a function is +compatible with the low-level conventions of Swift async functions, +provided it declares the right formal arguments. + +In most respects, this is similar to the ``swiftcall`` attribute, except for +the following: + +- A parameter may be marked ``swift_async_context``, ``swift_context`` + or ``swift_indirect_result`` (with the same restrictions on parameter + ordering as ``swiftcall``) but the parameter attribute + ``swift_error_result`` is not permitted. + +- A ``swiftasynccall`` function must have return type ``void``. + +- Within a ``swiftasynccall`` function, a call to a ``swiftasynccall`` + function that is the immediate operand of a ``return`` statement is + guaranteed to be performed as a tail call. This syntax is allowed even + in C as an extension (a call to a void-returning function cannot be a + return operand in standard C). If something in the calling function would + semantically be performed after a guaranteed tail call, such as the + non-trivial destruction of a local variable or temporary, + then the program is ill-formed. + }]; +} + +def SwiftAsyncContextDocs : Documentation { + let Category = DocCatVariable; + let Content = [{ +The ``swift_async_context`` attribute marks a parameter of a ``swiftasynccall`` +function as having the special asynchronous context-parameter ABI treatment. + +If the function is not ``swiftasynccall``, this attribute only generates +extended frame information. + +A context parameter must have pointer or reference type. + }]; +} + def SwiftErrorResultDocs : Documentation { let Category = DocCatVariable; let Content = [{ @@ -4431,7 +4621,8 @@ def SwiftIndirectResultDocs : Documentation { let Category = DocCatVariable; let Content = [{ The ``swift_indirect_result`` attribute marks a parameter of a ``swiftcall`` -function as having the special indirect-result ABI treatment. +or ``swiftasynccall`` function as having the special indirect-result ABI +treatment. This treatment gives the parameter the target's normal indirect-result ABI treatment, which may involve passing it differently from an ordinary @@ -4486,6 +4677,47 @@ argument is the index of the completion handler parameter. }]; } +def SwiftAsyncErrorDocs : Documentation { + let Category = SwiftDocs; + let Heading = "swift_async_error"; + let Content = [{ +The ``swift_async_error`` attribute specifies how an error state will be +represented in a swift async method. It's a bit analogous to the ``swift_error`` +attribute for the generated async method. The ``swift_async_error`` attribute +can indicate a variety of different ways of representing an error. + +- ``__attribute__((swift_async_error(zero_argument, N)))``, specifies that the + async method is considered to have failed if the Nth argument to the + completion handler is zero. + +- ``__attribute__((swift_async_error(nonzero_argument, N)))``, specifies that + the async method is considered to have failed if the Nth argument to the + completion handler is non-zero. + +- ``__attribute__((swift_async_error(nonnull_error)))``, specifies that the + async method is considered to have failed if the ``NSError *`` argument to the + completion handler is non-null. + +- ``__attribute__((swift_async_error(none)))``, specifies that the async method + cannot fail. + + +For instance: + +.. code-block:: objc + + @interface MyClass : NSObject + -(void)asyncMethod:(void (^)(char, int, float))handler + __attribute__((swift_async(swift_private, 1))) + __attribute__((swift_async_error(zero_argument, 2))); + @end + +Here, the ``swift_async`` attribute specifies that ``handler`` is the completion +handler for this method, and the ``swift_async_error`` attribute specifies that +the ``int`` parameter is the one that represents the error. +}]; +} + def SuppressDocs : Documentation { let Category = DocCatStmt; let Content = [{ @@ -4526,6 +4758,26 @@ the old mangled name and the new code will use the new mangled name with tags. }]; } +def BuiltinAliasDocs : Documentation { + let Category = DocCatFunction; + let Heading = "clang::builtin_alias, clang_builtin_alias"; + let Content = [{ +This attribute is used in the implementation of the C intrinsics. +It allows the C intrinsic functions to be declared using the names defined +in target builtins, and still be recognized as clang builtins equivalent to the +underlying name. For example, ``riscv_vector.h`` declares the function ``vadd`` +with ``__attribute__((clang_builtin_alias(__builtin_rvv_vadd_vv_i8m1)))``. +This ensures that both functions are recognized as that clang builtin, +and in the latter case, the choice of which builtin to identify the +function as can be deferred until after overload resolution. + +This attribute can only be used to set up the aliases for certain ARM/RISC-V +C intrinsic functions; it is intended for use only inside ``arm_*.h`` and +``riscv_*.h`` and is not a general mechanism for declaring arbitrary aliases +for clang builtin functions. + }]; +} + def PreferredNameDocs : Documentation { let Category = DocCatDecl; let Content = [{ @@ -4714,6 +4966,9 @@ def PatchableFunctionEntryDocs : Documentation { before the function entry and N-M NOPs after the function entry. This attribute takes precedence over the command line option ``-fpatchable-function-entry=N,M``. ``M`` defaults to 0 if omitted. + +This attribute is only supported on +aarch64/aarch64-be/riscv32/riscv64/i386/x86-64 targets. }]; } @@ -5517,6 +5772,10 @@ This attribute can only be used to set up the aliases for certain Arm intrinsic functions; it is intended for use only inside ``arm_*.h`` and is not a general mechanism for declaring arbitrary aliases for clang builtin functions. + +In order to avoid duplicating the attribute definitions for similar +purpose for other architecture, there is a general form for the +attribute `clang_builtin_alias`. }]; } @@ -5557,6 +5816,31 @@ once. }]; } +def UsingIfExistsDocs : Documentation { + let Category = DocCatDecl; + let Content = [{ +The ``using_if_exists`` attribute applies to a using-declaration. It allows +programmers to import a declaration that potentially does not exist, instead +deferring any errors to the point of use. For instance: + +.. code-block:: c++ + + namespace empty_namespace {}; + __attribute__((using_if_exists)) + using empty_namespace::does_not_exist; // no error! + + does_not_exist x; // error: use of unresolved 'using_if_exists' + +The C++ spelling of the attribte (`[[clang::using_if_exists]]`) is also +supported as a clang extension, since ISO C++ doesn't support attributes in this +position. If the entity referred to by the using-declaration is found by name +lookup, the attribute has no effect. This attribute is useful for libraries +(primarily, libc++) that wish to redeclare a set of declarations in another +namespace, when the availability of those declarations is difficult or +impossible to detect at compile time with the preprocessor. + }]; +} + def HandleDocs : DocumentationCategory<"Handle Attributes"> { let Content = [{ Handles are a way to identify resources like files, sockets, and processes. diff --git a/clang/include/clang/Basic/AttributeCommonInfo.h b/clang/include/clang/Basic/AttributeCommonInfo.h index f4a5db84aa9f..4be598e109fd 100644 --- a/clang/include/clang/Basic/AttributeCommonInfo.h +++ b/clang/include/clang/Basic/AttributeCommonInfo.h @@ -155,6 +155,12 @@ public: bool isC2xAttribute() const { return SyntaxUsed == AS_C2x; } + /// The attribute is spelled [[]] in either C or C++ mode, including standard + /// attributes spelled with a keyword, like alignas. + bool isStandardAttributeSyntax() const { + return isCXX11Attribute() || isC2xAttribute(); + } + bool isKeywordAttribute() const { return SyntaxUsed == AS_Keyword || SyntaxUsed == AS_ContextSensitiveKeyword; } diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def index ab1b5866c8a7..0e3898537bcf 100644 --- a/clang/include/clang/Basic/Builtins.def +++ b/clang/include/clang/Basic/Builtins.def @@ -24,7 +24,8 @@ // c -> char // s -> short // i -> int -// h -> half +// h -> half (__fp16, OpenCL) +// x -> half (_Float16) // f -> float // d -> double // z -> size_t @@ -529,6 +530,7 @@ BUILTIN(__builtin_rotateright32, "UZiUZiUZi", "nc") BUILTIN(__builtin_rotateright64, "UWiUWiUWi", "nc") // Random GCC builtins +BUILTIN(__builtin_calloc, "v*zz", "nF") BUILTIN(__builtin_constant_p, "i.", "nctu") BUILTIN(__builtin_classify_type, "i.", "nctu") BUILTIN(__builtin___CFStringMakeConstantString, "FC*cC*", "nc") @@ -542,6 +544,8 @@ BUILTIN(__builtin_bcmp, "ivC*vC*z", "Fn") BUILTIN(__builtin_bcopy, "vv*v*z", "n") BUILTIN(__builtin_bzero, "vv*z", "nF") BUILTIN(__builtin_fprintf, "iP*cC*.", "Fp:1:") +BUILTIN(__builtin_free, "vv*", "nF") +BUILTIN(__builtin_malloc, "v*z", "nF") BUILTIN(__builtin_memchr, "v*vC*iz", "nF") BUILTIN(__builtin_memcmp, "ivC*vC*z", "nF") BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF") @@ -577,6 +581,7 @@ BUILTIN(__builtin_wmemchr, "w*wC*wz", "nF") BUILTIN(__builtin_wmemcmp, "iwC*wC*z", "nF") BUILTIN(__builtin_wmemcpy, "w*w*wC*z", "nF") BUILTIN(__builtin_wmemmove, "w*w*wC*z", "nF") +BUILTIN(__builtin_realloc, "v*v*z", "nF") BUILTIN(__builtin_return_address, "v*IUi", "n") BUILTIN(__builtin_extract_return_addr, "v*v*", "n") BUILTIN(__builtin_frame_address, "v*IUi", "n") @@ -586,8 +591,9 @@ BUILTIN(__builtin_longjmp, "vv**i", "r") BUILTIN(__builtin_unwind_init, "v", "") BUILTIN(__builtin_eh_return_data_regno, "iIi", "nc") BUILTIN(__builtin_snprintf, "ic*zcC*.", "nFp:2:") -BUILTIN(__builtin_vsprintf, "ic*cC*a", "nFP:1:") +BUILTIN(__builtin_sprintf, "ic*cC*.", "nFP:1:") BUILTIN(__builtin_vsnprintf, "ic*zcC*a", "nFP:2:") +BUILTIN(__builtin_vsprintf, "ic*cC*a", "nFP:1:") BUILTIN(__builtin_thread_pointer, "v*", "nc") BUILTIN(__builtin_launder, "v*v*", "nt") LANGBUILTIN(__builtin_is_constant_evaluated, "b", "n", CXX_LANG) @@ -975,6 +981,8 @@ LIBBUILTIN(strtol, "LicC*c**i", "f", "stdlib.h", ALL_LANGUAGES) LIBBUILTIN(strtoll, "LLicC*c**i", "f", "stdlib.h", ALL_LANGUAGES) LIBBUILTIN(strtoul, "ULicC*c**i", "f", "stdlib.h", ALL_LANGUAGES) LIBBUILTIN(strtoull, "ULLicC*c**i", "f", "stdlib.h", ALL_LANGUAGES) +// C11 stdlib.h +LIBBUILTIN(aligned_alloc, "v*zz", "f", "stdlib.h", ALL_LANGUAGES) // C99 string.h LIBBUILTIN(memcpy, "v*v*vC*z", "f", "string.h", ALL_LANGUAGES) LIBBUILTIN(memcmp, "ivC*vC*z", "f", "string.h", ALL_LANGUAGES) @@ -1056,6 +1064,8 @@ LIBBUILTIN(longjmp, "vJi", "frT", "setjmp.h", ALL_LANGUAGES) // all languages, because losing this attribute would result in miscompilation // when these functions are used in non-GNU mode. PR16138. LIBBUILTIN(alloca, "v*z", "f", "stdlib.h", ALL_GNU_LANGUAGES) +// POSIX malloc.h +LIBBUILTIN(memalign, "v*zz", "f", "malloc.h", ALL_GNU_LANGUAGES) // POSIX string.h LIBBUILTIN(memccpy, "v*v*vC*iz", "f", "string.h", ALL_GNU_LANGUAGES) LIBBUILTIN(mempcpy, "v*v*vC*z", "f", "string.h", ALL_GNU_LANGUAGES) @@ -1568,22 +1578,22 @@ BUILTIN(__builtin_nontemporal_store, "v.", "t") BUILTIN(__builtin_nontemporal_load, "v.", "t") // Coroutine intrinsics. -BUILTIN(__builtin_coro_resume, "vv*", "") -BUILTIN(__builtin_coro_destroy, "vv*", "") -BUILTIN(__builtin_coro_done, "bv*", "n") -BUILTIN(__builtin_coro_promise, "v*v*IiIb", "n") - -BUILTIN(__builtin_coro_size, "z", "n") -BUILTIN(__builtin_coro_frame, "v*", "n") -BUILTIN(__builtin_coro_noop, "v*", "n") -BUILTIN(__builtin_coro_free, "v*v*", "n") - -BUILTIN(__builtin_coro_id, "v*Iiv*v*v*", "n") -BUILTIN(__builtin_coro_alloc, "b", "n") -BUILTIN(__builtin_coro_begin, "v*v*", "n") -BUILTIN(__builtin_coro_end, "bv*Ib", "n") -BUILTIN(__builtin_coro_suspend, "cIb", "n") -BUILTIN(__builtin_coro_param, "bv*v*", "n") +LANGBUILTIN(__builtin_coro_resume, "vv*", "", COR_LANG) +LANGBUILTIN(__builtin_coro_destroy, "vv*", "", COR_LANG) +LANGBUILTIN(__builtin_coro_done, "bv*", "n", COR_LANG) +LANGBUILTIN(__builtin_coro_promise, "v*v*IiIb", "n", COR_LANG) + +LANGBUILTIN(__builtin_coro_size, "z", "n", COR_LANG) +LANGBUILTIN(__builtin_coro_frame, "v*", "n", COR_LANG) +LANGBUILTIN(__builtin_coro_noop, "v*", "n", COR_LANG) +LANGBUILTIN(__builtin_coro_free, "v*v*", "n", COR_LANG) + +LANGBUILTIN(__builtin_coro_id, "v*Iiv*v*v*", "n", COR_LANG) +LANGBUILTIN(__builtin_coro_alloc, "b", "n", COR_LANG) +LANGBUILTIN(__builtin_coro_begin, "v*v*", "n", COR_LANG) +LANGBUILTIN(__builtin_coro_end, "bv*Ib", "n", COR_LANG) +LANGBUILTIN(__builtin_coro_suspend, "cIb", "n", COR_LANG) +LANGBUILTIN(__builtin_coro_param, "bv*v*", "n", COR_LANG) // OpenCL v2.0 s6.13.16, s9.17.3.5 - Pipe functions. // We need the generic prototype, since the packet type could be anything. @@ -1636,8 +1646,8 @@ LANGBUILTIN(__builtin_load_halff, "fhC*", "nc", ALL_OCLC_LANGUAGES) BUILTIN(__builtin_os_log_format_buffer_size, "zcC*.", "p:0:nut") BUILTIN(__builtin_os_log_format, "v*v*cC*.", "p:0:nt") -// OpenMP 4.0 -LANGBUILTIN(omp_is_initial_device, "i", "nc", OMP_LANG) +// CUDA/HIP +LANGBUILTIN(__builtin_get_device_side_mangled_name, "cC*.", "ncT", CUDA_LANG) // Builtins for XRay BUILTIN(__xray_customevent, "vcC*z", "") @@ -1648,6 +1658,9 @@ BUILTIN(__builtin_ms_va_start, "vc*&.", "nt") BUILTIN(__builtin_ms_va_end, "vc*&", "n") BUILTIN(__builtin_ms_va_copy, "vc*&c*&", "n") +// Arithmetic Fence: to prevent FP reordering and reassociation optimizations +LANGBUILTIN(__arithmetic_fence, "v.", "t", ALL_LANGUAGES) + #undef BUILTIN #undef LIBBUILTIN #undef LANGBUILTIN diff --git a/clang/include/clang/Basic/Builtins.h b/clang/include/clang/Basic/Builtins.h index 15bfcf797917..cdaaee48c32d 100644 --- a/clang/include/clang/Basic/Builtins.h +++ b/clang/include/clang/Basic/Builtins.h @@ -36,6 +36,8 @@ enum LanguageID { OCLC20_LANG = 0x20, // builtin for OpenCL C 2.0 only. OCLC1X_LANG = 0x40, // builtin for OpenCL C 1.x only. OMP_LANG = 0x80, // builtin requires OpenMP. + CUDA_LANG = 0x100, // builtin requires CUDA. + COR_LANG = 0x200, // builtin requires use of 'fcoroutine-ts' option. ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all languages. ALL_GNU_LANGUAGES = ALL_LANGUAGES | GNU_LANG, // builtin requires GNU mode. ALL_MS_LANGUAGES = ALL_LANGUAGES | MS_LANG, // builtin requires MS mode. @@ -178,10 +180,6 @@ public: strchr(getRecord(ID).Type, 'A') != nullptr; } - /// Completely forget that the given ID was ever considered a builtin, - /// e.g., because the user provided a conflicting signature. - void forgetBuiltin(unsigned ID, IdentifierTable &Table); - /// If this is a library function that comes from a specific /// header, retrieve that header name. const char *getHeaderName(unsigned ID) const { diff --git a/clang/include/clang/Basic/BuiltinsAArch64.def b/clang/include/clang/Basic/BuiltinsAArch64.def index b35510f8b691..1dac5d2371d4 100644 --- a/clang/include/clang/Basic/BuiltinsAArch64.def +++ b/clang/include/clang/Basic/BuiltinsAArch64.def @@ -99,6 +99,20 @@ BUILTIN(__builtin_arm_tcommit, "v", "n") BUILTIN(__builtin_arm_tcancel, "vWUIi", "n") BUILTIN(__builtin_arm_ttest, "WUi", "nc") +// Armv8.5-A FP rounding intrinsics +BUILTIN(__builtin_arm_frint32zf, "ff", "") +BUILTIN(__builtin_arm_frint32z, "dd", "") +BUILTIN(__builtin_arm_frint64zf, "ff", "") +BUILTIN(__builtin_arm_frint64z, "dd", "") +BUILTIN(__builtin_arm_frint32xf, "ff", "") +BUILTIN(__builtin_arm_frint32x, "dd", "") +BUILTIN(__builtin_arm_frint64xf, "ff", "") +BUILTIN(__builtin_arm_frint64x, "dd", "") + +// Armv8.5-A Random number generation intrinsics +BUILTIN(__builtin_arm_rndr, "iWUi*", "n") +BUILTIN(__builtin_arm_rndrrs, "iWUi*", "n") + // Armv8.7-A load/store 64-byte intrinsics BUILTIN(__builtin_arm_ld64b, "vvC*WUi*", "n") BUILTIN(__builtin_arm_st64b, "vv*WUiC*", "n") diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index 123a7ad212da..3570431d952c 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -9,6 +9,11 @@ // This file defines the AMDGPU-specific builtin function database. Users of // this file must define the BUILTIN macro to make use of this information. // +// Note: (unsigned) long int type should be avoided in builtin definitions +// since it has different size on Linux (64 bit) and Windows (32 bit). +// (unsigned) long long int type should also be avoided, which is 64 bit for +// C/C++/HIP but is 128 bit for OpenCL. Use `W` as width modifier in builtin +// definitions since it is fixed for 64 bit. //===----------------------------------------------------------------------===// // The format of this database matches clang/Basic/Builtins.def. @@ -44,12 +49,14 @@ BUILTIN(__builtin_amdgcn_grid_size_z, "Ui", "nc") BUILTIN(__builtin_amdgcn_mbcnt_hi, "UiUiUi", "nc") BUILTIN(__builtin_amdgcn_mbcnt_lo, "UiUiUi", "nc") +TARGET_BUILTIN(__builtin_amdgcn_s_memtime, "WUi", "n", "s-memtime-inst") + //===----------------------------------------------------------------------===// // Instruction builtins. //===----------------------------------------------------------------------===// BUILTIN(__builtin_amdgcn_s_getreg, "UiIi", "n") BUILTIN(__builtin_amdgcn_s_setreg, "vIiUi", "n") -BUILTIN(__builtin_amdgcn_s_getpc, "LUi", "n") +BUILTIN(__builtin_amdgcn_s_getpc, "WUi", "n") BUILTIN(__builtin_amdgcn_s_waitcnt, "vIi", "n") BUILTIN(__builtin_amdgcn_s_sendmsg, "vIiUi", "n") BUILTIN(__builtin_amdgcn_s_sendmsghalt, "vIiUi", "n") @@ -63,6 +70,7 @@ BUILTIN(__builtin_amdgcn_ds_gws_sema_v, "vUi", "n") BUILTIN(__builtin_amdgcn_ds_gws_sema_br, "vUiUi", "n") BUILTIN(__builtin_amdgcn_ds_gws_sema_p, "vUi", "n") BUILTIN(__builtin_amdgcn_fence, "vUicC*", "n") +BUILTIN(__builtin_amdgcn_groupstaticsize, "Ui", "n") BUILTIN(__builtin_amdgcn_atomic_inc32, "UZiUZiD*UZiUicC*", "n") BUILTIN(__builtin_amdgcn_atomic_inc64, "UWiUWiD*UWiUicC*", "n") @@ -105,16 +113,15 @@ BUILTIN(__builtin_amdgcn_cubeid, "ffff", "nc") BUILTIN(__builtin_amdgcn_cubesc, "ffff", "nc") BUILTIN(__builtin_amdgcn_cubetc, "ffff", "nc") BUILTIN(__builtin_amdgcn_cubema, "ffff", "nc") -BUILTIN(__builtin_amdgcn_s_memtime, "LUi", "n") BUILTIN(__builtin_amdgcn_s_sleep, "vIi", "n") BUILTIN(__builtin_amdgcn_s_incperflevel, "vIi", "n") BUILTIN(__builtin_amdgcn_s_decperflevel, "vIi", "n") -BUILTIN(__builtin_amdgcn_uicmp, "LUiUiUiIi", "nc") -BUILTIN(__builtin_amdgcn_uicmpl, "LUiLUiLUiIi", "nc") -BUILTIN(__builtin_amdgcn_sicmp, "LUiiiIi", "nc") -BUILTIN(__builtin_amdgcn_sicmpl, "LUiLiLiIi", "nc") -BUILTIN(__builtin_amdgcn_fcmp, "LUiddIi", "nc") -BUILTIN(__builtin_amdgcn_fcmpf, "LUiffIi", "nc") +BUILTIN(__builtin_amdgcn_uicmp, "WUiUiUiIi", "nc") +BUILTIN(__builtin_amdgcn_uicmpl, "WUiWUiWUiIi", "nc") +BUILTIN(__builtin_amdgcn_sicmp, "WUiiiIi", "nc") +BUILTIN(__builtin_amdgcn_sicmpl, "WUiWiWiIi", "nc") +BUILTIN(__builtin_amdgcn_fcmp, "WUiddIi", "nc") +BUILTIN(__builtin_amdgcn_fcmpf, "WUiffIi", "nc") BUILTIN(__builtin_amdgcn_ds_swizzle, "iiIi", "nc") BUILTIN(__builtin_amdgcn_ds_permute, "iii", "nc") BUILTIN(__builtin_amdgcn_ds_bpermute, "iii", "nc") @@ -140,9 +147,9 @@ BUILTIN(__builtin_amdgcn_sad_u8, "UiUiUiUi", "nc") BUILTIN(__builtin_amdgcn_msad_u8, "UiUiUiUi", "nc") BUILTIN(__builtin_amdgcn_sad_hi_u8, "UiUiUiUi", "nc") BUILTIN(__builtin_amdgcn_sad_u16, "UiUiUiUi", "nc") -BUILTIN(__builtin_amdgcn_qsad_pk_u16_u8, "LUiLUiUiLUi", "nc") -BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "LUiLUiUiLUi", "nc") -BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiLUiUiV4Ui", "nc") +BUILTIN(__builtin_amdgcn_qsad_pk_u16_u8, "WUiWUiUiWUi", "nc") +BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", "nc") +BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc") //===----------------------------------------------------------------------===// // CI+ only builtins. @@ -177,10 +184,11 @@ TARGET_BUILTIN(__builtin_amdgcn_frexp_manth, "hh", "nc", "16-bit-insts") TARGET_BUILTIN(__builtin_amdgcn_frexp_exph, "sh", "nc", "16-bit-insts") TARGET_BUILTIN(__builtin_amdgcn_fracth, "hh", "nc", "16-bit-insts") TARGET_BUILTIN(__builtin_amdgcn_classh, "bhi", "nc", "16-bit-insts") -TARGET_BUILTIN(__builtin_amdgcn_s_memrealtime, "LUi", "n", "s-memrealtime") +TARGET_BUILTIN(__builtin_amdgcn_s_memrealtime, "WUi", "n", "s-memrealtime") TARGET_BUILTIN(__builtin_amdgcn_mov_dpp, "iiIiIiIiIb", "nc", "dpp") TARGET_BUILTIN(__builtin_amdgcn_update_dpp, "iiiIiIiIiIb", "nc", "dpp") TARGET_BUILTIN(__builtin_amdgcn_s_dcache_wb, "v", "n", "gfx8-insts") +TARGET_BUILTIN(__builtin_amdgcn_perm, "UiUiUiUi", "nc", "gfx8-insts") //===----------------------------------------------------------------------===// // GFX9+ only builtins. @@ -192,13 +200,13 @@ TARGET_BUILTIN(__builtin_amdgcn_fmed3h, "hhhh", "nc", "gfx9-insts") // Deep learning builtins. //===----------------------------------------------------------------------===// -TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hfIb", "nc", "dot2-insts") +TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hfIb", "nc", "dot7-insts") TARGET_BUILTIN(__builtin_amdgcn_sdot2, "SiV2SsV2SsSiIb", "nc", "dot2-insts") TARGET_BUILTIN(__builtin_amdgcn_udot2, "UiV2UsV2UsUiIb", "nc", "dot2-insts") TARGET_BUILTIN(__builtin_amdgcn_sdot4, "SiSiSiSiIb", "nc", "dot1-insts") -TARGET_BUILTIN(__builtin_amdgcn_udot4, "UiUiUiUiIb", "nc", "dot2-insts") +TARGET_BUILTIN(__builtin_amdgcn_udot4, "UiUiUiUiIb", "nc", "dot7-insts") TARGET_BUILTIN(__builtin_amdgcn_sdot8, "SiSiSiSiIb", "nc", "dot1-insts") -TARGET_BUILTIN(__builtin_amdgcn_udot8, "UiUiUiUiIb", "nc", "dot2-insts") +TARGET_BUILTIN(__builtin_amdgcn_udot8, "UiUiUiUiIb", "nc", "dot7-insts") //===----------------------------------------------------------------------===// // GFX10+ only builtins. @@ -208,9 +216,20 @@ TARGET_BUILTIN(__builtin_amdgcn_permlanex16, "UiUiUiUiUiIbIb", "nc", "gfx10-inst TARGET_BUILTIN(__builtin_amdgcn_mov_dpp8, "UiUiIUi", "nc", "gfx10-insts") //===----------------------------------------------------------------------===// +// Raytracing builtins. +// By default the 1st argument is i32 and the 4/5-th arguments are float4. +// Postfix l indicates the 1st argument is i64. +// Postfix h indicates the 4/5-th arguments are half4. +//===----------------------------------------------------------------------===// +TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray, "V4UiUifV4fV4fV4fV4Ui", "nc", "gfx10-insts") +TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_h, "V4UiUifV4fV4hV4hV4Ui", "nc", "gfx10-insts") +TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_l, "V4UiWUifV4fV4fV4fV4Ui", "nc", "gfx10-insts") +TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_lh, "V4UiWUifV4fV4hV4hV4Ui", "nc", "gfx10-insts") + +//===----------------------------------------------------------------------===// // Special builtins. //===----------------------------------------------------------------------===// -BUILTIN(__builtin_amdgcn_read_exec, "LUi", "nc") +BUILTIN(__builtin_amdgcn_read_exec, "WUi", "nc") BUILTIN(__builtin_amdgcn_read_exec_lo, "Ui", "nc") BUILTIN(__builtin_amdgcn_read_exec_hi, "Ui", "nc") @@ -258,5 +277,13 @@ TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_4x4x2bf16, "V4fV2sV2sV4fIiIiIi", "nc", TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x4bf16, "V16fV2sV2sV16fIiIiIi", "nc", "mai-insts") TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x8bf16, "V4fV2sV2sV4fIiIiIi", "nc", "mai-insts") +TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x4bf16_1k, "V32fV4sV4sV32fIiIiIi", "nc", "mai-insts") +TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x4bf16_1k, "V16fV4sV4sV16fIiIiIi", "nc", "mai-insts") +TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_4x4x4bf16_1k, "V4fV4sV4sV4fIiIiIi", "nc", "mai-insts") +TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x8bf16_1k, "V16fV4sV4sV16fIiIiIi", "nc", "mai-insts") +TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x16bf16_1k, "V4fV4sV4sV4fIiIiIi", "nc", "mai-insts") +TARGET_BUILTIN(__builtin_amdgcn_mfma_f64_16x16x4f64, "V4dddV4dIiIiIi", "nc", "mai-insts") +TARGET_BUILTIN(__builtin_amdgcn_mfma_f64_4x4x4f64, "ddddIiIiIi", "nc", "mai-insts") + #undef BUILTIN #undef TARGET_BUILTIN diff --git a/clang/include/clang/Basic/BuiltinsHexagon.def b/clang/include/clang/Basic/BuiltinsHexagon.def index 28aa222166f5..0001bd556117 100644 --- a/clang/include/clang/Basic/BuiltinsHexagon.def +++ b/clang/include/clang/Basic/BuiltinsHexagon.def @@ -17,8 +17,10 @@ # define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS) #endif +#pragma push_macro("V68") +#define V68 "v68" #pragma push_macro("V67") -#define V67 "v67" +#define V67 "v67|" V68 #pragma push_macro("V66") #define V66 "v66|" V67 #pragma push_macro("V65") @@ -32,8 +34,10 @@ #pragma push_macro("V5") #define V5 "v5|" V55 +#pragma push_macro("HVXV68") +#define HVXV68 "hvxv68" #pragma push_macro("HVXV67") -#define HVXV67 "hvxv67" +#define HVXV67 "hvxv67|" HVXV68 #pragma push_macro("HVXV66") #define HVXV66 "hvxv66|" HVXV67 #pragma push_macro("HVXV65") @@ -123,6 +127,7 @@ TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_rtt_acc_128B,"V64iV64iV32iLLi","", " #pragma pop_macro("HVXV65") #pragma pop_macro("HVXV66") #pragma pop_macro("HVXV67") +#pragma pop_macro("HVXV68") #pragma pop_macro("V5") #pragma pop_macro("V55") @@ -131,6 +136,7 @@ TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_rtt_acc_128B,"V64iV64iV32iLLi","", " #pragma pop_macro("V65") #pragma pop_macro("V66") #pragma pop_macro("V67") +#pragma pop_macro("V68") #undef BUILTIN #undef TARGET_BUILTIN diff --git a/clang/include/clang/Basic/BuiltinsHexagonDep.def b/clang/include/clang/Basic/BuiltinsHexagonDep.def index b694e4c35d3b..152c9c4dd8ad 100644 --- a/clang/include/clang/Basic/BuiltinsHexagonDep.def +++ b/clang/include/clang/Basic/BuiltinsHexagonDep.def @@ -11,96 +11,389 @@ // V5 Scalar Instructions. -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpeq, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgt, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgtu, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpeqp, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgtp, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgtup, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_rcmpeqi, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_rcmpneqi, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_rcmpeq, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_rcmpneq, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_bitsset, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_bitsclr, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_nbitsset, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_nbitsclr, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpeqi, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgti, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgtui, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgei, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgeui, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmplt, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpltu, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_bitsclri, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_nbitsclri, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_cmpneqi, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_cmpltei, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_cmplteui, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_cmpneq, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_cmplte, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_cmplteu, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_and, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_or, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_xor, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_andn, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_not, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_orn, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_and_and, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_and_or, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_or_and, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_or_or, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_and_andn, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_and_orn, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_or_andn, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_or_orn, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_pxfer_map, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_any8, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_all8, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_vitpack, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_mux, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_muxii, "iiIiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_muxir, "iiiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_muxri, "iiIii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_vmux, "LLiiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_mask, "LLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_abs, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_absp, "LLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_abssat, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_add, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_hh, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_hl, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_lh, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_ll, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_sat_hh, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_sat_hl, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_sat_lh, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_sat_ll, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_l16_hl, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_l16_ll, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_l16_sat_hl, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_l16_sat_ll, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_addi, "iiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_addp, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_addpsat, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_addsat, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_addsp, "LLiiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_and, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_andir, "iiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_andp, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_aslh, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_asrh, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_combine_hh, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_combine_hl, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_combine_lh, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_combine_ll, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_combineii, "LLiIiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_combinew, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_max, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_maxp, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_maxu, "Uiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_maxup, "ULLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_min, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_minp, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_minu, "Uiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_minup, "ULLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_neg, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_negp, "LLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_negsat, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_not, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_notp, "LLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_or, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_orir, "iiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_orp, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_roundsat, "iLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_sat, "iLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_satb, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_sath, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_satub, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_satuh, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_sub, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_hh, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_hl, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_lh, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_ll, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_sat_hh, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_sat_hl, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_sat_lh, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_sat_ll, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_l16_hl, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_l16_ll, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_l16_sat_hl, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_l16_sat_ll, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_subp, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_subri, "iIii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_subsat, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_svaddh, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_svaddhs, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_svadduhs, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_svavgh, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_svavghs, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_svnavgh, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_svsubh, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_svsubhs, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_svsubuhs, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_swiz, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_sxtb, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_sxth, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_sxtw, "LLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_tfr, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_tfrih, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_tfril, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_tfrp, "LLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_tfrpi, "LLiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_tfrsi, "iIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vabsh, "LLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vabshsat, "LLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vabsw, "LLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vabswsat, "LLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddb_map, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddh, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddhs, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddub, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddubs, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vadduhs, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddw, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddws, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgh, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vavghcr, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vavghr, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgub, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgubr, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vavguh, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vavguhr, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vavguw, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vavguwr, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgw, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgwcr, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgwr, "LLiLLiLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmpbeq, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpbeqi, "iLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpbeq_any, "iLLiLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmpbgtu, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpbgtui, "iLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpbgt, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpbgti, "iLLiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmpheq, "iLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmphgt, "iLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmphgtu, "iLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmpweq, "iLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmpwgt, "iLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmpwgtu, "iLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vconj, "LLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxb, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxh, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxub, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxuh, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxuw, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxw, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vminb, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vminh, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vminub, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vminuh, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vminuw, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vminw, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavgh, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavghcr, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavghr, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavgw, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavgwcr, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavgwr, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vraddub, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vraddub_acc, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vrsadub, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vrsadub_acc, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubb_map, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubh, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubhs, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubub, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vsububs, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubuhs, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubw, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubws, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_xor, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_xorp, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_zxtb, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A2_zxth, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_andn, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_andnp, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_bitsplit, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_bitspliti, "LLiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_boundscheck, "iiLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpbeq, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpbeqi, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpbgtu, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpbgtui, "iiUIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpbgt, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpbgti, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmpheq, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmphgt, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmphgtu, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpheqi, "iLLiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmphgti, "iLLiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmphgtui, "iLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpbgtu, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpbgtui, "iiUIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpheq, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cmphgt, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cmphgtu, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpheqi, "iiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_cmphgt, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_A4_cmphgti, "iiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_cmphgtu, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_A4_cmphgtui, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmpweq, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmpwgt, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmpwgtu, "iLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_combineir, "LLiIii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_combineri, "LLiiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_cround_ri, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_cround_rr, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_modwrapu, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_orn, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_ornp, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_rcmpeq, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_rcmpeqi, "iiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_rcmpneq, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_rcmpneqi, "iiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_round_ri, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_round_ri_sat, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_round_rr, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_round_rr_sat, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_tlbmatch, "iLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpbeq_any, "iLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpbeqi, "iLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpbgt, "iLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpbgti, "iLLiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpbgtui, "iLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpheqi, "iLLiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmphgti, "iLLiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmphgtui, "iLLiUIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpweqi, "iLLiIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpwgti, "iLLiIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpwgtui, "iLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_boundscheck, "iiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_tlbmatch, "iLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_vrmaxh, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_vrmaxuh, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_vrmaxuw, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_vrmaxw, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_vrminh, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_vrminuh, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_vrminuw, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A4_vrminw, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_A5_vaddhubs, "iLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_all8, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_and, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_andn, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_any8, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_bitsclr, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_bitsclri, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_bitsset, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpeq, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpeqi, "iiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpeqp, "iLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgei, "iiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgeui, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgt, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgti, "iiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgtp, "iLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgtu, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgtui, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgtup, "iLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_cmplt, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpltu, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_mask, "LLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_mux, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_muxii, "iiIiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_muxir, "iiiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_muxri, "iiIii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_not, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_or, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_orn, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_pxfer_map, "ii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_C2_tfrpr, "ii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_C2_tfrrp, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_vitpack, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_vmux, "LLiiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C2_xor, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C4_and_and, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C4_and_andn, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C4_and_or, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C4_and_orn, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C4_cmplte, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C4_cmpltei, "iiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C4_cmplteu, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C4_cmplteui, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C4_cmpneq, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C4_cmpneqi, "iiIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_C4_fastcorner9, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_C4_fastcorner9_not, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C4_nbitsclr, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C4_nbitsclri, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C4_nbitsset, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C4_or_and, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C4_or_andn, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C4_or_or, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_C4_or_orn, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_d2df, "dLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_d2sf, "fLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2d, "LLid", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2d_chop, "LLid", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2sf, "fd", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2ud, "LLid", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2ud_chop, "LLid", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2uw, "id", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2uw_chop, "id", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2w, "id", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2w_chop, "id", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2d, "LLif", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2d_chop, "LLif", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2df, "df", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2ud, "LLif", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2ud_chop, "LLif", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2uw, "if", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2uw_chop, "if", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2w, "if", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2w_chop, "if", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_ud2df, "dLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_ud2sf, "fLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_uw2df, "di", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_uw2sf, "fi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_w2df, "di", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_w2sf, "fi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_dfclass, "idUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_dfcmpeq, "idd", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_dfcmpge, "idd", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_dfcmpgt, "idd", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_dfcmpuo, "idd", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_dfimm_n, "dUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_dfimm_p, "dUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sfadd, "fff", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sfclass, "ifUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sfcmpeq, "iff", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sfcmpge, "iff", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sfcmpgt, "iff", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sfcmpuo, "iff", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sffixupd, "fff", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sffixupn, "fff", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sffixupr, "ff", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sffma, "ffff", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sffma_lib, "ffff", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sffma_sc, "ffffi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sffms, "ffff", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sffms_lib, "ffff", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sfimm_n, "fUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sfimm_p, "fUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sfmax, "fff", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sfmin, "fff", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sfmpy, "fff", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_F2_sfsub, "fff", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_acci, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_accii, "iiiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cmaci_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cmacr_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cmacs_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cmacs_s1, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cmacsc_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cmacsc_s1, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyi_s0, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyr_s0, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyrs_s0, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyrs_s1, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyrsc_s0, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyrsc_s1, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpys_s0, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpys_s1, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpysc_s0, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpysc_s1, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cnacs_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cnacs_s1, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cnacsc_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_cnacsc_s1, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyss_acc_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyss_nac_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyss_rnd_s0, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyss_s0, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyuu_acc_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyuu_nac_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyuu_s0, "ULLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_hmmpyh_rs1, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_hmmpyh_s1, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_hmmpyl_rs1, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_hmmpyl_s1, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_maci, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_macsin, "iiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_macsip, "iiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmachs_rs0, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmachs_rs1, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmachs_s0, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmachs_s1, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacls_rs0, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacls_rs1, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacls_s0, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacls_s1, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacuhs_rs0, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacuhs_rs1, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacuhs_s0, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacuhs_s1, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmaculs_rs0, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmaculs_rs1, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmaculs_s0, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmaculs_s1, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyh_rs0, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyh_rs1, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyh_s0, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyh_s1, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyl_rs0, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyl_rs1, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyl_s0, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyl_s1, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyuh_rs0, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyuh_rs1, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyuh_s0, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyuh_s1, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyul_rs0, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyul_rs1, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyul_s0, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyul_s1, "LLiLLiLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_hh_s0, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_hh_s1, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_hl_s0, "iiii", "", V5) @@ -109,14 +402,6 @@ TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_lh_s0, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_lh_s1, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_ll_s0, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_ll_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_hh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_hh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_hl_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_hl_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_lh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_lh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_ll_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_ll_s1, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_sat_hh_s0, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_sat_hh_s1, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_sat_hl_s0, "iiii", "", V5) @@ -125,14 +410,6 @@ TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_sat_lh_s0, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_sat_lh_s1, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_sat_ll_s0, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_sat_ll_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_hh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_hh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_hl_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_hl_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_lh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_lh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_ll_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_ll_s1, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_hh_s0, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_hh_s1, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_hl_s0, "iii", "", V5) @@ -141,14 +418,22 @@ TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_lh_s0, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_lh_s1, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_ll_s0, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_ll_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_hh_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_hh_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_hl_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_hl_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_lh_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_lh_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_ll_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_ll_s1, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_hh_s0, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_hh_s1, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_hl_s0, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_hl_s1, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_lh_s0, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_lh_s1, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_ll_s0, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_ll_s1, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_hh_s0, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_hh_s1, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_hl_s0, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_hl_s1, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_lh_s0, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_lh_s1, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_ll_s0, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_ll_s1, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_rnd_hh_s0, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_rnd_hh_s1, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_rnd_hl_s0, "iii", "", V5) @@ -157,6 +442,14 @@ TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_rnd_lh_s0, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_rnd_lh_s1, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_rnd_ll_s0, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_rnd_ll_s1, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_hh_s0, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_hh_s1, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_hl_s0, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_hl_s1, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_lh_s0, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_lh_s1, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_ll_s0, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_ll_s1, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_rnd_hh_s0, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_rnd_hh_s1, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_rnd_hl_s0, "iii", "", V5) @@ -165,6 +458,9 @@ TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_rnd_lh_s0, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_rnd_lh_s1, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_rnd_ll_s0, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_rnd_ll_s1, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_up, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_up_s1, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_up_s1_sat, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_acc_hh_s0, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_acc_hh_s1, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_acc_hl_s0, "LLiLLiii", "", V5) @@ -173,14 +469,6 @@ TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_acc_lh_s0, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_acc_lh_s1, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_acc_ll_s0, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_acc_ll_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_hh_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_hh_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_hl_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_hl_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_lh_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_lh_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_ll_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_ll_s1, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_hh_s0, "LLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_hh_s1, "LLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_hl_s0, "LLiii", "", V5) @@ -189,6 +477,14 @@ TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_lh_s0, "LLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_lh_s1, "LLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_ll_s0, "LLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_ll_s1, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_hh_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_hh_s1, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_hl_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_hl_s1, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_lh_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_lh_s1, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_ll_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_ll_s1, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_rnd_hh_s0, "LLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_rnd_hh_s1, "LLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_rnd_hl_s0, "LLiii", "", V5) @@ -197,6 +493,9 @@ TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_rnd_lh_s0, "LLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_rnd_lh_s1, "LLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_rnd_ll_s0, "LLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_rnd_ll_s1, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyi, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpysmi, "iiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpysu_up, "iii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_acc_hh_s0, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_acc_hh_s1, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_acc_hl_s0, "iiii", "", V5) @@ -205,14 +504,6 @@ TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_acc_lh_s0, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_acc_lh_s1, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_acc_ll_s0, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_acc_ll_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_hh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_hh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_hl_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_hl_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_lh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_lh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_ll_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_ll_s1, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_hh_s0, "Uiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_hh_s1, "Uiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_hl_s0, "Uiii", "", V5) @@ -221,6 +512,15 @@ TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_lh_s0, "Uiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_lh_s1, "Uiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_ll_s0, "Uiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_ll_s1, "Uiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_hh_s0, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_hh_s1, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_hl_s0, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_hl_s1, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_lh_s0, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_lh_s1, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_ll_s0, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_ll_s1, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_up, "Uiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_acc_hh_s0, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_acc_hh_s1, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_acc_hl_s0, "LLiLLiii", "", V5) @@ -229,14 +529,6 @@ TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_acc_lh_s0, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_acc_lh_s1, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_acc_ll_s0, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_acc_ll_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_hh_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_hh_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_hl_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_hl_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_lh_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_lh_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_ll_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_ll_s1, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_hh_s0, "ULLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_hh_s1, "ULLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_hl_s0, "ULLiii", "", V5) @@ -245,632 +537,340 @@ TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_lh_s0, "ULLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_lh_s1, "ULLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_ll_s0, "ULLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_ll_s1, "ULLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpysmi, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_macsip, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_macsin, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyss_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyss_acc_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyss_nac_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyuu_s0, "ULLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyuu_acc_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyuu_nac_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_up, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_up_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_up_s1_sat, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_up, "Uiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpysu_up, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyss_rnd_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_mac_up_s1_sat, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_nac_up_s1_sat, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyi, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_hh_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_hh_s1, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_hl_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_hl_s1, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_lh_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_lh_s1, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_ll_s0, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_ll_s1, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyui, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_maci, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_acci, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_accii, "iiiIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_nacci, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_naccii, "iiiIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_subacc, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_mpyrr_addr, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_mpyri_addr_u2, "iiUIii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_mpyri_addr, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_mpyri_addi, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_mpyrr_addi, "iUIiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2s_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2s_s1, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vabsdiffh, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vabsdiffw, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmac_s0_sat_i, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmac_s0_sat_r, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmpy_s0_sat_i, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmpy_s0_sat_r, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmpy_s1_sat_i, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmpy_s1_sat_r, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmacs_s0, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmacs_s1, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmpyrs_s0, "iLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmpyrs_s1, "iLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmpys_s0, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmpys_s1, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2es, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2es_s0, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2es_s1, "LLiLLiLLiLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2s_s0, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2s_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2su_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2su_s1, "LLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2su_s0, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2su_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2s_s0pack, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2s_s1pack, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2es_s0, "LLiLLiLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2es_s1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2es_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2es_s1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2es, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrmac_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrmpy_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmpyrs_s0, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmpyrs_s1, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vrmpybuu, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vrmacbuu, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vrmpybsu, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vrmacbsu, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vmpybuu, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vmpybsu, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vmacbuu, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vmacbsu, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vdmpybsu, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vdmacbsu, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmacs_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmacs_s1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmpys_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmpys_s1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyrs_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyrs_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyrsc_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyrsc_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmacs_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmacs_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmacsc_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmacsc_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpys_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpys_s1, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpysc_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpysc_s1, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cnacs_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cnacs_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cnacsc_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cnacsc_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpys_s1, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpys_acc_s1, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpys_s1rp, "iLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacls_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacls_s1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmachs_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmachs_s1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyl_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyl_s1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyh_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyh_s1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacls_rs0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacls_rs1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmachs_rs0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmachs_rs1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyl_rs0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyl_rs1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyh_rs0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyh_rs1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyeh_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyeh_s1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyeh_acc_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyeh_acc_s1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyoh_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyoh_s1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyoh_acc_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyoh_acc_s1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_hmmpyl_rs1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_hmmpyh_rs1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_hmmpyl_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_hmmpyh_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmaculs_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmaculs_s1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacuhs_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacuhs_s1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyul_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyul_s1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyuh_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyuh_s1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmaculs_rs0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmaculs_rs1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacuhs_rs0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacuhs_rs1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyul_rs0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyul_rs1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyuh_rs0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyuh_rs1, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2s_s0, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2s_s0pack, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2s_s1, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2s_s1pack, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2su_s0, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2su_s1, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vraddh, "iLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vradduh, "iLLiLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmaci_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmacr_s0, "LLiLLiLLiLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmaci_s0c, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmacr_s0, "LLiLLiLLiLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmacr_s0c, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmaci_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmacr_s0, "LLiLLiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpyi_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpyr_s0, "LLiLLiLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpyi_s0c, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpyr_s0, "LLiLLiLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpyr_s0c, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyi_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyr_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_cmpyi_wh, "iLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_cmpyr_wh, "iLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_cmpyi_whc, "iLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_cmpyr_whc, "iLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmpy_s0_sat_i, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmpy_s0_sat_r, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmpy_s1_sat_i, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmpy_s1_sat_r, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmac_s0_sat_i, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmac_s0_sat_r, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vcrotate, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_vrcrotate_acc, "LLiLLiLLiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_vrcrotate, "LLiLLiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vcnegh, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vrcnegh, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_pmpyw, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vpmpyh, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_pmpyw_acc, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vpmpyh_acc, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_add, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_sub, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addsat, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subsat, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addi, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_l16_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_l16_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_l16_sat_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_l16_sat_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_l16_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_l16_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_l16_sat_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_l16_sat_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_lh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_hh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_sat_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_sat_lh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_sat_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_sat_hh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_lh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_hh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_sat_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_sat_lh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_sat_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_sat_hh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_aslh, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_asrh, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addpsat, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addsp, "LLiiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_neg, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_negsat, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_abs, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_abssat, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vconj, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_negp, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_absp, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_max, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_maxu, "Uiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_min, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_minu, "Uiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_maxp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_maxup, "ULLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_minp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_minup, "ULLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_tfr, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_tfrsi, "iIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_tfrp, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_tfrpi, "LLiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_zxtb, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_sxtb, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_zxth, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_sxth, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_combinew, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_combineri, "LLiiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_combineir, "LLiIii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_combineii, "LLiIiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_combine_hh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_combine_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_combine_lh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_combine_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_tfril, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_tfrih, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_and, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_or, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_xor, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_not, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpys_acc_s1, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpys_s1, "LLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpys_s1rp, "iLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vrmac_s0, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M2_vrmpy_s0, "LLiLLiLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M2_xor_xacc, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_xor_xacc, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_andn, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_orn, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_andnp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_ornp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_addaddi, "iiiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_subaddi, "iiIii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M4_and_and, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M4_and_andn, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M4_and_or, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M4_and_xor, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_cmpyi_wh, "iLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_cmpyi_whc, "iLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_cmpyr_wh, "iLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_cmpyr_whc, "iLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_mac_up_s1_sat, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_mpyri_addi, "iUIiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_mpyri_addr, "iiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_mpyri_addr_u2, "iiUIii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_mpyrr_addi, "iUIiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_mpyrr_addr, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_nac_up_s1_sat, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M4_or_and, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M4_or_andn, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M4_or_or, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M4_or_xor, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_or_andix, "iiiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_or_andi, "iiiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_or_ori, "iiiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_pmpyw, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_pmpyw_acc, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_vpmpyh, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_vpmpyh_acc, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyeh_acc_s0, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyeh_acc_s1, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyeh_s0, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyeh_s1, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyoh_acc_s0, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyoh_acc_s1, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyoh_s0, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyoh_s1, "LLiLLiLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M4_xor_and, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_xor_or, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_M4_xor_andn, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subri, "iIii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_andir, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_orir, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_andp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_orp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_xorp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_notp, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_sxtw, "LLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_sat, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_roundsat, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_sath, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_satuh, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_satub, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_satb, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddub, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddb_map, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddubs, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddhs, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vadduhs, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A5_vaddhubs, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddws, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_vxaddsubw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_vxsubaddw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_vxaddsubh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_vxsubaddh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_vxaddsubhr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_vxsubaddhr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svavgh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svavghs, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svnavgh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svaddh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svaddhs, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svadduhs, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svsubh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svsubhs, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svsubuhs, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vraddub, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vraddub_acc, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vraddh, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vradduh, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubub, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubb_map, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vsububs, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubhs, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubuhs, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubws, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vabsh, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vabshsat, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vabsw, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vabswsat, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vabsdiffw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vabsdiffh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vrsadub, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vrsadub_acc, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgub, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavguh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavgh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavgw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgwr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavgwr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgwcr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavgwcr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavghcr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavghcr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavguw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavguwr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgubr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavguhr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavghr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavghr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_round_ri, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_round_rr, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_round_ri_sat, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_round_rr_sat, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cround_ri, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cround_rr, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vrminh, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vrmaxh, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vrminuh, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vrmaxuh, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vrminw, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vrmaxw, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vrminuw, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vrmaxuw, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vminb, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxb, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vminub, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxub, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vminh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vminuh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxuh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vminw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vminuw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxuw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_modwrapu, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfadd, "fff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfsub, "fff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfmpy, "fff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sffma, "ffff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sffma_sc, "ffffi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sffms, "ffff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sffma_lib, "ffff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sffms_lib, "ffff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfcmpeq, "iff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfcmpgt, "iff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfcmpge, "iff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfcmpuo, "iff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfmax, "fff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfmin, "fff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfclass, "ifUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfimm_p, "fUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfimm_n, "fUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sffixupn, "fff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sffixupd, "fff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sffixupr, "ff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfcmpeq, "idd", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfcmpgt, "idd", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfcmpge, "idd", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfcmpuo, "idd", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfclass, "idUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfimm_p, "dUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfimm_n, "dUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2df, "df", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2sf, "fd", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_uw2sf, "fi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_uw2df, "di", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_w2sf, "fi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_w2df, "di", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_ud2sf, "fLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_ud2df, "dLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_d2sf, "fLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_d2df, "dLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2uw, "if", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2w, "if", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2ud, "LLif", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2d, "LLif", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2uw, "id", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2w, "id", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2ud, "LLid", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2d, "LLid", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2uw_chop, "if", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2w_chop, "if", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2ud_chop, "LLif", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2d_chop, "LLif", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2uw_chop, "id", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2w_chop, "id", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2ud_chop, "LLid", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2d_chop, "LLid", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p, "LLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_xor_or, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M4_xor_xacc, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M5_vdmacbsu, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M5_vdmpybsu, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M5_vmacbsu, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M5_vmacbuu, "LLiLLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M5_vmpybsu, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M5_vmpybuu, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M5_vrmacbsu, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M5_vrmacbuu, "LLiLLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M5_vrmpybsu, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_M5_vrmpybuu, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_addasl_rrri, "iiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p, "LLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p_acc, "LLiLLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p_and, "LLiLLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p_nac, "LLiLLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p_or, "LLiLLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p_xacc, "LLiLLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_acc, "iiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_and, "iiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_nac, "iiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_or, "iiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_sat, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_xacc, "iiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_vh, "LLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_vw, "LLiLLiUIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_p, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r_acc, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_r_acc, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_r_acc, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_r_acc, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p_acc, "LLiLLiLLii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_p_acc, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p_acc, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p_acc, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r_nac, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_r_nac, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_r_nac, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_r_nac, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p_nac, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_p_nac, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p_nac, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p_nac, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r_and, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_r_and, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_r_and, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_r_and, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r_or, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_r_or, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_r_or, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_r_or, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p_and, "LLiLLiLLii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_p_and, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p_and, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p_and, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p_or, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_p_nac, "LLiLLiLLii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_p_or, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p_or, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p_or, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p_xor, "LLiLLiLLii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_p_xor, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p_xor, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p_xor, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r_sat, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_r, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_r_acc, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_r_and, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_r_nac, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_r_or, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_r_sat, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_r, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_vh, "LLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_vw, "LLiLLii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_r_acc, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r_acc, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_acc, "iiiUIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p_acc, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p_acc, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p_acc, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_r_nac, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r_nac, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_nac, "iiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p_and, "LLiLLiLLiUIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p_nac, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p_nac, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p_nac, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r_xacc, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_xacc, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p_xacc, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p_xacc, "LLiLLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p_or, "LLiLLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p_rnd, "LLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p_rnd_goodsyntax, "LLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_r, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_r_acc, "iiiUIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_r_and, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r_and, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_and, "iiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_r_nac, "iiiUIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_r_or, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r_or, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_or, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p_and, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p_and, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p_and, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p_or, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p_or, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p_or, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_sat, "iiUIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_r_rnd, "iiUIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_r_rnd_goodsyntax, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p_rnd, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p_rnd_goodsyntax, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_lsli, "iIii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_addasl_rrri, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_andi_asl_ri, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_ori_asl_ri, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_addi_asl_ri, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_subi_asl_ri, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_andi_lsr_ri, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_ori_lsr_ri, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_addi_lsr_ri, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_subi_lsr_ri, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_valignib, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_valignrb, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vspliceib, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsplicerb, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsplatrh, "LLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsplatrb, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_insert, "iiiUIiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_tableidxb_goodsyntax, "iiiUIiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_tableidxh_goodsyntax, "iiiUIiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_tableidxw_goodsyntax, "iiiUIiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_tableidxd_goodsyntax, "iiiUIiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_bitspliti, "LLiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_bitsplit, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_extract, "iiUIiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_svw_trun, "iLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_vh, "LLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_vw, "LLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p, "LLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p_acc, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p_and, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p_nac, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p_or, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p_xor, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r_acc, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r_and, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r_nac, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r_or, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r_sat, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_svw_trun, "iLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_vh, "LLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_vw, "LLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_brev, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_brevp, "LLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_cl0, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_cl0p, "iLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_cl1, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_cl1p, "iLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_clb, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_clbnorm, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_clbp, "iLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_clrbit_i, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_clrbit_r, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_ct0, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_ct0p, "iLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_ct1, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_ct1p, "iLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_deinterleave, "LLiLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_extractu, "iiUIiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_insertp, "LLiLLiLLiUIiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_extractp, "LLiLLiUIiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_extractu_rp, "iiLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_extractup, "LLiLLiUIiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_extractup_rp, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_insert, "iiiUIiUIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_insert_rp, "iiiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_extract_rp, "iiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_extractu_rp, "iiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_insertp, "LLiLLiLLiUIiUIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_insertp_rp, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_extractp_rp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_extractup_rp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_tstbit_i, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_ntstbit_i, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_setbit_i, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_togglebit_i, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_clrbit_i, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_tstbit_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_ntstbit_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_setbit_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_togglebit_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_clrbit_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_vh, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_vh, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_vh, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_vh, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S5_asrhub_rnd_sat_goodsyntax, "iLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S5_asrhub_sat, "iLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S5_vasrhrnd_goodsyntax, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_vh, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_vh, "LLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_interleave, "LLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lfsp, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p, "LLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p_acc, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p_and, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p_nac, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p_or, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p_xor, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_r, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_r_acc, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_r_and, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_r_nac, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_r_or, "iiii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_vh, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_vw, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_svw_trun, "iLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_svw_trun, "iLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_vw, "LLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p, "LLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p_acc, "LLiLLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p_and, "LLiLLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p_nac, "LLiLLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p_or, "LLiLLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p_xacc, "LLiLLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r_acc, "iiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r_and, "iiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r_nac, "iiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r_or, "iiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r_xacc, "iiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_vh, "LLiLLiUIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_vw, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_vw, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_vw, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_vw, "LLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p, "LLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p_acc, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p_and, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p_nac, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p_or, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p_xor, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_r, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_r_acc, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_r_and, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_r_nac, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_r_or, "iiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_vh, "LLiLLii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_vw, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_vw, "LLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_packhl, "LLiii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_parityp, "iLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_setbit_i, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_setbit_r, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_shuffeb, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_shuffeh, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_shuffob, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_shuffoh, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_svsathb, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_svsathub, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_tableidxb_goodsyntax, "iiiUIiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_tableidxd_goodsyntax, "iiiUIiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_tableidxh_goodsyntax, "iiiUIiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_tableidxw_goodsyntax, "iiiUIiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_togglebit_i, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_togglebit_r, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_tstbit_i, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_tstbit_r, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_valignib, "LLiLLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_valignrb, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vcnegh, "LLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vcrotate, "LLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vrcnegh, "LLiLLiLLii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_vrndpackwh, "iLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_vrndpackwhs, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsxtbh, "LLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vzxtbh, "LLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsathub, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_svsathub, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_svsathb, "ii", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_vsathb, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vtrunohb, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vtrunewh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vtrunowh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vtrunehb, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsxthw, "LLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vzxthw, "LLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsatwh, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsatwuh, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_packhl, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_swiz, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsathub_nopack, "LLiLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_vsathb_nopack, "LLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vsathub, "iLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vsathub_nopack, "LLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vsatwh, "iLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_vsatwh_nopack, "LLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vsatwuh, "iLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S2_vsatwuh_nopack, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_shuffob, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_shuffeb, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_shuffoh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_shuffeh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S5_popcountp, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_parity, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_parityp, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lfsp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_clbnorm, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vsplatrb, "ii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vsplatrh, "LLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vspliceib, "LLiLLiLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vsplicerb, "LLiLLiLLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vsxtbh, "LLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vsxthw, "LLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vtrunehb, "iLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vtrunewh, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vtrunohb, "iLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vtrunowh, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vzxtbh, "LLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S2_vzxthw, "LLii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_addaddi, "iiiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_addi_asl_ri, "iUIiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_addi_lsr_ri, "iUIiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_andi_asl_ri, "iUIiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_andi_lsr_ri, "iUIiiUIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S4_clbaddi, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_clbpnorm, "iLLi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_S4_clbpaddi, "iLLiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_clb, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_cl0, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_cl1, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_clbp, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_cl0p, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_cl1p, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_brev, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_brevp, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_ct0, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_ct1, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_ct0p, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_ct1p, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_interleave, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_deinterleave, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_Y2_dcfetch, "vv*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_Y2_dczeroa, "vv*", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_clbpnorm, "iLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_extract, "iiUIiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_extract_rp, "iiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_extractp, "LLiLLiUIiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_extractp_rp, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_lsli, "iIii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_ntstbit_i, "iiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_ntstbit_r, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_or_andi, "iiiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_or_andix, "iiiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_or_ori, "iiiIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_ori_asl_ri, "iUIiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_ori_lsr_ri, "iUIiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_parity, "iii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_subaddi, "iiIii", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_subi_asl_ri, "iUIiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_subi_lsr_ri, "iUIiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_vrcrotate, "LLiLLiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_vrcrotate_acc, "LLiLLiLLiiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_vxaddsubh, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_vxaddsubhr, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_vxaddsubw, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_vxsubaddh, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_vxsubaddhr, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S4_vxsubaddw, "LLiLLiLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S5_asrhub_rnd_sat_goodsyntax, "iLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S5_asrhub_sat, "iLLiUIi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S5_popcountp, "iLLi", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_S5_vasrhrnd_goodsyntax, "LLiLLiUIi", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_Y2_dccleana, "vv*", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_Y2_dccleaninva, "vv*", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_Y2_dcfetch, "vv*", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_Y2_dcinva, "vv*", "", V5) +TARGET_BUILTIN(__builtin_HEXAGON_Y2_dczeroa, "vv*", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_Y4_l2fetch, "vv*i", "", V5) TARGET_BUILTIN(__builtin_HEXAGON_Y5_l2fetch, "vv*LLi", "", V5) // V60 Scalar Instructions. -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_r, "iiUIi", "", V60) TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_p, "LLiLLiUIi", "", V60) -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_r_acc, "iiiUIi", "", V60) TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_p_acc, "LLiLLiLLiUIi", "", V60) -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_r_nac, "iiiUIi", "", V60) +TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_p_and, "LLiLLiLLiUIi", "", V60) TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_p_nac, "LLiLLiLLiUIi", "", V60) -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_r_xacc, "iiiUIi", "", V60) +TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_p_or, "LLiLLiLLiUIi", "", V60) TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_p_xacc, "LLiLLiLLiUIi", "", V60) +TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_r, "iiUIi", "", V60) +TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_r_acc, "iiiUIi", "", V60) TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_r_and, "iiiUIi", "", V60) +TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_r_nac, "iiiUIi", "", V60) TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_r_or, "iiiUIi", "", V60) -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_p_and, "LLiLLiLLiUIi", "", V60) -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_p_or, "LLiLLiLLiUIi", "", V60) +TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_r_xacc, "iiiUIi", "", V60) // V62 Scalar Instructions. @@ -886,288 +886,201 @@ TARGET_BUILTIN(__builtin_HEXAGON_A6_vcmpbeq_notany, "iLLiLLi", "", V65) // V66 Scalar Instructions. -TARGET_BUILTIN(__builtin_HEXAGON_M2_mnaci, "iiii", "", V66) TARGET_BUILTIN(__builtin_HEXAGON_F2_dfadd, "ddd", "", V66) TARGET_BUILTIN(__builtin_HEXAGON_F2_dfsub, "ddd", "", V66) +TARGET_BUILTIN(__builtin_HEXAGON_M2_mnaci, "iiii", "", V66) TARGET_BUILTIN(__builtin_HEXAGON_S2_mask, "iUIiUIi", "", V66) // V67 Scalar Instructions. -TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyrw, "LLiLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyrw_acc, "LLiLLiLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyrwc, "LLiLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyrwc_acc, "LLiLLiLLiLLi", "", "audio") +TARGET_BUILTIN(__builtin_HEXAGON_A7_clip, "iiUIi", "", "audio") +TARGET_BUILTIN(__builtin_HEXAGON_A7_croundd_ri, "LLiLLiUIi", "", "audio") +TARGET_BUILTIN(__builtin_HEXAGON_A7_croundd_rr, "LLiLLii", "", "audio") +TARGET_BUILTIN(__builtin_HEXAGON_A7_vclip, "LLiLLiUIi", "", "audio") +TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmax, "ddd", "", V67) +TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmin, "ddd", "", V67) +TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmpyfix, "ddd", "", V67) +TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmpyhh, "dddd", "", V67) +TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmpylh, "dddd", "", V67) +TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmpyll, "ddd", "", V67) TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyiw, "LLiLLiLLi", "", "audio") TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyiw_acc, "LLiLLiLLiLLi", "", "audio") TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyiwc, "LLiLLiLLi", "", "audio") TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyiwc_acc, "LLiLLiLLiLLi", "", "audio") +TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyrw, "LLiLLiLLi", "", "audio") +TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyrw_acc, "LLiLLiLLiLLi", "", "audio") +TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyrwc, "LLiLLiLLi", "", "audio") +TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyrwc_acc, "LLiLLiLLiLLi", "", "audio") TARGET_BUILTIN(__builtin_HEXAGON_M7_vdmpy, "LLiLLiLLi", "", V67) TARGET_BUILTIN(__builtin_HEXAGON_M7_vdmpy_acc, "LLiLLiLLiLLi", "", V67) -TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyrw, "iLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyrwc, "iLLiLLi", "", "audio") TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyiw, "iLLiLLi", "", "audio") +TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyiw_rnd, "iLLiLLi", "", "audio") TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyiwc, "iLLiLLi", "", "audio") +TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyiwc_rnd, "iLLiLLi", "", "audio") +TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyrw, "iLLiLLi", "", "audio") TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyrw_rnd, "iLLiLLi", "", "audio") +TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyrwc, "iLLiLLi", "", "audio") TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyrwc_rnd, "iLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyiw_rnd, "iLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyiwc_rnd, "iLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_A7_croundd_ri, "LLiLLiUIi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_A7_croundd_rr, "LLiLLii", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_A7_clip, "iiUIi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_A7_vclip, "LLiLLiUIi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmax, "ddd", "", V67) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmin, "ddd", "", V67) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmpyfix, "ddd", "", V67) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmpyll, "ddd", "", V67) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmpylh, "dddd", "", V67) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmpyhh, "dddd", "", V67) + +// V68 Scalar Instructions. + +TARGET_BUILTIN(__builtin_HEXAGON_Y6_dmlink, "vv*v*", "", V68) +TARGET_BUILTIN(__builtin_HEXAGON_Y6_dmpause, "i", "", V68) +TARGET_BUILTIN(__builtin_HEXAGON_Y6_dmpoll, "i", "", V68) +TARGET_BUILTIN(__builtin_HEXAGON_Y6_dmresume, "vv*", "", V68) +TARGET_BUILTIN(__builtin_HEXAGON_Y6_dmstart, "vv*", "", V68) +TARGET_BUILTIN(__builtin_HEXAGON_Y6_dmwait, "i", "", V68) // V60 HVX Instructions. -TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_qpred_ai, "vV64bv*V16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_qpred_ai_128B, "vV128bv*V32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_extractw, "iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_extractw_128B, "iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_hi, "V16iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_hi_128B, "V32iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_lo, "V16iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_lo_128B, "V32iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplatw, "V16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplatw_128B, "V32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_and, "V64bV64bV64b", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_and_128B, "V128bV128bV128b", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_and_n, "V64bV64bV64b", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_and_n_128B, "V128bV128bV128b", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_not, "V64bV64b", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_not_128B, "V128bV128b", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_or, "V64bV64bV64b", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_or_128B, "V128bV128bV128b", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_or_n, "V64bV64bV64b", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_or_n_128B, "V128bV128bV128b", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_scalar2, "V64bi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_scalar2_128B, "V128bi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_xor, "V64bV64bV64b", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_xor_128B, "V128bV128bV128b", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_nqpred_ai, "vV64bv*V16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_nqpred_ai_128B, "vV128bv*V32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_nt_qpred_ai, "vV64bv*V16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_nt_qpred_ai_128B, "vV128bv*V32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_nt_nqpred_ai, "vV64bv*V16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_nt_nqpred_ai_128B, "vV128bv*V32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_valignb, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_valignb_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlalignb, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlalignb_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_valignbi, "V16iV16iV16iUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_valignbi_128B, "V32iV32iV32iUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlalignbi, "V16iV16iV16iUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlalignbi_128B, "V32iV32iV32iUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vror, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vror_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackub, "V32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackub_128B, "V64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackb, "V32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackb_128B, "V64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackuh, "V32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackuh_128B, "V64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackh, "V32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackh_128B, "V64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackob, "V32iV32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackob_128B, "V64iV64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackoh, "V32iV32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackoh_128B, "V64iV64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackeb, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackeb_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackeh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackeh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackob, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackob_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackoh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackoh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackhub_sat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackhub_sat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackhb_sat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackhb_sat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackwuh_sat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackwuh_sat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackwh_sat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackwh_sat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vzb, "V32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vzb_128B, "V64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsb, "V32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsb_128B, "V64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vzh, "V32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vzh_128B, "V64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsh, "V32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsh_128B, "V64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_dv, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_dv_128B, "V64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_dv_acc, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_dv_acc_128B, "V64iV64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_dv, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_dv_128B, "V64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_dv_acc, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_dv_acc_128B, "V64iV64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhvsat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhvsat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhvsat_acc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhvsat_acc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsat, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsat_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsat_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsat_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhisat, "V16iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhisat_128B, "V32iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhisat_acc, "V16iV16iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhisat_acc_128B, "V32iV32iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsusat, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsusat_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsusat_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsusat_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsuisat, "V16iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsuisat_128B, "V32iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsuisat_acc, "V16iV16iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsuisat_acc_128B, "V32iV32iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyb, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyb_128B, "V64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyb_acc, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyb_acc_128B, "V64iV64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpybus, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpybus_128B, "V64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpybus_acc, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpybus_acc_128B, "V64iV64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyhb, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyhb_128B, "V64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyhb_acc, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyhb_acc_128B, "V64iV64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubv_acc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubv_acc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybv_acc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybv_acc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubi, "V32iV32iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubi_128B, "V64iV64iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubi_acc, "V32iV32iV32iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubi_acc_128B, "V64iV64iV64iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybus, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybus_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybus_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybus_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusi, "V32iV32iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusi_128B, "V64iV64iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusi_acc, "V32iV32iV32iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusi_acc_128B, "V64iV64iV64iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusv_acc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusv_acc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdsaduh, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdsaduh_128B, "V64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdsaduh_acc, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdsaduh_acc_128B, "V64iV64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrsadubi, "V32iV32iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrsadubi_128B, "V64iV64iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrsadubi_acc, "V32iV32iV32iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrsadubi_acc_128B, "V64iV64iV64iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrw, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrw_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslw, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslw_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrw, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrw_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslwv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslwv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrwv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrwv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrh, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrh_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslh, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslh_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrh, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrh_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslhv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslhv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrhv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrhv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwh, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwh_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwhsat, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwhsat_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwhrndsat, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwhrndsat_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwuhsat, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwuhsat_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundwh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundwh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundwuh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundwuh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhubsat, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhubsat_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhubrndsat, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhubrndsat_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhbrndsat, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhbrndsat_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundhb, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundhb_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundhub, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundhub_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslw_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslw_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrw_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrw_acc_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_nt_qpred_ai, "vV64bv*V16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_nt_qpred_ai_128B, "vV128bv*V32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_qpred_ai, "vV64bv*V16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_qpred_ai_128B, "vV128bv*V32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffub, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffub_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffuh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffuh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffw, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffw_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsh, "V16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsh_128B, "V32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsh_sat, "V16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsh_sat_128B, "V32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsw, "V16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsw_128B, "V32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsw_sat, "V16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsw_sat_128B, "V32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddb, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddb_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubb, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubb_128B, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddb_dv, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddb_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubb_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubb_dv_128B, "V64iV64iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbnq, "V16iV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbnq_128B, "V32iV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbq, "V16iV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbq_128B, "V32iV128bV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddh, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubh_128B, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddh_dv, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddh_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubh_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubh_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddw, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddw_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubw, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubw_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddw_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddw_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubw_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubw_dv_128B, "V64iV64iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhnq, "V16iV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhnq_128B, "V32iV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhq, "V16iV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhq_128B, "V32iV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhsat, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhsat_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhsat_dv, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhsat_dv_128B, "V64iV64iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhw, "V32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhw_128B, "V64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubh, "V32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubh_128B, "V64iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubsat, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubsat_128B, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubsat_dv, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubsat_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububsat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububsat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububsat_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububsat_dv_128B, "V64iV64iV64i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhsat, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhsat_128B, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhsat_dv, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhsat_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhsat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhsat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhsat_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhsat_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhsat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhsat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhsat_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhsat_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhsat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhsat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhsat_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhsat_dv_128B, "V64iV64iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhw, "V32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhw_128B, "V64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddw, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddw_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddw_dv, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddw_dv_128B, "V64iV64iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwnq, "V16iV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwnq_128B, "V32iV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwq, "V16iV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwq_128B, "V32iV128bV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwsat, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwsat_128B, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwsat_dv, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwsat_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwsat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwsat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwsat_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwsat_dv_128B, "V64iV64iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_valignb, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_valignb_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_valignbi, "V16iV16iV16iUIi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_valignbi_128B, "V32iV32iV32iUIi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vand, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vand_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vandqrt, "V16iV64bi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vandqrt_128B, "V32iV128bi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vandqrt_acc, "V16iV16iV64bi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vandqrt_acc_128B, "V32iV32iV128bi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvrt, "V64bV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvrt_128B, "V128bV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvrt_acc, "V64bV64bV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvrt_acc_128B, "V128bV128bV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslh, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslh_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslhv, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslhv_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslw, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslw_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslw_acc, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslw_acc_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslwv, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslwv_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrh, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrh_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhbrndsat, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhbrndsat_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhubrndsat, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhubrndsat_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhubsat, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhubsat_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhv, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhv_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrw, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrw_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrw_acc, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrw_acc_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwh, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwh_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwhrndsat, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwhrndsat_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwhsat, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwhsat_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwuhsat, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwuhsat_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwv, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwv_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vassign, "V16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vassign_128B, "V32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vassignp, "V32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vassignp_128B, "V64iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vavghrnd, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vavghrnd_128B, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgub, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgub_128B, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgubrnd, "V16iV16iV16i", "", HVXV60) @@ -1176,208 +1089,76 @@ TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguh, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguh_128B, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguhrnd, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguhrnd_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavghrnd, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavghrnd_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgh_128B, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgw, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgw_128B, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgwrnd, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgwrnd_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgw, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgw_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffub, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffub_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffuh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffuh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffw, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffw_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgub, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgub_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubh, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubh_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububh, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububh_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhw, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhw_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhw, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhw_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhw, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhw_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhw, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhw_128B, "V64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcl0h, "V16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcl0h_128B, "V32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcl0w, "V16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcl0w_128B, "V32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcombine, "V32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcombine_128B, "V64iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vd0, "V16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vd0_128B, "V32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbnq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbnq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbnq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbnq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhnq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhnq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhnq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhnq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwnq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwnq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwnq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwnq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsh, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsh_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsh_sat, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsh_sat_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsw, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsw_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsw_sat, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsw_sat_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybv, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybv_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybv_acc, "V32iV32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybv_acc_128B, "V64iV64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyubv, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyubv_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyubv_acc, "V32iV32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyubv_acc_128B, "V64iV64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybusv, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybusv_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybusv_acc, "V32iV32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybusv_acc_128B, "V64iV64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabusv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabusv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabuuv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabuuv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhv, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhv_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhv_acc, "V32iV32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhv_acc_128B, "V64iV64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhv, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhv_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhv_acc, "V32iV32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhv_acc_128B, "V64iV64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhvsrs, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhvsrs_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhus, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhus_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhus_acc, "V32iV32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhus_acc_128B, "V64iV64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyih, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyih_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyih_acc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyih_acc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyewuh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyewuh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_rnd, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_rnd_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_sacc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_sacc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_rnd_sacc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_rnd_sacc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyieoh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyieoh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewuh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewuh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiowh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiowh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewh_acc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewh_acc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewuh_acc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewuh_acc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyub, "V32iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyub_128B, "V64iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyub_acc, "V32iV32iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyub_acc_128B, "V64iV64iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybus, "V32iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybus_128B, "V64iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybus_acc, "V32iV32iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybus_acc_128B, "V64iV64iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabus, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabus_128B, "V64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabus_acc, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabus_acc_128B, "V64iV64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpahb, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpahb_128B, "V64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpahb_acc, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpahb_acc_128B, "V64iV64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyh, "V32iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyh_128B, "V64iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhsat_acc, "V32iV32iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhsat_acc_128B, "V64iV64iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhss, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhss_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhsrs, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhsrs_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuh, "V32iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuh_128B, "V64iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuh_acc, "V32iV32iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuh_acc_128B, "V64iV64iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyihb, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyihb_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyihb_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyihb_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwb, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwb_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwb_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwb_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwh, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwh_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwh_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwh_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vand, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vand_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vor, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vor_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vxor, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vxor_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnot, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnot_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandqrt, "V16iV64bi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandqrt_128B, "V32iV128bi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandqrt_acc, "V16iV16iV64bi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandqrt_acc_128B, "V32iV32iV128bi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvrt, "V64bV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvrt_128B, "V128bV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvrt_acc, "V64bV64bV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvrt_acc_128B, "V128bV128bV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw, "V64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_128B, "V128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_and, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_and_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_or, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_or_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_xor, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_xor_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw, "V64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_128B, "V128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_and, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_and_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_or, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_or_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_xor, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_xor_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth, "V64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_128B, "V128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_and, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_and_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_or, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_or_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_xor, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_xor_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealb, "V16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealb_128B, "V32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealb4w, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealb4w_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealh, "V16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealh_128B, "V32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealvdd, "V32iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealvdd_128B, "V64iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdelta, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdelta_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_acc, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_acc_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_dv, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_dv_128B, "V64iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_dv_acc, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_dv_acc_128B, "V64iV64iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_acc, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_acc_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_dv, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_dv_128B, "V64iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_dv_acc, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_dv_acc_128B, "V64iV64iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhisat, "V16iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhisat_128B, "V32iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhisat_acc, "V16iV16iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhisat_acc_128B, "V32iV32iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsat, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsat_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsat_acc, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsat_acc_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsuisat, "V16iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsuisat_128B, "V32iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsuisat_acc, "V16iV16iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsuisat_acc_128B, "V32iV32iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsusat, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsusat_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsusat_acc, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsusat_acc_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhvsat, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhvsat_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhvsat_acc, "V16iV16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhvsat_acc_128B, "V32iV32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdsaduh, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdsaduh_128B, "V64iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdsaduh_acc, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdsaduh_acc_128B, "V64iV64iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb, "V64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_128B, "V128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_and, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_and_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_or, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_or_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_xor, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_xor_128B, "V128bV128bV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_veqh, "V64bV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_veqh_128B, "V128bV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_veqh_and, "V64bV64bV16iV16i", "", HVXV60) @@ -1386,6 +1167,14 @@ TARGET_BUILTIN(__builtin_HEXAGON_V6_veqh_or, "V64bV64bV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_veqh_or_128B, "V128bV128bV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_veqh_xor, "V64bV64bV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_veqh_xor_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw, "V64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_128B, "V128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_and, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_and_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_or, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_or_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_xor, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_xor_128B, "V128bV128bV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtb, "V64bV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtb_128B, "V128bV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtb_and, "V64bV64bV16iV16i", "", HVXV60) @@ -1394,30 +1183,14 @@ TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtb_or, "V64bV64bV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtb_or_128B, "V128bV128bV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtb_xor, "V64bV64bV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtb_xor_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb, "V64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_128B, "V128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_and, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_and_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_or, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_or_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_xor, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_xor_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw, "V64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_128B, "V128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_and, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_and_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_or, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_or_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_xor, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_xor_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh, "V64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_128B, "V128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_and, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_and_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_or, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_or_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_xor, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_xor_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth, "V64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_128B, "V128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_and, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_and_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_or, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_or_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_xor, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_xor_128B, "V128bV128bV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtub, "V64bV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtub_128B, "V128bV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtub_and, "V64bV64bV16iV16i", "", HVXV60) @@ -1426,296 +1199,543 @@ TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtub_or, "V64bV64bV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtub_or_128B, "V128bV128bV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtub_xor, "V64bV64bV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtub_xor_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_or, "V64bV64bV64b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_or_128B, "V128bV128bV128b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_and, "V64bV64bV64b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_and_128B, "V128bV128bV128b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_not, "V64bV64b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_not_128B, "V128bV128b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_xor, "V64bV64bV64b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_xor_128B, "V128bV128bV128b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_and_n, "V64bV64bV64b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_and_n_128B, "V128bV128bV128b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_or_n, "V64bV64bV64b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_or_n_128B, "V128bV128bV128b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_scalar2, "V64bi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_scalar2_128B, "V128bi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmux, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmux_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vswap, "V32iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vswap_128B, "V64iV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh, "V64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_128B, "V128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_and, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_and_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_or, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_or_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_xor, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_xor_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw, "V64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_128B, "V128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_and, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_and_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_or, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_or_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_xor, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_xor_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw, "V64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_128B, "V128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_and, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_and_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_or, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_or_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_xor, "V64bV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_xor_128B, "V128bV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vinsertwr, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vinsertwr_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlalignb, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlalignb_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlalignbi, "V16iV16iV16iUIi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlalignbi_128B, "V32iV32iV32iUIi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrh, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrh_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrhv, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrhv_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrw, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrw_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrwv, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrwv_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_oracc, "V16iV16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_oracc_128B, "V32iV32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh, "V32iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_128B, "V64iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_oracc, "V32iV32iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_oracc_128B, "V64iV64iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxh_128B, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxub, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxub_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vminub, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vminub_128B, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxuh, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxuh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vminuh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vminuh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vminh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vminh_128B, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxw, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxw_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vminh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vminh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vminub, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vminub_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vminuh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vminuh_128B, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vminw, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vminw_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabus, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabus_128B, "V64iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabus_acc, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabus_acc_128B, "V64iV64iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabusv, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabusv_128B, "V64iV64iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabuuv, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabuuv_128B, "V64iV64iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpahb, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpahb_128B, "V64iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpahb_acc, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpahb_acc_128B, "V64iV64iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybus, "V32iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybus_128B, "V64iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybus_acc, "V32iV32iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybus_acc_128B, "V64iV64iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybusv, "V32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybusv_128B, "V64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybusv_acc, "V32iV32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybusv_acc_128B, "V64iV64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybv, "V32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybv_128B, "V64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybv_acc, "V32iV32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybv_acc_128B, "V64iV64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyewuh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyewuh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyh, "V32iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyh_128B, "V64iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhsat_acc, "V32iV32iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhsat_acc_128B, "V64iV64iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhsrs, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhsrs_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhss, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhss_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhus, "V32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhus_128B, "V64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhus_acc, "V32iV32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhus_acc_128B, "V64iV64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhv, "V32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhv_128B, "V64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhv_acc, "V32iV32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhv_acc_128B, "V64iV64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhvsrs, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhvsrs_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyieoh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyieoh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewh_acc, "V16iV16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewh_acc_128B, "V32iV32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewuh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewuh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewuh_acc, "V16iV16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewuh_acc_128B, "V32iV32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyih, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyih_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyih_acc, "V16iV16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyih_acc_128B, "V32iV32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyihb, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyihb_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyihb_acc, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyihb_acc_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiowh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiowh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwb, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwb_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwb_acc, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwb_acc_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwh, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwh_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwh_acc, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwh_acc_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_rnd, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_rnd_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_rnd_sacc, "V16iV16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_rnd_sacc_128B, "V32iV32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_sacc, "V16iV16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_sacc_128B, "V32iV32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyub, "V32iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyub_128B, "V64iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyub_acc, "V32iV32iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyub_acc_128B, "V64iV64iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyubv, "V32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyubv_128B, "V64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyubv_acc, "V32iV32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyubv_acc_128B, "V64iV64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuh, "V32iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuh_128B, "V64iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuh_acc, "V32iV32iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuh_acc_128B, "V64iV64iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhv, "V32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhv_128B, "V64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhv_acc, "V32iV32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhv_acc_128B, "V64iV64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmux, "V16iV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmux_128B, "V32iV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgub, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgub_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgw, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgw_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vnormamth, "V16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vnormamth_128B, "V32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vnormamtw, "V16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vnormamtw_128B, "V32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vnot, "V16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vnot_128B, "V32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vor, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vor_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackeb, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackeb_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackeh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackeh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackhb_sat, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackhb_sat_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackhub_sat, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackhub_sat_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackob, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackob_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackoh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackoh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackwh_sat, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackwh_sat_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackwuh_sat, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackwuh_sat_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpopcounth, "V16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vpopcounth_128B, "V32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrdelta, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrdelta_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybus, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybus_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybus_acc, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybus_acc_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusi, "V32iV32iiUIi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusi_128B, "V64iV64iiUIi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusi_acc, "V32iV32iV32iiUIi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusi_acc_128B, "V64iV64iV64iiUIi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusv, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusv_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusv_acc, "V16iV16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusv_acc_128B, "V32iV32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybv, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybv_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybv_acc, "V16iV16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybv_acc_128B, "V32iV32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_acc, "V16iV16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_acc_128B, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubi, "V32iV32iiUIi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubi_128B, "V64iV64iiUIi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubi_acc, "V32iV32iV32iiUIi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubi_acc_128B, "V64iV64iV64iiUIi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubv, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubv_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubv_acc, "V16iV16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubv_acc_128B, "V32iV32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vror, "V16iV16ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vror_128B, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundhb, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundhb_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundhub, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundhub_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundwh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundwh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundwuh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundwuh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrsadubi, "V32iV32iiUIi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrsadubi_128B, "V64iV64iiUIi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrsadubi_acc, "V32iV32iV32iiUIi", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrsadubi_acc_128B, "V64iV64iV64iiUIi", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vsathub, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vsathub_128B, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vsatwh, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vsatwh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsb, "V32iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsb_128B, "V64iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsh, "V32iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsh_128B, "V64iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufeh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufeh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffb, "V16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffb_128B, "V32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffeb, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffeb_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffh, "V16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffh_128B, "V32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffob, "V16iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffob_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufeh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufeh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufoh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufoh_128B, "V32iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffvdd, "V32iV16iV16ii", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffvdd_128B, "V64iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealvdd, "V32iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealvdd_128B, "V64iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufoeh, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufoeh_128B, "V64iV32iV32i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufoeb, "V32iV16iV16i", "", HVXV60) TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufoeb_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealh, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealh_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealb, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealb_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealb4w, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealb4w_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffh, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffh_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffb, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffb_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_extractw, "iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_extractw_128B, "iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vinsertwr, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vinsertwr_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplatw, "V16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplatw_128B, "V32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vassignp, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vassignp_128B, "V64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vassign, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vassign_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcombine, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcombine_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdelta, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdelta_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrdelta, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrdelta_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcl0w, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcl0w_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcl0h, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcl0h_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnormamtw, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnormamtw_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnormamth, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnormamth_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpopcounth, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpopcounth_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_oracc, "V16iV16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_oracc_128B, "V32iV32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh, "V32iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_128B, "V64iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_oracc, "V32iV32iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_oracc_128B, "V64iV64iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_hi, "V16iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_hi_128B, "V32iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_lo, "V16iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_lo_128B, "V32iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufoeh, "V32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufoeh_128B, "V64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufoh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufoh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubb, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubb_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubb_dv, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubb_dv_128B, "V64iV64iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbnq, "V16iV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbnq_128B, "V32iV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbq, "V16iV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbq_128B, "V32iV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubh, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubh_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubh_dv, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubh_dv_128B, "V64iV64iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhnq, "V16iV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhnq_128B, "V32iV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhq, "V16iV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhq_128B, "V32iV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhsat, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhsat_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhsat_dv, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhsat_dv_128B, "V64iV64iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhw, "V32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhw_128B, "V64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububh, "V32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububh_128B, "V64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububsat, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububsat_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububsat_dv, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububsat_dv_128B, "V64iV64iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhsat, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhsat_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhsat_dv, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhsat_dv_128B, "V64iV64iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhw, "V32iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhw_128B, "V64iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubw, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubw_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubw_dv, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubw_dv_128B, "V64iV64iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwnq, "V16iV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwnq_128B, "V32iV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwq, "V16iV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwq_128B, "V32iV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwsat, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwsat_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwsat_dv, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwsat_dv_128B, "V64iV64iV64i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vswap, "V32iV64bV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vswap_128B, "V64iV128bV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyb, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyb_128B, "V64iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyb_acc, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyb_acc_128B, "V64iV64iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpybus, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpybus_128B, "V64iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpybus_acc, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpybus_acc_128B, "V64iV64iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyhb, "V32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyhb_128B, "V64iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyhb_acc, "V32iV32iV32ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyhb_acc_128B, "V64iV64iV64ii", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackb, "V32iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackb_128B, "V64iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackh, "V32iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackh_128B, "V64iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackob, "V32iV32iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackob_128B, "V64iV64iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackoh, "V32iV32iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackoh_128B, "V64iV64iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackub, "V32iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackub_128B, "V64iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackuh, "V32iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackuh_128B, "V64iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vxor, "V16iV16iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vxor_128B, "V32iV32iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vzb, "V32iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vzb_128B, "V64iV32i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vzh, "V32iV16i", "", HVXV60) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vzh_128B, "V64iV32i", "", HVXV60) // V62 HVX Instructions. -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrb, "V16iV16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrb_128B, "V32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwuhrndsat, "V16iV16iV16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwuhrndsat_128B, "V32iV32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruwuhrndsat, "V16iV16iV16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruwuhrndsat_128B, "V32iV32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhbsat, "V16iV16iV16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhbsat_128B, "V32iV32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrounduwuh, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrounduwuh_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrounduhub, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrounduhub_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduwsat, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduwsat_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduwsat_dv, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduwsat_dv_128B, "V64iV64iV64i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuwsat, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuwsat_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuwsat_dv, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuwsat_dv_128B, "V64iV64iV64i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplatb, "V16ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplatb_128B, "V32ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplath, "V16ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplath_128B, "V32ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_scalar2v2, "V64bi", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_scalar2v2_128B, "V128bi", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_shuffeqh, "V64bV64bV64b", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_shuffeqh_128B, "V128bV128bV128b", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_shuffeqw, "V64bV64bV64b", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_shuffeqw_128B, "V128bV128bV128b", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbsat, "V16iV16iV16i", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbsat_128B, "V32iV32iV32i", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbsat_dv, "V32iV32iV32i", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbsat_dv_128B, "V64iV64iV64i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbsat, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbsat_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbsat_dv, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbsat_dv_128B, "V64iV64iV64i", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddcarry, "V16iV16iV16iv*", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddcarry_128B, "V32iV32iV32iv*", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubcarry, "V16iV16iV16iv*", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubcarry_128B, "V32iV32iV32iv*", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddububb_sat, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddububb_sat_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubububb_sat, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubububb_sat_128B, "V32iV32iV32i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddclbh, "V16iV16iV16i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddclbh_128B, "V32iV32iV32i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddclbw, "V16iV16iV16i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddclbw_128B, "V32iV32iV32i", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhw_acc, "V32iV32iV16iV16i", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhw_acc_128B, "V64iV64iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhw_acc, "V32iV32iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhw_acc_128B, "V64iV64iV32iV32i", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubh_acc, "V32iV32iV16iV16i", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubh_acc_128B, "V64iV64iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyewuh_64, "V32iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyewuh_64_128B, "V64iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_64_acc, "V32iV32iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_64_acc_128B, "V64iV64iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpauhb, "V32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpauhb_128B, "V64iV64ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpauhb_acc, "V32iV32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpauhb_acc_128B, "V64iV64iV64ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwub, "V16iV16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwub_128B, "V32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwub_acc, "V16iV16iV16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwub_acc_128B, "V32iV32iV32ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddububb_sat, "V16iV16iV16i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddububb_sat_128B, "V32iV32iV32i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhw_acc, "V32iV32iV16iV16i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhw_acc_128B, "V64iV64iV32iV32i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduwsat, "V16iV16iV16i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduwsat_128B, "V32iV32iV32i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduwsat_dv, "V32iV32iV32i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduwsat_dv_128B, "V64iV64iV64i", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vandnqrt, "V16iV64bi", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vandnqrt_128B, "V32iV128bi", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vandnqrt_acc, "V16iV16iV64bi", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vandnqrt_acc_128B, "V32iV32iV128bi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvqv, "V16iV64bV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvqv_128B, "V32iV128bV32i", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvnqv, "V16iV64bV16i", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvnqv_128B, "V32iV128bV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_scalar2v2, "V64bi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_scalar2v2_128B, "V128bi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_shuffeqw, "V64bV64bV64b", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_shuffeqw_128B, "V128bV128bV128b", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_shuffeqh, "V64bV64bV64b", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_shuffeqh_128B, "V128bV128bV128b", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvqv, "V16iV64bV16i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvqv_128B, "V32iV128bV32i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhbsat, "V16iV16iV16ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhbsat_128B, "V32iV32iV32ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruwuhrndsat, "V16iV16iV16ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruwuhrndsat_128B, "V32iV32iV32ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwuhrndsat, "V16iV16iV16ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwuhrndsat_128B, "V32iV32iV32ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrb, "V16iV16ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrb_128B, "V32iV32ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_nm, "V16iV16iV16ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_nm_128B, "V32iV32iV32ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_oracci, "V16iV16iV16iV16iUIi", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_oracci_128B, "V32iV32iV32iV32iUIi", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvbi, "V16iV16iV16iUIi", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvbi_128B, "V32iV32iV32iUIi", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_nm, "V32iV16iV16ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_nm_128B, "V64iV32iV32ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_oracci, "V32iV32iV16iV16iUIi", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_oracci_128B, "V64iV64iV32iV32iUIi", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwhi, "V32iV16iV16iUIi", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwhi_128B, "V64iV32iV32iUIi", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxb, "V16iV16iV16i", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxb_128B, "V32iV32iV32i", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vminb, "V16iV16iV16i", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vminb_128B, "V32iV32iV32i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpauhb, "V32iV32ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpauhb_128B, "V64iV64ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpauhb_acc, "V32iV32iV32ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpauhb_acc_128B, "V64iV64iV64ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyewuh_64, "V32iV16iV16i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyewuh_64_128B, "V64iV32iV32i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwub, "V16iV16ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwub_128B, "V32iV32ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwub_acc, "V16iV16iV16ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwub_acc_128B, "V32iV32iV32ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_64_acc, "V32iV32iV16iV16i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_64_acc_128B, "V64iV64iV32iV32i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrounduhub, "V16iV16iV16i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrounduhub_128B, "V32iV32iV32i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrounduwuh, "V16iV16iV16i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrounduwuh_128B, "V32iV32iV32i", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vsatuwuh, "V16iV16iV16i", "", HVXV62) TARGET_BUILTIN(__builtin_HEXAGON_V6_vsatuwuh_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplath, "V16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplath_128B, "V32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplatb, "V16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplatb_128B, "V32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddclbw, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddclbw_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddclbh, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddclbh_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvbi, "V16iV16iV16iUIi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvbi_128B, "V32iV32iV32iUIi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_oracci, "V16iV16iV16iV16iUIi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_oracci_128B, "V32iV32iV32iV32iUIi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwhi, "V32iV16iV16iUIi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwhi_128B, "V64iV32iV32iUIi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_oracci, "V32iV32iV16iV16iUIi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_oracci_128B, "V64iV64iV32iV32iUIi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_nm, "V16iV16iV16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_nm_128B, "V32iV32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_nm, "V32iV16iV16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_nm_128B, "V64iV32iV32ii", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbsat, "V16iV16iV16i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbsat_128B, "V32iV32iV32i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbsat_dv, "V32iV32iV32i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbsat_dv_128B, "V64iV64iV64i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubcarry, "V16iV16iV16iv*", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubcarry_128B, "V32iV32iV32iv*", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubububb_sat, "V16iV16iV16i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubububb_sat_128B, "V32iV32iV32i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuwsat, "V16iV16iV16i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuwsat_128B, "V32iV32iV32i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuwsat_dv, "V32iV32iV32i", "", HVXV62) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuwsat_dv_128B, "V64iV64iV64i", "", HVXV62) // V65 HVX Instructions. -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruwuhsat, "V16iV16iV16ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruwuhsat_128B, "V32iV32iV32ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruhubsat, "V16iV16iV16ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruhubsat_128B, "V32iV32iV32ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruhubrndsat, "V16iV16iV16ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruhubrndsat_128B, "V32iV32iV32ii", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsb, "V16iV16i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsb_128B, "V32iV32i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsb_sat, "V16iV16i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsb_sat_128B, "V32iV32i", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslh_acc, "V16iV16iV16ii", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslh_acc_128B, "V32iV32iV32ii", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrh_acc, "V16iV16iV16ii", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrh_acc_128B, "V32iV32iV32ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguw, "V16iV16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguw_128B, "V32iV32iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguwrnd, "V16iV16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguwrnd_128B, "V32iV32iV32i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruhubrndsat, "V16iV16iV16ii", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruhubrndsat_128B, "V32iV32iV32ii", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruhubsat, "V16iV16iV16ii", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruhubsat_128B, "V32iV32iV32ii", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruwuhsat, "V16iV16iV16ii", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruwuhsat_128B, "V32iV32iV32ii", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgb, "V16iV16iV16i", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgb_128B, "V32iV32iV32i", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgbrnd, "V16iV16iV16i", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgbrnd_128B, "V32iV32iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgb, "V16iV16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgb_128B, "V32iV32iV32i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguw, "V16iV16iV16i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguw_128B, "V32iV32iV32i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguwrnd, "V16iV16iV16i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguwrnd_128B, "V32iV32iV32i", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vdd0, "V32i", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vdd0_128B, "V64i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsb, "V16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsb_128B, "V32iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsb_sat, "V16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsb_sat_128B, "V32iV32i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermh, "vv*iiV16i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermh_128B, "vv*iiV32i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhq, "vv*V64biiV16i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhq_128B, "vv*V128biiV32i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhw, "vv*iiV32i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhw_128B, "vv*iiV64i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhwq, "vv*V64biiV32i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhwq_128B, "vv*V128biiV64i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermw, "vv*iiV16i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermw_128B, "vv*iiV32i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermwq, "vv*V64biiV16i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermwq_128B, "vv*V128biiV32i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlut4, "V16iV16iLLi", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vlut4_128B, "V32iV32iLLi", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabuu, "V32iV32ii", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabuu_128B, "V64iV64ii", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabuu_acc, "V32iV32iV32ii", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabuu_acc_128B, "V64iV64iV64ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyh_acc, "V32iV32iV16ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyh_acc_128B, "V64iV64iV32ii", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpahhsat, "V16iV16iV16iLLi", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpahhsat_128B, "V32iV32iV32iLLi", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpauhuhsat, "V16iV16iV16iLLi", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpauhuhsat_128B, "V32iV32iV32iLLi", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpsuhuhsat, "V16iV16iV16iLLi", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpsuhuhsat_128B, "V32iV32iV32iLLi", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlut4, "V16iV16iLLi", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlut4_128B, "V32iV32iLLi", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyh_acc, "V32iV32iV16ii", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyh_acc_128B, "V64iV64iV32ii", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhe, "V16iV16ii", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhe_128B, "V32iV32ii", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhe_acc, "V16iV16iV16ii", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhe_acc_128B, "V32iV32iV32ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermw, "vv*iiV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermw_128B, "vv*iiV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermh, "vv*iiV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermh_128B, "vv*iiV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhw, "vv*iiV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhw_128B, "vv*iiV64i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermwq, "vv*V64biiV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermwq_128B, "vv*V128biiV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhq, "vv*V64biiV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhq_128B, "vv*V128biiV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhwq, "vv*V64biiV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhwq_128B, "vv*V128biiV64i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermw, "viiV16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermw_128B, "viiV32iV32i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgb, "V16iV16iV16i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgb_128B, "V32iV32iV32i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqb, "V16iV64b", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqb_128B, "V32iV128b", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqh, "V16iV64b", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqh_128B, "V32iV128b", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqw, "V16iV64b", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqw_128B, "V32iV128b", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermh, "viiV16iV16i", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermh_128B, "viiV32iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermw_add, "viiV16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermw_add_128B, "viiV32iV32i", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermh_add, "viiV16iV16i", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermh_add_128B, "viiV32iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermwq, "vV64biiV16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermwq_128B, "vV128biiV32iV32i", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhq, "vV64biiV16iV16i", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhq_128B, "vV128biiV32iV32i", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhw, "viiV32iV16i", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhw_128B, "viiV64iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhwq, "vV64biiV32iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhwq_128B, "vV128biiV64iV32i", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhw_add, "viiV32iV16i", "", HVXV65) TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhw_add_128B, "viiV64iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqb, "V16iV64b", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqb_128B, "V32iV128b", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqh, "V16iV64b", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqh_128B, "V32iV128b", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqw, "V16iV64b", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqw_128B, "V32iV128b", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhwq, "vV64biiV32iV16i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhwq_128B, "vV128biiV64iV32i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermw, "viiV16iV16i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermw_128B, "viiV32iV32i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermw_add, "viiV16iV16i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermw_add_128B, "viiV32iV32i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermwq, "vV64biiV16iV16i", "", HVXV65) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermwq_128B, "vV128biiV32iV32i", "", HVXV65) // V66 HVX Instructions. -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrotr, "V16iV16iV16i", "", HVXV66) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrotr_128B, "V32iV32iV32i", "", HVXV66) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasr_into, "V32iV32iV16iV16i", "", HVXV66) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasr_into_128B, "V64iV64iV32iV32i", "", HVXV66) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddcarrysat, "V16iV16iV16iV64b", "", HVXV66) TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddcarrysat_128B, "V32iV32iV32iV128b", "", HVXV66) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasr_into, "V32iV32iV16iV16i", "", HVXV66) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasr_into_128B, "V64iV64iV32iV32i", "", HVXV66) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrotr, "V16iV16iV16i", "", HVXV66) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vrotr_128B, "V32iV32iV32i", "", HVXV66) TARGET_BUILTIN(__builtin_HEXAGON_V6_vsatdw, "V16iV16iV16i", "", HVXV66) TARGET_BUILTIN(__builtin_HEXAGON_V6_vsatdw_128B, "V32iV32iV32i", "", HVXV66) + +// V68 HVX Instructions. + +TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyhubs10, "V32iV32iV32iUIi", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyhubs10_128B, "V64iV64iV64iUIi", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyhubs10_vxx, "V32iV32iV32iV32iUIi", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyhubs10_vxx_128B, "V64iV64iV64iV64iUIi", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyvubs10, "V32iV32iV32iUIi", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyvubs10_128B, "V64iV64iV64iUIi", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyvubs10_vxx, "V32iV32iV32iV32iUIi", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyvubs10_vxx_128B, "V64iV64iV64iV64iUIi", "", HVXV68) diff --git a/clang/include/clang/Basic/BuiltinsHexagonMapCustomDep.def b/clang/include/clang/Basic/BuiltinsHexagonMapCustomDep.def index 9478a1b3fd14..93f560fc5adc 100644 --- a/clang/include/clang/Basic/BuiltinsHexagonMapCustomDep.def +++ b/clang/include/clang/Basic/BuiltinsHexagonMapCustomDep.def @@ -8,66 +8,68 @@ // Automatically generated file, do not edit! //===----------------------------------------------------------------------===// -CUSTOM_BUILTIN_MAPPING(M2_mpysmi, 0) -CUSTOM_BUILTIN_MAPPING(M2_dpmpyss_s0, 0) -CUSTOM_BUILTIN_MAPPING(M2_dpmpyuu_s0, 0) -CUSTOM_BUILTIN_MAPPING(M2_mpyi, 0) -CUSTOM_BUILTIN_MAPPING(M2_mpyui, 0) CUSTOM_BUILTIN_MAPPING(A2_add, 0) -CUSTOM_BUILTIN_MAPPING(A2_sub, 0) CUSTOM_BUILTIN_MAPPING(A2_addi, 0) CUSTOM_BUILTIN_MAPPING(A2_addp, 0) -CUSTOM_BUILTIN_MAPPING(A2_subp, 0) +CUSTOM_BUILTIN_MAPPING(A2_and, 0) +CUSTOM_BUILTIN_MAPPING(A2_andir, 0) CUSTOM_BUILTIN_MAPPING(A2_neg, 0) -CUSTOM_BUILTIN_MAPPING(A2_zxtb, 0) +CUSTOM_BUILTIN_MAPPING(A2_not, 0) +CUSTOM_BUILTIN_MAPPING(A2_or, 0) +CUSTOM_BUILTIN_MAPPING(A2_orir, 0) +CUSTOM_BUILTIN_MAPPING(A2_sub, 0) +CUSTOM_BUILTIN_MAPPING(A2_subp, 0) +CUSTOM_BUILTIN_MAPPING(A2_subri, 0) CUSTOM_BUILTIN_MAPPING(A2_sxtb, 0) -CUSTOM_BUILTIN_MAPPING(A2_zxth, 0) CUSTOM_BUILTIN_MAPPING(A2_sxth, 0) -CUSTOM_BUILTIN_MAPPING(A2_and, 0) -CUSTOM_BUILTIN_MAPPING(A2_or, 0) CUSTOM_BUILTIN_MAPPING(A2_xor, 0) -CUSTOM_BUILTIN_MAPPING(A2_not, 0) -CUSTOM_BUILTIN_MAPPING(A2_subri, 0) -CUSTOM_BUILTIN_MAPPING(A2_andir, 0) -CUSTOM_BUILTIN_MAPPING(A2_orir, 0) -CUSTOM_BUILTIN_MAPPING(S2_asr_i_r, 0) -CUSTOM_BUILTIN_MAPPING(S2_lsr_i_r, 0) +CUSTOM_BUILTIN_MAPPING(A2_zxtb, 0) +CUSTOM_BUILTIN_MAPPING(A2_zxth, 0) +CUSTOM_BUILTIN_MAPPING(M2_dpmpyss_s0, 0) +CUSTOM_BUILTIN_MAPPING(M2_dpmpyuu_s0, 0) +CUSTOM_BUILTIN_MAPPING(M2_mpyi, 0) +CUSTOM_BUILTIN_MAPPING(M2_mpysmi, 0) +CUSTOM_BUILTIN_MAPPING(M2_mpyui, 0) +CUSTOM_BUILTIN_MAPPING(S2_asl_i_p, 0) CUSTOM_BUILTIN_MAPPING(S2_asl_i_r, 0) CUSTOM_BUILTIN_MAPPING(S2_asr_i_p, 0) +CUSTOM_BUILTIN_MAPPING(S2_asr_i_r, 0) CUSTOM_BUILTIN_MAPPING(S2_lsr_i_p, 0) -CUSTOM_BUILTIN_MAPPING(S2_asl_i_p, 0) -CUSTOM_BUILTIN_MAPPING(V6_vS32b_qpred_ai, 64) -CUSTOM_BUILTIN_MAPPING(V6_vS32b_qpred_ai_128B, 128) +CUSTOM_BUILTIN_MAPPING(S2_lsr_i_r, 0) +CUSTOM_BUILTIN_MAPPING(V6_pred_and, 64) +CUSTOM_BUILTIN_MAPPING(V6_pred_and_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_pred_and_n, 64) +CUSTOM_BUILTIN_MAPPING(V6_pred_and_n_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_pred_not, 64) +CUSTOM_BUILTIN_MAPPING(V6_pred_not_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_pred_or, 64) +CUSTOM_BUILTIN_MAPPING(V6_pred_or_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_pred_or_n, 64) +CUSTOM_BUILTIN_MAPPING(V6_pred_or_n_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2, 64) +CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_pred_xor, 64) +CUSTOM_BUILTIN_MAPPING(V6_pred_xor_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vS32b_nqpred_ai, 64) CUSTOM_BUILTIN_MAPPING(V6_vS32b_nqpred_ai_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vS32b_nt_qpred_ai, 64) -CUSTOM_BUILTIN_MAPPING(V6_vS32b_nt_qpred_ai_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vS32b_nt_nqpred_ai, 64) CUSTOM_BUILTIN_MAPPING(V6_vS32b_nt_nqpred_ai_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vaddbq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vaddbq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vsubbq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vsubbq_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vS32b_nt_qpred_ai, 64) +CUSTOM_BUILTIN_MAPPING(V6_vS32b_nt_qpred_ai_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vS32b_qpred_ai, 64) +CUSTOM_BUILTIN_MAPPING(V6_vS32b_qpred_ai_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vaddbnq, 64) CUSTOM_BUILTIN_MAPPING(V6_vaddbnq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vsubbnq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vsubbnq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vaddhq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vaddhq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vsubhq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vsubhq_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vaddbq, 64) +CUSTOM_BUILTIN_MAPPING(V6_vaddbq_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vaddhnq, 64) CUSTOM_BUILTIN_MAPPING(V6_vaddhnq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vsubhnq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vsubhnq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vaddwq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vaddwq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vsubwq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vsubwq_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vaddhq, 64) +CUSTOM_BUILTIN_MAPPING(V6_vaddhq_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vaddwnq, 64) CUSTOM_BUILTIN_MAPPING(V6_vaddwnq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vsubwnq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vsubwnq_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vaddwq, 64) +CUSTOM_BUILTIN_MAPPING(V6_vaddwq_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vandqrt, 64) CUSTOM_BUILTIN_MAPPING(V6_vandqrt_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vandqrt_acc, 64) @@ -76,30 +78,14 @@ CUSTOM_BUILTIN_MAPPING(V6_vandvrt, 64) CUSTOM_BUILTIN_MAPPING(V6_vandvrt_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vandvrt_acc, 64) CUSTOM_BUILTIN_MAPPING(V6_vandvrt_acc_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtw, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtw_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtw_and, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtw_and_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtw_or, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtw_or_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtw_xor, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtw_xor_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqw, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqw_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqw_and, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqw_and_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqw_or, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqw_or_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqw_xor, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqw_xor_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgth, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgth_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgth_and, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgth_and_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgth_or, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgth_or_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgth_xor, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgth_xor_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_veqb, 64) +CUSTOM_BUILTIN_MAPPING(V6_veqb_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_veqb_and, 64) +CUSTOM_BUILTIN_MAPPING(V6_veqb_and_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_veqb_or, 64) +CUSTOM_BUILTIN_MAPPING(V6_veqb_or_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_veqb_xor, 64) +CUSTOM_BUILTIN_MAPPING(V6_veqb_xor_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_veqh, 64) CUSTOM_BUILTIN_MAPPING(V6_veqh_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_veqh_and, 64) @@ -108,6 +94,14 @@ CUSTOM_BUILTIN_MAPPING(V6_veqh_or, 64) CUSTOM_BUILTIN_MAPPING(V6_veqh_or_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_veqh_xor, 64) CUSTOM_BUILTIN_MAPPING(V6_veqh_xor_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_veqw, 64) +CUSTOM_BUILTIN_MAPPING(V6_veqw_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_veqw_and, 64) +CUSTOM_BUILTIN_MAPPING(V6_veqw_and_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_veqw_or, 64) +CUSTOM_BUILTIN_MAPPING(V6_veqw_or_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_veqw_xor, 64) +CUSTOM_BUILTIN_MAPPING(V6_veqw_xor_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vgtb, 64) CUSTOM_BUILTIN_MAPPING(V6_vgtb_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vgtb_and, 64) @@ -116,30 +110,14 @@ CUSTOM_BUILTIN_MAPPING(V6_vgtb_or, 64) CUSTOM_BUILTIN_MAPPING(V6_vgtb_or_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vgtb_xor, 64) CUSTOM_BUILTIN_MAPPING(V6_vgtb_xor_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqb, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqb_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqb_and, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqb_and_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqb_or, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqb_or_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqb_xor, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqb_xor_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtuw, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtuw_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtuw_and, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtuw_and_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtuw_or, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtuw_or_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtuw_xor, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtuw_xor_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtuh, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtuh_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtuh_and, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtuh_and_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtuh_or, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtuh_or_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtuh_xor, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtuh_xor_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vgth, 64) +CUSTOM_BUILTIN_MAPPING(V6_vgth_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vgth_and, 64) +CUSTOM_BUILTIN_MAPPING(V6_vgth_and_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vgth_or, 64) +CUSTOM_BUILTIN_MAPPING(V6_vgth_or_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vgth_xor, 64) +CUSTOM_BUILTIN_MAPPING(V6_vgth_xor_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vgtub, 64) CUSTOM_BUILTIN_MAPPING(V6_vgtub_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vgtub_and, 64) @@ -148,59 +126,81 @@ CUSTOM_BUILTIN_MAPPING(V6_vgtub_or, 64) CUSTOM_BUILTIN_MAPPING(V6_vgtub_or_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vgtub_xor, 64) CUSTOM_BUILTIN_MAPPING(V6_vgtub_xor_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_pred_or, 64) -CUSTOM_BUILTIN_MAPPING(V6_pred_or_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_pred_and, 64) -CUSTOM_BUILTIN_MAPPING(V6_pred_and_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_pred_not, 64) -CUSTOM_BUILTIN_MAPPING(V6_pred_not_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_pred_xor, 64) -CUSTOM_BUILTIN_MAPPING(V6_pred_xor_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_pred_and_n, 64) -CUSTOM_BUILTIN_MAPPING(V6_pred_and_n_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_pred_or_n, 64) -CUSTOM_BUILTIN_MAPPING(V6_pred_or_n_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2, 64) -CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vgtuh, 64) +CUSTOM_BUILTIN_MAPPING(V6_vgtuh_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vgtuh_and, 64) +CUSTOM_BUILTIN_MAPPING(V6_vgtuh_and_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vgtuh_or, 64) +CUSTOM_BUILTIN_MAPPING(V6_vgtuh_or_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vgtuh_xor, 64) +CUSTOM_BUILTIN_MAPPING(V6_vgtuh_xor_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vgtuw, 64) +CUSTOM_BUILTIN_MAPPING(V6_vgtuw_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vgtuw_and, 64) +CUSTOM_BUILTIN_MAPPING(V6_vgtuw_and_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vgtuw_or, 64) +CUSTOM_BUILTIN_MAPPING(V6_vgtuw_or_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vgtuw_xor, 64) +CUSTOM_BUILTIN_MAPPING(V6_vgtuw_xor_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vgtw, 64) +CUSTOM_BUILTIN_MAPPING(V6_vgtw_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vgtw_and, 64) +CUSTOM_BUILTIN_MAPPING(V6_vgtw_and_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vgtw_or, 64) +CUSTOM_BUILTIN_MAPPING(V6_vgtw_or_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vgtw_xor, 64) +CUSTOM_BUILTIN_MAPPING(V6_vgtw_xor_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vmux, 64) CUSTOM_BUILTIN_MAPPING(V6_vmux_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vsubbnq, 64) +CUSTOM_BUILTIN_MAPPING(V6_vsubbnq_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vsubbq, 64) +CUSTOM_BUILTIN_MAPPING(V6_vsubbq_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vsubhnq, 64) +CUSTOM_BUILTIN_MAPPING(V6_vsubhnq_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vsubhq, 64) +CUSTOM_BUILTIN_MAPPING(V6_vsubhq_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vsubwnq, 64) +CUSTOM_BUILTIN_MAPPING(V6_vsubwnq_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vsubwq, 64) +CUSTOM_BUILTIN_MAPPING(V6_vsubwq_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vswap, 64) CUSTOM_BUILTIN_MAPPING(V6_vswap_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2v2, 64) +CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2v2_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_shuffeqh, 64) +CUSTOM_BUILTIN_MAPPING(V6_shuffeqh_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_shuffeqw, 64) +CUSTOM_BUILTIN_MAPPING(V6_shuffeqw_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vaddcarry, 64) CUSTOM_BUILTIN_MAPPING(V6_vaddcarry_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vsubcarry, 64) -CUSTOM_BUILTIN_MAPPING(V6_vsubcarry_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vandnqrt, 64) CUSTOM_BUILTIN_MAPPING(V6_vandnqrt_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vandnqrt_acc, 64) CUSTOM_BUILTIN_MAPPING(V6_vandnqrt_acc_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vandvqv, 64) -CUSTOM_BUILTIN_MAPPING(V6_vandvqv_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vandvnqv, 64) CUSTOM_BUILTIN_MAPPING(V6_vandvnqv_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2v2, 64) -CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2v2_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_shuffeqw, 64) -CUSTOM_BUILTIN_MAPPING(V6_shuffeqw_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_shuffeqh, 64) -CUSTOM_BUILTIN_MAPPING(V6_shuffeqh_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgathermwq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgathermwq_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vandvqv, 64) +CUSTOM_BUILTIN_MAPPING(V6_vandvqv_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vsubcarry, 64) +CUSTOM_BUILTIN_MAPPING(V6_vsubcarry_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vgathermhq, 64) CUSTOM_BUILTIN_MAPPING(V6_vgathermhq_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vgathermhwq, 64) CUSTOM_BUILTIN_MAPPING(V6_vgathermhwq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vscattermwq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vscattermwq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vscattermhq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vscattermhq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vscattermhwq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vscattermhwq_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vgathermwq, 64) +CUSTOM_BUILTIN_MAPPING(V6_vgathermwq_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vprefixqb, 64) CUSTOM_BUILTIN_MAPPING(V6_vprefixqb_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vprefixqh, 64) CUSTOM_BUILTIN_MAPPING(V6_vprefixqh_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vprefixqw, 64) CUSTOM_BUILTIN_MAPPING(V6_vprefixqw_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vscattermhq, 64) +CUSTOM_BUILTIN_MAPPING(V6_vscattermhq_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vscattermhwq, 64) +CUSTOM_BUILTIN_MAPPING(V6_vscattermhwq_128B, 128) +CUSTOM_BUILTIN_MAPPING(V6_vscattermwq, 64) +CUSTOM_BUILTIN_MAPPING(V6_vscattermwq_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vaddcarrysat, 64) CUSTOM_BUILTIN_MAPPING(V6_vaddcarrysat_128B, 128) diff --git a/clang/include/clang/Basic/BuiltinsLe64.def b/clang/include/clang/Basic/BuiltinsLe64.def deleted file mode 100644 index 776492cd21b3..000000000000 --- a/clang/include/clang/Basic/BuiltinsLe64.def +++ /dev/null @@ -1,18 +0,0 @@ -//==- BuiltinsLe64.def - Le64 Builtin function database ----------*- C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file defines the Le64-specific builtin function database. Users of this -// file must define the BUILTIN macro to make use of this information. -// -//===----------------------------------------------------------------------===// - -// The format of this database matches clang/Basic/Builtins.def. - -BUILTIN(__clear_cache, "vv*v*", "i") - -#undef BUILTIN diff --git a/clang/include/clang/Basic/BuiltinsNVPTX.def b/clang/include/clang/Basic/BuiltinsNVPTX.def index d149fa0127b9..3c96900136a4 100644 --- a/clang/include/clang/Basic/BuiltinsNVPTX.def +++ b/clang/include/clang/Basic/BuiltinsNVPTX.def @@ -21,7 +21,9 @@ #pragma push_macro("SM_72") #pragma push_macro("SM_75") #pragma push_macro("SM_80") -#define SM_80 "sm_80" +#pragma push_macro("SM_86") +#define SM_86 "sm_86" +#define SM_80 "sm_80|" SM_86 #define SM_75 "sm_75|" SM_80 #define SM_72 "sm_72|" SM_75 #define SM_70 "sm_70|" SM_72 @@ -35,7 +37,11 @@ #pragma push_macro("PTX64") #pragma push_macro("PTX65") #pragma push_macro("PTX70") -#define PTX70 "ptx70" +#pragma push_macro("PTX71") +#pragma push_macro("PTX72") +#define PTX72 "ptx72" +#define PTX71 "ptx71|" PTX72 +#define PTX70 "ptx70|" PTX71 #define PTX65 "ptx65|" PTX70 #define PTX64 "ptx64|" PTX65 #define PTX63 "ptx63|" PTX64 @@ -450,12 +456,45 @@ TARGET_BUILTIN(__nvvm_match_any_sync_i64, "WiUiWi", "", PTX60) TARGET_BUILTIN(__nvvm_match_all_sync_i32p, "UiUiUii*", "", PTX60) TARGET_BUILTIN(__nvvm_match_all_sync_i64p, "WiUiWii*", "", PTX60) +// Redux +TARGET_BUILTIN(__nvvm_redux_sync_add, "iii", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_redux_sync_min, "iii", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_redux_sync_max, "iii", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_redux_sync_umin, "UiUii", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_redux_sync_umax, "UiUii", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_redux_sync_and, "iii", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_redux_sync_xor, "iii", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_redux_sync_or, "iii", "", AND(SM_80,PTX70)) + // Membar BUILTIN(__nvvm_membar_cta, "v", "") BUILTIN(__nvvm_membar_gl, "v", "") BUILTIN(__nvvm_membar_sys, "v", "") +// mbarrier + +TARGET_BUILTIN(__nvvm_mbarrier_init, "vWi*i", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_mbarrier_init_shared, "vWi*3i", "", AND(SM_80,PTX70)) + +TARGET_BUILTIN(__nvvm_mbarrier_inval, "vWi*", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_mbarrier_inval_shared, "vWi*3", "", AND(SM_80,PTX70)) + +TARGET_BUILTIN(__nvvm_mbarrier_arrive, "WiWi*", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_mbarrier_arrive_shared, "WiWi*3", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_mbarrier_arrive_noComplete, "WiWi*i", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_mbarrier_arrive_noComplete_shared, "WiWi*3i", "", AND(SM_80,PTX70)) + +TARGET_BUILTIN(__nvvm_mbarrier_arrive_drop, "WiWi*", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_mbarrier_arrive_drop_shared, "WiWi*3", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_mbarrier_arrive_drop_noComplete, "WiWi*i", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_mbarrier_arrive_drop_noComplete_shared, "WiWi*3i", "", AND(SM_80,PTX70)) + +TARGET_BUILTIN(__nvvm_mbarrier_test_wait, "bWi*Wi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_mbarrier_test_wait_shared, "bWi*3Wi", "", AND(SM_80,PTX70)) + +TARGET_BUILTIN(__nvvm_mbarrier_pending_count, "iWi", "", AND(SM_80,PTX70)) + // Memcpy, Memset BUILTIN(__nvvm_memcpy, "vUc*Uc*zi","") @@ -685,6 +724,7 @@ TARGET_BUILTIN(__hmma_m8n32k16_mma_f16f32, "vi*iC*iC*fC*IiIi", "", AND(SM_70,PTX TARGET_BUILTIN(__bmma_m8n8k128_ld_a_b1, "vi*iC*UiIi", "", AND(SM_75,PTX63)) TARGET_BUILTIN(__bmma_m8n8k128_ld_b_b1, "vi*iC*UiIi", "", AND(SM_75,PTX63)) TARGET_BUILTIN(__bmma_m8n8k128_ld_c, "vi*iC*UiIi", "", AND(SM_75,PTX63)) +TARGET_BUILTIN(__bmma_m8n8k128_mma_and_popc_b1, "vi*iC*iC*iC*Ii", "", AND(SM_75,PTX71)) TARGET_BUILTIN(__bmma_m8n8k128_mma_xor_popc_b1, "vi*iC*iC*iC*Ii", "", AND(SM_75,PTX63)) TARGET_BUILTIN(__bmma_m8n8k128_st_c_i32, "vi*iC*UiIi", "", AND(SM_75,PTX63)) TARGET_BUILTIN(__imma_m16n16k16_ld_a_s8, "vi*iC*UiIi", "", AND(SM_72,PTX63)) @@ -720,6 +760,44 @@ TARGET_BUILTIN(__imma_m8n8k32_mma_s4, "vi*iC*iC*iC*IiIi", "", AND(SM_75,PTX63)) TARGET_BUILTIN(__imma_m8n8k32_mma_u4, "vi*iC*iC*iC*IiIi", "", AND(SM_75,PTX63)) TARGET_BUILTIN(__imma_m8n8k32_st_c_i32, "vi*iC*UiIi", "", AND(SM_75,PTX63)) +// Builtins to support double and alternate float WMMA instructions on sm_80 +TARGET_BUILTIN(__dmma_m8n8k4_ld_a, "vd*dC*UiIi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__dmma_m8n8k4_ld_b, "vd*dC*UiIi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__dmma_m8n8k4_ld_c, "vd*dC*UiIi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__dmma_m8n8k4_st_c_f64, "vd*dC*UiIi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__dmma_m8n8k4_mma_f64, "vd*dC*dC*dC*IiIi", "", AND(SM_80,PTX70)) + +TARGET_BUILTIN(__mma_bf16_m16n16k16_ld_a, "vi*iC*UiIi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__mma_bf16_m16n16k16_ld_b, "vi*iC*UiIi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__mma_bf16_m16n16k16_mma_f32, "vf*iC*iC*fC*IiIi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__mma_bf16_m8n32k16_ld_a, "vi*iC*UiIi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__mma_bf16_m8n32k16_ld_b, "vi*iC*UiIi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__mma_bf16_m8n32k16_mma_f32, "vf*iC*iC*fC*IiIi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__mma_bf16_m32n8k16_ld_a, "vi*iC*UiIi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__mma_bf16_m32n8k16_ld_b, "vi*iC*UiIi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__mma_bf16_m32n8k16_mma_f32, "vf*iC*iC*fC*IiIi", "", AND(SM_80,PTX70)) + +TARGET_BUILTIN(__mma_tf32_m16n16k8_ld_a, "vi*iC*UiIi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__mma_tf32_m16n16k8_ld_b, "vi*iC*UiIi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__mma_tf32_m16n16k8_ld_c, "vf*fC*UiIi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__mma_m16n16k8_st_c_f32, "vf*fC*UiIi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__mma_tf32_m16n16k8_mma_f32, "vf*iC*iC*fC*IiIi", "", AND(SM_80,PTX70)) + +// Async Copy +TARGET_BUILTIN(__nvvm_cp_async_mbarrier_arrive, "vWi*", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_cp_async_mbarrier_arrive_shared, "vWi*3", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_cp_async_mbarrier_arrive_noinc, "vWi*", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_cp_async_mbarrier_arrive_noinc_shared, "vWi*3", "", AND(SM_80,PTX70)) + +TARGET_BUILTIN(__nvvm_cp_async_ca_shared_global_4, "vv*3vC*1", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_cp_async_ca_shared_global_8, "vv*3vC*1", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_cp_async_ca_shared_global_16, "vv*3vC*1", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_cp_async_cg_shared_global_16, "vv*3vC*1", "", AND(SM_80,PTX70)) + +TARGET_BUILTIN(__nvvm_cp_async_commit_group, "v", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_cp_async_wait_group, "vIi", "", AND(SM_80,PTX70)) +TARGET_BUILTIN(__nvvm_cp_async_wait_all, "v", "", AND(SM_80,PTX70)) + #undef BUILTIN #undef TARGET_BUILTIN #pragma pop_macro("AND") @@ -728,9 +806,12 @@ TARGET_BUILTIN(__imma_m8n8k32_st_c_i32, "vi*iC*UiIi", "", AND(SM_75,PTX63)) #pragma pop_macro("SM_72") #pragma pop_macro("SM_75") #pragma pop_macro("SM_80") +#pragma pop_macro("SM_86") #pragma pop_macro("PTX60") #pragma pop_macro("PTX61") #pragma pop_macro("PTX63") #pragma pop_macro("PTX64") #pragma pop_macro("PTX65") #pragma pop_macro("PTX70") +#pragma pop_macro("PTX71") +#pragma pop_macro("PTX72") diff --git a/clang/include/clang/Basic/BuiltinsPPC.def b/clang/include/clang/Basic/BuiltinsPPC.def index 39c66f5daeb1..dfe97af300f4 100644 --- a/clang/include/clang/Basic/BuiltinsPPC.def +++ b/clang/include/clang/Basic/BuiltinsPPC.def @@ -20,11 +20,131 @@ // MMA builtins that are using their own format documented below. #if defined(BUILTIN) && !defined(CUSTOM_BUILTIN) -# define CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE) BUILTIN(__builtin_##ID, "i.", "t") +# define CUSTOM_BUILTIN(ID, INTR, TYPES, ACCUMULATE) \ + BUILTIN(__builtin_##ID, "i.", "t") #elif defined(CUSTOM_BUILTIN) && !defined(BUILTIN) # define BUILTIN(ID, TYPES, ATTRS) #endif +#define UNALIASED_CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE) \ + CUSTOM_BUILTIN(ID, ID, TYPES, ACCUMULATE) + +// XL Compatibility built-ins +BUILTIN(__builtin_ppc_popcntb, "ULiULi", "") +BUILTIN(__builtin_ppc_poppar4, "iUi", "") +BUILTIN(__builtin_ppc_poppar8, "iULLi", "") +BUILTIN(__builtin_ppc_eieio, "v", "") +BUILTIN(__builtin_ppc_iospace_eieio, "v", "") +BUILTIN(__builtin_ppc_isync, "v", "") +BUILTIN(__builtin_ppc_lwsync, "v", "") +BUILTIN(__builtin_ppc_iospace_lwsync, "v", "") +BUILTIN(__builtin_ppc_sync, "v", "") +BUILTIN(__builtin_ppc_iospace_sync, "v", "") +BUILTIN(__builtin_ppc_dcbfl, "vvC*", "") +BUILTIN(__builtin_ppc_dcbflp, "vvC*", "") +BUILTIN(__builtin_ppc_dcbst, "vvC*", "") +BUILTIN(__builtin_ppc_dcbt, "vv*", "") +BUILTIN(__builtin_ppc_dcbtst, "vv*", "") +BUILTIN(__builtin_ppc_dcbz, "vv*", "") +BUILTIN(__builtin_ppc_icbt, "vv*", "") +BUILTIN(__builtin_ppc_fric, "dd", "") +BUILTIN(__builtin_ppc_frim, "dd", "") +BUILTIN(__builtin_ppc_frims, "ff", "") +BUILTIN(__builtin_ppc_frin, "dd", "") +BUILTIN(__builtin_ppc_frins, "ff", "") +BUILTIN(__builtin_ppc_frip, "dd", "") +BUILTIN(__builtin_ppc_frips, "ff", "") +BUILTIN(__builtin_ppc_friz, "dd", "") +BUILTIN(__builtin_ppc_frizs, "ff", "") +BUILTIN(__builtin_ppc_fsel, "dddd", "") +BUILTIN(__builtin_ppc_fsels, "ffff", "") +BUILTIN(__builtin_ppc_frsqrte, "dd", "") +BUILTIN(__builtin_ppc_frsqrtes, "ff", "") +BUILTIN(__builtin_ppc_fsqrt, "dd", "") +BUILTIN(__builtin_ppc_fsqrts, "ff", "") +BUILTIN(__builtin_ppc_compare_and_swap, "iiD*i*i", "") +BUILTIN(__builtin_ppc_compare_and_swaplp, "iLiD*Li*Li", "") +BUILTIN(__builtin_ppc_fetch_and_add, "iiD*i", "") +BUILTIN(__builtin_ppc_fetch_and_addlp, "LiLiD*Li", "") +BUILTIN(__builtin_ppc_fetch_and_and, "UiUiD*Ui", "") +BUILTIN(__builtin_ppc_fetch_and_andlp, "ULiULiD*ULi", "") +BUILTIN(__builtin_ppc_fetch_and_or, "UiUiD*Ui", "") +BUILTIN(__builtin_ppc_fetch_and_orlp, "ULiULiD*ULi", "") +BUILTIN(__builtin_ppc_fetch_and_swap, "UiUiD*Ui", "") +BUILTIN(__builtin_ppc_fetch_and_swaplp, "ULiULiD*ULi", "") +BUILTIN(__builtin_ppc_ldarx, "LiLiD*", "") +BUILTIN(__builtin_ppc_lwarx, "iiD*", "") +BUILTIN(__builtin_ppc_lharx, "isD*", "") +BUILTIN(__builtin_ppc_lbarx, "UiUcD*", "") +BUILTIN(__builtin_ppc_stdcx, "iLiD*Li", "") +BUILTIN(__builtin_ppc_stwcx, "iiD*i", "") +BUILTIN(__builtin_ppc_sthcx, "isD*s", "") +BUILTIN(__builtin_ppc_stbcx, "icD*i", "") +BUILTIN(__builtin_ppc_tdw, "vLLiLLiIUi", "") +BUILTIN(__builtin_ppc_tw, "viiIUi", "") +BUILTIN(__builtin_ppc_trap, "vi", "") +BUILTIN(__builtin_ppc_trapd, "vLi", "") +BUILTIN(__builtin_ppc_fcfid, "dd", "") +BUILTIN(__builtin_ppc_fcfud, "dd", "") +BUILTIN(__builtin_ppc_fctid, "dd", "") +BUILTIN(__builtin_ppc_fctidz, "dd", "") +BUILTIN(__builtin_ppc_fctiw, "dd", "") +BUILTIN(__builtin_ppc_fctiwz, "dd", "") +BUILTIN(__builtin_ppc_fctudz, "dd", "") +BUILTIN(__builtin_ppc_fctuwz, "dd", "") +BUILTIN(__builtin_ppc_swdiv_nochk, "ddd", "") +BUILTIN(__builtin_ppc_swdivs_nochk, "fff", "") +BUILTIN(__builtin_ppc_alignx, "vIivC*", "nc") +BUILTIN(__builtin_ppc_rdlam, "UWiUWiUWiUWIi", "nc") +// Compare +BUILTIN(__builtin_ppc_cmpeqb, "LLiLLiLLi", "") +BUILTIN(__builtin_ppc_cmprb, "iCIiii", "") +BUILTIN(__builtin_ppc_setb, "LLiLLiLLi", "") +BUILTIN(__builtin_ppc_cmpb, "LLiLLiLLi", "") +// Multiply +BUILTIN(__builtin_ppc_mulhd, "LLiLiLi", "") +BUILTIN(__builtin_ppc_mulhdu, "ULLiULiULi", "") +BUILTIN(__builtin_ppc_mulhw, "iii", "") +BUILTIN(__builtin_ppc_mulhwu, "UiUiUi", "") +BUILTIN(__builtin_ppc_maddhd, "LLiLLiLLiLLi", "") +BUILTIN(__builtin_ppc_maddhdu, "ULLiULLiULLiULLi", "") +BUILTIN(__builtin_ppc_maddld, "LLiLLiLLiLLi", "") +// Rotate +BUILTIN(__builtin_ppc_rlwnm, "UiUiIUiIUi", "") +BUILTIN(__builtin_ppc_rlwimi, "UiUiUiIUiIUi", "") +BUILTIN(__builtin_ppc_rldimi, "ULLiULLiULLiIUiIULLi", "") +// load +BUILTIN(__builtin_ppc_load2r, "UiUs*", "") +BUILTIN(__builtin_ppc_load4r, "UiUi*", "") +BUILTIN(__builtin_ppc_load8r, "ULLiULLi*", "") +// store +BUILTIN(__builtin_ppc_store2r, "vUiUs*", "") +BUILTIN(__builtin_ppc_store4r, "vUiUi*", "") +BUILTIN(__builtin_ppc_store8r, "vULLiULLi*", "") +BUILTIN(__builtin_ppc_extract_exp, "Uid", "") +BUILTIN(__builtin_ppc_extract_sig, "ULLid", "") +BUILTIN(__builtin_ppc_mtfsb0, "vUIi", "") +BUILTIN(__builtin_ppc_mtfsb1, "vUIi", "") +BUILTIN(__builtin_ppc_mtfsf, "vUIiUi", "") +BUILTIN(__builtin_ppc_mtfsfi, "vUIiUIi", "") +BUILTIN(__builtin_ppc_insert_exp, "ddULLi", "") +BUILTIN(__builtin_ppc_fmsub, "dddd", "") +BUILTIN(__builtin_ppc_fmsubs, "ffff", "") +BUILTIN(__builtin_ppc_fnmadd, "dddd", "") +BUILTIN(__builtin_ppc_fnmadds, "ffff", "") +BUILTIN(__builtin_ppc_fnmsub, "dddd", "") +BUILTIN(__builtin_ppc_fnmsubs, "ffff", "") +BUILTIN(__builtin_ppc_fre, "dd", "") +BUILTIN(__builtin_ppc_fres, "ff", "") +BUILTIN(__builtin_ppc_dcbtstt, "vv*", "") +BUILTIN(__builtin_ppc_dcbtt, "vv*", "") +BUILTIN(__builtin_ppc_mftbu, "Ui","") +BUILTIN(__builtin_ppc_mfmsr, "Ui", "") +BUILTIN(__builtin_ppc_mfspr, "ULiIi", "") +BUILTIN(__builtin_ppc_mtmsr, "vUi", "") +BUILTIN(__builtin_ppc_mtspr, "vIiULi", "") +BUILTIN(__builtin_ppc_stfiw, "viC*d", "") + BUILTIN(__builtin_ppc_get_timebase, "ULLi", "n") // This is just a placeholder, the types and attributes are wrong. @@ -39,6 +159,7 @@ BUILTIN(__builtin_altivec_vadduws, "V4UiV4UiV4Ui", "") BUILTIN(__builtin_altivec_vaddeuqm, "V1ULLLiV1ULLLiV1ULLLiV1ULLLi","") BUILTIN(__builtin_altivec_vaddcuq, "V1ULLLiV1ULLLiV1ULLLi","") BUILTIN(__builtin_altivec_vaddecuq, "V1ULLLiV1ULLLiV1ULLLiV1ULLLi","") +BUILTIN(__builtin_altivec_vadduqm, "V1ULLLiV16UcV16Uc","") BUILTIN(__builtin_altivec_vsubsbs, "V16ScV16ScV16Sc", "") BUILTIN(__builtin_altivec_vsububs, "V16UcV16UcV16Uc", "") @@ -49,6 +170,7 @@ BUILTIN(__builtin_altivec_vsubuws, "V4UiV4UiV4Ui", "") BUILTIN(__builtin_altivec_vsubeuqm, "V1ULLLiV1ULLLiV1ULLLiV1ULLLi","") BUILTIN(__builtin_altivec_vsubcuq, "V1ULLLiV1ULLLiV1ULLLi","") BUILTIN(__builtin_altivec_vsubecuq, "V1ULLLiV1ULLLiV1ULLLiV1ULLLi","") +BUILTIN(__builtin_altivec_vsubuqm, "V1ULLLiV16UcV16Uc","") BUILTIN(__builtin_altivec_vavgsb, "V16ScV16ScV16Sc", "") BUILTIN(__builtin_altivec_vavgub, "V16UcV16UcV16Uc", "") @@ -75,11 +197,11 @@ BUILTIN(__builtin_altivec_vexptefp, "V4fV4f", "") BUILTIN(__builtin_altivec_vrfim, "V4fV4f", "") -BUILTIN(__builtin_altivec_lvx, "V4iivC*", "") -BUILTIN(__builtin_altivec_lvxl, "V4iivC*", "") -BUILTIN(__builtin_altivec_lvebx, "V16civC*", "") -BUILTIN(__builtin_altivec_lvehx, "V8sivC*", "") -BUILTIN(__builtin_altivec_lvewx, "V4iivC*", "") +BUILTIN(__builtin_altivec_lvx, "V4iLivC*", "") +BUILTIN(__builtin_altivec_lvxl, "V4iLivC*", "") +BUILTIN(__builtin_altivec_lvebx, "V16cLivC*", "") +BUILTIN(__builtin_altivec_lvehx, "V8sLivC*", "") +BUILTIN(__builtin_altivec_lvewx, "V4iLivC*", "") BUILTIN(__builtin_altivec_vlogefp, "V4fV4f", "") @@ -131,11 +253,11 @@ BUILTIN(__builtin_altivec_vpkudum, "V4UiV2ULLiV2ULLi", "") BUILTIN(__builtin_altivec_vperm_4si, "V4iV4iV4iV16Uc", "") -BUILTIN(__builtin_altivec_stvx, "vV4iiv*", "") -BUILTIN(__builtin_altivec_stvxl, "vV4iiv*", "") -BUILTIN(__builtin_altivec_stvebx, "vV16civ*", "") -BUILTIN(__builtin_altivec_stvehx, "vV8siv*", "") -BUILTIN(__builtin_altivec_stvewx, "vV4iiv*", "") +BUILTIN(__builtin_altivec_stvx, "vV4iLiv*", "") +BUILTIN(__builtin_altivec_stvxl, "vV4iLiv*", "") +BUILTIN(__builtin_altivec_stvebx, "vV16cLiv*", "") +BUILTIN(__builtin_altivec_stvehx, "vV8sLiv*", "") +BUILTIN(__builtin_altivec_stvewx, "vV4iLiv*", "") BUILTIN(__builtin_altivec_vcmpbfp, "V4iV4fV4f", "") @@ -437,13 +559,13 @@ BUILTIN(__builtin_altivec_vrlqnm, "V1ULLLiV1ULLLiV1ULLLi", "") // VSX built-ins. -BUILTIN(__builtin_vsx_lxvd2x, "V2divC*", "") -BUILTIN(__builtin_vsx_lxvw4x, "V4iivC*", "") +BUILTIN(__builtin_vsx_lxvd2x, "V2dLivC*", "") +BUILTIN(__builtin_vsx_lxvw4x, "V4iLivC*", "") BUILTIN(__builtin_vsx_lxvd2x_be, "V2dSLLivC*", "") BUILTIN(__builtin_vsx_lxvw4x_be, "V4iSLLivC*", "") -BUILTIN(__builtin_vsx_stxvd2x, "vV2div*", "") -BUILTIN(__builtin_vsx_stxvw4x, "vV4iiv*", "") +BUILTIN(__builtin_vsx_stxvd2x, "vV2dLiv*", "") +BUILTIN(__builtin_vsx_stxvw4x, "vV4iLiv*", "") BUILTIN(__builtin_vsx_stxvd2x_be, "vV2dSLLivC*", "") BUILTIN(__builtin_vsx_stxvw4x_be, "vV4iSLLivC*", "") @@ -451,6 +573,8 @@ BUILTIN(__builtin_vsx_lxvl, "V4ivC*ULLi", "") BUILTIN(__builtin_vsx_lxvll, "V4ivC*ULLi", "") BUILTIN(__builtin_vsx_stxvl, "vV4iv*ULLi", "") BUILTIN(__builtin_vsx_stxvll, "vV4iv*ULLi", "") +BUILTIN(__builtin_vsx_ldrmb, "V16UcCc*Ii", "") +BUILTIN(__builtin_vsx_strmb, "vCc*IiV16Uc", "") BUILTIN(__builtin_vsx_xvmaxdp, "V2dV2dV2d", "") BUILTIN(__builtin_vsx_xvmaxsp, "V4fV4fV4f", "") @@ -544,6 +668,8 @@ BUILTIN(__builtin_vsx_xvxsigsp, "V4UiV4f", "") // Conversion builtins BUILTIN(__builtin_vsx_xvcvdpsxws, "V4SiV2d", "") BUILTIN(__builtin_vsx_xvcvdpuxws, "V4UiV2d", "") +BUILTIN(__builtin_vsx_xvcvspsxds, "V2SLLiV4f", "") +BUILTIN(__builtin_vsx_xvcvspuxds, "V2ULLiV4f", "") BUILTIN(__builtin_vsx_xvcvsxwdp, "V2dV4Si", "") BUILTIN(__builtin_vsx_xvcvuxwdp, "V2dV4Ui", "") BUILTIN(__builtin_vsx_xvcvspdp, "V2dV4f", "") @@ -596,6 +722,12 @@ BUILTIN(__builtin_truncf128_round_to_odd, "dLLd", "") BUILTIN(__builtin_vsx_scalar_extract_expq, "ULLiLLd", "") BUILTIN(__builtin_vsx_scalar_insert_exp_qp, "LLdLLdULLi", "") +// Fastmath by default builtins +BUILTIN(__builtin_ppc_rsqrtf, "V4fV4f", "") +BUILTIN(__builtin_ppc_rsqrtd, "V2dV2d", "") +BUILTIN(__builtin_ppc_recipdivf, "V4fV4fV4f", "") +BUILTIN(__builtin_ppc_recipdivd, "V2dV2dV2d", "") + // HTM builtins BUILTIN(__builtin_tbegin, "UiUIi", "") BUILTIN(__builtin_tend, "UiUIi", "") @@ -664,90 +796,103 @@ BUILTIN(__builtin_dcbf, "vvC*", "") // Because these built-ins rely on target-dependent types and to avoid pervasive // change, they are type checked manually in Sema using custom type descriptors. // The first argument of the CUSTOM_BUILTIN macro is the name of the built-in -// with its prefix, the second argument specifies the type of the function +// with its prefix, the second argument is the name of the intrinsic this +// built-in generates, the third argument specifies the type of the function // (result value, then each argument) as follows: // i -> Unsigned integer followed by the greatest possible value for that // argument or 0 if no constraint on the value. // (e.g. i15 for a 4-bits value) -// V -> Vector type used with MMA builtins (vector unsigned char) +// V -> Vector type used with MMA built-ins (vector unsigned char) // W -> PPC Vector type followed by the size of the vector type. // (e.g. W512 for __vector_quad) // any other descriptor -> Fall back to generic type descriptor decoding. // The 'C' suffix can be used as a suffix to specify the const type. // The '*' suffix can be used as a suffix to specify a pointer to a type. -// The third argument is set to true if the builtin accumulates its result into +// The fourth argument is set to true if the built-in accumulates its result into // its given accumulator. -CUSTOM_BUILTIN(vsx_lxvp, "W256SLLiW256C*", false) -CUSTOM_BUILTIN(vsx_stxvp, "vW256SLLiW256C*", false) -CUSTOM_BUILTIN(vsx_assemble_pair, "vW256*VV", false) -CUSTOM_BUILTIN(vsx_disassemble_pair, "vv*W256*", false) - -CUSTOM_BUILTIN(mma_assemble_acc, "vW512*VVVV", false) -CUSTOM_BUILTIN(mma_disassemble_acc, "vv*W512*", false) -CUSTOM_BUILTIN(mma_xxmtacc, "vW512*", true) -CUSTOM_BUILTIN(mma_xxmfacc, "vW512*", true) -CUSTOM_BUILTIN(mma_xxsetaccz, "vW512*", false) -CUSTOM_BUILTIN(mma_xvi4ger8, "vW512*VV", false) -CUSTOM_BUILTIN(mma_xvi8ger4, "vW512*VV", false) -CUSTOM_BUILTIN(mma_xvi16ger2, "vW512*VV", false) -CUSTOM_BUILTIN(mma_xvi16ger2s, "vW512*VV", false) -CUSTOM_BUILTIN(mma_xvf16ger2, "vW512*VV", false) -CUSTOM_BUILTIN(mma_xvf32ger, "vW512*VV", false) -CUSTOM_BUILTIN(mma_xvf64ger, "vW512*W256V", false) -CUSTOM_BUILTIN(mma_pmxvi4ger8, "vW512*VVi15i15i255", false) -CUSTOM_BUILTIN(mma_pmxvi8ger4, "vW512*VVi15i15i15", false) -CUSTOM_BUILTIN(mma_pmxvi16ger2, "vW512*VVi15i15i3", false) -CUSTOM_BUILTIN(mma_pmxvi16ger2s, "vW512*VVi15i15i3", false) -CUSTOM_BUILTIN(mma_pmxvf16ger2, "vW512*VVi15i15i3", false) -CUSTOM_BUILTIN(mma_pmxvf32ger, "vW512*VVi15i15", false) -CUSTOM_BUILTIN(mma_pmxvf64ger, "vW512*W256Vi15i3", false) -CUSTOM_BUILTIN(mma_xvi4ger8pp, "vW512*VV", true) -CUSTOM_BUILTIN(mma_xvi8ger4pp, "vW512*VV", true) -CUSTOM_BUILTIN(mma_xvi8ger4spp, "vW512*VV", true) -CUSTOM_BUILTIN(mma_xvi16ger2pp, "vW512*VV", true) -CUSTOM_BUILTIN(mma_xvi16ger2spp, "vW512*VV", true) -CUSTOM_BUILTIN(mma_pmxvi4ger8pp, "vW512*VVi15i15i255", true) -CUSTOM_BUILTIN(mma_pmxvi8ger4pp, "vW512*VVi15i15i15", true) -CUSTOM_BUILTIN(mma_pmxvi8ger4spp, "vW512*VVi15i15i15", true) -CUSTOM_BUILTIN(mma_pmxvi16ger2pp, "vW512*VVi15i15i3", true) -CUSTOM_BUILTIN(mma_pmxvi16ger2spp, "vW512*VVi15i15i3", true) -CUSTOM_BUILTIN(mma_xvf16ger2pp, "vW512*VV", true) -CUSTOM_BUILTIN(mma_xvf16ger2pn, "vW512*VV", true) -CUSTOM_BUILTIN(mma_xvf16ger2np, "vW512*VV", true) -CUSTOM_BUILTIN(mma_xvf16ger2nn, "vW512*VV", true) -CUSTOM_BUILTIN(mma_pmxvf16ger2pp, "vW512*VVi15i15i3", true) -CUSTOM_BUILTIN(mma_pmxvf16ger2pn, "vW512*VVi15i15i3", true) -CUSTOM_BUILTIN(mma_pmxvf16ger2np, "vW512*VVi15i15i3", true) -CUSTOM_BUILTIN(mma_pmxvf16ger2nn, "vW512*VVi15i15i3", true) -CUSTOM_BUILTIN(mma_xvf32gerpp, "vW512*VV", true) -CUSTOM_BUILTIN(mma_xvf32gerpn, "vW512*VV", true) -CUSTOM_BUILTIN(mma_xvf32gernp, "vW512*VV", true) -CUSTOM_BUILTIN(mma_xvf32gernn, "vW512*VV", true) -CUSTOM_BUILTIN(mma_pmxvf32gerpp, "vW512*VVi15i15", true) -CUSTOM_BUILTIN(mma_pmxvf32gerpn, "vW512*VVi15i15", true) -CUSTOM_BUILTIN(mma_pmxvf32gernp, "vW512*VVi15i15", true) -CUSTOM_BUILTIN(mma_pmxvf32gernn, "vW512*VVi15i15", true) -CUSTOM_BUILTIN(mma_xvf64gerpp, "vW512*W256V", true) -CUSTOM_BUILTIN(mma_xvf64gerpn, "vW512*W256V", true) -CUSTOM_BUILTIN(mma_xvf64gernp, "vW512*W256V", true) -CUSTOM_BUILTIN(mma_xvf64gernn, "vW512*W256V", true) -CUSTOM_BUILTIN(mma_pmxvf64gerpp, "vW512*W256Vi15i3", true) -CUSTOM_BUILTIN(mma_pmxvf64gerpn, "vW512*W256Vi15i3", true) -CUSTOM_BUILTIN(mma_pmxvf64gernp, "vW512*W256Vi15i3", true) -CUSTOM_BUILTIN(mma_pmxvf64gernn, "vW512*W256Vi15i3", true) -CUSTOM_BUILTIN(mma_xvbf16ger2, "vW512*VV", false) -CUSTOM_BUILTIN(mma_pmxvbf16ger2, "vW512*VVi15i15i3", false) -CUSTOM_BUILTIN(mma_xvbf16ger2pp, "vW512*VV", true) -CUSTOM_BUILTIN(mma_xvbf16ger2pn, "vW512*VV", true) -CUSTOM_BUILTIN(mma_xvbf16ger2np, "vW512*VV", true) -CUSTOM_BUILTIN(mma_xvbf16ger2nn, "vW512*VV", true) -CUSTOM_BUILTIN(mma_pmxvbf16ger2pp, "vW512*VVi15i15i3", true) -CUSTOM_BUILTIN(mma_pmxvbf16ger2pn, "vW512*VVi15i15i3", true) -CUSTOM_BUILTIN(mma_pmxvbf16ger2np, "vW512*VVi15i15i3", true) -CUSTOM_BUILTIN(mma_pmxvbf16ger2nn, "vW512*VVi15i15i3", true) +// Provided builtins with _mma_ prefix for compatibility. +CUSTOM_BUILTIN(mma_lxvp, vsx_lxvp, "W256SLLiW256C*", false) +CUSTOM_BUILTIN(mma_stxvp, vsx_stxvp, "vW256SLLiW256C*", false) +CUSTOM_BUILTIN(mma_assemble_pair, vsx_assemble_pair, "vW256*VV", false) +CUSTOM_BUILTIN(mma_disassemble_pair, vsx_disassemble_pair, "vv*W256*", false) + +// UNALIASED_CUSTOM_BUILTIN macro is used for built-ins that have +// the same name as that of the intrinsic they generate, i.e. the +// ID and INTR are the same. +// This avoids repeating the ID and INTR in the macro expression. + +UNALIASED_CUSTOM_BUILTIN(vsx_lxvp, "W256SLLiW256C*", false) +UNALIASED_CUSTOM_BUILTIN(vsx_stxvp, "vW256SLLiW256C*", false) +UNALIASED_CUSTOM_BUILTIN(vsx_assemble_pair, "vW256*VV", false) +UNALIASED_CUSTOM_BUILTIN(vsx_disassemble_pair, "vv*W256*", false) + +UNALIASED_CUSTOM_BUILTIN(mma_assemble_acc, "vW512*VVVV", false) +UNALIASED_CUSTOM_BUILTIN(mma_disassemble_acc, "vv*W512*", false) +UNALIASED_CUSTOM_BUILTIN(mma_xxmtacc, "vW512*", true) +UNALIASED_CUSTOM_BUILTIN(mma_xxmfacc, "vW512*", true) +UNALIASED_CUSTOM_BUILTIN(mma_xxsetaccz, "vW512*", false) +UNALIASED_CUSTOM_BUILTIN(mma_xvi4ger8, "vW512*VV", false) +UNALIASED_CUSTOM_BUILTIN(mma_xvi8ger4, "vW512*VV", false) +UNALIASED_CUSTOM_BUILTIN(mma_xvi16ger2, "vW512*VV", false) +UNALIASED_CUSTOM_BUILTIN(mma_xvi16ger2s, "vW512*VV", false) +UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2, "vW512*VV", false) +UNALIASED_CUSTOM_BUILTIN(mma_xvf32ger, "vW512*VV", false) +UNALIASED_CUSTOM_BUILTIN(mma_xvf64ger, "vW512*W256V", false) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvi4ger8, "vW512*VVi15i15i255", false) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvi8ger4, "vW512*VVi15i15i15", false) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2, "vW512*VVi15i15i3", false) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2s, "vW512*VVi15i15i3", false) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2, "vW512*VVi15i15i3", false) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32ger, "vW512*VVi15i15", false) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64ger, "vW512*W256Vi15i3", false) +UNALIASED_CUSTOM_BUILTIN(mma_xvi4ger8pp, "vW512*VV", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvi8ger4pp, "vW512*VV", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvi8ger4spp, "vW512*VV", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvi16ger2pp, "vW512*VV", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvi16ger2spp, "vW512*VV", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvi4ger8pp, "vW512*VVi15i15i255", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvi8ger4pp, "vW512*VVi15i15i15", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvi8ger4spp, "vW512*VVi15i15i15", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2pp, "vW512*VVi15i15i3", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2spp, "vW512*VVi15i15i3", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2pp, "vW512*VV", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2pn, "vW512*VV", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2np, "vW512*VV", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2nn, "vW512*VV", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2pp, "vW512*VVi15i15i3", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2pn, "vW512*VVi15i15i3", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2np, "vW512*VVi15i15i3", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2nn, "vW512*VVi15i15i3", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvf32gerpp, "vW512*VV", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvf32gerpn, "vW512*VV", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvf32gernp, "vW512*VV", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvf32gernn, "vW512*VV", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gerpp, "vW512*VVi15i15", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gerpn, "vW512*VVi15i15", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gernp, "vW512*VVi15i15", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gernn, "vW512*VVi15i15", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvf64gerpp, "vW512*W256V", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvf64gerpn, "vW512*W256V", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvf64gernp, "vW512*W256V", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvf64gernn, "vW512*W256V", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64gerpp, "vW512*W256Vi15i3", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64gerpn, "vW512*W256Vi15i3", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64gernp, "vW512*W256Vi15i3", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64gernn, "vW512*W256Vi15i3", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2, "vW512*VV", false) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2, "vW512*VVi15i15i3", false) +UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2pp, "vW512*VV", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2pn, "vW512*VV", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2np, "vW512*VV", true) +UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2nn, "vW512*VV", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2pp, "vW512*VVi15i15i3", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2pn, "vW512*VVi15i15i3", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2np, "vW512*VVi15i15i3", true) +UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2nn, "vW512*VVi15i15i3", true) // FIXME: Obviously incomplete. #undef BUILTIN #undef CUSTOM_BUILTIN +#undef UNALIASED_CUSTOM_BUILTIN diff --git a/clang/include/clang/Basic/BuiltinsRISCV.def b/clang/include/clang/Basic/BuiltinsRISCV.def new file mode 100644 index 000000000000..b2b4950f92bd --- /dev/null +++ b/clang/include/clang/Basic/BuiltinsRISCV.def @@ -0,0 +1,63 @@ +//==- BuiltinsRISCV.def - RISC-V Builtin function database -------*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines the RISC-V-specific builtin function database. Users of +// this file must define the BUILTIN macro to make use of this information. +// +//===----------------------------------------------------------------------===// + +#if defined(BUILTIN) && !defined(TARGET_BUILTIN) +# define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS) +#endif + +#include "clang/Basic/riscv_vector_builtins.inc" + +// Zbb extension +TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "experimental-zbb") +TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "experimental-zbb,64bit") + +// Zbc extension +TARGET_BUILTIN(__builtin_riscv_clmul, "LiLiLi", "nc", "experimental-zbc") +TARGET_BUILTIN(__builtin_riscv_clmulh, "LiLiLi", "nc", "experimental-zbc") +TARGET_BUILTIN(__builtin_riscv_clmulr, "LiLiLi", "nc", "experimental-zbc") + +// Zbe extension +TARGET_BUILTIN(__builtin_riscv_bcompress_32, "ZiZiZi", "nc", "experimental-zbe") +TARGET_BUILTIN(__builtin_riscv_bcompress_64, "WiWiWi", "nc", + "experimental-zbe,64bit") +TARGET_BUILTIN(__builtin_riscv_bdecompress_32, "ZiZiZi", "nc", + "experimental-zbe") +TARGET_BUILTIN(__builtin_riscv_bdecompress_64, "WiWiWi", "nc", + "experimental-zbe,64bit") + +// Zbp extension +TARGET_BUILTIN(__builtin_riscv_grev_32, "ZiZiZi", "nc", "experimental-zbp") +TARGET_BUILTIN(__builtin_riscv_grev_64, "WiWiWi", "nc", "experimental-zbp,64bit") +TARGET_BUILTIN(__builtin_riscv_gorc_32, "ZiZiZi", "nc", "experimental-zbp") +TARGET_BUILTIN(__builtin_riscv_gorc_64, "WiWiWi", "nc", "experimental-zbp,64bit") +TARGET_BUILTIN(__builtin_riscv_shfl_32, "ZiZiZi", "nc", "experimental-zbp") +TARGET_BUILTIN(__builtin_riscv_shfl_64, "WiWiWi", "nc", "experimental-zbp,64bit") +TARGET_BUILTIN(__builtin_riscv_unshfl_32, "ZiZiZi", "nc", "experimental-zbp") +TARGET_BUILTIN(__builtin_riscv_unshfl_64, "WiWiWi", "nc", "experimental-zbp,64bit") +TARGET_BUILTIN(__builtin_riscv_xperm_n, "LiLiLi", "nc", "experimental-zbp") +TARGET_BUILTIN(__builtin_riscv_xperm_b, "LiLiLi", "nc", "experimental-zbp") +TARGET_BUILTIN(__builtin_riscv_xperm_h, "LiLiLi", "nc", "experimental-zbp") +TARGET_BUILTIN(__builtin_riscv_xperm_w, "WiWiWi", "nc", "experimental-zbp,64bit") + +// Zbr extension +TARGET_BUILTIN(__builtin_riscv_crc32_b, "LiLi", "nc", "experimental-zbr") +TARGET_BUILTIN(__builtin_riscv_crc32_h, "LiLi", "nc", "experimental-zbr") +TARGET_BUILTIN(__builtin_riscv_crc32_w, "LiLi", "nc", "experimental-zbr") +TARGET_BUILTIN(__builtin_riscv_crc32c_b, "LiLi", "nc", "experimental-zbr") +TARGET_BUILTIN(__builtin_riscv_crc32c_h, "LiLi", "nc", "experimental-zbr") +TARGET_BUILTIN(__builtin_riscv_crc32c_w, "LiLi", "nc", "experimental-zbr") +TARGET_BUILTIN(__builtin_riscv_crc32_d, "LiLi", "nc", "experimental-zbr") +TARGET_BUILTIN(__builtin_riscv_crc32c_d, "LiLi", "nc", "experimental-zbr") + +#undef BUILTIN +#undef TARGET_BUILTIN diff --git a/clang/include/clang/Basic/BuiltinsSystemZ.def b/clang/include/clang/Basic/BuiltinsSystemZ.def index 5ea6671e623b..079e41136488 100644 --- a/clang/include/clang/Basic/BuiltinsSystemZ.def +++ b/clang/include/clang/Basic/BuiltinsSystemZ.def @@ -291,5 +291,12 @@ TARGET_BUILTIN(__builtin_s390_vlbrh, "V8UsV8Us", "nc", "vector") TARGET_BUILTIN(__builtin_s390_vlbrf, "V4UiV4Ui", "nc", "vector") TARGET_BUILTIN(__builtin_s390_vlbrg, "V2ULLiV2ULLi", "nc", "vector") +// NNP-assist facility intrinsics. +TARGET_BUILTIN(__builtin_s390_vclfnhs, "V4fV8UsIi", "nc", "nnp-assist") +TARGET_BUILTIN(__builtin_s390_vclfnls, "V4fV8UsIi", "nc", "nnp-assist") +TARGET_BUILTIN(__builtin_s390_vcrnfs, "V8UsV4fV4fIi", "nc", "nnp-assist") +TARGET_BUILTIN(__builtin_s390_vcfn, "V8UsV8UsIi", "nc", "nnp-assist") +TARGET_BUILTIN(__builtin_s390_vcnf, "V8UsV8UsIi", "nc", "nnp-assist") + #undef BUILTIN #undef TARGET_BUILTIN diff --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def b/clang/include/clang/Basic/BuiltinsWebAssembly.def index bb7d6d379e58..04ec45aa3b74 100644 --- a/clang/include/clang/Basic/BuiltinsWebAssembly.def +++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def @@ -66,37 +66,22 @@ TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i64_f64, "LLid", "nc", "nontrappi TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i64_f64, "LLid", "nc", "nontrapping-fptoint") // SIMD builtins -TARGET_BUILTIN(__builtin_wasm_swizzle_v8x16, "V16ScV16ScV16Sc", "nc", "simd128") - -TARGET_BUILTIN(__builtin_wasm_extract_lane_s_i8x16, "iV16ScIi", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_extract_lane_u_i8x16, "iV16UcIUi", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_extract_lane_s_i16x8, "iV8sIi", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_extract_lane_u_i16x8, "iV8UsIUi", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_extract_lane_i32x4, "iV4iIi", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_extract_lane_i64x2, "LLiV2LLiIi", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_extract_lane_f32x4, "fV4fIi", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_extract_lane_f64x2, "dV2dIi", "nc", "simd128") - -TARGET_BUILTIN(__builtin_wasm_replace_lane_i8x16, "V16ScV16ScIii", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_replace_lane_i16x8, "V8sV8sIii", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_replace_lane_i32x4, "V4iV4iIii", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_replace_lane_i64x2, "V2LLiV2LLiIiLLi", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_replace_lane_f32x4, "V4fV4fIif", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_replace_lane_f64x2, "V2dV2dIid", "nc", "simd128") - -TARGET_BUILTIN(__builtin_wasm_add_saturate_s_i8x16, "V16ScV16ScV16Sc", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_add_saturate_u_i8x16, "V16UcV16UcV16Uc", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_add_saturate_s_i16x8, "V8sV8sV8s", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_add_saturate_u_i16x8, "V8UsV8UsV8Us", "nc", "simd128") - -TARGET_BUILTIN(__builtin_wasm_sub_saturate_s_i8x16, "V16ScV16ScV16Sc", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_sub_saturate_u_i8x16, "V16UcV16UcV16Uc", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_sub_saturate_s_i16x8, "V8sV8sV8s", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_sub_saturate_u_i16x8, "V8UsV8UsV8Us", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_swizzle_i8x16, "V16ScV16ScV16Sc", "nc", "simd128") + +TARGET_BUILTIN(__builtin_wasm_add_sat_s_i8x16, "V16ScV16ScV16Sc", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_add_sat_u_i8x16, "V16UcV16UcV16Uc", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_add_sat_s_i16x8, "V8sV8sV8s", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_add_sat_u_i16x8, "V8UsV8UsV8Us", "nc", "simd128") + +TARGET_BUILTIN(__builtin_wasm_sub_sat_s_i8x16, "V16ScV16ScV16Sc", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_sub_sat_u_i8x16, "V16UcV16UcV16Uc", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_sub_sat_s_i16x8, "V8sV8sV8s", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_sub_sat_u_i16x8, "V8UsV8UsV8Us", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_abs_i8x16, "V16ScV16Sc", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_abs_i16x8, "V8sV8s", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_abs_i32x4, "V4iV4i", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_abs_i64x2, "V2LLiV2LLi", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_min_s_i8x16, "V16ScV16ScV16Sc", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_min_u_i8x16, "V16UcV16UcV16Uc", "nc", "simd128") @@ -116,22 +101,7 @@ TARGET_BUILTIN(__builtin_wasm_avgr_u_i16x8, "V8UsV8UsV8Us", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_popcnt_i8x16, "V16ScV16Sc", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_q15mulr_saturate_s_i16x8, "V8sV8sV8s", "nc", "simd128") - -TARGET_BUILTIN(__builtin_wasm_extmul_low_i8x16_s_i16x8, "V8sV16ScV16Sc", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_extmul_high_i8x16_s_i16x8, "V8sV16ScV16Sc", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_extmul_low_i8x16_u_i16x8, "V8UsV16UcV16Uc", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_extmul_high_i8x16_u_i16x8, "V8UsV16UcV16Uc", "nc", "simd128") - -TARGET_BUILTIN(__builtin_wasm_extmul_low_i16x8_s_i32x4, "V4iV8sV8s", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_extmul_high_i16x8_s_i32x4, "V4iV8sV8s", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_extmul_low_i16x8_u_i32x4, "V4UiV8UsV8Us", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_extmul_high_i16x8_u_i32x4, "V4UiV8UsV8Us", "nc", "simd128") - -TARGET_BUILTIN(__builtin_wasm_extmul_low_i32x4_s_i64x2, "V2LLiV4iV4i", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_extmul_high_i32x4_s_i64x2, "V2LLiV4iV4i", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_extmul_low_i32x4_u_i64x2, "V2ULLiV4UiV4Ui", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_extmul_high_i32x4_u_i64x2, "V2ULLiV4UiV4Ui", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_q15mulr_sat_s_i16x8, "V8sV8sV8s", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_extadd_pairwise_i8x16_s_i16x8, "V8sV16Sc", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_extadd_pairwise_i8x16_u_i16x8, "V8UsV16Uc", "nc", "simd128") @@ -141,21 +111,13 @@ TARGET_BUILTIN(__builtin_wasm_extadd_pairwise_i16x8_u_i32x4, "V4UiV8Us", "nc", " TARGET_BUILTIN(__builtin_wasm_bitselect, "V4iV4iV4iV4i", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_signselect_i8x16, "V16ScV16ScV16ScV16Sc", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_signselect_i16x8, "V8sV8sV8sV8s", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_signselect_i32x4, "V4iV4iV4iV4i", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_signselect_i64x2, "V2LLiV2LLiV2LLiV2LLi", "nc", "simd128") - -TARGET_BUILTIN(__builtin_wasm_shuffle_v8x16, "V16ScV16ScV16ScIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIi", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_shuffle_i8x16, "V16ScV16ScV16ScIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIi", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_any_true_i8x16, "iV16Sc", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_any_true_i16x8, "iV8s", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_any_true_i32x4, "iV4i", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_any_true_i64x2, "iV2LLi", "nc", "unimplemented-simd128") +TARGET_BUILTIN(__builtin_wasm_any_true_v128, "iV16Sc", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_all_true_i8x16, "iV16Sc", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_all_true_i16x8, "iV8s", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_all_true_i32x4, "iV4i", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_all_true_i64x2, "iV2LLi", "nc", "unimplemented-simd128") +TARGET_BUILTIN(__builtin_wasm_all_true_i64x2, "iV2LLi", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_bitmask_i8x16, "iV16Sc", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_bitmask_i16x8, "iV8s", "nc", "simd128") @@ -167,12 +129,8 @@ TARGET_BUILTIN(__builtin_wasm_abs_f64x2, "V2dV2d", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_min_f32x4, "V4fV4fV4f", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_max_f32x4, "V4fV4fV4f", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_pmin_f32x4, "V4fV4fV4f", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_pmax_f32x4, "V4fV4fV4f", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_min_f64x2, "V2dV2dV2d", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_max_f64x2, "V2dV2dV2d", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_pmin_f64x2, "V2dV2dV2d", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_pmax_f64x2, "V2dV2dV2d", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_ceil_f32x4, "V4fV4f", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_floor_f32x4, "V4fV4f", "nc", "simd128") @@ -188,47 +146,16 @@ TARGET_BUILTIN(__builtin_wasm_dot_s_i32x4_i16x8, "V4iV8sV8s", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_sqrt_f32x4, "V4fV4f", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_sqrt_f64x2, "V2dV2d", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_qfma_f32x4, "V4fV4fV4fV4f", "nc", "unimplemented-simd128") -TARGET_BUILTIN(__builtin_wasm_qfms_f32x4, "V4fV4fV4fV4f", "nc", "unimplemented-simd128") -TARGET_BUILTIN(__builtin_wasm_qfma_f64x2, "V2dV2dV2dV2d", "nc", "unimplemented-simd128") -TARGET_BUILTIN(__builtin_wasm_qfms_f64x2, "V2dV2dV2dV2d", "nc", "unimplemented-simd128") - TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i32x4_f32x4, "V4iV4f", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i32x4_f32x4, "V4iV4f", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_narrow_s_i8x16_i16x8, "V16ScV8sV8s", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, "V16UcV8UsV8Us", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, "V16UcV8sV8s", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_narrow_s_i16x8_i32x4, "V8sV4iV4i", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4UiV4Ui", "nc", "simd128") - -TARGET_BUILTIN(__builtin_wasm_widen_low_s_i32x4_i64x2, "V2LLiV4i", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_widen_high_s_i32x4_i64x2, "V2LLiV4i", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_widen_low_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_widen_high_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", "simd128") - -TARGET_BUILTIN(__builtin_wasm_convert_low_s_i32x4_f64x2, "V2dV4i", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_convert_low_u_i32x4_f64x2, "V2dV4Ui", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_trunc_saturate_zero_s_f64x2_i32x4, "V4iV2d", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_trunc_saturate_zero_u_f64x2_i32x4, "V4UiV2d", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_demote_zero_f64x2_f32x4, "V4fV2d", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_promote_low_f32x4_f64x2, "V2dV4f", "nc", "simd128") - -TARGET_BUILTIN(__builtin_wasm_load32_zero, "V4ii*", "n", "simd128") -TARGET_BUILTIN(__builtin_wasm_load64_zero, "V2LLiLLi*", "n", "simd128") - -TARGET_BUILTIN(__builtin_wasm_load8_lane, "V16ScSc*V16ScIi", "n", "simd128") -TARGET_BUILTIN(__builtin_wasm_load16_lane, "V8ss*V8sIi", "n", "simd128") -TARGET_BUILTIN(__builtin_wasm_load32_lane, "V4ii*V4iIi", "n", "simd128") -TARGET_BUILTIN(__builtin_wasm_load64_lane, "V2LLiLLi*V2LLiIi", "n", "simd128") -TARGET_BUILTIN(__builtin_wasm_store8_lane, "vSc*V16ScIi", "n", "simd128") -TARGET_BUILTIN(__builtin_wasm_store16_lane, "vs*V8sIi", "n", "simd128") -TARGET_BUILTIN(__builtin_wasm_store32_lane, "vi*V4iIi", "n", "simd128") -TARGET_BUILTIN(__builtin_wasm_store64_lane, "vLLi*V2LLiIi", "n", "simd128") - -TARGET_BUILTIN(__builtin_wasm_eq_i64x2, "V2LLiV2LLiV2LLi", "nc", "simd128") - -TARGET_BUILTIN(__builtin_wasm_prefetch_t, "vv*", "n", "simd128") -TARGET_BUILTIN(__builtin_wasm_prefetch_nt, "vv*", "n", "simd128") +TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4iV4i", "nc", "simd128") + +TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4, "V4iV2d", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4, "V4UiV2d", "nc", "simd128") #undef BUILTIN #undef TARGET_BUILTIN diff --git a/clang/include/clang/Basic/BuiltinsX86.def b/clang/include/clang/Basic/BuiltinsX86.def index 16fb7dd7b0e6..18e541fe9cb5 100644 --- a/clang/include/clang/Basic/BuiltinsX86.def +++ b/clang/include/clang/Basic/BuiltinsX86.def @@ -1878,6 +1878,10 @@ TARGET_BUILTIN(__builtin_ia32_reduce_and_d512, "iV16i", "ncV:512:", "avx512f") TARGET_BUILTIN(__builtin_ia32_reduce_and_q512, "OiV8Oi", "ncV:512:", "avx512f") TARGET_BUILTIN(__builtin_ia32_reduce_fadd_pd512, "ddV8d", "ncV:512:", "avx512f") TARGET_BUILTIN(__builtin_ia32_reduce_fadd_ps512, "ffV16f", "ncV:512:", "avx512f") +TARGET_BUILTIN(__builtin_ia32_reduce_fmax_pd512, "dV8d", "ncV:512:", "avx512f") +TARGET_BUILTIN(__builtin_ia32_reduce_fmax_ps512, "fV16f", "ncV:512:", "avx512f") +TARGET_BUILTIN(__builtin_ia32_reduce_fmin_pd512, "dV8d", "ncV:512:", "avx512f") +TARGET_BUILTIN(__builtin_ia32_reduce_fmin_ps512, "fV16f", "ncV:512:", "avx512f") TARGET_BUILTIN(__builtin_ia32_reduce_fmul_pd512, "ddV8d", "ncV:512:", "avx512f") TARGET_BUILTIN(__builtin_ia32_reduce_fmul_ps512, "ffV16f", "ncV:512:", "avx512f") TARGET_BUILTIN(__builtin_ia32_reduce_mul_d512, "iV16i", "ncV:512:", "avx512f") diff --git a/clang/include/clang/Basic/BuiltinsX86_64.def b/clang/include/clang/Basic/BuiltinsX86_64.def index 974ba35b3233..ce2b1decdf6c 100644 --- a/clang/include/clang/Basic/BuiltinsX86_64.def +++ b/clang/include/clang/Basic/BuiltinsX86_64.def @@ -101,10 +101,16 @@ TARGET_BUILTIN(__builtin_ia32_testui, "Uc", "n", "uintr") TARGET_BUILTIN(__builtin_ia32_senduipi, "vUWi", "n", "uintr") // AMX internal builtin +TARGET_BUILTIN(__builtin_ia32_tile_loadconfig_internal, "vvC*", "n", "amx-tile") TARGET_BUILTIN(__builtin_ia32_tileloadd64_internal, "V256iUsUsvC*z", "n", "amx-tile") +TARGET_BUILTIN(__builtin_ia32_tileloaddt164_internal, "V256iUsUsvC*z", "n", "amx-tile") TARGET_BUILTIN(__builtin_ia32_tdpbssd_internal, "V256iUsUsUsV256iV256iV256i", "n", "amx-int8") +TARGET_BUILTIN(__builtin_ia32_tdpbsud_internal, "V256iUsUsUsV256iV256iV256i", "n", "amx-int8") +TARGET_BUILTIN(__builtin_ia32_tdpbusd_internal, "V256iUsUsUsV256iV256iV256i", "n", "amx-int8") +TARGET_BUILTIN(__builtin_ia32_tdpbuud_internal, "V256iUsUsUsV256iV256iV256i", "n", "amx-int8") TARGET_BUILTIN(__builtin_ia32_tilestored64_internal, "vUsUsv*zV256i", "n", "amx-tile") TARGET_BUILTIN(__builtin_ia32_tilezero_internal, "V256iUsUs", "n", "amx-tile") +TARGET_BUILTIN(__builtin_ia32_tdpbf16ps_internal, "V256iUsUsUsV256iV256iV256i", "n", "amx-bf16") // AMX TARGET_BUILTIN(__builtin_ia32_tile_loadconfig, "vvC*", "n", "amx-tile") TARGET_BUILTIN(__builtin_ia32_tile_storeconfig, "vvC*", "n", "amx-tile") diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index 5c8af65326ed..e3202cf88756 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -39,9 +39,9 @@ CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) o CODEGENOPT(Autolink , 1, 1) ///< -fno-autolink CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be EH-safe. CODEGENOPT(Backchain , 1, 0) ///< -mbackchain -CODEGENOPT(IgnoreXCOFFVisibility , 1, 0) ///< -mignore-xcoff-visibility CODEGENOPT(ControlFlowGuardNoChecks , 1, 0) ///< -cfguard-no-checks CODEGENOPT(ControlFlowGuard , 1, 0) ///< -cfguard +CODEGENOPT(EHContGuard , 1, 0) ///< -ehcontguard CODEGENOPT(CXAAtExit , 1, 1) ///< Use __cxa_atexit for calling destructors. CODEGENOPT(RegisterGlobalDtorsWithAtExit, 1, 1) ///< Use atexit or __cxa_atexit to register global destructors. CODEGENOPT(CXXCtorDtorAliases, 1, 0) ///< Emit complete ctors/dtors as linker @@ -63,12 +63,17 @@ CODEGENOPT(DisableLifetimeMarkers, 1, 0) ///< Don't emit any lifetime markers CODEGENOPT(DisableO0ImplyOptNone , 1, 0) ///< Don't annonate function with optnone at O0 CODEGENOPT(ExperimentalStrictFloatingPoint, 1, 0) ///< Enables the new, experimental ///< strict floating point. +CODEGENOPT(EnableNoundefAttrs, 1, 0) ///< Enable emitting `noundef` attributes on IR call arguments and return values CODEGENOPT(LegacyPassManager, 1, 0) ///< Use the legacy pass manager. CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new ///< pass manager. CODEGENOPT(DisableRedZone , 1, 0) ///< Set when -mno-red-zone is enabled. CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of ///< '-g' + 'O>0' level. +CODEGENOPT(EnableDIPreservationVerify, 1, 0) ///< Enable di preservation verify + ///< each (it means check + ///< the original debug info + ///< metadata preservation). CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs ///< is specified. CODEGENOPT(DisableTailCalls , 1, 0) ///< Do not emit tail calls. @@ -167,7 +172,8 @@ CODEGENOPT(NoInlineLineTables, 1, 0) ///< Whether debug info should contain CODEGENOPT(StackClashProtector, 1, 0) ///< Set when -fstack-clash-protection is enabled. CODEGENOPT(NoImplicitFloat , 1, 0) ///< Set when -mno-implicit-float is enabled. CODEGENOPT(NullPointerIsValid , 1, 0) ///< Assume Null pointer deference is defined. -CODEGENOPT(CorrectlyRoundedDivSqrt, 1, 0) ///< -cl-fp32-correctly-rounded-divide-sqrt +CODEGENOPT(OpenCLCorrectlyRoundedDivSqrt, 1, 0) ///< -cl-fp32-correctly-rounded-divide-sqrt +CODEGENOPT(HIPCorrectlyRoundedDivSqrt, 1, 1) ///< -fno-hip-fp32-correctly-rounded-divide-sqrt CODEGENOPT(UniqueInternalLinkageNames, 1, 0) ///< Internal Linkage symbols get unique names. CODEGENOPT(SplitMachineFunctions, 1, 0) ///< Split machine functions using profile information. @@ -206,6 +212,10 @@ CODEGENOPT(NewStructPathTBAA , 1, 0) ///< Whether or not to use enhanced struct- CODEGENOPT(SaveTempLabels , 1, 0) ///< Save temporary labels. CODEGENOPT(SanitizeAddressUseAfterScope , 1, 0) ///< Enable use-after-scope detection ///< in AddressSanitizer +ENUM_CODEGENOPT(SanitizeAddressUseAfterReturn, + llvm::AsanDetectStackUseAfterReturnMode, 2, + llvm::AsanDetectStackUseAfterReturnMode::Runtime + ) ///< Set detection mode for stack-use-after-return. CODEGENOPT(SanitizeAddressPoisonCustomArrayCookie, 1, 0) ///< Enable poisoning operator new[] which is not a replaceable ///< global allocation function in AddressSanitizer @@ -214,6 +224,9 @@ CODEGENOPT(SanitizeAddressGlobalsDeadStripping, 1, 0) ///< Enable linker dead st CODEGENOPT(SanitizeAddressUseOdrIndicator, 1, 0) ///< Enable ODR indicator globals CODEGENOPT(SanitizeMemoryTrackOrigins, 2, 0) ///< Enable tracking origins in ///< MemorySanitizer +ENUM_CODEGENOPT(SanitizeAddressDtor, llvm::AsanDtorKind, 2, + llvm::AsanDtorKind::Global) ///< Set how ASan global + ///< destructors are emitted. CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete detection ///< in MemorySanitizer CODEGENOPT(SanitizeCfiCrossDso, 1, 0) ///< Enable cross-dso support in CFI. @@ -266,6 +279,9 @@ CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer. CODEGENOPT(VectorizeSLP , 1, 0) ///< Run SLP vectorizer. CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate. +/// Treat loops as finite: language, always, never. +ENUM_CODEGENOPT(FiniteLoops, FiniteLoopsKind, 2, FiniteLoopsKind::Language) + /// Attempt to use register sized accesses to bit-fields in structures, when /// possible. CODEGENOPT(UseRegisterSizedBitfieldAccess , 1, 0) @@ -281,7 +297,9 @@ VALUE_CODEGENOPT(StackAlignment , 32, 0) ///< Overrides default stack ///< alignment, if not 0. VALUE_CODEGENOPT(StackProbeSize , 32, 4096) ///< Overrides default stack ///< probe size, even if 0. +VALUE_CODEGENOPT(WarnStackSize , 32, UINT_MAX) ///< Set via -fwarn-stack-size. CODEGENOPT(NoStackArgProbe, 1, 0) ///< Set when -mno-stack-arg-probe is used +CODEGENOPT(DebugStrictDwarf, 1, 1) ///< Whether or not to use strict DWARF info. CODEGENOPT(DebugColumnInfo, 1, 0) ///< Whether or not to use column information ///< in debug info. @@ -329,7 +347,7 @@ ENUM_CODEGENOPT(DebugInfo, codegenoptions::DebugInfoKind, 4, codegenoptions::NoD CODEGENOPT(MacroDebugInfo, 1, 0) /// Tune the debug info for this debugger. -ENUM_CODEGENOPT(DebuggerTuning, llvm::DebuggerKind, 2, +ENUM_CODEGENOPT(DebuggerTuning, llvm::DebuggerKind, 3, llvm::DebuggerKind::Default) /// Dwarf version. Version zero indicates to LLVM that no DWARF should be @@ -359,7 +377,7 @@ ENUM_CODEGENOPT(DefaultTLSModel, TLSModel, 2, GeneralDynamicTLSModel) VALUE_CODEGENOPT(TLSSize, 8, 0) /// The default stack protector guard offset to use. -VALUE_CODEGENOPT(StackProtectorGuardOffset, 32, (unsigned)-1) +VALUE_CODEGENOPT(StackProtectorGuardOffset, 32, INT_MAX) /// Number of path components to strip when emitting checks. (0 == full /// filename) @@ -414,6 +432,11 @@ CODEGENOPT(PassByValueIsNoAlias, 1, 0) /// according to the field declaring type width. CODEGENOPT(AAPCSBitfieldWidth, 1, 1) +/// Sets the IEEE bit in the expected default floating point mode register. +/// Floating point opcodes that support exception flag gathering quiet and +/// propagate signaling NaN inputs per IEEE 754-2008 (AMDGPU Only) +CODEGENOPT(EmitIEEENaNCompliantInsts, 1, 1) + #undef CODEGENOPT #undef ENUM_CODEGENOPT #undef VALUE_CODEGENOPT diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h index 73d41e3293c6..617c255641ef 100644 --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -20,6 +20,7 @@ #include "llvm/Support/CodeGen.h" #include "llvm/Support/Regex.h" #include "llvm/Target/TargetOptions.h" +#include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h" #include <map> #include <memory> #include <string> @@ -54,11 +55,12 @@ public: }; enum VectorLibrary { - NoLibrary, // Don't use any vector library. - Accelerate, // Use the Accelerate framework. - LIBMVEC, // GLIBC vector math library. - MASSV, // IBM MASS vector library. - SVML // Intel short vector math library. + NoLibrary, // Don't use any vector library. + Accelerate, // Use the Accelerate framework. + LIBMVEC, // GLIBC vector math library. + MASSV, // IBM MASS vector library. + SVML, // Intel short vector math library. + Darwin_libsystem_m // Use Darwin's libsytem_m vector functions. }; enum ObjCDispatchMethodKind { @@ -74,23 +76,6 @@ public: LocalExecTLSModel }; - /// Clang versions with different platform ABI conformance. - enum class ClangABI { - /// Attempt to be ABI-compatible with code generated by Clang 3.8.x - /// (SVN r257626). This causes <1 x long long> to be passed in an - /// integer register instead of an SSE register on x64_64. - Ver3_8, - - /// Attempt to be ABI-compatible with code generated by Clang 4.0.x - /// (SVN r291814). This causes move operations to be ignored when - /// determining whether a class type can be passed or returned directly. - Ver4, - - /// Conform to the underlying platform's C and C++ ABIs as closely - /// as we can. - Latest - }; - enum StructReturnConventionKind { SRCK_Default, // No special option was passed. SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return). @@ -140,6 +125,12 @@ public: All, // Keep all frame pointers. }; + enum FiniteLoopsKind { + Language, // Not specified, use language standard. + Always, // All loops are assumed to be finite. + Never, // No loop is assumed to be finite. + }; + /// The code model to use (-mcmodel). std::string CodeModel; @@ -166,6 +157,9 @@ public: /// The string to embed in debug information as the current working directory. std::string DebugCompilationDir; + /// The string to embed in coverage mapping as the current working directory. + std::string CoverageCompilationDir; + /// The string to embed in the debug information for the compile unit, if /// non-empty. std::string DwarfDebugFlags; @@ -175,11 +169,15 @@ public: std::string RecordCommandLine; std::map<std::string, std::string> DebugPrefixMap; - std::map<std::string, std::string> ProfilePrefixMap; + std::map<std::string, std::string> CoveragePrefixMap; /// The ABI to use for passing floating point arguments. std::string FloatABI; + /// The file to use for dumping bug report by `Debugify` for original + /// debug info. + std::string DIBugsReportFilePath; + /// The floating-point denormal mode to use. llvm::DenormalMode FPDenormalMode = llvm::DenormalMode::getIEEE(); @@ -278,27 +276,52 @@ public: /// -fsymbol-partition (see https://lld.llvm.org/Partitions.html). std::string SymbolPartition; - /// Regular expression to select optimizations for which we should enable - /// optimization remarks. Transformation passes whose name matches this - /// expression (and support this feature), will emit a diagnostic - /// whenever they perform a transformation. This is enabled by the - /// -Rpass=regexp flag. - std::shared_ptr<llvm::Regex> OptimizationRemarkPattern; - - /// Regular expression to select optimizations for which we should enable - /// missed optimization remarks. Transformation passes whose name matches this - /// expression (and support this feature), will emit a diagnostic - /// whenever they tried but failed to perform a transformation. This is - /// enabled by the -Rpass-missed=regexp flag. - std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern; - - /// Regular expression to select optimizations for which we should enable - /// optimization analyses. Transformation passes whose name matches this - /// expression (and support this feature), will emit a diagnostic - /// whenever they want to explain why they decided to apply or not apply - /// a given transformation. This is enabled by the -Rpass-analysis=regexp - /// flag. - std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern; + enum RemarkKind { + RK_Missing, // Remark argument not present on the command line. + RK_Enabled, // Remark enabled via '-Rgroup'. + RK_EnabledEverything, // Remark enabled via '-Reverything'. + RK_Disabled, // Remark disabled via '-Rno-group'. + RK_DisabledEverything, // Remark disabled via '-Rno-everything'. + RK_WithPattern, // Remark pattern specified via '-Rgroup=regexp'. + }; + + /// Optimization remark with an optional regular expression pattern. + struct OptRemark { + RemarkKind Kind; + std::string Pattern; + std::shared_ptr<llvm::Regex> Regex; + + /// By default, optimization remark is missing. + OptRemark() : Kind(RK_Missing), Pattern(""), Regex(nullptr) {} + + /// Returns true iff the optimization remark holds a valid regular + /// expression. + bool hasValidPattern() const { return Regex != nullptr; } + + /// Matches the given string against the regex, if there is some. + bool patternMatches(StringRef String) const { + return hasValidPattern() && Regex->match(String); + } + }; + + /// Selected optimizations for which we should enable optimization remarks. + /// Transformation passes whose name matches the contained (optional) regular + /// expression (and support this feature), will emit a diagnostic whenever + /// they perform a transformation. + OptRemark OptimizationRemark; + + /// Selected optimizations for which we should enable missed optimization + /// remarks. Transformation passes whose name matches the contained (optional) + /// regular expression (and support this feature), will emit a diagnostic + /// whenever they tried but failed to perform a transformation. + OptRemark OptimizationRemarkMissed; + + /// Selected optimizations for which we should enable optimization analyses. + /// Transformation passes whose name matches the contained (optional) regular + /// expression (and support this feature), will emit a diagnostic whenever + /// they want to explain why they decided to apply or not apply a given + /// transformation. + OptRemark OptimizationRemarkAnalysis; /// Set of files defining the rules for the symbol rewriting. std::vector<std::string> RewriteMapFiles; @@ -341,14 +364,21 @@ public: /// other styles we may implement in the future. std::string StackProtectorGuard; - /// The TLS base register when StackProtectorGuard is "tls". + /// The TLS base register when StackProtectorGuard is "tls", or register used + /// to store the stack canary for "sysreg". /// On x86 this can be "fs" or "gs". + /// On AArch64 this can only be "sp_el0". std::string StackProtectorGuardReg; - /// Path to blocklist file specifying which objects + /// Path to ignorelist file specifying which objects /// (files, functions) listed for instrumentation by sanitizer /// coverage pass should actually not be instrumented. - std::vector<std::string> SanitizeCoverageBlocklistFiles; + std::vector<std::string> SanitizeCoverageIgnorelistFiles; + + /// Name of the stack usage file (i.e., .su file) if user passes + /// -fstack-usage. If empty, it can be implied that -fstack-usage is not + /// passed on the command line. + std::string StackUsageOutput; /// Executable and command-line used to create a given CompilerInvocation. /// Most of the time this will be the full -cc1 command. @@ -380,10 +410,6 @@ public: CodeGenOptions(); - /// Is this a libc/libm function that is no longer recognized as a - /// builtin because a -fno-builtin-* option has been specified? - bool isNoBuiltinFunc(const char *Name) const; - const std::vector<std::string> &getNoBuiltinFuncs() const { return NoBuiltinFuncs; } @@ -426,6 +452,12 @@ public: bool hasMaybeUnusedDebugInfo() const { return getDebugInfo() >= codegenoptions::UnusedTypeInfo; } + + // Check if any one of SanitizeCoverage* is enabled. + bool hasSanitizeCoverage() const { + return SanitizeCoverageType || SanitizeCoverageIndirectCalls || + SanitizeCoverageTraceCmp; + } }; } // end namespace clang diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h index b3a2e99fe931..aa12724cbf0c 100644 --- a/clang/include/clang/Basic/Cuda.h +++ b/clang/include/clang/Basic/Cuda.h @@ -29,7 +29,9 @@ enum class CudaVersion { CUDA_101, CUDA_102, CUDA_110, - LATEST = CUDA_110, + CUDA_111, + CUDA_112, + LATEST = CUDA_112, LATEST_SUPPORTED = CUDA_101, }; const char *CudaVersionToString(CudaVersion V); @@ -55,6 +57,7 @@ enum class CudaArch { SM_72, SM_75, SM_80, + SM_86, GFX600, GFX601, GFX602, @@ -75,14 +78,18 @@ enum class CudaArch { GFX906, GFX908, GFX909, + GFX90a, GFX90c, GFX1010, GFX1011, GFX1012, + GFX1013, GFX1030, GFX1031, GFX1032, GFX1033, + GFX1034, + GFX1035, LAST, }; diff --git a/clang/include/clang/Basic/DarwinSDKInfo.h b/clang/include/clang/Basic/DarwinSDKInfo.h new file mode 100644 index 000000000000..918dc7c8becc --- /dev/null +++ b/clang/include/clang/Basic/DarwinSDKInfo.h @@ -0,0 +1,157 @@ +//===--- DarwinSDKInfo.h - SDK Information parser for darwin ----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_BASIC_DARWIN_SDK_INFO_H +#define LLVM_CLANG_BASIC_DARWIN_SDK_INFO_H + +#include "clang/Basic/LLVM.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/Triple.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/VersionTuple.h" +#include "llvm/Support/VirtualFileSystem.h" + +namespace llvm { +namespace json { +class Object; +} // end namespace json +} // end namespace llvm + +namespace clang { + +/// The information about the darwin SDK that was used during this compilation. +class DarwinSDKInfo { +public: + /// A value that describes two os-environment pairs that can be used as a key + /// to the version map in the SDK. + struct OSEnvPair { + public: + using StorageType = uint64_t; + + constexpr OSEnvPair(llvm::Triple::OSType FromOS, + llvm::Triple::EnvironmentType FromEnv, + llvm::Triple::OSType ToOS, + llvm::Triple::EnvironmentType ToEnv) + : Value(((StorageType(FromOS) * StorageType(llvm::Triple::LastOSType) + + StorageType(FromEnv)) + << 32ull) | + (StorageType(ToOS) * StorageType(llvm::Triple::LastOSType) + + StorageType(ToEnv))) {} + + /// Returns the os-environment mapping pair that's used to represent the + /// macOS -> Mac Catalyst version mapping. + static inline constexpr OSEnvPair macOStoMacCatalystPair() { + return OSEnvPair(llvm::Triple::MacOSX, llvm::Triple::UnknownEnvironment, + llvm::Triple::IOS, llvm::Triple::MacABI); + } + + /// Returns the os-environment mapping pair that's used to represent the + /// Mac Catalyst -> macOS version mapping. + static inline constexpr OSEnvPair macCatalystToMacOSPair() { + return OSEnvPair(llvm::Triple::IOS, llvm::Triple::MacABI, + llvm::Triple::MacOSX, llvm::Triple::UnknownEnvironment); + } + + private: + StorageType Value; + + friend class DarwinSDKInfo; + }; + + /// Represents a version mapping that maps from a version of one target to a + /// version of a related target. + /// + /// e.g. "macOS_iOSMac":{"10.15":"13.1"} is an example of a macOS -> Mac + /// Catalyst version map. + class RelatedTargetVersionMapping { + public: + RelatedTargetVersionMapping( + VersionTuple MinimumKeyVersion, VersionTuple MaximumKeyVersion, + VersionTuple MinimumValue, VersionTuple MaximumValue, + llvm::DenseMap<VersionTuple, VersionTuple> Mapping) + : MinimumKeyVersion(MinimumKeyVersion), + MaximumKeyVersion(MaximumKeyVersion), MinimumValue(MinimumValue), + MaximumValue(MaximumValue), Mapping(Mapping) { + assert(!this->Mapping.empty() && "unexpected empty mapping"); + } + + /// Returns the value with the lowest version in the mapping. + const VersionTuple &getMinimumValue() const { return MinimumValue; } + + /// Returns the mapped key, or the appropriate Minimum / MaximumValue if + /// they key is outside of the mapping bounds. If they key isn't mapped, but + /// within the minimum and maximum bounds, None is returned. + Optional<VersionTuple> map(const VersionTuple &Key, + const VersionTuple &MinimumValue, + Optional<VersionTuple> MaximumValue) const; + + static Optional<RelatedTargetVersionMapping> + parseJSON(const llvm::json::Object &Obj, + VersionTuple MaximumDeploymentTarget); + + private: + VersionTuple MinimumKeyVersion; + VersionTuple MaximumKeyVersion; + VersionTuple MinimumValue; + VersionTuple MaximumValue; + llvm::DenseMap<VersionTuple, VersionTuple> Mapping; + }; + + DarwinSDKInfo(VersionTuple Version, VersionTuple MaximumDeploymentTarget, + llvm::DenseMap<OSEnvPair::StorageType, + Optional<RelatedTargetVersionMapping>> + VersionMappings = + llvm::DenseMap<OSEnvPair::StorageType, + Optional<RelatedTargetVersionMapping>>()) + : Version(Version), MaximumDeploymentTarget(MaximumDeploymentTarget), + VersionMappings(std::move(VersionMappings)) {} + + const llvm::VersionTuple &getVersion() const { return Version; } + + // Returns the optional, target-specific version mapping that maps from one + // target to another target. + // + // This mapping is constructed from an appropriate mapping in the SDKSettings, + // for instance, when building for Mac Catalyst, the mapping would contain the + // "macOS_iOSMac" mapping as it maps the macOS versions to the Mac Catalyst + // versions. + // + // This mapping does not exist when the target doesn't have an appropriate + // related version mapping, or when there was an error reading the mapping + // from the SDKSettings, or when it's missing in the SDKSettings. + const RelatedTargetVersionMapping *getVersionMapping(OSEnvPair Kind) const { + auto Mapping = VersionMappings.find(Kind.Value); + if (Mapping == VersionMappings.end()) + return nullptr; + return Mapping->getSecond().hasValue() ? Mapping->getSecond().getPointer() + : nullptr; + } + + static Optional<DarwinSDKInfo> + parseDarwinSDKSettingsJSON(const llvm::json::Object *Obj); + +private: + VersionTuple Version; + VersionTuple MaximumDeploymentTarget; + // Need to wrap the value in an optional here as the value has to be default + // constructible, and std::unique_ptr doesn't like DarwinSDKInfo being + // Optional as Optional is trying to copy it in emplace. + llvm::DenseMap<OSEnvPair::StorageType, Optional<RelatedTargetVersionMapping>> + VersionMappings; +}; + +/// Parse the SDK information from the SDKSettings.json file. +/// +/// \returns an error if the SDKSettings.json file is invalid, None if the +/// SDK has no SDKSettings.json, or a valid \c DarwinSDKInfo otherwise. +Expected<Optional<DarwinSDKInfo>> parseDarwinSDKInfo(llvm::vfs::FileSystem &VFS, + StringRef SDKRootPath); + +} // end namespace clang + +#endif // LLVM_CLANG_BASIC_DARWIN_SDK_INFO_H diff --git a/clang/include/clang/Basic/DebugInfoOptions.h b/clang/include/clang/Basic/DebugInfoOptions.h index 7f5669c1760f..c1259d7797db 100644 --- a/clang/include/clang/Basic/DebugInfoOptions.h +++ b/clang/include/clang/Basic/DebugInfoOptions.h @@ -37,6 +37,7 @@ enum DebugInfoKind { /// Limit generated debug info for classes to reduce size. This emits class /// type info only where the constructor is emitted, if it is a class that /// has a constructor. + /// FIXME: Consider combining this with LimitedDebugInfo. DebugInfoConstructor, /// Limit generated debug info to reduce size (-fno-standalone-debug). This diff --git a/clang/include/clang/Basic/DeclNodes.td b/clang/include/clang/Basic/DeclNodes.td index 4771a3549426..f8ad6cf5b262 100644 --- a/clang/include/clang/Basic/DeclNodes.td +++ b/clang/include/clang/Basic/DeclNodes.td @@ -71,10 +71,13 @@ def Named : DeclNode<Decl, "named declarations", 1>; def TemplateTemplateParm : DeclNode<Template>; def BuiltinTemplate : DeclNode<Template>; def Concept : DeclNode<Template>; - def Using : DeclNode<Named>; + def BaseUsing : DeclNode<Named, "", 1>; + def Using : DeclNode<BaseUsing>; + def UsingEnum : DeclNode<BaseUsing>; def UsingPack : DeclNode<Named>; def UsingShadow : DeclNode<Named>; def ConstructorUsingShadow : DeclNode<UsingShadow>; + def UnresolvedUsingIfExists : DeclNode<Named>; def ObjCMethod : DeclNode<Named, "Objective-C methods">, DeclContext; def ObjCContainer : DeclNode<Named, "Objective-C containers", 1>, DeclContext; def ObjCCategory : DeclNode<ObjCContainer>; diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h index 3499c551cfdf..3b915fb15a89 100644 --- a/clang/include/clang/Basic/Diagnostic.h +++ b/clang/include/clang/Basic/Diagnostic.h @@ -273,6 +273,13 @@ private: // Which overload candidates to show. OverloadsShown ShowOverloads = Ovl_All; + // With Ovl_Best, the number of overload candidates to show when we encounter + // an error. + // + // The value here is the number of candidates to show in the first nontrivial + // error. Future errors may show a different number of candidates. + unsigned NumOverloadsToShow = 32; + // Cap of # errors emitted, 0 -> no limit. unsigned ErrorLimit = 0; @@ -707,6 +714,37 @@ public: } OverloadsShown getShowOverloads() const { return ShowOverloads; } + /// When a call or operator fails, print out up to this many candidate + /// overloads as suggestions. + /// + /// With Ovl_Best, we set a high limit for the first nontrivial overload set + /// we print, and a lower limit for later sets. This way the user has a + /// chance of diagnosing at least one callsite in their program without + /// having to recompile with -fshow-overloads=all. + unsigned getNumOverloadCandidatesToShow() const { + switch (getShowOverloads()) { + case Ovl_All: + // INT_MAX rather than UINT_MAX so that we don't have to think about the + // effect of implicit conversions on this value. In practice we'll never + // hit 2^31 candidates anyway. + return std::numeric_limits<int>::max(); + case Ovl_Best: + return NumOverloadsToShow; + } + llvm_unreachable("invalid OverloadsShown kind"); + } + + /// Call this after showing N overload candidates. This influences the value + /// returned by later calls to getNumOverloadCandidatesToShow(). + void overloadCandidatesShown(unsigned N) { + // Current heuristic: Start out with a large value for NumOverloadsToShow, + // and then once we print one nontrivially-large overload set, decrease it + // for future calls. + if (N > 4) { + NumOverloadsToShow = 4; + } + } + /// Pretend that the last diagnostic issued was ignored, so any /// subsequent notes will be suppressed, or restore a prior ignoring /// state after ignoring some diagnostics and their notes, possibly in @@ -806,6 +844,7 @@ public: return FatalErrorOccurred || UnrecoverableErrorOccurred; } + unsigned getNumErrors() const { return NumErrors; } unsigned getNumWarnings() const { return NumWarnings; } void setNumWarnings(unsigned NumWarnings) { diff --git a/clang/include/clang/Basic/DiagnosticASTKinds.td b/clang/include/clang/Basic/DiagnosticASTKinds.td index f6b936f5ccd9..496d86ee2fe7 100644 --- a/clang/include/clang/Basic/DiagnosticASTKinds.td +++ b/clang/include/clang/Basic/DiagnosticASTKinds.td @@ -349,6 +349,8 @@ def note_constexpr_new_delete_mismatch : Note< "used to delete pointer to " "%select{array object of type %2|non-array object of type %2|" "object allocated with 'new'}0}1">; +def note_constexpr_deallocate_null : Note< + "'std::allocator<...>::deallocate' used to delete a null pointer">; def note_constexpr_delete_subobject : Note< "delete of pointer%select{ to subobject|}1 '%0' " "%select{|that does not point to complete object}1">; diff --git a/clang/include/clang/Basic/DiagnosticCategories.td b/clang/include/clang/Basic/DiagnosticCategories.td index d7203173790e..fb6bdd710741 100644 --- a/clang/include/clang/Basic/DiagnosticCategories.td +++ b/clang/include/clang/Basic/DiagnosticCategories.td @@ -7,4 +7,5 @@ //===----------------------------------------------------------------------===// class CatInlineAsm : DiagCategory<"Inline Assembly Issue">; +class CatSourceMgr : DiagCategory<"SourceMgr Reported Issue">; class CatBackend : DiagCategory<"Backend Issue">; diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td index a4f96a97991e..4dff3379ed35 100644 --- a/clang/include/clang/Basic/DiagnosticCommonKinds.td +++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td @@ -111,6 +111,8 @@ def err_module_cycle : Error<"cyclic dependency in module '%0': %1">, DefaultFatal; def err_module_prebuilt : Error< "error in loading module '%0' from prebuilt module path">, DefaultFatal; +def err_module_rebuild_finalized : Error< + "cannot rebuild module '%0' as it is already finalized">, DefaultFatal; def note_pragma_entered_here : Note<"#pragma entered here">; def note_decl_hiding_tag_type : Note< "%1 %0 is hidden by a non-type declaration of %0 here">; @@ -187,6 +189,17 @@ def ext_cxx11_longlong : Extension< def warn_cxx98_compat_longlong : Warning< "'long long' is incompatible with C++98">, InGroup<CXX98CompatPedantic>, DefaultIgnore; +def ext_cxx2b_size_t_suffix : ExtWarn< + "'size_t' suffix for literals is a C++2b extension">, + InGroup<CXX2b>; +def warn_cxx20_compat_size_t_suffix : Warning< + "'size_t' suffix for literals is incompatible with C++ standards before " + "C++2b">, InGroup<CXXPre2bCompat>, DefaultIgnore; +def err_cxx2b_size_t_suffix: Error< + "'size_t' suffix for literals is a C++2b feature">; +def err_size_t_literal_too_large: Error< + "%select{signed |}0'size_t' literal is out of range of possible " + "%select{signed |}0'size_t' values">; def err_integer_literal_too_large : Error< "integer literal is too large to be represented in any %select{signed |}0" "integer type">; @@ -336,6 +349,8 @@ def warn_ignored_hip_only_option : Warning< // OpenMP def err_omp_more_one_clause : Error< "directive '#pragma omp %0' cannot contain more than one '%1' clause%select{| with '%3' name modifier| with 'source' dependence}2">; +def err_omp_required_clause : Error< + "directive '#pragma omp %0' requires the '%1' clause">; // Static Analyzer Core def err_unknown_analyzer_checker_or_package : Error< @@ -347,4 +362,13 @@ def note_suggest_disabling_all_checkers : Note< def warn_poison_system_directories : Warning < "include location '%0' is unsafe for cross-compilation">, InGroup<DiagGroup<"poison-system-directories">>, DefaultIgnore; + +def warn_opencl_unsupported_core_feature : Warning< + "%0 is a core feature in %select{OpenCL C|C++ for OpenCL}1 version %2 but not supported on this target">, + InGroup<OpenCLCoreFeaturesDiagGroup>, DefaultIgnore; + +def err_opencl_extension_and_feature_differs : Error< + "options %0 and %1 are set to different values">; +def err_opencl_feature_requires : Error< + "feature %0 requires support of %1 feature">; } diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index ad13f923fb63..3b4daa59f66b 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -67,6 +67,8 @@ def err_drv_no_hip_runtime : Error< "cannot find HIP runtime. Provide its path via --rocm-path, or pass " "-nogpuinc to build without HIP runtime.">; +def err_drv_undetermined_amdgpu_arch : Error< + "Cannot determine AMDGPU architecture: %0. Consider passing it via --march.">; def err_drv_cuda_version_unsupported : Error< "GPU arch %0 is supported by CUDA versions between %1 and %2 (inclusive), " "but installation at %3 is %4. Use --cuda-path to specify a different CUDA " @@ -127,6 +129,10 @@ def err_drv_invalid_Xopenmp_target_with_args : Error< "invalid -Xopenmp-target argument: '%0', options requiring arguments are unsupported">; def err_drv_argument_only_allowed_with : Error< "invalid argument '%0' only allowed with '%1'">; +def err_drv_minws_unsupported_input_type : Error< + "'-fminimize-whitespace' invalid for input of type %0">; +def err_drv_amdgpu_ieee_without_no_honor_nans : Error< + "invalid argument '-mno-amdgpu-ieee' only allowed with relaxed NaN handling">; def err_drv_argument_not_allowed_with : Error< "invalid argument '%0' not allowed with '%1'">; def err_drv_invalid_version_number : Error< @@ -163,12 +169,12 @@ def err_drv_invalid_libcxx_deployment : Error< "invalid deployment target for -stdlib=libc++ (requires %0 or later)">; def err_drv_invalid_argument_to_option : Error< "invalid argument '%0' to -%1">; -def err_drv_malformed_sanitizer_blacklist : Error< - "malformed sanitizer blacklist: '%0'">; +def err_drv_malformed_sanitizer_ignorelist : Error< + "malformed sanitizer ignorelist: '%0'">; def err_drv_malformed_sanitizer_coverage_whitelist : Error< "malformed sanitizer coverage whitelist: '%0'">; -def err_drv_malformed_sanitizer_coverage_blacklist : Error< - "malformed sanitizer coverage blacklist: '%0'">; +def err_drv_malformed_sanitizer_coverage_ignorelist : Error< + "malformed sanitizer coverage ignorelist: '%0'">; def err_drv_duplicate_config : Error< "no more than one option '--config' is allowed">; def err_drv_config_file_not_exist : Error< @@ -210,12 +216,10 @@ def warn_drv_yc_multiple_inputs_clang_cl : Warning< "support for '/Yc' with more than one source file not implemented yet; flag ignored">, InGroup<ClangClPch>; -def err_drv_dllexport_inlines_and_fallback : Error< - "option '/Zc:dllexportInlines-' is ABI-changing and not compatible with '/fallback'">; - def err_drv_invalid_value : Error<"invalid value '%1' in '%0'">; def err_drv_invalid_int_value : Error<"invalid integral value '%1' in '%0'">; -def err_drv_invalid_value_with_suggestion : Error<"invalid value '%1' in '%0','%2'">; +def err_drv_invalid_value_with_suggestion : Error< + "invalid value '%1' in '%0', expected one of: %2">; def err_drv_invalid_remap_file : Error< "invalid option '%0' not of the form <from-file>;<to-file>">; def err_drv_invalid_gcc_output_type : Error< @@ -229,6 +233,8 @@ def warn_invalid_ios_deployment_target : Warning< "invalid iOS deployment version '%0', iOS 10 is the maximum deployment " "target for 32-bit targets">, InGroup<InvalidIOSDeploymentTarget>, DefaultError; +def err_invalid_macos_32bit_deployment_target : Error< + "32-bit targets are not supported when building for Mac Catalyst">; def err_drv_conflicting_deployment_targets : Error< "conflicting deployment targets, both '%0' and '%1' are present in environment">; def err_arc_unsupported_on_runtime : Error< @@ -264,8 +270,9 @@ def err_drv_omp_host_target_not_supported : Error< def err_drv_expecting_fopenmp_with_fopenmp_targets : Error< "The option -fopenmp-targets must be used in conjunction with a -fopenmp option compatible with offloading, please use -fopenmp=libomp or -fopenmp=libiomp5.">; def err_drv_omp_offload_target_missingbcruntime : Error< - "No library '%0' found in the default clang lib directory or in LIBRARY_PATH. Please use --libomptarget-nvptx-bc-path to specify nvptx bitcode library.">; + "No library '%0' found in the default clang lib directory or in LIBRARY_PATH. Please use --libomptarget-%1-bc-path to specify %1 bitcode library.">; def err_drv_omp_offload_target_bcruntime_not_found : Error<"Bitcode library '%0' does not exist.">; +def err_drv_omp_offload_target_cuda_version_not_support : Error<"NVPTX target requires CUDA 9.2 or above. CUDA %0 is detected.">; def warn_drv_omp_offload_target_duplicate : Warning< "The OpenMP offloading target '%0' is similar to target '%1' already specified - will be ignored.">, InGroup<OpenMPTarget>; @@ -273,6 +280,10 @@ def err_drv_unsupported_embed_bitcode : Error<"%0 is not supported with -fembed-bitcode">; def err_drv_bitcode_unsupported_on_toolchain : Error< "-fembed-bitcode is not supported on versions of iOS prior to 6.0">; +def err_drv_negative_columns : Error< + "invalid value '%1' in '%0', value must be 'none' or a positive integer">; +def err_drv_small_columns : Error< + "invalid value '%1' in '%0', value must be '%2' or greater">; def err_drv_invalid_malign_branch_EQ : Error< "invalid argument '%0' to -malign-branch=; each element must be one of: %1">; @@ -344,6 +355,10 @@ def warn_drv_disabling_vptr_no_rtti_default : Warning< def warn_drv_object_size_disabled_O0 : Warning< "the object size sanitizer has no effect at -O0, but is explicitly enabled: %0">, InGroup<InvalidCommandLineArgument>, DefaultWarnNoWerror; +def warn_ignoring_verify_debuginfo_preserve_export : Warning< + "ignoring -fverify-debuginfo-preserve-export=%0 because " + "-fverify-debuginfo-preserve wasn't enabled">, + InGroup<UnusedCommandLineArgument>; def err_invalid_branch_protection: Error < "invalid branch protection option '%0' in '%1'">; def err_invalid_sls_hardening : Error< @@ -392,9 +407,6 @@ def err_test_module_file_extension_format : Error< "-ftest-module-file-extension argument '%0' is not of the required form " "'blockname:major:minor:hashed:user info'">; -def warn_drv_invoking_fallback : Warning<"falling back to %0">, - InGroup<Fallback>; - def warn_slash_u_filename : Warning<"'/U%0' treated as the '/U' option">, InGroup<DiagGroup<"slash-u-filename">>; def note_use_dashdash : Note<"Use '--' to treat subsequent arguments as filenames">; @@ -534,6 +546,15 @@ def err_drv_cannot_mix_options : Error<"cannot specify '%1' along with '%0'">; def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not recognized and is not a valid setting.">; -def err_aix_default_altivec_abi : Error< - "The default Altivec ABI on AIX is not yet supported, use '-mabi=vec-extabi' for the extended Altivec ABI">; +def err_aix_unsupported_tls_model : Error<"TLS model '%0' is not yet supported on AIX">; + +def err_invalid_cxx_abi : Error<"Invalid C++ ABI name '%0'">; +def err_unsupported_cxx_abi : Error<"C++ ABI '%0' is not supported on target triple '%1'">; + +def note_cc1_round_trip_original : Note<"Original arguments in round-trip: %0">; +def note_cc1_round_trip_generated : Note<"Generated arguments #%0 in round-trip: %1">; +def remark_cc1_round_trip_generated : Remark<"Generated arguments #%0 in round-trip: %1">, InGroup<RoundTripCC1Args>; +def err_cc1_round_trip_fail_then_ok : Error<"Original arguments parse failed, then succeeded in round-trip">; +def err_cc1_round_trip_ok_then_fail : Error<"Generated arguments parse failed in round-trip">; +def err_cc1_round_trip_mismatch : Error<"Generated arguments do not match in round-trip">; } diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td index b9f8c78e43da..0f4ccec38550 100644 --- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -19,13 +19,16 @@ def err_fe_inline_asm : Error<"%0">, CatInlineAsm; def warn_fe_inline_asm : Warning<"%0">, CatInlineAsm, InGroup<BackendInlineAsm>; def note_fe_inline_asm : Note<"%0">, CatInlineAsm; def note_fe_inline_asm_here : Note<"instantiated into assembly here">; +def err_fe_source_mgr : Error<"%0">, CatSourceMgr; +def warn_fe_source_mgr : Warning<"%0">, CatSourceMgr, InGroup<BackendSourceMgr>; +def note_fe_source_mgr : Note<"%0">, CatSourceMgr; def err_fe_cannot_link_module : Error<"cannot link module '%0': %1">, DefaultFatal; -def warn_fe_frame_larger_than : Warning<"stack frame size of %0 bytes in %q1">, - BackendInfo, InGroup<BackendFrameLargerThanEQ>; +def warn_fe_frame_larger_than : Warning<"stack frame size (%0) exceeds limit (%1) in %q2">, + BackendInfo, InGroup<BackendFrameLargerThan>; def warn_fe_backend_frame_larger_than: Warning<"%0">, - BackendInfo, InGroup<BackendFrameLargerThanEQ>; + BackendInfo, InGroup<BackendFrameLargerThan>; def err_fe_backend_frame_larger_than: Error<"%0">, BackendInfo; def note_fe_backend_frame_larger_than: Note<"%0">, BackendInfo; @@ -109,7 +112,7 @@ def err_fe_action_not_available : Error< def err_fe_invalid_alignment : Error< "invalid value '%1' in '%0'; alignment must be a power of 2">; def err_fe_invalid_exception_model - : Error<"invalid exception model '%select{none|dwarf|sjlj|arm|seh|wasm|aix}0' for target '%1'">; + : Error<"invalid exception model '%select{none|sjlj|seh|dwarf|wasm}0' for target '%1'">; def warn_fe_concepts_ts_flag : Warning< "-fconcepts-ts is deprecated - use '-std=c++20' for Concepts support">, InGroup<Deprecated>; @@ -155,6 +158,8 @@ def err_verify_invalid_no_diags : Error< "%select{'expected-no-diagnostics' directive|other expected directives}0">; def err_verify_no_directives : Error< "no expected directives found: consider use of 'expected-no-diagnostics'">; +def err_verify_nonconst_addrspace : Error< + "qualifier 'const' is needed for variables in address space '%0'">; def note_fixit_applied : Note<"FIX-IT applied suggested code changes">; def note_fixit_in_macro : Note< diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 04ba89aa457e..4b4928a7a00e 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -162,8 +162,12 @@ def CXX11CompatDeprecatedWritableStr : def DeprecatedArrayCompare : DiagGroup<"deprecated-array-compare">; def DeprecatedAttributes : DiagGroup<"deprecated-attributes">; def DeprecatedCommaSubscript : DiagGroup<"deprecated-comma-subscript">; -def DeprecatedCopy : DiagGroup<"deprecated-copy">; -def DeprecatedCopyDtor : DiagGroup<"deprecated-copy-dtor">; +def DeprecatedCopyWithUserProvidedCopy : DiagGroup<"deprecated-copy-with-user-provided-copy">; +def DeprecatedCopyWithUserProvidedDtor : DiagGroup<"deprecated-copy-with-user-provided-dtor">; +def DeprecatedCopy : DiagGroup<"deprecated-copy", [DeprecatedCopyWithUserProvidedCopy]>; +def DeprecatedCopyWithDtor : DiagGroup<"deprecated-copy-with-dtor", [DeprecatedCopyWithUserProvidedDtor]>; +// For compatibility with GCC. +def : DiagGroup<"deprecated-copy-dtor", [DeprecatedCopyWithDtor]>; def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">; def UnavailableDeclarations : DiagGroup<"unavailable-declarations">; def UnguardedAvailabilityNew : DiagGroup<"unguarded-availability-new">; @@ -186,7 +190,7 @@ def Deprecated : DiagGroup<"deprecated", [DeprecatedAnonEnumEnumConversion, DeprecatedAttributes, DeprecatedCommaSubscript, DeprecatedCopy, - DeprecatedCopyDtor, + DeprecatedCopyWithDtor, DeprecatedDeclarations, DeprecatedDynamicExceptionSpec, DeprecatedEnumCompare, @@ -253,17 +257,33 @@ def : DiagGroup<"c++1z-compat-mangling", [CXX17CompatMangling]>; // Name of this warning in GCC. def NoexceptType : DiagGroup<"noexcept-type", [CXX17CompatMangling]>; -// Warnings for C++1y code which is not compatible with prior C++ standards. -def CXXPre14Compat : DiagGroup<"c++98-c++11-compat">; -def CXXPre14CompatPedantic : DiagGroup<"c++98-c++11-compat-pedantic", +// Warnings for C code which is not compatible with previous C standards. +def CPre2xCompat : DiagGroup<"pre-c2x-compat">; +def CPre2xCompatPedantic : DiagGroup<"pre-c2x-compat-pedantic", + [CPre2xCompat]>; + +// Warnings for C++ code which is not compatible with previous C++ standards. +def CXXPre14Compat : DiagGroup<"pre-c++14-compat">; +def : DiagGroup<"c++98-c++11-compat", [CXXPre14Compat]>; +def CXXPre14CompatPedantic : DiagGroup<"pre-c++14-compat-pedantic", [CXXPre14Compat, CXXPre14CompatBinaryLiteral]>; -def CXXPre17Compat : DiagGroup<"c++98-c++11-c++14-compat">; -def CXXPre17CompatPedantic : DiagGroup<"c++98-c++11-c++14-compat-pedantic", +def : DiagGroup<"c++98-c++11-compat-pedantic", [CXXPre14CompatPedantic]>; +def CXXPre17Compat : DiagGroup<"pre-c++17-compat">; +def : DiagGroup<"c++98-c++11-c++14-compat", [CXXPre17Compat]>; +def CXXPre17CompatPedantic : DiagGroup<"pre-c++17-compat-pedantic", [CXXPre17Compat]>; -def CXXPre20Compat : DiagGroup<"c++98-c++11-c++14-c++17-compat">; -def CXXPre20CompatPedantic : DiagGroup<"c++98-c++11-c++14-c++17-compat-pedantic", +def : DiagGroup<"c++98-c++11-c++14-compat-pedantic", + [CXXPre17CompatPedantic]>; +def CXXPre20Compat : DiagGroup<"pre-c++20-compat">; +def : DiagGroup<"c++98-c++11-c++14-c++17-compat", [CXXPre20Compat]>; +def CXXPre20CompatPedantic : DiagGroup<"pre-c++20-compat-pedantic", [CXXPre20Compat]>; +def : DiagGroup<"c++98-c++11-c++14-c++17-compat-pedantic", + [CXXPre20CompatPedantic]>; +def CXXPre2bCompat : DiagGroup<"pre-c++2b-compat">; +def CXXPre2bCompatPedantic : + DiagGroup<"pre-c++2b-compat-pedantic", [CXXPre2bCompat]>; def CXX98CompatBindToTemporaryCopy : DiagGroup<"c++98-compat-bind-to-temporary-copy">; @@ -277,7 +297,8 @@ def CXX98Compat : DiagGroup<"c++98-compat", CXX98CompatUnnamedTypeTemplateArgs, CXXPre14Compat, CXXPre17Compat, - CXXPre20Compat]>; + CXXPre20Compat, + CXXPre2bCompat]>; // Warnings for C++11 features which are Extensions in C++98 mode. def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic", [CXX98Compat, @@ -285,7 +306,8 @@ def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic", CXX98CompatExtraSemi, CXXPre14CompatPedantic, CXXPre17CompatPedantic, - CXXPre20CompatPedantic]>; + CXXPre20CompatPedantic, + CXXPre2bCompatPedantic]>; def CXX11Narrowing : DiagGroup<"c++11-narrowing">; @@ -314,33 +336,40 @@ def CXX11Compat : DiagGroup<"c++11-compat", CXX11CompatDeprecatedWritableStr, CXXPre14Compat, CXXPre17Compat, - CXXPre20Compat]>; + CXXPre20Compat, + CXXPre2bCompat]>; def : DiagGroup<"c++0x-compat", [CXX11Compat]>; def CXX11CompatPedantic : DiagGroup<"c++11-compat-pedantic", [CXX11Compat, CXXPre14CompatPedantic, CXXPre17CompatPedantic, - CXXPre20CompatPedantic]>; + CXXPre20CompatPedantic, + CXXPre2bCompatPedantic]>; def CXX14Compat : DiagGroup<"c++14-compat", [CXXPre17Compat, - CXXPre20Compat]>; + CXXPre20Compat, + CXXPre2bCompat]>; def CXX14CompatPedantic : DiagGroup<"c++14-compat-pedantic", [CXX14Compat, CXXPre17CompatPedantic, - CXXPre20CompatPedantic]>; + CXXPre20CompatPedantic, + CXXPre2bCompatPedantic]>; def CXX17Compat : DiagGroup<"c++17-compat", [DeprecatedRegister, DeprecatedIncrementBool, CXX17CompatMangling, - CXXPre20Compat]>; + CXXPre20Compat, + CXXPre2bCompat]>; def CXX17CompatPedantic : DiagGroup<"c++17-compat-pedantic", [CXX17Compat, - CXXPre20CompatPedantic]>; + CXXPre20CompatPedantic, + CXXPre2bCompatPedantic]>; def : DiagGroup<"c++1z-compat", [CXX17Compat]>; -def CXX20Compat : DiagGroup<"c++20-compat">; +def CXX20Compat : DiagGroup<"c++20-compat", [CXXPre2bCompat]>; def CXX20CompatPedantic : DiagGroup<"c++20-compat-pedantic", - [CXX20Compat]>; + [CXX20Compat, + CXXPre2bCompatPedantic]>; def : DiagGroup<"c++2a-compat", [CXX20Compat]>; def : DiagGroup<"c++2a-compat-pedantic", [CXX20CompatPedantic]>; @@ -437,6 +466,7 @@ def ModuleBuild : DiagGroup<"module-build">; def ModuleImport : DiagGroup<"module-import">; def ModuleConflict : DiagGroup<"module-conflict">; def ModuleFileExtension : DiagGroup<"module-file-extension">; +def RoundTripCC1Args : DiagGroup<"round-trip-cc1-args">; def NewlineEOF : DiagGroup<"newline-eof">; def Nullability : DiagGroup<"nullability">; def NullabilityDeclSpec : DiagGroup<"nullability-declspec">; @@ -457,6 +487,7 @@ def ClassVarargs : DiagGroup<"class-varargs", [NonPODVarargs]>; def : DiagGroup<"nonportable-cfstrings">; def NonVirtualDtor : DiagGroup<"non-virtual-dtor">; def NullPointerArithmetic : DiagGroup<"null-pointer-arithmetic">; +def NullPointerSubtraction : DiagGroup<"null-pointer-subtraction">; def : DiagGroup<"effc++", [NonVirtualDtor]>; def OveralignedType : DiagGroup<"over-aligned">; def OldStyleCast : DiagGroup<"old-style-cast">; @@ -473,6 +504,7 @@ def PrivateExtern : DiagGroup<"private-extern">; def SelTypeCast : DiagGroup<"cast-of-sel-type">; def FunctionDefInObjCContainer : DiagGroup<"function-def-in-objc-container">; def BadFunctionCast : DiagGroup<"bad-function-cast">; +def CastFunctionType : DiagGroup<"cast-function-type">; def ObjCPropertyImpl : DiagGroup<"objc-property-implementation">; def ObjCPropertyNoAttribute : DiagGroup<"objc-property-no-attribute">; def ObjCPropertyAssignOnObjectType : DiagGroup<"objc-property-assign-on-object-type">; @@ -494,18 +526,17 @@ def OpenCLUnsupportedRGBA: DiagGroup<"opencl-unsupported-rgba">; def UnderalignedExceptionObject : DiagGroup<"underaligned-exception-object">; def DeprecatedObjCIsaUsage : DiagGroup<"deprecated-objc-isa-usage">; def ExplicitInitializeCall : DiagGroup<"explicit-initialize-call">; +def OrderedCompareFunctionPointers : DiagGroup<"ordered-compare-function-pointers">; def Packed : DiagGroup<"packed">; def Padded : DiagGroup<"padded">; def PessimizingMove : DiagGroup<"pessimizing-move">; -def ReturnStdMoveInCXX11 : DiagGroup<"return-std-move-in-c++11">; def ReturnStdMove : DiagGroup<"return-std-move">; def PointerArith : DiagGroup<"pointer-arith">; def PoundWarning : DiagGroup<"#warnings">; def PoundPragmaMessage : DiagGroup<"#pragma-messages">, DiagCategory<"#pragma message Directive">; -def : DiagGroup<"pointer-to-int-cast">; def : DiagGroup<"redundant-decls">; def RedeclaredClassMember : DiagGroup<"redeclared-class-member">; def GNURedeclaredEnum : DiagGroup<"gnu-redeclared-enum">; @@ -540,7 +571,6 @@ def ShadowAll : DiagGroup<"shadow-all", [Shadow, ShadowFieldInConstructor, def Shorten64To32 : DiagGroup<"shorten-64-to-32">; def : DiagGroup<"sign-promo">; def SignCompare : DiagGroup<"sign-compare">; -def : DiagGroup<"stack-protector">; def : DiagGroup<"switch-default">; def : DiagGroup<"synth">; def SizeofArrayArgument : DiagGroup<"sizeof-array-argument">; @@ -567,11 +597,13 @@ def SwiftNameAttribute : DiagGroup<"swift-name-attribute">; def IntInBoolContext : DiagGroup<"int-in-bool-context">; def TautologicalTypeLimitCompare : DiagGroup<"tautological-type-limit-compare">; def TautologicalUnsignedZeroCompare : DiagGroup<"tautological-unsigned-zero-compare">; +def TautologicalUnsignedCharZeroCompare : DiagGroup<"tautological-unsigned-char-zero-compare">; def TautologicalUnsignedEnumZeroCompare : DiagGroup<"tautological-unsigned-enum-zero-compare">; // For compatibility with GCC. Tautological comparison warnings for constants // that are an extremal value of the type. def TypeLimits : DiagGroup<"type-limits", [TautologicalTypeLimitCompare, TautologicalUnsignedZeroCompare, + TautologicalUnsignedCharZeroCompare, TautologicalUnsignedEnumZeroCompare]>; // Additional tautological comparison warnings based on the expression, not // only on its type. @@ -608,7 +640,8 @@ def : DiagGroup<"sequence-point", [Unsequenced]>; // Preprocessor warnings. def AmbiguousMacro : DiagGroup<"ambiguous-macro">; def KeywordAsMacro : DiagGroup<"keyword-macro">; -def ReservedIdAsMacro : DiagGroup<"reserved-id-macro">; +def ReservedIdAsMacro : DiagGroup<"reserved-macro-identifier">; +def ReservedIdAsMacroAlias : DiagGroup<"reserved-id-macro", [ReservedIdAsMacro]>; // Just silence warnings about -Wstrict-aliasing for now. def : DiagGroup<"strict-aliasing=0">; @@ -626,7 +659,6 @@ def : DiagGroup<"strict-overflow=5">; def : DiagGroup<"strict-overflow">; def InvalidOffsetof : DiagGroup<"invalid-offsetof">; -def : DiagGroup<"strict-prototypes">; def StrictSelector : DiagGroup<"strict-selector-match">; def MethodDuplicate : DiagGroup<"duplicate-method-match">; def ObjCCStringFormat : DiagGroup<"cstring-format-directive">; @@ -695,6 +727,7 @@ def UnusedMemberFunction : DiagGroup<"unused-member-function", def UnusedLabel : DiagGroup<"unused-label">; def UnusedLambdaCapture : DiagGroup<"unused-lambda-capture">; def UnusedParameter : DiagGroup<"unused-parameter">; +def UnusedButSetParameter : DiagGroup<"unused-but-set-parameter">; def UnusedResult : DiagGroup<"unused-result">; def PotentiallyEvaluatedExpression : DiagGroup<"potentially-evaluated-expression">; def UnevaluatedExpression : DiagGroup<"unevaluated-expression", @@ -704,6 +737,7 @@ def UnusedValue : DiagGroup<"unused-value", [UnusedComparison, UnusedResult, def UnusedConstVariable : DiagGroup<"unused-const-variable">; def UnusedVariable : DiagGroup<"unused-variable", [UnusedConstVariable]>; +def UnusedButSetVariable : DiagGroup<"unused-but-set-variable">; def UnusedLocalTypedef : DiagGroup<"unused-local-typedef">; def UnusedPropertyIvar : DiagGroup<"unused-property-ivar">; def UnusedGetterReturnValue : DiagGroup<"unused-getter-return-value">; @@ -752,7 +786,6 @@ def Visibility : DiagGroup<"visibility">; def ZeroLengthArray : DiagGroup<"zero-length-array">; def GNUZeroLineDirective : DiagGroup<"gnu-zero-line-directive">; def GNUZeroVariadicMacroArguments : DiagGroup<"gnu-zero-variadic-macro-arguments">; -def Fallback : DiagGroup<"fallback">; def MisleadingIndentation : DiagGroup<"misleading-indentation">; // This covers both the deprecated case (in C++98) @@ -773,6 +806,9 @@ def LargeByValueCopy : DiagGroup<"large-by-value-copy">; def DuplicateArgDecl : DiagGroup<"duplicate-method-arg">; def SignedEnumBitfield : DiagGroup<"signed-enum-bitfield">; +def ReservedIdentifier : DiagGroup<"reserved-identifier", + [ReservedIdAsMacro]>; + // Unreachable code warning groups. // // The goal is make -Wunreachable-code on by default, in -Wall, or at @@ -843,7 +879,7 @@ def Unused : DiagGroup<"unused", // UnusedMemberFunction, (clean-up llvm before enabling) UnusedPrivateField, UnusedLambdaCapture, UnusedLocalTypedef, UnusedValue, UnusedVariable, - UnusedPropertyIvar]>, + UnusedButSetVariable, UnusedPropertyIvar]>, DiagCategory<"Unused Entity Issue">; // Format settings. @@ -895,7 +931,9 @@ def Extra : DiagGroup<"extra", [ MissingMethodReturnType, SignCompare, UnusedParameter, + UnusedButSetParameter, NullPointerArithmetic, + NullPointerSubtraction, EmptyInitStatement, StringConcatation, FUseLdPath, @@ -1006,6 +1044,10 @@ def CXX17 : DiagGroup<"c++17-extensions">; // earlier C++ versions. def CXX20 : DiagGroup<"c++20-extensions", [CXX20Designator]>; +// A warning group for warnings about using C++2b features as extensions in +// earlier C++ versions. +def CXX2b : DiagGroup<"c++2b-extensions">; + def : DiagGroup<"c++0x-extensions", [CXX11]>; def : DiagGroup<"c++1y-extensions", [CXX14]>; def : DiagGroup<"c++1z-extensions", [CXX17]>; @@ -1043,6 +1085,9 @@ def GNU : DiagGroup<"gnu", [GNUAlignofExpression, GNUAnonymousStruct, // A warning group for warnings about code that clang accepts but gcc doesn't. def GccCompat : DiagGroup<"gcc-compat">; +// A warning group for warnings about code that may be incompatible on AIX. +def AIXCompat : DiagGroup<"aix-compat">; + // Warnings for Microsoft extensions. def MicrosoftCharize : DiagGroup<"microsoft-charize">; def MicrosoftDrectveSection : DiagGroup<"microsoft-drectve-section">; @@ -1050,6 +1095,7 @@ def MicrosoftInclude : DiagGroup<"microsoft-include">; def MicrosoftCppMacro : DiagGroup<"microsoft-cpp-macro">; def MicrosoftFixedEnum : DiagGroup<"microsoft-fixed-enum">; def MicrosoftSealed : DiagGroup<"microsoft-sealed">; +def MicrosoftAbstract : DiagGroup<"microsoft-abstract">; def MicrosoftUnqualifiedFriend : DiagGroup<"microsoft-unqualified-friend">; def MicrosoftExceptionSpec : DiagGroup<"microsoft-exception-spec">; def MicrosoftUsingDecl : DiagGroup<"microsoft-using-decl">; @@ -1078,6 +1124,8 @@ def MicrosoftAnonTag : DiagGroup<"microsoft-anon-tag">; def MicrosoftCommentPaste : DiagGroup<"microsoft-comment-paste">; def MicrosoftEndOfFile : DiagGroup<"microsoft-end-of-file">; def MicrosoftInaccessibleBase : DiagGroup<"microsoft-inaccessible-base">; +def MicrosoftStaticAssert : DiagGroup<"microsoft-static-assert">; + // Aliases. def : DiagGroup<"msvc-include", [MicrosoftInclude]>; // -Wmsvc-include = -Wmicrosoft-include @@ -1085,7 +1133,7 @@ def : DiagGroup<"msvc-include", [MicrosoftInclude]>; // Warnings group for warnings about Microsoft extensions. def Microsoft : DiagGroup<"microsoft", [MicrosoftCharize, MicrosoftDrectveSection, MicrosoftInclude, - MicrosoftCppMacro, MicrosoftFixedEnum, MicrosoftSealed, + MicrosoftCppMacro, MicrosoftFixedEnum, MicrosoftSealed, MicrosoftAbstract, MicrosoftUnqualifiedFriend, MicrosoftExceptionSpec, MicrosoftUsingDecl, MicrosoftMutableReference, MicrosoftPureDefinition, MicrosoftUnionMemberReference, MicrosoftExplicitConstructorCall, @@ -1093,7 +1141,7 @@ def Microsoft : DiagGroup<"microsoft", MicrosoftRedeclareStatic, MicrosoftEnumForwardReference, MicrosoftGoto, MicrosoftFlexibleArray, MicrosoftExtraQualification, MicrosoftCast, MicrosoftConstInit, MicrosoftVoidPseudoDtor, MicrosoftAnonTag, - MicrosoftCommentPaste, MicrosoftEndOfFile, + MicrosoftCommentPaste, MicrosoftEndOfFile, MicrosoftStaticAssert, MicrosoftInconsistentDllImport]>; def ClangClPch : DiagGroup<"clang-cl-pch">; @@ -1143,13 +1191,19 @@ def OpenMPClauses : DiagGroup<"openmp-clauses">; def OpenMPLoopForm : DiagGroup<"openmp-loop-form">; def OpenMPMapping : DiagGroup<"openmp-mapping">; def OpenMPTarget : DiagGroup<"openmp-target", [OpenMPMapping]>; +def OpenMPPre51Compat : DiagGroup<"pre-openmp-51-compat">; +def OpenMP51Ext : DiagGroup<"openmp-51-extensions">; def OpenMP : DiagGroup<"openmp", [ - SourceUsesOpenMP, OpenMPClauses, OpenMPLoopForm, OpenMPTarget, OpenMPMapping + SourceUsesOpenMP, OpenMPClauses, OpenMPLoopForm, OpenMPTarget, + OpenMPMapping, OpenMP51Ext ]>; // Backend warnings. def BackendInlineAsm : DiagGroup<"inline-asm">; -def BackendFrameLargerThanEQ : DiagGroup<"frame-larger-than=">; +def BackendSourceMgr : DiagGroup<"source-mgr">; +def BackendFrameLargerThan : DiagGroup<"frame-larger-than">; +// Compatibility flag name from old versions of Clang. +def : DiagGroup<"frame-larger-than=", [BackendFrameLargerThan]>; def BackendPlugin : DiagGroup<"backend-plugin">; def RemarkBackendPlugin : DiagGroup<"remark-backend-plugin">; def BackendOptimizationRemark : DiagGroup<"pass">; @@ -1247,3 +1301,5 @@ in addition with the pragmas or -fmax-tokens flag to get any warnings. def WebAssemblyExceptionSpec : DiagGroup<"wasm-exception-spec">; def RTTI : DiagGroup<"rtti">; + +def OpenCLCoreFeaturesDiagGroup : DiagGroup<"pedantic-core-features">; diff --git a/clang/include/clang/Basic/DiagnosticIDs.h b/clang/include/clang/Basic/DiagnosticIDs.h index 7fd107c4add7..288504def5eb 100644 --- a/clang/include/clang/Basic/DiagnosticIDs.h +++ b/clang/include/clang/Basic/DiagnosticIDs.h @@ -36,7 +36,7 @@ namespace clang { DIAG_SIZE_AST = 250, DIAG_SIZE_COMMENT = 100, DIAG_SIZE_CROSSTU = 100, - DIAG_SIZE_SEMA = 4000, + DIAG_SIZE_SEMA = 4500, DIAG_SIZE_ANALYSIS = 100, DIAG_SIZE_REFACTORING = 1000, }; diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td index 130e7687bad2..ce6d0d0394b4 100644 --- a/clang/include/clang/Basic/DiagnosticLexKinds.td +++ b/clang/include/clang/Basic/DiagnosticLexKinds.td @@ -179,6 +179,9 @@ def err_invalid_suffix_constant : Error< def warn_cxx11_compat_digit_separator : Warning< "digit separators are incompatible with C++ standards before C++14">, InGroup<CXXPre14Compat>, DefaultIgnore; +def warn_c2x_compat_digit_separator : Warning< + "digit separators are incompatible with C standards before C2x">, + InGroup<CPre2xCompat>, DefaultIgnore; def err_digit_separator_not_between_digits : Error< "digit separator cannot appear at %select{start|end}0 of digit sequence">; def warn_extraneous_char_constant : Warning< @@ -452,9 +455,11 @@ def err_pp_malformed_ident : Error<"invalid #ident directive">; def err_pp_unterminated_conditional : Error< "unterminated conditional directive">; def pp_err_else_after_else : Error<"#else after #else">; -def pp_err_elif_after_else : Error<"#elif after #else">; +def pp_err_elif_after_else : Error< + "%select{#elif|#elifdef|#elifndef}0 after #else">; def pp_err_else_without_if : Error<"#else without #if">; -def pp_err_elif_without_if : Error<"#elif without #if">; +def pp_err_elif_without_if : Error< + "%select{#elif|#elifdef|#elifndef}0 without #if">; def err_pp_endif_without_if : Error<"#endif without #if">; def err_pp_expected_value_in_expr : Error<"expected value in expression">; def err_pp_expected_rparen : Error<"expected ')' in preprocessor expression">; diff --git a/clang/include/clang/Basic/DiagnosticOptions.def b/clang/include/clang/Basic/DiagnosticOptions.def index 927710a0cb9a..7be81f6b6a95 100644 --- a/clang/include/clang/Basic/DiagnosticOptions.def +++ b/clang/include/clang/Basic/DiagnosticOptions.def @@ -78,7 +78,6 @@ ENUM_DIAGOPT(VerifyIgnoreUnexpected, DiagnosticLevelMask, 4, /// -verify. DIAGOPT(ElideType, 1, 0) /// Elide identical types in template diffing DIAGOPT(ShowTemplateTree, 1, 0) /// Print a template tree when diffing -DIAGOPT(CLFallbackMode, 1, 0) /// Format for clang-cl fallback mode VALUE_DIAGOPT(ErrorLimit, 32, 0) /// Limit # errors emitted. /// Limit depth of macro expansion backtrace. diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index 0ed80a481e78..7e4b0841e06b 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -21,7 +21,7 @@ let CategoryName = "Inline Assembly Issue" in { def err_asm_empty : Error<"__asm used with no assembly instructions">; def err_inline_ms_asm_parsing : Error<"%0">; def err_msasm_unsupported_arch : Error< - "Unsupported architecture '%0' for MS-style inline assembly">; + "unsupported architecture '%0' for MS-style inline assembly">; def err_msasm_unable_to_create_target : Error< "MS-style inline assembly is not available: %0">; def err_gnu_inline_asm_disabled : Error< @@ -424,12 +424,21 @@ def err_bool_redeclaration : Error< def warn_cxx98_compat_static_assert : Warning< "static_assert declarations are incompatible with C++98">, InGroup<CXX98Compat>, DefaultIgnore; -def ext_static_assert_no_message : ExtWarn< - "static_assert with no message is a C++17 extension">, InGroup<CXX17>; +def ext_ms_static_assert : ExtWarn< + "use of 'static_assert' without inclusion of <assert.h> is a Microsoft " + "extension">, InGroup<MicrosoftStaticAssert>; +def ext_cxx_static_assert_no_message : ExtWarn< + "'static_assert' with no message is a C++17 extension">, InGroup<CXX17>; +def ext_c_static_assert_no_message : ExtWarn< + "'_Static_assert' with no message is a C2x extension">, InGroup<C2x>; def warn_cxx14_compat_static_assert_no_message : Warning< - "static_assert with no message is incompatible with C++ standards before " + "'static_assert' with no message is incompatible with C++ standards before " "C++17">, DefaultIgnore, InGroup<CXXPre17Compat>; +def warn_c17_compat_static_assert_no_message : Warning< + "'_Static_assert' with no message is incompatible with C standards before " + "C2x">, + DefaultIgnore, InGroup<CPre2xCompat>; def err_function_definition_not_allowed : Error< "function definition is not allowed here">; def err_expected_end_of_enumerator : Error< @@ -571,6 +580,12 @@ def warn_cxx98_compat_noexcept_decl : Warning< def err_expected_catch : Error<"expected catch">; def err_using_namespace_in_class : Error< "'using namespace' is not allowed in classes">; +def warn_cxx17_compat_using_enum_declaration : Warning< + "using enum declaration is incompatible with C++ standards before C++20">, + InGroup<CXXPre20Compat>, DefaultIgnore; +def ext_using_enum_declaration : ExtWarn< + "using enum declaration is a C++20 extension">, + InGroup<CXX20>; def err_constructor_bad_name : Error< "missing return type for function %0; did you mean the constructor name %1?">; def err_destructor_tilde_identifier : Error< @@ -675,8 +690,6 @@ def err_attribute_requires_arguments : Error< "parentheses must be omitted if %0 attribute's argument list is empty">; def err_cxx11_attribute_forbids_ellipsis : Error< "attribute %0 cannot be used as an attribute pack">; -def err_cxx11_attribute_repeated : Error< - "attribute %0 cannot appear multiple times in an attribute specifier">; def warn_cxx14_compat_using_attribute_ns : Warning< "default scope specifier for attributes is incompatible with C++ standards " "before C++17">, InGroup<CXXPre17Compat>, DefaultIgnore; @@ -686,6 +699,9 @@ def ext_using_attribute_ns : ExtWarn< def err_using_attribute_ns_conflict : Error< "attribute with scope specifier cannot follow default scope specifier">; def err_attributes_not_allowed : Error<"an attribute list cannot appear here">; +def ext_cxx11_attr_placement : ExtWarn< + "ISO C++ does not allow an attribute list to appear here">, + InGroup<DiagGroup<"cxx-attribute-extension">>; def err_attributes_misplaced : Error<"misplaced attributes; expected attributes here">; def err_l_square_l_square_not_attribute : Error< "C++11 only allows consecutive left square brackets when " @@ -915,10 +931,16 @@ def err_override_control_interface : Error< def ext_ms_sealed_keyword : ExtWarn< "'sealed' keyword is a Microsoft extension">, InGroup<MicrosoftSealed>; +def ext_ms_abstract_keyword : ExtWarn< + "'abstract' keyword is a Microsoft extension">, + InGroup<MicrosoftAbstract>; def err_access_specifier_interface : Error< "interface types cannot specify '%select{private|protected}0' access">; +def err_duplicate_class_virt_specifier : Error< + "class already marked '%0'">; + def err_duplicate_virt_specifier : Error< "class member already marked '%0'">; @@ -940,9 +962,6 @@ def err_expected_lambda_body : Error<"expected body of lambda expression">; def warn_cxx98_compat_lambda : Warning< "lambda expressions are incompatible with C++98">, InGroup<CXX98Compat>, DefaultIgnore; -def err_lambda_missing_parens : Error< - "lambda requires '()' before %select{'mutable'|return type|" - "attribute specifier|'constexpr'|'consteval'|'requires' clause}0">; def err_lambda_decl_specifier_repeated : Error< "%select{'mutable'|'constexpr'|'consteval'}0 cannot appear multiple times in a lambda declarator">; def err_lambda_capture_misplaced_ellipsis : Error< @@ -952,6 +971,16 @@ def err_lambda_capture_multiple_ellipses : Error< "multiple ellipses in pack capture">; def err_capture_default_first : Error< "capture default must be first">; +def ext_decl_attrs_on_lambda : ExtWarn< + "an attribute specifier sequence in this position is a C++2b extension">, + InGroup<CXX2b>; +def ext_lambda_missing_parens : ExtWarn< + "lambda without a parameter clause is a C++2b extension">, + InGroup<CXX2b>; +def warn_cxx20_compat_decl_attrs_on_lambda : Warning< + "an attribute specifier sequence in this position is incompatible with C++ " + "standards before C++2b">, InGroup<CXXPre2bCompat>, DefaultIgnore; + // C++17 lambda expressions def err_expected_star_this_capture : Error< "expected 'this' following '*' in lambda capture list">; @@ -1220,22 +1249,18 @@ def note_pragma_attribute_namespace_on_attribute : Note< "omit the namespace to add attributes to the most-recently" " pushed attribute group">; -def err_opencl_unroll_hint_on_non_loop : Error< - "OpenCL only supports 'opencl_unroll_hint' attribute on for, while, and do statements">; - // OpenCL EXTENSION pragma (OpenCL 1.1 [9.1]) def warn_pragma_expected_colon : Warning< "missing ':' after %0 - ignoring">, InGroup<IgnoredPragmas>; def warn_pragma_expected_predicate : Warning< "expected %select{'enable', 'disable', 'begin' or 'end'|'disable'}0 - ignoring">, InGroup<IgnoredPragmas>; -def warn_pragma_begin_end_mismatch : Warning< - "OpenCL extension end directive mismatches begin directive - ignoring">, InGroup<IgnoredPragmas>; def warn_pragma_unknown_extension : Warning< "unknown OpenCL extension %0 - ignoring">, InGroup<IgnoredPragmas>; def warn_pragma_unsupported_extension : Warning< "unsupported OpenCL extension %0 - ignoring">, InGroup<IgnoredPragmas>; def warn_pragma_extension_is_core : Warning< - "OpenCL extension %0 is core feature or supported optional core feature - ignoring">, InGroup<DiagGroup<"pedantic-core-features">>, DefaultIgnore; + "OpenCL extension %0 is core feature or supported optional core feature - ignoring">, + InGroup<OpenCLCoreFeaturesDiagGroup>, DefaultIgnore; // OpenCL errors. def err_opencl_taking_function_address_parser : Error< @@ -1302,7 +1327,15 @@ def warn_omp_unknown_assumption_clause_without_args def note_omp_assumption_clause_continue_here : Note<"the ignored tokens spans until here">; def err_omp_declare_target_unexpected_clause: Error< - "unexpected '%0' clause, only %select{'to' or 'link'|'to', 'link' or 'device_type'}1 clauses expected">; + "unexpected '%0' clause, only %select{'device_type'|'to' or 'link'|'to', 'link' or 'device_type'}1 clauses expected">; +def err_omp_begin_declare_target_unexpected_implicit_to_clause: Error< + "unexpected '(', only 'to', 'link' or 'device_type' clauses expected for 'begin declare target' directive">; +def err_omp_declare_target_unexpected_clause_after_implicit_to: Error< + "unexpected clause after an implicit 'to' clause">; +def err_omp_declare_target_missing_to_or_link_clause: Error< + "expected at least one 'to' or 'link' clause">; +def err_omp_declare_target_multiple : Error< + "%0 appears multiple times in clauses on the same declare target directive">; def err_omp_expected_clause: Error< "expected at least one clause on '#pragma omp %0' directive">; def err_omp_mapper_illegal_identifier : Error< @@ -1387,6 +1420,22 @@ def err_omp_variant_ctx_second_match_extension : Error< "only a single match extension allowed per OpenMP context selector">; def err_omp_invalid_dsa: Error< "data-sharing attribute '%0' in '%1' clause requires OpenMP version %2 or above">; +def err_omp_expected_punc_after_interop_mod : Error< + "expected ',' after interop modifier">; +def err_omp_expected_interop_type : Error< + "expected interop type: 'target' and/or 'targetsync'">; +def warn_omp_more_one_interop_type + : Warning<"interop type '%0' cannot be specified more than once">, + InGroup<OpenMPClauses>; +def err_expected_sequence_or_directive : Error< + "expected an OpenMP 'directive' or 'sequence' attribute argument">; +def ext_omp_attributes : ExtWarn< + "specifying OpenMP directives with [[]] is an OpenMP 5.1 extension">, + InGroup<OpenMP51Ext>; +def warn_omp51_compat_attributes : Warning< + "specifying OpenMP directives with [[]] is incompatible with OpenMP " + "standards before OpenMP 5.1">, + InGroup<OpenMPPre51Compat>, DefaultIgnore; // Pragma loop support. def err_pragma_loop_missing_argument : Error< diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 67c59f3ca09a..108f1796415c 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -82,11 +82,11 @@ def err_typecheck_converted_constant_expression_indirect : Error< "bind reference to a temporary">; def err_expr_not_cce : Error< "%select{case value|enumerator value|non-type template argument|" - "array size|constexpr if condition|explicit specifier argument}0 " + "array size|explicit specifier argument}0 " "is not a constant expression">; def ext_cce_narrowing : ExtWarn< "%select{case value|enumerator value|non-type template argument|" - "array size|constexpr if condition|explicit specifier argument}0 " + "array size|explicit specifier argument}0 " "%select{cannot be narrowed from type %2 to %3|" "evaluates to %2, which cannot be narrowed to type %3}1">, InGroup<CXX11Narrowing>, DefaultError, SFINAEFailure; @@ -118,7 +118,8 @@ def warn_float_underflow : Warning< "magnitude of floating-point constant too small for type %0; minimum is %1">, InGroup<LiteralRange>; def warn_double_const_requires_fp64 : Warning< - "double precision constant requires cl_khr_fp64, casting to single precision">; + "double precision constant requires %select{cl_khr_fp64|cl_khr_fp64 and __opencl_c_fp64}0, " + "casting to single precision">; def err_half_const_requires_fp16 : Error< "half precision constant requires cl_khr_fp16">; @@ -214,6 +215,9 @@ def ext_designated_init_reordered : ExtWarn< SFINAEFailure; def note_previous_field_init : Note< "previous initialization for field %0 is here">; +def ext_designated_init_brace_elision : ExtWarn< + "brace elision for designated initializer is a C99 extension">, + InGroup<C99Designator>, SFINAEFailure; // Declarations. def ext_plain_complex : ExtWarn< @@ -290,6 +294,10 @@ def err_anyx86_interrupt_attribute : Error< "a pointer as the first parameter|a %2 type as the second parameter}1">; def err_anyx86_interrupt_called : Error< "interrupt service routine cannot be called directly">; +def warn_anyx86_interrupt_regsave : Warning< + "interrupt service routine should only call a function" + " with attribute 'no_caller_saved_registers'">, + InGroup<DiagGroup<"interrupt-service-routine">>; def warn_arm_interrupt_calling_convention : Warning< "call to function without interrupt attribute could clobber interruptee's VFP registers">, InGroup<Extra>; @@ -303,8 +311,12 @@ def note_riscv_repeated_interrupt_attribute : Note< "repeated RISC-V 'interrupt' attribute is here">; def warn_unused_parameter : Warning<"unused parameter %0">, InGroup<UnusedParameter>, DefaultIgnore; +def warn_unused_but_set_parameter : Warning<"parameter %0 set but not used">, + InGroup<UnusedButSetParameter>, DefaultIgnore; def warn_unused_variable : Warning<"unused variable %0">, InGroup<UnusedVariable>, DefaultIgnore; +def warn_unused_but_set_variable : Warning<"variable %0 set but not used">, + InGroup<UnusedButSetVariable>, DefaultIgnore; def warn_unused_local_typedef : Warning< "unused %select{typedef|type alias}0 %1">, InGroup<UnusedLocalTypedef>, DefaultIgnore; @@ -372,6 +384,15 @@ def warn_unused_lambda_capture: Warning<"lambda capture %0 is not " "%select{used|required to be captured for this use}1">, InGroup<UnusedLambdaCapture>, DefaultIgnore; +def warn_reserved_extern_symbol: Warning< + "identifier %0 is reserved because %select{" + "<ERROR>|" // ReservedIdentifierStatus::NotReserved + "it starts with '_' at global scope|" + "it starts with '__'|" + "it starts with '_' followed by a capital letter|" + "it contains '__'}1">, + InGroup<ReservedIdentifier>, DefaultIgnore; + def warn_parameter_size: Warning< "%0 is a large (%1 bytes) pass-by-value argument; " "pass it by reference instead ?">, InGroup<LargeByValueCopy>; @@ -422,7 +443,8 @@ def warn_decl_shadow : "static data member of %2|" "field of %2|" "typedef in %2|" - "type alias in %2}1">, + "type alias in %2|" + "structured binding}1">, InGroup<Shadow>, DefaultIgnore; def warn_decl_shadow_uncaptured_local : Warning<warn_decl_shadow.Text>, @@ -514,6 +536,10 @@ def err_using_dependent_value_is_type : Error< "dependent using declaration resolved to type without 'typename'">; def err_using_decl_nested_name_specifier_is_not_class : Error< "using declaration in class refers into '%0', which is not a class">; +def warn_cxx17_compat_using_decl_non_member_enumerator : Warning< + "member using declaration naming non-class '%0' enumerator is " + "incompatible with C++ standards before C++20">, InGroup<CXXPre20Compat>, + DefaultIgnore; def err_using_decl_nested_name_specifier_is_current_class : Error< "using declaration refers to its own class">; def err_using_decl_nested_name_specifier_is_not_base_class : Error< @@ -522,6 +548,14 @@ def err_using_decl_constructor_not_in_direct_base : Error< "%0 is not a direct base of %1, cannot inherit constructors">; def err_using_decl_can_not_refer_to_class_member : Error< "using declaration cannot refer to class member">; +def warn_cxx17_compat_using_decl_class_member_enumerator : Warning< + "member using declaration naming a non-member enumerator is incompatible " + "with C++ standards before C++20">, InGroup<CXXPre20Compat>, DefaultIgnore; +def ext_using_decl_class_member_enumerator : ExtWarn< + "member using declaration naming a non-member enumerator is " + "a C++20 extension">, InGroup<CXX20>; +def err_using_enum_is_dependent : Error< + "using-enum cannot name a dependent type">; def err_ambiguous_inherited_constructor : Error< "constructor of %0 inherited from multiple base class subobjects">; def note_ambiguous_inherited_constructor_using : Note< @@ -531,8 +565,12 @@ def note_using_decl_class_member_workaround : Note< "a const variable|a constexpr variable}0 instead">; def err_using_decl_can_not_refer_to_namespace : Error< "using declaration cannot refer to a namespace">; -def err_using_decl_can_not_refer_to_scoped_enum : Error< - "using declaration cannot refer to a scoped enumerator">; +def warn_cxx17_compat_using_decl_scoped_enumerator: Warning< + "using declaration naming a scoped enumerator is incompatible with " + "C++ standards before C++20">, InGroup<CXXPre20Compat>, DefaultIgnore; +def ext_using_decl_scoped_enumerator : ExtWarn< + "using declaration naming a scoped enumerator is a C++20 extension">, + InGroup<CXX20>; def err_using_decl_constructor : Error< "using declaration cannot refer to a constructor">; def warn_cxx98_compat_using_decl_constructor : Warning< @@ -552,6 +590,15 @@ def err_using_decl_conflict_reverse : Error< def note_using_decl : Note<"%select{|previous }0using declaration">; def err_using_decl_redeclaration_expansion : Error< "using declaration pack expansion at block scope produces multiple values">; +def err_use_of_empty_using_if_exists : Error< + "reference to unresolved using declaration">; +def note_empty_using_if_exists_here : Note< + "using declaration annotated with 'using_if_exists' here">; +def err_using_if_exists_on_ctor : Error< + "'using_if_exists' attribute cannot be applied to an inheriting constructor">; +def err_using_enum_decl_redeclaration : Error< + "redeclaration of using-enum declaration">; +def note_using_enum_decl : Note<"%select{|previous }0using-enum declaration">; def warn_access_decl_deprecated : Warning< "access declarations are deprecated; use using declarations instead">, @@ -559,15 +606,24 @@ def warn_access_decl_deprecated : Warning< def err_access_decl : Error< "ISO C++11 does not allow access declarations; " "use using declarations instead">; -def warn_deprecated_copy_operation : Warning< +def warn_deprecated_copy : Warning< "definition of implicit copy %select{constructor|assignment operator}1 " "for %0 is deprecated because it has a user-declared copy " "%select{assignment operator|constructor}1">, InGroup<DeprecatedCopy>, DefaultIgnore; -def warn_deprecated_copy_dtor_operation : Warning< +def warn_deprecated_copy_with_dtor : Warning< "definition of implicit copy %select{constructor|assignment operator}1 " "for %0 is deprecated because it has a user-declared destructor">, - InGroup<DeprecatedCopyDtor>, DefaultIgnore; + InGroup<DeprecatedCopyWithDtor>, DefaultIgnore; +def warn_deprecated_copy_with_user_provided_copy: Warning< + "definition of implicit copy %select{constructor|assignment operator}1 " + "for %0 is deprecated because it has a user-provided copy " + "%select{assignment operator|constructor}1">, + InGroup<DeprecatedCopyWithUserProvidedCopy>, DefaultIgnore; +def warn_deprecated_copy_with_user_provided_dtor : Warning< + "definition of implicit copy %select{constructor|assignment operator}1 " + "for %0 is deprecated because it has a user-provided destructor">, + InGroup<DeprecatedCopyWithUserProvidedDtor>, DefaultIgnore; def warn_cxx17_compat_exception_spec_in_signature : Warning< "mangled name of %0 will change in C++17 due to non-throwing exception " "specification in function signature">, InGroup<CXX17CompatMangling>; @@ -1431,6 +1487,8 @@ def err_messaging_class_with_direct_method : Error< // C++ declarations def err_static_assert_expression_is_not_constant : Error< "static_assert expression is not an integral constant expression">; +def err_constexpr_if_condition_expression_is_not_constant : Error< + "constexpr if condition is not a constant expression">; def err_static_assert_failed : Error<"static_assert failed%select{ %1|}0">; def err_static_assert_requirement_failed : Error< "static_assert failed due to requirement '%0'%select{ %2|}1">; @@ -1705,6 +1763,8 @@ def warn_cxx98_compat_sfinae_access_control : Warning< // C++ name lookup def err_incomplete_nested_name_spec : Error< "incomplete type %0 named in nested name specifier">; +def err_incomplete_enum : Error< + "enumeration %0 is incomplete">; def err_dependent_nested_name_spec : Error< "nested name specifier for a declaration cannot depend on a template " "parameter">; @@ -2816,6 +2876,53 @@ def warn_nomerge_attribute_ignored_in_stmt: Warning< "%0 attribute is ignored because there exists no call expression inside the " "statement">, InGroup<IgnoredAttributes>; + +def err_musttail_needs_trivial_args : Error< + "tail call requires that the return value, all parameters, and any " + "temporaries created by the expression are trivially destructible">; +def err_musttail_needs_call : Error< + "%0 attribute requires that the return value is the result of a function call" + >; +def err_musttail_needs_prototype : Error< + "%0 attribute requires that both caller and callee functions have a " + "prototype">; +def note_musttail_fix_non_prototype : Note< + "add 'void' to the parameter list to turn an old-style K&R function " + "declaration into a prototype">; +def err_musttail_structors_forbidden : Error<"cannot perform a tail call " + "%select{from|to}0 a %select{constructor|destructor}1">; +def note_musttail_structors_forbidden : Note<"target " + "%select{constructor|destructor}0 is declared here">; +def err_musttail_forbidden_from_this_context : Error< + "%0 attribute cannot be used from " + "%select{a block|an Objective-C function|this context}1">; +def err_musttail_member_mismatch : Error< + "%select{non-member|static member|non-static member}0 " + "function cannot perform a tail call to " + "%select{non-member|static member|non-static member|pointer-to-member}1 " + "function%select{| %3}2">; +def note_musttail_callee_defined_here : Note<"%0 declared here">; +def note_tail_call_required : Note<"tail call required by %0 attribute here">; +def err_musttail_mismatch : Error< + "cannot perform a tail call to function%select{| %1}0 because its signature " + "is incompatible with the calling function">; +def note_musttail_mismatch : Note< + "target function " + "%select{is a member of different class%diff{ (expected $ but has $)|}1,2" + "|has different number of parameters (expected %1 but has %2)" + "|has type mismatch at %ordinal3 parameter" + "%diff{ (expected $ but has $)|}1,2" + "|has different return type%diff{ ($ expected but has $)|}1,2}0">; +def err_musttail_callconv_mismatch : Error< + "cannot perform a tail call to function%select{| %1}0 because it uses an " + "incompatible calling convention">; +def note_musttail_callconv_mismatch : Note< + "target function has calling convention %1 (expected %0)">; +def err_musttail_scope : Error< + "cannot perform a tail call from this return statement">; +def err_musttail_no_variadic : Error< + "%0 attribute may not be used with variadic functions">; + def err_nsobject_attribute : Error< "'NSObject' attribute is for pointer types only">; def err_attributes_are_not_compatible : Error< @@ -3049,7 +3156,8 @@ def warn_nsdictionary_duplicate_key : Warning< def note_nsdictionary_duplicate_key_here : Note< "previous equal key is here">; def err_swift_param_attr_not_swiftcall : Error< - "'%0' parameter can only be used with swiftcall calling convention">; + "'%0' parameter can only be used with swiftcall%select{ or swiftasynccall|}1 " + "calling convention%select{|s}1">; def err_swift_indirect_result_not_first : Error< "'swift_indirect_result' parameters must be first parameters of function">; def err_swift_error_result_not_after_swift_context : Error< @@ -3078,6 +3186,8 @@ def warn_objc_redundant_literal_use : Warning< def err_attr_tlsmodel_arg : Error<"tls_model must be \"global-dynamic\", " "\"local-dynamic\", \"initial-exec\" or \"local-exec\"">; +def err_aix_attr_unsupported_tls_model : Error<"TLS model '%0' is not yet supported on AIX">; + def err_tls_var_aligned_over_maximum : Error< "alignment (%0) of thread-local variable %1 is greater than the maximum supported " "alignment (%2) for a thread-local variable on this target">; @@ -3087,6 +3197,8 @@ def err_only_annotate_after_access_spec : Error< def err_attribute_section_invalid_for_target : Error< "argument to %select{'code_seg'|'section'}1 attribute is not valid for this target: %0">; +def err_pragma_section_invalid_for_target : Error< + "argument to #pragma section is not valid for this target: %0">; def warn_attribute_section_drectve : Warning< "#pragma %0(\".drectve\") has undefined behavior, " "use #pragma comment(linker, ...) instead">, InGroup<MicrosoftDrectveSection>; @@ -3142,6 +3254,10 @@ def warn_assume_aligned_too_great : Warning<"requested alignment must be %0 bytes or smaller; maximum " "alignment assumed">, InGroup<DiagGroup<"builtin-assume-aligned-alignment">>; +def warn_not_xl_compatible + : Warning<"requesting an alignment of 16 bytes or greater for struct" + " members is not binary compatible with AIX XL 16.1 and older">, + InGroup<AIXCompat>; def warn_redeclaration_without_attribute_prev_attribute_ignored : Warning< "%q0 redeclared without %1 attribute: previous %1 ignored">, InGroup<MicrosoftInconsistentDllImport>; @@ -3156,6 +3272,9 @@ def warn_attribute_ignored : Warning<"%0 attribute ignored">, def warn_nothrow_attribute_ignored : Warning<"'nothrow' attribute conflicts with" " exception specification; attribute ignored">, InGroup<IgnoredAttributes>; +def warn_attribute_ignored_on_non_definition : + Warning<"%0 attribute ignored on a non-definition declaration">, + InGroup<IgnoredAttributes>; def warn_attribute_ignored_on_inline : Warning<"%0 attribute ignored on inline function">, InGroup<IgnoredAttributes>; @@ -3430,6 +3549,10 @@ def warn_at_available_unchecked_use : Warning< "use if (%select{@available|__builtin_available}0) instead">, InGroup<DiagGroup<"unsupported-availability-guard">>; +def warn_missing_sdksettings_for_availability_checking : Warning< + "%0 availability is ignored without a valid 'SDKSettings.json' in the SDK">, + InGroup<DiagGroup<"ignored-availability-without-sdk-settings">>; + // Thread Safety Attributes def warn_thread_attribute_ignored : Warning< "ignoring %0 attribute because its argument is invalid">, @@ -3554,13 +3677,13 @@ def warn_fun_requires_lock_precise : def note_found_mutex_near_match : Note<"found near match '%0'">; // Verbose thread safety warnings -def warn_thread_safety_verbose : Warning<"Thread safety verbose warning.">, +def warn_thread_safety_verbose : Warning<"thread safety verbose warning">, InGroup<ThreadSafetyVerbose>, DefaultIgnore; -def note_thread_warning_in_fun : Note<"Thread warning in function %0">; -def note_guarded_by_declared_here : Note<"Guarded_by declared here.">; +def note_thread_warning_in_fun : Note<"thread warning in function %0">; +def note_guarded_by_declared_here : Note<"guarded_by declared here">; // Dummy warning that will trigger "beta" warnings from the analysis if enabled. -def warn_thread_safety_beta : Warning<"Thread safety beta warning.">, +def warn_thread_safety_beta : Warning<"thread safety beta warning">, InGroup<ThreadSafetyBeta>, DefaultIgnore; // Consumed warnings @@ -3876,6 +3999,9 @@ def warn_attribute_sentinel_named_arguments : Warning< def warn_attribute_sentinel_not_variadic : Warning< "'sentinel' attribute only supported for variadic %select{functions|blocks}0">, InGroup<IgnoredAttributes>; +def warn_deprecated_ignored_on_using : Warning< + "%0 currently has no effect on a using declaration">, + InGroup<IgnoredAttributes>; def err_attribute_sentinel_less_than_zero : Error< "'sentinel' parameter 1 less than zero">; def err_attribute_sentinel_not_zero_or_one : Error< @@ -3957,6 +4083,8 @@ def note_protocol_decl_undefined : Note< def err_attribute_preferred_name_arg_invalid : Error< "argument %0 to 'preferred_name' attribute is not a typedef for " "a specialization of %1">; +def err_attribute_builtin_alias : Error< + "%0 attribute can only be applied to a ARM or RISC-V builtin">; // called-once attribute diagnostics. def err_called_once_attribute_wrong_type : Error< @@ -4104,6 +4232,17 @@ def err_swift_async_bad_block_type : Error< "'swift_async' completion handler parameter must have block type returning" " 'void', type here is %0">; +def err_swift_async_error_without_swift_async : Error< + "%0 attribute must be applied to a %select{function|method}1 annotated " + "with non-'none' attribute 'swift_async'">; +def err_swift_async_error_no_error_parameter : Error< + "%0 attribute with 'nonnull_error' convention can only be applied to a " + "%select{function|method}1 with a completion handler with an error " + "parameter">; +def err_swift_async_error_non_integral : Error< + "%0 attribute with '%1' convention must have an integral-typed parameter " + "in completion handler at index %2, type here is %3">; + def warn_ignored_objc_externally_retained : Warning< "'objc_externally_retained' can only be applied to local variables " "%select{of retainable type|with strong ownership}0">, @@ -4279,8 +4418,6 @@ def warn_diagnose_if_succeeded : Warning<"%0">, InGroup<UserDefinedWarnings>, ShowInSystemHeader; def note_ovl_candidate_disabled_by_function_cond_attr : Note< "candidate disabled: %0">; -def note_ovl_candidate_disabled_by_extension : Note< - "candidate unavailable as it requires OpenCL extension '%0' to be enabled">; def err_addrof_function_disabled_by_enable_if_attr : Error< "cannot take address of function %0 because it has one or more " "non-tautological enable_if conditions">; @@ -5710,11 +5847,8 @@ def err_anon_bitfield_has_negative_width : Error< "anonymous bit-field has negative width (%0)">; def err_bitfield_has_zero_width : Error<"named bit-field %0 has zero width">; def err_bitfield_width_exceeds_type_width : Error< - "width of bit-field %0 (%1 bits) exceeds %select{width|size}2 " - "of its type (%3 bit%s3)">; -def err_anon_bitfield_width_exceeds_type_width : Error< - "width of anonymous bit-field (%0 bits) exceeds %select{width|size}1 " - "of its type (%2 bit%s2)">; + "width of%select{ anonymous|}0 bit-field%select{| %1}0 (%2 bits) exceeds the " + "%select{width|size}3 of its type (%4 bit%s4)">; def err_incorrect_number_of_vector_initializers : Error< "number of elements must be either one or match the size of the vector">; @@ -5753,6 +5887,9 @@ def note_goto_ms_asm_label : Note< def warn_unused_label : Warning<"unused label %0">, InGroup<UnusedLabel>, DefaultIgnore; +def err_continue_from_cond_var_init : Error< + "cannot jump from this continue statement to the loop increment; " + "jump bypasses initialization of loop condition variable">; def err_goto_into_protected_scope : Error< "cannot jump from this goto statement to its label">; def ext_goto_into_protected_scope : ExtWarn< @@ -6257,6 +6394,14 @@ def warn_pointer_arith_null_ptr : Warning< def warn_gnu_null_ptr_arith : Warning< "arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension">, InGroup<NullPointerArithmetic>, DefaultIgnore; +def warn_pointer_sub_null_ptr : Warning< + "performing pointer subtraction with a null pointer %select{has|may have}0 undefined behavior">, + InGroup<NullPointerSubtraction>, DefaultIgnore; +def err_kernel_invalidates_sycl_unique_stable_name + : Error<"kernel instantiation changes the result of an evaluated " + "'__builtin_sycl_unique_stable_name'">; +def note_sycl_unique_stable_name_evaluated_here + : Note<"'__builtin_sycl_unique_stable_name' evaluated here">; def warn_floatingpoint_eq : Warning< "comparing floating point with == or != is unsafe">, @@ -6351,19 +6496,6 @@ def warn_pessimizing_move_on_initialization : Warning< InGroup<PessimizingMove>, DefaultIgnore; def note_remove_move : Note<"remove std::move call here">; -def warn_return_std_move : Warning< - "local variable %0 will be copied despite being %select{returned|thrown}1 by name">, - InGroup<ReturnStdMove>, DefaultIgnore; -def note_add_std_move : Note< - "call 'std::move' explicitly to avoid copying">; -def warn_return_std_move_in_cxx11 : Warning< - "prior to the resolution of a defect report against ISO C++11, " - "local variable %0 would have been copied despite being returned by name, " - "due to its not matching the function return type%diff{ ($ vs $)|}1,2">, - InGroup<ReturnStdMoveInCXX11>, DefaultIgnore; -def note_add_std_move_in_cxx11 : Note< - "call 'std::move' explicitly to avoid copying on older compilers">; - def warn_string_plus_int : Warning< "adding %0 to a string does not append to the string">, InGroup<StringPlusInt>; @@ -6637,11 +6769,14 @@ def warn_pointer_indirection_from_incompatible_type : Warning< def warn_taking_address_of_packed_member : Warning< "taking address of packed member %0 of class or structure %q1 may result in an unaligned pointer value">, InGroup<DiagGroup<"address-of-packed-member">>; +def warn_param_mismatched_alignment : Warning< + "passing %0-byte aligned argument to %1-byte aligned parameter %2 of %3 may result in an unaligned pointer access">, + InGroup<DiagGroup<"align-mismatch">>; def err_objc_object_assignment : Error< "cannot assign to class object (%0 invalid)">; def err_typecheck_invalid_operands : Error< - "invalid operands to binary expression (%0 and %1)">; + "invalid operands to binary expression (%0 and %1)">, Deferrable; def note_typecheck_invalid_operands_converted : Note< "%select{first|second}0 operand was implicitly converted to type %1">; def err_typecheck_logical_vector_expr_gnu_cpp_restrict : Error< @@ -6664,9 +6799,14 @@ def ext_typecheck_compare_complete_incomplete_pointers : Extension< "%0 is %select{|in}2complete and " "%1 is %select{|in}3complete">, InGroup<C11>; +def warn_typecheck_ordered_comparison_of_function_pointers : Warning< + "ordered comparison of function pointers (%0 and %1)">, + InGroup<OrderedCompareFunctionPointers>; def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn< "ordered comparison of function pointers (%0 and %1)">, - InGroup<DiagGroup<"ordered-compare-function-pointers">>; + InGroup<OrderedCompareFunctionPointers>; +def err_typecheck_ordered_comparison_of_function_pointers : Error< + "ordered comparison of function pointers (%0 and %1)">; def ext_typecheck_comparison_of_fptr_to_void : Extension< "equality comparison between function pointer and void pointer (%0 and %1)">; def err_typecheck_comparison_of_fptr_to_void : Error< @@ -6762,6 +6902,10 @@ def warn_unsigned_always_true_comparison : Warning< "result of comparison of %select{%3|unsigned expression}0 %2 " "%select{unsigned expression|%3}0 is always %4">, InGroup<TautologicalUnsignedZeroCompare>, DefaultIgnore; +def warn_unsigned_char_always_true_comparison : Warning< + "result of comparison of %select{%3|char expression}0 %2 " + "%select{char expression|%3}0 is always %4, since char is interpreted as " + "unsigned">, InGroup<TautologicalUnsignedCharZeroCompare>, DefaultIgnore; def warn_unsigned_enum_always_true_comparison : Warning< "result of comparison of %select{%3|unsigned enum expression}0 %2 " "%select{unsigned enum expression|%3}0 is always %4">, @@ -7172,6 +7316,9 @@ def err_need_header_before_typeid : Error< "you need to include <typeinfo> before using the 'typeid' operator">; def err_need_header_before_ms_uuidof : Error< "you need to include <guiddef.h> before using the '__uuidof' operator">; +def err_need_header_before_placement_new : Error< + "no matching %0 function for non-allocating placement new expression; " + "include <new>">; def err_ms___leave_not_in___try : Error< "'__leave' statement not in __try block">; def err_uuidof_without_guid : Error< @@ -7299,6 +7446,12 @@ def warn_deprecated_volatile_structured_binding : Warning< "volatile qualifier in structured binding declaration is deprecated">, InGroup<DeprecatedVolatile>; +def warn_deprecated_altivec_src_compat : Warning< + "Current handling of vector bool and vector pixel types in this context are " + "deprecated. The default behaviour will soon change to that implied by the " + "'-altivec-compat=xl' option">, + InGroup<DiagGroup<"deprecated-altivec-src-compat">>; + def err_catch_incomplete_ptr : Error< "cannot catch pointer to incomplete type %0">; def err_catch_incomplete_ref : Error< @@ -7401,9 +7554,10 @@ def err_conditional_vector_element_size : Error< def err_conditional_vector_has_void : Error< "GNU vector conditional operand cannot be %select{void|a throw expression}0">; def err_conditional_vector_operand_type - : Error<"%select{enumeration|extended vector}0 type %1 is not allowed in a " - "vector conditional">; -def err_conditional_vector_mismatched_vectors + : Error<"enumeration type %0 is not allowed in a vector conditional">; +def err_conditional_vector_cond_result_mismatch + : Error<"cannot mix vectors and extended vectors in a vector conditional">; +def err_conditional_vector_mismatched : Error<"vector operands to the vector conditional must be the same type " "%diff{($ and $)|}0,1}">; @@ -7439,6 +7593,8 @@ let CategoryName = "Lambda Issue" in { "duration">; def err_this_capture : Error< "'this' cannot be %select{implicitly |}0captured in this context">; + def note_lambda_this_capture_fixit : Note< + "explicitly capture 'this'">; def err_lambda_capture_anonymous_var : Error< "unnamed variable cannot be implicitly captured in a lambda expression">; def err_lambda_capture_flexarray_type : Error< @@ -7447,6 +7603,10 @@ let CategoryName = "Lambda Issue" in { def err_lambda_impcap : Error< "variable %0 cannot be implicitly captured in a lambda with no " "capture-default specified">; + def note_lambda_variable_capture_fixit : Note< + "capture %0 by %select{value|reference}1">; + def note_lambda_default_capture_fixit : Note< + "default capture by %select{value|reference}0">; def note_lambda_decl : Note<"lambda expression begins here">; def err_lambda_unevaluated_operand : Error< "lambda expression in an unevaluated operand">; @@ -7624,7 +7784,7 @@ def warn_condition_is_assignment : Warning<"using the result of an " "assignment as a condition without parentheses">, InGroup<Parentheses>; def warn_free_nonheap_object - : Warning<"attempt to call %0 on non-heap object %1">, + : Warning<"attempt to call %0 on non-heap %select{object %2|object: block expression|object: lambda-to-function-pointer conversion}1">, InGroup<FreeNonHeapObject>; // Completely identical except off by default. @@ -8156,6 +8316,9 @@ def err_atomic_op_needs_non_const_pointer : Error< def err_atomic_op_needs_trivial_copy : Error< "address argument to atomic operation must be a pointer to a " "trivially-copyable type (%0 invalid)">; +def err_atomic_op_needs_atomic_int_ptr_or_fp : Error< + "address argument to atomic operation must be a pointer to %select{|atomic }0" + "integer, pointer or supported floating point type (%1 invalid)">; def err_atomic_op_needs_atomic_int_or_ptr : Error< "address argument to atomic operation must be a pointer to %select{|atomic }0" "integer or pointer (%1 invalid)">; @@ -8208,6 +8371,10 @@ def err_global_call_not_config : Error< def err_ref_bad_target : Error< "reference to %select{__device__|__global__|__host__|__host__ __device__}0 " "%select{function|variable}1 %2 in %select{__device__|__global__|__host__|__host__ __device__}3 function">; +def note_cuda_const_var_unpromoted : Note< + "const variable cannot be emitted on device side due to dynamic initialization">; +def note_cuda_host_var : Note< + "host variable declared here">; def err_ref_bad_target_global_initializer : Error< "reference to %select{__device__|__global__|__host__|__host__ __device__}0 " "function %1 in global initializer">; @@ -8271,6 +8438,9 @@ def note_cuda_device_builtin_surftex_should_be_template_class : Note< "%0 needs to be instantiated from a class template with proper " "template arguments">; +def err_hip_invalid_args_builtin_mangled_name : Error< + "invalid argument: symbol must be a device-side function or global variable">; + def warn_non_pod_vararg_with_format_string : Warning< "cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic " "%select{function|block|method|constructor}2; expected type from format " @@ -8354,6 +8524,9 @@ def note_change_calling_conv_fixit : Note< def warn_bad_function_cast : Warning< "cast from function call of type %0 to non-matching type %1">, InGroup<BadFunctionCast>, DefaultIgnore; +def warn_cast_function_type : Warning< + "cast %diff{from $ to $ |}0,1converts to incompatible function type">, + InGroup<CastFunctionType>, DefaultIgnore; def err_cast_pointer_to_non_pointer_int : Error< "pointer cannot be cast to type %0">; def err_cast_to_bfloat16 : Error<"cannot type-cast to __bf16">; @@ -8362,6 +8535,9 @@ def err_typecheck_expect_scalar_operand : Error< "operand of type %0 where arithmetic or pointer type is required">; def err_typecheck_cond_incompatible_operands : Error< "incompatible operand types%diff{ ($ and $)|}0,1">; +def err_typecheck_expect_flt_or_vector : Error< + "invalid operand of type %0 where floating, complex or " + "a vector of such types is required">; def err_cast_selector_expr : Error< "cannot type cast @selector expression">; def ext_typecheck_cond_incompatible_pointers : ExtWarn< @@ -8492,6 +8668,7 @@ let CategoryName = "Inline Assembly Issue" in { "asm constraint has an unexpected number of alternatives: %0 vs %1">; def err_asm_incomplete_type : Error<"asm operand has incomplete type %0">; def err_asm_unknown_register_name : Error<"unknown register name '%0' in asm">; + def err_asm_unwind_and_goto : Error<"unwind clobber can't be used with asm goto">; def err_asm_invalid_global_var_reg : Error<"register '%0' unsuitable for " "global register variables on this target">; def err_asm_register_size_mismatch : Error<"size of register '%0' does not " @@ -8539,6 +8716,12 @@ let CategoryName = "Inline Assembly Issue" in { let CategoryName = "Semantic Issue" in { +def err_invalid_conversion_between_matrixes : Error< + "conversion between matrix types%diff{ $ and $|}0,1 of different size is not allowed">; + +def err_invalid_conversion_between_matrix_and_type : Error< + "conversion between matrix type %0 and incompatible type %1 is not allowed">; + def err_invalid_conversion_between_vectors : Error< "invalid conversion between vector type%diff{ $ and $|}0,1 of different " "size">; @@ -8547,7 +8730,7 @@ def err_invalid_conversion_between_vector_and_integer : Error< "of different size">; def err_opencl_function_pointer : Error< - "pointers to functions are not allowed">; + "%select{pointers|references}0 to functions are not allowed">; def err_opencl_taking_address_capture : Error< "taking address of a capture is not allowed">; @@ -8574,6 +8757,15 @@ def warn_initializer_out_of_order : Warning< "%select{field|base class}0 %1 will be initialized after " "%select{field|base}2 %3">, InGroup<ReorderCtor>, DefaultIgnore; + +def warn_some_initializers_out_of_order : Warning< + "initializer order does not match the declaration order">, + InGroup<ReorderCtor>, DefaultIgnore; + +def note_initializer_out_of_order : Note< + "%select{field|base class}0 %1 will be initialized after " + "%select{field|base}2 %3">; + def warn_abstract_vbase_init_ignored : Warning< "initializer for virtual base class %0 of abstract class %1 " "will never be used">, @@ -8950,8 +9142,8 @@ def note_defaulted_comparison_calls_deleted : Note< "defaulted %0 is implicitly deleted because it would invoke a deleted " "comparison function%select{| for member %2| for base class %2}1">; def note_defaulted_comparison_no_viable_function : Note< - "defaulted %0 is implicitly deleted because there is no viable comparison " - "function%select{| for member %2| for base class %2}1">; + "defaulted %0 is implicitly deleted because there is no viable three-way " + "comparison function for%select{| member| base class}1 %2">; def note_defaulted_comparison_no_viable_function_synthesized : Note< "three-way comparison cannot be synthesized because there is no viable " "function for %select{'=='|'<'}0 comparison">; @@ -9003,6 +9195,14 @@ def warn_array_index_precedes_bounds : Warning< def warn_array_index_exceeds_bounds : Warning< "array index %0 is past the end of the array (which contains %1 " "element%s2)">, InGroup<ArrayBounds>; +def warn_ptr_arith_exceeds_max_addressable_bounds : Warning< + "the pointer incremented by %0 refers past the last possible element for an array in %1-bit " + "address space containing %2-bit (%3-byte) elements (max possible %4 element%s5)">, + InGroup<ArrayBounds>; +def warn_array_index_exceeds_max_addressable_bounds : Warning< + "array index %0 refers past the last possible element for an array in %1-bit " + "address space containing %2-bit (%3-byte) elements (max possible %4 element%s5)">, + InGroup<ArrayBounds>; def note_array_declared_here : Note< "array %0 declared here">; @@ -9537,6 +9737,8 @@ def err_argument_not_shifted_byte : Error< "argument should be an 8-bit value shifted by a multiple of 8 bits">; def err_argument_not_shifted_byte_or_xxff : Error< "argument should be an 8-bit value shifted by a multiple of 8 bits, or in the form 0x??FF">; +def err_argument_not_contiguous_bit_field : Error< + "argument %0 value should represent a contiguous bit field">; def err_rotation_argument_to_cadd : Error<"argument should be the value 90 or 270">; def err_rotation_argument_to_cmla @@ -9565,8 +9767,8 @@ def err_mips_builtin_requires_dspr2 : Error< "this builtin requires 'dsp r2' ASE, please use -mdspr2">; def err_mips_builtin_requires_msa : Error< "this builtin requires 'msa' ASE, please use -mmsa">; -def err_ppc_builtin_only_on_pwr7 : Error< - "this builtin is only valid on POWER7 or later CPUs">; +def err_ppc_builtin_only_on_arch : Error< + "this builtin is only valid on POWER%0 or later CPUs">; def err_ppc_invalid_use_mma_type : Error< "invalid use of PPC MMA type">; def err_x86_builtin_invalid_rounding : Error< @@ -9618,7 +9820,7 @@ def warn_duplicate_attribute_exact : Warning< "attribute %0 is already applied">, InGroup<IgnoredAttributes>; def warn_duplicate_attribute : Warning< - "attribute %0 is already applied with different parameters">, + "attribute %0 is already applied with different arguments">, InGroup<IgnoredAttributes>; def warn_sync_fetch_and_nand_semantics_change : Warning< @@ -9886,13 +10088,20 @@ def err_opencl_pointer_to_type : Error< "pointer to type %0 is invalid in OpenCL">; def err_opencl_type_can_only_be_used_as_function_parameter : Error < "type %0 can only be used as a function parameter in OpenCL">; +def err_opencl_type_not_found : Error< + "%0 type %1 not found; include the base header with -finclude-default-header">; def warn_opencl_attr_deprecated_ignored : Warning < "%0 attribute is deprecated and ignored in OpenCL version %1">, InGroup<IgnoredAttributes>; def err_opencl_variadic_function : Error< "invalid prototype, variadic arguments are not allowed in OpenCL">; def err_opencl_requires_extension : Error< - "use of %select{type|declaration}0 %1 requires %2 extension to be enabled">; + "use of %select{type|declaration}0 %1 requires %2 support">; +def ext_opencl_double_without_pragma : Extension< + "Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is" + " supported">; +def err_opencl_double_requires_extension : Error< + "use of type 'double' requires %select{cl_khr_fp64|cl_khr_fp64 and __opencl_c_fp64}0 support">; def warn_opencl_generic_address_space_arg : Warning< "passing non-generic address space pointer to %0" " may cause dynamic conversion affecting performance">, @@ -9912,7 +10121,8 @@ def err_opencl_builtin_pipe_invalid_access_modifier : Error< def err_opencl_invalid_access_qualifier : Error< "access qualifier can only be used for pipe and image type">; def err_opencl_invalid_read_write : Error< - "access qualifier %0 can not be used for %1 %select{|prior to OpenCL version 2.0}2">; + "access qualifier %0 can not be used for %1 %select{|prior to OpenCL C version 2.0 or in version 3.0 " + "and without __opencl_c_read_write_images feature}2">; def err_opencl_multiple_access_qualifiers : Error< "multiple access qualifiers">; def note_opencl_typedef_access_qualifier : Note< @@ -9947,9 +10157,9 @@ def err_opencl_enqueue_kernel_blocks_no_args : Error< def err_opencl_builtin_expected_type : Error< "illegal call to %0, expected %1 argument type">; -// OpenCL v2.2 s2.1.2.3 - Vector Component Access +// OpenCL v3.0 s6.3.7 - Vector Components def ext_opencl_ext_vector_type_rgba_selector: ExtWarn< - "vector component name '%0' is an OpenCL version 2.2 feature">, + "vector component name '%0' is an OpenCL C version 3.0 feature">, InGroup<OpenCLUnsupportedRGBA>; def err_openclcxx_placement_new : Error< @@ -10101,8 +10311,6 @@ def warn_omp_alignment_not_power_of_two : Warning< InGroup<OpenMPClauses>; def err_omp_invalid_target_decl : Error< "%0 used in declare target directive is not a variable or a function name">; -def err_omp_declare_target_multiple : Error< - "%0 appears multiple times in clauses on the same declare target directive">; def err_omp_declare_target_to_and_link : Error< "%0 must not appear in both clauses 'to' and 'link'">; def warn_omp_not_in_target_context : Warning< @@ -10465,6 +10673,8 @@ def err_omp_expected_private_copy_for_allocate : Error< "the referenced item is not found in any private clause on the same directive">; def err_omp_stmt_depends_on_loop_counter : Error< "the loop %select{initializer|condition}0 expression depends on the current loop control variable">; +def err_omp_invariant_dependency : Error< + "expected loop invariant expression">; def err_omp_invariant_or_linear_dependency : Error< "expected loop invariant expression or '<invariant1> * %0 + <invariant2>' kind of expression">; def err_omp_wrong_dependency_iterator_type : Error< @@ -10554,6 +10764,23 @@ def note_omp_protected_structured_block : Note<"jump bypasses OpenMP structured block">; def note_omp_exits_structured_block : Note<"jump exits scope of OpenMP structured block">; +def err_omp_interop_variable_expected : Error< + "expected%select{| non-const}0 variable of type 'omp_interop_t'">; +def err_omp_interop_variable_wrong_type : Error< + "interop variable must be of type 'omp_interop_t'">; +def err_omp_interop_prefer_type : Error< + "prefer_list item must be a string literal or constant integral " + "expression">; +def err_omp_interop_bad_depend_clause : Error< + "'depend' clause requires the 'targetsync' interop type">; +def err_omp_interop_var_multiple_actions : Error< + "interop variable %0 used in multiple action clauses">; +def err_omp_dispatch_statement_call + : Error<"statement after '#pragma omp dispatch' must be a direct call" + " to a target function or an assignment to one">; +def err_omp_unroll_full_variable_trip_count : Error< + "loop to be fully unrolled must have a constant trip count">; +def note_omp_directive_here : Note<"'%0' directive found here">; } // end of OpenMP category let CategoryName = "Related Result Type Issue" in { @@ -11119,4 +11346,10 @@ def err_tcb_conflicting_attributes : Error< def warn_tcb_enforcement_violation : Warning< "calling %0 is a violation of trusted computing base '%1'">, InGroup<DiagGroup<"tcb-enforcement">>; + +// RISC-V builtin required extension warning +def err_riscv_builtin_requires_extension : Error< + "builtin requires '%0' extension support to be enabled">; +def err_riscv_builtin_invalid_lmul : Error< + "LMUL argument must be in the range [0,3] or [5,7]">; } // end of sema component. diff --git a/clang/include/clang/Basic/DiagnosticSerializationKinds.td b/clang/include/clang/Basic/DiagnosticSerializationKinds.td index ce48833a8703..bf3221be004d 100644 --- a/clang/include/clang/Basic/DiagnosticSerializationKinds.td +++ b/clang/include/clang/Basic/DiagnosticSerializationKinds.td @@ -69,6 +69,9 @@ def err_module_file_not_module : Error< "AST file '%0' was not built as a module">, DefaultFatal; def err_module_file_missing_top_level_submodule : Error< "module file '%0' is missing its top-level submodule">, DefaultFatal; +def note_module_file_conflict : Note< + "this is generally caused by modules with the same name found in multiple " + "paths">; def remark_module_import : Remark< "importing module '%0'%select{| into '%3'}2 from '%1'">, diff --git a/clang/include/clang/Basic/DirectoryEntry.h b/clang/include/clang/Basic/DirectoryEntry.h index e0f4ae28321a..edb8031a20b8 100644 --- a/clang/include/clang/Basic/DirectoryEntry.h +++ b/clang/include/clang/Basic/DirectoryEntry.h @@ -120,8 +120,7 @@ public: MapEntryOptionalStorage() : MaybeRef(optional_none_tag()) {} template <class... ArgTypes> - explicit MapEntryOptionalStorage(llvm::optional_detail::in_place_t, - ArgTypes &&...Args) + explicit MapEntryOptionalStorage(llvm::in_place_t, ArgTypes &&...Args) : MaybeRef(std::forward<ArgTypes>(Args)...) {} void reset() { MaybeRef = optional_none_tag(); } diff --git a/clang/include/clang/Basic/Features.def b/clang/include/clang/Basic/Features.def index 5424da67b62d..6ca0e646b865 100644 --- a/clang/include/clang/Basic/Features.def +++ b/clang/include/clang/Basic/Features.def @@ -49,6 +49,7 @@ FEATURE(memtag_sanitizer, LangOpts.Sanitize.has(SanitizerKind::MemTag)) FEATURE(xray_instrument, LangOpts.XRayInstrument) FEATURE(undefined_behavior_sanitizer, LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined)) +FEATURE(coverage_sanitizer, LangOpts.SanitizeCoverage) FEATURE(assume_nonnull, true) FEATURE(attribute_analyzer_noreturn, true) FEATURE(attribute_availability, true) @@ -92,6 +93,9 @@ FEATURE(memory_sanitizer, FEATURE(thread_sanitizer, LangOpts.Sanitize.has(SanitizerKind::Thread)) FEATURE(dataflow_sanitizer, LangOpts.Sanitize.has(SanitizerKind::DataFlow)) FEATURE(scudo, LangOpts.Sanitize.hasOneOf(SanitizerKind::Scudo)) +FEATURE(swiftasynccc, + PP.getTargetInfo().checkCallingConvention(CC_SwiftAsync) == + clang::TargetInfo::CCCR_OK) // Objective-C features FEATURE(objc_arr, LangOpts.ObjCAutoRefCount) // FIXME: REMOVE? FEATURE(objc_arc, LangOpts.ObjCAutoRefCount) @@ -253,9 +257,12 @@ EXTENSION(cxx_variable_templates, LangOpts.CPlusPlus) EXTENSION(overloadable_unmarked, true) EXTENSION(pragma_clang_attribute_namespaces, true) EXTENSION(pragma_clang_attribute_external_declaration, true) +EXTENSION(statement_attributes_with_gnu_syntax, true) EXTENSION(gnu_asm, LangOpts.GNUAsm) EXTENSION(gnu_asm_goto_with_outputs, LangOpts.GNUAsm) EXTENSION(matrix_types, LangOpts.MatrixTypes) +EXTENSION(matrix_types_scalar_division, true) +EXTENSION(cxx_attributes_on_using_declarations, LangOpts.CPlusPlus11) FEATURE(cxx_abi_relative_vtable, LangOpts.CPlusPlus && LangOpts.RelativeCXXABIVTables) diff --git a/clang/include/clang/Basic/IdentifierTable.h b/clang/include/clang/Basic/IdentifierTable.h index 204a0f0cc0a5..f2379c7ddfbd 100644 --- a/clang/include/clang/Basic/IdentifierTable.h +++ b/clang/include/clang/Basic/IdentifierTable.h @@ -40,6 +40,14 @@ class LangOptions; class MultiKeywordSelector; class SourceLocation; +enum class ReservedIdentifierStatus { + NotReserved = 0, + StartsWithUnderscoreAtGlobalScope, + StartsWithDoubleUnderscore, + StartsWithUnderscoreFollowedByCapitalLetter, + ContainsDoubleUnderscore, +}; + /// A simple pair of identifier info and location. using IdentifierLocPair = std::pair<IdentifierInfo *, SourceLocation>; @@ -48,7 +56,7 @@ using IdentifierLocPair = std::pair<IdentifierInfo *, SourceLocation>; /// of a pointer to one of these classes. enum { IdentifierInfoAlignment = 8 }; -static constexpr int ObjCOrBuiltinIDBits = 15; +static constexpr int ObjCOrBuiltinIDBits = 16; /// One of these records is kept for each identifier that /// is lexed. This contains information about whether the token was \#define'd, @@ -385,14 +393,7 @@ public: /// Determine whether \p this is a name reserved for the implementation (C99 /// 7.1.3, C++ [lib.global.names]). - bool isReservedName(bool doubleUnderscoreOnly = false) const { - if (getLength() < 2) - return false; - const char *Name = getNameStart(); - return Name[0] == '_' && - (Name[1] == '_' || - (Name[1] >= 'A' && Name[1] <= 'Z' && !doubleUnderscoreOnly)); - } + ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const; /// Provide less than operator for lexicographical sorting. bool operator<(const IdentifierInfo &RHS) const { diff --git a/clang/include/clang/Basic/LLVM.h b/clang/include/clang/Basic/LLVM.h index 02e422051071..4ac2d744af3c 100644 --- a/clang/include/clang/Basic/LLVM.h +++ b/clang/include/clang/Basic/LLVM.h @@ -22,6 +22,9 @@ // None.h includes an enumerator that is desired & cannot be forward declared // without a definition of NoneType. #include "llvm/ADT/None.h" +// Add this header as a workaround to prevent `too few template arguments for +// class template 'SmallVector'` building error with build compilers like XL. +#include "llvm/ADT/SmallVector.h" namespace llvm { // ADT's. diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index c01f0cca9c9c..08b8d8851afa 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -98,6 +98,8 @@ BENIGN_LANGOPT(ObjCDefaultSynthProperties , 1, 0, "Objective-C auto-synthesized properties") BENIGN_LANGOPT(EncodeExtendedBlockSig , 1, 0, "Encoding extended block type signature") +BENIGN_LANGOPT(EncodeCXXClassTemplateSpec , 1, 0, + "Fully encode c++ class template specialization") BENIGN_LANGOPT(ObjCInferRelatedResultType , 1, 1, "Objective-C related result type inference") LANGOPT(AppExt , 1, 0, "Objective-C App Extension") @@ -107,6 +109,7 @@ LANGOPT(Bool , 1, 0, "bool, true, and false keywords") LANGOPT(Half , 1, 0, "half keyword") LANGOPT(WChar , 1, CPlusPlus, "wchar_t keyword") LANGOPT(Char8 , 1, 0, "char8_t keyword") +LANGOPT(IEEE128 , 1, 0, "__ieee128 keyword") LANGOPT(DeclSpecKeyword , 1, 0, "__declspec keyword") BENIGN_LANGOPT(DollarIdents , 1, 1, "'$' in identifiers") BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode") @@ -123,12 +126,15 @@ LANGOPT(WritableStrings , 1, 0, "writable string support") LANGOPT(ConstStrings , 1, 0, "const-qualified string support") ENUM_LANGOPT(LaxVectorConversions, LaxVectorConversionKind, 2, LaxVectorConversionKind::All, "lax vector conversions") +ENUM_LANGOPT(AltivecSrcCompat, AltivecSrcCompatKind, 2, + AltivecSrcCompatKind::Default, "Altivec source compatibility") LANGOPT(ConvergentFunctions, 1, 1, "Assume convergent functions") LANGOPT(AltiVec , 1, 0, "AltiVec-style vector initializers") LANGOPT(ZVector , 1, 0, "System z vector extensions") LANGOPT(Exceptions , 1, 0, "exception handling") LANGOPT(ObjCExceptions , 1, 0, "Objective-C exceptions") LANGOPT(CXXExceptions , 1, 0, "C++ exceptions") +LANGOPT(EHAsynch , 1, 0, "C/C++ EH Asynch exceptions") ENUM_LANGOPT(ExceptionHandling, ExceptionHandlingKind, 3, ExceptionHandlingKind::None, "exception handling") LANGOPT(IgnoreExceptions , 1, 0, "ignore exceptions") @@ -193,6 +199,8 @@ COMPATIBLE_LANGOPT(Deprecated , 1, 0, "__DEPRECATED predefined macro") COMPATIBLE_LANGOPT(FastMath , 1, 0, "fast FP math optimizations, and __FAST_MATH__ predefined macro") COMPATIBLE_LANGOPT(FiniteMathOnly , 1, 0, "__FINITE_MATH_ONLY__ predefined macro") COMPATIBLE_LANGOPT(UnsafeFPMath , 1, 0, "Unsafe Floating Point Math") +COMPATIBLE_LANGOPT(ProtectParens , 1, 0, "optimizer honors parentheses " + "when floating-point expressions are evaluated") BENIGN_LANGOPT(AllowFPReassoc , 1, 0, "Permit Floating Point reassociation") BENIGN_LANGOPT(NoHonorNaNs , 1, 0, "Permit Floating Point optimization without regard to NaN") BENIGN_LANGOPT(NoHonorInfs , 1, 0, "Permit Floating Point optimization without regard to infinities") @@ -215,6 +223,8 @@ LANGOPT(OpenCL , 1, 0, "OpenCL") LANGOPT(OpenCLVersion , 32, 0, "OpenCL C version") LANGOPT(OpenCLCPlusPlus , 1, 0, "C++ for OpenCL") LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "C++ for OpenCL version") +LANGOPT(OpenCLGenericAddressSpace, 1, 0, "OpenCL generic keyword") +LANGOPT(OpenCLPipe , 1, 0, "OpenCL pipe keyword") LANGOPT(NativeHalfType , 1, 0, "Native half type support") LANGOPT(NativeHalfArgsAndReturns, 1, 0, "Native half args and returns") LANGOPT(HalfArgsAndReturns, 1, 0, "half args and returns") @@ -230,8 +240,8 @@ LANGOPT(OpenMPCUDAForceFullRuntime , 1, 0, "Force to use full runtime in all con LANGOPT(OpenMPCUDANumSMs , 32, 0, "Number of SMs for CUDA devices.") LANGOPT(OpenMPCUDABlocksPerSM , 32, 0, "Number of blocks per SM for CUDA devices.") LANGOPT(OpenMPCUDAReductionBufNum , 32, 1024, "Number of the reduction records in the intermediate reduction buffer used for the teams reductions.") +LANGOPT(OpenMPTargetNewRuntime , 1, 0, "Use the new bitcode library for OpenMP offloading") LANGOPT(OpenMPOptimisticCollapse , 1, 0, "Use at most 32 bits to represent the collapsed loop nest counter.") -LANGOPT(OpenMPCUDATargetParallel, 1, 0, "Support parallel execution of target region on Cuda-based devices.") LANGOPT(RenderScript , 1, 0, "RenderScript") LANGOPT(CUDAIsDevice , 1, 0, "compiling for CUDA device") @@ -240,13 +250,13 @@ LANGOPT(CUDAHostDeviceConstexpr, 1, 1, "treating unattributed constexpr function LANGOPT(CUDADeviceApproxTranscendentals, 1, 0, "using approximate transcendental functions") LANGOPT(GPURelocatableDeviceCode, 1, 0, "generate relocatable device code") LANGOPT(GPUAllowDeviceInit, 1, 0, "allowing device side global init functions for HIP") -LANGOPT(GPUMaxThreadsPerBlock, 32, 256, "default max threads per block for kernel launch bounds for HIP") +LANGOPT(GPUMaxThreadsPerBlock, 32, 1024, "default max threads per block for kernel launch bounds for HIP") LANGOPT(GPUDeferDiag, 1, 0, "defer host/device related diagnostic messages for CUDA/HIP") LANGOPT(GPUExcludeWrongSideOverloads, 1, 0, "always exclude wrong side overloads in overloading resolution for CUDA/HIP") -LANGOPT(SYCL , 1, 0, "SYCL") LANGOPT(SYCLIsDevice , 1, 0, "Generate code for SYCL device") -ENUM_LANGOPT(SYCLVersion , SYCLMajorVersion, 1, SYCL_None, "Version of the SYCL standard used") +LANGOPT(SYCLIsHost , 1, 0, "SYCL host compilation") +ENUM_LANGOPT(SYCLVersion , SYCLMajorVersion, 2, SYCL_None, "Version of the SYCL standard used") LANGOPT(HIPUseNewLaunchAPI, 1, 0, "Use new kernel launching API for HIP") @@ -260,9 +270,12 @@ BENIGN_LANGOPT(ModulesDebugInfo , 1, 0, "Modules debug info") BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision") BENIGN_LANGOPT(DumpRecordLayouts , 1, 0, "dumping the layout of IRgen'd records") BENIGN_LANGOPT(DumpRecordLayoutsSimple , 1, 0, "dumping the layout of IRgen'd records in a simple form") +BENIGN_LANGOPT(DumpRecordLayoutsCanonical , 1, 0, "dumping the AST layout of records using canonical field types") +BENIGN_LANGOPT(DumpRecordLayoutsComplete , 1, 0, "dumping the AST layout of all complete records") BENIGN_LANGOPT(DumpVTableLayouts , 1, 0, "dumping the layouts of emitted vtables") LANGOPT(NoConstantCFStrings , 1, 0, "no constant CoreFoundation strings") BENIGN_LANGOPT(InlineVisibilityHidden , 1, 0, "hidden visibility for inline C++ methods") +BENIGN_LANGOPT(IgnoreXCOFFVisibility, 1, 0, "All the visibility attributes that are specified in the source code are ignored in aix XCOFF.") BENIGN_LANGOPT(VisibilityInlinesHiddenStaticLocalVar, 1, 0, "hidden visibility for static local variables in inline C++ " "methods when -fvisibility-inlines hidden is enabled") @@ -292,6 +305,8 @@ LANGOPT(ObjCSubscriptingLegacyRuntime , 1, 0, "Subscripting support in l BENIGN_LANGOPT(CompatibilityQualifiedIdBlockParamTypeChecking, 1, 0, "compatibility mode for type checking block parameters " "involving qualified id types") +LANGOPT(ObjCDisableDirectMethodsForTesting, 1, 0, + "Disable recognition of objc_direct methods") LANGOPT(CFProtectionBranch , 1, 0, "Control-Flow Branch Protection enabled") LANGOPT(FakeAddressSpaceMap , 1, 0, "OpenCL fake address space map") ENUM_LANGOPT(AddressSpaceMapMangling , AddrSpaceMapMangling, 2, ASMM_Target, "OpenCL address space map mangling mode") @@ -406,6 +421,10 @@ LANGOPT(RelativeCXXABIVTables, 1, 0, LANGOPT(ArmSveVectorBits, 32, 0, "SVE vector size in bits") +ENUM_LANGOPT(ExtendIntArgs, ExtendArgsKind, 1, ExtendArgsKind::ExtendTo32, + "Controls how scalar integer arguments are extended in calls " + "to unprototyped and varargs functions") + #undef LANGOPT #undef COMPATIBLE_LANGOPT #undef BENIGN_LANGOPT diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h index d8bd2a8b52fc..71cf0c65e692 100644 --- a/clang/include/clang/Basic/LangOptions.h +++ b/clang/include/clang/Basic/LangOptions.h @@ -19,11 +19,11 @@ #include "clang/Basic/LangStandard.h" #include "clang/Basic/ObjCRuntime.h" #include "clang/Basic/Sanitizers.h" +#include "clang/Basic/TargetCXXABI.h" #include "clang/Basic/Visibility.h" #include "llvm/ADT/FloatingPointMode.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" -#include "llvm/MC/MCTargetOptions.h" #include <string> #include <vector> @@ -124,11 +124,16 @@ public: MSVC2017_5 = 1912, MSVC2017_7 = 1914, MSVC2019 = 1920, + MSVC2019_8 = 1928, }; enum SYCLMajorVersion { SYCL_None, SYCL_2017, + SYCL_2020, + // The "default" SYCL version to be used when none is specified on the + // frontend command line. + SYCL_Default = SYCL_2020 }; /// Clang versions with different platform ABI conformance. @@ -163,13 +168,18 @@ public: Ver9, /// Attempt to be ABI-compatible with code generated by Clang 11.0.x - /// (git 2e10b7a39b93). This causes clang to pass unions with a 256-bit + /// (git 2e10b7a39b93). This causes clang to pass unions with a 256-bit /// vector member on the stack instead of using registers, to not properly /// mangle substitutions for template names in some cases, and to mangle /// declaration template arguments without a cast to the parameter type /// even when that can lead to mangling collisions. Ver11, + /// Attempt to be ABI-compatible with code generated by Clang 12.0.x + /// (git 8e464dd76bef). This causes clang to mangle lambdas within + /// global-scope inline variables incorrectly. + Ver12, + /// Conform to the underlying platform's C and C++ ABIs as closely /// as we can. Latest @@ -221,7 +231,7 @@ public: }; /// Possible exception handling behavior. - using ExceptionHandlingKind = llvm::ExceptionHandling; + enum class ExceptionHandlingKind { None, SjLj, WinEH, DwarfCFI, Wasm }; enum class LaxVectorConversionKind { /// Permit no implicit vector bitcasts. @@ -234,6 +244,18 @@ public: All, }; + enum class AltivecSrcCompatKind { + // All vector compares produce scalars except vector pixel and vector bool. + // The types vector pixel and vector bool return vector results. + Mixed, + // All vector compares produce vector results as in GCC. + GCC, + // All vector compares produce scalars as in XL. + XL, + // Default clang behaviour. + Default = Mixed, + }; + enum class SignReturnAddressScopeKind { /// No signing for any function. None, @@ -257,16 +279,25 @@ public: Single }; + enum class ExtendArgsKind { + /// Integer arguments are sign or zero extended to 32/64 bits + /// during default argument promotions. + ExtendTo32, + ExtendTo64 + }; + public: /// The used language standard. LangStandard::Kind LangStd; /// Set of enabled sanitizers. SanitizerSet Sanitize; + /// Is at least one coverage instrumentation type enabled. + bool SanitizeCoverage = false; - /// Paths to blacklist files specifying which objects + /// Paths to files specifying which objects /// (files, functions, variables) should not be instrumented. - std::vector<std::string> SanitizerBlacklistFiles; + std::vector<std::string> NoSanitizeFiles; /// Paths to the XRay "always instrument" files specifying which /// objects (files, functions, variables) should be imbued with the XRay @@ -331,6 +362,16 @@ public: /// host code generation. std::string OMPHostIRFile; + /// The user provided compilation unit ID, if non-empty. This is used to + /// externalize static variables which is needed to support accessing static + /// device variables in host code for single source offloading languages + /// like CUDA/HIP. + std::string CUID; + + /// C++ ABI to compile with, if specified by the frontend through -fc++-abi=. + /// This overrides the default ABI used by the target. + llvm::Optional<TargetCXXABI::Kind> CXXABI; + /// Indicates whether the front-end is explicitly told that the /// input is a header file (i.e. -x c-header). bool IsHeaderFile = false; @@ -403,20 +444,22 @@ public: } bool hasSjLjExceptions() const { - return getExceptionHandling() == llvm::ExceptionHandling::SjLj; + return getExceptionHandling() == ExceptionHandlingKind::SjLj; } bool hasSEHExceptions() const { - return getExceptionHandling() == llvm::ExceptionHandling::WinEH; + return getExceptionHandling() == ExceptionHandlingKind::WinEH; } bool hasDWARFExceptions() const { - return getExceptionHandling() == llvm::ExceptionHandling::DwarfCFI; + return getExceptionHandling() == ExceptionHandlingKind::DwarfCFI; } bool hasWasmExceptions() const { - return getExceptionHandling() == llvm::ExceptionHandling::Wasm; + return getExceptionHandling() == ExceptionHandlingKind::Wasm; } + + bool isSYCL() const { return SYCLIsDevice || SYCLIsHost; } }; /// Floating point control options @@ -654,7 +697,11 @@ enum TranslationUnitKind { TU_Prefix, /// The translation unit is a module. - TU_Module + TU_Module, + + /// The translation unit is a is a complete translation unit that we might + /// incrementally extend later. + TU_Incremental }; } // namespace clang diff --git a/clang/include/clang/Basic/LangStandard.h b/clang/include/clang/Basic/LangStandard.h index f82ce05a6369..b0785409628c 100644 --- a/clang/include/clang/Basic/LangStandard.h +++ b/clang/include/clang/Basic/LangStandard.h @@ -32,6 +32,7 @@ enum class Language : uint8_t { ObjC, ObjCXX, OpenCL, + OpenCLCXX, CUDA, RenderScript, HIP, diff --git a/clang/include/clang/Basic/LangStandards.def b/clang/include/clang/Basic/LangStandards.def index f086d8a43ccb..2cfeb68e56d6 100644 --- a/clang/include/clang/Basic/LangStandards.def +++ b/clang/include/clang/Basic/LangStandards.def @@ -194,11 +194,11 @@ LANGSTANDARD_ALIAS_DEPR(openclcpp, "CLC++") // CUDA LANGSTANDARD(cuda, "cuda", CUDA, "NVIDIA CUDA(tm)", - LineComment | CPlusPlus | Digraphs) + LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | Digraphs) // HIP LANGSTANDARD(hip, "hip", HIP, "HIP", - LineComment | CPlusPlus | Digraphs) + LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | Digraphs) #undef LANGSTANDARD #undef LANGSTANDARD_ALIAS diff --git a/clang/include/clang/Basic/Module.h b/clang/include/clang/Basic/Module.h index f5b176f8d20b..3476b05d2e92 100644 --- a/clang/include/clang/Basic/Module.h +++ b/clang/include/clang/Basic/Module.h @@ -133,9 +133,7 @@ public: std::string PresumedModuleMapFile; /// The umbrella header or directory. - llvm::PointerUnion<const FileEntryRef::MapEntry *, - const DirectoryEntryRef::MapEntry *> - Umbrella; + llvm::PointerUnion<const FileEntry *, const DirectoryEntry *> Umbrella; /// The module signature. ASTFileSignature Signature; @@ -143,6 +141,9 @@ public: /// The name of the umbrella entry, as written in the module map. std::string UmbrellaAsWritten; + // The path to the umbrella entry relative to the root module's \c Directory. + std::string UmbrellaRelativeToRootModuleDirectory; + /// The module through which entities defined in this module will /// eventually be exposed, for use in "private" modules. std::string ExportAsModule; @@ -190,18 +191,20 @@ public: /// file. struct Header { std::string NameAsWritten; - OptionalFileEntryRefDegradesToFileEntryPtr Entry; + std::string PathRelativeToRootModuleDirectory; + const FileEntry *Entry; - explicit operator bool() { return Entry != None; } + explicit operator bool() { return Entry; } }; /// Information about a directory name as found in the module map /// file. struct DirectoryName { std::string NameAsWritten; - OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr Entry; + std::string PathRelativeToRootModuleDirectory; + const DirectoryEntry *Entry; - explicit operator bool() { return Entry != None; } + explicit operator bool() { return Entry; } }; /// The headers that are part of this module. @@ -546,15 +549,16 @@ public: /// Retrieve the header that serves as the umbrella header for this /// module. Header getUmbrellaHeader() const { - if (auto *ME = Umbrella.dyn_cast<const FileEntryRef::MapEntry *>()) - return Header{UmbrellaAsWritten, FileEntryRef(*ME)}; + if (auto *FE = Umbrella.dyn_cast<const FileEntry *>()) + return Header{UmbrellaAsWritten, UmbrellaRelativeToRootModuleDirectory, + FE}; return Header{}; } /// Determine whether this module has an umbrella directory that is /// not based on an umbrella header. bool hasUmbrellaDir() const { - return Umbrella && Umbrella.is<const DirectoryEntryRef::MapEntry *>(); + return Umbrella && Umbrella.is<const DirectoryEntry *>(); } /// Add a top-level header associated with this module. @@ -639,7 +643,7 @@ public: } /// Print the module map for this module to the given stream. - void print(raw_ostream &OS, unsigned Indent = 0) const; + void print(raw_ostream &OS, unsigned Indent = 0, bool Dump = false) const; /// Dump the contents of this module to the given output stream. void dump() const; diff --git a/clang/include/clang/Basic/NoSanitizeList.h b/clang/include/clang/Basic/NoSanitizeList.h new file mode 100644 index 000000000000..3f80e0fdedda --- /dev/null +++ b/clang/include/clang/Basic/NoSanitizeList.h @@ -0,0 +1,50 @@ +//===--- NoSanitizeList.h - List of ignored entities for sanitizers --*- C++ +//-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// User-provided list of ignored entities used to disable/alter +// instrumentation done in sanitizers. +// +//===----------------------------------------------------------------------===// +#ifndef LLVM_CLANG_BASIC_NOSANITIZELIST_H +#define LLVM_CLANG_BASIC_NOSANITIZELIST_H + +#include "clang/Basic/LLVM.h" +#include "clang/Basic/SourceLocation.h" +#include "llvm/ADT/StringRef.h" +#include <memory> +#include <vector> + +namespace clang { + +class SanitizerMask; +class SourceManager; +class SanitizerSpecialCaseList; + +class NoSanitizeList { + std::unique_ptr<SanitizerSpecialCaseList> SSCL; + SourceManager &SM; + +public: + NoSanitizeList(const std::vector<std::string> &NoSanitizeListPaths, + SourceManager &SM); + ~NoSanitizeList(); + bool containsGlobal(SanitizerMask Mask, StringRef GlobalName, + StringRef Category = StringRef()) const; + bool containsType(SanitizerMask Mask, StringRef MangledTypeName, + StringRef Category = StringRef()) const; + bool containsFunction(SanitizerMask Mask, StringRef FunctionName) const; + bool containsFile(SanitizerMask Mask, StringRef FileName, + StringRef Category = StringRef()) const; + bool containsLocation(SanitizerMask Mask, SourceLocation Loc, + StringRef Category = StringRef()) const; +}; + +} // end namespace clang + +#endif diff --git a/clang/include/clang/Basic/OpenCLExtensions.def b/clang/include/clang/Basic/OpenCLExtensions.def index 801916c3ab94..a053a0e9adb5 100644 --- a/clang/include/clang/Basic/OpenCLExtensions.def +++ b/clang/include/clang/Basic/OpenCLExtensions.def @@ -16,8 +16,12 @@ // If extensions are to be enumerated with information about whether // an extension is core or optional core and minimum OpenCL version // when an extension becomes available, -// define OPENCL_GENERIC_EXTENSION(ext, avail, core, opt) where +// define OPENCL_GENERIC_EXTENSION(ext, pragma, avail, core, opt) where // ext - name of the extension or optional core feature. +// pragma - true if extension needs pragmas or false otherwise. +// NOTE: extension pragma without any documentation detailing +// its behavior explicitly is deprecated. Therefore the default +// value is false. // avail - minimum OpenCL version supporting it. // core - OpenCL versions mask when the extension becomes core feature. // 0U indicates not a core feature. @@ -50,55 +54,69 @@ #endif // OPENCL_GENERIC_EXTENSION // Declaration helpers -#define OPENCL_EXTENSION(ext, avail) OPENCL_GENERIC_EXTENSION(ext, avail, 0U, 0U) -#define OPENCL_COREFEATURE(ext, avail, core) OPENCL_GENERIC_EXTENSION(ext, avail, core, 0U) -#define OPENCL_OPTIONALCOREFEATURE(ext, avail, opt) OPENCL_GENERIC_EXTENSION(ext, avail, 0U, opt) +#define OPENCL_EXTENSION(ext, pragma, avail) OPENCL_GENERIC_EXTENSION(ext, pragma, avail, 0U, 0U) +#define OPENCL_COREFEATURE(ext, pragma, avail, core) OPENCL_GENERIC_EXTENSION(ext, pragma, avail, core, 0U) +#define OPENCL_OPTIONALCOREFEATURE(ext, pragma, avail, opt) OPENCL_GENERIC_EXTENSION(ext, pragma, avail, 0U, opt) // OpenCL 1.0. -OPENCL_COREFEATURE(cl_khr_byte_addressable_store, 100, OCL_C_11P) -OPENCL_COREFEATURE(cl_khr_global_int32_base_atomics, 100, OCL_C_11P) -OPENCL_COREFEATURE(cl_khr_global_int32_extended_atomics, 100, OCL_C_11P) -OPENCL_COREFEATURE(cl_khr_local_int32_base_atomics, 100, OCL_C_11P) -OPENCL_COREFEATURE(cl_khr_local_int32_extended_atomics, 100, OCL_C_11P) -OPENCL_OPTIONALCOREFEATURE(cl_khr_fp64, 100, OCL_C_12P) -OPENCL_EXTENSION(cl_khr_fp16, 100) -OPENCL_EXTENSION(cl_khr_int64_base_atomics, 100) -OPENCL_EXTENSION(cl_khr_int64_extended_atomics, 100) -OPENCL_GENERIC_EXTENSION(cl_khr_3d_image_writes, 100, OCL_C_20, OCL_C_30) +OPENCL_COREFEATURE(cl_khr_byte_addressable_store, true, 100, OCL_C_11P) +OPENCL_COREFEATURE(cl_khr_global_int32_base_atomics, true, 100, OCL_C_11P) +OPENCL_COREFEATURE(cl_khr_global_int32_extended_atomics, true, 100, OCL_C_11P) +OPENCL_COREFEATURE(cl_khr_local_int32_base_atomics, true, 100, OCL_C_11P) +OPENCL_COREFEATURE(cl_khr_local_int32_extended_atomics, true, 100, OCL_C_11P) +OPENCL_OPTIONALCOREFEATURE(cl_khr_fp64, true, 100, OCL_C_12P) +OPENCL_EXTENSION(cl_khr_fp16, true, 100) +OPENCL_EXTENSION(cl_khr_int64_base_atomics, true, 100) +OPENCL_EXTENSION(cl_khr_int64_extended_atomics, true, 100) +OPENCL_GENERIC_EXTENSION(cl_khr_3d_image_writes, true, 100, OCL_C_20, OCL_C_30) // EMBEDDED_PROFILE -OPENCL_EXTENSION(cles_khr_int64, 110) +OPENCL_EXTENSION(cles_khr_int64, true, 110) // OpenCL 1.2. -OPENCL_EXTENSION(cl_khr_depth_images, 120) -OPENCL_EXTENSION(cl_khr_gl_msaa_sharing, 120) +OPENCL_EXTENSION(cl_khr_depth_images, true, 120) +OPENCL_EXTENSION(cl_khr_gl_msaa_sharing,true, 120) // OpenCL 2.0. -OPENCL_EXTENSION(cl_khr_mipmap_image, 200) -OPENCL_EXTENSION(cl_khr_mipmap_image_writes, 200) -OPENCL_EXTENSION(cl_khr_srgb_image_writes, 200) -OPENCL_EXTENSION(cl_khr_subgroups, 200) +OPENCL_EXTENSION(cl_khr_mipmap_image, true, 200) +OPENCL_EXTENSION(cl_khr_mipmap_image_writes, true, 200) +OPENCL_EXTENSION(cl_khr_srgb_image_writes, true, 200) +OPENCL_EXTENSION(cl_khr_subgroups, true, 200) // Clang Extensions. -OPENCL_EXTENSION(cl_clang_storage_class_specifiers, 100) -OPENCL_EXTENSION(__cl_clang_function_pointers, 100) -OPENCL_EXTENSION(__cl_clang_variadic_functions, 100) +OPENCL_EXTENSION(cl_clang_storage_class_specifiers, true, 100) +OPENCL_EXTENSION(__cl_clang_function_pointers, true, 100) +OPENCL_EXTENSION(__cl_clang_variadic_functions, true, 100) +OPENCL_EXTENSION(__cl_clang_non_portable_kernel_param_types, true, 100) +OPENCL_EXTENSION(__cl_clang_bitfields, true, 100) // AMD OpenCL extensions -OPENCL_EXTENSION(cl_amd_media_ops, 100) -OPENCL_EXTENSION(cl_amd_media_ops2, 100) +OPENCL_EXTENSION(cl_amd_media_ops, true, 100) +OPENCL_EXTENSION(cl_amd_media_ops2, true, 100) // ARM OpenCL extensions -OPENCL_EXTENSION(cl_arm_integer_dot_product_int8, 120) -OPENCL_EXTENSION(cl_arm_integer_dot_product_accumulate_int8, 120) -OPENCL_EXTENSION(cl_arm_integer_dot_product_accumulate_int16, 120) -OPENCL_EXTENSION(cl_arm_integer_dot_product_accumulate_saturate_int8, 120) +OPENCL_EXTENSION(cl_arm_integer_dot_product_int8, true, 120) +OPENCL_EXTENSION(cl_arm_integer_dot_product_accumulate_int8, true, 120) +OPENCL_EXTENSION(cl_arm_integer_dot_product_accumulate_int16, true, 120) +OPENCL_EXTENSION(cl_arm_integer_dot_product_accumulate_saturate_int8, true, 120) // Intel OpenCL extensions -OPENCL_EXTENSION(cl_intel_subgroups, 120) -OPENCL_EXTENSION(cl_intel_subgroups_short, 120) -OPENCL_EXTENSION(cl_intel_device_side_avc_motion_estimation, 120) +OPENCL_EXTENSION(cl_intel_subgroups, true, 120) +OPENCL_EXTENSION(cl_intel_subgroups_short, true, 120) +OPENCL_EXTENSION(cl_intel_device_side_avc_motion_estimation, true, 120) +// OpenCL C 3.0 features (6.2.1. Features) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_pipes, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_generic_address_space, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_acq_rel, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_seq_cst, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_subgroups, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_3d_image_writes, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_device_enqueue, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_read_write_images, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_program_scope_global_variables, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_fp64, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_images, false, 300, OCL_C_30) #undef OPENCL_OPTIONALCOREFEATURE #undef OPENCL_COREFEATURE diff --git a/clang/include/clang/Basic/OpenCLImageTypes.def b/clang/include/clang/Basic/OpenCLImageTypes.def index cfb018a661ae..ada5892c06b3 100644 --- a/clang/include/clang/Basic/OpenCLImageTypes.def +++ b/clang/include/clang/Basic/OpenCLImageTypes.def @@ -65,7 +65,7 @@ IMAGE_WRITE_TYPE(image2d_msaa, OCLImage2dMSAA, "cl_khr_gl_msaa_sharing") IMAGE_WRITE_TYPE(image2d_array_msaa, OCLImage2dArrayMSAA, "cl_khr_gl_msaa_sharing") IMAGE_WRITE_TYPE(image2d_msaa_depth, OCLImage2dMSAADepth, "cl_khr_gl_msaa_sharing") IMAGE_WRITE_TYPE(image2d_array_msaa_depth, OCLImage2dArrayMSAADepth, "cl_khr_gl_msaa_sharing") -IMAGE_WRITE_TYPE(image3d, OCLImage3d, "cl_khr_3d_image_writes") +IMAGE_WRITE_TYPE(image3d, OCLImage3d, "") IMAGE_READ_WRITE_TYPE(image1d, OCLImage1d, "") IMAGE_READ_WRITE_TYPE(image1d_array, OCLImage1dArray, "") diff --git a/clang/include/clang/Basic/OpenCLOptions.h b/clang/include/clang/Basic/OpenCLOptions.h index fe27ef19d4d5..1a035626fade 100644 --- a/clang/include/clang/Basic/OpenCLOptions.h +++ b/clang/include/clang/Basic/OpenCLOptions.h @@ -19,6 +19,9 @@ namespace clang { +class DiagnosticsEngine; +class TargetInfo; + namespace { // This enum maps OpenCL version(s) into value. These values are used as // a mask to indicate in which OpenCL version(s) extension is a core or @@ -51,28 +54,48 @@ static inline OpenCLVersionID encodeOpenCLVersion(unsigned OpenCLVersion) { } } -// Simple helper to check if OpenCL C version is contained in a given encoded -// OpenCL C version mask -static inline bool isOpenCLVersionIsContainedInMask(const LangOptions &LO, - unsigned Mask) { +// Check if OpenCL C version is contained in a given encoded OpenCL C version +// mask. +static inline bool isOpenCLVersionContainedInMask(const LangOptions &LO, + unsigned Mask) { auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion; OpenCLVersionID Code = encodeOpenCLVersion(CLVer); return Mask & Code; } + } // end anonymous namespace /// OpenCL supported extensions and optional core features class OpenCLOptions { + public: + // OpenCL C v1.2 s6.5 - All program scope variables must be declared in the + // __constant address space. + // OpenCL C v2.0 s6.5.1 - Variables defined at program scope and static + // variables inside a function can also be declared in the global + // address space. + // OpenCL C v3.0 s6.7.1 - Variables at program scope or static or extern + // variables inside functions can be declared in global address space if + // the __opencl_c_program_scope_global_variables feature is supported + // C++ for OpenCL inherits rule from OpenCL C v2.0. + bool areProgramScopeVariablesSupported(const LangOptions &Opts) const { + return Opts.OpenCLCPlusPlus || Opts.OpenCLVersion == 200 || + (Opts.OpenCLVersion == 300 && + isSupported("__opencl_c_program_scope_global_variables", Opts)); + } + struct OpenCLOptionInfo { + // Does this option have pragma. + bool WithPragma = false; + // Option starts to be available in this OpenCL version - unsigned Avail; + unsigned Avail = 100U; // Option becomes core feature in this OpenCL versions - unsigned Core; + unsigned Core = 0U; // Option becomes optional core feature in this OpenCL versions - unsigned Opt; + unsigned Opt = 0U; // Is this option supported bool Supported = false; @@ -80,8 +103,10 @@ public: // Is this option enabled bool Enabled = false; - OpenCLOptionInfo(unsigned A = 100, unsigned C = 0U, unsigned O = 0U) - : Avail(A), Core(C), Opt(O) {} + OpenCLOptionInfo() = default; + OpenCLOptionInfo(bool Pragma, unsigned AvailV, unsigned CoreV, + unsigned OptV) + : WithPragma(Pragma), Avail(AvailV), Core(CoreV), Opt(OptV) {} bool isCore() const { return Core != 0U; } @@ -96,18 +121,23 @@ public: // Is core option in OpenCL version \p LO. bool isCoreIn(const LangOptions &LO) const { - return isAvailableIn(LO) && isOpenCLVersionIsContainedInMask(LO, Core); + return isAvailableIn(LO) && isOpenCLVersionContainedInMask(LO, Core); } // Is optional core option in OpenCL version \p LO. bool isOptionalCoreIn(const LangOptions &LO) const { - return isAvailableIn(LO) && isOpenCLVersionIsContainedInMask(LO, Opt); + return isAvailableIn(LO) && isOpenCLVersionContainedInMask(LO, Opt); } }; bool isKnown(llvm::StringRef Ext) const; - bool isEnabled(llvm::StringRef Ext) const; + // For core or optional core feature check that it is supported + // by a target, for any other option (extension) check that it is + // enabled via pragma + bool isAvailableOption(llvm::StringRef Ext, const LangOptions &LO) const; + + bool isWithPragma(llvm::StringRef Ext) const; // Is supported as either an extension or an (optional) core feature for // OpenCL version \p LO. @@ -131,6 +161,11 @@ public: // For supported core or optional core feature, return false. bool isSupportedExtension(llvm::StringRef Ext, const LangOptions &LO) const; + // FIXME: Whether extension should accept pragma should not + // be reset dynamically. But it currently required when + // registering new extensions via pragmas. + void acceptsPragma(llvm::StringRef Ext, bool V = true); + void enable(llvm::StringRef Ext, bool V = true); /// Enable or disable support for OpenCL extensions @@ -139,7 +174,6 @@ public: void support(llvm::StringRef Ext, bool V = true); OpenCLOptions(); - OpenCLOptions(const OpenCLOptions &) = default; // Set supported options based on target settings and language version void addSupport(const llvm::StringMap<bool> &FeaturesMap, @@ -148,15 +182,36 @@ public: // Disable all extensions void disableAll(); - // Enable supported core and optional core features - void enableSupportedCore(const LangOptions &LO); - friend class ASTWriter; friend class ASTReader; using OpenCLOptionInfoMap = llvm::StringMap<OpenCLOptionInfo>; + template <typename... Args> + static bool isOpenCLOptionCoreIn(const LangOptions &LO, Args &&... args) { + return OpenCLOptionInfo(std::forward<Args>(args)...).isCoreIn(LO); + } + + template <typename... Args> + static bool isOpenCLOptionAvailableIn(const LangOptions &LO, + Args &&... args) { + return OpenCLOptionInfo(std::forward<Args>(args)...).isAvailableIn(LO); + } + + // Diagnose feature dependencies for OpenCL C 3.0. Return false if target + // doesn't follow these requirements. + static bool diagnoseUnsupportedFeatureDependencies(const TargetInfo &TI, + DiagnosticsEngine &Diags); + + // Diagnose that features and equivalent extension are set to same values. + // Return false if target doesn't follow these requirements. + static bool diagnoseFeatureExtensionDifferences(const TargetInfo &TI, + DiagnosticsEngine &Diags); + private: + // Option is enabled via pragma + bool isEnabled(llvm::StringRef Ext) const; + OpenCLOptionInfoMap OptMap; }; diff --git a/clang/include/clang/Basic/OpenMPKinds.h b/clang/include/clang/Basic/OpenMPKinds.h index 0f37dc9ad997..c7a2591de26c 100644 --- a/clang/include/clang/Basic/OpenMPKinds.h +++ b/clang/include/clang/Basic/OpenMPKinds.h @@ -267,6 +267,11 @@ bool isOpenMPTaskingDirective(OpenMPDirectiveKind Kind); /// functions bool isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind); +/// Checks if the specified directive is a loop transformation directive. +/// \param DKind Specified directive. +/// \return True iff the directive is a loop transformation. +bool isOpenMPLoopTransformationDirective(OpenMPDirectiveKind DKind); + /// Return the captured regions of an OpenMP directive. void getOpenMPCaptureRegions( llvm::SmallVectorImpl<OpenMPDirectiveKind> &CaptureRegions, diff --git a/clang/include/clang/Basic/RISCVVTypes.def b/clang/include/clang/Basic/RISCVVTypes.def new file mode 100644 index 000000000000..f6ef62a64636 --- /dev/null +++ b/clang/include/clang/Basic/RISCVVTypes.def @@ -0,0 +1,147 @@ +//===-- RISCVVTypes.def - Metadata for the RISC-V V types ------*- C++ -*--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines various RISC-V V builtin types. The macros are: +// +// - RVV_TYPE(Name, Id, SingletonId) +// A builtin type that has not been covered by any other #define +// Defining this macro covers all the builtins. +// +// - RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, IsSigned, IsFP) +// A RISC-V V scalable vector. +// +// - RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) +// An RISC-V V scalable mask. +// +// where: +// +// - Name is the name of the builtin type. +// +// - Id is the enumerator defining the type. +// +// - SingletonId is the global singleton of this type. +// +// - NumEls enumerates the number of the elements. +// +// - ElBits is the size of one element in bits (SEW). +// +// - NF is the number of fields (NFIELDS) used in the Zvlsseg instructions +// (TODO). +// +// - IsSigned is true for vectors of signed integer elements and +// for vectors of floating-point elements. +// +// - IsFP is true for vectors of floating-point elements. +// +//===----------------------------------------------------------------------===// + +#ifndef RVV_VECTOR_TYPE +#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, IsFP)\ + RVV_TYPE(Name, Id, SingletonId) +#endif + +#ifndef RVV_PREDICATE_TYPE +#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls)\ + RVV_TYPE(Name, Id, SingletonId) +#endif + +#ifndef RVV_VECTOR_TYPE_INT +#define RVV_VECTOR_TYPE_INT(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned) \ + RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, false) +#endif + +#ifndef RVV_VECTOR_TYPE_FLOAT +#define RVV_VECTOR_TYPE_FLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \ + RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, false, true) +#endif + +//===- Vector types -------------------------------------------------------===// + +RVV_VECTOR_TYPE_INT("__rvv_int8mf8_t", RvvInt8mf8, RvvInt8mf8Ty, 1, 8, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int8mf4_t", RvvInt8mf4, RvvInt8mf4Ty, 2, 8, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int8mf2_t", RvvInt8mf2, RvvInt8mf2Ty, 4, 8, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int8m1_t", RvvInt8m1, RvvInt8m1Ty, 8, 8, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int8m2_t", RvvInt8m2, RvvInt8m2Ty, 16, 8, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int8m4_t", RvvInt8m4, RvvInt8m4Ty, 32, 8, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int8m8_t", RvvInt8m8, RvvInt8m8Ty, 64, 8, 1, true) + +RVV_VECTOR_TYPE_INT("__rvv_uint8mf8_t",RvvUint8mf8,RvvUint8mf8Ty,1, 8, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint8mf4_t",RvvUint8mf4,RvvUint8mf4Ty,2, 8, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint8mf2_t",RvvUint8mf2,RvvUint8mf2Ty,4, 8, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint8m1_t", RvvUint8m1, RvvUint8m1Ty, 8, 8, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint8m2_t", RvvUint8m2, RvvUint8m2Ty, 16, 8, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint8m4_t", RvvUint8m4, RvvUint8m4Ty, 32, 8, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint8m8_t", RvvUint8m8, RvvUint8m8Ty, 64, 8, 1, false) + +RVV_VECTOR_TYPE_INT("__rvv_int16mf4_t",RvvInt16mf4,RvvInt16mf4Ty,1, 16, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int16mf2_t",RvvInt16mf2,RvvInt16mf2Ty,2, 16, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int16m1_t", RvvInt16m1, RvvInt16m1Ty, 4, 16, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int16m2_t", RvvInt16m2, RvvInt16m2Ty, 8, 16, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int16m4_t", RvvInt16m4, RvvInt16m4Ty, 16, 16, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int16m8_t", RvvInt16m8, RvvInt16m8Ty, 32, 16, 1, true) + +RVV_VECTOR_TYPE_INT("__rvv_uint16mf4_t",RvvUint16mf4,RvvUint16mf4Ty,1, 16, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint16mf2_t",RvvUint16mf2,RvvUint16mf2Ty,2, 16, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint16m1_t", RvvUint16m1, RvvUint16m1Ty, 4, 16, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint16m2_t", RvvUint16m2, RvvUint16m2Ty, 8, 16, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint16m4_t", RvvUint16m4, RvvUint16m4Ty, 16, 16, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint16m8_t", RvvUint16m8, RvvUint16m8Ty, 32, 16, 1, false) + +RVV_VECTOR_TYPE_INT("__rvv_int32mf2_t",RvvInt32mf2,RvvInt32mf2Ty,1, 32, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int32m1_t", RvvInt32m1, RvvInt32m1Ty, 2, 32, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int32m2_t", RvvInt32m2, RvvInt32m2Ty, 4, 32, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int32m4_t", RvvInt32m4, RvvInt32m4Ty, 8, 32, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int32m8_t", RvvInt32m8, RvvInt32m8Ty, 16, 32, 1, true) + +RVV_VECTOR_TYPE_INT("__rvv_uint32mf2_t",RvvUint32mf2,RvvUint32mf2Ty,1, 32, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint32m1_t", RvvUint32m1, RvvUint32m1Ty, 2, 32, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint32m2_t", RvvUint32m2, RvvUint32m2Ty, 4, 32, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint32m4_t", RvvUint32m4, RvvUint32m4Ty, 8, 32, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint32m8_t", RvvUint32m8, RvvUint32m8Ty, 16, 32, 1, false) + +RVV_VECTOR_TYPE_INT("__rvv_int64m1_t", RvvInt64m1, RvvInt64m1Ty, 1, 64, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int64m2_t", RvvInt64m2, RvvInt64m2Ty, 2, 64, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int64m4_t", RvvInt64m4, RvvInt64m4Ty, 4, 64, 1, true) +RVV_VECTOR_TYPE_INT("__rvv_int64m8_t", RvvInt64m8, RvvInt64m8Ty, 8, 64, 1, true) + +RVV_VECTOR_TYPE_INT("__rvv_uint64m1_t",RvvUint64m1,RvvUint64m1Ty,1, 64, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint64m2_t",RvvUint64m2,RvvUint64m2Ty,2, 64, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint64m4_t",RvvUint64m4,RvvUint64m4Ty,4, 64, 1, false) +RVV_VECTOR_TYPE_INT("__rvv_uint64m8_t",RvvUint64m8,RvvUint64m8Ty,8, 64, 1, false) + +RVV_VECTOR_TYPE_FLOAT("__rvv_float16mf4_t",RvvFloat16mf4,RvvFloat16mf4Ty,1, 16, 1) +RVV_VECTOR_TYPE_FLOAT("__rvv_float16mf2_t",RvvFloat16mf2,RvvFloat16mf2Ty,2, 16, 1) +RVV_VECTOR_TYPE_FLOAT("__rvv_float16m1_t", RvvFloat16m1, RvvFloat16m1Ty, 4, 16, 1) +RVV_VECTOR_TYPE_FLOAT("__rvv_float16m2_t", RvvFloat16m2, RvvFloat16m2Ty, 8, 16, 1) +RVV_VECTOR_TYPE_FLOAT("__rvv_float16m4_t", RvvFloat16m4, RvvFloat16m4Ty, 16, 16, 1) +RVV_VECTOR_TYPE_FLOAT("__rvv_float16m8_t", RvvFloat16m8, RvvFloat16m8Ty, 32, 16, 1) + +RVV_VECTOR_TYPE_FLOAT("__rvv_float32mf2_t",RvvFloat32mf2,RvvFloat32mf2Ty,1, 32, 1) +RVV_VECTOR_TYPE_FLOAT("__rvv_float32m1_t", RvvFloat32m1, RvvFloat32m1Ty, 2, 32, 1) +RVV_VECTOR_TYPE_FLOAT("__rvv_float32m2_t", RvvFloat32m2, RvvFloat32m2Ty, 4, 32, 1) +RVV_VECTOR_TYPE_FLOAT("__rvv_float32m4_t", RvvFloat32m4, RvvFloat32m4Ty, 8, 32, 1) +RVV_VECTOR_TYPE_FLOAT("__rvv_float32m8_t", RvvFloat32m8, RvvFloat32m8Ty, 16, 32, 1) + +RVV_VECTOR_TYPE_FLOAT("__rvv_float64m1_t", RvvFloat64m1, RvvFloat64m1Ty, 1, 64, 1) +RVV_VECTOR_TYPE_FLOAT("__rvv_float64m2_t", RvvFloat64m2, RvvFloat64m2Ty, 2, 64, 1) +RVV_VECTOR_TYPE_FLOAT("__rvv_float64m4_t", RvvFloat64m4, RvvFloat64m4Ty, 4, 64, 1) +RVV_VECTOR_TYPE_FLOAT("__rvv_float64m8_t", RvvFloat64m8, RvvFloat64m8Ty, 8, 64, 1) + +RVV_PREDICATE_TYPE("__rvv_bool1_t", RvvBool1, RvvBool1Ty, 64) +RVV_PREDICATE_TYPE("__rvv_bool2_t", RvvBool2, RvvBool2Ty, 32) +RVV_PREDICATE_TYPE("__rvv_bool4_t", RvvBool4, RvvBool4Ty, 16) +RVV_PREDICATE_TYPE("__rvv_bool8_t", RvvBool8, RvvBool8Ty, 8) +RVV_PREDICATE_TYPE("__rvv_bool16_t", RvvBool16, RvvBool16Ty, 4) +RVV_PREDICATE_TYPE("__rvv_bool32_t", RvvBool32, RvvBool32Ty, 2) +RVV_PREDICATE_TYPE("__rvv_bool64_t", RvvBool64, RvvBool64Ty, 1) + +#undef RVV_VECTOR_TYPE_FLOAT +#undef RVV_VECTOR_TYPE_INT +#undef RVV_VECTOR_TYPE +#undef RVV_PREDICATE_TYPE +#undef RVV_TYPE diff --git a/clang/include/clang/Basic/SanitizerBlacklist.h b/clang/include/clang/Basic/SanitizerBlacklist.h deleted file mode 100644 index c874ff28aacc..000000000000 --- a/clang/include/clang/Basic/SanitizerBlacklist.h +++ /dev/null @@ -1,49 +0,0 @@ -//===--- SanitizerBlacklist.h - Blacklist for sanitizers --------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// User-provided blacklist used to disable/alter instrumentation done in -// sanitizers. -// -//===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_BASIC_SANITIZERBLACKLIST_H -#define LLVM_CLANG_BASIC_SANITIZERBLACKLIST_H - -#include "clang/Basic/LLVM.h" -#include "clang/Basic/SourceLocation.h" -#include "llvm/ADT/StringRef.h" -#include <memory> -#include <vector> - -namespace clang { - -class SanitizerMask; -class SourceManager; -class SanitizerSpecialCaseList; - -class SanitizerBlacklist { - std::unique_ptr<SanitizerSpecialCaseList> SSCL; - SourceManager &SM; - -public: - SanitizerBlacklist(const std::vector<std::string> &BlacklistPaths, - SourceManager &SM); - ~SanitizerBlacklist(); - bool isBlacklistedGlobal(SanitizerMask Mask, StringRef GlobalName, - StringRef Category = StringRef()) const; - bool isBlacklistedType(SanitizerMask Mask, StringRef MangledTypeName, - StringRef Category = StringRef()) const; - bool isBlacklistedFunction(SanitizerMask Mask, StringRef FunctionName) const; - bool isBlacklistedFile(SanitizerMask Mask, StringRef FileName, - StringRef Category = StringRef()) const; - bool isBlacklistedLocation(SanitizerMask Mask, SourceLocation Loc, - StringRef Category = StringRef()) const; -}; - -} // end namespace clang - -#endif diff --git a/clang/include/clang/Basic/SanitizerSpecialCaseList.h b/clang/include/clang/Basic/SanitizerSpecialCaseList.h index c84894dae298..d024b7dfc2e8 100644 --- a/clang/include/clang/Basic/SanitizerSpecialCaseList.h +++ b/clang/include/clang/Basic/SanitizerSpecialCaseList.h @@ -39,7 +39,7 @@ public: createOrDie(const std::vector<std::string> &Paths, llvm::vfs::FileSystem &VFS); - // Query blacklisted entries if any bit in Mask matches the entry's section. + // Query ignorelisted entries if any bit in Mask matches the entry's section. bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query, StringRef Category = StringRef()) const; diff --git a/clang/include/clang/Basic/Sanitizers.h b/clang/include/clang/Basic/Sanitizers.h index c6b0446cea4f..b12a3b7821d7 100644 --- a/clang/include/clang/Basic/Sanitizers.h +++ b/clang/include/clang/Basic/Sanitizers.h @@ -16,7 +16,7 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/StringRef.h" -#include "llvm/Support/MathExtras.h" +#include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h" #include <cassert> #include <cstdint> @@ -59,12 +59,7 @@ public: return SanitizerMask(mask1, mask2); } - unsigned countPopulation() const { - unsigned total = 0; - for (const auto &Val : maskLoToHigh) - total += llvm::countPopulation(Val); - return total; - } + unsigned countPopulation() const; void flipAllBits() { for (auto &Val : maskLoToHigh) @@ -178,6 +173,10 @@ struct SanitizerSet { /// Returns a non-zero SanitizerMask, or \c 0 if \p Value is not known. SanitizerMask parseSanitizerValue(StringRef Value, bool AllowGroups); +/// Serialize a SanitizerSet into values for -fsanitize= or -fno-sanitize=. +void serializeSanitizerSet(SanitizerSet Set, + SmallVectorImpl<StringRef> &Values); + /// For each sanitizer group bit set in \p Kinds, set the bits for sanitizers /// this group enables. SanitizerMask expandSanitizerGroups(SanitizerMask Kinds); @@ -189,6 +188,16 @@ inline SanitizerMask getPPTransparentSanitizers() { SanitizerKind::Undefined | SanitizerKind::FloatDivideByZero; } +StringRef AsanDtorKindToString(llvm::AsanDtorKind kind); + +llvm::AsanDtorKind AsanDtorKindFromString(StringRef kind); + +StringRef AsanDetectStackUseAfterReturnModeToString( + llvm::AsanDetectStackUseAfterReturnMode mode); + +llvm::AsanDetectStackUseAfterReturnMode +AsanDetectStackUseAfterReturnModeFromString(StringRef modeStr); + } // namespace clang #endif // LLVM_CLANG_BASIC_SANITIZERS_H diff --git a/clang/include/clang/Basic/SourceLocation.h b/clang/include/clang/Basic/SourceLocation.h index fc722b1d563d..540de23b9f55 100644 --- a/clang/include/clang/Basic/SourceLocation.h +++ b/clang/include/clang/Basic/SourceLocation.h @@ -16,7 +16,6 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/StringRef.h" -#include "llvm/Support/PointerLikeTypeTraits.h" #include <cassert> #include <cstdint> #include <string> @@ -92,11 +91,14 @@ class SourceLocation { friend class SourceManager; friend struct llvm::FoldingSetTrait<SourceLocation>; - unsigned ID = 0; +public: + using UIntTy = uint32_t; + using IntTy = int32_t; - enum : unsigned { - MacroIDBit = 1U << 31 - }; +private: + UIntTy ID = 0; + + enum : UIntTy { MacroIDBit = 1ULL << (8 * sizeof(UIntTy) - 1) }; public: bool isFileID() const { return (ID & MacroIDBit) == 0; } @@ -112,18 +114,16 @@ public: private: /// Return the offset into the manager's global input view. - unsigned getOffset() const { - return ID & ~MacroIDBit; - } + UIntTy getOffset() const { return ID & ~MacroIDBit; } - static SourceLocation getFileLoc(unsigned ID) { + static SourceLocation getFileLoc(UIntTy ID) { assert((ID & MacroIDBit) == 0 && "Ran out of source locations!"); SourceLocation L; L.ID = ID; return L; } - static SourceLocation getMacroLoc(unsigned ID) { + static SourceLocation getMacroLoc(UIntTy ID) { assert((ID & MacroIDBit) == 0 && "Ran out of source locations!"); SourceLocation L; L.ID = MacroIDBit | ID; @@ -133,7 +133,7 @@ private: public: /// Return a source location with the specified offset from this /// SourceLocation. - SourceLocation getLocWithOffset(int Offset) const { + SourceLocation getLocWithOffset(IntTy Offset) const { assert(((getOffset()+Offset) & MacroIDBit) == 0 && "offset overflow"); SourceLocation L; L.ID = ID+Offset; @@ -145,13 +145,13 @@ public: /// /// This should only be passed to SourceLocation::getFromRawEncoding, it /// should not be inspected directly. - unsigned getRawEncoding() const { return ID; } + UIntTy getRawEncoding() const { return ID; } /// Turn a raw encoding of a SourceLocation object into /// a real SourceLocation. /// /// \see getRawEncoding. - static SourceLocation getFromRawEncoding(unsigned Encoding) { + static SourceLocation getFromRawEncoding(UIntTy Encoding) { SourceLocation X; X.ID = Encoding; return X; @@ -171,7 +171,7 @@ public: /// Turn a pointer encoding of a SourceLocation object back /// into a real SourceLocation. static SourceLocation getFromPtrEncoding(const void *Encoding) { - return getFromRawEncoding((unsigned)(uintptr_t)Encoding); + return getFromRawEncoding((SourceLocation::UIntTy)(uintptr_t)Encoding); } static bool isPairOfFileLocations(SourceLocation Start, SourceLocation End) { @@ -489,11 +489,13 @@ namespace llvm { /// DenseMapInfo<unsigned> which uses SourceLocation::ID is used as a key. template <> struct DenseMapInfo<clang::SourceLocation> { static clang::SourceLocation getEmptyKey() { - return clang::SourceLocation::getFromRawEncoding(~0U); + constexpr clang::SourceLocation::UIntTy Zero = 0; + return clang::SourceLocation::getFromRawEncoding(~Zero); } static clang::SourceLocation getTombstoneKey() { - return clang::SourceLocation::getFromRawEncoding(~0U - 1); + constexpr clang::SourceLocation::UIntTy Zero = 0; + return clang::SourceLocation::getFromRawEncoding(~Zero - 1); } static unsigned getHashValue(clang::SourceLocation Loc) { @@ -510,20 +512,6 @@ namespace llvm { static void Profile(const clang::SourceLocation &X, FoldingSetNodeID &ID); }; - // Teach SmallPtrSet how to handle SourceLocation. - template<> - struct PointerLikeTypeTraits<clang::SourceLocation> { - static constexpr int NumLowBitsAvailable = 0; - - static void *getAsVoidPointer(clang::SourceLocation L) { - return L.getPtrEncoding(); - } - - static clang::SourceLocation getFromVoidPointer(void *P) { - return clang::SourceLocation::getFromRawEncoding((unsigned)(uintptr_t)P); - } - }; - } // namespace llvm #endif // LLVM_CLANG_BASIC_SOURCELOCATION_H diff --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h index 8cd37756d8f1..cc29c24f5a35 100644 --- a/clang/include/clang/Basic/SourceManager.h +++ b/clang/include/clang/Basic/SourceManager.h @@ -465,8 +465,9 @@ static_assert(sizeof(FileInfo) <= sizeof(ExpansionInfo), /// SourceManager keeps an array of these objects, and they are uniquely /// identified by the FileID datatype. class SLocEntry { - unsigned Offset : 31; - unsigned IsExpansion : 1; + static constexpr int OffsetBits = 8 * sizeof(SourceLocation::UIntTy) - 1; + SourceLocation::UIntTy Offset : OffsetBits; + SourceLocation::UIntTy IsExpansion : 1; union { FileInfo File; ExpansionInfo Expansion; @@ -475,7 +476,7 @@ class SLocEntry { public: SLocEntry() : Offset(), IsExpansion(), File() {} - unsigned getOffset() const { return Offset; } + SourceLocation::UIntTy getOffset() const { return Offset; } bool isExpansion() const { return IsExpansion; } bool isFile() const { return !isExpansion(); } @@ -490,8 +491,8 @@ public: return Expansion; } - static SLocEntry get(unsigned Offset, const FileInfo &FI) { - assert(!(Offset & (1u << 31)) && "Offset is too large"); + static SLocEntry get(SourceLocation::UIntTy Offset, const FileInfo &FI) { + assert(!(Offset & (1ULL << OffsetBits)) && "Offset is too large"); SLocEntry E; E.Offset = Offset; E.IsExpansion = false; @@ -499,8 +500,9 @@ public: return E; } - static SLocEntry get(unsigned Offset, const ExpansionInfo &Expansion) { - assert(!(Offset & (1u << 31)) && "Offset is too large"); + static SLocEntry get(SourceLocation::UIntTy Offset, + const ExpansionInfo &Expansion) { + assert(!(Offset & (1ULL << OffsetBits)) && "Offset is too large"); SLocEntry E; E.Offset = Offset; E.IsExpansion = true; @@ -690,17 +692,18 @@ class SourceManager : public RefCountedBase<SourceManager> { /// The starting offset of the next local SLocEntry. /// /// This is LocalSLocEntryTable.back().Offset + the size of that entry. - unsigned NextLocalOffset; + SourceLocation::UIntTy NextLocalOffset; /// The starting offset of the latest batch of loaded SLocEntries. /// /// This is LoadedSLocEntryTable.back().Offset, except that that entry might /// not have been loaded, so that value would be unknown. - unsigned CurrentLoadedOffset; + SourceLocation::UIntTy CurrentLoadedOffset; - /// The highest possible offset is 2^31-1, so CurrentLoadedOffset - /// starts at 2^31. - static const unsigned MaxLoadedOffset = 1U << 31U; + /// The highest possible offset is 2^32-1 (2^63-1 for 64-bit source + /// locations), so CurrentLoadedOffset starts at 2^31 (2^63 resp.). + static const SourceLocation::UIntTy MaxLoadedOffset = + 1ULL << (8 * sizeof(SourceLocation::UIntTy) - 1); /// A bitmap that indicates whether the entries of LoadedSLocEntryTable /// have already been loaded from the external source. @@ -865,11 +868,13 @@ public: /// This translates NULL into standard input. FileID createFileID(const FileEntry *SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, - int LoadedID = 0, unsigned LoadedOffset = 0); + int LoadedID = 0, + SourceLocation::UIntTy LoadedOffset = 0); FileID createFileID(FileEntryRef SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, - int LoadedID = 0, unsigned LoadedOffset = 0); + int LoadedID = 0, + SourceLocation::UIntTy LoadedOffset = 0); /// Create a new FileID that represents the specified memory buffer. /// @@ -877,7 +882,7 @@ public: /// MemoryBuffer, so only pass a MemoryBuffer to this once. FileID createFileID(std::unique_ptr<llvm::MemoryBuffer> Buffer, SrcMgr::CharacteristicKind FileCharacter = SrcMgr::C_User, - int LoadedID = 0, unsigned LoadedOffset = 0, + int LoadedID = 0, SourceLocation::UIntTy LoadedOffset = 0, SourceLocation IncludeLoc = SourceLocation()); /// Create a new FileID that represents the specified memory buffer. @@ -886,7 +891,7 @@ public: /// outlive the SourceManager. FileID createFileID(const llvm::MemoryBufferRef &Buffer, SrcMgr::CharacteristicKind FileCharacter = SrcMgr::C_User, - int LoadedID = 0, unsigned LoadedOffset = 0, + int LoadedID = 0, SourceLocation::UIntTy LoadedOffset = 0, SourceLocation IncludeLoc = SourceLocation()); /// Get the FileID for \p SourceFile if it exists. Otherwise, create a @@ -905,13 +910,11 @@ public: /// Return a new SourceLocation that encodes the fact /// that a token from SpellingLoc should actually be referenced from /// ExpansionLoc. - SourceLocation createExpansionLoc(SourceLocation Loc, - SourceLocation ExpansionLocStart, - SourceLocation ExpansionLocEnd, - unsigned TokLength, - bool ExpansionIsTokenRange = true, - int LoadedID = 0, - unsigned LoadedOffset = 0); + SourceLocation + createExpansionLoc(SourceLocation Loc, SourceLocation ExpansionLocStart, + SourceLocation ExpansionLocEnd, unsigned TokLength, + bool ExpansionIsTokenRange = true, int LoadedID = 0, + SourceLocation::UIntTy LoadedOffset = 0); /// Return a new SourceLocation that encodes that the token starting /// at \p TokenStart ends prematurely at \p TokenEnd. @@ -1098,7 +1101,7 @@ public: /// the entry in SLocEntryTable which contains the specified location. /// FileID getFileID(SourceLocation SpellingLoc) const { - unsigned SLocOffset = SpellingLoc.getOffset(); + SourceLocation::UIntTy SLocOffset = SpellingLoc.getOffset(); // If our one-entry cache covers this offset, just return it. if (isOffsetInFileID(LastFileIDLookup, SLocOffset)) @@ -1221,7 +1224,7 @@ public: if (!Entry) return SourceLocation(); - unsigned GlobalOffset = Entry->getOffset() + Offset; + SourceLocation::UIntTy GlobalOffset = Entry->getOffset() + Offset; return Entry->isFile() ? SourceLocation::getFileLoc(GlobalOffset) : SourceLocation::getMacroLoc(GlobalOffset); } @@ -1326,17 +1329,17 @@ public: /// /// If it's true and \p RelativeOffset is non-null, it will be set to the /// relative offset of \p Loc inside the chunk. - bool isInSLocAddrSpace(SourceLocation Loc, - SourceLocation Start, unsigned Length, - unsigned *RelativeOffset = nullptr) const { + bool + isInSLocAddrSpace(SourceLocation Loc, SourceLocation Start, unsigned Length, + SourceLocation::UIntTy *RelativeOffset = nullptr) const { assert(((Start.getOffset() < NextLocalOffset && Start.getOffset()+Length <= NextLocalOffset) || (Start.getOffset() >= CurrentLoadedOffset && Start.getOffset()+Length < MaxLoadedOffset)) && "Chunk is not valid SLoc address space"); - unsigned LocOffs = Loc.getOffset(); - unsigned BeginOffs = Start.getOffset(); - unsigned EndOffs = BeginOffs + Length; + SourceLocation::UIntTy LocOffs = Loc.getOffset(); + SourceLocation::UIntTy BeginOffs = Start.getOffset(); + SourceLocation::UIntTy EndOffs = BeginOffs + Length; if (LocOffs >= BeginOffs && LocOffs < EndOffs) { if (RelativeOffset) *RelativeOffset = LocOffs - BeginOffs; @@ -1352,8 +1355,8 @@ public: /// If it's true and \p RelativeOffset is non-null, it will be set to the /// offset of \p RHS relative to \p LHS. bool isInSameSLocAddrSpace(SourceLocation LHS, SourceLocation RHS, - int *RelativeOffset) const { - unsigned LHSOffs = LHS.getOffset(), RHSOffs = RHS.getOffset(); + SourceLocation::IntTy *RelativeOffset) const { + SourceLocation::UIntTy LHSOffs = LHS.getOffset(), RHSOffs = RHS.getOffset(); bool LHSLoaded = LHSOffs >= CurrentLoadedOffset; bool RHSLoaded = RHSOffs >= CurrentLoadedOffset; @@ -1517,7 +1520,7 @@ public: /// of FileID) to \p relativeOffset. bool isInFileID(SourceLocation Loc, FileID FID, unsigned *RelativeOffset = nullptr) const { - unsigned Offs = Loc.getOffset(); + SourceLocation::UIntTy Offs = Loc.getOffset(); if (isOffsetInFileID(FID, Offs)) { if (RelativeOffset) *RelativeOffset = Offs - getSLocEntry(FID).getOffset(); @@ -1636,8 +1639,9 @@ public: /// offset in the "source location address space". /// /// Note that we always consider source locations loaded from - bool isBeforeInSLocAddrSpace(SourceLocation LHS, unsigned RHS) const { - unsigned LHSOffset = LHS.getOffset(); + bool isBeforeInSLocAddrSpace(SourceLocation LHS, + SourceLocation::UIntTy RHS) const { + SourceLocation::UIntTy LHSOffset = LHS.getOffset(); bool LHSLoaded = LHSOffset >= CurrentLoadedOffset; bool RHSLoaded = RHS >= CurrentLoadedOffset; if (LHSLoaded == RHSLoaded) @@ -1699,7 +1703,7 @@ public: return getSLocEntryByID(FID.ID, Invalid); } - unsigned getNextLocalOffset() const { return NextLocalOffset; } + SourceLocation::UIntTy getNextLocalOffset() const { return NextLocalOffset; } void setExternalSLocEntrySource(ExternalSLocEntrySource *Source) { assert(LoadedSLocEntryTable.empty() && @@ -1713,8 +1717,9 @@ public: /// NumSLocEntries will be allocated, which occupy a total of TotalSize space /// in the global source view. The lowest ID and the base offset of the /// entries will be returned. - std::pair<int, unsigned> - AllocateLoadedSLocEntries(unsigned NumSLocEntries, unsigned TotalSize); + std::pair<int, SourceLocation::UIntTy> + AllocateLoadedSLocEntries(unsigned NumSLocEntries, + SourceLocation::UIntTy TotalSize); /// Returns true if \p Loc came from a PCH/Module. bool isLoadedSourceLocation(SourceLocation Loc) const { @@ -1795,14 +1800,15 @@ private: /// Implements the common elements of storing an expansion info struct into /// the SLocEntry table and producing a source location that refers to it. - SourceLocation createExpansionLocImpl(const SrcMgr::ExpansionInfo &Expansion, - unsigned TokLength, - int LoadedID = 0, - unsigned LoadedOffset = 0); + SourceLocation + createExpansionLocImpl(const SrcMgr::ExpansionInfo &Expansion, + unsigned TokLength, int LoadedID = 0, + SourceLocation::UIntTy LoadedOffset = 0); /// Return true if the specified FileID contains the /// specified SourceLocation offset. This is a very hot method. - inline bool isOffsetInFileID(FileID FID, unsigned SLocOffset) const { + inline bool isOffsetInFileID(FileID FID, + SourceLocation::UIntTy SLocOffset) const { const SrcMgr::SLocEntry &Entry = getSLocEntry(FID); // If the entry is after the offset, it can't contain it. if (SLocOffset < Entry.getOffset()) return false; @@ -1836,7 +1842,7 @@ private: FileID createFileIDImpl(SrcMgr::ContentCache &File, StringRef Filename, SourceLocation IncludePos, SrcMgr::CharacteristicKind DirCharacter, int LoadedID, - unsigned LoadedOffset); + SourceLocation::UIntTy LoadedOffset); SrcMgr::ContentCache &getOrCreateContentCache(FileEntryRef SourceFile, bool isSystemFile = false); @@ -1845,9 +1851,9 @@ private: SrcMgr::ContentCache & createMemBufferContentCache(std::unique_ptr<llvm::MemoryBuffer> Buf); - FileID getFileIDSlow(unsigned SLocOffset) const; - FileID getFileIDLocal(unsigned SLocOffset) const; - FileID getFileIDLoaded(unsigned SLocOffset) const; + FileID getFileIDSlow(SourceLocation::UIntTy SLocOffset) const; + FileID getFileIDLocal(SourceLocation::UIntTy SLocOffset) const; + FileID getFileIDLoaded(SourceLocation::UIntTy SLocOffset) const; SourceLocation getExpansionLocSlowCase(SourceLocation Loc) const; SourceLocation getSpellingLocSlowCase(SourceLocation Loc) const; diff --git a/clang/include/clang/Basic/Specifiers.h b/clang/include/clang/Basic/Specifiers.h index 07d8177b8ab2..1c38b411e083 100644 --- a/clang/include/clang/Basic/Specifiers.h +++ b/clang/include/clang/Basic/Specifiers.h @@ -105,9 +105,9 @@ namespace clang { /// The categorization of expression values, currently following the /// C++11 scheme. enum ExprValueKind { - /// An r-value expression (a pr-value in the C++11 taxonomy) + /// A pr-value expression (in the C++11 taxonomy) /// produces a temporary value. - VK_RValue, + VK_PRValue, /// An l-value expression is a reference to an object with /// independent storage. @@ -266,6 +266,7 @@ namespace clang { CC_SpirFunction, // default for OpenCL functions on SPIR target CC_OpenCLKernel, // inferred for OpenCL kernels CC_Swift, // __attribute__((swiftcall)) + CC_SwiftAsync, // __attribute__((swiftasynccall)) CC_PreserveMost, // __attribute__((preserve_most)) CC_PreserveAll, // __attribute__((preserve_all)) CC_AArch64VectorCall, // __attribute__((aarch64_vector_pcs)) @@ -284,6 +285,7 @@ namespace clang { case CC_SpirFunction: case CC_OpenCLKernel: case CC_Swift: + case CC_SwiftAsync: return false; default: return true; @@ -344,7 +346,12 @@ namespace clang { /// This parameter (which must have pointer type) uses the special /// Swift context-pointer ABI treatment. There can be at /// most one parameter on a given function that uses this treatment. - SwiftContext + SwiftContext, + + /// This parameter (which must have pointer type) uses the special + /// Swift asynchronous context-pointer ABI treatment. There can be at + /// most one parameter on a given function that uses this treatment. + SwiftAsyncContext, }; /// Assigned inheritance model for a class in the MS C++ ABI. Must match order diff --git a/clang/include/clang/Basic/StmtNodes.td b/clang/include/clang/Basic/StmtNodes.td index 5965e8b9902a..508f1fddf1b3 100644 --- a/clang/include/clang/Basic/StmtNodes.td +++ b/clang/include/clang/Basic/StmtNodes.td @@ -57,6 +57,7 @@ def CoreturnStmt : StmtNode<Stmt>; // Expressions def Expr : StmtNode<ValueStmt, 1>; def PredefinedExpr : StmtNode<Expr>; +def SYCLUniqueStableNameExpr : StmtNode<Expr>; def DeclRefExpr : StmtNode<Expr>; def IntegerLiteral : StmtNode<Expr>; def FixedPointLiteral : StmtNode<Expr>; @@ -216,10 +217,14 @@ def MSDependentExistsStmt : StmtNode<Stmt>; def AsTypeExpr : StmtNode<Expr>; // OpenMP Directives. +def OMPCanonicalLoop : StmtNode<Stmt>; def OMPExecutableDirective : StmtNode<Stmt, 1>; -def OMPLoopDirective : StmtNode<OMPExecutableDirective, 1>; +def OMPLoopBasedDirective : StmtNode<OMPExecutableDirective, 1>; +def OMPLoopDirective : StmtNode<OMPLoopBasedDirective, 1>; def OMPParallelDirective : StmtNode<OMPExecutableDirective>; def OMPSimdDirective : StmtNode<OMPLoopDirective>; +def OMPTileDirective : StmtNode<OMPLoopBasedDirective>; +def OMPUnrollDirective : StmtNode<OMPLoopBasedDirective>; def OMPForDirective : StmtNode<OMPLoopDirective>; def OMPForSimdDirective : StmtNode<OMPLoopDirective>; def OMPSectionsDirective : StmtNode<OMPExecutableDirective>; @@ -272,3 +277,6 @@ def OMPTargetTeamsDistributeDirective : StmtNode<OMPLoopDirective>; def OMPTargetTeamsDistributeParallelForDirective : StmtNode<OMPLoopDirective>; def OMPTargetTeamsDistributeParallelForSimdDirective : StmtNode<OMPLoopDirective>; def OMPTargetTeamsDistributeSimdDirective : StmtNode<OMPLoopDirective>; +def OMPInteropDirective : StmtNode<OMPExecutableDirective>; +def OMPDispatchDirective : StmtNode<OMPExecutableDirective>; +def OMPMaskedDirective : StmtNode<OMPExecutableDirective>; diff --git a/clang/include/clang/Basic/TargetBuiltins.h b/clang/include/clang/Basic/TargetBuiltins.h index b472547012f0..ed53b10f61ef 100644 --- a/clang/include/clang/Basic/TargetBuiltins.h +++ b/clang/include/clang/Basic/TargetBuiltins.h @@ -124,6 +124,16 @@ namespace clang { enum { LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, LastTSBuiltin }; } + /// RISCV builtins + namespace RISCV { + enum { + LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, +#define BUILTIN(ID, TYPE, ATTRS) BI##ID, +#include "clang/Basic/BuiltinsRISCV.def" + LastTSBuiltin + }; + } // namespace RISCV + /// Flags to identify the types for overloaded Neon builtins. /// /// These must be kept in sync with the flags in utils/TableGen/NeonEmitter.h. @@ -290,16 +300,6 @@ namespace clang { }; } - /// Le64 builtins - namespace Le64 { - enum { - LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, - #define BUILTIN(ID, TYPE, ATTRS) BI##ID, - #include "clang/Basic/BuiltinsLe64.def" - LastTSBuiltin - }; - } - /// SystemZ builtins namespace SystemZ { enum { @@ -321,12 +321,11 @@ namespace clang { } static constexpr uint64_t LargestBuiltinID = std::max<uint64_t>( - {NEON::FirstTSBuiltin, ARM::LastTSBuiltin, SVE::FirstTSBuiltin, - AArch64::LastTSBuiltin, BPF::LastTSBuiltin, PPC::LastTSBuiltin, - NVPTX::LastTSBuiltin, AMDGPU::LastTSBuiltin, X86::LastTSBuiltin, + {ARM::LastTSBuiltin, AArch64::LastTSBuiltin, BPF::LastTSBuiltin, + PPC::LastTSBuiltin, NVPTX::LastTSBuiltin, AMDGPU::LastTSBuiltin, + X86::LastTSBuiltin, VE::LastTSBuiltin, RISCV::LastTSBuiltin, Hexagon::LastTSBuiltin, Mips::LastTSBuiltin, XCore::LastTSBuiltin, - Le64::LastTSBuiltin, SystemZ::LastTSBuiltin, - WebAssembly::LastTSBuiltin}); + SystemZ::LastTSBuiltin, WebAssembly::LastTSBuiltin}); } // end namespace clang. diff --git a/clang/include/clang/Basic/TargetCXXABI.def b/clang/include/clang/Basic/TargetCXXABI.def new file mode 100644 index 000000000000..9501cca76094 --- /dev/null +++ b/clang/include/clang/Basic/TargetCXXABI.def @@ -0,0 +1,129 @@ +//===--- TargetCXXABI.def - Target C++ ABI database --------------- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines the various C++ ABI kinds used on different platforms. +// Users of this file must define the CXXABI macro to make use of this +// information. +// +//===----------------------------------------------------------------------===// + +#ifndef CXXABI +#error Define the CXXABI macro to handle C++ ABI kinds. +#endif + +#ifndef ITANIUM_CXXABI +#define ITANIUM_CXXABI(Name, Str) CXXABI(Name, Str) +#endif + +#ifndef MICROSOFT_CXXABI +#define MICROSOFT_CXXABI(Name, Str) CXXABI(Name, Str) +#endif + +/// The generic Itanium ABI is the standard ABI of most open-source +/// and Unix-like platforms. It is the primary ABI targeted by +/// many compilers, including Clang and GCC. +/// +/// It is documented here: +/// http://www.codesourcery.com/public/cxx-abi/ +ITANIUM_CXXABI(GenericItanium, "itanium") + +/// The generic ARM ABI is a modified version of the Itanium ABI +/// proposed by ARM for use on ARM-based platforms. +/// +/// These changes include: +/// - the representation of member function pointers is adjusted +/// to not conflict with the 'thumb' bit of ARM function pointers; +/// - constructors and destructors return 'this'; +/// - guard variables are smaller; +/// - inline functions are never key functions; +/// - array cookies have a slightly different layout; +/// - additional convenience functions are specified; +/// - and more! +/// +/// It is documented here: +/// http://infocenter.arm.com +/// /help/topic/com.arm.doc.ihi0041c/IHI0041C_cppabi.pdf +ITANIUM_CXXABI(GenericARM, "arm") + +/// The iOS ABI is a partial implementation of the ARM ABI. +/// Several of the features of the ARM ABI were not fully implemented +/// in the compilers that iOS was launched with. +/// +/// Essentially, the iOS ABI includes the ARM changes to: +/// - member function pointers, +/// - guard variables, +/// - array cookies, and +/// - constructor/destructor signatures. +ITANIUM_CXXABI(iOS, "ios") + +/// The iOS 64-bit and macOS 64-bit ARM ABI follows ARM's published 64-bit +/// ABI more closely, but we don't guarantee to follow it perfectly. +/// +/// It is documented here: +/// http://infocenter.arm.com +/// /help/topic/com.arm.doc.ihi0059a/IHI0059A_cppabi64.pdf +ITANIUM_CXXABI(AppleARM64, "applearm64") + +/// WatchOS is a modernisation of the iOS ABI, which roughly means it's +/// the iOS64 ABI ported to 32-bits. The primary difference from iOS64 is +/// that RTTI objects must still be unique at the moment. +ITANIUM_CXXABI(WatchOS, "watchos") + +/// The generic AArch64 ABI is also a modified version of the Itanium ABI, +/// but it has fewer divergences than the 32-bit ARM ABI. +/// +/// The relevant changes from the generic ABI in this case are: +/// - representation of member function pointers adjusted as in ARM. +/// - guard variables are smaller. +ITANIUM_CXXABI(GenericAArch64, "aarch64") + +/// The generic Mips ABI is a modified version of the Itanium ABI. +/// +/// At the moment, only change from the generic ABI in this case is: +/// - representation of member function pointers adjusted as in ARM. +ITANIUM_CXXABI(GenericMIPS, "mips") + +/// The WebAssembly ABI is a modified version of the Itanium ABI. +/// +/// The changes from the Itanium ABI are: +/// - representation of member function pointers is adjusted, as in ARM; +/// - member functions are not specially aligned; +/// - constructors and destructors return 'this', as in ARM; +/// - guard variables are 32-bit on wasm32, as in ARM; +/// - unused bits of guard variables are reserved, as in ARM; +/// - inline functions are never key functions, as in ARM; +/// - C++11 POD rules are used for tail padding, as in iOS64. +/// +/// TODO: At present the WebAssembly ABI is not considered stable, so none +/// of these details is necessarily final yet. +ITANIUM_CXXABI(WebAssembly, "webassembly") + +/// The Fuchsia ABI is a modified version of the Itanium ABI. +/// +/// The relevant changes from the Itanium ABI are: +/// - constructors and destructors return 'this', as in ARM. +ITANIUM_CXXABI(Fuchsia, "fuchsia") + +/// The XL ABI is the ABI used by IBM xlclang compiler and is a modified +/// version of the Itanium ABI. +/// +/// The relevant changes from the Itanium ABI are: +/// - static initialization is adjusted to use sinit and sterm functions; +ITANIUM_CXXABI(XL, "xl") + +/// The Microsoft ABI is the ABI used by Microsoft Visual Studio (and +/// compatible compilers). +/// +/// FIXME: should this be split into Win32 and Win64 variants? +/// +/// Only scattered and incomplete official documentation exists. +MICROSOFT_CXXABI(Microsoft, "microsoft") + +#undef CXXABI +#undef ITANIUM_CXXABI +#undef MICROSOFT_CXXABI diff --git a/clang/include/clang/Basic/TargetCXXABI.h b/clang/include/clang/Basic/TargetCXXABI.h index 2d267f43f92b..e727f85edad7 100644 --- a/clang/include/clang/Basic/TargetCXXABI.h +++ b/clang/include/clang/Basic/TargetCXXABI.h @@ -15,7 +15,11 @@ #ifndef LLVM_CLANG_BASIC_TARGETCXXABI_H #define LLVM_CLANG_BASIC_TARGETCXXABI_H +#include <map> + #include "clang/Basic/LLVM.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/Triple.h" #include "llvm/Support/ErrorHandling.h" namespace clang { @@ -25,105 +29,8 @@ class TargetCXXABI { public: /// The basic C++ ABI kind. enum Kind { - /// The generic Itanium ABI is the standard ABI of most open-source - /// and Unix-like platforms. It is the primary ABI targeted by - /// many compilers, including Clang and GCC. - /// - /// It is documented here: - /// http://www.codesourcery.com/public/cxx-abi/ - GenericItanium, - - /// The generic ARM ABI is a modified version of the Itanium ABI - /// proposed by ARM for use on ARM-based platforms. - /// - /// These changes include: - /// - the representation of member function pointers is adjusted - /// to not conflict with the 'thumb' bit of ARM function pointers; - /// - constructors and destructors return 'this'; - /// - guard variables are smaller; - /// - inline functions are never key functions; - /// - array cookies have a slightly different layout; - /// - additional convenience functions are specified; - /// - and more! - /// - /// It is documented here: - /// http://infocenter.arm.com - /// /help/topic/com.arm.doc.ihi0041c/IHI0041C_cppabi.pdf - GenericARM, - - /// The iOS ABI is a partial implementation of the ARM ABI. - /// Several of the features of the ARM ABI were not fully implemented - /// in the compilers that iOS was launched with. - /// - /// Essentially, the iOS ABI includes the ARM changes to: - /// - member function pointers, - /// - guard variables, - /// - array cookies, and - /// - constructor/destructor signatures. - iOS, - - /// The iOS 64-bit and macOS 64-bit ARM ABI follows ARM's published 64-bit - /// ABI more closely, but we don't guarantee to follow it perfectly. - /// - /// It is documented here: - /// http://infocenter.arm.com - /// /help/topic/com.arm.doc.ihi0059a/IHI0059A_cppabi64.pdf - AppleARM64, - - /// WatchOS is a modernisation of the iOS ABI, which roughly means it's - /// the AppleARM64 ABI ported to 32-bits. The primary difference from - /// AppleARM64 is that RTTI objects must still be unique at the moment. - WatchOS, - - /// The generic AArch64 ABI is also a modified version of the Itanium ABI, - /// but it has fewer divergences than the 32-bit ARM ABI. - /// - /// The relevant changes from the generic ABI in this case are: - /// - representation of member function pointers adjusted as in ARM. - /// - guard variables are smaller. - GenericAArch64, - - /// The generic Mips ABI is a modified version of the Itanium ABI. - /// - /// At the moment, only change from the generic ABI in this case is: - /// - representation of member function pointers adjusted as in ARM. - GenericMIPS, - - /// The WebAssembly ABI is a modified version of the Itanium ABI. - /// - /// The changes from the Itanium ABI are: - /// - representation of member function pointers is adjusted, as in ARM; - /// - member functions are not specially aligned; - /// - constructors and destructors return 'this', as in ARM; - /// - guard variables are 32-bit on wasm32, as in ARM; - /// - unused bits of guard variables are reserved, as in ARM; - /// - inline functions are never key functions, as in ARM; - /// - C++11 POD rules are used for tail padding, as in AppleARM64. - /// - /// TODO: At present the WebAssembly ABI is not considered stable, so none - /// of these details is necessarily final yet. - WebAssembly, - - /// The Fuchsia ABI is a modified version of the Itanium ABI. - /// - /// The relevant changes from the Itanium ABI are: - /// - constructors and destructors return 'this', as in ARM. - Fuchsia, - - /// The XL ABI is the ABI used by IBM xlclang compiler and is a modified - /// version of the Itanium ABI. - /// - /// The relevant changes from the Itanium ABI are: - /// - static initialization is adjusted to use sinit and sterm functions; - XL, - - /// The Microsoft ABI is the ABI used by Microsoft Visual Studio (and - /// compatible compilers). - /// - /// FIXME: should this be split into Win32 and Win64 variants? - /// - /// Only scattered and incomplete official documentation exists. - Microsoft +#define CXXABI(Name, Str) Name, +#include "TargetCXXABI.def" }; private: @@ -132,7 +39,37 @@ private: // audit the users to pass it by reference instead. Kind TheKind; + static const auto &getABIMap() { + static llvm::StringMap<Kind> ABIMap = { +#define CXXABI(Name, Str) {Str, Name}, +#include "TargetCXXABI.def" + }; + return ABIMap; + } + + static const auto &getSpellingMap() { + static std::map<Kind, std::string> SpellingMap = { +#define CXXABI(Name, Str) {Name, Str}, +#include "TargetCXXABI.def" + }; + return SpellingMap; + } + public: + static Kind getKind(StringRef Name) { return getABIMap().lookup(Name); } + static const auto &getSpelling(Kind ABIKind) { + return getSpellingMap().find(ABIKind)->second; + } + static bool isABI(StringRef Name) { + return getABIMap().find(Name) != getABIMap().end(); + } + + // Return true if this target should use the relative vtables C++ ABI by + // default. + static bool usesRelativeVTables(const llvm::Triple &T) { + return T.isOSFuchsia(); + } + /// A bogus initialization of the platform ABI. TargetCXXABI() : TheKind(GenericItanium) {} @@ -144,22 +81,54 @@ public: Kind getKind() const { return TheKind; } - /// Does this ABI generally fall into the Itanium family of ABIs? - bool isItaniumFamily() const { - switch (getKind()) { - case AppleARM64: - case Fuchsia: - case GenericAArch64: - case GenericItanium: + // Check that the kind provided by the fc++-abi flag is supported on this + // target. Users who want to experiment using different ABIs on specific + // platforms can change this freely, but this function should be conservative + // enough such that not all ABIs are allowed on all platforms. For example, we + // probably don't want to allow usage of an ARM ABI on an x86 architecture. + static bool isSupportedCXXABI(const llvm::Triple &T, Kind Kind) { + switch (Kind) { case GenericARM: + return T.isARM() || T.isAArch64(); + case iOS: case WatchOS: + case AppleARM64: + return T.isOSDarwin(); + + case Fuchsia: + return T.isOSFuchsia(); + + case GenericAArch64: + return T.isAArch64(); + case GenericMIPS: + return T.isMIPS(); + case WebAssembly: + return T.isWasm(); + case XL: + return T.isOSAIX(); + + case GenericItanium: return true; case Microsoft: + return T.isKnownWindowsMSVCEnvironment(); + } + llvm_unreachable("invalid CXXABI kind"); + }; + + /// Does this ABI generally fall into the Itanium family of ABIs? + bool isItaniumFamily() const { + switch (getKind()) { +#define CXXABI(Name, Str) +#define ITANIUM_CXXABI(Name, Str) case Name: +#include "TargetCXXABI.def" + return true; + + default: return false; } llvm_unreachable("bad ABI kind"); @@ -168,20 +137,13 @@ public: /// Is this ABI an MSVC-compatible ABI? bool isMicrosoft() const { switch (getKind()) { - case AppleARM64: - case Fuchsia: - case GenericAArch64: - case GenericItanium: - case GenericARM: - case iOS: - case WatchOS: - case GenericMIPS: - case WebAssembly: - case XL: - return false; - - case Microsoft: +#define CXXABI(Name, Str) +#define MICROSOFT_CXXABI(Name, Str) case Name: +#include "TargetCXXABI.def" return true; + + default: + return false; } llvm_unreachable("bad ABI kind"); } diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index b782172d93a3..4f0cbf986b31 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -32,6 +32,7 @@ #include "llvm/ADT/Triple.h" #include "llvm/Frontend/OpenMP/OMPGridValues.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/Error.h" #include "llvm/Support/VersionTuple.h" #include <cassert> #include <string> @@ -39,7 +40,6 @@ namespace llvm { struct fltSemantics; -class DataLayout; } namespace clang { @@ -129,9 +129,9 @@ struct TransferrableTargetInfo { Float128 }; protected: - IntType SizeType, IntMaxType, PtrDiffType, IntPtrType, WCharType, - WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType, - ProcessIDType; + IntType SizeType, IntMaxType, PtrDiffType, IntPtrType, WCharType, WIntType, + Char16Type, Char32Type, Int64Type, Int16Type, SigAtomicType, + ProcessIDType; /// Whether Objective-C's built-in boolean type should be signed char. /// @@ -154,12 +154,20 @@ protected: /// zero-length bitfield. unsigned UseZeroLengthBitfieldAlignment : 1; + /// Whether zero length bitfield alignment is respected if they are the + /// leading members. + unsigned UseLeadingZeroLengthBitfield : 1; + /// Whether explicit bit field alignment attributes are honored. unsigned UseExplicitBitFieldAlignment : 1; /// If non-zero, specifies a fixed alignment value for bitfields that follow /// zero length bitfield, regardless of the zero length bitfield type. unsigned ZeroLengthBitfieldBoundary; + + /// If non-zero, specifies a maximum alignment to truncate alignment + /// specified in the aligned attribute of a static variable to this value. + unsigned MaxAlignedAttribute; }; /// OpenCL type kinds. @@ -196,7 +204,8 @@ protected: unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth; unsigned short SimdDefaultAlign; - std::unique_ptr<llvm::DataLayout> DataLayout; + std::string DataLayoutString; + const char *UserLabelPrefix; const char *MCountName; unsigned char RegParmMax, SSERegParmMax; TargetCXXABI TheCXXABI; @@ -218,6 +227,8 @@ protected: unsigned HasAArch64SVETypes : 1; + unsigned HasRISCVVTypes : 1; + unsigned AllowAMDGPUUnsafeFPAtomics : 1; unsigned ARMCDECoprocMask : 8; @@ -227,7 +238,9 @@ protected: // TargetInfo Constructor. Default initializes all fields. TargetInfo(const llvm::Triple &T); - void resetDataLayout(StringRef DL); + // UserLabelPrefix must match DL's getGlobalPrefix() when interpreted + // as a DataLayout object. + void resetDataLayout(StringRef DL, const char *UserLabelPrefix = ""); public: /// Construct a target for the given options. @@ -338,6 +351,10 @@ public: IntType getUInt64Type() const { return getCorrespondingUnsignedType(Int64Type); } + IntType getInt16Type() const { return Int16Type; } + IntType getUInt16Type() const { + return getCorrespondingUnsignedType(Int16Type); + } IntType getSigAtomicType() const { return SigAtomicType; } IntType getProcessIDType() const { return ProcessIDType; } @@ -601,8 +618,8 @@ public: } /// Return the largest alignment for which a suitably-sized allocation with - /// '::operator new(size_t)' is guaranteed to produce a correctly-aligned - /// pointer. + /// '::operator new(size_t)' or 'malloc' is guaranteed to produce a + /// correctly-aligned pointer. unsigned getNewAlign() const { return NewAlign ? NewAlign : std::max(LongDoubleAlign, LongLongAlign); } @@ -736,6 +753,12 @@ public: return PointerWidth; } + /// \brief Returns the default value of the __USER_LABEL_PREFIX__ macro, + /// which is the prefix given to user symbols by default. + /// + /// On most platforms this is "", but it is "_" on some. + const char *getUserLabelPrefix() const { return UserLabelPrefix; } + /// Returns the name of the mcount instrumentation function. const char *getMCountName() const { return MCountName; @@ -765,12 +788,22 @@ public: return UseZeroLengthBitfieldAlignment; } + /// Check whether zero length bitfield alignment is respected if they are + /// leading members. + bool useLeadingZeroLengthBitfield() const { + return UseLeadingZeroLengthBitfield; + } + /// Get the fixed alignment value in bits for a member that follows /// a zero length bitfield. unsigned getZeroLengthBitfieldBoundary() const { return ZeroLengthBitfieldBoundary; } + /// Get the maximum alignment in bits for a static variable with + /// aligned attribute. + unsigned getMaxAlignedAttribute() const { return MaxAlignedAttribute; } + /// Check whether explicit bitfield alignment attributes should be // honored, as in "__attribute__((aligned(2))) int b : 1;". bool useExplicitBitFieldAlignment() const { @@ -859,6 +892,10 @@ public: /// available on this target. bool hasAArch64SVETypes() const { return HasAArch64SVETypes; } + /// Returns whether or not the RISC-V V built-in types are + /// available on this target. + bool hasRISCVVTypes() const { return HasRISCVVTypes; } + /// Returns whether or not the AMDGPU unsafe floating point atomics are /// allowed. bool allowAMDGPUUnsafeFPAtomics() const { return AllowAMDGPUUnsafeFPAtomics; } @@ -1054,6 +1091,12 @@ public: return std::string(1, *Constraint); } + /// Replace some escaped characters with another string based on + /// target-specific rules + virtual llvm::Optional<std::string> handleAsmEscapedChar(char C) const { + return llvm::None; + } + /// Returns a string of target-specific clobbers, in LLVM format. virtual const char *getClobbers() const = 0; @@ -1071,9 +1114,9 @@ public: /// Returns the target ID if supported. virtual llvm::Optional<std::string> getTargetID() const { return llvm::None; } - const llvm::DataLayout &getDataLayout() const { - assert(DataLayout && "Uninitialized DataLayout!"); - return *DataLayout; + const char *getDataLayoutString() const { + assert(!DataLayoutString.empty() && "Uninitialized DataLayout!"); + return DataLayoutString.c_str(); } struct GCCRegAlias { @@ -1105,19 +1148,13 @@ public: getTriple().isWindowsItaniumEnvironment() || getTriple().isPS4CPU(); } - /// An optional hook that targets can implement to perform semantic - /// checking on attribute((section("foo"))) specifiers. - /// - /// In this case, "foo" is passed in to be checked. If the section - /// specifier is invalid, the backend should return a non-empty string - /// that indicates the problem. - /// - /// This hook is a simple quality of implementation feature to catch errors - /// and give good diagnostics in cases when the assembler or code generator - /// would otherwise reject the section specifier. - /// - virtual std::string isValidSectionSpecifier(StringRef SR) const { - return ""; + // Does this target have PS4 specific dllimport/export handling? + virtual bool hasPS4DLLImportExport() const { + return getTriple().isPS4CPU() || + // Windows Itanium support allows for testing the SCEI flavour of + // dllimport/export handling on a Windows system. + (getTriple().isWindowsItaniumEnvironment() && + getTriple().getVendor() == llvm::Triple::SCEI); } /// Set forced language options. @@ -1125,7 +1162,7 @@ public: /// Apply changes to the target information with respect to certain /// language options which change the target configuration and adjust /// the language based on the target options where applicable. - virtual void adjust(LangOptions &Opts); + virtual void adjust(DiagnosticsEngine &Diags, LangOptions &Opts); /// Adjust target options based on codegen options. virtual void adjustTargetOptions(const CodeGenOptions &CGOpts, @@ -1192,6 +1229,12 @@ public: return false; } + /// Check if target has a given feature enabled + virtual bool hasFeatureEnabled(const llvm::StringMap<bool> &Features, + StringRef Name) const { + return Features.lookup(Name); + } + /// Enable or disable a specific target feature; /// the feature name must be valid. virtual void setFeatureEnabled(llvm::StringMap<bool> &Features, @@ -1378,6 +1421,12 @@ public: bool isBigEndian() const { return BigEndian; } bool isLittleEndian() const { return !BigEndian; } + /// Whether the option -fextend-arguments={32,64} is supported on the target. + virtual bool supportsExtendIntArgs() const { return false; } + + /// Controls if __arithmetic_fence is supported in the targeted backend. + virtual bool checkArithmeticFenceSupported() const { return false; } + /// Gets the default calling convention for the given target and /// declaration context. virtual CallingConv getDefaultCallingConv() const { @@ -1439,7 +1488,8 @@ public: virtual void setSupportedOpenCLOpts() {} virtual void supportAllOpenCLOpts(bool V = true) { -#define OPENCLEXTNAME(Ext) getTargetOpts().OpenCLFeaturesMap[#Ext] = V; +#define OPENCLEXTNAME(Ext) \ + setFeatureEnabled(getTargetOpts().OpenCLFeaturesMap, #Ext, V); #include "clang/Basic/OpenCLExtensions.def" } @@ -1459,10 +1509,6 @@ public: } } - /// Define OpenCL macros based on target settings and language version - void getOpenCLFeatureDefines(const LangOptions &Opts, - MacroBuilder &Builder) const; - /// Get supported OpenCL extensions and optional core features. llvm::StringMap<bool> &getSupportedOpenCLOpts() { return getTargetOpts().OpenCLFeaturesMap; @@ -1502,10 +1548,15 @@ public: return true; } + /// Check that OpenCL target has valid options setting based on OpenCL + /// version. + virtual bool validateOpenCLTarget(const LangOptions &Opts, + DiagnosticsEngine &Diags) const; + virtual void setAuxTarget(const TargetInfo *Aux) {} - /// Whether target allows debuginfo types for decl only variables. - virtual bool allowDebugInfoForExternalVar() const { return false; } + /// Whether target allows debuginfo types for decl only variables/functions. + virtual bool allowDebugInfoForExternalRef() const { return false; } protected: /// Copy type and layout related info. diff --git a/clang/include/clang/Basic/Thunk.h b/clang/include/clang/Basic/Thunk.h new file mode 100644 index 000000000000..91088be6ae73 --- /dev/null +++ b/clang/include/clang/Basic/Thunk.h @@ -0,0 +1,188 @@ +//===----- Thunk.h - Declarations related to VTable Thunks ------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Enums/classes describing THUNK related information about constructors, +/// destructors and thunks. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_BASIC_THUNK_H +#define LLVM_CLANG_BASIC_THUNK_H + +#include <cstdint> +#include <cstring> + +namespace clang { + +class CXXMethodDecl; + +/// A return adjustment. +struct ReturnAdjustment { + /// The non-virtual adjustment from the derived object to its + /// nearest virtual base. + int64_t NonVirtual; + + /// Holds the ABI-specific information about the virtual return + /// adjustment, if needed. + union VirtualAdjustment { + // Itanium ABI + struct { + /// The offset (in bytes), relative to the address point + /// of the virtual base class offset. + int64_t VBaseOffsetOffset; + } Itanium; + + // Microsoft ABI + struct { + /// The offset (in bytes) of the vbptr, relative to the beginning + /// of the derived class. + uint32_t VBPtrOffset; + + /// Index of the virtual base in the vbtable. + uint32_t VBIndex; + } Microsoft; + + VirtualAdjustment() { memset(this, 0, sizeof(*this)); } + + bool Equals(const VirtualAdjustment &Other) const { + return memcmp(this, &Other, sizeof(Other)) == 0; + } + + bool isEmpty() const { + VirtualAdjustment Zero; + return Equals(Zero); + } + + bool Less(const VirtualAdjustment &RHS) const { + return memcmp(this, &RHS, sizeof(RHS)) < 0; + } + } Virtual; + + ReturnAdjustment() : NonVirtual(0) {} + + bool isEmpty() const { return !NonVirtual && Virtual.isEmpty(); } + + friend bool operator==(const ReturnAdjustment &LHS, + const ReturnAdjustment &RHS) { + return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Equals(RHS.Virtual); + } + + friend bool operator!=(const ReturnAdjustment &LHS, + const ReturnAdjustment &RHS) { + return !(LHS == RHS); + } + + friend bool operator<(const ReturnAdjustment &LHS, + const ReturnAdjustment &RHS) { + if (LHS.NonVirtual < RHS.NonVirtual) + return true; + + return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Less(RHS.Virtual); + } +}; + +/// A \c this pointer adjustment. +struct ThisAdjustment { + /// The non-virtual adjustment from the derived object to its + /// nearest virtual base. + int64_t NonVirtual; + + /// Holds the ABI-specific information about the virtual this + /// adjustment, if needed. + union VirtualAdjustment { + // Itanium ABI + struct { + /// The offset (in bytes), relative to the address point, + /// of the virtual call offset. + int64_t VCallOffsetOffset; + } Itanium; + + struct { + /// The offset of the vtordisp (in bytes), relative to the ECX. + int32_t VtordispOffset; + + /// The offset of the vbptr of the derived class (in bytes), + /// relative to the ECX after vtordisp adjustment. + int32_t VBPtrOffset; + + /// The offset (in bytes) of the vbase offset in the vbtable. + int32_t VBOffsetOffset; + } Microsoft; + + VirtualAdjustment() { memset(this, 0, sizeof(*this)); } + + bool Equals(const VirtualAdjustment &Other) const { + return memcmp(this, &Other, sizeof(Other)) == 0; + } + + bool isEmpty() const { + VirtualAdjustment Zero; + return Equals(Zero); + } + + bool Less(const VirtualAdjustment &RHS) const { + return memcmp(this, &RHS, sizeof(RHS)) < 0; + } + } Virtual; + + ThisAdjustment() : NonVirtual(0) {} + + bool isEmpty() const { return !NonVirtual && Virtual.isEmpty(); } + + friend bool operator==(const ThisAdjustment &LHS, const ThisAdjustment &RHS) { + return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Equals(RHS.Virtual); + } + + friend bool operator!=(const ThisAdjustment &LHS, const ThisAdjustment &RHS) { + return !(LHS == RHS); + } + + friend bool operator<(const ThisAdjustment &LHS, const ThisAdjustment &RHS) { + if (LHS.NonVirtual < RHS.NonVirtual) + return true; + + return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Less(RHS.Virtual); + } +}; + +/// The \c this pointer adjustment as well as an optional return +/// adjustment for a thunk. +struct ThunkInfo { + /// The \c this pointer adjustment. + ThisAdjustment This; + + /// The return adjustment. + ReturnAdjustment Return; + + /// Holds a pointer to the overridden method this thunk is for, + /// if needed by the ABI to distinguish different thunks with equal + /// adjustments. Otherwise, null. + /// CAUTION: In the unlikely event you need to sort ThunkInfos, consider using + /// an ABI-specific comparator. + const CXXMethodDecl *Method; + + ThunkInfo() : Method(nullptr) {} + + ThunkInfo(const ThisAdjustment &This, const ReturnAdjustment &Return, + const CXXMethodDecl *Method = nullptr) + : This(This), Return(Return), Method(Method) {} + + friend bool operator==(const ThunkInfo &LHS, const ThunkInfo &RHS) { + return LHS.This == RHS.This && LHS.Return == RHS.Return && + LHS.Method == RHS.Method; + } + + bool isEmpty() const { + return This.isEmpty() && Return.isEmpty() && Method == nullptr; + } +}; + +} // end namespace clang + +#endif diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def index 572ebae6618d..48a664e3494e 100644 --- a/clang/include/clang/Basic/TokenKinds.def +++ b/clang/include/clang/Basic/TokenKinds.def @@ -98,6 +98,8 @@ PPKEYWORD(if) PPKEYWORD(ifdef) PPKEYWORD(ifndef) PPKEYWORD(elif) +PPKEYWORD(elifdef) +PPKEYWORD(elifndef) PPKEYWORD(else) PPKEYWORD(endif) PPKEYWORD(defined) @@ -694,11 +696,12 @@ ALIAS("_declspec" , __declspec , KEYMS) ALIAS("_pascal" , __pascal , KEYBORLAND) // Clang Extensions. -KEYWORD(__builtin_convertvector , KEYALL) -ALIAS("__char16_t" , char16_t , KEYCXX) -ALIAS("__char32_t" , char32_t , KEYCXX) -KEYWORD(__builtin_bit_cast , KEYALL) -KEYWORD(__builtin_available , KEYALL) +KEYWORD(__builtin_convertvector , KEYALL) +ALIAS("__char16_t" , char16_t , KEYCXX) +ALIAS("__char32_t" , char32_t , KEYCXX) +KEYWORD(__builtin_bit_cast , KEYALL) +KEYWORD(__builtin_available , KEYALL) +KEYWORD(__builtin_sycl_unique_stable_name, KEYSYCL) // Clang-specific keywords enabled only in testing. TESTING_KEYWORD(__unknown_anytype , KEYALL) @@ -860,6 +863,13 @@ PRAGMA_ANNOTATION(pragma_ms_pragma) PRAGMA_ANNOTATION(pragma_opencl_extension) // Annotations for OpenMP pragma directives - #pragma omp ... +// The parser produces this annotation token when it parses an [[omp::*]] +// attribute. The tokens from the attribute argument list are replayed to the +// token stream with this leading token (and a trailing pragma_openmp_end) so +// that the parser can reuse the OpenMP parsing logic but still be able to +// distinguish between a real pragma and a converted pragma. It is not marked +// as a PRAGMA_ANNOTATION because it doesn't get generated from a #pragma. +ANNOTATION(attr_openmp) // The lexer produces these so that they only take effect when the parser // handles #pragma omp ... directives. PRAGMA_ANNOTATION(pragma_openmp) diff --git a/clang/include/clang/Basic/XRayInstr.h b/clang/include/clang/Basic/XRayInstr.h index 42ca7773fcce..23ca2c75fc99 100644 --- a/clang/include/clang/Basic/XRayInstr.h +++ b/clang/include/clang/Basic/XRayInstr.h @@ -65,8 +65,13 @@ struct XRayInstrSet { XRayInstrMask Mask = 0; }; +/// Parses a command line argument into a mask. XRayInstrMask parseXRayInstrValue(StringRef Value); +/// Serializes a set into a list of command line arguments. +void serializeXRayInstrValue(XRayInstrSet Set, + SmallVectorImpl<StringRef> &Values); + } // namespace clang #endif // LLVM_CLANG_BASIC_XRAYINSTR_H diff --git a/clang/include/clang/Basic/arm_mve.td b/clang/include/clang/Basic/arm_mve.td index 8106f9a5a9de..52185ca07da4 100644 --- a/clang/include/clang/Basic/arm_mve.td +++ b/clang/include/clang/Basic/arm_mve.td @@ -575,7 +575,7 @@ defm vmaxnmavq: Reduction<Scalar, "maxnmav", [Scalar, Vector]>; } foreach half = [ "b", "t" ] in { - defvar halfconst = !if(!eq(half, "b"), 0, 1); + defvar halfconst = !ne(half, "b"); let params = [f32], pnt = PNT_None in { def vcvt#half#q_f16: Intrinsic< @@ -1153,8 +1153,7 @@ defm vshlltq : vshll_imm<1>; multiclass DyadicImmShift<Type outtype, Immediate imm, string intname = NAME, dag extraargs = (?)> { - defvar intparams = !if(!eq(!cast<string>(outtype), !cast<string>(Vector)), - [Vector], [outtype, Vector]); + defvar intparams = !if(!eq(outtype, Vector), [Vector], [outtype, Vector]); def q_n: Intrinsic< outtype, (args outtype:$a, Vector:$b, imm:$sh), @@ -1529,12 +1528,7 @@ let params = T.Usual in { foreach desttype = T.All in { // We want a vreinterpretq between every pair of supported vector types // _except_ that there shouldn't be one from a type to itself. - // - // So this foldl expression implements what you'd write in Python as - // [srctype for srctype in T.All if srctype != desttype] - let params = !foldl([]<Type>, T.All, tlist, srctype, !listconcat(tlist, - !if(!eq(!cast<string>(desttype),!cast<string>(srctype)),[],[srctype]))) - in { + let params = !filter(srctype, T.All, !ne(srctype, desttype)) in { def "vreinterpretq_" # desttype: Intrinsic< VecOf<desttype>, (args Vector:$x), (vreinterpret $x, VecOf<desttype>)>; } @@ -1543,7 +1537,7 @@ foreach desttype = T.All in { let params = T.All in { let pnt = PNT_None in { def vcreateq: Intrinsic<Vector, (args u64:$a, u64:$b), - (bitcast (ielt_const (ielt_const (undef VecOf<u64>), $a, 0), + (vreinterpret (ielt_const (ielt_const (undef VecOf<u64>), $a, 0), $b, 1), Vector)>; def vuninitializedq: Intrinsic<Vector, (args), (undef Vector)>; } @@ -1576,8 +1570,9 @@ foreach desttype = !listconcat(T.Int16, T.Int32, T.Float) in { defvar is_dest_float = !eq(desttype.kind, "f"); defvar is_dest_unsigned = !eq(desttype.kind, "u"); // First immediate operand of the LLVM intrinsic - defvar unsigned_flag = !if(is_dest_float, (unsignedflag Scalar), - !if(is_dest_unsigned, V.True, V.False)); + defvar unsigned_flag = !cond(is_dest_float: (unsignedflag Scalar), + is_dest_unsigned: V.True, + true: V.False); // For float->int conversions _n and _x_n intrinsics are not polymorphic // because the signedness of the destination type cannot be inferred. defvar pnt_nx = !if(is_dest_float, PNT_2Type, PNT_None); diff --git a/clang/include/clang/Basic/arm_neon.td b/clang/include/clang/Basic/arm_neon.td index 3b2a578f796e..173003d171ee 100644 --- a/clang/include/clang/Basic/arm_neon.td +++ b/clang/include/clang/Basic/arm_neon.td @@ -646,7 +646,7 @@ def VABS : SInst<"vabs", "..", "csifQcQsQiQf">; def VQABS : SInst<"vqabs", "..", "csiQcQsQi">; def VNEG : SOpInst<"vneg", "..", "csifQcQsQiQf", OP_NEG>; def VQNEG : SInst<"vqneg", "..", "csiQcQsQi">; -def VCLS : SInst<"vcls", "..", "csiQcQsQi">; +def VCLS : SInst<"vcls", "S.", "csiUcUsUiQcQsQiQUcQUsQUi">; def VCLZ : IInst<"vclz", "..", "csiUcUsUiQcQsQiQUcQUsQUi">; def VCNT : WInst<"vcnt", "..", "UccPcQUcQcQPc">; def VRECPE : SInst<"vrecpe", "..", "fUiQfQUi">; @@ -709,6 +709,11 @@ def SCALAR_HALF_GET_LANEQ : IOpInst<"vget_lane", "1.I", "Qh", OP_SCALAR_HALF_GET def SCALAR_HALF_SET_LANEQ : IOpInst<"vset_lane", ".1.I", "Qh", OP_SCALAR_HALF_SET_LNQ>; //////////////////////////////////////////////////////////////////////////////// +// Non poly128_t vaddp for Arm and AArch64 +// TODO: poly128_t not implemented on arm32 +def VADDP : WInst<"vadd", "...", "PcPsPlQPcQPsQPl">; + +//////////////////////////////////////////////////////////////////////////////// // AArch64 Intrinsics let ArchGuard = "defined(__aarch64__)" in { @@ -1117,12 +1122,14 @@ def VEXT_A64 : WInst<"vext", "...I", "dQdPlQPl">; //////////////////////////////////////////////////////////////////////////////// // Crypto -let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_CRYPTO)" in { +let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_AES)" in { def AESE : SInst<"vaese", "...", "QUc">; def AESD : SInst<"vaesd", "...", "QUc">; def AESMC : SInst<"vaesmc", "..", "QUc">; def AESIMC : SInst<"vaesimc", "..", "QUc">; +} +let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_SHA2)" in { def SHA1H : SInst<"vsha1h", "11", "Ui">; def SHA1SU1 : SInst<"vsha1su1", "...", "QUi">; def SHA256SU0 : SInst<"vsha256su0", "...", "QUi">; @@ -1136,6 +1143,43 @@ def SHA256H2 : SInst<"vsha256h2", "....", "QUi">; def SHA256SU1 : SInst<"vsha256su1", "....", "QUi">; } +let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_SHA3) && defined(__aarch64__)" in { +def BCAX : SInst<"vbcax", "....", "QUcQUsQUiQUlQcQsQiQl">; +def EOR3 : SInst<"veor3", "....", "QUcQUsQUiQUlQcQsQiQl">; +def RAX1 : SInst<"vrax1", "...", "QUl">; + +let isVXAR = 1 in { +def XAR : SInst<"vxar", "...I", "QUl">; +} +} + +let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_SHA512) && defined(__aarch64__)" in { + +def SHA512SU0 : SInst<"vsha512su0", "...", "QUl">; +def SHA512su1 : SInst<"vsha512su1", "....", "QUl">; +def SHA512H : SInst<"vsha512h", "....", "QUl">; +def SHA512H2 : SInst<"vsha512h2", "....", "QUl">; +} + +let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_SM3) && defined(__aarch64__)" in { +def SM3SS1 : SInst<"vsm3ss1", "....", "QUi">; +def SM3TT1A : SInst<"vsm3tt1a", "....I", "QUi">; +def SM3TT1B : SInst<"vsm3tt1b", "....I", "QUi">; +def SM3TT2A : SInst<"vsm3tt2a", "....I", "QUi">; +def SM3TT2B : SInst<"vsm3tt2b", "....I", "QUi">; +def SM3PARTW1 : SInst<"vsm3partw1", "....", "QUi">; +def SM3PARTW2 : SInst<"vsm3partw2", "....", "QUi">; +} + +let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_SM4) && defined(__aarch64__)" in { +def SM4E : SInst<"vsm4e", "...", "QUi">; +def SM4EKEY : SInst<"vsm4ekey", "...", "QUi">; +} + +//////////////////////////////////////////////////////////////////////////////// +// poly128_t vadd for AArch64 only see VADDP for the rest +def VADDP_Q : WInst<"vadd", "...", "QPk">; + //////////////////////////////////////////////////////////////////////////////// // Float -> Int conversions with explicit rounding mode @@ -1184,6 +1228,13 @@ def FRINTZ_S64 : SInst<"vrnd", "..", "dQd">; def FRINTI_S64 : SInst<"vrndi", "..", "dQd">; } +let ArchGuard = "__ARM_ARCH >= 8 && defined(__aarch64__) && defined(__ARM_FEATURE_FRINT)" in { +def FRINT32X_S32 : SInst<"vrnd32x", "..", "fQf">; +def FRINT32Z_S32 : SInst<"vrnd32z", "..", "fQf">; +def FRINT64X_S32 : SInst<"vrnd64x", "..", "fQf">; +def FRINT64Z_S32 : SInst<"vrnd64z", "..", "fQf">; +} + //////////////////////////////////////////////////////////////////////////////// // MaxNum/MinNum Floating Point @@ -1838,7 +1889,7 @@ let ArchGuard = "defined(__ARM_FEATURE_DOTPROD) && defined(__aarch64__)" in { } // v8.2-A FP16 fused multiply-add long instructions. -let ArchGuard = "defined(__ARM_FEATURE_FP16FML) && defined(__aarch64__)" in { +let ArchGuard = "defined(__ARM_FEATURE_FP16_FML) && defined(__aarch64__)" in { def VFMLAL_LOW : SInst<"vfmlal_low", ">>..", "hQh">; def VFMLSL_LOW : SInst<"vfmlsl_low", ">>..", "hQh">; def VFMLAL_HIGH : SInst<"vfmlal_high", ">>..", "hQh">; diff --git a/clang/include/clang/Basic/arm_neon_incl.td b/clang/include/clang/Basic/arm_neon_incl.td index dd20b70433ef..60dbea627d58 100644 --- a/clang/include/clang/Basic/arm_neon_incl.td +++ b/clang/include/clang/Basic/arm_neon_incl.td @@ -272,6 +272,7 @@ class Inst <string n, string p, string t, Operation o> { bit isScalarShift = 0; bit isScalarNarrowShift = 0; bit isVCVT_N = 0; + bit isVXAR = 0; // For immediate checks: the immediate will be assumed to specify the lane of // a Q register. Only used for intrinsics which end up calling polymorphic // builtins. diff --git a/clang/include/clang/Basic/arm_sve.td b/clang/include/clang/Basic/arm_sve.td index 19a42e79c36a..5e9d1c96558b 100644 --- a/clang/include/clang/Basic/arm_sve.td +++ b/clang/include/clang/Basic/arm_sve.td @@ -668,16 +668,16 @@ let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in { // Prefetches // Prefetch (Scalar base) -def SVPRFB : MInst<"svprfb", "vPcJ", "c", [IsPrefetch], MemEltTyInt8, "aarch64_sve_prf">; -def SVPRFH : MInst<"svprfh", "vPcJ", "s", [IsPrefetch], MemEltTyInt16, "aarch64_sve_prf">; -def SVPRFW : MInst<"svprfw", "vPcJ", "i", [IsPrefetch], MemEltTyInt32, "aarch64_sve_prf">; -def SVPRFD : MInst<"svprfd", "vPcJ", "l", [IsPrefetch], MemEltTyInt64, "aarch64_sve_prf">; +def SVPRFB : MInst<"svprfb", "vPQJ", "c", [IsPrefetch], MemEltTyInt8, "aarch64_sve_prf">; +def SVPRFH : MInst<"svprfh", "vPQJ", "s", [IsPrefetch], MemEltTyInt16, "aarch64_sve_prf">; +def SVPRFW : MInst<"svprfw", "vPQJ", "i", [IsPrefetch], MemEltTyInt32, "aarch64_sve_prf">; +def SVPRFD : MInst<"svprfd", "vPQJ", "l", [IsPrefetch], MemEltTyInt64, "aarch64_sve_prf">; // Prefetch (Scalar base, VL displacement) -def SVPRFB_VNUM : MInst<"svprfb_vnum", "vPclJ", "c", [IsPrefetch], MemEltTyInt8, "aarch64_sve_prf">; -def SVPRFH_VNUM : MInst<"svprfh_vnum", "vPclJ", "s", [IsPrefetch], MemEltTyInt16, "aarch64_sve_prf">; -def SVPRFW_VNUM : MInst<"svprfw_vnum", "vPclJ", "i", [IsPrefetch], MemEltTyInt32, "aarch64_sve_prf">; -def SVPRFD_VNUM : MInst<"svprfd_vnum", "vPclJ", "l", [IsPrefetch], MemEltTyInt64, "aarch64_sve_prf">; +def SVPRFB_VNUM : MInst<"svprfb_vnum", "vPQlJ", "c", [IsPrefetch], MemEltTyInt8, "aarch64_sve_prf">; +def SVPRFH_VNUM : MInst<"svprfh_vnum", "vPQlJ", "s", [IsPrefetch], MemEltTyInt16, "aarch64_sve_prf">; +def SVPRFW_VNUM : MInst<"svprfw_vnum", "vPQlJ", "i", [IsPrefetch], MemEltTyInt32, "aarch64_sve_prf">; +def SVPRFD_VNUM : MInst<"svprfd_vnum", "vPQlJ", "l", [IsPrefetch], MemEltTyInt64, "aarch64_sve_prf">; // Prefetch (Vector bases) def SVPRFB_GATHER_BASES : MInst<"svprfb_gather[_{2}base]", "vPdJ", "UiUl", [IsGatherPrefetch], MemEltTyInt8, "aarch64_sve_prfb_gather_scalar_offset">; @@ -2073,7 +2073,7 @@ def SVSM4E : SInst<"svsm4e[_{d}]", "ddd", "Ui", MergeNone, "aarch64_sve_sm def SVSM4EKEY : SInst<"svsm4ekey[_{d}]", "ddd", "Ui", MergeNone, "aarch64_sve_sm4ekey", [IsOverloadNone]>; } -let ArchGuard = "__ARM_FEATURE_SVE2_BITPERM" in { +let ArchGuard = "defined (__ARM_FEATURE_SVE2_BITPERM)" in { def SVBDEP : SInst<"svbdep[_{d}]", "ddd", "UcUsUiUl", MergeNone, "aarch64_sve_bdep_x">; def SVBDEP_N : SInst<"svbdep[_n_{d}]", "dda", "UcUsUiUl", MergeNone, "aarch64_sve_bdep_x">; def SVBEXT : SInst<"svbext[_{d}]", "ddd", "UcUsUiUl", MergeNone, "aarch64_sve_bext_x">; diff --git a/clang/include/clang/Basic/riscv_vector.td b/clang/include/clang/Basic/riscv_vector.td new file mode 100644 index 000000000000..48c032dd1422 --- /dev/null +++ b/clang/include/clang/Basic/riscv_vector.td @@ -0,0 +1,2112 @@ +//==--- riscv_vector.td - RISC-V V-ext Builtin function list --------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines the builtins for RISC-V V-extension. See: +// +// https://github.com/riscv/rvv-intrinsic-doc +// +//===----------------------------------------------------------------------===// + +//===----------------------------------------------------------------------===// +// Instruction definitions +//===----------------------------------------------------------------------===// +// Each record of the class RVVBuiltin defines a collection of builtins (i.e. +// "def vadd : RVVBuiltin" will be used to define things like "vadd_vv_i32m1", +// "vadd_vv_i32m2", etc). +// +// The elements of this collection are defined by an instantiation process the +// range of which is specified by the cross product of the LMUL attribute and +// every element in the attribute TypeRange. By default builtins have LMUL = [1, +// 2, 4, 8, 1/2, 1/4, 1/8] so the process is repeated 7 times. In tablegen we +// use the Log2LMUL [0, 1, 2, 3, -1, -2, -3] to represent the LMUL. +// +// LMUL represents the fact that the types of values used by that builtin are +// values generated by instructions that are executed under that LMUL. However, +// this does not mean the builtin is necessarily lowered into an instruction +// that executes under the specified LMUL. An example where this happens are +// loads and stores of masks. A mask like `vbool8_t` can be generated, for +// instance, by comparing two `__rvv_int8m1_t` (this is LMUL=1) or comparing two +// `__rvv_int16m2_t` (this is LMUL=2). The actual load or store, however, will +// be performed under LMUL=1 because mask registers are not grouped. +// +// TypeRange is a non-empty sequence of basic types: +// +// c: int8_t (i8) +// s: int16_t (i16) +// i: int32_t (i32) +// l: int64_t (i64) +// x: float16_t (half) +// f: float32_t (float) +// d: float64_t (double) +// +// This way, given an LMUL, a record with a TypeRange "sil" will cause the +// definition of 3 builtins. Each type "t" in the TypeRange (in this example +// they are int16_t, int32_t, int64_t) is used as a parameter that drives the +// definition of that particular builtin (for the given LMUL). +// +// During the instantiation, types can be transformed or modified using type +// transformers. Given a type "t" the following primitive type transformers can +// be applied to it to yield another type. +// +// e: type of "t" as is (identity) +// v: computes a vector type whose element type is "t" for the current LMUL +// w: computes a vector type identical to what 'v' computes except for the +// element type which is twice as wide as the element type of 'v' +// q: computes a vector type identical to what 'v' computes except for the +// element type which is four times as wide as the element type of 'v' +// o: computes a vector type identical to what 'v' computes except for the +// element type which is eight times as wide as the element type of 'v' +// m: computes a vector type identical to what 'v' computes except for the +// element type which is bool +// 0: void type, ignores "t" +// z: size_t, ignores "t" +// t: ptrdiff_t, ignores "t" +// u: unsigned long, ignores "t" +// l: long, ignores "t" +// +// So for instance if t is "i", i.e. int, then "e" will yield int again. "v" +// will yield an RVV vector type (assume LMUL=1), so __rvv_int32m1_t. +// Accordingly "w" would yield __rvv_int64m2_t. +// +// A type transformer can be prefixed by other non-primitive type transformers. +// +// P: constructs a pointer to the current type +// C: adds const to the type +// K: requires the integer type to be a constant expression +// U: given an integer type or vector type, computes its unsigned variant +// I: given a vector type, compute the vector type with integer type +// elements of the same width +// F: given a vector type, compute the vector type with floating-point type +// elements of the same width +// S: given a vector type, computes its equivalent one for LMUL=1. This is a +// no-op if the vector was already LMUL=1 +// (Log2EEW:Value): Log2EEW value could be 3/4/5/6 (8/16/32/64), given a +// vector type (SEW and LMUL) and EEW (8/16/32/64), computes its +// equivalent integer vector type with EEW and corresponding ELMUL (elmul = +// (eew/sew) * lmul). For example, vector type is __rvv_float16m4 +// (SEW=16, LMUL=4) and Log2EEW is 3 (EEW=8), and then equivalent vector +// type is __rvv_uint8m2_t (elmul=(8/16)*4 = 2). Ignore to define a new +// builtins if its equivalent type has illegal lmul. +// (FixedSEW:Value): Given a vector type (SEW and LMUL), and computes another +// vector type which only changed SEW as given value. Ignore to define a new +// builtin if its equivalent type has illegal lmul or the SEW does not changed. +// (SFixedLog2LMUL:Value): Smaller Fixed Log2LMUL. Given a vector type (SEW +// and LMUL), and computes another vector type which only changed LMUL as +// given value. The new LMUL should be smaller than the old one. Ignore to +// define a new builtin if its equivalent type has illegal lmul. +// (LFixedLog2LMUL:Value): Larger Fixed Log2LMUL. Given a vector type (SEW +// and LMUL), and computes another vector type which only changed LMUL as +// given value. The new LMUL should be larger than the old one. Ignore to +// define a new builtin if its equivalent type has illegal lmul. +// +// Following with the example above, if t is "i", then "Ue" will yield unsigned +// int and "Fv" will yield __rvv_float32m1_t (again assuming LMUL=1), Fw would +// yield __rvv_float64m2_t, etc. +// +// Each builtin is then defined by applying each type in TypeRange against the +// sequence of type transformers described in Suffix and Prototype. +// +// The name of the builtin is defined by the Name attribute (which defaults to +// the name of the class) appended (separated with an underscore) the Suffix +// attribute. For instance with Name="foo", Suffix = "v" and TypeRange = "il", +// the builtin generated will be __builtin_rvv_foo_i32m1 and +// __builtin_rvv_foo_i64m1 (under LMUL=1). If Suffix contains more than one +// type transformer (say "vv") each of the types is separated with an +// underscore as in "__builtin_rvv_foo_i32m1_i32m1". +// +// The C/C++ prototype of the builtin is defined by the Prototype attribute. +// Prototype is a non-empty sequence of type transformers, the first of which +// is the return type of the builtin and the rest are the parameters of the +// builtin, in order. For instance if Prototype is "wvv" and TypeRange is "si" +// a first builtin will have type +// __rvv_int32m2_t (__rvv_int16m1_t, __rvv_int16m1_t) and the second builtin +// will have type __rvv_int64m2_t (__rvv_int32m1_t, __rvv_int32m1_t) (again +// under LMUL=1). +// +// There are a number of attributes that are used to constraint the number and +// shape of the builtins generated. Refer to the comments below for them. +class RVVBuiltin<string suffix, string prototype, string type_range, + string mangled_suffix = ""> { + // Base name that will be prepended in __builtin_rvv_ and appended the + // computed Suffix. + string Name = NAME; + + // If not empty, each instantiated builtin will have this appended after an + // underscore (_). It is instantiated like Prototype. + string Suffix = suffix; + + // If empty, default MangledName is sub string of `Name` which end of first + // '_'. For example, the default mangled name is `vadd` for Name `vadd_vv`. + // It's used for describe some special naming cases. + string MangledName = ""; + + // If not empty, each MangledName will have this appended after an + // underscore (_). It is instantiated like Prototype. + string MangledSuffix = mangled_suffix; + + // The different variants of the builtin, parameterised with a type. + string TypeRange = type_range; + + // We use each type described in TypeRange and LMUL with prototype to + // instantiate a specific element of the set of builtins being defined. + // Prototype attribute defines the C/C++ prototype of the builtin. It is a + // non-empty sequence of type transformers, the first of which is the return + // type of the builtin and the rest are the parameters of the builtin, in + // order. For instance if Prototype is "wvv", TypeRange is "si" and LMUL=1, a + // first builtin will have type + // __rvv_int32m2_t (__rvv_int16m1_t, __rvv_int16m1_t), and the second builtin + // will have type __rvv_int64m2_t (__rvv_int32m1_t, __rvv_int32m1_t). + string Prototype = prototype; + + // This builtin has a masked form. + bit HasMask = true; + + // If HasMask, this flag states that this builtin has a maskedoff operand. It + // is always the first operand in builtin and IR intrinsic. + bit HasMaskedOffOperand = true; + + // This builtin has a granted vector length parameter in the last position. + bit HasVL = true; + + // This builtin supports non-masked function overloading api. + // All masked operations support overloading api. + bit HasNoMaskedOverloaded = true; + + // Reads or writes "memory" or has other side-effects. + bit HasSideEffects = false; + + // This builtin is valid for the given Log2LMULs. + list<int> Log2LMUL = [0, 1, 2, 3, -1, -2, -3]; + + // Manual code in clang codegen riscv_vector_builtin_cg.inc + code ManualCodegen = [{}]; + code ManualCodegenMask = [{}]; + + // When emit the automatic clang codegen, it describes what types we have to use + // to obtain the specific LLVM intrinsic. -1 means the return type, otherwise, + // k >= 0 meaning the k-th operand (counting from zero) of the codegen'd + // parameter of the unmasked version. k can't be the mask operand's position. + list<int> IntrinsicTypes = []; + + // If these names are not empty, this is the ID of the LLVM intrinsic + // we want to lower to. + string IRName = NAME; + + // If HasMask, this is the ID of the LLVM intrinsic we want to lower to. + string IRNameMask = NAME #"_mask"; + + // If non empty, this is the code emitted in the header, otherwise + // an automatic definition in header is emitted. + string HeaderCode = ""; + + // Sub extension of vector spec. Currently only support Zvamo or Zvlsseg. + string RequiredExtension = ""; + + // Number of fields for Zvlsseg. + int NF = 1; +} + +//===----------------------------------------------------------------------===// +// Basic classes with automatic codegen. +//===----------------------------------------------------------------------===// + +class RVVOutBuiltin<string suffix, string prototype, string type_range> + : RVVBuiltin<suffix, prototype, type_range> { + let IntrinsicTypes = [-1]; +} + +class RVVOp0Builtin<string suffix, string prototype, string type_range> + : RVVBuiltin<suffix, prototype, type_range> { + let IntrinsicTypes = [0]; +} + +class RVVOutOp1Builtin<string suffix, string prototype, string type_range> + : RVVBuiltin<suffix, prototype, type_range> { + let IntrinsicTypes = [-1, 1]; +} + +class RVVOutOp0Op1Builtin<string suffix, string prototype, string type_range> + : RVVBuiltin<suffix, prototype, type_range> { + let IntrinsicTypes = [-1, 0, 1]; +} + +multiclass RVVBuiltinSet<string intrinsic_name, string type_range, + list<list<string>> suffixes_prototypes, + list<int> intrinsic_types> { + let IRName = intrinsic_name, IRNameMask = intrinsic_name # "_mask", + IntrinsicTypes = intrinsic_types in { + foreach s_p = suffixes_prototypes in { + let Name = NAME # "_" # s_p[0] in { + defvar suffix = s_p[1]; + defvar prototype = s_p[2]; + def : RVVBuiltin<suffix, prototype, type_range>; + } + } + } +} + +// IntrinsicTypes is output, op0, op1 [-1, 0, 1] +multiclass RVVOutOp0Op1BuiltinSet<string intrinsic_name, string type_range, + list<list<string>> suffixes_prototypes> + : RVVBuiltinSet<intrinsic_name, type_range, suffixes_prototypes, + [-1, 0, 1]>; + +multiclass RVVOutBuiltinSet<string intrinsic_name, string type_range, + list<list<string>> suffixes_prototypes> + : RVVBuiltinSet<intrinsic_name, type_range, suffixes_prototypes, [-1]>; + +multiclass RVVOp0BuiltinSet<string intrinsic_name, string type_range, + list<list<string>> suffixes_prototypes> + : RVVBuiltinSet<intrinsic_name, type_range, suffixes_prototypes, [0]>; + +// IntrinsicTypes is output, op1 [-1, 1] +multiclass RVVOutOp1BuiltinSet<string intrinsic_name, string type_range, + list<list<string>> suffixes_prototypes> + : RVVBuiltinSet<intrinsic_name, type_range, suffixes_prototypes, [-1, 1]>; + +multiclass RVVOp0Op1BuiltinSet<string intrinsic_name, string type_range, + list<list<string>> suffixes_prototypes> + : RVVBuiltinSet<intrinsic_name, type_range, suffixes_prototypes, [0, 1]>; + +multiclass RVVOutOp1Op2BuiltinSet<string intrinsic_name, string type_range, + list<list<string>> suffixes_prototypes> + : RVVBuiltinSet<intrinsic_name, type_range, suffixes_prototypes, [-1, 1, 2]>; + +multiclass RVVSignedBinBuiltinSet + : RVVOutOp1BuiltinSet<NAME, "csil", + [["vv", "v", "vvv"], + ["vx", "v", "vve"]]>; + +multiclass RVVUnsignedBinBuiltinSet + : RVVOutOp1BuiltinSet<NAME, "csil", + [["vv", "Uv", "UvUvUv"], + ["vx", "Uv", "UvUvUe"]]>; + +multiclass RVVIntBinBuiltinSet + : RVVSignedBinBuiltinSet, + RVVUnsignedBinBuiltinSet; + +multiclass RVVSlideOneBuiltinSet + : RVVOutOp1BuiltinSet<NAME, "csil", + [["vx", "v", "vve"], + ["vx", "Uv", "UvUve"]]>; + +multiclass RVVSignedShiftBuiltinSet + : RVVOutOp1BuiltinSet<NAME, "csil", + [["vv", "v", "vvUv"], + ["vx", "v", "vvz"]]>; + +multiclass RVVUnsignedShiftBuiltinSet + : RVVOutOp1BuiltinSet<NAME, "csil", + [["vv", "Uv", "UvUvUv"], + ["vx", "Uv", "UvUvz"]]>; + +multiclass RVVShiftBuiltinSet + : RVVSignedShiftBuiltinSet, + RVVUnsignedShiftBuiltinSet; + +let Log2LMUL = [-3, -2, -1, 0, 1, 2] in { + multiclass RVVSignedNShiftBuiltinSet + : RVVOutOp0Op1BuiltinSet<NAME, "csil", + [["wv", "v", "vwUv"], + ["wx", "v", "vwz"]]>; + multiclass RVVUnsignedNShiftBuiltinSet + : RVVOutOp0Op1BuiltinSet<NAME, "csil", + [["wv", "Uv", "UvUwUv"], + ["wx", "Uv", "UvUwz"]]>; +} + +multiclass RVVCarryinBuiltinSet + : RVVOutOp1BuiltinSet<NAME, "csil", + [["vvm", "v", "vvvm"], + ["vxm", "v", "vvem"], + ["vvm", "Uv", "UvUvUvm"], + ["vxm", "Uv", "UvUvUem"]]>; + +multiclass RVVCarryOutInBuiltinSet<string intrinsic_name> + : RVVOp0Op1BuiltinSet<intrinsic_name, "csil", + [["vvm", "vm", "mvvm"], + ["vxm", "vm", "mvem"], + ["vvm", "Uvm", "mUvUvm"], + ["vxm", "Uvm", "mUvUem"]]>; + +multiclass RVVSignedMaskOutBuiltinSet + : RVVOp0Op1BuiltinSet<NAME, "csil", + [["vv", "vm", "mvv"], + ["vx", "vm", "mve"]]>; + +multiclass RVVUnsignedMaskOutBuiltinSet + : RVVOp0Op1BuiltinSet<NAME, "csil", + [["vv", "Uvm", "mUvUv"], + ["vx", "Uvm", "mUvUe"]]>; + +multiclass RVVIntMaskOutBuiltinSet + : RVVSignedMaskOutBuiltinSet, + RVVUnsignedMaskOutBuiltinSet; + +class RVVIntExt<string intrinsic_name, string suffix, string prototype, + string type_range> + : RVVBuiltin<suffix, prototype, type_range> { + let IRName = intrinsic_name; + let IRNameMask = intrinsic_name # "_mask"; + let MangledName = NAME; + let IntrinsicTypes = [-1, 0]; +} + +let HasMaskedOffOperand = false in { + multiclass RVVIntTerBuiltinSet { + defm "" : RVVOutOp1BuiltinSet<NAME, "csil", + [["vv", "v", "vvvv"], + ["vx", "v", "vvev"], + ["vv", "Uv", "UvUvUvUv"], + ["vx", "Uv", "UvUvUeUv"]]>; + } + multiclass RVVFloatingTerBuiltinSet { + defm "" : RVVOutOp1BuiltinSet<NAME, "xfd", + [["vv", "v", "vvvv"], + ["vf", "v", "vvev"]]>; + } +} + +let HasMaskedOffOperand = false, Log2LMUL = [-2, -1, 0, 1, 2] in { + multiclass RVVFloatingWidenTerBuiltinSet { + defm "" : RVVOutOp1Op2BuiltinSet<NAME, "xf", + [["vv", "w", "wwvv"], + ["vf", "w", "wwev"]]>; + } +} + +multiclass RVVFloatingBinBuiltinSet + : RVVOutOp1BuiltinSet<NAME, "xfd", + [["vv", "v", "vvv"], + ["vf", "v", "vve"]]>; + +multiclass RVVFloatingBinVFBuiltinSet + : RVVOutOp1BuiltinSet<NAME, "xfd", + [["vf", "v", "vve"]]>; + +multiclass RVVFloatingMaskOutBuiltinSet + : RVVOp0Op1BuiltinSet<NAME, "xfd", + [["vv", "vm", "mvv"], + ["vf", "vm", "mve"]]>; + +multiclass RVVFloatingMaskOutVFBuiltinSet + : RVVOp0Op1BuiltinSet<NAME, "fd", + [["vf", "vm", "mve"]]>; + +class RVVMaskBinBuiltin : RVVOutBuiltin<"m", "mmm", "c"> { + let Name = NAME # "_mm"; + let HasMask = false; +} + +class RVVMaskUnaryBuiltin : RVVOutBuiltin<"m", "mm", "c"> { + let Name = NAME # "_m"; +} + +class RVVMaskNullaryBuiltin : RVVOutBuiltin<"m", "m", "c"> { + let Name = NAME # "_m"; + let HasMask = false; + let HasNoMaskedOverloaded = false; +} + +class RVVMaskOp0Builtin<string prototype> : RVVOp0Builtin<"m", prototype, "c"> { + let Name = NAME # "_m"; + let HasMaskedOffOperand = false; +} + +let HasMaskedOffOperand = false in { + multiclass RVVSlideBuiltinSet { + defm "" : RVVOutBuiltinSet<NAME, "csilxfd", + [["vx","v", "vvvz"]]>; + defm "" : RVVOutBuiltinSet<NAME, "csil", + [["vx","Uv", "UvUvUvz"]]>; + } +} + +class RVVFloatingUnaryBuiltin<string builtin_suffix, string ir_suffix, + string prototype> + : RVVOutBuiltin<ir_suffix, prototype, "xfd"> { + let Name = NAME # "_" # builtin_suffix; +} + +class RVVFloatingUnaryVVBuiltin : RVVFloatingUnaryBuiltin<"v", "v", "vv">; + +class RVVConvBuiltin<string suffix, string prototype, string type_range, + string mangled_name> + : RVVBuiltin<suffix, prototype, type_range> { + let IntrinsicTypes = [-1, 0]; + let MangledName = mangled_name; +} + +class RVVConvToSignedBuiltin<string mangled_name> + : RVVConvBuiltin<"Iv", "Ivv", "xfd", mangled_name>; + +class RVVConvToUnsignedBuiltin<string mangled_name> + : RVVConvBuiltin<"Uv", "Uvv", "xfd", mangled_name>; + +class RVVConvToWidenSignedBuiltin<string mangled_name> + : RVVConvBuiltin<"Iw", "Iwv", "xf", mangled_name>; + +class RVVConvToWidenUnsignedBuiltin<string mangled_name> + : RVVConvBuiltin<"Uw", "Uwv", "xf", mangled_name>; + +class RVVConvToNarrowingSignedBuiltin<string mangled_name> + : RVVConvBuiltin<"Iv", "IvFw", "csi", mangled_name>; + +class RVVConvToNarrowingUnsignedBuiltin<string mangled_name> + : RVVConvBuiltin<"Uv", "UvFw", "csi", mangled_name>; + +let HasMaskedOffOperand = false in { + multiclass RVVSignedReductionBuiltin { + defm "" : RVVOutOp1BuiltinSet<NAME, "csil", + [["vs", "vSv", "SvSvvSv"]]>; + } + multiclass RVVUnsignedReductionBuiltin { + defm "" : RVVOutOp1BuiltinSet<NAME, "csil", + [["vs", "UvUSv", "USvUSvUvUSv"]]>; + } + multiclass RVVFloatingReductionBuiltin { + defm "" : RVVOutOp1BuiltinSet<NAME, "xfd", + [["vs", "vSv", "SvSvvSv"]]>; + } + multiclass RVVFloatingWidenReductionBuiltin { + defm "" : RVVOutOp1BuiltinSet<NAME, "xf", + [["vs", "vSw", "SwSwvSw"]]>; + } +} + +multiclass RVVIntReductionBuiltinSet + : RVVSignedReductionBuiltin, + RVVUnsignedReductionBuiltin; + +// For widen operation which has different mangling name. +multiclass RVVWidenBuiltinSet<string intrinsic_name, string type_range, + list<list<string>> suffixes_prototypes> { + let Log2LMUL = [-3, -2, -1, 0, 1, 2], + IRName = intrinsic_name, IRNameMask = intrinsic_name # "_mask" in { + foreach s_p = suffixes_prototypes in { + let Name = NAME # "_" # s_p[0], + MangledName = NAME # "_" # s_p[0] in { + defvar suffix = s_p[1]; + defvar prototype = s_p[2]; + def : RVVOutOp0Op1Builtin<suffix, prototype, type_range>; + } + } + } +} + +// For widen operation with widen operand which has different mangling name. +multiclass RVVWidenWOp0BuiltinSet<string intrinsic_name, string type_range, + list<list<string>> suffixes_prototypes> { + let Log2LMUL = [-3, -2, -1, 0, 1, 2], + IRName = intrinsic_name, IRNameMask = intrinsic_name # "_mask" in { + foreach s_p = suffixes_prototypes in { + let Name = NAME # "_" # s_p[0], + MangledName = NAME # "_" # s_p[0] in { + defvar suffix = s_p[1]; + defvar prototype = s_p[2]; + def : RVVOutOp1Builtin<suffix, prototype, type_range>; + } + } + } +} + +multiclass RVVSignedWidenBinBuiltinSet + : RVVWidenBuiltinSet<NAME, "csi", + [["vv", "w", "wvv"], + ["vx", "w", "wve"]]>; + +multiclass RVVSignedWidenOp0BinBuiltinSet + : RVVWidenWOp0BuiltinSet<NAME # "_w", "csi", + [["wv", "w", "wwv"], + ["wx", "w", "wwe"]]>; + +multiclass RVVUnsignedWidenBinBuiltinSet + : RVVWidenBuiltinSet<NAME, "csi", + [["vv", "Uw", "UwUvUv"], + ["vx", "Uw", "UwUvUe"]]>; + +multiclass RVVUnsignedWidenOp0BinBuiltinSet + : RVVWidenWOp0BuiltinSet<NAME # "_w", "csi", + [["wv", "Uw", "UwUwUv"], + ["wx", "Uw", "UwUwUe"]]>; + +multiclass RVVFloatingWidenBinBuiltinSet + : RVVWidenBuiltinSet<NAME, "xf", + [["vv", "w", "wvv"], + ["vf", "w", "wve"]]>; + +multiclass RVVFloatingWidenOp0BinBuiltinSet + : RVVWidenWOp0BuiltinSet<NAME # "_w", "xf", + [["wv", "w", "wwv"], + ["wf", "w", "wwe"]]>; + +defvar TypeList = ["c","s","i","l","x","f","d"]; +defvar EEWList = [["8", "(Log2EEW:3)"], + ["16", "(Log2EEW:4)"], + ["32", "(Log2EEW:5)"], + ["64", "(Log2EEW:6)"]]; + +class IsFloat<string type> { + bit val = !or(!eq(type, "x"), !eq(type, "f"), !eq(type, "d")); +} + +let HasNoMaskedOverloaded = false, + ManualCodegen = [{ + IntrinsicTypes = {ResultType, Ops[1]->getType()}; + Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo()); + }], + ManualCodegenMask= [{ + // Move mask to right before vl. + std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + IntrinsicTypes = {ResultType, Ops[3]->getType()}; + Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo()); + }] in { + class RVVVLEMaskBuiltin : RVVBuiltin<"m", "mPCUe", "c"> { + let Name = "vle1_v"; + let IRName = "vle1"; + let HasMask = false; + } + multiclass RVVVLEBuiltin<list<string> types> { + let Name = NAME # "_v", + IRName = "vle", + IRNameMask ="vle_mask" in { + foreach type = types in { + def : RVVBuiltin<"v", "vPCe", type>; + if !not(IsFloat<type>.val) then { + def : RVVBuiltin<"Uv", "UvPCUe", type>; + } + } + } + } +} + +multiclass RVVVLEFFBuiltin<list<string> types> { + let Name = NAME # "_v", + IRName = "vleff", + IRNameMask = "vleff_mask", + HasNoMaskedOverloaded = false, + ManualCodegen = [{ + { + IntrinsicTypes = {ResultType, Ops[2]->getType()}; + Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo()); + Value *NewVL = Ops[1]; + Ops.erase(Ops.begin() + 1); + llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); + llvm::Value *LoadValue = Builder.CreateCall(F, Ops, ""); + llvm::Value *V = Builder.CreateExtractValue(LoadValue, {0}); + // Store new_vl. + clang::CharUnits Align = + CGM.getNaturalTypeAlignment(getContext().getSizeType()); + Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {1}), + Address(NewVL, Align)); + return V; + } + }], + ManualCodegenMask = [{ + { + // Move mask to right before vl. + std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + IntrinsicTypes = {ResultType, Ops[4]->getType()}; + Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo()); + Value *NewVL = Ops[2]; + Ops.erase(Ops.begin() + 2); + llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); + llvm::Value *LoadValue = Builder.CreateCall(F, Ops, ""); + llvm::Value *V = Builder.CreateExtractValue(LoadValue, {0}); + // Store new_vl. + clang::CharUnits Align = + CGM.getNaturalTypeAlignment(getContext().getSizeType()); + Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {1}), + Address(NewVL, Align)); + return V; + } + }] in { + foreach type = types in { + def : RVVBuiltin<"v", "vPCePz", type>; + // Skip floating types for unsigned versions. + if !not(IsFloat<type>.val) then { + def : RVVBuiltin<"Uv", "UvPCUePz", type>; + } + } + } +} + +multiclass RVVVLSEBuiltin<list<string> types> { + let Name = NAME # "_v", + IRName = "vlse", + IRNameMask ="vlse_mask", + HasNoMaskedOverloaded = false, + ManualCodegen = [{ + IntrinsicTypes = {ResultType, Ops[2]->getType()}; + Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo()); + }], + ManualCodegenMask= [{ + // Move mask to right before vl. + std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + IntrinsicTypes = {ResultType, Ops[4]->getType()}; + Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo()); + }] in { + foreach type = types in { + def : RVVBuiltin<"v", "vPCet", type>; + if !not(IsFloat<type>.val) then { + def : RVVBuiltin<"Uv", "UvPCUet", type>; + } + } + } +} + +multiclass RVVIndexedLoad<string op> { + let ManualCodegen = [{ + IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType()}; + Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo()); + }], + ManualCodegenMask = [{ + // Move mask to right before vl. + std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops[4]->getType()}; + Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo()); + }] in { + foreach type = TypeList in { + foreach eew_list = EEWList in { + defvar eew = eew_list[0]; + defvar eew_type = eew_list[1]; + let Name = op # eew # "_v", IRName = op, IRNameMask = op # "_mask" in { + def: RVVBuiltin<"v", "vPCe" # eew_type # "Uv", type>; + if !not(IsFloat<type>.val) then { + def: RVVBuiltin<"Uv", "UvPCUe" # eew_type # "Uv", type>; + } + } + } + } + } +} + +let HasMaskedOffOperand = false, + ManualCodegen = [{ + // Builtin: (ptr, value, vl). Intrinsic: (value, ptr, vl) + std::swap(Ops[0], Ops[1]); + Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo()); + IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType()}; + }], + ManualCodegenMask= [{ + // Builtin: (mask, ptr, value, vl). Intrinsic: (value, ptr, mask, vl) + std::swap(Ops[0], Ops[2]); + Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo()); + IntrinsicTypes = {Ops[0]->getType(), Ops[3]->getType()}; + }] in { + class RVVVSEMaskBuiltin : RVVBuiltin<"m", "0PUem", "c"> { + let Name = "vse1_v"; + let IRName = "vse1"; + let HasMask = false; + } + multiclass RVVVSEBuiltin<list<string> types> { + let Name = NAME # "_v", + IRName = "vse", + IRNameMask = "vse_mask" in { + foreach type = types in { + def : RVVBuiltin<"v", "0Pev", type>; + if !not(IsFloat<type>.val) then { + def : RVVBuiltin<"Uv", "0PUeUv", type>; + } + } + } + } +} + +multiclass RVVVSSEBuiltin<list<string> types> { + let Name = NAME # "_v", + IRName = "vsse", + IRNameMask = "vsse_mask", + HasMaskedOffOperand = false, + ManualCodegen = [{ + // Builtin: (ptr, stride, value, vl). Intrinsic: (value, ptr, stride, vl) + std::rotate(Ops.begin(), Ops.begin() + 2, Ops.begin() + 3); + Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo()); + IntrinsicTypes = {Ops[0]->getType(), Ops[3]->getType()}; + }], + ManualCodegenMask= [{ + // Builtin: (mask, ptr, stride, value, vl). Intrinsic: (value, ptr, stride, mask, vl) + std::swap(Ops[0], Ops[3]); + Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo()); + IntrinsicTypes = {Ops[0]->getType(), Ops[4]->getType()}; + }] in { + foreach type = types in { + def : RVVBuiltin<"v", "0Petv", type>; + if !not(IsFloat<type>.val) then { + def : RVVBuiltin<"Uv", "0PUetUv", type>; + } + } + } +} + +multiclass RVVIndexedStore<string op> { + let HasMaskedOffOperand = false, + ManualCodegen = [{ + // Builtin: (ptr, index, value, vl). Intrinsic: (value, ptr, index, vl) + std::rotate(Ops.begin(), Ops.begin() + 2, Ops.begin() + 3); + Ops[1] = Builder.CreateBitCast(Ops[1],Ops[0]->getType()->getPointerTo()); + IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType(), Ops[3]->getType()}; + }], + ManualCodegenMask= [{ + // Builtin: (mask, ptr, index, value, vl). Intrinsic: (value, ptr, index, mask, vl) + std::swap(Ops[0], Ops[3]); + Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo()); + IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType(), Ops[4]->getType()}; + }] in { + foreach type = TypeList in { + foreach eew_list = EEWList in { + defvar eew = eew_list[0]; + defvar eew_type = eew_list[1]; + let Name = op # eew # "_v", IRName = op, IRNameMask = op # "_mask" in { + def : RVVBuiltin<"v", "0Pe" # eew_type # "Uvv", type>; + if !not(IsFloat<type>.val) then { + def : RVVBuiltin<"Uv", "0PUe" # eew_type # "UvUv", type>; + } + } + } + } + } +} + +defvar NFList = [2, 3, 4, 5, 6, 7, 8]; + +class PVString<int nf, bit signed> { + string S = + !cond(!eq(nf, 2): !if(signed, "PvPv", "PUvPUv"), + !eq(nf, 3): !if(signed, "PvPvPv", "PUvPUvPUv"), + !eq(nf, 4): !if(signed, "PvPvPvPv", "PUvPUvPUvPUv"), + !eq(nf, 5): !if(signed, "PvPvPvPvPv", "PUvPUvPUvPUvPUv"), + !eq(nf, 6): !if(signed, "PvPvPvPvPvPv", "PUvPUvPUvPUvPUvPUv"), + !eq(nf, 7): !if(signed, "PvPvPvPvPvPvPv", "PUvPUvPUvPUvPUvPUvPUv"), + !eq(nf, 8): !if(signed, "PvPvPvPvPvPvPvPv", "PUvPUvPUvPUvPUvPUvPUvPUv")); +} + +multiclass RVVUnitStridedSegLoad<string op> { + foreach type = TypeList in { + defvar eew = !cond(!eq(type, "c") : "8", + !eq(type, "s") : "16", + !eq(type, "i") : "32", + !eq(type, "l") : "64", + !eq(type, "x") : "16", + !eq(type, "f") : "32", + !eq(type, "d") : "64"); + foreach nf = NFList in { + let Name = op # nf # "e" # eew # "_v", + IRName = op # nf, + IRNameMask = op # nf # "_mask", + NF = nf, + HasNoMaskedOverloaded = false, + ManualCodegen = [{ + { + // builtin: (val0 address, val1 address, ..., ptr, vl) + IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(), + Ops[NF + 1]->getType()}; + // intrinsic: (ptr, vl) + llvm::Value *Operands[] = {Ops[NF], Ops[NF + 1]}; + llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); + llvm::Value *LoadValue = Builder.CreateCall(F, Operands, ""); + clang::CharUnits Align = CharUnits::fromQuantity( + IntrinsicTypes[0]->getScalarSizeInBits() / 8); + llvm::Value *V; + for (unsigned I = 0; I < NF; ++I) { + V = Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}), + Address(Ops[I], Align)); + } + return V; + } + }], + ManualCodegenMask = [{ + { + // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, vl) + // intrinsic: (maskedoff0, ..., ptr, mask, vl) + IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(), + Ops[2 * NF + 2]->getType()}; + SmallVector<llvm::Value*, 12> Operands; + for (unsigned I = 0; I < NF; ++I) + Operands.push_back(Ops[NF + I + 1]); + Operands.push_back(Ops[2 * NF + 1]); + Operands.push_back(Ops[NF]); + Operands.push_back(Ops[2 * NF + 2]); + assert(Operands.size() == NF + 3); + llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); + llvm::Value *LoadValue = Builder.CreateCall(F, Operands, ""); + clang::CharUnits Align = CharUnits::fromQuantity( + IntrinsicTypes[0]->getScalarSizeInBits() / 8); + llvm::Value *V; + for (unsigned I = 0; I < NF; ++I) { + V = Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}), + Address(Ops[I], Align)); + } + return V; + } + }] in { + defvar PV = PVString<nf, /*signed=*/true>.S; + defvar PUV = PVString<nf, /*signed=*/false>.S; + def : RVVBuiltin<"v", "0" # PV # "PCe", type>; + if !not(IsFloat<type>.val) then { + def : RVVBuiltin<"Uv", "0" # PUV # "PCUe", type>; + } + } + } + } +} + +multiclass RVVUnitStridedSegLoadFF<string op> { + foreach type = TypeList in { + defvar eew = !cond(!eq(type, "c") : "8", + !eq(type, "s") : "16", + !eq(type, "i") : "32", + !eq(type, "l") : "64", + !eq(type, "x") : "16", + !eq(type, "f") : "32", + !eq(type, "d") : "64"); + foreach nf = NFList in { + let Name = op # nf # "e" # eew # "ff_v", + IRName = op # nf # "ff", + IRNameMask = op # nf # "ff_mask", + NF = nf, + HasNoMaskedOverloaded = false, + ManualCodegen = [{ + { + // builtin: (val0 address, val1 address, ..., ptr, new_vl, vl) + IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(), + Ops[NF + 2]->getType()}; + // intrinsic: (ptr, vl) + llvm::Value *Operands[] = {Ops[NF], Ops[NF + 2]}; + Value *NewVL = Ops[NF + 1]; + llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); + llvm::Value *LoadValue = Builder.CreateCall(F, Operands, ""); + clang::CharUnits Align = CharUnits::fromQuantity( + IntrinsicTypes[0]->getScalarSizeInBits() / 8); + for (unsigned I = 0; I < NF; ++I) { + Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}), + Address(Ops[I], Align)); + } + // Store new_vl. + return Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {NF}), + Address(NewVL, Align)); + } + }], + ManualCodegenMask = [{ + { + // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, new_vl, vl) + // intrinsic: (maskedoff0, ..., ptr, mask, vl) + IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(), + Ops[2 * NF + 3]->getType()}; + SmallVector<llvm::Value*, 12> Operands; + for (unsigned I = 0; I < NF; ++I) + Operands.push_back(Ops[NF + I + 1]); + Operands.push_back(Ops[2 * NF + 1]); + Operands.push_back(Ops[NF]); + Operands.push_back(Ops[2 * NF + 3]); + Value *NewVL = Ops[2 * NF + 2]; + assert(Operands.size() == NF + 3); + llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); + llvm::Value *LoadValue = Builder.CreateCall(F, Operands, ""); + clang::CharUnits Align = CharUnits::fromQuantity( + IntrinsicTypes[0]->getScalarSizeInBits() / 8); + for (unsigned I = 0; I < NF; ++I) { + Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}), + Address(Ops[I], Align)); + } + // Store new_vl. + return Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {NF}), + Address(NewVL, Align)); + } + }] in { + defvar PV = PVString<nf, /*signed=*/true>.S; + defvar PUV = PVString<nf, /*signed=*/false>.S; + def : RVVBuiltin<"v", "0" # PV # "PCe" # "Pz", type>; + if !not(IsFloat<type>.val) then { + def : RVVBuiltin<"Uv", "0" # PUV # "PCUe" # "Pz", type>; + } + } + } + } +} + +multiclass RVVStridedSegLoad<string op> { + foreach type = TypeList in { + defvar eew = !cond(!eq(type, "c") : "8", + !eq(type, "s") : "16", + !eq(type, "i") : "32", + !eq(type, "l") : "64", + !eq(type, "x") : "16", + !eq(type, "f") : "32", + !eq(type, "d") : "64"); + foreach nf = NFList in { + let Name = op # nf # "e" # eew # "_v", + IRName = op # nf, + IRNameMask = op # nf # "_mask", + NF = nf, + HasNoMaskedOverloaded = false, + ManualCodegen = [{ + { + // builtin: (val0 address, val1 address, ..., ptr, stride, vl) + IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(), + Ops[NF + 2]->getType()}; + // intrinsic: (ptr, stride, vl) + llvm::Value *Operands[] = {Ops[NF], Ops[NF + 1], Ops[NF + 2]}; + llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); + llvm::Value *LoadValue = Builder.CreateCall(F, Operands, ""); + clang::CharUnits Align = CharUnits::fromQuantity( + IntrinsicTypes[0]->getScalarSizeInBits() / 8); + llvm::Value *V; + for (unsigned I = 0; I < NF; ++I) { + V = Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}), + Address(Ops[I], Align)); + } + return V; + } + }], + ManualCodegenMask = [{ + { + // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, stride, vl) + // intrinsic: (maskedoff0, ..., ptr, stride, mask, vl) + IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(), + Ops[2 * NF + 3]->getType()}; + SmallVector<llvm::Value*, 12> Operands; + for (unsigned I = 0; I < NF; ++I) + Operands.push_back(Ops[NF + I + 1]); + Operands.push_back(Ops[2 * NF + 1]); + Operands.push_back(Ops[2 * NF + 2]); + Operands.push_back(Ops[NF]); + Operands.push_back(Ops[2 * NF + 3]); + assert(Operands.size() == NF + 4); + llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); + llvm::Value *LoadValue = Builder.CreateCall(F, Operands, ""); + clang::CharUnits Align = CharUnits::fromQuantity( + IntrinsicTypes[0]->getScalarSizeInBits() / 8); + llvm::Value *V; + for (unsigned I = 0; I < NF; ++I) { + V = Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}), + Address(Ops[I], Align)); + } + return V; + } + }] in { + defvar PV = PVString<nf, /*signed=*/true>.S; + defvar PUV = PVString<nf, /*signed=*/false>.S; + def : RVVBuiltin<"v", "0" # PV # "PCe" # "t", type>; + if !not(IsFloat<type>.val) then { + def : RVVBuiltin<"Uv", "0" # PUV # "PCUe" # "t", type>; + } + } + } + } +} + +multiclass RVVIndexedSegLoad<string op> { + foreach type = TypeList in { + foreach eew_info = EEWList in { + defvar eew = eew_info[0]; + defvar eew_type = eew_info[1]; + foreach nf = NFList in { + let Name = op # nf # "ei" # eew # "_v", + IRName = op # nf, + IRNameMask = op # nf # "_mask", + NF = nf, + ManualCodegen = [{ + { + // builtin: (val0 address, val1 address, ..., ptr, index, vl) + IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(), + Ops[NF + 1]->getType(), Ops[NF + 2]->getType()}; + // intrinsic: (ptr, index, vl) + llvm::Value *Operands[] = {Ops[NF], Ops[NF + 1], Ops[NF + 2]}; + llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); + llvm::Value *LoadValue = Builder.CreateCall(F, Operands, ""); + clang::CharUnits Align = CharUnits::fromQuantity( + IntrinsicTypes[0]->getScalarSizeInBits() / 8); + llvm::Value *V; + for (unsigned I = 0; I < NF; ++I) { + V = Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}), + Address(Ops[I], Align)); + } + return V; + } + }], + ManualCodegenMask = [{ + { + // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, index, vl) + IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(), + Ops[2 * NF + 2]->getType(), Ops[2 * NF + 3]->getType()}; + // intrinsic: (maskedoff0, ..., ptr, index, mask, vl) + SmallVector<llvm::Value*, 12> Operands; + for (unsigned I = 0; I < NF; ++I) + Operands.push_back(Ops[NF + I + 1]); + Operands.push_back(Ops[2 * NF + 1]); + Operands.push_back(Ops[2 * NF + 2]); + Operands.push_back(Ops[NF]); + Operands.push_back(Ops[2 * NF + 3]); + assert(Operands.size() == NF + 4); + llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); + llvm::Value *LoadValue = Builder.CreateCall(F, Operands, ""); + clang::CharUnits Align = CharUnits::fromQuantity( + IntrinsicTypes[0]->getScalarSizeInBits() / 8); + llvm::Value *V; + for (unsigned I = 0; I < NF; ++I) { + V = Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}), + Address(Ops[I], Align)); + } + return V; + } + }] in { + defvar PV = PVString<nf, /*signed=*/true>.S; + defvar PUV = PVString<nf, /*signed=*/false>.S; + def : RVVBuiltin<"v", "0" # PV # "PCe" # eew_type # "Uv", type>; + if !not(IsFloat<type>.val) then { + def : RVVBuiltin<"Uv", "0" # PUV # "PCUe" # eew_type # "Uv", type>; + } + } + } + } + } +} + +class VString<int nf, bit signed> { + string S = !cond(!eq(nf, 2): !if(signed, "vv", "UvUv"), + !eq(nf, 3): !if(signed, "vvv", "UvUvUv"), + !eq(nf, 4): !if(signed, "vvvv", "UvUvUvUv"), + !eq(nf, 5): !if(signed, "vvvvv", "UvUvUvUvUv"), + !eq(nf, 6): !if(signed, "vvvvvv", "UvUvUvUvUvUv"), + !eq(nf, 7): !if(signed, "vvvvvvv", "UvUvUvUvUvUvUv"), + !eq(nf, 8): !if(signed, "vvvvvvvv", "UvUvUvUvUvUvUvUv")); +} + +multiclass RVVUnitStridedSegStore<string op> { + foreach type = TypeList in { + defvar eew = !cond(!eq(type, "c") : "8", + !eq(type, "s") : "16", + !eq(type, "i") : "32", + !eq(type, "l") : "64", + !eq(type, "x") : "16", + !eq(type, "f") : "32", + !eq(type, "d") : "64"); + foreach nf = NFList in { + let Name = op # nf # "e" # eew # "_v", + IRName = op # nf, + IRNameMask = op # nf # "_mask", + NF = nf, + HasMaskedOffOperand = false, + ManualCodegen = [{ + { + // Builtin: (ptr, val0, val1, ..., vl) + // Intrinsic: (val0, val1, ..., ptr, vl) + std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()}; + assert(Ops.size() == NF + 2); + } + }], + ManualCodegenMask = [{ + { + // Builtin: (mask, ptr, val0, val1, ..., vl) + // Intrinsic: (val0, val1, ..., ptr, mask, vl) + std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1); + std::swap(Ops[NF], Ops[NF + 1]); + IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 2]->getType()}; + assert(Ops.size() == NF + 3); + } + }] in { + defvar V = VString<nf, /*signed=*/true>.S; + defvar UV = VString<nf, /*signed=*/false>.S; + def : RVVBuiltin<"v", "0Pe" # V, type>; + if !not(IsFloat<type>.val) then { + def : RVVBuiltin<"Uv", "0PUe" # UV, type>; + } + } + } + } +} + +multiclass RVVStridedSegStore<string op> { + foreach type = TypeList in { + defvar eew = !cond(!eq(type, "c") : "8", + !eq(type, "s") : "16", + !eq(type, "i") : "32", + !eq(type, "l") : "64", + !eq(type, "x") : "16", + !eq(type, "f") : "32", + !eq(type, "d") : "64"); + foreach nf = NFList in { + let Name = op # nf # "e" # eew # "_v", + IRName = op # nf, + IRNameMask = op # nf # "_mask", + NF = nf, + HasMaskedOffOperand = false, + ManualCodegen = [{ + { + // Builtin: (ptr, stride, val0, val1, ..., vl). + // Intrinsic: (val0, val1, ..., ptr, stride, vl) + std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1); + IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()}; + assert(Ops.size() == NF + 3); + } + }], + ManualCodegenMask = [{ + { + // Builtin: (mask, ptr, stride, val0, val1, ..., vl). + // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl) + std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1); + std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3); + IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()}; + assert(Ops.size() == NF + 4); + } + }] in { + defvar V = VString<nf, /*signed=*/true>.S; + defvar UV = VString<nf, /*signed=*/false>.S; + def : RVVBuiltin<"v", "0Pet" # V, type>; + if !not(IsFloat<type>.val) then { + def : RVVBuiltin<"Uv", "0PUet" # UV, type>; + } + } + } + } +} + +multiclass RVVIndexedSegStore<string op> { + foreach type = TypeList in { + foreach eew_info = EEWList in { + defvar eew = eew_info[0]; + defvar eew_type = eew_info[1]; + foreach nf = NFList in { + let Name = op # nf # "ei" # eew # "_v", + IRName = op # nf, + IRNameMask = op # nf # "_mask", + NF = nf, + HasMaskedOffOperand = false, + ManualCodegen = [{ + { + // Builtin: (ptr, index, val0, val1, ..., vl) + // Intrinsic: (val0, val1, ..., ptr, index, vl) + std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1); + IntrinsicTypes = {Ops[0]->getType(), + Ops[NF + 1]->getType(), Ops[NF + 2]->getType()}; + assert(Ops.size() == NF + 3); + } + }], + ManualCodegenMask = [{ + { + // Builtin: (mask, ptr, index, val0, val1, ..., vl) + // Intrinsic: (val0, val1, ..., ptr, index, mask, vl) + std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1); + std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3); + IntrinsicTypes = {Ops[0]->getType(), + Ops[NF + 1]->getType(), Ops[NF + 3]->getType()}; + assert(Ops.size() == NF + 4); + } + }] in { + defvar V = VString<nf, /*signed=*/true>.S; + defvar UV = VString<nf, /*signed=*/false>.S; + def : RVVBuiltin<"v", "0Pe" # eew_type # "Uv" # V, type>; + if !not(IsFloat<type>.val) then { + def : RVVBuiltin<"Uv", "0PUe" # eew_type # "Uv" # UV, type>; + } + } + } + } + } +} + +multiclass RVVAMOBuiltinSet<bit has_signed = false, bit has_unsigned = false, + bit has_fp = false> { + defvar type_list = !if(has_fp, ["i","l","f","d"], ["i","l"]); + foreach type = type_list in + foreach eew_list = EEWList in { + defvar eew = eew_list[0]; + defvar eew_index = eew_list[1]; + let Name = NAME # "ei" # eew # "_" # "v", + IRName = NAME, + IRNameMask = NAME # "_mask", + HasMaskedOffOperand = false, + ManualCodegen = [{ + // base, bindex, value, vl + IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[3]->getType()}; + Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo()); + }], + ManualCodegenMask = [{ + std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[4]->getType()}; + Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo()); + }] in { + if has_signed then + def : RVVBuiltin<"v", "vPe" # eew_index # "Uvv", type>; + if !and(!not(IsFloat<type>.val), has_unsigned) then + def : RVVBuiltin<"Uv", "UvPUe" # eew_index # "UvUv", type>; + } + } +} + +multiclass RVVPseudoUnaryBuiltin<string IR, string type_range> { + let Name = NAME, + IRName = IR, + IRNameMask = IR # "_mask", + ManualCodegen = [{ + { + // op1, vl + IntrinsicTypes = {ResultType, + cast<llvm::VectorType>(ResultType)->getElementType(), + Ops[1]->getType()}; + Ops.insert(Ops.begin() + 1, llvm::Constant::getNullValue(IntrinsicTypes[1])); + break; + } + }], + ManualCodegenMask = [{ + { + std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + // maskedoff, op1, mask, vl + IntrinsicTypes = {ResultType, + cast<llvm::VectorType>(ResultType)->getElementType(), + Ops[3]->getType()}; + Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(IntrinsicTypes[1])); + break; + } + }] in { + def : RVVBuiltin<"v", "vv", type_range>; + } +} + +multiclass RVVPseudoVNotBuiltin<string IR, string type_range> { + let Name = NAME, + IRName = IR, + IRNameMask = IR # "_mask", + ManualCodegen = [{ + { + // op1, vl + IntrinsicTypes = {ResultType, + cast<llvm::VectorType>(ResultType)->getElementType(), + Ops[1]->getType()}; + Ops.insert(Ops.begin() + 1, + llvm::Constant::getAllOnesValue(IntrinsicTypes[1])); + break; + } + }], + ManualCodegenMask = [{ + { + std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + // maskedoff, op1, mask, vl + IntrinsicTypes = {ResultType, + cast<llvm::VectorType>(ResultType)->getElementType(), + Ops[3]->getType()}; + Ops.insert(Ops.begin() + 2, + llvm::Constant::getAllOnesValue(IntrinsicTypes[1])); + break; + } + }] in { + def : RVVBuiltin<"v", "vv", type_range>; + def : RVVBuiltin<"Uv", "UvUv", type_range>; + } +} + +multiclass RVVPseudoMaskBuiltin<string IR, string type_range> { + let Name = NAME, + IRName = IR, + HasMask = false, + ManualCodegen = [{ + { + // op1, vl + IntrinsicTypes = {ResultType, + Ops[1]->getType()}; + Ops.insert(Ops.begin() + 1, Ops[0]); + break; + } + }] in { + def : RVVBuiltin<"m", "mm", type_range>; + } +} + +multiclass RVVPseudoVFUnaryBuiltin<string IR, string type_range> { + let Name = NAME, + IRName = IR, + IRNameMask = IR # "_mask", + ManualCodegen = [{ + { + // op1, vl + IntrinsicTypes = {ResultType, + Ops[0]->getType(), Ops[1]->getType()}; + Ops.insert(Ops.begin() + 1, Ops[0]); + break; + } + }], + ManualCodegenMask = [{ + { + std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + // maskedoff, op1, mask, vl + IntrinsicTypes = {ResultType, + Ops[1]->getType(), + Ops[3]->getType()}; + Ops.insert(Ops.begin() + 2, Ops[1]); + break; + } + }] in { + def : RVVBuiltin<"v", "vv", type_range>; + } +} + +multiclass RVVPseudoVWCVTBuiltin<string IR, string MName, string type_range, + list<list<string>> suffixes_prototypes> { + let Name = NAME, + MangledName = MName, + IRName = IR, + IRNameMask = IR # "_mask", + ManualCodegen = [{ + { + // op1, vl + IntrinsicTypes = {ResultType, + Ops[0]->getType(), + cast<llvm::VectorType>(Ops[0]->getType())->getElementType(), + Ops[1]->getType()}; + Ops.insert(Ops.begin() + 1, llvm::Constant::getNullValue(IntrinsicTypes[2])); + break; + } + }], + ManualCodegenMask = [{ + { + std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + // maskedoff, op1, mask, vl + IntrinsicTypes = {ResultType, + Ops[1]->getType(), + cast<llvm::VectorType>(Ops[1]->getType())->getElementType(), + Ops[3]->getType()}; + Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(IntrinsicTypes[2])); + break; + } + }] in { + foreach s_p = suffixes_prototypes in { + def : RVVBuiltin<s_p[0], s_p[1], type_range>; + } + } +} + +multiclass RVVPseudoVNCVTBuiltin<string IR, string MName, string type_range, + list<list<string>> suffixes_prototypes> { + let Name = NAME, + MangledName = MName, + IRName = IR, + IRNameMask = IR # "_mask", + ManualCodegen = [{ + { + // op1, vl + IntrinsicTypes = {ResultType, + Ops[0]->getType(), + Ops[1]->getType(), + Ops[1]->getType()}; + Ops.insert(Ops.begin() + 1, llvm::Constant::getNullValue(IntrinsicTypes[2])); + break; + } + }], + ManualCodegenMask = [{ + { + std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + // maskedoff, op1, mask, vl + IntrinsicTypes = {ResultType, + Ops[1]->getType(), + Ops[3]->getType(), + Ops[3]->getType()}; + Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(IntrinsicTypes[2])); + break; + } + }] in { + foreach s_p = suffixes_prototypes in { + def : RVVBuiltin<s_p[0], s_p[1], type_range>; + } + } +} + +// 6. Configuration-Setting Instructions +// 6.1. vsetvli/vsetvl instructions +let HasVL = false, + HasMask = false, + HasSideEffects = true, + Log2LMUL = [0], + ManualCodegen = [{IntrinsicTypes = {ResultType};}] in // Set XLEN type +{ + // vsetvl is a macro because for it require constant integers in SEW and LMUL. + let HeaderCode = +[{ +#define vsetvl_e8mf8(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 5) +#define vsetvl_e8mf4(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 6) +#define vsetvl_e8mf2(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 7) +#define vsetvl_e8m1(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 0) +#define vsetvl_e8m2(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 1) +#define vsetvl_e8m4(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 2) +#define vsetvl_e8m8(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 3) + +#define vsetvl_e16mf4(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 6) +#define vsetvl_e16mf2(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 7) +#define vsetvl_e16m1(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 0) +#define vsetvl_e16m2(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 1) +#define vsetvl_e16m4(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 2) +#define vsetvl_e16m8(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 3) + +#define vsetvl_e32mf2(avl) __builtin_rvv_vsetvli((size_t)(avl), 2, 7) +#define vsetvl_e32m1(avl) __builtin_rvv_vsetvli((size_t)(avl), 2, 0) +#define vsetvl_e32m2(avl) __builtin_rvv_vsetvli((size_t)(avl), 2, 1) +#define vsetvl_e32m4(avl) __builtin_rvv_vsetvli((size_t)(avl), 2, 2) +#define vsetvl_e32m8(avl) __builtin_rvv_vsetvli((size_t)(avl), 2, 3) + +#define vsetvl_e64m1(avl) __builtin_rvv_vsetvli((size_t)(avl), 3, 0) +#define vsetvl_e64m2(avl) __builtin_rvv_vsetvli((size_t)(avl), 3, 1) +#define vsetvl_e64m4(avl) __builtin_rvv_vsetvli((size_t)(avl), 3, 2) +#define vsetvl_e64m8(avl) __builtin_rvv_vsetvli((size_t)(avl), 3, 3) + +}] in + def vsetvli : RVVBuiltin<"", "zzKzKz", "i">; + + let HeaderCode = +[{ +#define vsetvlmax_e8mf8() __builtin_rvv_vsetvlimax(0, 5) +#define vsetvlmax_e8mf4() __builtin_rvv_vsetvlimax(0, 6) +#define vsetvlmax_e8mf2() __builtin_rvv_vsetvlimax(0, 7) +#define vsetvlmax_e8m1() __builtin_rvv_vsetvlimax(0, 0) +#define vsetvlmax_e8m2() __builtin_rvv_vsetvlimax(0, 1) +#define vsetvlmax_e8m4() __builtin_rvv_vsetvlimax(0, 2) +#define vsetvlmax_e8m8() __builtin_rvv_vsetvlimax(0, 3) + +#define vsetvlmax_e16mf4() __builtin_rvv_vsetvlimax(1, 6) +#define vsetvlmax_e16mf2() __builtin_rvv_vsetvlimax(1, 7) +#define vsetvlmax_e16m1() __builtin_rvv_vsetvlimax(1, 0) +#define vsetvlmax_e16m2() __builtin_rvv_vsetvlimax(1, 1) +#define vsetvlmax_e16m4() __builtin_rvv_vsetvlimax(1, 2) +#define vsetvlmax_e16m8() __builtin_rvv_vsetvlimax(1, 3) + +#define vsetvlmax_e32mf2() __builtin_rvv_vsetvlimax(2, 7) +#define vsetvlmax_e32m1() __builtin_rvv_vsetvlimax(2, 0) +#define vsetvlmax_e32m2() __builtin_rvv_vsetvlimax(2, 1) +#define vsetvlmax_e32m4() __builtin_rvv_vsetvlimax(2, 2) +#define vsetvlmax_e32m8() __builtin_rvv_vsetvlimax(2, 3) + +#define vsetvlmax_e64m1() __builtin_rvv_vsetvlimax(3, 0) +#define vsetvlmax_e64m2() __builtin_rvv_vsetvlimax(3, 1) +#define vsetvlmax_e64m4() __builtin_rvv_vsetvlimax(3, 2) +#define vsetvlmax_e64m8() __builtin_rvv_vsetvlimax(3, 3) + +}] in + def vsetvlimax : RVVBuiltin<"", "zKzKz", "i">; +} + +// 7. Vector Loads and Stores +// 7.4. Vector Unit-Stride Instructions +def vle1: RVVVLEMaskBuiltin; +defm vle8: RVVVLEBuiltin<["c"]>; +defm vle16: RVVVLEBuiltin<["s","x"]>; +defm vle32: RVVVLEBuiltin<["i","f"]>; +defm vle64: RVVVLEBuiltin<["l","d"]>; + +def vse1 : RVVVSEMaskBuiltin; +defm vse8 : RVVVSEBuiltin<["c"]>; +defm vse16: RVVVSEBuiltin<["s","x"]>; +defm vse32: RVVVSEBuiltin<["i","f"]>; +defm vse64: RVVVSEBuiltin<["l","d"]>; + +// 7.5. Vector Strided Instructions +defm vlse8: RVVVLSEBuiltin<["c"]>; +defm vlse16: RVVVLSEBuiltin<["s","x"]>; +defm vlse32: RVVVLSEBuiltin<["i","f"]>; +defm vlse64: RVVVLSEBuiltin<["l","d"]>; + +defm vsse8 : RVVVSSEBuiltin<["c"]>; +defm vsse16: RVVVSSEBuiltin<["s","x"]>; +defm vsse32: RVVVSSEBuiltin<["i","f"]>; +defm vsse64: RVVVSSEBuiltin<["l","d"]>; + +// 7.6. Vector Indexed Instructions +defm : RVVIndexedLoad<"vluxei">; +defm : RVVIndexedLoad<"vloxei">; + +defm : RVVIndexedStore<"vsuxei">; +defm : RVVIndexedStore<"vsoxei">; + +// 7.7. Unit-stride Fault-Only-First Loads +defm vle8ff: RVVVLEFFBuiltin<["c"]>; +defm vle16ff: RVVVLEFFBuiltin<["s","x"]>; +defm vle32ff: RVVVLEFFBuiltin<["i", "f"]>; +defm vle64ff: RVVVLEFFBuiltin<["l", "d"]>; + +// 7.8 Vector Load/Store Segment Instructions +let RequiredExtension = "Zvlsseg" in { +defm : RVVUnitStridedSegLoad<"vlseg">; +defm : RVVUnitStridedSegLoadFF<"vlseg">; +defm : RVVStridedSegLoad<"vlsseg">; +defm : RVVIndexedSegLoad<"vluxseg">; +defm : RVVIndexedSegLoad<"vloxseg">; +defm : RVVUnitStridedSegStore<"vsseg">; +defm : RVVStridedSegStore<"vssseg">; +defm : RVVIndexedSegStore<"vsuxseg">; +defm : RVVIndexedSegStore<"vsoxseg">; +} + +// 8. Vector AMO Operations +let RequiredExtension = "Zvamo" in { +defm vamoswap : RVVAMOBuiltinSet< /* hasSigned */ true, /* hasUnsigned */ true, /* hasFP */ true>; +defm vamoadd : RVVAMOBuiltinSet< /* hasSigned */ true, /* hasUnsigned */ true>; +defm vamoxor : RVVAMOBuiltinSet< /* hasSigned */ true, /* hasUnsigned */ true>; +defm vamoand : RVVAMOBuiltinSet< /* hasSigned */ true, /* hasUnsigned */ true>; +defm vamoor : RVVAMOBuiltinSet< /* hasSigned */ true, /* hasUnsigned */ true>; +defm vamomin : RVVAMOBuiltinSet< /* hasSigned */ true>; +defm vamomax : RVVAMOBuiltinSet< /* hasSigned */ true>; +defm vamominu : RVVAMOBuiltinSet< /* hasSigned */ false, /* hasUnsigned */ true>; +defm vamomaxu : RVVAMOBuiltinSet< /* hasSigned */ false, /* hasUnsigned */ true>; +} + +// 12. Vector Integer Arithmetic Instructions +// 12.1. Vector Single-Width Integer Add and Subtract +defm vadd : RVVIntBinBuiltinSet; +defm vsub : RVVIntBinBuiltinSet; +defm vrsub : RVVOutOp1BuiltinSet<"vrsub", "csil", + [["vx", "v", "vve"], + ["vx", "Uv", "UvUvUe"]]>; +defm vneg_v : RVVPseudoUnaryBuiltin<"vrsub", "csil">; + +// 12.2. Vector Widening Integer Add/Subtract +// Widening unsigned integer add/subtract, 2*SEW = SEW +/- SEW +defm vwaddu : RVVUnsignedWidenBinBuiltinSet; +defm vwsubu : RVVUnsignedWidenBinBuiltinSet; +// Widening signed integer add/subtract, 2*SEW = SEW +/- SEW +defm vwadd : RVVSignedWidenBinBuiltinSet; +defm vwsub : RVVSignedWidenBinBuiltinSet; +// Widening unsigned integer add/subtract, 2*SEW = 2*SEW +/- SEW +defm vwaddu : RVVUnsignedWidenOp0BinBuiltinSet; +defm vwsubu : RVVUnsignedWidenOp0BinBuiltinSet; +// Widening signed integer add/subtract, 2*SEW = 2*SEW +/- SEW +defm vwadd : RVVSignedWidenOp0BinBuiltinSet; +defm vwsub : RVVSignedWidenOp0BinBuiltinSet; +defm vwcvtu_x_x_v : RVVPseudoVWCVTBuiltin<"vwaddu", "vwcvtu_x", "csi", + [["Uw", "UwUv"]]>; +defm vwcvt_x_x_v : RVVPseudoVWCVTBuiltin<"vwadd", "vwcvt_x", "csi", + [["w", "wv"]]>; + +// 12.3. Vector Integer Extension +let Log2LMUL = [-3, -2, -1, 0, 1, 2] in { + def vsext_vf2 : RVVIntExt<"vsext", "w", "wv", "csi">; + def vzext_vf2 : RVVIntExt<"vzext", "Uw", "UwUv", "csi">; +} +let Log2LMUL = [-3, -2, -1, 0, 1] in { + def vsext_vf4 : RVVIntExt<"vsext", "q", "qv", "cs">; + def vzext_vf4 : RVVIntExt<"vzext", "Uq", "UqUv", "cs">; +} +let Log2LMUL = [-3, -2, -1, 0] in { + def vsext_vf8 : RVVIntExt<"vsext", "o", "ov", "c">; + def vzext_vf8 : RVVIntExt<"vzext", "Uo", "UoUv", "c">; +} + +// 12.4. Vector Integer Add-with-Carry / Subtract-with-Borrow Instructions +let HasMask = false in { + defm vadc : RVVCarryinBuiltinSet; + defm vmadc : RVVCarryOutInBuiltinSet<"vmadc_carry_in">; + defm vmadc : RVVIntMaskOutBuiltinSet; + defm vsbc : RVVCarryinBuiltinSet; + defm vmsbc : RVVCarryOutInBuiltinSet<"vmsbc_borrow_in">; + defm vmsbc : RVVIntMaskOutBuiltinSet; +} + +// 12.5. Vector Bitwise Logical Instructions +defm vand : RVVIntBinBuiltinSet; +defm vxor : RVVIntBinBuiltinSet; +defm vor : RVVIntBinBuiltinSet; +defm vnot_v : RVVPseudoVNotBuiltin<"vxor", "csil">; + +// 12.6. Vector Single-Width Bit Shift Instructions +defm vsll : RVVShiftBuiltinSet; +defm vsrl : RVVUnsignedShiftBuiltinSet; +defm vsra : RVVSignedShiftBuiltinSet; + +// 12.7. Vector Narrowing Integer Right Shift Instructions +defm vnsrl : RVVUnsignedNShiftBuiltinSet; +defm vnsra : RVVSignedNShiftBuiltinSet; +defm vncvt_x_x_w : RVVPseudoVNCVTBuiltin<"vnsrl", "vncvt_x", "csi", + [["v", "vw"], + ["Uv", "UvUw"]]>; + +// 12.8. Vector Integer Comparison Instructions +defm vmseq : RVVIntMaskOutBuiltinSet; +defm vmsne : RVVIntMaskOutBuiltinSet; +defm vmsltu : RVVUnsignedMaskOutBuiltinSet; +defm vmslt : RVVSignedMaskOutBuiltinSet; +defm vmsleu : RVVUnsignedMaskOutBuiltinSet; +defm vmsle : RVVSignedMaskOutBuiltinSet; +defm vmsgtu : RVVUnsignedMaskOutBuiltinSet; +defm vmsgt : RVVSignedMaskOutBuiltinSet; +defm vmsgeu : RVVUnsignedMaskOutBuiltinSet; +defm vmsge : RVVSignedMaskOutBuiltinSet; + +// 12.9. Vector Integer Min/Max Instructions +defm vminu : RVVUnsignedBinBuiltinSet; +defm vmin : RVVSignedBinBuiltinSet; +defm vmaxu : RVVUnsignedBinBuiltinSet; +defm vmax : RVVSignedBinBuiltinSet; + +// 12.10. Vector Single-Width Integer Multiply Instructions +defm vmul : RVVIntBinBuiltinSet; +defm vmulh : RVVSignedBinBuiltinSet; +defm vmulhu : RVVUnsignedBinBuiltinSet; +defm vmulhsu : RVVOutOp1BuiltinSet<"vmulhsu", "csil", + [["vv", "v", "vvUv"], + ["vx", "v", "vvUe"]]>; + +// 12.11. Vector Integer Divide Instructions +defm vdivu : RVVUnsignedBinBuiltinSet; +defm vdiv : RVVSignedBinBuiltinSet; +defm vremu : RVVUnsignedBinBuiltinSet; +defm vrem : RVVSignedBinBuiltinSet; + +// 12.12. Vector Widening Integer Multiply Instructions +let Log2LMUL = [-3, -2, -1, 0, 1, 2] in { +defm vwmul : RVVOutOp0Op1BuiltinSet<"vwmul", "csi", + [["vv", "w", "wvv"], + ["vx", "w", "wve"]]>; +defm vwmulu : RVVOutOp0Op1BuiltinSet<"vwmulu", "csi", + [["vv", "Uw", "UwUvUv"], + ["vx", "Uw", "UwUvUe"]]>; +defm vwmulsu : RVVOutOp0Op1BuiltinSet<"vwmulsu", "csi", + [["vv", "w", "wvUv"], + ["vx", "w", "wvUe"]]>; +} + +// 12.13. Vector Single-Width Integer Multiply-Add Instructions +defm vmacc : RVVIntTerBuiltinSet; +defm vnmsac : RVVIntTerBuiltinSet; +defm vmadd : RVVIntTerBuiltinSet; +defm vnmsub : RVVIntTerBuiltinSet; + +// 12.14. Vector Widening Integer Multiply-Add Instructions +let HasMaskedOffOperand = false, + Log2LMUL = [-3, -2, -1, 0, 1, 2] in { +defm vwmaccu : RVVOutOp1Op2BuiltinSet<"vwmaccu", "csi", + [["vv", "Uw", "UwUwUvUv"], + ["vx", "Uw", "UwUwUeUv"]]>; +defm vwmacc : RVVOutOp1Op2BuiltinSet<"vwmacc", "csi", + [["vv", "w", "wwvv"], + ["vx", "w", "wwev"]]>; +defm vwmaccsu : RVVOutOp1Op2BuiltinSet<"vwmaccsu", "csi", + [["vv", "w", "wwvUv"], + ["vx", "w", "wweUv"]]>; +defm vwmaccus : RVVOutOp1Op2BuiltinSet<"vwmaccus", "csi", + [["vx", "w", "wwUev"]]>; +} + +// 12.15. Vector Integer Merge Instructions +// C/C++ Operand: (mask, op1, op2, vl), Intrinsic: (op1, op2, mask, vl) +let HasMask = false, + ManualCodegen = [{ + std::rotate(Ops.begin(), Ops.begin() + 1, Ops.begin() + 3); + IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[3]->getType()}; + }] in { + defm vmerge : RVVOutOp1BuiltinSet<"vmerge", "csil", + [["vvm", "v", "vmvv"], + ["vxm", "v", "vmve"], + ["vvm", "Uv", "UvmUvUv"], + ["vxm", "Uv", "UvmUvUe"]]>; +} + +// 12.16. Vector Integer Move Instructions +let HasMask = false in { + let MangledName = "vmv_v" in { + defm vmv_v : RVVOutBuiltinSet<"vmv_v_v", "csil", + [["v", "Uv", "UvUv"]]>; + defm vmv_v : RVVOutBuiltinSet<"vmv_v_v", "csilxfd", + [["v", "v", "vv"]]>; + } + let HasNoMaskedOverloaded = false in + defm vmv_v : RVVOutBuiltinSet<"vmv_v_x", "csil", + [["x", "v", "ve"], + ["x", "Uv", "UvUe"]]>; +} + +// 13. Vector Fixed-Point Arithmetic Instructions +// 13.1. Vector Single-Width Saturating Add and Subtract +defm vsaddu : RVVUnsignedBinBuiltinSet; +defm vsadd : RVVSignedBinBuiltinSet; +defm vssubu : RVVUnsignedBinBuiltinSet; +defm vssub : RVVSignedBinBuiltinSet; + +// 13.2. Vector Single-Width Averaging Add and Subtract +defm vaaddu : RVVUnsignedBinBuiltinSet; +defm vaadd : RVVSignedBinBuiltinSet; +defm vasubu : RVVUnsignedBinBuiltinSet; +defm vasub : RVVSignedBinBuiltinSet; + +// 13.3. Vector Single-Width Fractional Multiply with Rounding and Saturation +defm vsmul : RVVSignedBinBuiltinSet; + +// 13.4. Vector Single-Width Scaling Shift Instructions +defm vssrl : RVVUnsignedShiftBuiltinSet; +defm vssra : RVVSignedShiftBuiltinSet; + +// 13.5. Vector Narrowing Fixed-Point Clip Instructions +defm vnclipu : RVVUnsignedNShiftBuiltinSet; +defm vnclip : RVVSignedNShiftBuiltinSet; + +// 14. Vector Floating-Point Instructions +// 14.2. Vector Single-Width Floating-Point Add/Subtract Instructions +defm vfadd : RVVFloatingBinBuiltinSet; +defm vfsub : RVVFloatingBinBuiltinSet; +defm vfrsub : RVVFloatingBinVFBuiltinSet; + +// 14.3. Vector Widening Floating-Point Add/Subtract Instructions +// Widening FP add/subtract, 2*SEW = SEW +/- SEW +defm vfwadd : RVVFloatingWidenBinBuiltinSet; +defm vfwsub : RVVFloatingWidenBinBuiltinSet; +// Widening FP add/subtract, 2*SEW = 2*SEW +/- SEW +defm vfwadd : RVVFloatingWidenOp0BinBuiltinSet; +defm vfwsub : RVVFloatingWidenOp0BinBuiltinSet; + +// 14.4. Vector Single-Width Floating-Point Multiply/Divide Instructions +defm vfmul : RVVFloatingBinBuiltinSet; +defm vfdiv : RVVFloatingBinBuiltinSet; +defm vfrdiv : RVVFloatingBinVFBuiltinSet; + +// 14.5. Vector Widening Floating-Point Multiply +let Log2LMUL = [-2, -1, 0, 1, 2] in { + defm vfwmul : RVVOutOp0Op1BuiltinSet<"vfwmul", "xf", + [["vv", "w", "wvv"], + ["vf", "w", "wve"]]>; +} + +// 14.6. Vector Single-Width Floating-Point Fused Multiply-Add Instructions +defm vfmacc : RVVFloatingTerBuiltinSet; +defm vfnmacc : RVVFloatingTerBuiltinSet; +defm vfmsac : RVVFloatingTerBuiltinSet; +defm vfnmsac : RVVFloatingTerBuiltinSet; +defm vfmadd : RVVFloatingTerBuiltinSet; +defm vfnmadd : RVVFloatingTerBuiltinSet; +defm vfmsub : RVVFloatingTerBuiltinSet; +defm vfnmsub : RVVFloatingTerBuiltinSet; + +// 14.7. Vector Widening Floating-Point Fused Multiply-Add Instructions +defm vfwmacc : RVVFloatingWidenTerBuiltinSet; +defm vfwnmacc : RVVFloatingWidenTerBuiltinSet; +defm vfwmsac : RVVFloatingWidenTerBuiltinSet; +defm vfwnmsac : RVVFloatingWidenTerBuiltinSet; + +// 14.8. Vector Floating-Point Square-Root Instruction +def vfsqrt : RVVFloatingUnaryVVBuiltin; + +// 14.9. Vector Floating-Point Reciprocal Square-Root Estimate Instruction +def vfrsqrt7 : RVVFloatingUnaryVVBuiltin; + +// 14.10. Vector Floating-Point Reciprocal Estimate Instruction +def vfrec7 : RVVFloatingUnaryVVBuiltin; + +// 14.11. Vector Floating-Point MIN/MAX Instructions +defm vfmin : RVVFloatingBinBuiltinSet; +defm vfmax : RVVFloatingBinBuiltinSet; + +// 14.12. Vector Floating-Point Sign-Injection Instructions +defm vfsgnj : RVVFloatingBinBuiltinSet; +defm vfsgnjn : RVVFloatingBinBuiltinSet; +defm vfsgnjx : RVVFloatingBinBuiltinSet; +defm vfneg_v : RVVPseudoVFUnaryBuiltin<"vfsgnjn", "xfd">; +defm vfabs_v : RVVPseudoVFUnaryBuiltin<"vfsgnjx", "xfd">; + +// 14.13. Vector Floating-Point Compare Instructions +defm vmfeq : RVVFloatingMaskOutBuiltinSet; +defm vmfne : RVVFloatingMaskOutBuiltinSet; +defm vmflt : RVVFloatingMaskOutBuiltinSet; +defm vmfle : RVVFloatingMaskOutBuiltinSet; +defm vmfgt : RVVFloatingMaskOutBuiltinSet; +defm vmfge : RVVFloatingMaskOutBuiltinSet; + +// 14.14. Vector Floating-Point Classify Instruction +let Name = "vfclass_v" in + def vfclass : RVVOp0Builtin<"Uv", "Uvv", "xfd">; + +// 14.15. Vector Floating-Point Merge Instructio +// C/C++ Operand: (mask, op1, op2, vl), Builtin: (op1, op2, mask, vl) +let HasMask = false, + ManualCodegen = [{ + std::rotate(Ops.begin(), Ops.begin() + 1, Ops.begin() + 3); + IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[3]->getType()}; + }] in { + defm vmerge : RVVOutOp1BuiltinSet<"vfmerge", "xfd", + [["vvm", "v", "vmvv"]]>; + defm vfmerge : RVVOutOp1BuiltinSet<"vfmerge", "xfd", + [["vfm", "v", "vmve"]]>; +} + +// 14.16. Vector Floating-Point Move Instruction +let HasMask = false, HasNoMaskedOverloaded = false in + defm vfmv_v : RVVOutBuiltinSet<"vfmv_v_f", "xfd", + [["f", "v", "ve"]]>; + +// 14.17. Single-Width Floating-Point/Integer Type-Convert Instructions +def vfcvt_xu_f_v : RVVConvToUnsignedBuiltin<"vfcvt_xu">; +def vfcvt_x_f_v : RVVConvToSignedBuiltin<"vfcvt_x">; +def vfcvt_rtz_xu_f_v : RVVConvToUnsignedBuiltin<"vfcvt_rtz_xu">; +def vfcvt_rtz_x_f_v : RVVConvToSignedBuiltin<"vfcvt_rtz_x">; +def vfcvt_f_xu_v : RVVConvBuiltin<"Fv", "FvUv", "sil", "vfcvt_f">; +def vfcvt_f_x_v : RVVConvBuiltin<"Fv", "Fvv", "sil", "vfcvt_f">; + +// 14.18. Widening Floating-Point/Integer Type-Convert Instructions +let Log2LMUL = [-3, -2, -1, 0, 1, 2] in { + def vfwcvt_xu_f_v : RVVConvToWidenUnsignedBuiltin<"vfwcvt_xu">; + def vfwcvt_x_f_v : RVVConvToWidenSignedBuiltin<"vfwcvt_x">; + def vfwcvt_rtz_xu_f_v : RVVConvToWidenUnsignedBuiltin<"vfwcvt_rtz_xu">; + def vfwcvt_rtz_x_f_v : RVVConvToWidenSignedBuiltin<"vfwcvt_rtz_x">; + def vfwcvt_f_xu_v : RVVConvBuiltin<"Fw", "FwUv", "csi", "vfwcvt_f">; + def vfwcvt_f_x_v : RVVConvBuiltin<"Fw", "Fwv", "csi", "vfwcvt_f">; + def vfwcvt_f_f_v : RVVConvBuiltin<"w", "wv", "xf", "vfwcvt_f">; +} + +// 14.19. Narrowing Floating-Point/Integer Type-Convert Instructions +let Log2LMUL = [-3, -2, -1, 0, 1, 2] in { + def vfncvt_xu_f_w : RVVConvToNarrowingUnsignedBuiltin<"vfncvt_xu">; + def vfncvt_x_f_w : RVVConvToNarrowingSignedBuiltin<"vfncvt_x">; + def vfncvt_rtz_xu_f_w : RVVConvToNarrowingUnsignedBuiltin<"vfncvt_rtz_xu">; + def vfncvt_rtz_x_f_w : RVVConvToNarrowingSignedBuiltin<"vfncvt_rtz_x">; + def vfncvt_f_xu_w : RVVConvBuiltin<"Fv", "FvUw", "csi", "vfncvt_f">; + def vfncvt_f_x_w : RVVConvBuiltin<"Fv", "Fvw", "csi", "vfncvt_f">; + def vfncvt_f_f_w : RVVConvBuiltin<"v", "vw", "xf", "vfncvt_f">; + def vfncvt_rod_f_f_w : RVVConvBuiltin<"v", "vw", "xf", "vfncvt_rod_f">; +} + +// 15. Vector Reduction Operations +// 15.1. Vector Single-Width Integer Reduction Instructions +defm vredsum : RVVIntReductionBuiltinSet; +defm vredmaxu : RVVUnsignedReductionBuiltin; +defm vredmax : RVVSignedReductionBuiltin; +defm vredminu : RVVUnsignedReductionBuiltin; +defm vredmin : RVVSignedReductionBuiltin; +defm vredand : RVVIntReductionBuiltinSet; +defm vredor : RVVIntReductionBuiltinSet; +defm vredxor : RVVIntReductionBuiltinSet; + +// 15.2. Vector Widening Integer Reduction Instructions +// Vector Widening Integer Reduction Operations +let HasMaskedOffOperand = false in { + defm vwredsum : RVVOutOp1BuiltinSet<"vwredsum", "csi", + [["vs", "vSw", "SwSwvSw"]]>; + defm vwredsumu : RVVOutOp1BuiltinSet<"vwredsumu", "csi", + [["vs", "UvUSw", "USwUSwUvUSw"]]>; +} + +// 15.3. Vector Single-Width Floating-Point Reduction Instructions +defm vfredmax : RVVFloatingReductionBuiltin; +defm vfredmin : RVVFloatingReductionBuiltin; +defm vfredsum : RVVFloatingReductionBuiltin; +defm vfredosum : RVVFloatingReductionBuiltin; + +// 15.4. Vector Widening Floating-Point Reduction Instructions +defm vfwredsum : RVVFloatingWidenReductionBuiltin; +defm vfwredosum : RVVFloatingWidenReductionBuiltin; + +// 16. Vector Mask Instructions +// 16.1. Vector Mask-Register Logical Instructions +def vmand : RVVMaskBinBuiltin; +def vmnand : RVVMaskBinBuiltin; +def vmandnot : RVVMaskBinBuiltin; +def vmxor : RVVMaskBinBuiltin; +def vmor : RVVMaskBinBuiltin; +def vmnor : RVVMaskBinBuiltin; +def vmornot : RVVMaskBinBuiltin; +def vmxnor : RVVMaskBinBuiltin; +// pseudoinstructions +def vmclr : RVVMaskNullaryBuiltin; +def vmset : RVVMaskNullaryBuiltin; +defm vmmv_m : RVVPseudoMaskBuiltin<"vmand", "c">; +defm vmnot_m : RVVPseudoMaskBuiltin<"vmnand", "c">; + +// 16.2. Vector mask population count vpopc +def vpopc : RVVMaskOp0Builtin<"um">; + +// 16.3. vfirst find-first-set mask bit +def vfirst : RVVMaskOp0Builtin<"lm">; + +// 16.4. vmsbf.m set-before-first mask bit +def vmsbf : RVVMaskUnaryBuiltin; + +// 16.5. vmsif.m set-including-first mask bit +def vmsif : RVVMaskUnaryBuiltin; + +// 16.6. vmsof.m set-only-first mask bit +def vmsof : RVVMaskUnaryBuiltin; + +let HasNoMaskedOverloaded = false in { + // 16.8. Vector Iota Instruction + defm viota : RVVOutBuiltinSet<"viota", "csil", [["m", "Uv", "Uvm"]]>; + + // 16.9. Vector Element Index Instruction + defm vid : RVVOutBuiltinSet<"vid", "csil", [["v", "v", "v"], + ["v", "Uv", "Uv"]]>; +} + +// 17. Vector Permutation Instructions +// 17.1. Integer Scalar Move Instructions +let HasMask = false in { + let HasVL = false, MangledName = "vmv_x" in + defm vmv_x : RVVOp0BuiltinSet<"vmv_x_s", "csil", + [["s", "ve", "ev"], + ["s", "UvUe", "UeUv"]]>; + let MangledName = "vmv_s" in + defm vmv_s : RVVOutBuiltinSet<"vmv_s_x", "csil", + [["x", "v", "vve"], + ["x", "Uv", "UvUvUe"]]>; +} + +// 17.2. Floating-Point Scalar Move Instructions +let HasMask = false in { + let HasVL = false, MangledName = "vfmv_f" in + defm vfmv_f : RVVOp0BuiltinSet<"vfmv_f_s", "xfd", + [["s", "ve", "ev"]]>; + let MangledName = "vfmv_s" in + defm vfmv_s : RVVOutBuiltinSet<"vfmv_s_f", "xfd", + [["f", "v", "vve"], + ["x", "Uv", "UvUvUe"]]>; +} + +// 17.3. Vector Slide Instructions +// 17.3.1. Vector Slideup Instructions +defm vslideup : RVVSlideBuiltinSet; +// 17.3.2. Vector Slidedown Instructions +defm vslidedown : RVVSlideBuiltinSet; + +// 17.3.3. Vector Slide1up Instructions +defm vslide1up : RVVSlideOneBuiltinSet; +defm vfslide1up : RVVFloatingBinVFBuiltinSet; + +// 17.3.4. Vector Slide1down Instruction +defm vslide1down : RVVSlideOneBuiltinSet; +defm vfslide1down : RVVFloatingBinVFBuiltinSet; + +// 17.4. Vector Register Gather Instructions +// signed and floating type +defm vrgather : RVVOutBuiltinSet<"vrgather_vv", "csilxfd", + [["vv", "v", "vvUv"]]>; +defm vrgather : RVVOutBuiltinSet<"vrgather_vx", "csilxfd", + [["vx", "v", "vvz"]]>; +defm vrgatherei16 : RVVOutBuiltinSet<"vrgatherei16_vv", "csilxfd", + [["vv", "v", "vv(Log2EEW:4)Uv"]]>; +// unsigned type +defm vrgather : RVVOutBuiltinSet<"vrgather_vv", "csil", + [["vv", "Uv", "UvUvUv"]]>; +defm vrgather : RVVOutBuiltinSet<"vrgather_vx", "csil", + [["vx", "Uv", "UvUvz"]]>; +defm vrgatherei16 : RVVOutBuiltinSet<"vrgatherei16_vv", "csil", + [["vv", "Uv", "UvUv(Log2EEW:4)Uv"]]>; + +// 17.5. Vector Compress Instruction +let HasMask = false, + ManualCodegen = [{ + std::rotate(Ops.begin(), Ops.begin() + 1, Ops.begin() + 3); + IntrinsicTypes = {ResultType, Ops[3]->getType()}; + }] in { + // signed and floating type + defm vcompress : RVVOutBuiltinSet<"vcompress", "csilxfd", + [["vm", "v", "vmvv"]]>; + // unsigned type + defm vcompress : RVVOutBuiltinSet<"vcompress", "csil", + [["vm", "Uv", "UvmUvUv"]]>; +} + +// Miscellaneous +let HasMask = false, HasVL = false, IRName = "" in { + let Name = "vreinterpret_v", + ManualCodegen = [{ + return Builder.CreateBitCast(Ops[0], ResultType); + }] in { + // Reinterpret between different type under the same SEW and LMUL + def vreinterpret_i_u : RVVBuiltin<"Uvv", "vUv", "csil", "v">; + def vreinterpret_i_f : RVVBuiltin<"Fvv", "vFv", "sil", "v">; + def vreinterpret_u_i : RVVBuiltin<"vUv", "Uvv", "csil", "Uv">; + def vreinterpret_u_f : RVVBuiltin<"FvUv", "UvFv", "sil", "Uv">; + def vreinterpret_f_i : RVVBuiltin<"vFv", "Fvv", "sil", "Fv">; + def vreinterpret_f_u : RVVBuiltin<"UvFv", "FvUv", "sil", "Fv">; + + // Reinterpret between different SEW under the same LMUL + foreach dst_sew = ["(FixedSEW:8)", "(FixedSEW:16)", "(FixedSEW:32)", + "(FixedSEW:64)"] in { + def vreinterpret_i_ # dst_sew : RVVBuiltin<"v" # dst_sew # "v", + dst_sew # "vv", "csil", dst_sew # "v">; + def vreinterpret_u_ # dst_sew : RVVBuiltin<"Uv" # dst_sew # "Uv", + dst_sew # "UvUv", "csil", dst_sew # "Uv">; + } + } + + let Name = "vundefined", HasNoMaskedOverloaded = false, + ManualCodegen = [{ + return llvm::UndefValue::get(ResultType); + }] in { + def vundefined : RVVBuiltin<"v", "v", "csilxfd">; + def vundefined_u : RVVBuiltin<"Uv", "Uv", "csil">; + } + + // LMUL truncation + // C/C++ Operand: VecTy, IR Operand: VecTy, Index + let Name = "vlmul_trunc_v", MangledName = "vlmul_trunc", + ManualCodegen = [{ { + ID = Intrinsic::experimental_vector_extract; + IntrinsicTypes = {ResultType, Ops[0]->getType()}; + Ops.push_back(ConstantInt::get(Int64Ty, 0)); + return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Ops, ""); + } }] in { + foreach dst_lmul = ["(SFixedLog2LMUL:-3)", "(SFixedLog2LMUL:-2)", "(SFixedLog2LMUL:-1)", + "(SFixedLog2LMUL:0)", "(SFixedLog2LMUL:1)", "(SFixedLog2LMUL:2)"] in { + def vlmul_trunc # dst_lmul : RVVBuiltin<"v" # dst_lmul # "v", + dst_lmul # "vv", "csilxfd", dst_lmul # "v">; + def vlmul_trunc_u # dst_lmul : RVVBuiltin<"Uv" # dst_lmul # "Uv", + dst_lmul # "UvUv", "csil", dst_lmul # "Uv">; + } + } + + // LMUL extension + // C/C++ Operand: SubVecTy, IR Operand: VecTy, SubVecTy, Index + let Name = "vlmul_ext_v", MangledName = "vlmul_ext", + ManualCodegen = [{ + ID = Intrinsic::experimental_vector_insert; + IntrinsicTypes = {ResultType, Ops[0]->getType()}; + Ops.push_back(llvm::UndefValue::get(ResultType)); + std::swap(Ops[0], Ops[1]); + Ops.push_back(ConstantInt::get(Int64Ty, 0)); + return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Ops, ""); + }] in { + foreach dst_lmul = ["(LFixedLog2LMUL:-2)", "(LFixedLog2LMUL:-1)", "(LFixedLog2LMUL:-0)", + "(LFixedLog2LMUL:1)", "(LFixedLog2LMUL:2)", "(LFixedLog2LMUL:3)"] in { + def vlmul_ext # dst_lmul : RVVBuiltin<"v" # dst_lmul # "v", + dst_lmul # "vv", "csilxfd", dst_lmul # "v">; + def vlmul_ext_u # dst_lmul : RVVBuiltin<"Uv" # dst_lmul # "Uv", + dst_lmul # "UvUv", "csil", dst_lmul # "Uv">; + } + } + + let Name = "vget_v", + ManualCodegen = [{ + { + ID = Intrinsic::experimental_vector_extract; + ScalableVectorType *VecTy = cast<ScalableVectorType>(ResultType); + Ops[1] = Builder.CreateMul(Ops[1], + ConstantInt::get(Ops[1]->getType(), + VecTy->getMinNumElements())); + IntrinsicTypes = {ResultType, Ops[0]->getType()}; + return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Ops, ""); + } + }] in { + foreach dst_lmul = ["(SFixedLog2LMUL:0)", "(SFixedLog2LMUL:1)", "(SFixedLog2LMUL:2)"] in { + def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "vvKz", "csilfd", dst_lmul # "v">; + def : RVVBuiltin<"Uv" # dst_lmul # "Uv", dst_lmul # "UvUvKz", "csil", dst_lmul # "Uv">; + } + } + + let Name = "vset_v", Log2LMUL = [0, 1, 2], + ManualCodegen = [{ + { + ID = Intrinsic::experimental_vector_insert; + IntrinsicTypes = {ResultType, Ops[2]->getType()}; + ScalableVectorType *VecTy = cast<ScalableVectorType>(Ops[2]->getType()); + Ops[1] = Builder.CreateMul(Ops[1], + ConstantInt::get(Ops[1]->getType(), + VecTy->getMinNumElements())); + std::swap(Ops[1], Ops[2]); + return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Ops, ""); + } + }] in { + foreach dst_lmul = ["(LFixedLog2LMUL:1)", "(LFixedLog2LMUL:2)", "(LFixedLog2LMUL:3)"] in { + def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "v" # dst_lmul # "vKzv", "csilfd">; + def : RVVBuiltin<"Uv" # dst_lmul # "Uv", dst_lmul # "Uv" # dst_lmul #"UvKzUv", "csil">; + } + } +} diff --git a/clang/include/clang/CodeGen/BackendUtil.h b/clang/include/clang/CodeGen/BackendUtil.h index 43de07cc145b..77d500079f01 100644 --- a/clang/include/clang/CodeGen/BackendUtil.h +++ b/clang/include/clang/CodeGen/BackendUtil.h @@ -39,8 +39,7 @@ namespace clang { void EmitBackendOutput(DiagnosticsEngine &Diags, const HeaderSearchOptions &, const CodeGenOptions &CGOpts, const TargetOptions &TOpts, const LangOptions &LOpts, - const llvm::DataLayout &TDesc, llvm::Module *M, - BackendAction Action, + StringRef TDesc, llvm::Module *M, BackendAction Action, std::unique_ptr<raw_pwrite_stream> OS); void EmbedBitcode(llvm::Module *M, const CodeGenOptions &CGOpts, diff --git a/clang/include/clang/CodeGen/CGFunctionInfo.h b/clang/include/clang/CodeGen/CGFunctionInfo.h index 253ef946ce15..4899c9deda6a 100644 --- a/clang/include/clang/CodeGen/CGFunctionInfo.h +++ b/clang/include/clang/CodeGen/CGFunctionInfo.h @@ -93,13 +93,20 @@ private: llvm::Type *PaddingType; // canHavePaddingType() llvm::Type *UnpaddedCoerceAndExpandType; // isCoerceAndExpand() }; + struct DirectAttrInfo { + unsigned Offset; + unsigned Align; + }; + struct IndirectAttrInfo { + unsigned Align; + unsigned AddrSpace; + }; union { - unsigned DirectOffset; // isDirect() || isExtend() - unsigned IndirectAlign; // isIndirect() + DirectAttrInfo DirectAttr; // isDirect() || isExtend() + IndirectAttrInfo IndirectAttr; // isIndirect() unsigned AllocaFieldIndex; // isInAlloca() }; Kind TheKind; - unsigned IndirectAddrSpace : 24; // isIndirect() bool PaddingInReg : 1; bool InAllocaSRet : 1; // isInAlloca() bool InAllocaIndirect : 1;// isInAlloca() @@ -126,19 +133,20 @@ private: public: ABIArgInfo(Kind K = Direct) - : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0), TheKind(K), - IndirectAddrSpace(0), PaddingInReg(false), InAllocaSRet(false), + : TypeData(nullptr), PaddingType(nullptr), DirectAttr{0, 0}, TheKind(K), + PaddingInReg(false), InAllocaSRet(false), InAllocaIndirect(false), IndirectByVal(false), IndirectRealign(false), SRetAfterThis(false), InReg(false), CanBeFlattened(false), SignExt(false) {} static ABIArgInfo getDirect(llvm::Type *T = nullptr, unsigned Offset = 0, llvm::Type *Padding = nullptr, - bool CanBeFlattened = true) { + bool CanBeFlattened = true, unsigned Align = 0) { auto AI = ABIArgInfo(Direct); AI.setCoerceToType(T); AI.setPaddingType(Padding); AI.setDirectOffset(Offset); + AI.setDirectAlign(Align); AI.setCanBeFlattened(CanBeFlattened); return AI; } @@ -154,6 +162,7 @@ public: AI.setCoerceToType(T); AI.setPaddingType(nullptr); AI.setDirectOffset(0); + AI.setDirectAlign(0); AI.setSignExt(true); return AI; } @@ -164,6 +173,7 @@ public: AI.setCoerceToType(T); AI.setPaddingType(nullptr); AI.setDirectOffset(0); + AI.setDirectAlign(0); AI.setSignExt(false); return AI; } @@ -299,11 +309,20 @@ public: // Direct/Extend accessors unsigned getDirectOffset() const { assert((isDirect() || isExtend()) && "Not a direct or extend kind"); - return DirectOffset; + return DirectAttr.Offset; } void setDirectOffset(unsigned Offset) { assert((isDirect() || isExtend()) && "Not a direct or extend kind"); - DirectOffset = Offset; + DirectAttr.Offset = Offset; + } + + unsigned getDirectAlign() const { + assert((isDirect() || isExtend()) && "Not a direct or extend kind"); + return DirectAttr.Align; + } + void setDirectAlign(unsigned Align) { + assert((isDirect() || isExtend()) && "Not a direct or extend kind"); + DirectAttr.Align = Align; } bool isSignExt() const { @@ -369,11 +388,11 @@ public: // Indirect accessors CharUnits getIndirectAlign() const { assert((isIndirect() || isIndirectAliased()) && "Invalid kind!"); - return CharUnits::fromQuantity(IndirectAlign); + return CharUnits::fromQuantity(IndirectAttr.Align); } void setIndirectAlign(CharUnits IA) { assert((isIndirect() || isIndirectAliased()) && "Invalid kind!"); - IndirectAlign = IA.getQuantity(); + IndirectAttr.Align = IA.getQuantity(); } bool getIndirectByVal() const { @@ -387,12 +406,12 @@ public: unsigned getIndirectAddrSpace() const { assert(isIndirectAliased() && "Invalid kind!"); - return IndirectAddrSpace; + return IndirectAttr.AddrSpace; } void setIndirectAddrSpace(unsigned AddrSpace) { assert(isIndirectAliased() && "Invalid kind!"); - IndirectAddrSpace = AddrSpace; + IndirectAttr.AddrSpace = AddrSpace; } bool getIndirectRealign() const { diff --git a/clang/include/clang/CodeGen/CodeGenAction.h b/clang/include/clang/CodeGen/CodeGenAction.h index 1db904ea974c..b5721344046d 100644 --- a/clang/include/clang/CodeGen/CodeGenAction.h +++ b/clang/include/clang/CodeGen/CodeGenAction.h @@ -19,6 +19,7 @@ namespace llvm { namespace clang { class BackendConsumer; +class CodeGenerator; class CodeGenAction : public ASTFrontendAction { private: @@ -77,6 +78,8 @@ public: /// Take the LLVM context used by this action. llvm::LLVMContext *takeLLVMContext(); + CodeGenerator *getCodeGenerator() const; + BackendConsumer *BEConsumer; }; diff --git a/clang/include/clang/CodeGen/SwiftCallingConv.h b/clang/include/clang/CodeGen/SwiftCallingConv.h index 2c5e9a6de7e2..b1a638a58a09 100644 --- a/clang/include/clang/CodeGen/SwiftCallingConv.h +++ b/clang/include/clang/CodeGen/SwiftCallingConv.h @@ -6,7 +6,8 @@ // //===----------------------------------------------------------------------===// // -// Defines constants and types related to Swift ABI lowering. +// Defines constants and types related to Swift ABI lowering. The same ABI +// lowering applies to both sync and async functions. // //===----------------------------------------------------------------------===// diff --git a/clang/include/clang/CrossTU/CrossTranslationUnit.h b/clang/include/clang/CrossTU/CrossTranslationUnit.h index 027c6f16430b..d9f9c51fccd9 100644 --- a/clang/include/clang/CrossTU/CrossTranslationUnit.h +++ b/clang/include/clang/CrossTU/CrossTranslationUnit.h @@ -15,6 +15,7 @@ #define LLVM_CLANG_CROSSTU_CROSSTRANSLATIONUNIT_H #include "clang/AST/ASTImporterSharedState.h" +#include "clang/Analysis/MacroExpansionContext.h" #include "clang/Basic/LLVM.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" @@ -37,6 +38,7 @@ class TranslationUnitDecl; namespace cross_tu { enum class index_error_code { + success = 0, unspecified = 1, missing_index_file, invalid_index_format, @@ -182,21 +184,18 @@ public: /// Emit diagnostics for the user for potential configuration errors. void emitCrossTUDiagnostics(const IndexError &IE); - /// Determine the original source location in the original TU for an - /// imported source location. + /// Returns the MacroExpansionContext for the imported TU to which the given + /// source-location corresponds. /// \p ToLoc Source location in the imported-to AST. - /// \return Source location in the imported-from AST and the corresponding - /// ASTUnit object (the AST was loaded from a file using an internal ASTUnit - /// object that is returned here). - /// If any error happens (ToLoc is a non-imported source location) empty is - /// returned. - llvm::Optional<std::pair<SourceLocation /*FromLoc*/, ASTUnit *>> - getImportedFromSourceLocation(const clang::SourceLocation &ToLoc) const; + /// \note If any error happens such as \p ToLoc is a non-imported + /// source-location, empty is returned. + /// \note Macro expansion tracking for imported TUs is not implemented yet. + /// It returns empty unconditionally. + llvm::Optional<clang::MacroExpansionContext> + getMacroExpansionContextForSourceLocation( + const clang::SourceLocation &ToLoc) const; private: - using ImportedFileIDMap = - llvm::DenseMap<FileID, std::pair<FileID, ASTUnit *>>; - void lazyInitImporterSharedSt(TranslationUnitDecl *ToTU); ASTImporter &getOrCreateASTImporter(ASTUnit *Unit); template <typename T> @@ -217,14 +216,6 @@ private: ASTContext &Context; std::shared_ptr<ASTImporterSharedState> ImporterSharedSt; - /// Map of imported FileID's (in "To" context) to FileID in "From" context - /// and the ASTUnit for the From context. - /// This map is used by getImportedFromSourceLocation to lookup a FileID and - /// its Preprocessor when knowing only the FileID in the 'To' context. The - /// FileID could be imported by any of multiple 'From' ASTImporter objects. - /// we do not want to loop over all ASTImporter's to find the one that - /// imported the FileID. - ImportedFileIDMap ImportedFileIDs; using LoadResultTy = llvm::Expected<std::unique_ptr<ASTUnit>>; @@ -263,6 +254,7 @@ private: /// In case of on-demand parsing, the invocations for parsing the source /// files is stored. llvm::Optional<InvocationListTy> InvocationList; + index_error_code PreviousParsingResult = index_error_code::success; }; /// Maintain number of AST loads and check for reaching the load limit. diff --git a/clang/include/clang/Driver/Action.h b/clang/include/clang/Driver/Action.h index 27c95c6f89d4..ba84d886a6cf 100644 --- a/clang/include/clang/Driver/Action.h +++ b/clang/include/clang/Driver/Action.h @@ -214,14 +214,18 @@ public: class InputAction : public Action { const llvm::opt::Arg &Input; - + std::string Id; virtual void anchor(); public: - InputAction(const llvm::opt::Arg &Input, types::ID Type); + InputAction(const llvm::opt::Arg &Input, types::ID Type, + StringRef Id = StringRef()); const llvm::opt::Arg &getInputArg() const { return Input; } + void setId(StringRef _Id) { Id = _Id.str(); } + StringRef getId() const { return Id; } + static bool classof(const Action *A) { return A->getKind() == InputClass; } diff --git a/clang/include/clang/Driver/ClangOptionDocs.td b/clang/include/clang/Driver/ClangOptionDocs.td index 55136421614d..3f914afea735 100644 --- a/clang/include/clang/Driver/ClangOptionDocs.td +++ b/clang/include/clang/Driver/ClangOptionDocs.td @@ -29,7 +29,7 @@ GCC-compatible ``clang`` and ``clang++`` drivers. string Program = "clang"; list<string> ExcludedFlags = ["HelpHidden", "NoDriverOption", - "CLOption", "Unsupported", "Ignored"]; + "CLOption", "Unsupported", "Ignored", "FlangOnlyOption"]; } include "Options.td" diff --git a/clang/include/clang/Driver/DarwinSDKInfo.h b/clang/include/clang/Driver/DarwinSDKInfo.h deleted file mode 100644 index f7075a8d3b7f..000000000000 --- a/clang/include/clang/Driver/DarwinSDKInfo.h +++ /dev/null @@ -1,41 +0,0 @@ -//===--- DarwinSDKInfo.h - SDK Information parser for darwin ----*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_DRIVER_DARWIN_SDK_INFO_H -#define LLVM_CLANG_DRIVER_DARWIN_SDK_INFO_H - -#include "clang/Basic/LLVM.h" -#include "llvm/Support/Error.h" -#include "llvm/Support/VersionTuple.h" -#include "llvm/Support/VirtualFileSystem.h" - -namespace clang { -namespace driver { - -/// The information about the darwin SDK that was used during this compilation. -class DarwinSDKInfo { -public: - DarwinSDKInfo(llvm::VersionTuple Version) : Version(Version) {} - - const llvm::VersionTuple &getVersion() const { return Version; } - -private: - llvm::VersionTuple Version; -}; - -/// Parse the SDK information from the SDKSettings.json file. -/// -/// \returns an error if the SDKSettings.json file is invalid, None if the -/// SDK has no SDKSettings.json, or a valid \c DarwinSDKInfo otherwise. -Expected<Optional<DarwinSDKInfo>> parseDarwinSDKInfo(llvm::vfs::FileSystem &VFS, - StringRef SDKRootPath); - -} // end namespace driver -} // end namespace clang - -#endif // LLVM_CLANG_DRIVER_DARWIN_SDK_INFO_H diff --git a/clang/include/clang/Driver/Distro.h b/clang/include/clang/Driver/Distro.h index 0e98d00764c1..0d2a0939639e 100644 --- a/clang/include/clang/Driver/Distro.h +++ b/clang/include/clang/Driver/Distro.h @@ -71,6 +71,7 @@ public: UbuntuFocal, UbuntuGroovy, UbuntuHirsute, + UbuntuImpish, UnknownDistro }; @@ -122,7 +123,7 @@ public: } bool IsUbuntu() const { - return DistroVal >= UbuntuHardy && DistroVal <= UbuntuHirsute; + return DistroVal >= UbuntuHardy && DistroVal <= UbuntuImpish; } bool IsAlpineLinux() const { return DistroVal == AlpineLinux; } diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 74a9cf3dab81..da7e8386a151 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -84,6 +84,9 @@ class Driver { /// LTO mode selected via -f(no-)?lto(=.*)? options. LTOKind LTOMode; + /// LTO mode selected via -f(no-offload-)?lto(=.*)? options. + LTOKind OffloadLTOMode; + public: enum OpenMPRuntimeKind { /// An unknown OpenMP runtime. We can't generate effective OpenMP code @@ -156,14 +159,17 @@ public: /// Information about the host which can be overridden by the user. std::string HostBits, HostMachine, HostSystem, HostRelease; + /// The file to log CC_PRINT_PROC_STAT_FILE output to, if enabled. + std::string CCPrintStatReportFilename; + /// The file to log CC_PRINT_OPTIONS output to, if enabled. - const char *CCPrintOptionsFilename; + std::string CCPrintOptionsFilename; /// The file to log CC_PRINT_HEADERS output to, if enabled. - const char *CCPrintHeadersFilename; + std::string CCPrintHeadersFilename; /// The file to log CC_LOG_DIAGNOSTICS output to, if enabled. - const char *CCLogDiagnosticsFilename; + std::string CCLogDiagnosticsFilename; /// A list of inputs and their types for the given arguments. typedef SmallVector<std::pair<types::ID, const llvm::opt::Arg *>, 16> @@ -204,6 +210,10 @@ public: /// Whether the driver is generating diagnostics for debugging purposes. unsigned CCGenDiagnostics : 1; + /// Set CC_PRINT_PROC_STAT mode, which causes the driver to dump + /// performance report to CC_PRINT_PROC_STAT_FILE or to stdout. + unsigned CCPrintProcessStats : 1; + /// Pointer to the ExecuteCC1Tool function, if available. /// When the clangDriver lib is used through clang.exe, this provides a /// shortcut for executing the -cc1 command-line directly, in the same @@ -370,12 +380,6 @@ public: /// to determine if an error occurred. Compilation *BuildCompilation(ArrayRef<const char *> Args); - /// @name Driver Steps - /// @{ - - /// ParseDriverMode - Look for and handle the driver mode option in Args. - void ParseDriverMode(StringRef ProgramName, ArrayRef<const char *> Args); - /// ParseArgStrings - Parse the given list of strings into an /// ArgList. llvm::opt::InputArgList ParseArgStrings(ArrayRef<const char *> Args, @@ -552,10 +556,14 @@ public: bool ShouldEmitStaticLibrary(const llvm::opt::ArgList &Args) const; /// Returns true if we are performing any kind of LTO. - bool isUsingLTO() const { return LTOMode != LTOK_None; } + bool isUsingLTO(bool IsOffload = false) const { + return getLTOMode(IsOffload) != LTOK_None; + } /// Get the specific kind of LTO being performed. - LTOKind getLTOMode() const { return LTOMode; } + LTOKind getLTOMode(bool IsOffload = false) const { + return IsOffload ? OffloadLTOMode : LTOMode; + } private: @@ -570,9 +578,9 @@ private: /// \returns true, if error occurred while reading. bool readConfigFile(StringRef FileName); - /// Set the driver mode (cl, gcc, etc) from an option string of the form - /// --driver-mode=<mode>. - void setDriverModeFromOption(StringRef Opt); + /// Set the driver mode (cl, gcc, etc) from the value of the `--driver-mode` + /// option. + void setDriverMode(StringRef DriverModeValue); /// Parse the \p Args list for LTO options and record the type of LTO /// compilation based on which -f(no-)?lto(=.*)? option occurs last. @@ -632,6 +640,16 @@ bool isOptimizationLevelFast(const llvm::opt::ArgList &Args); /// \return True if the argument combination will end up generating remarks. bool willEmitRemarks(const llvm::opt::ArgList &Args); +/// Returns the driver mode option's value, i.e. `X` in `--driver-mode=X`. If \p +/// Args doesn't mention one explicitly, tries to deduce from `ProgName`. +/// Returns empty on failure. +/// Common values are "gcc", "g++", "cpp", "cl" and "flang". Returned value need +/// not be one of these. +llvm::StringRef getDriverMode(StringRef ProgName, ArrayRef<const char *> Args); + +/// Checks whether the value produced by getDriverMode is for CL mode. +bool IsClangCL(StringRef DriverMode); + } // end namespace driver } // end namespace clang diff --git a/clang/include/clang/Driver/InputInfo.h b/clang/include/clang/Driver/InputInfo.h new file mode 100644 index 000000000000..a1ecdb623331 --- /dev/null +++ b/clang/include/clang/Driver/InputInfo.h @@ -0,0 +1,107 @@ +//===--- InputInfo.h - Input Source & Type Information ----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_DRIVER_INPUTINFO_H +#define LLVM_CLANG_DRIVER_INPUTINFO_H + +#include "clang/Driver/Action.h" +#include "clang/Driver/Types.h" +#include "llvm/Option/Arg.h" +#include <cassert> +#include <string> + +namespace clang { +namespace driver { + +/// InputInfo - Wrapper for information about an input source. +class InputInfo { + // FIXME: The distinction between filenames and inputarg here is + // gross; we should probably drop the idea of a "linker + // input". Doing so means tweaking pipelining to still create link + // steps when it sees linker inputs (but not treat them as + // arguments), and making sure that arguments get rendered + // correctly. + enum Class { + Nothing, + Filename, + InputArg, + Pipe + }; + + union { + const char *Filename; + const llvm::opt::Arg *InputArg; + } Data; + Class Kind; + const Action* Act; + types::ID Type; + const char *BaseInput; + + static types::ID GetActionType(const Action *A) { + return A != nullptr ? A->getType() : types::TY_Nothing; + } + +public: + InputInfo() : InputInfo(nullptr, nullptr) {} + InputInfo(const Action *A, const char *_BaseInput) + : Kind(Nothing), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) {} + + InputInfo(types::ID _Type, const char *_Filename, const char *_BaseInput) + : Kind(Filename), Act(nullptr), Type(_Type), BaseInput(_BaseInput) { + Data.Filename = _Filename; + } + InputInfo(const Action *A, const char *_Filename, const char *_BaseInput) + : Kind(Filename), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) { + Data.Filename = _Filename; + } + + InputInfo(types::ID _Type, const llvm::opt::Arg *_InputArg, + const char *_BaseInput) + : Kind(InputArg), Act(nullptr), Type(_Type), BaseInput(_BaseInput) { + Data.InputArg = _InputArg; + } + InputInfo(const Action *A, const llvm::opt::Arg *_InputArg, + const char *_BaseInput) + : Kind(InputArg), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) { + Data.InputArg = _InputArg; + } + + bool isNothing() const { return Kind == Nothing; } + bool isFilename() const { return Kind == Filename; } + bool isInputArg() const { return Kind == InputArg; } + types::ID getType() const { return Type; } + const char *getBaseInput() const { return BaseInput; } + /// The action for which this InputInfo was created. May be null. + const Action *getAction() const { return Act; } + void setAction(const Action *A) { Act = A; } + + const char *getFilename() const { + assert(isFilename() && "Invalid accessor."); + return Data.Filename; + } + const llvm::opt::Arg &getInputArg() const { + assert(isInputArg() && "Invalid accessor."); + return *Data.InputArg; + } + + /// getAsString - Return a string name for this input, for + /// debugging. + std::string getAsString() const { + if (isFilename()) + return std::string("\"") + getFilename() + '"'; + else if (isInputArg()) + return "(input arg)"; + else + return "(nothing)"; + } +}; + +} // end namespace driver +} // end namespace clang + +#endif diff --git a/clang/include/clang/Driver/Job.h b/clang/include/clang/Driver/Job.h index 199387cddd5c..8b287638a271 100644 --- a/clang/include/clang/Driver/Job.h +++ b/clang/include/clang/Driver/Job.h @@ -10,6 +10,7 @@ #define LLVM_CLANG_DRIVER_JOB_H #include "clang/Basic/LLVM.h" +#include "clang/Driver/InputInfo.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" @@ -119,8 +120,8 @@ class Command { /// argument, which will be the executable). llvm::opt::ArgStringList Arguments; - /// The list of program arguments which are inputs. - llvm::opt::ArgStringList InputFilenames; + /// The list of program inputs. + std::vector<InputInfo> InputInfoList; /// The list of program arguments which are outputs. May be empty. std::vector<std::string> OutputFilenames; @@ -207,9 +208,7 @@ public: const llvm::opt::ArgStringList &getArguments() const { return Arguments; } - const llvm::opt::ArgStringList &getInputFilenames() const { - return InputFilenames; - } + const std::vector<InputInfo> &getInputInfos() const { return InputInfoList; } const std::vector<std::string> &getOutputFilenames() const { return OutputFilenames; @@ -241,26 +240,6 @@ public: void setEnvironment(llvm::ArrayRef<const char *> NewEnvironment) override; }; -/// Like Command, but with a fallback which is executed in case -/// the primary command crashes. -class FallbackCommand : public Command { -public: - FallbackCommand(const Action &Source_, const Tool &Creator_, - ResponseFileSupport ResponseSupport, const char *Executable_, - const llvm::opt::ArgStringList &Arguments_, - ArrayRef<InputInfo> Inputs, ArrayRef<InputInfo> Outputs, - std::unique_ptr<Command> Fallback_); - - void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, - CrashReportInfo *CrashInfo = nullptr) const override; - - int Execute(ArrayRef<Optional<StringRef>> Redirects, std::string *ErrMsg, - bool *ExecutionFailed) const override; - -private: - std::unique_ptr<Command> Fallback; -}; - /// Like Command, but always pretends that the wrapped command succeeded. class ForceSuccessCommand : public Command { public: diff --git a/clang/include/clang/Driver/Options.h b/clang/include/clang/Driver/Options.h index b641f64c3116..056660192ac5 100644 --- a/clang/include/clang/Driver/Options.h +++ b/clang/include/clang/Driver/Options.h @@ -9,8 +9,6 @@ #ifndef LLVM_CLANG_DRIVER_OPTIONS_H #define LLVM_CLANG_DRIVER_OPTIONS_H -#include <memory> - namespace llvm { namespace opt { class OptTable; diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 42c5319041d0..5a9fd078390e 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -160,6 +160,8 @@ def m_hexagon_Features_Group : OptionGroup<"<hexagon features group>">, // These are explicitly handled. def m_hexagon_Features_HVX_Group : OptionGroup<"<hexagon features group>">, Group<m_Group>, DocName<"Hexagon">; +def m_m68k_Features_Group: OptionGroup<"<m68k features group>">, + Group<m_Group>, DocName<"M68k">; def m_mips_Features_Group : OptionGroup<"<mips features group>">, Group<m_Group>, DocName<"MIPS">; def m_ppc_Features_Group : OptionGroup<"<ppc features group>">, @@ -246,53 +248,58 @@ class DiagnosticOpts<string base> class LangOpts<string base> : KeyPathAndMacro<"LangOpts->", base, "LANG_"> {} class TargetOpts<string base> - : KeyPathAndMacro<"TargetOpts->", base> {} + : KeyPathAndMacro<"TargetOpts->", base, "TARGET_"> {} class FrontendOpts<string base> - : KeyPathAndMacro<"FrontendOpts.", base> {} + : KeyPathAndMacro<"FrontendOpts.", base, "FRONTEND_"> {} class PreprocessorOutputOpts<string base> - : KeyPathAndMacro<"PreprocessorOutputOpts.", base> {} + : KeyPathAndMacro<"PreprocessorOutputOpts.", base, "PREPROCESSOR_OUTPUT_"> {} class DependencyOutputOpts<string base> - : KeyPathAndMacro<"DependencyOutputOpts.", base> {} + : KeyPathAndMacro<"DependencyOutputOpts.", base, "DEPENDENCY_OUTPUT_"> {} class CodeGenOpts<string base> : KeyPathAndMacro<"CodeGenOpts.", base, "CODEGEN_"> {} class HeaderSearchOpts<string base> - : KeyPathAndMacro<"HeaderSearchOpts->", base> {} + : KeyPathAndMacro<"HeaderSearchOpts->", base, "HEADER_SEARCH_"> {} class PreprocessorOpts<string base> - : KeyPathAndMacro<"PreprocessorOpts->", base> {} + : KeyPathAndMacro<"PreprocessorOpts->", base, "PREPROCESSOR_"> {} class FileSystemOpts<string base> - : KeyPathAndMacro<"FileSystemOpts.", base> {} + : KeyPathAndMacro<"FileSystemOpts.", base, "FILE_SYSTEM_"> {} class AnalyzerOpts<string base> - : KeyPathAndMacro<"AnalyzerOpts->", base> {} + : KeyPathAndMacro<"AnalyzerOpts->", base, "ANALYZER_"> {} class MigratorOpts<string base> - : KeyPathAndMacro<"MigratorOpts.", base> {} + : KeyPathAndMacro<"MigratorOpts.", base, "MIGRATOR_"> {} // A boolean option which is opt-in in CC1. The positive option exists in CC1 and -// Args.hasArg(OPT_ffoo) is used to check that the flag is enabled. +// Args.hasArg(OPT_ffoo) can be used to check that the flag is enabled. // This is useful if the option is usually disabled. +// Use this only when the option cannot be declared via BoolFOption. multiclass OptInFFlag<string name, string pos_prefix, string neg_prefix="", - string help="", list<OptionFlag> flags=[], - KeyPathAndMacro kpm = EmptyKPM, - list<string> enablers = []> { - def f#NAME : Flag<["-"], "f"#name>, Flags<!listconcat([CC1Option], flags)>, - Group<f_Group>, HelpText<!strconcat(pos_prefix, help)>, - MarshallingInfoFlag<kpm, "false">, - ImpliedByAnyOf<enablers, "true">; + string help="", list<OptionFlag> flags=[]> { + def f#NAME : Flag<["-"], "f"#name>, Flags<[CC1Option] # flags>, + Group<f_Group>, HelpText<pos_prefix # help>; def fno_#NAME : Flag<["-"], "fno-"#name>, Flags<flags>, - Group<f_Group>, HelpText<!strconcat(neg_prefix, help)>; + Group<f_Group>, HelpText<neg_prefix # help>; } // A boolean option which is opt-out in CC1. The negative option exists in CC1 and -// Args.hasArg(OPT_fno_foo) is used to check that the flag is disabled. +// Args.hasArg(OPT_fno_foo) can be used to check that the flag is disabled. +// Use this only when the option cannot be declared via BoolFOption. multiclass OptOutFFlag<string name, string pos_prefix, string neg_prefix, - string help="", list<OptionFlag> flags=[], - KeyPathAndMacro kpm = EmptyKPM, - list<string> disablers = []> { + string help="", list<OptionFlag> flags=[]> { def f#NAME : Flag<["-"], "f"#name>, Flags<flags>, - Group<f_Group>, HelpText<!strconcat(pos_prefix, help)>; - def fno_#NAME : Flag<["-"], "fno-"#name>, Flags<!listconcat([CC1Option], flags)>, - Group<f_Group>, HelpText<!strconcat(neg_prefix, help)>, - MarshallingInfoFlag<kpm, "false">, - ImpliedByAnyOf<disablers, "true">; + Group<f_Group>, HelpText<pos_prefix # help>; + def fno_#NAME : Flag<["-"], "fno-"#name>, Flags<[CC1Option] # flags>, + Group<f_Group>, HelpText<neg_prefix # help>; +} + +// Creates a positive and negative flags where both of them are prefixed with +// "m", have help text specified for positive and negative option, and a Group +// optionally specified by the opt_group argument, otherwise Group<m_Group>. +multiclass SimpleMFlag<string name, string pos_prefix, string neg_prefix, + string help, OptionGroup opt_group = m_Group> { + def m#NAME : Flag<["-"], "m"#name>, Group<opt_group>, + HelpText<pos_prefix # help>; + def mno_#NAME : Flag<["-"], "mno-"#name>, Group<opt_group>, + HelpText<neg_prefix # help>; } //===----------------------------------------------------------------------===// @@ -342,8 +349,8 @@ class BothFlags<list<OptionFlag> option_flags, string help = ""> { class ApplySuffix<FlagDef flag, BothFlags suffix> { FlagDef Result = FlagDef<flag.Polarity, flag.Value, - !listconcat(flag.OptionFlags, suffix.OptionFlags), - !strconcat(flag.Help, suffix.Help), flag.ImpliedBy>; + flag.OptionFlags # suffix.OptionFlags, + flag.Help # suffix.Help, flag.ImpliedBy>; } // Definition of the command line flag with positive spelling, e.g. "-ffoo". @@ -361,16 +368,16 @@ class FlagDefExpanded<FlagDef flag, string prefix, string name, string spelling> : FlagDef<flag.Polarity, flag.Value, flag.OptionFlags, flag.Help, flag.ImpliedBy> { // Name of the TableGen record. - string RecordName = prefix#!cond(flag.Polarity : "", true : "no_")#name; + string RecordName = prefix # !if(flag.Polarity, "", "no_") # name; // Spelling of the flag. - string Spelling = prefix#!cond(flag.Polarity : "", true : "no-")#spelling; + string Spelling = prefix # !if(flag.Polarity, "", "no-") # spelling; // Can the flag be implied by another flag? bit CanBeImplied = !not(!empty(flag.ImpliedBy)); // C++ code that will be assigned to the keypath when the flag is present. - code ValueAsCode = !cond(flag.Value : "true", true: "false"); + code ValueAsCode = !if(flag.Value, "true", "false"); } // TableGen record for a single marshalled flag. @@ -387,6 +394,8 @@ class MarshalledFlagRec<FlagDefExpanded flag, FlagDefExpanded other, // key path via the marshalling infrastructure. // Names of the records consist of the specified prefix, "no_" for the negative // flag, and NAME. +// Used for -cc1 frontend options. Driver-only options do not map to +// CompilerInvocation. multiclass BoolOption<string prefix = "", string spelling_base, KeyPathAndMacro kpm, Default default, FlagDef flag1_base, FlagDef flag2_base, @@ -397,11 +406,19 @@ multiclass BoolOption<string prefix = "", string spelling_base, defvar flag2 = FlagDefExpanded<ApplySuffix<flag2_base, suffix>.Result, prefix, NAME, spelling_base>; - // TODO: Assert that the flags have different polarity. - // TODO: Assert that the flags have different value. - // TODO: Assert that only one of the flags can be implied. + // The flags must have different polarity, different values, and only + // one can be implied. + assert !xor(flag1.Polarity, flag2.Polarity), + "the flags must have different polarity: flag1: " # + flag1.Polarity # ", flag2: " # flag2.Polarity; + assert !ne(flag1.Value, flag2.Value), + "the flags must have different values: flag1: " # + flag1.Value # ", flag2: " # flag2.Value; + assert !not(!and(flag1.CanBeImplied, flag2.CanBeImplied)), + "only one of the flags can be implied: flag1: " # + flag1.CanBeImplied # ", flag2: " # flag2.CanBeImplied; - defvar implied = !cond(flag1.CanBeImplied: flag1, true: flag2); + defvar implied = !if(flag1.CanBeImplied, flag1, flag2); def flag1.RecordName : MarshalledFlagRec<flag1, flag2, implied, kpm, default>; def flag2.RecordName : MarshalledFlagRec<flag2, flag1, implied, kpm, default>; @@ -409,6 +426,8 @@ multiclass BoolOption<string prefix = "", string spelling_base, /// Creates a BoolOption where both of the flags are prefixed with "f", are in /// the Group<f_Group>. +/// Used for -cc1 frontend options. Driver-only options do not map to +/// CompilerInvocation. multiclass BoolFOption<string flag_base, KeyPathAndMacro kpm, Default default, FlagDef flag1, FlagDef flag2, BothFlags both = BothFlags<[], "">> { @@ -418,6 +437,8 @@ multiclass BoolFOption<string flag_base, KeyPathAndMacro kpm, // Creates a BoolOption where both of the flags are prefixed with "g" and have // the Group<g_Group>. +// Used for -cc1 frontend options. Driver-only options do not map to +// CompilerInvocation. multiclass BoolGOption<string flag_base, KeyPathAndMacro kpm, Default default, FlagDef flag1, FlagDef flag2, BothFlags both = BothFlags<[], "">> { @@ -427,20 +448,26 @@ multiclass BoolGOption<string flag_base, KeyPathAndMacro kpm, // FIXME: Diagnose if target does not support protected visibility. class MarshallingInfoVisibility<KeyPathAndMacro kpm, code default> - : MarshallingInfoString<kpm, default>, + : MarshallingInfoEnum<kpm, default>, Values<"default,hidden,internal,protected">, NormalizedValues<["DefaultVisibility", "HiddenVisibility", - "HiddenVisibility", "ProtectedVisibility"]>, - AutoNormalizeEnum {} + "HiddenVisibility", "ProtectedVisibility"]> {} // Key paths that are constant during parsing of options with the same key path prefix. defvar cplusplus = LangOpts<"CPlusPlus">; +defvar cpp11 = LangOpts<"CPlusPlus11">; +defvar cpp17 = LangOpts<"CPlusPlus17">; +defvar cpp20 = LangOpts<"CPlusPlus20">; defvar c99 = LangOpts<"C99">; +defvar c2x = LangOpts<"C2x">; defvar lang_std = LangOpts<"LangStd">; defvar open_cl = LangOpts<"OpenCL">; +defvar cuda = LangOpts<"CUDA">; defvar render_script = LangOpts<"RenderScript">; defvar hip = LangOpts<"HIP">; defvar gnu_mode = LangOpts<"GNUMode">; +defvar asm_preprocessor = LangOpts<"AsmPreprocessor">; +defvar cpp_modules = LangOpts<"CPlusPlusModules">; defvar std = !strconcat("LangStandard::getLangStandardForKind(", lang_std.KeyPath, ")"); @@ -513,6 +540,11 @@ def gen_reproducer: Flag<["-"], "gen-reproducer">, InternalDebugOpt, def gen_cdb_fragment_path: Separate<["-"], "gen-cdb-fragment-path">, InternalDebugOpt, HelpText<"Emit a compilation database fragment to the specified directory">; +def round_trip_args : Flag<["-"], "round-trip-args">, Flags<[CC1Option, NoDriverOption]>, + HelpText<"Enable command line arguments round-trip.">; +def no_round_trip_args : Flag<["-"], "no-round-trip-args">, Flags<[CC1Option, NoDriverOption]>, + HelpText<"Disable command line arguments round-trip.">; + def _migrate : Flag<["--"], "migrate">, Flags<[NoXarchOption]>, HelpText<"Run the migrator">; def ccc_objcmt_migrate : Separate<["-"], "ccc-objcmt-migrate">, @@ -583,8 +615,14 @@ def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[NoXarchOption, CoreOption, Flan def _DASH_DASH : Option<["--"], "", KIND_REMAINING_ARGS>, Flags<[NoXarchOption, CoreOption]>; def A : JoinedOrSeparate<["-"], "A">, Flags<[RenderJoined]>, Group<gfortran_Group>; -def B : JoinedOrSeparate<["-"], "B">, MetaVarName<"<dir>">, - HelpText<"Add <dir> to search path for binaries and object files used implicitly">; +def B : JoinedOrSeparate<["-"], "B">, MetaVarName<"<prefix>">, + HelpText<"Search $prefix/$triple-$file and $prefix$file for executables, libraries, " + "includes, and data files used by the compiler. $prefix may or may not be a directory">; +def gcc_toolchain : Joined<["--"], "gcc-toolchain=">, Flags<[NoXarchOption]>, + HelpText<"Search for GCC installation in the specified directory on targets which commonly use GCC. " + "The directory usually contains 'lib{,32,64}/gcc{,-cross}/$triple' and 'include'. If specified, " + "sysroot is skipped for GCC detection. Note: executables (e.g. ld) used by the compiler are not " + "overridden by the selected GCC installation">; def CC : Flag<["-"], "CC">, Flags<[CC1Option]>, Group<Preprocessor_Group>, HelpText<"Include comments from within macros in preprocessed output">, MarshallingInfoFlag<PreprocessorOutputOpts<"ShowMacroComments">>; @@ -605,6 +643,12 @@ def G_EQ : Joined<["-"], "G=">, Flags<[NoXarchOption]>, Group<m_Group>, Alias<G> def H : Flag<["-"], "H">, Flags<[CC1Option]>, Group<Preprocessor_Group>, HelpText<"Show header includes and nesting depth">, MarshallingInfoFlag<DependencyOutputOpts<"ShowHeaderIncludes">>; +def fshow_skipped_includes : Flag<["-"], "fshow-skipped-includes">, + Flags<[CC1Option]>, HelpText<"Show skipped includes in -H output.">, + DocBrief<[{#include files may be "skipped" due to include guard optimization + or #pragma once. This flag makes -H show also such includes.}]>, + MarshallingInfoFlag<DependencyOutputOpts<"ShowSkippedHeaderIncludes">>; + def I_ : Flag<["-"], "I-">, Group<I_Group>, HelpText<"Restrict all prior -I flags to double-quoted inclusion and " "remove current directory from include path">; @@ -664,8 +708,10 @@ def Qy : Flag<["-"], "Qy">, Flags<[CC1Option]>, HelpText<"Emit metadata containing compiler name and version">; def Qn : Flag<["-"], "Qn">, Flags<[CC1Option]>, HelpText<"Do not emit metadata containing compiler name and version">; -def : Flag<["-"], "fident">, Group<f_Group>, Alias<Qy>, Flags<[CC1Option]>; -def : Flag<["-"], "fno-ident">, Group<f_Group>, Alias<Qn>, Flags<[CC1Option]>; +def : Flag<["-"], "fident">, Group<f_Group>, Alias<Qy>, + Flags<[CoreOption, CC1Option]>; +def : Flag<["-"], "fno-ident">, Group<f_Group>, Alias<Qn>, + Flags<[CoreOption, CC1Option]>; def Qunused_arguments : Flag<["-"], "Qunused-arguments">, Flags<[NoXarchOption, CoreOption]>, HelpText<"Don't emit warning for unused driver arguments">; def Q : Flag<["-"], "Q">, IgnoredGCCCompat; @@ -720,7 +766,7 @@ def Wundef_prefix_EQ : CommaJoined<["-"], "Wundef-prefix=">, Group<W_value_Group MarshallingInfoStringVector<DiagnosticOpts<"UndefPrefixes">>; def Wwrite_strings : Flag<["-"], "Wwrite-strings">, Group<W_Group>, Flags<[CC1Option, HelpHidden]>; def Wno_write_strings : Flag<["-"], "Wno-write-strings">, Group<W_Group>, Flags<[CC1Option, HelpHidden]>; -def W_Joined : Joined<["-"], "W">, Group<W_Group>, Flags<[CC1Option, CoreOption]>, +def W_Joined : Joined<["-"], "W">, Group<W_Group>, Flags<[CC1Option, CoreOption, FC1Option, FlangOption]>, MetaVarName<"<warning>">, HelpText<"Enable the specified warning">; def Xanalyzer : Separate<["-"], "Xanalyzer">, HelpText<"Pass <arg> to the static analyzer">, MetaVarName<"<arg>">, @@ -802,10 +848,12 @@ def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, Group<opencl_Group HelpText<"OpenCL only. Allow denormals to be flushed to zero.">; def cl_fp32_correctly_rounded_divide_sqrt : Flag<["-"], "cl-fp32-correctly-rounded-divide-sqrt">, Group<opencl_Group>, Flags<[CC1Option]>, HelpText<"OpenCL only. Specify that single precision floating-point divide and sqrt used in the program source are correctly rounded.">, - MarshallingInfoFlag<CodeGenOpts<"CorrectlyRoundedDivSqrt">>; + MarshallingInfoFlag<CodeGenOpts<"OpenCLCorrectlyRoundedDivSqrt">>; def cl_uniform_work_group_size : Flag<["-"], "cl-uniform-work-group-size">, Group<opencl_Group>, Flags<[CC1Option]>, HelpText<"OpenCL only. Defines that the global work-size be a multiple of the work-group size specified to clEnqueueNDRangeKernel">, MarshallingInfoFlag<CodeGenOpts<"UniformWGSize">>; +def cl_no_stdinc : Flag<["-"], "cl-no-stdinc">, Group<opencl_Group>, + HelpText<"OpenCL only. Disables all standard includes containing non-native compiler types and functions.">; def client__name : JoinedOrSeparate<["-"], "client_name">; def combine : Flag<["-", "--"], "combine">, Flags<[NoXarchOption, Unsupported]>; def compatibility__version : JoinedOrSeparate<["-"], "compatibility_version">; @@ -869,20 +917,29 @@ def cuda_path_ignore_env : Flag<["--"], "cuda-path-ignore-env">, Group<i_Group>, HelpText<"Ignore environment variables to detect CUDA installation">; def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group<i_Group>, HelpText<"Path to ptxas (used for compiling CUDA code)">; +def fgpu_flush_denormals_to_zero : Flag<["-"], "fgpu-flush-denormals-to-zero">, + HelpText<"Flush denormal floating point values to zero in CUDA/HIP device mode.">; +def fno_gpu_flush_denormals_to_zero : Flag<["-"], "fno-gpu-flush-denormals-to-zero">; def fcuda_flush_denormals_to_zero : Flag<["-"], "fcuda-flush-denormals-to-zero">, - HelpText<"Flush denormal floating point values to zero in CUDA device mode.">; -def fno_cuda_flush_denormals_to_zero : Flag<["-"], "fno-cuda-flush-denormals-to-zero">; + Alias<fgpu_flush_denormals_to_zero>; +def fno_cuda_flush_denormals_to_zero : Flag<["-"], "fno-cuda-flush-denormals-to-zero">, + Alias<fno_gpu_flush_denormals_to_zero>; defm gpu_rdc : BoolFOption<"gpu-rdc", LangOpts<"GPURelocatableDeviceCode">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Generate relocatable device code, also known as separate compilation mode">, NegFlag<SetFalse>>; def : Flag<["-"], "fcuda-rdc">, Alias<fgpu_rdc>; def : Flag<["-"], "fno-cuda-rdc">, Alias<fno_gpu_rdc>; -defm cuda_short_ptr : OptInFFlag<"cuda-short-ptr", - "Use 32-bit pointers for accessing const/local/shared address spaces", "", "", - [], TargetOpts<"NVPTXUseShortPointers">>; +defm cuda_short_ptr : BoolFOption<"cuda-short-ptr", + TargetOpts<"NVPTXUseShortPointers">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Use 32-bit pointers for accessing const/local/shared address spaces">, + NegFlag<SetFalse>>; def rocm_path_EQ : Joined<["--"], "rocm-path=">, Group<i_Group>, HelpText<"ROCm installation path, used for finding and automatically linking required bitcode libraries.">; +def hip_path_EQ : Joined<["--"], "hip-path=">, Group<i_Group>, + HelpText<"HIP runtime installation path, used for finding HIP version and adding HIP include path.">; +def amdgpu_arch_tool_EQ : Joined<["--"], "amdgpu-arch-tool=">, Group<i_Group>, + HelpText<"Tool used for detecting AMD GPU arch in the system.">; def rocm_device_lib_path_EQ : Joined<["--"], "rocm-device-lib-path=">, Group<Link_Group>, HelpText<"ROCm device library path. Alternative to rocm-path.">; def : Joined<["--"], "hip-device-lib-path=">, Alias<rocm_device_lib_path_EQ>; @@ -896,10 +953,17 @@ defm hip_new_launch_api : BoolFOption<"hip-new-launch-api", LangOpts<"HIPUseNewLaunchAPI">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Use">, NegFlag<SetFalse, [], "Don't use">, BothFlags<[], " new kernel launching API for HIP">>; +defm hip_fp32_correctly_rounded_divide_sqrt : BoolFOption<"hip-fp32-correctly-rounded-divide-sqrt", + CodeGenOpts<"HIPCorrectlyRoundedDivSqrt">, DefaultTrue, + PosFlag<SetTrue, [], "Specify">, + NegFlag<SetFalse, [CC1Option], "Don't specify">, + BothFlags<[], " that single precision floating-point divide and sqrt used in " + "the program source are correctly rounded (HIP device compilation only)">>, + ShouldParseIf<hip.KeyPath>; defm gpu_allow_device_init : BoolFOption<"gpu-allow-device-init", LangOpts<"GPUAllowDeviceInit">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Allow">, NegFlag<SetFalse, [], "Don't allow">, - BothFlags<[], " device side init function in HIP">>, + BothFlags<[], " device side init function in HIP (experimental)">>, ShouldParseIf<hip.KeyPath>; defm gpu_defer_diag : BoolFOption<"gpu-defer-diag", LangOpts<"GPUDeferDiag">, DefaultFalse, @@ -913,11 +977,36 @@ defm gpu_exclude_wrong_side_overloads : BoolFOption<"gpu-exclude-wrong-side-over def gpu_max_threads_per_block_EQ : Joined<["--"], "gpu-max-threads-per-block=">, Flags<[CC1Option]>, HelpText<"Default max threads per block for kernel launch bounds for HIP">, - MarshallingInfoStringInt<LangOpts<"GPUMaxThreadsPerBlock">, "256">, + MarshallingInfoInt<LangOpts<"GPUMaxThreadsPerBlock">, "1024">, ShouldParseIf<hip.KeyPath>; +def fgpu_inline_threshold_EQ : Joined<["-"], "fgpu-inline-threshold=">, + Flags<[HelpHidden]>, + HelpText<"Inline threshold for device compilation for CUDA/HIP">; def gpu_instrument_lib_EQ : Joined<["--"], "gpu-instrument-lib=">, HelpText<"Instrument device library for HIP, which is a LLVM bitcode containing " "__cyg_profile_func_enter and __cyg_profile_func_exit">; +def fgpu_sanitize : Flag<["-"], "fgpu-sanitize">, Group<f_Group>, + HelpText<"Enable sanitizer for AMDGPU target">; +def fno_gpu_sanitize : Flag<["-"], "fno-gpu-sanitize">, Group<f_Group>; +def gpu_bundle_output : Flag<["--"], "gpu-bundle-output">, + Group<f_Group>, HelpText<"Bundle output files of HIP device compilation">; +def no_gpu_bundle_output : Flag<["--"], "no-gpu-bundle-output">, + Group<f_Group>, HelpText<"Do not bundle output files of HIP device compilation">; +def cuid_EQ : Joined<["-"], "cuid=">, Flags<[CC1Option]>, + HelpText<"An ID for compilation unit, which should be the same for the same " + "compilation unit but different for different compilation units. " + "It is used to externalize device-side static variables for single " + "source offloading languages CUDA and HIP so that they can be " + "accessed by the host code of the same compilation unit.">, + MarshallingInfoString<LangOpts<"CUID">>; +def fuse_cuid_EQ : Joined<["-"], "fuse-cuid=">, + HelpText<"Method to generate ID's for compilation units for single source " + "offloading languages CUDA and HIP: 'hash' (ID's generated by hashing " + "file path and command line options) | 'random' (ID's generated as " + "random numbers) | 'none' (disabled). Default is 'hash'. This option " + "will be overriden by option '-cuid=[ID]' if it is specified." >; +def libomptarget_amdgcn_bc_path_EQ : Joined<["--"], "libomptarget-amdgcn-bc-path=">, Group<i_Group>, + HelpText<"Path to libomptarget-amdgcn bitcode library">; def libomptarget_nvptx_bc_path_EQ : Joined<["--"], "libomptarget-nvptx-bc-path=">, Group<i_Group>, HelpText<"Path to libomptarget-nvptx bitcode library">; def dD : Flag<["-"], "dD">, Group<d_Group>, Flags<[CC1Option]>, @@ -964,7 +1053,7 @@ def exported__symbols__list : Separate<["-"], "exported_symbols_list">; def e : JoinedOrSeparate<["-"], "e">, Flags<[LinkerInput]>, Group<Link_Group>; def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">, - MarshallingInfoStringInt<LangOpts<"MaxTokens">>; + MarshallingInfoInt<LangOpts<"MaxTokens">>; def fPIC : Flag<["-"], "fPIC">, Group<f_Group>; def fno_PIC : Flag<["-"], "fno-PIC">, Group<f_Group>; def fPIE : Flag<["-"], "fPIE">, Group<f_Group>; @@ -988,8 +1077,10 @@ defm apple_pragma_pack : BoolFOption<"apple-pragma-pack", LangOpts<"ApplePragmaPack">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Enable Apple gcc-compatible #pragma pack handling">, NegFlag<SetFalse>>; -def fxl_pragma_pack : Flag<["-"], "fxl-pragma-pack">, Group<f_Group>, Flags<[CC1Option]>, - HelpText<"Enable IBM XL #pragma pack handling">; +defm xl_pragma_pack : BoolFOption<"xl-pragma-pack", + LangOpts<"XLPragmaPack">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Enable IBM XL #pragma pack handling">, + NegFlag<SetFalse>>; def shared_libsan : Flag<["-"], "shared-libsan">, HelpText<"Dynamically link the sanitizer runtime">; def static_libsan : Flag<["-"], "static-libsan">, @@ -997,20 +1088,16 @@ def static_libsan : Flag<["-"], "static-libsan">, def : Flag<["-"], "shared-libasan">, Alias<shared_libsan>; def fasm : Flag<["-"], "fasm">, Group<f_Group>; -defm asm_blocks : OptInFFlag<"asm-blocks", "">; - def fassume_sane_operator_new : Flag<["-"], "fassume-sane-operator-new">, Group<f_Group>; def fastcp : Flag<["-"], "fastcp">, Group<f_Group>; def fastf : Flag<["-"], "fastf">, Group<f_Group>; def fast : Flag<["-"], "fast">, Group<f_Group>; def fasynchronous_unwind_tables : Flag<["-"], "fasynchronous-unwind-tables">, Group<f_Group>; -def fdouble_square_bracket_attributes : Flag<[ "-" ], "fdouble-square-bracket-attributes">, - Group<f_Group>, Flags<[NoXarchOption, CC1Option]>, - HelpText<"Enable '[[]]' attributes in all C and C++ language modes">; -def fno_double_square_bracket_attributes : Flag<[ "-" ], "fno-double-square-bracket-attributes">, - Group<f_Group>, Flags<[NoXarchOption, CC1Option]>, - HelpText<"Disable '[[]]' attributes in all C and C++ language modes">; +defm double_square_bracket_attributes : BoolFOption<"double-square-bracket-attributes", + LangOpts<"DoubleSquareBracketAttributes">, Default<!strconcat(cpp11.KeyPath, "||", c2x.KeyPath)>, + PosFlag<SetTrue, [], "Enable">, NegFlag<SetFalse, [], "Disable">, + BothFlags<[NoXarchOption, CC1Option], " '[[]]' attributes in all C and C++ language modes">>; defm autolink : BoolFOption<"autolink", CodeGenOpts<"Autolink">, DefaultTrue, @@ -1018,14 +1105,17 @@ defm autolink : BoolFOption<"autolink", PosFlag<SetTrue>>; // C++ Coroutines TS -defm coroutines_ts : OptInFFlag<"coroutines-ts", "Enable support for the C++ Coroutines TS">; +defm coroutines_ts : BoolFOption<"coroutines-ts", + LangOpts<"Coroutines">, Default<cpp20.KeyPath>, + PosFlag<SetTrue, [CC1Option], "Enable support for the C++ Coroutines TS">, + NegFlag<SetFalse>>; def fembed_bitcode_EQ : Joined<["-"], "fembed-bitcode=">, Group<f_Group>, Flags<[NoXarchOption, CC1Option, CC1AsOption]>, MetaVarName<"<option>">, HelpText<"Embed LLVM bitcode (option: off, all, bitcode, marker)">, Values<"off,all,bitcode,marker">, NormalizedValuesScope<"CodeGenOptions">, NormalizedValues<["Embed_Off", "Embed_All", "Embed_Bitcode", "Embed_Marker"]>, - MarshallingInfoString<CodeGenOpts<"EmbedBitcode">, "Embed_Off">, AutoNormalizeEnum; + MarshallingInfoEnum<CodeGenOpts<"EmbedBitcode">, "Embed_Off">; def fembed_bitcode : Flag<["-"], "fembed-bitcode">, Group<f_Group>, Alias<fembed_bitcode_EQ>, AliasArgs<["all"]>, HelpText<"Embed LLVM IR bitcode as data">; @@ -1064,13 +1154,20 @@ def fauto_profile_accurate : Flag<["-"], "fauto-profile-accurate">, Group<f_Group>, Alias<fprofile_sample_accurate>; def fno_auto_profile_accurate : Flag<["-"], "fno-auto-profile-accurate">, Group<f_Group>, Alias<fno_profile_sample_accurate>; -def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">, +def fdebug_compilation_dir_EQ : Joined<["-"], "fdebug-compilation-dir=">, Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>, - HelpText<"The compilation directory to embed in the debug info.">, + HelpText<"The compilation directory to embed in the debug info">, MarshallingInfoString<CodeGenOpts<"DebugCompilationDir">>; -def fdebug_compilation_dir_EQ : Joined<["-"], "fdebug-compilation-dir=">, +def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">, + Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>, + Alias<fdebug_compilation_dir_EQ>; +def fcoverage_compilation_dir_EQ : Joined<["-"], "fcoverage-compilation-dir=">, Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>, - Alias<fdebug_compilation_dir>; + HelpText<"The compilation directory to embed in the coverage mapping.">, + MarshallingInfoString<CodeGenOpts<"CoverageCompilationDir">>; +def ffile_compilation_dir_EQ : Joined<["-"], "ffile-compilation-dir=">, Group<f_Group>, + Flags<[CoreOption]>, + HelpText<"The compilation directory to embed in the debug info and coverage mapping.">; defm debug_info_for_profiling : BoolFOption<"debug-info-for-profiling", CodeGenOpts<"DebugInfoForProfiling">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Emit extra debug info to make sample profile more accurate">, @@ -1090,8 +1187,6 @@ def fprofile_remapping_file_EQ : Joined<["-"], "fprofile-remapping-file=">, Group<f_Group>, Flags<[CC1Option, CoreOption]>, MetaVarName<"<file>">, HelpText<"Use the remappings described in <file> to match the profile data against names in the program">, MarshallingInfoString<CodeGenOpts<"ProfileRemappingFile">>; -def fprofile_remapping_file : Separate<["-"], "fprofile-remapping-file">, - Group<f_Group>, Flags<[CoreOption]>, Alias<fprofile_remapping_file_EQ>; defm coverage_mapping : BoolFOption<"coverage-mapping", CodeGenOpts<"CoverageMapping">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Generate coverage mapping to enable code coverage analysis">, @@ -1147,7 +1242,7 @@ def fprofile_update_EQ : Joined<["-"], "fprofile-update=">, defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling", CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse, PosFlag<SetTrue, [], "Emit">, NegFlag<SetFalse, [], "Do not emit">, - BothFlags<[NoXarchOption, CC1Option], " pseudo probes for sample profiler">>; + BothFlags<[NoXarchOption, CC1Option], " pseudo probes for sample profiling">>; def forder_file_instrumentation : Flag<["-"], "forder-file-instrumentation">, Group<f_Group>, Flags<[CC1Option, CoreOption]>, HelpText<"Generate instrumented code to collect order file into default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env var)">; @@ -1209,7 +1304,7 @@ def fcf_runtime_abi_EQ : Joined<["-"], "fcf-runtime-abi=">, Group<f_Group>, Flags<[CC1Option]>, Values<"unspecified,standalone,objc,swift,swift-5.0,swift-4.2,swift-4.1">, NormalizedValuesScope<"LangOptions::CoreFoundationABI">, NormalizedValues<["ObjectiveC", "ObjectiveC", "ObjectiveC", "Swift5_0", "Swift5_0", "Swift4_2", "Swift4_1"]>, - MarshallingInfoString<LangOpts<"CFRuntime">, "ObjectiveC">, AutoNormalizeEnum; + MarshallingInfoEnum<LangOpts<"CFRuntime">, "ObjectiveC">; defm constant_cfstrings : BoolFOption<"constant-cfstrings", LangOpts<"NoConstantCFStrings">, DefaultFalse, NegFlag<SetTrue, [CC1Option], "Disable creation of CodeFoundation-type constant strings">, @@ -1224,11 +1319,16 @@ def fconstexpr_backtrace_limit_EQ : Joined<["-"], "fconstexpr-backtrace-limit="> Group<f_Group>; def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, Group<f_clang_Group>, Flags<[NoArgumentUnused, CoreOption]>, HelpText<"Disable auto-generation of preprocessed source files and a script for reproduction during a clang crash">; -def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">, Group<f_clang_Group>, Flags<[NoArgumentUnused, CoreOption]>; +def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">, + Group<f_clang_Group>, Flags<[NoArgumentUnused, CoreOption]>, + HelpText<"Put crash-report files in <dir>">, MetaVarName<"<dir>">; def fcreate_profile : Flag<["-"], "fcreate-profile">, Group<f_Group>; defm cxx_exceptions: BoolFOption<"cxx-exceptions", LangOpts<"CXXExceptions">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Enable C++ exceptions">, NegFlag<SetFalse>>; +defm async_exceptions: BoolFOption<"async-exceptions", + LangOpts<"EHAsynch">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Enable EH Asynchronous exceptions">, NegFlag<SetFalse>>; def fcxx_modules : Flag <["-"], "fcxx-modules">, Group<f_Group>, Flags<[NoXarchOption]>; def fdebug_pass_arguments : Flag<["-"], "fdebug-pass-arguments">, Group<f_Group>; @@ -1267,14 +1367,14 @@ def fdiagnostics_show_template_tree : Flag<["-"], "fdiagnostics-show-template-tr Group<f_Group>, Flags<[CC1Option]>, HelpText<"Print a template comparison tree for differing templates">, MarshallingInfoFlag<DiagnosticOpts<"ShowTemplateTree">>; -def fdeclspec : Flag<["-"], "fdeclspec">, Group<f_clang_Group>, - HelpText<"Allow __declspec as a keyword">, Flags<[CC1Option]>; def fdiscard_value_names : Flag<["-"], "fdiscard-value-names">, Group<f_clang_Group>, HelpText<"Discard value names in LLVM IR">, Flags<[NoXarchOption]>; def fno_discard_value_names : Flag<["-"], "fno-discard-value-names">, Group<f_clang_Group>, HelpText<"Do not discard value names in LLVM IR">, Flags<[NoXarchOption]>; -def fdollars_in_identifiers : Flag<["-"], "fdollars-in-identifiers">, Group<f_Group>, - HelpText<"Allow '$' in identifiers">, Flags<[CC1Option]>; +defm dollars_in_identifiers : BoolFOption<"dollars-in-identifiers", + LangOpts<"DollarIdents">, Default<!strconcat("!", asm_preprocessor.KeyPath)>, + PosFlag<SetTrue, [], "Allow">, NegFlag<SetFalse, [], "Disallow">, + BothFlags<[CC1Option], " '$' in identifiers">>; def fdwarf2_cfi_asm : Flag<["-"], "fdwarf2-cfi-asm">, Group<clang_ignored_f_Group>; def fno_dwarf2_cfi_asm : Flag<["-"], "fno-dwarf2-cfi-asm">, Group<clang_ignored_f_Group>; defm dwarf_directory_asm : BoolFOption<"dwarf-directory-asm", @@ -1315,10 +1415,9 @@ def fwasm_exceptions : Flag<["-"], "fwasm-exceptions">, Group<f_Group>, def exception_model : Separate<["-"], "exception-model">, Flags<[CC1Option, NoDriverOption]>, HelpText<"The exception model: dwarf|sjlj|seh|wasm">, Values<"dwarf,sjlj,seh,wasm">, - NormalizedValuesScope<"llvm::ExceptionHandling">, + NormalizedValuesScope<"LangOptions::ExceptionHandlingKind">, NormalizedValues<["DwarfCFI", "SjLj", "WinEH", "Wasm"]>, - MarshallingInfoString<LangOpts<"ExceptionHandling">, "None">, - AutoNormalizeEnum; + MarshallingInfoEnum<LangOpts<"ExceptionHandling">, "None">; def exception_model_EQ : Joined<["-"], "exception-model=">, Flags<[CC1Option, NoDriverOption]>, Alias<exception_model>; def fignore_exceptions : Flag<["-"], "fignore-exceptions">, Group<f_Group>, Flags<[CC1Option]>, @@ -1338,14 +1437,32 @@ def fdenormal_fp_math_EQ : Joined<["-"], "fdenormal-fp-math=">, Group<f_Group>, def ffp_model_EQ : Joined<["-"], "ffp-model=">, Group<f_Group>, Flags<[NoXarchOption]>, HelpText<"Controls the semantics of floating-point calculations.">; def ffp_exception_behavior_EQ : Joined<["-"], "ffp-exception-behavior=">, Group<f_Group>, Flags<[CC1Option]>, - HelpText<"Specifies the exception behavior of floating-point operations.">; -defm fast_math : OptInFFlag<"fast-math", "Allow aggressive, lossy floating-point optimizations", "", "", [], - LangOpts<"FastMath">, [cl_fast_relaxed_math.KeyPath]>; + HelpText<"Specifies the exception behavior of floating-point operations.">, + Values<"ignore,maytrap,strict">, NormalizedValuesScope<"LangOptions">, + NormalizedValues<["FPE_Ignore", "FPE_MayTrap", "FPE_Strict"]>, + MarshallingInfoEnum<LangOpts<"FPExceptionMode">, "FPE_Ignore">; +defm fast_math : BoolFOption<"fast-math", + LangOpts<"FastMath">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Allow aggressive, lossy floating-point optimizations", + [cl_fast_relaxed_math.KeyPath]>, + NegFlag<SetFalse>>; def menable_unsafe_fp_math : Flag<["-"], "menable-unsafe-fp-math">, Flags<[CC1Option]>, HelpText<"Allow unsafe floating-point math optimizations which may decrease precision">, MarshallingInfoFlag<LangOpts<"UnsafeFPMath">>, ImpliedByAnyOf<[cl_unsafe_math_optimizations.KeyPath, ffast_math.KeyPath]>; -defm math_errno : OptInFFlag<"math-errno", "Require math functions to indicate errors by setting errno">; +defm math_errno : BoolFOption<"math-errno", + LangOpts<"MathErrno">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Require math functions to indicate errors by setting errno">, + NegFlag<SetFalse>>, + ShouldParseIf<!strconcat("!", open_cl.KeyPath)>; +def fextend_args_EQ : Joined<["-"], "fextend-arguments=">, Group<f_Group>, + Flags<[CC1Option, NoArgumentUnused]>, + HelpText<"Controls how scalar integer arguments are extended in calls " + "to unprototyped and varargs functions">, + Values<"32,64">, + NormalizedValues<["ExtendTo32", "ExtendTo64"]>, + NormalizedValuesScope<"LangOptions::ExtendArgsKind">, + MarshallingInfoEnum<LangOpts<"ExtendIntArgs">,"ExtendTo32">; def fbracket_depth_EQ : Joined<["-"], "fbracket-depth=">, Group<f_Group>, Flags<[CoreOption]>; def fsignaling_math : Flag<["-"], "fsignaling-math">, Group<f_Group>; def fno_signaling_math : Flag<["-"], "fno-signaling-math">, Group<f_Group>; @@ -1353,12 +1470,18 @@ defm jump_tables : BoolFOption<"jump-tables", CodeGenOpts<"NoUseJumpTables">, DefaultFalse, NegFlag<SetTrue, [CC1Option], "Do not use">, PosFlag<SetFalse, [], "Use">, BothFlags<[], " jump tables for lowering switches">>; -defm force_enable_int128 : OptInFFlag<"force-enable-int128", "Enable", "Disable", " support for int128_t type", [], TargetOpts<"ForceEnableInt128">>; +defm force_enable_int128 : BoolFOption<"force-enable-int128", + TargetOpts<"ForceEnableInt128">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Enable">, NegFlag<SetFalse, [], "Disable">, + BothFlags<[], " support for int128_t type">>; defm keep_static_consts : BoolFOption<"keep-static-consts", CodeGenOpts<"KeepStaticConsts">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Keep">, NegFlag<SetFalse, [], "Don't keep">, BothFlags<[NoXarchOption], " static const variables if unused">>; -defm fixed_point : OptInFFlag<"fixed-point", "Enable", "Disable", " fixed point types">; +defm fixed_point : BoolFOption<"fixed-point", + LangOpts<"FixedPoint">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Enable">, NegFlag<SetFalse, [], "Disable">, + BothFlags<[], " fixed point types">>, ShouldParseIf<!strconcat("!", cplusplus.KeyPath)>; defm cxx_static_destructors : BoolFOption<"c++-static-destructors", LangOpts<"RegisterStaticDestructors">, DefaultTrue, NegFlag<SetFalse, [CC1Option], "Disable C++ static destructor registration">, @@ -1381,25 +1504,33 @@ def fsanitize_EQ : CommaJoined<["-"], "fsanitize=">, Group<f_clang_Group>, "or suspicious behavior. See user manual for available checks">; def fno_sanitize_EQ : CommaJoined<["-"], "fno-sanitize=">, Group<f_clang_Group>, Flags<[CoreOption, NoXarchOption]>; -def fsanitize_blacklist : Joined<["-"], "fsanitize-blacklist=">, - Group<f_clang_Group>, - HelpText<"Path to blacklist file for sanitizers">, - MarshallingInfoStringVector<LangOpts<"SanitizerBlacklistFiles">>; -def fsanitize_system_blacklist : Joined<["-"], "fsanitize-system-blacklist=">, - HelpText<"Path to system blacklist file for sanitizers">, - Flags<[CC1Option]>; -def fno_sanitize_blacklist : Flag<["-"], "fno-sanitize-blacklist">, - Group<f_clang_Group>, - HelpText<"Don't use blacklist file for sanitizers">; -def fsanitize_coverage - : CommaJoined<["-"], "fsanitize-coverage=">, - Group<f_clang_Group>, - HelpText<"Specify the type of coverage instrumentation for Sanitizers">; -def fno_sanitize_coverage - : CommaJoined<["-"], "fno-sanitize-coverage=">, - Group<f_clang_Group>, Flags<[CoreOption, NoXarchOption]>, - HelpText<"Disable specified features of coverage instrumentation for " - "Sanitizers">, Values<"func,bb,edge,indirect-calls,trace-bb,trace-cmp,trace-div,trace-gep,8bit-counters,trace-pc,trace-pc-guard,no-prune,inline-8bit-counters,inline-bool-flag">; + +def fsanitize_ignorelist_EQ : Joined<["-"], "fsanitize-ignorelist=">, + Group<f_clang_Group>, HelpText<"Path to ignorelist file for sanitizers">; +def : Joined<["-"], "fsanitize-blacklist=">, + Group<f_clang_Group>, Flags<[HelpHidden]>, Alias<fsanitize_ignorelist_EQ>, + HelpText<"Alias for -fsanitize-ignorelist=">; + +def fsanitize_system_ignorelist_EQ : Joined<["-"], "fsanitize-system-ignorelist=">, + HelpText<"Path to system ignorelist file for sanitizers">, Flags<[CC1Option]>; +def : Joined<["-"], "fsanitize-system-blacklist=">, + HelpText<"Alias for -fsanitize-system-ignorelist=">, + Flags<[CC1Option, HelpHidden]>, Alias<fsanitize_system_ignorelist_EQ>; + +def fno_sanitize_ignorelist : Flag<["-"], "fno-sanitize-ignorelist">, + Group<f_clang_Group>, HelpText<"Don't use ignorelist file for sanitizers">; +def : Flag<["-"], "fno-sanitize-blacklist">, + Group<f_clang_Group>, Flags<[HelpHidden]>, Alias<fno_sanitize_ignorelist>; + +def fsanitize_coverage : CommaJoined<["-"], "fsanitize-coverage=">, + Group<f_clang_Group>, + HelpText<"Specify the type of coverage instrumentation for Sanitizers">; +def fno_sanitize_coverage : CommaJoined<["-"], "fno-sanitize-coverage=">, + Group<f_clang_Group>, Flags<[CoreOption, NoXarchOption]>, + HelpText<"Disable features of coverage instrumentation for Sanitizers">, + Values<"func,bb,edge,indirect-calls,trace-bb,trace-cmp,trace-div,trace-gep," + "8bit-counters,trace-pc,trace-pc-guard,no-prune,inline-8bit-counters," + "inline-bool-flag">; def fsanitize_coverage_allowlist : Joined<["-"], "fsanitize-coverage-allowlist=">, Group<f_clang_Group>, Flags<[CoreOption, NoXarchOption]>, HelpText<"Restrict sanitizer coverage instrumentation exclusively to modules and functions that match the provided special case list, except the blocked ones">, @@ -1407,17 +1538,19 @@ def fsanitize_coverage_allowlist : Joined<["-"], "fsanitize-coverage-allowlist=" def : Joined<["-"], "fsanitize-coverage-whitelist=">, Group<f_clang_Group>, Flags<[CoreOption, HelpHidden]>, Alias<fsanitize_coverage_allowlist>, HelpText<"Deprecated, use -fsanitize-coverage-allowlist= instead">; -def fsanitize_coverage_blocklist : Joined<["-"], "fsanitize-coverage-blocklist=">, +def fsanitize_coverage_ignorelist : Joined<["-"], "fsanitize-coverage-ignorelist=">, Group<f_clang_Group>, Flags<[CoreOption, NoXarchOption]>, - HelpText<"Disable sanitizer coverage instrumentation for modules and functions that match the provided special case list, even the allowed ones">, - MarshallingInfoStringVector<CodeGenOpts<"SanitizeCoverageBlocklistFiles">>; + HelpText<"Disable sanitizer coverage instrumentation for modules and functions " + "that match the provided special case list, even the allowed ones">, + MarshallingInfoStringVector<CodeGenOpts<"SanitizeCoverageIgnorelistFiles">>; def : Joined<["-"], "fsanitize-coverage-blacklist=">, - Group<f_clang_Group>, Flags<[CoreOption, HelpHidden]>, Alias<fsanitize_coverage_blocklist>, - HelpText<"Deprecated, use -fsanitize-coverage-blocklist= instead">; + Group<f_clang_Group>, Flags<[CoreOption, HelpHidden]>, + Alias<fsanitize_coverage_ignorelist>, + HelpText<"Deprecated, use -fsanitize-coverage-ignorelist= instead">; def fsanitize_memory_track_origins_EQ : Joined<["-"], "fsanitize-memory-track-origins=">, Group<f_clang_Group>, HelpText<"Enable origins tracking in MemorySanitizer">, - MarshallingInfoStringInt<CodeGenOpts<"SanitizeMemoryTrackOrigins">>; + MarshallingInfoInt<CodeGenOpts<"SanitizeMemoryTrackOrigins">>; def fsanitize_memory_track_origins : Flag<["-"], "fsanitize-memory-track-origins">, Group<f_clang_Group>, HelpText<"Enable origins tracking in MemorySanitizer">; @@ -1425,6 +1558,20 @@ def fno_sanitize_memory_track_origins : Flag<["-"], "fno-sanitize-memory-track-o Group<f_clang_Group>, Flags<[CoreOption, NoXarchOption]>, HelpText<"Disable origins tracking in MemorySanitizer">; +def fsanitize_address_outline_instrumentation : Flag<["-"], "fsanitize-address-outline-instrumentation">, + Group<f_clang_Group>, + HelpText<"Always generate function calls for address sanitizer instrumentation">; +def fno_sanitize_address_outline_instrumentation : Flag<["-"], "fno-sanitize-address-outline-instrumentation">, + Group<f_clang_Group>, + HelpText<"Use default code inlining logic for the address sanitizer">; +def fsanitize_hwaddress_experimental_aliasing + : Flag<["-"], "fsanitize-hwaddress-experimental-aliasing">, + Group<f_clang_Group>, + HelpText<"Enable aliasing mode in HWAddressSanitizer">; +def fno_sanitize_hwaddress_experimental_aliasing + : Flag<["-"], "fno-sanitize-hwaddress-experimental-aliasing">, + Group<f_clang_Group>, Flags<[CoreOption, NoXarchOption]>, + HelpText<"Disable aliasing mode in HWAddressSanitizer">; defm sanitize_memory_use_after_dtor : BoolOption<"f", "sanitize-memory-use-after-dtor", CodeGenOpts<"SanitizeMemoryUseAfterDtor">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Enable">, NegFlag<SetFalse, [], "Disable">, @@ -1433,12 +1580,22 @@ defm sanitize_memory_use_after_dtor : BoolOption<"f", "sanitize-memory-use-after def fsanitize_address_field_padding : Joined<["-"], "fsanitize-address-field-padding=">, Group<f_clang_Group>, HelpText<"Level of field padding for AddressSanitizer">, - MarshallingInfoStringInt<LangOpts<"SanitizeAddressFieldPadding">>; + MarshallingInfoInt<LangOpts<"SanitizeAddressFieldPadding">>; defm sanitize_address_use_after_scope : BoolOption<"f", "sanitize-address-use-after-scope", CodeGenOpts<"SanitizeAddressUseAfterScope">, DefaultFalse, PosFlag<SetTrue, [], "Enable">, NegFlag<SetFalse, [CoreOption, NoXarchOption], "Disable">, BothFlags<[], " use-after-scope detection in AddressSanitizer">>, Group<f_clang_Group>; +def sanitize_address_use_after_return_EQ + : Joined<["-"], "fsanitize-address-use-after-return=">, + MetaVarName<"<mode>">, + Flags<[CC1Option]>, + HelpText<"Select the mode of detecting stack use-after-return in AddressSanitizer: never | runtime (default) | always">, + Group<f_clang_Group>, + Values<"never,runtime,always">, + NormalizedValuesScope<"llvm::AsanDetectStackUseAfterReturnMode">, + NormalizedValues<["Never", "Runtime", "Always"]>, + MarshallingInfoEnum<CodeGenOpts<"SanitizeAddressUseAfterReturn">, "Runtime">; defm sanitize_address_poison_custom_array_cookie : BoolOption<"f", "sanitize-address-poison-custom-array-cookie", CodeGenOpts<"SanitizeAddressPoisonCustomArrayCookie">, DefaultFalse, PosFlag<SetTrue, [], "Enable">, NegFlag<SetFalse, [], "Disable">, @@ -1453,6 +1610,15 @@ defm sanitize_address_use_odr_indicator : BoolOption<"f", "sanitize-address-use- " reports in partially sanitized programs at the cost of an increase in binary size">, NegFlag<SetFalse, [], "Disable ODR indicator globals">>, Group<f_clang_Group>; +def sanitize_address_destructor_EQ + : Joined<["-"], "fsanitize-address-destructor=">, + Flags<[CC1Option]>, + HelpText<"Set destructor type used in ASan instrumentation">, + Group<f_clang_Group>, + Values<"none,global">, + NormalizedValuesScope<"llvm::AsanDtorKind">, + NormalizedValues<["None", "Global"]>, + MarshallingInfoEnum<CodeGenOpts<"SanitizeAddressDtor">, "Global">; // Note: This flag was introduced when it was necessary to distinguish between // ABI for correct codegen. This is no longer needed, but the flag is // not removed since targeting either ABI will behave the same. @@ -1548,7 +1714,7 @@ def fsanitize_undefined_strip_path_components_EQ : Joined<["-"], "fsanitize-unde Group<f_clang_Group>, MetaVarName<"<number>">, HelpText<"Strip (or keep only, if negative) a given number of path components " "when emitting check metadata.">, - MarshallingInfoStringInt<CodeGenOpts<"EmitCheckPathComponentsToStrip">, "0", "int">; + MarshallingInfoInt<CodeGenOpts<"EmitCheckPathComponentsToStrip">, "0", "int">; } // end -f[no-]sanitize* flags @@ -1558,12 +1724,17 @@ def fno_unsafe_math_optimizations : Flag<["-"], "fno-unsafe-math-optimizations"> Group<f_Group>; def fassociative_math : Flag<["-"], "fassociative-math">, Group<f_Group>; def fno_associative_math : Flag<["-"], "fno-associative-math">, Group<f_Group>; -defm reciprocal_math : OptInFFlag<"reciprocal-math", "Allow division operations to be reassociated", "", "", [], - LangOpts<"AllowRecip">, [menable_unsafe_fp_math.KeyPath]>; +defm reciprocal_math : BoolFOption<"reciprocal-math", + LangOpts<"AllowRecip">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Allow division operations to be reassociated", + [menable_unsafe_fp_math.KeyPath]>, + NegFlag<SetFalse>>; def fapprox_func : Flag<["-"], "fapprox-func">, Group<f_Group>, Flags<[CC1Option, NoDriverOption]>, MarshallingInfoFlag<LangOpts<"ApproxFunc">>, ImpliedByAnyOf<[menable_unsafe_fp_math.KeyPath]>; -defm finite_math_only : OptInFFlag<"finite-math-only", "", "", "", [], - LangOpts<"FiniteMathOnly">, [cl_finite_math_only.KeyPath, ffast_math.KeyPath]>; +defm finite_math_only : BoolFOption<"finite-math-only", + LangOpts<"FiniteMathOnly">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "", [cl_finite_math_only.KeyPath, ffast_math.KeyPath]>, + NegFlag<SetFalse>>; defm signed_zeros : BoolFOption<"signed-zeros", LangOpts<"NoSignedZero">, DefaultFalse, NegFlag<SetTrue, [CC1Option], "Allow optimizations that ignore the sign of floating point zeros", @@ -1597,6 +1768,13 @@ defm strict_float_cast_overflow : BoolFOption<"strict-float-cast-overflow", " of the target's native float-to-int conversion instructions">, PosFlag<SetTrue, [], "Assume that overflowing float-to-int casts are undefined (default)">>; +defm protect_parens : BoolFOption<"protect-parens", + LangOpts<"ProtectParens">, DefaultFalse, + PosFlag<SetTrue, [CoreOption, CC1Option], + "Determines whether the optimizer honors parentheses when " + "floating-point expressions are evaluated">, + NegFlag<SetFalse>>; + def ffor_scope : Flag<["-"], "ffor-scope">, Group<f_Group>; def fno_for_scope : Flag<["-"], "fno-for-scope">, Group<f_Group>; @@ -1613,17 +1791,17 @@ defm delete_null_pointer_checks : BoolFOption<"delete-null-pointer-checks", PosFlag<SetFalse, [], "Treat usage of null pointers as undefined behavior (default)">, BothFlags<[CoreOption]>>; -def frewrite_map_file : Separate<["-"], "frewrite-map-file">, - Group<f_Group>, - Flags<[ NoXarchOption, CC1Option ]>, - MarshallingInfoStringVector<CodeGenOpts<"RewriteMapFiles">>; def frewrite_map_file_EQ : Joined<["-"], "frewrite-map-file=">, Group<f_Group>, - Flags<[NoXarchOption]>; + Flags<[NoXarchOption, CC1Option]>, + MarshallingInfoStringVector<CodeGenOpts<"RewriteMapFiles">>; defm use_line_directives : BoolFOption<"use-line-directives", PreprocessorOutputOpts<"UseLineDirectives">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Use #line in preprocessed output">, NegFlag<SetFalse>>; +defm minimize_whitespace : BoolFOption<"minimize-whitespace", + PreprocessorOutputOpts<"MinimizeWhitespace">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Minimize whitespace when emitting preprocessor output">, NegFlag<SetFalse>>; def ffreestanding : Flag<["-"], "ffreestanding">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Assert that the compilation takes place in a freestanding environment">, @@ -1673,7 +1851,8 @@ def fexperimental_strict_floating_point : Flag<["-"], "fexperimental-strict-floa Group<f_clang_Group>, Flags<[CC1Option]>, HelpText<"Enables experimental strict floating point in LLVM.">, MarshallingInfoFlag<LangOpts<"ExpStrictFP">>; -def finput_charset_EQ : Joined<["-"], "finput-charset=">, Group<f_Group>; +def finput_charset_EQ : Joined<["-"], "finput-charset=">, Flags<[FlangOption, FC1Option]>, Group<f_Group>, + HelpText<"Specify the default character set for source files">; def fexec_charset_EQ : Joined<["-"], "fexec-charset=">, Group<f_Group>; def finstrument_functions : Flag<["-"], "finstrument-functions">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Generate calls to instrument function entry and exit">, @@ -1690,13 +1869,16 @@ def fcf_protection : Flag<["-"], "fcf-protection">, Group<f_Group>, Flags<[CoreO Alias<fcf_protection_EQ>, AliasArgs<["full"]>, HelpText<"Enable cf-protection in 'full' mode">; -defm xray_instrument : OptInFFlag<"xray-instrument", "Generate XRay instrumentation sleds on function entry and exit", "", "", [], LangOpts<"XRayInstrument">>; +defm xray_instrument : BoolFOption<"xray-instrument", + LangOpts<"XRayInstrument">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Generate XRay instrumentation sleds on function entry and exit">, + NegFlag<SetFalse>>; def fxray_instruction_threshold_EQ : JoinedOrSeparate<["-"], "fxray-instruction-threshold=">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Sets the minimum function size to instrument with XRay">, - MarshallingInfoStringInt<CodeGenOpts<"XRayInstructionThreshold">, "200">; + MarshallingInfoInt<CodeGenOpts<"XRayInstructionThreshold">, "200">; def fxray_instruction_threshold_ : JoinedOrSeparate<["-"], "fxray-instruction-threshold">, Group<f_Group>, Flags<[CC1Option]>; @@ -1721,16 +1903,29 @@ def fxray_modes : Group<f_Group>, Flags<[CC1Option]>, HelpText<"List of modes to link in by default into XRay instrumented binaries.">; -defm xray_always_emit_customevents : OptInFFlag<"xray-always-emit-customevents", - "Always emit __xray_customevent(...) calls even if the containing function is not always instrumented", "", "", [], LangOpts<"XRayAlwaysEmitCustomEvents">>; +defm xray_always_emit_customevents : BoolFOption<"xray-always-emit-customevents", + LangOpts<"XRayAlwaysEmitCustomEvents">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Always emit __xray_customevent(...) calls" + " even if the containing function is not always instrumented">, + NegFlag<SetFalse>>; + +defm xray_always_emit_typedevents : BoolFOption<"xray-always-emit-typedevents", + LangOpts<"XRayAlwaysEmitTypedEvents">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Always emit __xray_typedevent(...) calls" + " even if the containing function is not always instrumented">, + NegFlag<SetFalse>>; -defm xray_always_emit_typedevents : OptInFFlag<"xray-always-emit-typedevents", - "Always emit __xray_typedevent(...) calls even if the containing function is not always instrumented", "", "", [], LangOpts<"XRayAlwaysEmitTypedEvents">>; +defm xray_ignore_loops : BoolFOption<"xray-ignore-loops", + CodeGenOpts<"XRayIgnoreLoops">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Don't instrument functions with loops" + " unless they also meet the minimum function size">, + NegFlag<SetFalse>>; -defm xray_ignore_loops : OptInFFlag<"xray-ignore-loops", - "Don't instrument functions with loops unless they also meet the minimum function size", "", "", [], CodeGenOpts<"XRayIgnoreLoops">>; -defm xray_function_index : OptOutFFlag<"xray-function-index", "", - "Omit function index section at the expense of single-function patching performance", "", [], CodeGenOpts<"XRayOmitFunctionIndex">>; +defm xray_function_index : BoolFOption<"xray-function-index", + CodeGenOpts<"XRayOmitFunctionIndex">, DefaultTrue, + NegFlag<SetFalse, [CC1Option], "Omit function index section at the" + " expense of single-function patching performance">, + PosFlag<SetTrue>>; def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group<f_Group>, Flags<[CC1Option]>, @@ -1747,13 +1942,13 @@ def fxray_function_groups : Joined<["-"], "fxray-function-groups=">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Only instrument 1 of N groups">, - MarshallingInfoStringInt<CodeGenOpts<"XRayTotalFunctionGroups">, "1">; + MarshallingInfoInt<CodeGenOpts<"XRayTotalFunctionGroups">, "1">; def fxray_selected_function_group : Joined<["-"], "fxray-selected-function-group=">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"When using -fxray-function-groups, select which group of functions to instrument. Valid range is 0 to fxray-function-groups - 1">, - MarshallingInfoStringInt<CodeGenOpts<"XRaySelectedFunctionGroup">, "0">; + MarshallingInfoInt<CodeGenOpts<"XRaySelectedFunctionGroup">, "0">; defm fine_grained_bitfield_accesses : BoolOption<"f", "fine-grained-bitfield-accesses", @@ -1763,10 +1958,18 @@ defm fine_grained_bitfield_accesses : BoolOption<"f", "fine-grained-bitfield-acc BothFlags<[CC1Option]>>, Group<f_clang_Group>; -defm experimental_relative_cxx_abi_vtables : BoolFOption<"experimental-relative-c++-abi-vtables", - LangOpts<"RelativeCXXABIVTables">, DefaultFalse, - PosFlag<SetTrue, [], "Use">, NegFlag<SetFalse, [], "Do not use">, - BothFlags<[CC1Option], " the experimental C++ class ABI for classes with virtual tables">>; +def fexperimental_relative_cxx_abi_vtables : + Flag<["-"], "fexperimental-relative-c++-abi-vtables">, + Group<f_clang_Group>, Flags<[CC1Option]>, + HelpText<"Use the experimental C++ class ABI for classes with virtual tables">; +def fno_experimental_relative_cxx_abi_vtables : + Flag<["-"], "fno-experimental-relative-c++-abi-vtables">, + Group<f_clang_Group>, Flags<[CC1Option]>, + HelpText<"Do not use the experimental C++ class ABI for classes with virtual tables">; + +def fcxx_abi_EQ : Joined<["-"], "fc++-abi=">, + Group<f_clang_Group>, Flags<[CC1Option]>, + HelpText<"C++ ABI to use. This will override the target C++ ABI.">; def flat__namespace : Flag<["-"], "flat_namespace">; def flax_vector_conversions_EQ : Joined<["-"], "flax-vector-conversions=">, Group<f_Group>, @@ -1774,10 +1977,10 @@ def flax_vector_conversions_EQ : Joined<["-"], "flax-vector-conversions=">, Grou NormalizedValues<["LangOptions::LaxVectorConversionKind::None", "LangOptions::LaxVectorConversionKind::Integer", "LangOptions::LaxVectorConversionKind::All"]>, - MarshallingInfoString<LangOpts<"LaxVectorConversions">, - !strconcat(open_cl.KeyPath, " ? LangOptions::LaxVectorConversionKind::None" - " : LangOptions::LaxVectorConversionKind::All")>, - AutoNormalizeEnum; + MarshallingInfoEnum<LangOpts<"LaxVectorConversions">, + open_cl.KeyPath # + " ? LangOptions::LaxVectorConversionKind::None" # + " : LangOptions::LaxVectorConversionKind::All">; def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group<f_Group>, Alias<flax_vector_conversions_EQ>, AliasArgs<["integer"]>; def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group<f_Group>; @@ -1785,10 +1988,18 @@ def fapple_link_rtlib : Flag<["-"], "fapple-link-rtlib">, Group<f_Group>, HelpText<"Force linking the clang builtins runtime library">; def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, Group<f_Group>, HelpText<"Set LTO mode to either 'full' or 'thin'">, Values<"thin,full">; +def flto_EQ_jobserver : Flag<["-"], "flto=jobserver">, Group<f_Group>; +def flto_EQ_auto : Flag<["-"], "flto=auto">, Group<f_Group>; def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group<f_Group>, HelpText<"Enable LTO in 'full' mode">; def fno_lto : Flag<["-"], "fno-lto">, Flags<[CoreOption, CC1Option]>, Group<f_Group>, HelpText<"Disable LTO mode (default)">; +def foffload_lto_EQ : Joined<["-"], "foffload-lto=">, Flags<[CoreOption]>, Group<f_Group>, + HelpText<"Set LTO mode to either 'full' or 'thin' for offload compilation">, Values<"thin,full">; +def foffload_lto : Flag<["-"], "foffload-lto">, Flags<[CoreOption]>, Group<f_Group>, + HelpText<"Enable LTO in 'full' mode for offload compilation">; +def fno_offload_lto : Flag<["-"], "fno-offload-lto">, Flags<[CoreOption]>, Group<f_Group>, + HelpText<"Disable LTO mode (default) for offload compilation">; def flto_jobs_EQ : Joined<["-"], "flto-jobs=">, Flags<[CC1Option]>, Group<f_Group>, HelpText<"Controls the backend parallelism of -flto=thin (default " @@ -1809,12 +2020,16 @@ defm merge_all_constants : BoolFOption<"merge-all-constants", BothFlags<[], " merging of constants">>; def fmessage_length_EQ : Joined<["-"], "fmessage-length=">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Format message diagnostics so that they fit within N columns">, - MarshallingInfoStringInt<DiagnosticOpts<"MessageLength">>; -def fms_extensions : Flag<["-"], "fms-extensions">, Group<f_Group>, Flags<[CC1Option, CoreOption]>, - HelpText<"Accept some non-standard constructs supported by the Microsoft compiler">; + MarshallingInfoInt<DiagnosticOpts<"MessageLength">>; def fms_compatibility : Flag<["-"], "fms-compatibility">, Group<f_Group>, Flags<[CC1Option, CoreOption]>, HelpText<"Enable full Microsoft Visual C++ compatibility">, MarshallingInfoFlag<LangOpts<"MSVCCompat">>; +def fms_extensions : Flag<["-"], "fms-extensions">, Group<f_Group>, Flags<[CC1Option, CoreOption]>, + HelpText<"Accept some non-standard constructs supported by the Microsoft compiler">, + MarshallingInfoFlag<LangOpts<"MicrosoftExt">>, ImpliedByAnyOf<[fms_compatibility.KeyPath]>; +defm asm_blocks : BoolFOption<"asm-blocks", + LangOpts<"AsmBlocks">, Default<fms_extensions.KeyPath>, + PosFlag<SetTrue, [CC1Option]>, NegFlag<SetFalse>>; def fms_volatile : Flag<["-"], "fms-volatile">, Group<f_Group>, Flags<[CC1Option]>, MarshallingInfoFlag<CodeGenOpts<"MSVolatile">>; def fmsc_version : Joined<["-"], "fmsc-version=">, Group<f_Group>, Flags<[NoXarchOption, CoreOption]>, @@ -1835,8 +2050,20 @@ def fms_memptr_rep_EQ : Joined<["-"], "fms-memptr-rep=">, Group<f_Group>, Flags< Values<"single,multiple,virtual">, NormalizedValuesScope<"LangOptions">, NormalizedValues<["PPTMK_FullGeneralitySingleInheritance", "PPTMK_FullGeneralityMultipleInheritance", "PPTMK_FullGeneralityVirtualInheritance"]>, - MarshallingInfoString<LangOpts<"MSPointerToMemberRepresentationMethod">, "PPTMK_BestCase">, - AutoNormalizeEnum; + MarshallingInfoEnum<LangOpts<"MSPointerToMemberRepresentationMethod">, "PPTMK_BestCase">; +// __declspec is enabled by default for the PS4 by the driver, and also +// enabled for Microsoft Extensions or Borland Extensions, here. +// +// FIXME: __declspec is also currently enabled for CUDA, but isn't really a +// CUDA extension. However, it is required for supporting +// __clang_cuda_builtin_vars.h, which uses __declspec(property). Once that has +// been rewritten in terms of something more generic, remove the Opts.CUDA +// term here. +defm declspec : BoolOption<"f", "declspec", + LangOpts<"DeclSpecKeyword">, DefaultFalse, + PosFlag<SetTrue, [], "Allow", [fms_extensions.KeyPath, fborland_extensions.KeyPath, cuda.KeyPath]>, + NegFlag<SetFalse, [], "Disallow">, + BothFlags<[CC1Option], " __declspec as a keyword">>, Group<f_clang_Group>; def fmodules_cache_path : Joined<["-"], "fmodules-cache-path=">, Group<i_Group>, Flags<[NoXarchOption, CC1Option]>, MetaVarName<"<directory>">, HelpText<"Specify the module cache path">; @@ -1847,24 +2074,23 @@ def fmodules_user_build_path : Separate<["-"], "fmodules-user-build-path">, Grou def fprebuilt_module_path : Joined<["-"], "fprebuilt-module-path=">, Group<i_Group>, Flags<[NoXarchOption, CC1Option]>, MetaVarName<"<directory>">, HelpText<"Specify the prebuilt module path">; -defm prebuilt_implicit_modules : OptInFFlag<"prebuilt-implicit-modules", - "Look up implicit modules in the prebuilt module path", "", "", - [NoXarchOption, CC1Option], HeaderSearchOpts<"EnablePrebuiltImplicitModules">>; +defm prebuilt_implicit_modules : BoolFOption<"prebuilt-implicit-modules", + HeaderSearchOpts<"EnablePrebuiltImplicitModules">, DefaultFalse, + PosFlag<SetTrue, [], "Look up implicit modules in the prebuilt module path">, + NegFlag<SetFalse>, BothFlags<[NoXarchOption, CC1Option]>>; + def fmodules_prune_interval : Joined<["-"], "fmodules-prune-interval=">, Group<i_Group>, Flags<[CC1Option]>, MetaVarName<"<seconds>">, HelpText<"Specify the interval (in seconds) between attempts to prune the module cache">, - MarshallingInfoStringInt<HeaderSearchOpts<"ModuleCachePruneInterval">, "7 * 24 * 60 * 60">; + MarshallingInfoInt<HeaderSearchOpts<"ModuleCachePruneInterval">, "7 * 24 * 60 * 60">; def fmodules_prune_after : Joined<["-"], "fmodules-prune-after=">, Group<i_Group>, Flags<[CC1Option]>, MetaVarName<"<seconds>">, HelpText<"Specify the interval (in seconds) after which a module file will be considered unused">, - MarshallingInfoStringInt<HeaderSearchOpts<"ModuleCachePruneAfter">, "31 * 24 * 60 * 60">; -def fmodules_search_all : Flag <["-"], "fmodules-search-all">, Group<f_Group>, - Flags<[NoXarchOption, CC1Option]>, - HelpText<"Search even non-imported modules to resolve references">; + MarshallingInfoInt<HeaderSearchOpts<"ModuleCachePruneAfter">, "31 * 24 * 60 * 60">; def fbuild_session_timestamp : Joined<["-"], "fbuild-session-timestamp=">, Group<i_Group>, Flags<[CC1Option]>, MetaVarName<"<time since Epoch in seconds>">, HelpText<"Time when the current build session started">, - MarshallingInfoStringInt<HeaderSearchOpts<"BuildSessionTimestamp">, "0", "uint64_t">; + MarshallingInfoInt<HeaderSearchOpts<"BuildSessionTimestamp">, "0", "uint64_t">; def fbuild_session_file : Joined<["-"], "fbuild-session-file=">, Group<i_Group>, MetaVarName<"<file>">, HelpText<"Use the last modification time of <file> as the build session timestamp">; @@ -1912,48 +2138,53 @@ defm pch_codegen: OptInFFlag<"pch-codegen", "Generate ", "Do not generate ", defm pch_debuginfo: OptInFFlag<"pch-debuginfo", "Generate ", "Do not generate ", "debug info for types in an object file built from this PCH and do not generate them elsewhere">; -def fmodules : Flag <["-"], "fmodules">, Group<f_Group>, - Flags<[NoXarchOption, CC1Option]>, - HelpText<"Enable the 'modules' language feature">; def fimplicit_module_maps : Flag <["-"], "fimplicit-module-maps">, Group<f_Group>, - Flags<[NoXarchOption, CC1Option]>, + Flags<[NoXarchOption, CC1Option, CoreOption]>, HelpText<"Implicitly search the file system for module map files.">, MarshallingInfoFlag<HeaderSearchOpts<"ImplicitModuleMaps">>; def fmodules_ts : Flag <["-"], "fmodules-ts">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Enable support for the C++ Modules TS">, MarshallingInfoFlag<LangOpts<"ModulesTS">>; -def fmodule_maps : Flag <["-"], "fmodule-maps">, Alias<fimplicit_module_maps>; +defm modules : BoolFOption<"modules", + LangOpts<"Modules">, Default<!strconcat(fmodules_ts.KeyPath, "||", cpp_modules.KeyPath)>, + PosFlag<SetTrue, [CC1Option], "Enable the 'modules' language feature">, + NegFlag<SetFalse>, BothFlags<[NoXarchOption, CoreOption]>>; +def fmodule_maps : Flag <["-"], "fmodule-maps">, Flags<[CoreOption]>, Alias<fimplicit_module_maps>; def fmodule_name_EQ : Joined<["-"], "fmodule-name=">, Group<f_Group>, - Flags<[NoXarchOption,CC1Option]>, MetaVarName<"<name>">, + Flags<[NoXarchOption,CC1Option,CoreOption]>, MetaVarName<"<name>">, HelpText<"Specify the name of the module to build">, MarshallingInfoString<LangOpts<"ModuleName">>; -def fmodule_name : Separate<["-"], "fmodule-name">, Alias<fmodule_name_EQ>; def fmodule_implementation_of : Separate<["-"], "fmodule-implementation-of">, - Flags<[CC1Option]>, Alias<fmodule_name_EQ>; -def fsystem_module : Flag<["-"], "fsystem-module">, Flags<[CC1Option]>, + Flags<[CC1Option,CoreOption]>, Alias<fmodule_name_EQ>; +def fsystem_module : Flag<["-"], "fsystem-module">, Flags<[CC1Option,CoreOption]>, HelpText<"Build this module as a system module. Only used with -emit-module">, MarshallingInfoFlag<FrontendOpts<"IsSystemModule">>; def fmodule_map_file : Joined<["-"], "fmodule-map-file=">, - Group<f_Group>, Flags<[NoXarchOption,CC1Option]>, MetaVarName<"<file>">, + Group<f_Group>, Flags<[NoXarchOption,CC1Option,CoreOption]>, MetaVarName<"<file>">, HelpText<"Load this module map file">, MarshallingInfoStringVector<FrontendOpts<"ModuleMapFiles">>; def fmodule_file : Joined<["-"], "fmodule-file=">, - Group<i_Group>, Flags<[NoXarchOption,CC1Option]>, MetaVarName<"[<name>=]<file>">, + Group<i_Group>, Flags<[NoXarchOption,CC1Option,CoreOption]>, MetaVarName<"[<name>=]<file>">, HelpText<"Specify the mapping of module name to precompiled module file, or load a module file if name is omitted.">; -def fmodules_ignore_macro : Joined<["-"], "fmodules-ignore-macro=">, Group<f_Group>, Flags<[CC1Option]>, +def fmodules_ignore_macro : Joined<["-"], "fmodules-ignore-macro=">, Group<f_Group>, + Flags<[CC1Option,CoreOption]>, HelpText<"Ignore the definition of the given macro when building and loading modules">; -def fmodules_decluse : Flag <["-"], "fmodules-decluse">, Group<f_Group>, - Flags<[NoXarchOption,CC1Option]>, - HelpText<"Require declaration of modules used within a module">; def fmodules_strict_decluse : Flag <["-"], "fmodules-strict-decluse">, Group<f_Group>, - Flags<[NoXarchOption,CC1Option]>, + Flags<[NoXarchOption,CC1Option,CoreOption]>, HelpText<"Like -fmodules-decluse but requires all headers to be in modules">, MarshallingInfoFlag<LangOpts<"ModulesStrictDeclUse">>; -def fno_modules_search_all : Flag <["-"], "fno-modules-search-all">, Group<f_Group>, - Flags<[NoXarchOption, CC1Option]>; +defm modules_decluse : BoolFOption<"modules-decluse", + LangOpts<"ModulesDeclUse">, Default<fmodules_strict_decluse.KeyPath>, + PosFlag<SetTrue, [CC1Option], "Require declaration of modules used within a module">, + NegFlag<SetFalse>, BothFlags<[NoXarchOption,CoreOption]>>; +defm modules_search_all : BoolFOption<"modules-search-all", + LangOpts<"ModulesSearchAll">, DefaultFalse, + PosFlag<SetTrue, [], "Search even non-imported modules to resolve references">, + NegFlag<SetFalse>, BothFlags<[NoXarchOption, CC1Option,CoreOption]>>, + ShouldParseIf<fmodules.KeyPath>; defm implicit_modules : BoolFOption<"implicit-modules", LangOpts<"ImplicitModules">, DefaultTrue, - NegFlag<SetFalse, [CC1Option]>, PosFlag<SetTrue>, BothFlags<[NoXarchOption]>>; + NegFlag<SetFalse, [CC1Option]>, PosFlag<SetTrue>, BothFlags<[NoXarchOption,CoreOption]>>; def fretain_comments_from_system_headers : Flag<["-"], "fretain-comments-from-system-headers">, Group<f_Group>, Flags<[CC1Option]>, MarshallingInfoFlag<LangOpts<"RetainCommentsFromSystemHeaders">>; @@ -1961,7 +2192,6 @@ def fmudflapth : Flag<["-"], "fmudflapth">, Group<f_Group>; def fmudflap : Flag<["-"], "fmudflap">, Group<f_Group>; def fnested_functions : Flag<["-"], "fnested-functions">, Group<f_Group>; def fnext_runtime : Flag<["-"], "fnext-runtime">, Group<f_Group>; -def fno_xl_pragma_pack : Flag<["-"], "fno-xl-pragma-pack">, Group<f_Group>; def fno_asm : Flag<["-"], "fno-asm">, Group<f_Group>; def fno_asynchronous_unwind_tables : Flag<["-"], "fno-asynchronous-unwind-tables">, Group<f_Group>; def fno_assume_sane_operator_new : Flag<["-"], "fno-assume-sane-operator-new">, Group<f_Group>, @@ -1982,10 +2212,6 @@ defm digraphs : BoolFOption<"digraphs", PosFlag<SetTrue, [], "Enable alternative token representations '<:', ':>', '<%', '%>', '%:', '%:%:' (default)">, NegFlag<SetFalse, [], "Disallow alternative token representations '<:', ':>', '<%', '%>', '%:', '%:%:'">, BothFlags<[CC1Option]>>; -def fno_declspec : Flag<["-"], "fno-declspec">, Group<f_clang_Group>, - HelpText<"Disallow __declspec as a keyword">, Flags<[CC1Option]>; -def fno_dollars_in_identifiers : Flag<["-"], "fno-dollars-in-identifiers">, Group<f_Group>, - HelpText<"Disallow '$' in identifiers">, Flags<[CC1Option]>; def fno_eliminate_unused_debug_symbols : Flag<["-"], "fno-eliminate-unused-debug-symbols">, Group<f_Group>; def fno_inline_functions : Flag<["-"], "fno-inline-functions">, Group<f_clang_Group>, Flags<[CC1Option]>; def fno_inline : Flag<["-"], "fno-inline">, Group<f_clang_Group>, Flags<[CC1Option]>; @@ -1995,19 +2221,16 @@ def fno_experimental_isel : Flag<["-"], "fno-experimental-isel">, Group<f_clang_ Alias<fno_global_isel>; def fveclib : Joined<["-"], "fveclib=">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Use the given vector functions library">, - Values<"Accelerate,libmvec,MASSV,SVML,none">, + Values<"Accelerate,libmvec,MASSV,SVML,Darwin_libsystem_m,none">, NormalizedValuesScope<"CodeGenOptions">, - NormalizedValues<["Accelerate", "LIBMVEC", "MASSV", "SVML", "NoLibrary"]>, - MarshallingInfoString<CodeGenOpts<"VecLib">, "NoLibrary">, AutoNormalizeEnum; + NormalizedValues<["Accelerate", "LIBMVEC", "MASSV", "SVML", + "Darwin_libsystem_m", "NoLibrary"]>, + MarshallingInfoEnum<CodeGenOpts<"VecLib">, "NoLibrary">; def fno_lax_vector_conversions : Flag<["-"], "fno-lax-vector-conversions">, Group<f_Group>, Alias<flax_vector_conversions_EQ>, AliasArgs<["none"]>; -def fno_modules : Flag <["-"], "fno-modules">, Group<f_Group>, - Flags<[NoXarchOption]>; def fno_implicit_module_maps : Flag <["-"], "fno-implicit-module-maps">, Group<f_Group>, Flags<[NoXarchOption]>; def fno_module_maps : Flag <["-"], "fno-module-maps">, Alias<fno_implicit_module_maps>; -def fno_modules_decluse : Flag <["-"], "fno-modules-decluse">, Group<f_Group>, - Flags<[NoXarchOption]>; def fno_modules_strict_decluse : Flag <["-"], "fno-strict-modules-decluse">, Group<f_Group>, Flags<[NoXarchOption]>; def fmodule_file_deps : Flag <["-"], "fmodule-file-deps">, Group<f_Group>, @@ -2021,9 +2244,10 @@ def fno_ms_compatibility : Flag<["-"], "fno-ms-compatibility">, Group<f_Group>, def fno_objc_legacy_dispatch : Flag<["-"], "fno-objc-legacy-dispatch">, Group<f_Group>; def fno_objc_weak : Flag<["-"], "fno-objc-weak">, Group<f_Group>, Flags<[CC1Option]>; def fno_omit_frame_pointer : Flag<["-"], "fno-omit-frame-pointer">, Group<f_Group>; -def fno_operator_names : Flag<["-"], "fno-operator-names">, Group<f_Group>, - HelpText<"Do not treat C++ operator name keywords as synonyms for operators">, - Flags<[CC1Option]>; +defm operator_names : BoolFOption<"operator-names", + LangOpts<"CXXOperatorNames">, Default<cplusplus.KeyPath>, + NegFlag<SetFalse, [CC1Option], "Do not treat C++ operator name keywords as synonyms for operators">, + PosFlag<SetTrue>>; def fdiagnostics_absolute_paths : Flag<["-"], "fdiagnostics-absolute-paths">, Group<f_Group>, Flags<[CC1Option, CoreOption]>, HelpText<"Print absolute paths in diagnostics">, MarshallingInfoFlag<DiagnosticOpts<"AbsolutePath">>; @@ -2052,12 +2276,17 @@ def fno_wrapv : Flag<["-"], "fno-wrapv">, Group<f_Group>; def fobjc_arc : Flag<["-"], "fobjc-arc">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Synthesize retain and release calls for Objective-C pointers">; def fno_objc_arc : Flag<["-"], "fno-objc-arc">, Group<f_Group>; +defm objc_encode_cxx_class_template_spec : BoolFOption<"objc-encode-cxx-class-template-spec", + LangOpts<"EncodeCXXClassTemplateSpec">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Fully encode c++ class template specialization">, + NegFlag<SetFalse>>; defm objc_convert_messages_to_runtime_calls : BoolFOption<"objc-convert-messages-to-runtime-calls", CodeGenOpts<"ObjCConvertMessagesToRuntimeCalls">, DefaultTrue, NegFlag<SetFalse, [CC1Option]>, PosFlag<SetTrue>>; -defm objc_arc_exceptions : OptInFFlag<"objc-arc-exceptions", - "Use EH-safe code when synthesizing retains and releases in -fobjc-arc", - "", "", [], CodeGenOpts<"ObjCAutoRefCountExceptions">>; +defm objc_arc_exceptions : BoolFOption<"objc-arc-exceptions", + CodeGenOpts<"ObjCAutoRefCountExceptions">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Use EH-safe code when synthesizing retains and releases in -fobjc-arc">, + NegFlag<SetFalse>>; def fobjc_atdefs : Flag<["-"], "fobjc-atdefs">, Group<clang_ignored_f_Group>; def fobjc_call_cxx_cdtors : Flag<["-"], "fobjc-call-cxx-cdtors">, Group<clang_ignored_f_Group>; defm objc_exceptions : BoolFOption<"objc-exceptions", @@ -2075,14 +2304,14 @@ defm sized_deallocation : BoolFOption<"sized-deallocation", LangOpts<"SizedDeallocation">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Enable C++14 sized global deallocation functions">, NegFlag<SetFalse>>; -def faligned_allocation : Flag<["-"], "faligned-allocation">, Flags<[CC1Option]>, - HelpText<"Enable C++17 aligned allocation functions">, Group<f_Group>; -def fno_aligned_allocation: Flag<["-"], "fno-aligned-allocation">, - Group<f_Group>, Flags<[CC1Option]>; +defm aligned_allocation : BoolFOption<"aligned-allocation", + LangOpts<"AlignedAllocation">, Default<cpp17.KeyPath>, + PosFlag<SetTrue, [], "Enable C++17 aligned allocation functions">, + NegFlag<SetFalse>, BothFlags<[CC1Option]>>; def fnew_alignment_EQ : Joined<["-"], "fnew-alignment=">, HelpText<"Specifies the largest alignment guaranteed by '::operator new(size_t)'">, MetaVarName<"<align>">, Group<f_Group>, Flags<[CC1Option]>, - MarshallingInfoStringInt<LangOpts<"NewAlignOverride">>; + MarshallingInfoInt<LangOpts<"NewAlignOverride">>; def : Separate<["-"], "fnew-alignment">, Alias<fnew_alignment_EQ>; def : Flag<["-"], "faligned-new">, Alias<faligned_allocation>; def : Flag<["-"], "fno-aligned-new">, Alias<fno_aligned_allocation>; @@ -2107,10 +2336,15 @@ def fobjc_nonfragile_abi : Flag<["-"], "fobjc-nonfragile-abi">, Group<f_Group>; def fno_objc_nonfragile_abi : Flag<["-"], "fno-objc-nonfragile-abi">, Group<f_Group>; def fobjc_sender_dependent_dispatch : Flag<["-"], "fobjc-sender-dependent-dispatch">, Group<f_Group>; +def fobjc_disable_direct_methods_for_testing : + Flag<["-"], "fobjc-disable-direct-methods-for-testing">, + Group<f_Group>, Flags<[CC1Option]>, + HelpText<"Ignore attribute objc_direct so that direct methods can be tested">, + MarshallingInfoFlag<LangOpts<"ObjCDisableDirectMethodsForTesting">>; + def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group<f_Group>; -def fopenmp : Flag<["-"], "fopenmp">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>, - HelpText<"Parse OpenMP pragmas and generate parallel code.">, - MarshallingInfoFlag<LangOpts<"OpenMP">, "0u">, Normalizer<"makeFlagToValueNormalizer(50u)">; +def fopenmp : Flag<["-"], "fopenmp">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused, FlangOption, FC1Option]>, + HelpText<"Parse OpenMP pragmas and generate parallel code.">; def fno_openmp : Flag<["-"], "fno-openmp">, Group<f_Group>, Flags<[NoArgumentUnused]>; def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>; def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group<f_Group>; @@ -2143,15 +2377,13 @@ def fopenmp_cuda_blocks_per_sm_EQ : Joined<["-"], "fopenmp-cuda-blocks-per-sm="> Flags<[CC1Option, NoArgumentUnused, HelpHidden]>; def fopenmp_cuda_teams_reduction_recs_num_EQ : Joined<["-"], "fopenmp-cuda-teams-reduction-recs-num=">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>; +defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime", + LangOpts<"OpenMPTargetNewRuntime">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Use the new bitcode library for OpenMP offloading">, + NegFlag<SetFalse>>; defm openmp_optimistic_collapse : BoolFOption<"openmp-optimistic-collapse", LangOpts<"OpenMPOptimisticCollapse">, DefaultFalse, PosFlag<SetTrue, [CC1Option]>, NegFlag<SetFalse>, BothFlags<[NoArgumentUnused, HelpHidden]>>; -def fopenmp_cuda_parallel_target_regions : Flag<["-"], "fopenmp-cuda-parallel-target-regions">, Group<f_Group>, - Flags<[CC1Option, NoArgumentUnused, HelpHidden]>, - HelpText<"Support parallel execution of target regions on Cuda-based devices.">; -def fno_openmp_cuda_parallel_target_regions : Flag<["-"], "fno-openmp-cuda-parallel-target-regions">, Group<f_Group>, - Flags<[NoArgumentUnused, HelpHidden]>, - HelpText<"Support only serial execution of target regions on Cuda-based devices.">; def static_openmp: Flag<["-"], "static-openmp">, HelpText<"Use the static host OpenMP runtime while linking.">; def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, Group<f_Group>; @@ -2168,10 +2400,10 @@ def fpack_struct : Flag<["-"], "fpack-struct">, Group<f_Group>; def fno_pack_struct : Flag<["-"], "fno-pack-struct">, Group<f_Group>; def fpack_struct_EQ : Joined<["-"], "fpack-struct=">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Specify the default maximum struct packing alignment">, - MarshallingInfoStringInt<LangOpts<"PackStruct">>; + MarshallingInfoInt<LangOpts<"PackStruct">>; def fmax_type_align_EQ : Joined<["-"], "fmax-type-align=">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Specify the maximum alignment to enforce on pointers lacking an explicit alignment">, - MarshallingInfoStringInt<LangOpts<"MaxTypeAlign">>; + MarshallingInfoInt<LangOpts<"MaxTypeAlign">>; def fno_max_type_align : Flag<["-"], "fno-max-type-align">, Group<f_Group>; defm pascal_strings : BoolFOption<"pascal-strings", LangOpts<"PascalStrings">, DefaultFalse, @@ -2182,7 +2414,7 @@ defm pascal_strings : BoolFOption<"pascal-strings", // are treated as a single integer. def fpatchable_function_entry_EQ : Joined<["-"], "fpatchable-function-entry=">, Group<f_Group>, Flags<[CC1Option]>, MetaVarName<"<N,M>">, HelpText<"Generate M NOPs before function entry and N-M NOPs after function entry">, - MarshallingInfoStringInt<CodeGenOpts<"PatchableFunctionEntryCount">>; + MarshallingInfoInt<CodeGenOpts<"PatchableFunctionEntryCount">>; def fpcc_struct_return : Flag<["-"], "fpcc-struct-return">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Override the default ABI to return all structs on the stack">; def fpch_preprocess : Flag<["-"], "fpch-preprocess">, Group<f_Group>; @@ -2220,18 +2452,24 @@ def framework : Separate<["-"], "framework">, Flags<[LinkerInput]>; def frandom_seed_EQ : Joined<["-"], "frandom-seed=">, Group<clang_ignored_f_Group>; def freg_struct_return : Flag<["-"], "freg-struct-return">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Override the default ABI to return small structs in registers">; -defm rtti : OptOutFFlag<"rtti", "", "Disable generation of rtti information">; -defm rtti_data : OptOutFFlag<"rtti-data", "", "Disable generation of RTTI data">; +defm rtti : BoolFOption<"rtti", + LangOpts<"RTTI">, Default<cplusplus.KeyPath>, + NegFlag<SetFalse, [CC1Option], "Disable generation of rtti information">, + PosFlag<SetTrue>>, ShouldParseIf<cplusplus.KeyPath>; +defm rtti_data : BoolFOption<"rtti-data", + LangOpts<"RTTIData">, Default<frtti.KeyPath>, + NegFlag<SetFalse, [CC1Option], "Disable generation of RTTI data">, + PosFlag<SetTrue>>, ShouldParseIf<frtti.KeyPath>; def : Flag<["-"], "fsched-interblock">, Group<clang_ignored_f_Group>; defm short_enums : BoolFOption<"short-enums", LangOpts<"ShortEnums">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Allocate to an enum type only as many bytes as it" " needs for the declared range of possible values">, NegFlag<SetFalse>>; -def fchar8__t : Flag<["-"], "fchar8_t">, Group<f_Group>, Flags<[CC1Option]>, - HelpText<"Enable C++ builtin type char8_t">; -def fno_char8__t : Flag<["-"], "fno-char8_t">, Group<f_Group>, Flags<[CC1Option]>, - HelpText<"Disable C++ builtin type char8_t">; +defm char8__t : BoolFOption<"char8_t", + LangOpts<"Char8">, Default<cpp20.KeyPath>, + PosFlag<SetTrue, [], "Enable">, NegFlag<SetFalse, [], "Disable">, + BothFlags<[CC1Option], " C++ builtin type char8_t">>; def fshort_wchar : Flag<["-"], "fshort-wchar">, Group<f_Group>, HelpText<"Force wchar_t to be a short unsigned int">; def fno_short_wchar : Flag<["-"], "fno-short-wchar">, Group<f_Group>, @@ -2240,7 +2478,7 @@ def fshow_overloads_EQ : Joined<["-"], "fshow-overloads=">, Group<f_Group>, Flag HelpText<"Which overload candidates to show when overload resolution fails: " "best|all; defaults to all">, Values<"best,all">, NormalizedValues<["Ovl_Best", "Ovl_All"]>, - MarshallingInfoString<DiagnosticOpts<"ShowOverloads">, "Ovl_All">, AutoNormalizeEnum; + MarshallingInfoEnum<DiagnosticOpts<"ShowOverloads">, "Ovl_All">; defm show_column : BoolFOption<"show-column", DiagnosticOpts<"ShowColumn">, DefaultTrue, NegFlag<SetFalse, [CC1Option], "Do not include column number on diagnostics">, @@ -2254,8 +2492,14 @@ defm spell_checking : BoolFOption<"spell-checking", NegFlag<SetFalse, [CC1Option], "Disable spell-checking">, PosFlag<SetTrue>>; def fspell_checking_limit_EQ : Joined<["-"], "fspell-checking-limit=">, Group<f_Group>; def fsigned_bitfields : Flag<["-"], "fsigned-bitfields">, Group<f_Group>; -defm signed_char : OptOutFFlag<"signed-char", "char is signed", "char is unsigned">; -def fsplit_stack : Flag<["-"], "fsplit-stack">, Group<f_Group>; +defm signed_char : BoolFOption<"signed-char", + LangOpts<"CharIsSigned">, DefaultTrue, + NegFlag<SetFalse, [CC1Option], "char is unsigned">, PosFlag<SetTrue, [], "char is signed">>, + ShouldParseIf<!strconcat("!", open_cl.KeyPath)>; +defm split_stack : BoolFOption<"split-stack", + CodeGenOpts<"EnableSegmentedStacks">, DefaultFalse, + NegFlag<SetFalse, [], "Wouldn't use segmented stack">, + PosFlag<SetTrue, [CC1Option], "Use segmented stack">>; def fstack_protector_all : Flag<["-"], "fstack-protector-all">, Group<f_Group>, HelpText<"Enable stack protectors for all functions">; defm stack_clash_protection : BoolFOption<"stack-clash-protection", @@ -2283,13 +2527,13 @@ def ftrivial_auto_var_init : Joined<["-"], "ftrivial-auto-var-init=">, Group<f_G " | pattern">, Values<"uninitialized,zero,pattern">, NormalizedValuesScope<"LangOptions::TrivialAutoVarInitKind">, NormalizedValues<["Uninitialized", "Zero", "Pattern"]>, - MarshallingInfoString<LangOpts<"TrivialAutoVarInit">, "Uninitialized">, AutoNormalizeEnum; + MarshallingInfoEnum<LangOpts<"TrivialAutoVarInit">, "Uninitialized">; def enable_trivial_var_init_zero : Flag<["-"], "enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang">, Flags<[CC1Option, CoreOption]>, HelpText<"Trivial automatic variable initialization to zero is only here for benchmarks, it'll eventually be removed, and I'm OK with that because I'm only using it to benchmark">; def ftrivial_auto_var_init_stop_after : Joined<["-"], "ftrivial-auto-var-init-stop-after=">, Group<f_Group>, Flags<[CC1Option, CoreOption]>, HelpText<"Stop initializing trivial automatic stack variables after the specified number of instances">, - MarshallingInfoStringInt<LangOpts<"TrivialAutoVarInitStopAfter">>; + MarshallingInfoInt<LangOpts<"TrivialAutoVarInitStopAfter">>; def fstandalone_debug : Flag<["-"], "fstandalone-debug">, Group<f_Group>, Flags<[CoreOption]>, HelpText<"Emit full debug info for all types used by the program">; def fno_standalone_debug : Flag<["-"], "fno-standalone-debug">, Group<f_Group>, Flags<[CoreOption]>, @@ -2352,13 +2596,18 @@ def Wlarge_by_value_copy_def : Flag<["-"], "Wlarge-by-value-copy">, HelpText<"Warn if a function definition returns or accepts an object larger " "in bytes than a given value">, Flags<[HelpHidden]>; def Wlarge_by_value_copy_EQ : Joined<["-"], "Wlarge-by-value-copy=">, Flags<[CC1Option]>, - MarshallingInfoStringInt<LangOpts<"NumLargeByValueCopy">>; + MarshallingInfoInt<LangOpts<"NumLargeByValueCopy">>; // These "special" warning flags are effectively processed as f_Group flags by the driver: // Just silence warnings about -Wlarger-than for now. def Wlarger_than_EQ : Joined<["-"], "Wlarger-than=">, Group<clang_ignored_f_Group>; def Wlarger_than_ : Joined<["-"], "Wlarger-than-">, Alias<Wlarger_than_EQ>; -def Wframe_larger_than_EQ : Joined<["-"], "Wframe-larger-than=">, Group<f_Group>, Flags<[NoXarchOption]>; + +// This is converted to -fwarn-stack-size=N and also passed through by the driver. +// FIXME: The driver should strip out the =<value> when passing W_value_Group through. +def Wframe_larger_than_EQ : Joined<["-"], "Wframe-larger-than=">, Group<W_value_Group>, + Flags<[NoXarchOption, CC1Option]>; +def Wframe_larger_than : Flag<["-"], "Wframe-larger-than">, Alias<Wframe_larger_than_EQ>; def : Flag<["-"], "fterminated-vtables">, Alias<fapple_kext>; defm threadsafe_statics : BoolFOption<"threadsafe-statics", @@ -2383,7 +2632,7 @@ can be analyzed with chrome://tracing or `Speedscope App def ftime_trace_granularity_EQ : Joined<["-"], "ftime-trace-granularity=">, Group<f_Group>, HelpText<"Minimum time granularity (in microseconds) traced by time profiler">, Flags<[CC1Option, CoreOption]>, - MarshallingInfoStringInt<FrontendOpts<"TimeTraceGranularity">, "500u">; + MarshallingInfoInt<FrontendOpts<"TimeTraceGranularity">, "500u">; def fproc_stat_report : Joined<["-"], "fproc-stat-report">, Group<f_Group>, HelpText<"Print subprocess statistics">; def fproc_stat_report_EQ : Joined<["-"], "fproc-stat-report=">, Group<f_Group>, @@ -2392,7 +2641,7 @@ def ftlsmodel_EQ : Joined<["-"], "ftls-model=">, Group<f_Group>, Flags<[CC1Optio Values<"global-dynamic,local-dynamic,initial-exec,local-exec">, NormalizedValuesScope<"CodeGenOptions">, NormalizedValues<["GeneralDynamicTLSModel", "LocalDynamicTLSModel", "InitialExecTLSModel", "LocalExecTLSModel"]>, - MarshallingInfoString<CodeGenOpts<"DefaultTLSModel">, "GeneralDynamicTLSModel">, AutoNormalizeEnum; + MarshallingInfoEnum<CodeGenOpts<"DefaultTLSModel">, "GeneralDynamicTLSModel">; def ftrapv : Flag<["-"], "ftrapv">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Trap on integer overflow">; def ftrapv_handler_EQ : Joined<["-"], "ftrapv-handler=">, Group<f_Group>, @@ -2410,6 +2659,11 @@ def fno_unroll_loops : Flag<["-"], "fno-unroll-loops">, Group<f_Group>, defm reroll_loops : BoolFOption<"reroll-loops", CodeGenOpts<"RerollLoops">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Turn on loop reroller">, NegFlag<SetFalse>>; +def ffinite_loops: Flag<["-"], "ffinite-loops">, Group<f_Group>, + HelpText<"Assume all loops are finite.">, Flags<[CC1Option]>; +def fno_finite_loops: Flag<["-"], "fno-finite-loops">, Group<f_Group>, + HelpText<"Do not assume that any loop is finite.">, Flags<[CC1Option]>; + def ftrigraphs : Flag<["-"], "ftrigraphs">, Group<f_Group>, HelpText<"Process trigraph sequences">, Flags<[CC1Option]>; def fno_trigraphs : Flag<["-"], "fno-trigraphs">, Group<f_Group>, @@ -2452,9 +2706,10 @@ def fvisibility_externs_nodllstorageclass_EQ : Joined<["-"], "fvisibility-extern ShouldParseIf<fvisibility_from_dllstorageclass.KeyPath>; def fvisibility_EQ : Joined<["-"], "fvisibility=">, Group<f_Group>, HelpText<"Set the default symbol visibility for all global declarations">, Values<"hidden,default">; -def fvisibility_inlines_hidden : Flag<["-"], "fvisibility-inlines-hidden">, Group<f_Group>, - HelpText<"Give inline C++ member functions hidden visibility by default">, - Flags<[CC1Option]>, MarshallingInfoFlag<LangOpts<"InlineVisibilityHidden">>; +defm visibility_inlines_hidden : BoolFOption<"visibility-inlines-hidden", + LangOpts<"InlineVisibilityHidden">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Give inline C++ member functions hidden visibility by default">, + NegFlag<SetFalse>>; defm visibility_inlines_hidden_static_local_var : BoolFOption<"visibility-inlines-hidden-static-local-var", LangOpts<"VisibilityInlinesHiddenStaticLocalVar">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "When -fvisibility-inlines-hidden is enabled, static variables in" @@ -2493,7 +2748,10 @@ defm zero_initialized_in_bss : BoolFOption<"zero-initialized-in-bss", CodeGenOpts<"NoZeroInitializedInBSS">, DefaultFalse, NegFlag<SetTrue, [CC1Option], "Don't place zero initialized data in BSS">, PosFlag<SetFalse>>; -defm function_sections : OptInFFlag<"function-sections", "Place each function in its own section">; +defm function_sections : BoolFOption<"function-sections", + CodeGenOpts<"FunctionSections">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Place each function in its own section">, + NegFlag<SetFalse>>; def fbasic_block_sections_EQ : Joined<["-"], "fbasic-block-sections=">, Group<f_Group>, Flags<[CC1Option, CC1AsOption]>, HelpText<"Place each function's basic blocks in unique sections (ELF Only) : all | labels | none | list=<file>">, @@ -2507,6 +2765,12 @@ defm stack_size_section : BoolFOption<"stack-size-section", CodeGenOpts<"StackSizeSection">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Emit section containing metadata on function stack sizes">, NegFlag<SetFalse>>; +def fstack_usage : Flag<["-"], "fstack-usage">, Group<f_Group>, + HelpText<"Emit .su file containing information on function stack sizes">; +def stack_usage_file : Separate<["-"], "stack-usage-file">, + Flags<[CC1Option, NoDriverOption]>, + HelpText<"Filename (or -) to write stack usage output to">, + MarshallingInfoString<CodeGenOpts<"StackUsageOutput">>; defm unique_basic_block_section_names : BoolFOption<"unique-basic-block-section-names", CodeGenOpts<"UniqueBasicBlockSectionNames">, DefaultFalse, @@ -2547,9 +2811,9 @@ defm debug_ranges_base_address : BoolFOption<"debug-ranges-base-address", PosFlag<SetTrue, [CC1Option], "Use DWARF base address selection entries in .debug_ranges">, NegFlag<SetFalse>>; defm split_dwarf_inlining : BoolFOption<"split-dwarf-inlining", - CodeGenOpts<"SplitDwarfInlining">, DefaultTrue, - NegFlag<SetFalse, [CC1Option]>, - PosFlag<SetTrue, [], "Provide minimal debug info in the object/executable" + CodeGenOpts<"SplitDwarfInlining">, DefaultFalse, + NegFlag<SetFalse, []>, + PosFlag<SetTrue, [CC1Option], "Provide minimal debug info in the object/executable" " to facilitate online symbolication/stack traces in the absence of" " .dwo/.dwp files when using Split DWARF">>; def fdebug_default_version: Joined<["-"], "fdebug-default-version=">, Group<f_Group>, @@ -2558,10 +2822,10 @@ def fdebug_prefix_map_EQ : Joined<["-"], "fdebug-prefix-map=">, Group<f_Group>, Flags<[CC1Option,CC1AsOption]>, HelpText<"remap file source paths in debug info">; -def fprofile_prefix_map_EQ - : Joined<["-"], "fprofile-prefix-map=">, Group<f_Group>, +def fcoverage_prefix_map_EQ + : Joined<["-"], "fcoverage-prefix-map=">, Group<f_Group>, Flags<[CC1Option]>, - HelpText<"remap file source paths in coverage info">; + HelpText<"remap file source paths in coverage mapping">; def ffile_prefix_map_EQ : Joined<["-"], "ffile-prefix-map=">, Group<f_Group>, HelpText<"remap file source paths in debug info and predefined preprocessor macros">; @@ -2589,6 +2853,7 @@ def ggdb2 : Flag<["-"], "ggdb2">, Group<ggdbN_Group>; def ggdb3 : Flag<["-"], "ggdb3">, Group<ggdbN_Group>; def glldb : Flag<["-"], "glldb">, Group<gTune_Group>; def gsce : Flag<["-"], "gsce">, Group<gTune_Group>; +def gdbx : Flag<["-"], "gdbx">, Group<gTune_Group>; // Equivalent to our default dwarf version. Forces usual dwarf emission when // CodeView is enabled. def gdwarf : Flag<["-"], "gdwarf">, Group<g_Group>, Flags<[CoreOption]>, @@ -2601,10 +2866,12 @@ def gdwarf_4 : Flag<["-"], "gdwarf-4">, Group<g_Group>, HelpText<"Generate source-level debug information with dwarf version 4">; def gdwarf_5 : Flag<["-"], "gdwarf-5">, Group<g_Group>, HelpText<"Generate source-level debug information with dwarf version 5">; -def gdwarf64 : Flag<["-"], "gdwarf64">, Group<g_Group>, Flags<[CC1Option]>, +def gdwarf64 : Flag<["-"], "gdwarf64">, Group<g_Group>, + Flags<[CC1Option, CC1AsOption]>, HelpText<"Enables DWARF64 format for ELF binaries, if debug information emission is enabled.">, MarshallingInfoFlag<CodeGenOpts<"Dwarf64">>; -def gdwarf32 : Flag<["-"], "gdwarf32">, Group<g_Group>, Flags<[CC1Option]>, +def gdwarf32 : Flag<["-"], "gdwarf32">, Group<g_Group>, + Flags<[CC1Option, CC1AsOption]>, HelpText<"Enables DWARF32 format for ELF binaries, if debug information emission is enabled.">; def gcodeview : Flag<["-"], "gcodeview">, @@ -2633,8 +2900,10 @@ def gno_record_command_line : Flag<["-"], "gno-record-command-line">, Group<g_flags_Group>; def : Flag<["-"], "grecord-gcc-switches">, Alias<grecord_command_line>; def : Flag<["-"], "gno-record-gcc-switches">, Alias<gno_record_command_line>; -def gstrict_dwarf : Flag<["-"], "gstrict-dwarf">, Group<g_flags_Group>; -def gno_strict_dwarf : Flag<["-"], "gno-strict-dwarf">, Group<g_flags_Group>; +defm strict_dwarf : BoolOption<"g", "strict-dwarf", + CodeGenOpts<"DebugStrictDwarf">, DefaultFalse, + PosFlag<SetTrue, [CC1Option]>, NegFlag<SetFalse>, BothFlags<[CoreOption]>>, + Group<g_flags_Group>; defm column_info : BoolOption<"g", "column-info", CodeGenOpts<"DebugColumnInfo">, DefaultTrue, NegFlag<SetFalse, [CC1Option]>, PosFlag<SetTrue>, BothFlags<[CoreOption]>>, @@ -2757,7 +3026,7 @@ def mlong_calls : Flag<["-"], "mlong-calls">, Group<m_Group>, HelpText<"Generate branches with extended addressability, usually via indirect jumps.">; def mdouble_EQ : Joined<["-"], "mdouble=">, Group<m_Group>, Values<"32,64">, Flags<[CC1Option]>, HelpText<"Force double to be 32 bits or 64 bits">, - MarshallingInfoStringInt<LangOpts<"DoubleSize">, "0">; + MarshallingInfoInt<LangOpts<"DoubleSize">, "0">; def LongDouble_Group : OptionGroup<"<LongDouble group>">, Group<m_Group>, DocName<"Long double flags">, DocBrief<[{Selects the long double implementation}]>; @@ -2791,7 +3060,7 @@ def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group<m_Group>, Flags<[CC1Option]>, def mtls_size_EQ : Joined<["-"], "mtls-size=">, Group<m_Group>, Flags<[NoXarchOption, CC1Option]>, HelpText<"Specify bit size of immediate TLS offsets (AArch64 ELF only): " "12 (for 4KB) | 24 (for 16MB, default) | 32 (for 4GB) | 48 (for 256TB, needs -mcmodel=large)">, - MarshallingInfoStringInt<CodeGenOpts<"TLSSize">>; + MarshallingInfoInt<CodeGenOpts<"TLSSize">>; def mimplicit_it_EQ : Joined<["-"], "mimplicit-it=">, Group<m_Group>; def mdefault_build_attributes : Joined<["-"], "mdefault-build-attributes">, Group<m_Group>; def mno_default_build_attributes : Joined<["-"], "mno-default-build-attributes">, Group<m_Group>; @@ -2849,22 +3118,24 @@ def mstackrealign : Flag<["-"], "mstackrealign">, Group<m_Group>, Flags<[CC1Opti MarshallingInfoFlag<CodeGenOpts<"StackRealignment">>; def mstack_alignment : Joined<["-"], "mstack-alignment=">, Group<m_Group>, Flags<[CC1Option]>, HelpText<"Set the stack alignment">, - MarshallingInfoStringInt<CodeGenOpts<"StackAlignment">>; + MarshallingInfoInt<CodeGenOpts<"StackAlignment">>; def mstack_probe_size : Joined<["-"], "mstack-probe-size=">, Group<m_Group>, Flags<[CC1Option]>, HelpText<"Set the stack probe size">, - MarshallingInfoStringInt<CodeGenOpts<"StackProbeSize">, "4096">; + MarshallingInfoInt<CodeGenOpts<"StackProbeSize">, "4096">; def mstack_arg_probe : Flag<["-"], "mstack-arg-probe">, Group<m_Group>, HelpText<"Enable stack probes">; def mno_stack_arg_probe : Flag<["-"], "mno-stack-arg-probe">, Group<m_Group>, Flags<[CC1Option]>, HelpText<"Disable stack probes which are enabled by default">, MarshallingInfoFlag<CodeGenOpts<"NoStackArgProbe">>; def mthread_model : Separate<["-"], "mthread-model">, Group<m_Group>, Flags<[CC1Option]>, - HelpText<"The thread model to use, e.g. posix, single (posix by default)">, Values<"posix,single">; + HelpText<"The thread model to use, e.g. posix, single (posix by default)">, Values<"posix,single">, + NormalizedValues<["POSIX", "Single"]>, NormalizedValuesScope<"LangOptions::ThreadModelKind">, + MarshallingInfoEnum<LangOpts<"ThreadModel">, "POSIX">; def meabi : Separate<["-"], "meabi">, Group<m_Group>, Flags<[CC1Option]>, HelpText<"Set EABI type, e.g. 4, 5 or gnu (default depends on triple)">, Values<"default,4,5,gnu">, - MarshallingInfoString<TargetOpts<"EABIVersion">, "Default">, + MarshallingInfoEnum<TargetOpts<"EABIVersion">, "Default">, NormalizedValuesScope<"llvm::EABI">, - NormalizedValues<["Default", "EABI4", "EABI5", "GNU"]>, AutoNormalizeEnum; + NormalizedValues<["Default", "EABI4", "EABI5", "GNU"]>; def mno_constant_cfstrings : Flag<["-"], "mno-constant-cfstrings">, Group<m_Group>; def mno_global_merge : Flag<["-"], "mno-global-merge">, Group<m_Group>, Flags<[CC1Option]>, @@ -2957,8 +3228,8 @@ defm aapcs_bitfield_width : BoolOption<"f", "aapcs-bitfield-width", " volatile bit-field width is dictated by the field container type. (ARM only).">>, Group<m_arm_Features_Group>; -def mgeneral_regs_only : Flag<["-"], "mgeneral-regs-only">, Group<m_aarch64_Features_Group>, - HelpText<"Generate code which only uses the general purpose registers (AArch64 only)">; +def mgeneral_regs_only : Flag<["-"], "mgeneral-regs-only">, Group<m_Group>, + HelpText<"Generate code which only uses the general purpose registers (AArch64/x86 only)">; def mfix_cortex_a53_835769 : Flag<["-"], "mfix-cortex-a53-835769">, Group<m_aarch64_Features_Group>, HelpText<"Workaround Cortex-A53 erratum 835769 (AArch64 only)">; @@ -2980,7 +3251,9 @@ def msve_vector_bits_EQ : Joined<["-"], "msve-vector-bits=">, Group<m_aarch64_Features_Group>, Flags<[NoXarchOption,CC1Option]>, HelpText<"Specify the size in bits of an SVE vector register. Defaults to the" " vector length agnostic value of \"scalable\". (AArch64 only)">, - Values<"128,256,512,1024,2048,scalable">; + Values<"128,256,512,1024,2048,scalable">, + NormalizedValues<["128", "256", "512", "1024", "2048", "0"]>, + MarshallingInfoEnum<LangOpts<"ArmSveVectorBits">, "0">; def msign_return_address_EQ : Joined<["-"], "msign-return-address=">, Flags<[CC1Option]>, Group<m_Group>, Values<"none,all,non-leaf">, @@ -2992,8 +3265,6 @@ def mharden_sls_EQ : Joined<["-"], "mharden-sls=">, HelpText<"Select straight-line speculation hardening scope">; def msimd128 : Flag<["-"], "msimd128">, Group<m_wasm_Features_Group>; -def munimplemented_simd128 : Flag<["-"], "munimplemented-simd128">, Group<m_wasm_Features_Group>; -def mno_unimplemented_simd128 : Flag<["-"], "mno-unimplemented-simd128">, Group<m_wasm_Features_Group>; def mno_simd128 : Flag<["-"], "mno-simd128">, Group<m_wasm_Features_Group>; def mnontrapping_fptoint : Flag<["-"], "mnontrapping-fptoint">, Group<m_wasm_Features_Group>; def mno_nontrapping_fptoint : Flag<["-"], "mno-nontrapping-fptoint">, Group<m_wasm_Features_Group>; @@ -3017,22 +3288,30 @@ def mexec_model_EQ : Joined<["-"], "mexec-model=">, Group<m_wasm_Features_Driver Values<"command,reactor">, HelpText<"Execution model (WebAssembly only)">; +defm amdgpu_ieee : BoolOption<"m", "amdgpu-ieee", + CodeGenOpts<"EmitIEEENaNCompliantInsts">, DefaultTrue, + PosFlag<SetTrue, [], "Sets the IEEE bit in the expected default floating point " + " mode register. Floating point opcodes that support exception flag " + "gathering quiet and propagate signaling NaN inputs per IEEE 754-2008. " + "This option changes the ABI. (AMDGPU only)">, + NegFlag<SetFalse, [CC1Option]>>, Group<m_Group>; + def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, Group<m_Group>, HelpText<"Specify code object ABI version. Defaults to 3. (AMDGPU only)">, MetaVarName<"<version>">, Values<"2,3,4">; -def mcode_object_v3_legacy : Flag<["-"], "mcode-object-v3">, Group<m_Group>, - HelpText<"Legacy option to specify code object ABI V2 (-mnocode-object-v3) or V3 (-mcode-object-v3) (AMDGPU only)">; -def mno_code_object_v3_legacy : Flag<["-"], "mno-code-object-v3">, Group<m_Group>; - -def mcumode : Flag<["-"], "mcumode">, Group<m_amdgpu_Features_Group>, - HelpText<"Specify CU (-mcumode) or WGP (-mno-cumode) wavefront execution mode (AMDGPU only)">; -def mno_cumode : Flag<["-"], "mno-cumode">, Group<m_amdgpu_Features_Group>; - -def mwavefrontsize64 : Flag<["-"], "mwavefrontsize64">, Group<m_Group>, - HelpText<"Specify wavefront size 64 mode (AMDGPU only)">; -def mno_wavefrontsize64 : Flag<["-"], "mno-wavefrontsize64">, Group<m_Group>, - HelpText<"Specify wavefront size 32 mode (AMDGPU only)">; +defm code_object_v3_legacy : SimpleMFlag<"code-object-v3", + "Legacy option to specify code object ABI V3", + "Legacy option to specify code object ABI V2", + " (AMDGPU only)">; +defm cumode : SimpleMFlag<"cumode", + "Specify CU wavefront", "Specify WGP wavefront", + " execution mode (AMDGPU only)", m_amdgpu_Features_Group>; +defm tgsplit : SimpleMFlag<"tgsplit", "Enable", "Disable", + " threadgroup split execution mode (AMDGPU only)", m_amdgpu_Features_Group>; +defm wavefrontsize64 : SimpleMFlag<"wavefrontsize64", + "Specify wavefront size 64", "Specify wavefront size 32", + " mode (AMDGPU only)">; defm unsafe_fp_atomics : BoolOption<"m", "unsafe-fp-atomics", TargetOpts<"AllowAMDGPUUnsafeFPAtomics">, DefaultFalse, @@ -3045,11 +3324,14 @@ def maltivec : Flag<["-"], "maltivec">, Group<m_ppc_Features_Group>; def mno_altivec : Flag<["-"], "mno-altivec">, Group<m_ppc_Features_Group>; def mpcrel: Flag<["-"], "mpcrel">, Group<m_ppc_Features_Group>; def mno_pcrel: Flag<["-"], "mno-pcrel">, Group<m_ppc_Features_Group>; +def mprefixed: Flag<["-"], "mprefixed">, Group<m_ppc_Features_Group>; +def mno_prefixed: Flag<["-"], "mno-prefixed">, Group<m_ppc_Features_Group>; def mspe : Flag<["-"], "mspe">, Group<m_ppc_Features_Group>; def mno_spe : Flag<["-"], "mno-spe">, Group<m_ppc_Features_Group>; def mefpu2 : Flag<["-"], "mefpu2">, Group<m_ppc_Features_Group>; def mabi_EQ_vec_extabi : Flag<["-"], "mabi=vec-extabi">, Group<m_Group>, Flags<[CC1Option]>, - HelpText<"Enable the extended Altivec ABI on AIX (AIX only). Uses volatile and nonvolatile vector registers">; + HelpText<"Enable the extended Altivec ABI on AIX (AIX only). Uses volatile and nonvolatile vector registers">, + MarshallingInfoFlag<LangOpts<"EnableAIXExtendedAltivecABI">>; def mabi_EQ_vec_default : Flag<["-"], "mabi=vec-default">, Group<m_Group>, Flags<[CC1Option]>, HelpText<"Enable the default Altivec ABI on AIX (AIX only). Uses only volatile vector registers.">; def mvsx : Flag<["-"], "mvsx">, Group<m_ppc_Features_Group>; @@ -3110,6 +3392,10 @@ def mno_longcall : Flag<["-"], "mno-longcall">, Group<m_ppc_Features_Group>; def mmma: Flag<["-"], "mmma">, Group<m_ppc_Features_Group>; def mno_mma: Flag<["-"], "mno-mma">, Group<m_ppc_Features_Group>; +def mrop_protect : Flag<["-"], "mrop-protect">, + Group<m_ppc_Features_Group>; +def mprivileged : Flag<["-"], "mprivileged">, + Group<m_ppc_Features_Group>; def maix_struct_return : Flag<["-"], "maix-struct-return">, Group<m_Group>, Flags<[CC1Option]>, HelpText<"Return all structs in memory (PPC32 only)">; @@ -3179,14 +3465,10 @@ def mstack_protector_guard_EQ : Joined<["-"], "mstack-protector-guard=">, Group< MarshallingInfoString<CodeGenOpts<"StackProtectorGuard">>; def mstack_protector_guard_offset_EQ : Joined<["-"], "mstack-protector-guard-offset=">, Group<m_Group>, Flags<[CC1Option]>, HelpText<"Use the given offset for addressing the stack-protector guard">, - MarshallingInfoStringInt<CodeGenOpts<"StackProtectorGuardOffset">, "(unsigned)-1">; + MarshallingInfoInt<CodeGenOpts<"StackProtectorGuardOffset">, "INT_MAX", "int">; def mstack_protector_guard_reg_EQ : Joined<["-"], "mstack-protector-guard-reg=">, Group<m_Group>, Flags<[CC1Option]>, HelpText<"Use the given reg for addressing the stack-protector guard">, - MarshallingInfoString<CodeGenOpts<"StackProtectorGuardReg">, [{"none"}]>; -def mpie_copy_relocations : Flag<["-"], "mpie-copy-relocations">, - Alias<fdirect_access_external_data>, Group<m_Group>; -def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, - Alias<fno_direct_access_external_data>, Group<m_Group>; + MarshallingInfoString<CodeGenOpts<"StackProtectorGuardReg">>; def mfentry : Flag<["-"], "mfentry">, HelpText<"Insert calls to fentry at function entry (x86/SystemZ only)">, Flags<[CC1Option]>, Group<m_Group>, MarshallingInfoFlag<CodeGenOpts<"CallFEntry">>; @@ -3397,8 +3679,8 @@ def pagezero__size : JoinedOrSeparate<["-"], "pagezero_size">; def pass_exit_codes : Flag<["-", "--"], "pass-exit-codes">, Flags<[Unsupported]>; def pedantic_errors : Flag<["-", "--"], "pedantic-errors">, Group<pedantic_Group>, Flags<[CC1Option]>, MarshallingInfoFlag<DiagnosticOpts<"PedanticErrors">>; -def pedantic : Flag<["-", "--"], "pedantic">, Group<pedantic_Group>, Flags<[CC1Option]>, - MarshallingInfoFlag<DiagnosticOpts<"Pedantic">>; +def pedantic : Flag<["-", "--"], "pedantic">, Group<pedantic_Group>, Flags<[CC1Option,FlangOption,FC1Option]>, + HelpText<"Warn on language extensions">, MarshallingInfoFlag<DiagnosticOpts<"Pedantic">>; def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, Flags<[CC1Option]>, MarshallingInfoFlag<CodeGenOpts<"InstrumentForProfiling">>; def pipe : Flag<["-", "--"], "pipe">, @@ -3422,6 +3704,8 @@ def print_target_triple : Flag<["-", "--"], "print-target-triple">, HelpText<"Print the normalized target triple">; def print_effective_triple : Flag<["-", "--"], "print-effective-triple">, HelpText<"Print the effective target triple">; +def print_multiarch : Flag<["-", "--"], "print-multiarch">, + HelpText<"Print the multiarch target triple">; def print_prog_name_EQ : Joined<["-", "--"], "print-prog-name=">, HelpText<"Print the full program path of <name>">, MetaVarName<"<name>">; def print_resource_dir : Flag<["-", "--"], "print-resource-dir">, @@ -3430,6 +3714,10 @@ def print_search_dirs : Flag<["-", "--"], "print-search-dirs">, HelpText<"Print the paths used for finding libraries and programs">; def print_targets : Flag<["-", "--"], "print-targets">, HelpText<"Print the registered targets">; +def print_rocm_search_dirs : Flag<["-", "--"], "print-rocm-search-dirs">, + HelpText<"Print the paths used for finding ROCm installation">; +def print_runtime_dir : Flag<["-", "--"], "print-runtime-dir">, + HelpText<"Print the directory pathname containing clangs runtime libraries">; def private__bundle : Flag<["-"], "private_bundle">; def pthreads : Flag<["-"], "pthreads">; defm pthread : BoolOption<"", "pthread", @@ -3496,7 +3784,7 @@ def static_libgcc : Flag<["-"], "static-libgcc">; def static_libstdcxx : Flag<["-"], "static-libstdc++">; def static : Flag<["-", "--"], "static">, Group<Link_Group>, Flags<[NoArgumentUnused]>; def std_default_EQ : Joined<["-"], "std-default=">; -def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>, +def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option,FlangOption,FC1Option]>, Group<CompileOnly_Group>, HelpText<"Language standard to compile for">, ValuesCode<[{ const char *Values = @@ -3535,8 +3823,6 @@ def print_supported_cpus : Flag<["-", "--"], "print-supported-cpus">, MarshallingInfoFlag<FrontendOpts<"PrintSupportedCPUs">>; def mcpu_EQ_QUESTION : Flag<["-"], "mcpu=?">, Alias<print_supported_cpus>; def mtune_EQ_QUESTION : Flag<["-"], "mtune=?">, Alias<print_supported_cpus>; -def gcc_toolchain : Joined<["--"], "gcc-toolchain=">, Flags<[NoXarchOption]>, - HelpText<"Use the gcc toolchain at the given directory">; def time : Flag<["-"], "time">, HelpText<"Time individual commands">; def traditional_cpp : Flag<["-", "--"], "traditional-cpp">, Flags<[CC1Option]>, @@ -3558,6 +3844,18 @@ def u : JoinedOrSeparate<["-"], "u">, Group<u_Group>; def v : Flag<["-"], "v">, Flags<[CC1Option, CoreOption]>, HelpText<"Show commands to run and use verbose output">, MarshallingInfoFlag<HeaderSearchOpts<"Verbose">>; +def altivec_src_compat : Joined<["-"], "faltivec-src-compat=">, + Flags<[CC1Option]>, Group<f_Group>, + HelpText<"Source-level compatibility for Altivec vectors (for PowerPC " + "targets). This includes results of vector comparison (scalar for " + "'xl', vector for 'gcc') as well as behavior when initializing with " + "a scalar (splatting for 'xl', element zero only for 'gcc'). For " + "'mixed', the compatibility is as 'gcc' for 'vector bool/vector " + "pixel' and as 'xl' for other types. Current default is 'mixed'.">, + Values<"mixed,gcc,xl">, + NormalizedValuesScope<"LangOptions::AltivecSrcCompatKind">, + NormalizedValues<["Mixed", "GCC", "XL"]>, + MarshallingInfoEnum<LangOpts<"AltivecSrcCompat">, "Mixed">; def verify_debug_info : Flag<["--"], "verify-debug-info">, Flags<[NoXarchOption]>, HelpText<"Verify the binary representation of debug output">; def weak_l : Joined<["-"], "weak-l">, Flags<[LinkerInput]>; @@ -3565,7 +3863,8 @@ def weak__framework : Separate<["-"], "weak_framework">, Flags<[LinkerInput]>; def weak__library : Separate<["-"], "weak_library">, Flags<[LinkerInput]>; def weak__reference__mismatches : Separate<["-"], "weak_reference_mismatches">; def whatsloaded : Flag<["-"], "whatsloaded">; -def whyload : Flag<["-"], "whyload">; +def why_load : Flag<["-"], "why_load">; +def whyload : Flag<["-"], "whyload">, Alias<why_load>; def w : Flag<["-"], "w">, HelpText<"Suppress all warnings">, Flags<[CC1Option]>, MarshallingInfoFlag<DiagnosticOpts<"IgnoreWarnings">>; def x : JoinedOrSeparate<["-"], "x">, Flags<[NoXarchOption,CC1Option]>, @@ -3605,7 +3904,7 @@ def _CLASSPATH : Separate<["--"], "CLASSPATH">, Alias<fclasspath_EQ>; def _all_warnings : Flag<["--"], "all-warnings">, Alias<Wall>; def _analyzer_no_default_checks : Flag<["--"], "analyzer-no-default-checks">, Flags<[NoXarchOption]>; def _analyzer_output : JoinedOrSeparate<["--"], "analyzer-output">, Flags<[NoXarchOption]>, - HelpText<"Static analyzer report output format (html|plist|plist-multi-file|plist-html|sarif|text).">; + HelpText<"Static analyzer report output format (html|plist|plist-multi-file|plist-html|sarif|sarif-html|text).">; def _analyze : Flag<["--"], "analyze">, Flags<[NoXarchOption, CoreOption]>, HelpText<"Run the static analyzer">; def _assemble : Flag<["--"], "assemble">, Alias<S>; @@ -3727,6 +4026,8 @@ def mv67 : Flag<["-"], "mv67">, Group<m_hexagon_Features_Group>, Alias<mcpu_EQ>, AliasArgs<["hexagonv67"]>; def mv67t : Flag<["-"], "mv67t">, Group<m_hexagon_Features_Group>, Alias<mcpu_EQ>, AliasArgs<["hexagonv67t"]>; +def mv68 : Flag<["-"], "mv68">, Group<m_hexagon_Features_Group>, + Alias<mcpu_EQ>, AliasArgs<["hexagonv68"]>; def mhexagon_hvx : Flag<["-"], "mhvx">, Group<m_hexagon_Features_HVX_Group>, HelpText<"Enable Hexagon Vector eXtensions">; def mhexagon_hvx_EQ : Joined<["-"], "mhvx=">, @@ -3757,6 +4058,20 @@ def mnvs : Flag<["-"], "mnvs">, Group<m_hexagon_Features_Group>, def mno_nvs : Flag<["-"], "mno-nvs">, Group<m_hexagon_Features_Group>, Flags<[CC1Option]>, HelpText<"Disable generation of new-value stores">; +// M68k features flags +def m68000 : Flag<["-"], "m68000">, Group<m_m68k_Features_Group>; +def m68010 : Flag<["-"], "m68010">, Group<m_m68k_Features_Group>; +def m68020 : Flag<["-"], "m68020">, Group<m_m68k_Features_Group>; +def m68030 : Flag<["-"], "m68030">, Group<m_m68k_Features_Group>; +def m68040 : Flag<["-"], "m68040">, Group<m_m68k_Features_Group>; +def m68060 : Flag<["-"], "m68060">, Group<m_m68k_Features_Group>; + +foreach i = {0-6} in + def ffixed_a#i : Flag<["-"], "ffixed-a"#i>, Group<m_m68k_Features_Group>, + HelpText<"Reserve the a"#i#" register (M68k only)">; +foreach i = {0-7} in + def ffixed_d#i : Flag<["-"], "ffixed-d"#i>, Group<m_m68k_Features_Group>, + HelpText<"Reserve the d"#i#" register (M68k only)">; // X86 feature flags def mx87 : Flag<["-"], "mx87">, Group<m_x86_Features_Group>; @@ -4072,9 +4387,6 @@ defm devirtualize_speculatively : BooleanFFlag<"devirtualize-speculatively">, // Generic gfortran options. def A_DASH : Joined<["-"], "A-">, Group<gfortran_Group>; -def J : JoinedOrSeparate<["-"], "J">, Flags<[RenderJoined]>, Group<gfortran_Group>; -def cpp : Flag<["-"], "cpp">, Group<gfortran_Group>; -def nocpp : Flag<["-"], "nocpp">, Group<gfortran_Group>; def static_libgfortran : Flag<["-"], "static-libgfortran">, Group<gfortran_Group>; // "f" options with values for gfortran. @@ -4082,7 +4394,6 @@ def fblas_matmul_limit_EQ : Joined<["-"], "fblas-matmul-limit=">, Group<gfortran def fcheck_EQ : Joined<["-"], "fcheck=">, Group<gfortran_Group>; def fcoarray_EQ : Joined<["-"], "fcoarray=">, Group<gfortran_Group>; def fconvert_EQ : Joined<["-"], "fconvert=">, Group<gfortran_Group>; -def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, Group<gfortran_Group>; def ffpe_trap_EQ : Joined<["-"], "ffpe-trap=">, Group<gfortran_Group>; def ffree_line_length_VALUE : Joined<["-"], "ffree-line-length-">, Group<gfortran_Group>; def finit_character_EQ : Joined<["-"], "finit-character=">, Group<gfortran_Group>; @@ -4100,33 +4411,25 @@ defm aggressive_function_elimination : BooleanFFlag<"aggressive-function-elimina defm align_commons : BooleanFFlag<"align-commons">, Group<gfortran_Group>; defm all_intrinsics : BooleanFFlag<"all-intrinsics">, Group<gfortran_Group>; defm automatic : BooleanFFlag<"automatic">, Group<gfortran_Group>; -defm backslash : BooleanFFlag<"backslash">, Group<gfortran_Group>; defm backtrace : BooleanFFlag<"backtrace">, Group<gfortran_Group>; defm bounds_check : BooleanFFlag<"bounds-check">, Group<gfortran_Group>; defm check_array_temporaries : BooleanFFlag<"check-array-temporaries">, Group<gfortran_Group>; defm cray_pointer : BooleanFFlag<"cray-pointer">, Group<gfortran_Group>; defm d_lines_as_code : BooleanFFlag<"d-lines-as-code">, Group<gfortran_Group>; defm d_lines_as_comments : BooleanFFlag<"d-lines-as-comments">, Group<gfortran_Group>; -defm default_double_8 : BooleanFFlag<"default-double-8">, Group<gfortran_Group>; -defm default_integer_8 : BooleanFFlag<"default-integer-8">, Group<gfortran_Group>; -defm default_real_8 : BooleanFFlag<"default-real-8">, Group<gfortran_Group>; defm dollar_ok : BooleanFFlag<"dollar-ok">, Group<gfortran_Group>; defm dump_fortran_optimized : BooleanFFlag<"dump-fortran-optimized">, Group<gfortran_Group>; defm dump_fortran_original : BooleanFFlag<"dump-fortran-original">, Group<gfortran_Group>; defm dump_parse_tree : BooleanFFlag<"dump-parse-tree">, Group<gfortran_Group>; defm external_blas : BooleanFFlag<"external-blas">, Group<gfortran_Group>; defm f2c : BooleanFFlag<"f2c">, Group<gfortran_Group>; -defm fixed_form : BooleanFFlag<"fixed-form">, Group<gfortran_Group>; -defm free_form : BooleanFFlag<"free-form">, Group<gfortran_Group>; defm frontend_optimize : BooleanFFlag<"frontend-optimize">, Group<gfortran_Group>; -defm implicit_none : BooleanFFlag<"implicit-none">, Group<gfortran_Group>; defm init_local_zero : BooleanFFlag<"init-local-zero">, Group<gfortran_Group>; defm integer_4_integer_8 : BooleanFFlag<"integer-4-integer-8">, Group<gfortran_Group>; -defm intrinsic_modules_path : BooleanFFlag<"intrinsic-modules-path">, Group<gfortran_Group>; defm max_identifier_length : BooleanFFlag<"max-identifier-length">, Group<gfortran_Group>; defm module_private : BooleanFFlag<"module-private">, Group<gfortran_Group>; defm pack_derived : BooleanFFlag<"pack-derived">, Group<gfortran_Group>; -defm protect_parens : BooleanFFlag<"protect-parens">, Group<gfortran_Group>; +//defm protect_parens : BooleanFFlag<"protect-parens">, Group<gfortran_Group>; defm range_check : BooleanFFlag<"range-check">, Group<gfortran_Group>; defm real_4_real_10 : BooleanFFlag<"real-4-real-10">, Group<gfortran_Group>; defm real_4_real_16 : BooleanFFlag<"real-4-real-16">, Group<gfortran_Group>; @@ -4144,21 +4447,135 @@ defm underscoring : BooleanFFlag<"underscoring">, Group<gfortran_Group>; defm whole_file : BooleanFFlag<"whole-file">, Group<gfortran_Group>; // C++ SYCL options -defm sycl : BoolOption<"f", "sycl", - LangOpts<"SYCL">, DefaultFalse, - PosFlag<SetTrue, [CC1Option], "Enable">, NegFlag<SetFalse, [], "Disable">, - BothFlags<[CoreOption], " SYCL kernels compilation for device">>, - Group<sycl_Group>; -def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group<sycl_Group>, Flags<[CC1Option, NoArgumentUnused, CoreOption]>, - HelpText<"SYCL language standard to compile for.">, Values<"2017,121,1.2.1,sycl-1.2.1">, - NormalizedValues<["SYCL_2017", "SYCL_2017", "SYCL_2017", "SYCL_2017"]>, NormalizedValuesScope<"LangOptions">, - MarshallingInfoString<LangOpts<"SYCLVersion">, "SYCL_None">, ShouldParseIf<fsycl.KeyPath>, AutoNormalizeEnum; +def fsycl : Flag<["-"], "fsycl">, Flags<[NoXarchOption, CoreOption]>, + Group<sycl_Group>, HelpText<"Enables SYCL kernels compilation for device">; +def fno_sycl : Flag<["-"], "fno-sycl">, Flags<[NoXarchOption, CoreOption]>, + Group<sycl_Group>, HelpText<"Disables SYCL kernels compilation for device">; + +//===----------------------------------------------------------------------===// +// FLangOption + CoreOption + NoXarchOption +//===----------------------------------------------------------------------===// +let Flags = [FlangOption, FlangOnlyOption, NoXarchOption, CoreOption] in { +def Xflang : Separate<["-"], "Xflang">, + HelpText<"Pass <arg> to the flang compiler">, MetaVarName<"<arg>">, + Flags<[NoXarchOption, CoreOption]>, Group<CompileOnly_Group>; +} //===----------------------------------------------------------------------===// // FlangOption and FC1 Options //===----------------------------------------------------------------------===// -def test_io : Flag<["-"], "test-io">, Flags<[HelpHidden, FlangOption, FC1Option, FlangOnlyOption]>, Group<Action_Group>, +let Flags = [FC1Option, FlangOption, FlangOnlyOption] in { + +def cpp : Flag<["-"], "cpp">, Group<f_Group>, + HelpText<"Enable predefined and command line preprocessor macros">; +def nocpp : Flag<["-"], "nocpp">, Group<f_Group>, + HelpText<"Disable predefined and command line preprocessor macros">; +def module_dir : Separate<["-"], "module-dir">, MetaVarName<"<dir>">, + HelpText<"Put MODULE files in <dir>">, + DocBrief<[{This option specifies where to put .mod files for compiled modules. +It is also added to the list of directories to be searched by an USE statement. +The default is the current directory.}]>; + +def ffixed_form : Flag<["-"], "ffixed-form">, Group<f_Group>, + HelpText<"Process source files in fixed form">; +def ffree_form : Flag<["-"], "ffree-form">, Group<f_Group>, + HelpText<"Process source files in free form">; +def ffixed_line_length_EQ : Joined<["-"], "ffixed-line-length=">, Group<f_Group>, + HelpText<"Use <value> as character line width in fixed mode">, + DocBrief<[{Set column after which characters are ignored in typical fixed-form lines in the source +file}]>; +def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, Group<f_Group>, Alias<ffixed_line_length_EQ>; +def fopenacc : Flag<["-"], "fopenacc">, Group<f_Group>, + HelpText<"Enable OpenACC">; +def fdefault_double_8 : Flag<["-"],"fdefault-double-8">, Group<f_Group>, + HelpText<"Set the default double precision kind to an 8 byte wide type">; +def fdefault_integer_8 : Flag<["-"],"fdefault-integer-8">, Group<f_Group>, + HelpText<"Set the default integer kind to an 8 byte wide type">; +def fdefault_real_8 : Flag<["-"],"fdefault-real-8">, Group<f_Group>, + HelpText<"Set the default real kind to an 8 byte wide type">; +def flarge_sizes : Flag<["-"],"flarge-sizes">, Group<f_Group>, + HelpText<"Use INTEGER(KIND=8) for the result type in size-related intrinsics">; +def fbackslash : Flag<["-"], "fbackslash">, Group<f_Group>, + HelpText<"Specify that backslash in string introduces an escape character">, + DocBrief<[{Change the interpretation of backslashes in string literals from +a single backslash character to "C-style" escape characters.}]>; +def fno_backslash : Flag<["-"], "fno-backslash">, Group<f_Group>; +def fxor_operator : Flag<["-"], "fxor-operator">, Group<f_Group>, + HelpText<"Enable .XOR. as a synonym of .NEQV.">; +def fno_xor_operator : Flag<["-"], "fno-xor-operator">, Group<f_Group>; +def flogical_abbreviations : Flag<["-"], "flogical-abbreviations">, Group<f_Group>, + HelpText<"Enable logical abbreviations">; +def fno_logical_abbreviations : Flag<["-"], "fno-logical-abbreviations">, Group<f_Group>; +def fimplicit_none : Flag<["-"], "fimplicit-none">, Group<f_Group>, + HelpText<"No implicit typing allowed unless overridden by IMPLICIT statements">; +def fno_implicit_none : Flag<["-"], "fno-implicit-none">, Group<f_Group>; +def falternative_parameter_statement : Flag<["-"], "falternative-parameter-statement">, Group<f_Group>, + HelpText<"Enable the old style PARAMETER statement">; +def fintrinsic_modules_path : Separate<["-"], "fintrinsic-modules-path">, Group<f_Group>, MetaVarName<"<dir>">, + HelpText<"Specify where to find the compiled intrinsic modules">, + DocBrief<[{This option specifies the location of pre-compiled intrinsic modules, + if they are not in the default location expected by the compiler.}]>; +} + +def J : JoinedOrSeparate<["-"], "J">, + Flags<[RenderJoined, FlangOption, FC1Option, FlangOnlyOption]>, + Group<gfortran_Group>, + Alias<module_dir>; + +//===----------------------------------------------------------------------===// +// FC1 Options +//===----------------------------------------------------------------------===// +let Flags = [FC1Option, FlangOnlyOption] in { + +def fget_definition : MultiArg<["-"], "fget-definition", 3>, + HelpText<"Get the symbol definition from <line> <start-column> <end-column>">, + Group<Action_Group>; +def test_io : Flag<["-"], "test-io">, Group<Action_Group>, HelpText<"Run the InputOuputTest action. Use for development and testing only.">; +def fdebug_unparse_no_sema : Flag<["-"], "fdebug-unparse-no-sema">, Group<Action_Group>, + HelpText<"Unparse and stop (skips the semantic checks)">, + DocBrief<[{Only run the parser, then unparse the parse-tree and output the +generated Fortran source file. Semantic checks are disabled.}]>; +def fdebug_unparse : Flag<["-"], "fdebug-unparse">, Group<Action_Group>, + HelpText<"Unparse and stop.">, + DocBrief<[{Run the parser and the semantic checks. Then unparse the +parse-tree and output the generated Fortran source file.}]>; +def fdebug_unparse_with_symbols : Flag<["-"], "fdebug-unparse-with-symbols">, Group<Action_Group>, + HelpText<"Unparse and stop.">; +def fdebug_dump_symbols : Flag<["-"], "fdebug-dump-symbols">, Group<Action_Group>, + HelpText<"Dump symbols after the semantic analysis">; +def fdebug_dump_parse_tree : Flag<["-"], "fdebug-dump-parse-tree">, Group<Action_Group>, + HelpText<"Dump the parse tree">, + DocBrief<[{Run the Parser and the semantic checks, and then output the +parse tree.}]>; +def fdebug_dump_parse_tree_no_sema : Flag<["-"], "fdebug-dump-parse-tree-no-sema">, Group<Action_Group>, + HelpText<"Dump the parse tree (skips the semantic checks)">, + DocBrief<[{Run the Parser and then output the parse tree. Semantic +checks are disabled.}]>; +def fdebug_dump_all : Flag<["-"], "fdebug-dump-all">, Group<Action_Group>, + HelpText<"Dump symbols and the parse tree after the semantic checks">; +def fdebug_dump_provenance : Flag<["-"], "fdebug-dump-provenance">, Group<Action_Group>, + HelpText<"Dump provenance">; +def fdebug_dump_parsing_log : Flag<["-"], "fdebug-dump-parsing-log">, Group<Action_Group>, + HelpText<"Run instrumented parse and dump the parsing log">; +def fdebug_measure_parse_tree : Flag<["-"], "fdebug-measure-parse-tree">, Group<Action_Group>, + HelpText<"Measure the parse tree">; +def fdebug_pre_fir_tree : Flag<["-"], "fdebug-pre-fir-tree">, Group<Action_Group>, + HelpText<"Dump the pre-FIR tree">; +def fdebug_module_writer : Flag<["-"],"fdebug-module-writer">, + HelpText<"Enable debug messages while writing module files">; +def fget_symbols_sources : Flag<["-"], "fget-symbols-sources">, Group<Action_Group>, + HelpText<"Dump symbols and their source code locations">; + +def module_suffix : Separate<["-"], "module-suffix">, Group<f_Group>, MetaVarName<"<suffix>">, + HelpText<"Use <suffix> as the suffix for module files (the default value is `.mod`)">; +def fanalyzed_objects_for_unparse : Flag<["-"], + "fanalyzed-objects-for-unparse">, Group<f_Group>; +def fno_analyzed_objects_for_unparse : Flag<["-"], + "fno-analyzed-objects-for-unparse">, Group<f_Group>, + HelpText<"Do not use the analyzed objects when unparsing">; + +} //===----------------------------------------------------------------------===// // CC1 Options @@ -4201,9 +4618,11 @@ def mfpmath : Separate<["-"], "mfpmath">, HelpText<"Which unit to use for fp math">, MarshallingInfoString<TargetOpts<"FPMath">>; -def fpadding_on_unsigned_fixed_point : Flag<["-"], "fpadding-on-unsigned-fixed-point">, - HelpText<"Force each unsigned fixed point type to have an extra bit of padding to align their scales with those of signed fixed point types">; -def fno_padding_on_unsigned_fixed_point : Flag<["-"], "fno-padding-on-unsigned-fixed-point">; +defm padding_on_unsigned_fixed_point : BoolOption<"f", "padding-on-unsigned-fixed-point", + LangOpts<"PaddingOnUnsignedFixedPoint">, DefaultFalse, + PosFlag<SetTrue, [], "Force each unsigned fixed point type to have an extra bit of padding to align their scales with those of signed fixed point types">, + NegFlag<SetFalse>>, + ShouldParseIf<ffixed_point.KeyPath>; //===----------------------------------------------------------------------===// // Analyzer Options @@ -4260,7 +4679,7 @@ def analyzer_dump_egraph_EQ : Joined<["-"], "analyzer-dump-egraph=">, Alias<anal def analyzer_inline_max_stack_depth : Separate<["-"], "analyzer-inline-max-stack-depth">, HelpText<"Bound on stack depth while inlining (4 by default)">, // Cap the stack depth at 4 calls (5 stack frames, base + 4 calls). - MarshallingInfoStringInt<AnalyzerOpts<"InlineMaxStackDepth">, "5">; + MarshallingInfoInt<AnalyzerOpts<"InlineMaxStackDepth">, "5">; def analyzer_inline_max_stack_depth_EQ : Joined<["-"], "analyzer-inline-max-stack-depth=">, Alias<analyzer_inline_max_stack_depth>; @@ -4274,7 +4693,7 @@ def analyzer_disable_retry_exhausted : Flag<["-"], "analyzer-disable-retry-exhau def analyzer_max_loop : Separate<["-"], "analyzer-max-loop">, HelpText<"The maximum number of times the analyzer will go through a loop">, - MarshallingInfoStringInt<AnalyzerOpts<"maxBlockVisitOnPath">, "4">; + MarshallingInfoInt<AnalyzerOpts<"maxBlockVisitOnPath">, "4">; def analyzer_stats : Flag<["-"], "analyzer-stats">, HelpText<"Print internal analyzer statistics.">, MarshallingInfoFlag<AnalyzerOpts<"PrintStats">>; @@ -4350,8 +4769,7 @@ def analyzer_checker_option_help_developer : Flag<["-"], "analyzer-checker-optio def analyzer_config_compatibility_mode : Separate<["-"], "analyzer-config-compatibility-mode">, HelpText<"Don't emit errors on invalid analyzer-config inputs">, Values<"true,false">, NormalizedValues<[[{false}], [{true}]]>, - MarshallingInfoString<AnalyzerOpts<"ShouldEmitErrorsOnInvalidConfigValue">, [{true}]>, - AutoNormalizeEnum; + MarshallingInfoEnum<AnalyzerOpts<"ShouldEmitErrorsOnInvalidConfigValue">, [{true}]>; def analyzer_config_compatibility_mode_EQ : Joined<["-"], "analyzer-config-compatibility-mode=">, Alias<analyzer_config_compatibility_mode>; @@ -4376,12 +4794,7 @@ def migrator_no_finalize_removal : Flag<["-"], "no-finalize-removal">, //===----------------------------------------------------------------------===// let Flags = [CC1Option, CC1AsOption, NoDriverOption] in { -def debug_info_kind_EQ : Joined<["-"], "debug-info-kind=">, - Values<"line-tables-only,line-directives-only,constructor,limited,standalone,unused-types">, - NormalizedValuesScope<"codegenoptions">, - NormalizedValues<["DebugLineTablesOnly", "DebugDirectivesOnly", "DebugInfoConstructor", - "LimitedDebugInfo", "FullDebugInfo", "UnusedTypeInfo"]>, - MarshallingInfoString<CodeGenOpts<"DebugInfo">, "NoDebugInfo">, AutoNormalizeEnum; +def debug_info_kind_EQ : Joined<["-"], "debug-info-kind=">; def debug_info_macro : Flag<["-"], "debug-info-macro">, HelpText<"Emit macro debug information">, MarshallingInfoFlag<CodeGenOpts<"MacroDebugInfo">>; @@ -4389,11 +4802,11 @@ def default_function_attr : Separate<["-"], "default-function-attr">, HelpText<"Apply given attribute to all functions">, MarshallingInfoStringVector<CodeGenOpts<"DefaultFunctionAttrs">>; def dwarf_version_EQ : Joined<["-"], "dwarf-version=">, - MarshallingInfoStringInt<CodeGenOpts<"DwarfVersion">>; + MarshallingInfoInt<CodeGenOpts<"DwarfVersion">>; def debugger_tuning_EQ : Joined<["-"], "debugger-tuning=">, - Values<"gdb,lldb,sce">, - NormalizedValuesScope<"llvm::DebuggerKind">, NormalizedValues<["GDB", "LLDB", "SCE"]>, - MarshallingInfoString<CodeGenOpts<"DebuggerTuning">, "Default">, AutoNormalizeEnum; + Values<"gdb,lldb,sce,dbx">, + NormalizedValuesScope<"llvm::DebuggerKind">, NormalizedValues<["GDB", "LLDB", "SCE", "DBX"]>, + MarshallingInfoEnum<CodeGenOpts<"DebuggerTuning">, "Default">; def dwarf_debug_flags : Separate<["-"], "dwarf-debug-flags">, HelpText<"The string to embed in the Dwarf debug flags record.">, MarshallingInfoString<CodeGenOpts<"DwarfDebugFlags">>; @@ -4403,7 +4816,7 @@ def record_command_line : Separate<["-"], "record-command-line">, def compress_debug_sections_EQ : Joined<["-", "--"], "compress-debug-sections=">, HelpText<"DWARF debug sections compression type">, Values<"none,zlib,zlib-gnu">, NormalizedValuesScope<"llvm::DebugCompressionType">, NormalizedValues<["None", "Z", "GNU"]>, - MarshallingInfoString<CodeGenOpts<"CompressDebugSections">, "None">, AutoNormalizeEnum; + MarshallingInfoEnum<CodeGenOpts<"CompressDebugSections">, "None">; def compress_debug_sections : Flag<["-", "--"], "compress-debug-sections">, Alias<compress_debug_sections_EQ>, AliasArgs<["zlib"]>; def mno_exec_stack : Flag<["-"], "mnoexecstack">, @@ -4427,11 +4840,12 @@ def mrelocation_model : Separate<["-"], "mrelocation-model">, HelpText<"The relocation model to use">, Values<"static,pic,ropi,rwpi,ropi-rwpi,dynamic-no-pic">, NormalizedValuesScope<"llvm::Reloc">, NormalizedValues<["Static", "PIC_", "ROPI", "RWPI", "ROPI_RWPI", "DynamicNoPIC"]>, - MarshallingInfoString<CodeGenOpts<"RelocationModel">, "PIC_">, - AutoNormalizeEnum; + MarshallingInfoEnum<CodeGenOpts<"RelocationModel">, "PIC_">; def fno_math_builtin : Flag<["-"], "fno-math-builtin">, HelpText<"Disable implicit builtin knowledge of math functions">, MarshallingInfoFlag<LangOpts<"NoMathBuiltin">>; +def fno_use_ctor_homing: Flag<["-"], "fno-use-ctor-homing">, + HelpText<"Don't use constructor homing for debug info">; def fuse_ctor_homing: Flag<["-"], "fuse-ctor-homing">, HelpText<"Use constructor homing if we are using limited debug info already">; } @@ -4513,7 +4927,7 @@ def mdebug_pass : Separate<["-"], "mdebug-pass">, def mframe_pointer_EQ : Joined<["-"], "mframe-pointer=">, HelpText<"Specify which frame pointers to retain (all, non-leaf, none).">, Values<"all,non-leaf,none">, NormalizedValuesScope<"CodeGenOptions::FramePointerKind">, NormalizedValues<["All", "NonLeaf", "None"]>, - MarshallingInfoString<CodeGenOpts<"FramePointer">, "None">, AutoNormalizeEnum; + MarshallingInfoEnum<CodeGenOpts<"FramePointer">, "None">; def mdisable_tail_calls : Flag<["-"], "mdisable-tail-calls">, HelpText<"Disable tail call optimization, keeping the call stack accurate">, MarshallingInfoFlag<CodeGenOpts<"DisableTailCalls">>; @@ -4537,15 +4951,12 @@ def mtp : Separate<["-"], "mtp">, def mlimit_float_precision : Separate<["-"], "mlimit-float-precision">, HelpText<"Limit float precision to the given value">, MarshallingInfoString<CodeGenOpts<"LimitFloatPrecision">>; -def split_stacks : Flag<["-"], "split-stacks">, - HelpText<"Try to use a split stack if possible.">, - MarshallingInfoFlag<CodeGenOpts<"EnableSegmentedStacks">>; def mregparm : Separate<["-"], "mregparm">, HelpText<"Limit the number of registers available for integer arguments">, - MarshallingInfoStringInt<CodeGenOpts<"NumRegisterParameters">>; + MarshallingInfoInt<CodeGenOpts<"NumRegisterParameters">>; def msmall_data_limit : Separate<["-"], "msmall-data-limit">, HelpText<"Put global and static data smaller than the limit into a special section">, - MarshallingInfoStringInt<CodeGenOpts<"SmallDataLimit">>; + MarshallingInfoInt<CodeGenOpts<"SmallDataLimit">>; def munwind_tables : Flag<["-"], "munwind-tables">, HelpText<"Generate unwinding tables for all functions">, MarshallingInfoFlag<CodeGenOpts<"UnwindTables">>; @@ -4573,7 +4984,7 @@ def linker_option : Joined<["--"], "linker-option=">, MarshallingInfoStringVector<CodeGenOpts<"LinkerOptions">>; def fsanitize_coverage_type : Joined<["-"], "fsanitize-coverage-type=">, HelpText<"Sanitizer coverage type">, - MarshallingInfoStringInt<CodeGenOpts<"SanitizeCoverageType">>; + MarshallingInfoInt<CodeGenOpts<"SanitizeCoverageType">>; def fsanitize_coverage_indirect_calls : Flag<["-"], "fsanitize-coverage-indirect-calls">, HelpText<"Enable sanitizer coverage for indirect calls">, @@ -4629,13 +5040,13 @@ def fsanitize_coverage_stack_depth def fpatchable_function_entry_offset_EQ : Joined<["-"], "fpatchable-function-entry-offset=">, MetaVarName<"<M>">, HelpText<"Generate M NOPs before function entry">, - MarshallingInfoStringInt<CodeGenOpts<"PatchableFunctionEntryOffset">>; + MarshallingInfoInt<CodeGenOpts<"PatchableFunctionEntryOffset">>; def fprofile_instrument_EQ : Joined<["-"], "fprofile-instrument=">, HelpText<"Enable PGO instrumentation. The accepted value is clang, llvm, " "or none">, Values<"none,clang,llvm,csllvm">, NormalizedValuesScope<"CodeGenOptions">, NormalizedValues<["ProfileNone", "ProfileClangInstr", "ProfileIRInstr", "ProfileCSIRInstr"]>, - MarshallingInfoString<CodeGenOpts<"ProfileInstr">, "ProfileNone">, AutoNormalizeEnum; + MarshallingInfoEnum<CodeGenOpts<"ProfileInstr">, "ProfileNone">; def fprofile_instrument_path_EQ : Joined<["-"], "fprofile-instrument-path=">, HelpText<"Generate instrumented code to collect execution counts into " "<file> (overridden by LLVM_PROFILE_FILE env var)">, @@ -4660,6 +5071,21 @@ def fexperimental_debug_variable_locations : Flag<["-"], "fexperimental-debug-variable-locations">, HelpText<"Use experimental new value-tracking variable locations">, MarshallingInfoFlag<CodeGenOpts<"ValueTrackingVariableLocations">>; +def fverify_debuginfo_preserve + : Flag<["-"], "fverify-debuginfo-preserve">, + HelpText<"Enable Debug Info Metadata preservation testing in " + "optimizations.">, + MarshallingInfoFlag<CodeGenOpts<"EnableDIPreservationVerify">>; +def fverify_debuginfo_preserve_export + : Joined<["-"], "fverify-debuginfo-preserve-export=">, + MetaVarName<"<file>">, + HelpText<"Export debug info (by testing original Debug Info) failures " + "into specified (JSON) file (should be abs path as we use " + "append mode to insert new JSON objects).">, + MarshallingInfoString<CodeGenOpts<"DIBugsReportFilePath">>; +def fwarn_stack_size_EQ + : Joined<["-"], "fwarn-stack-size=">, + MarshallingInfoInt<CodeGenOpts<"WarnStackSize">, "UINT_MAX">; // The driver option takes the key as a parameter to the -msign-return-address= // and -mbranch-protection= options, but CC1 has a separate option so we // don't have to parse the parameter twice. @@ -4675,6 +5101,9 @@ def cfguard_no_checks : Flag<["-"], "cfguard-no-checks">, def cfguard : Flag<["-"], "cfguard">, HelpText<"Emit Windows Control Flow Guard tables and checks">, MarshallingInfoFlag<CodeGenOpts<"ControlFlowGuard">>; +def ehcontguard : Flag<["-"], "ehcontguard">, + HelpText<"Emit Windows EH Continuation Guard tables">, + MarshallingInfoFlag<CodeGenOpts<"EHContGuard">>; def fdenormal_fp_math_f32_EQ : Joined<["-"], "fdenormal-fp-math-f32=">, Group<f_Group>; @@ -4707,43 +5136,42 @@ def diagnostic_serialized_file : Separate<["-"], "serialize-diagnostic-file">, HelpText<"File for serializing diagnostics in a binary format">; def fdiagnostics_format : Separate<["-"], "fdiagnostics-format">, - HelpText<"Change diagnostic formatting to match IDE and command line tools">, Values<"clang,msvc,msvc-fallback,vi">, - NormalizedValuesScope<"DiagnosticOptions">, NormalizedValues<["Clang", "MSVC", "MSVC", "Vi"]>, - MarshallingInfoString<DiagnosticOpts<"Format">, "Clang">, AutoNormalizeEnum; + HelpText<"Change diagnostic formatting to match IDE and command line tools">, Values<"clang,msvc,vi">, + NormalizedValuesScope<"DiagnosticOptions">, NormalizedValues<["Clang", "MSVC", "Vi"]>, + MarshallingInfoEnum<DiagnosticOpts<"Format">, "Clang">; def fdiagnostics_show_category : Separate<["-"], "fdiagnostics-show-category">, HelpText<"Print diagnostic category">, Values<"none,id,name">, NormalizedValues<["0", "1", "2"]>, - MarshallingInfoString<DiagnosticOpts<"ShowCategories">, "0">, AutoNormalizeEnum; + MarshallingInfoEnum<DiagnosticOpts<"ShowCategories">, "0">; def fno_diagnostics_use_presumed_location : Flag<["-"], "fno-diagnostics-use-presumed-location">, HelpText<"Ignore #line directives when displaying diagnostic locations">, MarshallingInfoNegativeFlag<DiagnosticOpts<"ShowPresumedLoc">>; def ftabstop : Separate<["-"], "ftabstop">, MetaVarName<"<N>">, HelpText<"Set the tab stop distance.">, - MarshallingInfoStringInt<DiagnosticOpts<"TabStop">, "DiagnosticOptions::DefaultTabStop">; + MarshallingInfoInt<DiagnosticOpts<"TabStop">, "DiagnosticOptions::DefaultTabStop">; def ferror_limit : Separate<["-"], "ferror-limit">, MetaVarName<"<N>">, HelpText<"Set the maximum number of errors to emit before stopping (0 = no limit).">, - MarshallingInfoStringInt<DiagnosticOpts<"ErrorLimit">>; + MarshallingInfoInt<DiagnosticOpts<"ErrorLimit">>; def fmacro_backtrace_limit : Separate<["-"], "fmacro-backtrace-limit">, MetaVarName<"<N>">, HelpText<"Set the maximum number of entries to print in a macro expansion backtrace (0 = no limit).">, - MarshallingInfoStringInt<DiagnosticOpts<"MacroBacktraceLimit">, "DiagnosticOptions::DefaultMacroBacktraceLimit">; + MarshallingInfoInt<DiagnosticOpts<"MacroBacktraceLimit">, "DiagnosticOptions::DefaultMacroBacktraceLimit">; def ftemplate_backtrace_limit : Separate<["-"], "ftemplate-backtrace-limit">, MetaVarName<"<N>">, HelpText<"Set the maximum number of entries to print in a template instantiation backtrace (0 = no limit).">, - MarshallingInfoStringInt<DiagnosticOpts<"TemplateBacktraceLimit">, "DiagnosticOptions::DefaultTemplateBacktraceLimit">; + MarshallingInfoInt<DiagnosticOpts<"TemplateBacktraceLimit">, "DiagnosticOptions::DefaultTemplateBacktraceLimit">; def fconstexpr_backtrace_limit : Separate<["-"], "fconstexpr-backtrace-limit">, MetaVarName<"<N>">, HelpText<"Set the maximum number of entries to print in a constexpr evaluation backtrace (0 = no limit).">, - MarshallingInfoStringInt<DiagnosticOpts<"ConstexprBacktraceLimit">, "DiagnosticOptions::DefaultConstexprBacktraceLimit">; + MarshallingInfoInt<DiagnosticOpts<"ConstexprBacktraceLimit">, "DiagnosticOptions::DefaultConstexprBacktraceLimit">; def fspell_checking_limit : Separate<["-"], "fspell-checking-limit">, MetaVarName<"<N>">, HelpText<"Set the maximum number of times to perform spell checking on unrecognized identifiers (0 = no limit).">, - MarshallingInfoStringInt<DiagnosticOpts<"SpellCheckingLimit">, "DiagnosticOptions::DefaultSpellCheckingLimit">; + MarshallingInfoInt<DiagnosticOpts<"SpellCheckingLimit">, "DiagnosticOptions::DefaultSpellCheckingLimit">; def fcaret_diagnostics_max_lines : Separate<["-"], "fcaret-diagnostics-max-lines">, MetaVarName<"<N>">, HelpText<"Set the maximum number of source lines to show in a caret diagnostic">, - MarshallingInfoStringInt<DiagnosticOpts<"SnippetLineLimit">, "DiagnosticOptions::DefaultSnippetLineLimit">; + MarshallingInfoInt<DiagnosticOpts<"SnippetLineLimit">, "DiagnosticOptions::DefaultSnippetLineLimit">; def verify_EQ : CommaJoined<["-"], "verify=">, MetaVarName<"<prefixes>">, HelpText<"Verify diagnostic output using comment directives that start with" - " prefixes in the comma-separated sequence <prefixes>">, - MarshallingInfoStringVector<DiagnosticOpts<"VerifyPrefixes">>; + " prefixes in the comma-separated sequence <prefixes>">; def verify : Flag<["-"], "verify">, HelpText<"Equivalent to -verify=expected">; def verify_ignore_unexpected : Flag<["-"], "verify-ignore-unexpected">, @@ -4803,6 +5231,9 @@ def code_completion_with_fixits : Flag<["-"], "code-completion-with-fixits">, def disable_free : Flag<["-"], "disable-free">, HelpText<"Disable freeing of memory on exit">, MarshallingInfoFlag<FrontendOpts<"DisableFree">>; +def enable_noundef_analysis : Flag<["-"], "enable-noundef-analysis">, Group<f_Group>, + HelpText<"Enable analyzing function argument and return types for mandatory definedness">, + MarshallingInfoFlag<CodeGenOpts<"EnableNoundefAttrs">>; def discard_value_names : Flag<["-"], "discard-value-names">, HelpText<"Discard value names in LLVM IR">, MarshallingInfoFlag<CodeGenOpts<"DiscardValueNames">>; @@ -4845,10 +5276,14 @@ def fmodules_embed_all_files : Joined<["-"], "fmodules-embed-all-files">, HelpText<"Embed the contents of all files read by this compilation into " "the produced module file.">, MarshallingInfoFlag<FrontendOpts<"ModulesEmbedAllFiles">>; +// FIXME: We only need this in C++ modules / Modules TS if we might textually +// enter a different module (eg, when building a header unit). def fmodules_local_submodule_visibility : Flag<["-"], "fmodules-local-submodule-visibility">, HelpText<"Enforce name visibility rules across submodules of the same " - "top-level module.">; + "top-level module.">, + MarshallingInfoFlag<LangOpts<"ModulesLocalVisibility">>, + ImpliedByAnyOf<[fmodules_ts.KeyPath, cpp_modules.KeyPath]>; def fmodules_codegen : Flag<["-"], "fmodules-codegen">, HelpText<"Generate code for uses of this module that assumes an explicit " @@ -4893,8 +5328,6 @@ def analyze : Flag<["-"], "analyze">, HelpText<"Run static analysis engine">; def dump_tokens : Flag<["-"], "dump-tokens">, HelpText<"Run preprocessor, dump internal rep of tokens">; -def init_only : Flag<["-"], "init-only">, - HelpText<"Only execute frontend initialization">; def fixit : Flag<["-"], "fixit">, HelpText<"Apply fix-it advice to the input source">; def fixit_EQ : Joined<["-"], "fixit=">, @@ -4969,8 +5402,7 @@ def arcmt_action_EQ : Joined<["-"], "arcmt-action=">, Flags<[CC1Option, NoDriver HelpText<"The ARC migration action to take">, Values<"check,modify,migrate">, NormalizedValuesScope<"FrontendOptions">, NormalizedValues<["ARCMT_Check", "ARCMT_Modify", "ARCMT_Migrate"]>, - MarshallingInfoString<FrontendOpts<"ARCMTAction">, "ARCMT_None">, - AutoNormalizeEnum; + MarshallingInfoEnum<FrontendOpts<"ARCMTAction">, "ARCMT_None">; def opt_record_file : Separate<["-"], "opt-record-file">, HelpText<"File name to use for YAML optimization record output">, @@ -4986,11 +5418,19 @@ def print_stats : Flag<["-"], "print-stats">, def stats_file : Joined<["-"], "stats-file=">, HelpText<"Filename to write statistics to">, MarshallingInfoString<FrontendOpts<"StatsFile">>; -def fdump_record_layouts : Flag<["-"], "fdump-record-layouts">, - HelpText<"Dump record layout information">; def fdump_record_layouts_simple : Flag<["-"], "fdump-record-layouts-simple">, HelpText<"Dump record layout information in a simple form used for testing">, MarshallingInfoFlag<LangOpts<"DumpRecordLayoutsSimple">>; +def fdump_record_layouts_canonical : Flag<["-"], "fdump-record-layouts-canonical">, + HelpText<"Dump record layout information with canonical field types">, + MarshallingInfoFlag<LangOpts<"DumpRecordLayoutsCanonical">>; +def fdump_record_layouts_complete : Flag<["-"], "fdump-record-layouts-complete">, + HelpText<"Dump record layout information for all complete types">, + MarshallingInfoFlag<LangOpts<"DumpRecordLayoutsComplete">>; +def fdump_record_layouts : Flag<["-"], "fdump-record-layouts">, + HelpText<"Dump record layout information">, + MarshallingInfoFlag<LangOpts<"DumpRecordLayouts">>, + ImpliedByAnyOf<[fdump_record_layouts_simple.KeyPath, fdump_record_layouts_complete.KeyPath, fdump_record_layouts_canonical.KeyPath]>; def fix_what_you_can : Flag<["-"], "fix-what-you-can">, HelpText<"Apply fix-it advice even in the presence of unfixable errors">, MarshallingInfoFlag<FrontendOpts<"FixWhatYouCan">>; @@ -5024,7 +5464,9 @@ def building_pch_with_obj : Flag<["-"], "building-pch-with-obj">, MarshallingInfoFlag<LangOpts<"BuildingPCHWithObjectFile">>; def aligned_alloc_unavailable : Flag<["-"], "faligned-alloc-unavailable">, - HelpText<"Aligned allocation/deallocation functions are unavailable">; + HelpText<"Aligned allocation/deallocation functions are unavailable">, + MarshallingInfoFlag<LangOpts<"AlignedAllocationUnavailable">>, + ShouldParseIf<faligned_allocation.KeyPath>; //===----------------------------------------------------------------------===// // Language Options @@ -5054,7 +5496,9 @@ def split_dwarf_file : Separate<["-"], "split-dwarf-file">, HelpText<"Name of the split dwarf debug info file to encode in the object file">, MarshallingInfoString<CodeGenOpts<"SplitDwarfFile">>; def fno_wchar : Flag<["-"], "fno-wchar">, - HelpText<"Disable C++ builtin type wchar_t">; + HelpText<"Disable C++ builtin type wchar_t">, + MarshallingInfoNegativeFlag<LangOpts<"WChar">, cplusplus.KeyPath>, + ShouldParseIf<cplusplus.KeyPath>; def fconstant_string_class : Separate<["-"], "fconstant-string-class">, MetaVarName<"<class name>">, HelpText<"Specify the class to use for constant Objective-C string objects.">, @@ -5062,13 +5506,13 @@ def fconstant_string_class : Separate<["-"], "fconstant-string-class">, def fobjc_arc_cxxlib_EQ : Joined<["-"], "fobjc-arc-cxxlib=">, HelpText<"Objective-C++ Automatic Reference Counting standard library kind">, Values<"libc++,libstdc++,none">, NormalizedValues<["ARCXX_libcxx", "ARCXX_libstdcxx", "ARCXX_nolib"]>, - MarshallingInfoString<PreprocessorOpts<"ObjCXXARCStandardLibrary">, "ARCXX_nolib">, AutoNormalizeEnum; + MarshallingInfoEnum<PreprocessorOpts<"ObjCXXARCStandardLibrary">, "ARCXX_nolib">; def fobjc_runtime_has_weak : Flag<["-"], "fobjc-runtime-has-weak">, HelpText<"The target Objective-C runtime supports ARC weak operations">; def fobjc_dispatch_method_EQ : Joined<["-"], "fobjc-dispatch-method=">, HelpText<"Objective-C dispatch method to use">, Values<"legacy,non-legacy,mixed">, NormalizedValuesScope<"CodeGenOptions">, NormalizedValues<["Legacy", "NonLegacy", "Mixed"]>, - MarshallingInfoString<CodeGenOpts<"ObjCDispatchMethod">, "Legacy">, AutoNormalizeEnum; + MarshallingInfoEnum<CodeGenOpts<"ObjCDispatchMethod">, "Legacy">; def disable_objc_default_synthesize_properties : Flag<["-"], "disable-objc-default-synthesize-properties">, HelpText<"disable the default synthesis of Objective-C properties">, MarshallingInfoNegativeFlag<LangOpts<"ObjCDefaultSynthProperties">>; @@ -5077,9 +5521,10 @@ def fencode_extended_block_signature : Flag<["-"], "fencode-extended-block-signa MarshallingInfoFlag<LangOpts<"EncodeExtendedBlockSig">>; def function_alignment : Separate<["-"], "function-alignment">, HelpText<"default alignment for functions">, - MarshallingInfoStringInt<LangOpts<"FunctionAlignment">>; + MarshallingInfoInt<LangOpts<"FunctionAlignment">>; def pic_level : Separate<["-"], "pic-level">, - HelpText<"Value for __PIC__">; + HelpText<"Value for __PIC__">, + MarshallingInfoInt<LangOpts<"PICLevel">>; def pic_is_pie : Flag<["-"], "pic-is-pie">, HelpText<"File is for a position independent executable">, MarshallingInfoFlag<LangOpts<"PIE">>; @@ -5097,6 +5542,10 @@ def fallow_pch_with_errors : Flag<["-"], "fallow-pch-with-compiler-errors">, HelpText<"Accept a PCH file that was created with compiler errors">, MarshallingInfoFlag<PreprocessorOpts<"AllowPCHWithCompilerErrors">>, ImpliedByAnyOf<[fallow_pcm_with_errors.KeyPath]>; +def fallow_pch_with_different_modules_cache_path : + Flag<["-"], "fallow-pch-with-different-modules-cache-path">, + HelpText<"Accept a PCH file that was created with a different modules cache path">, + MarshallingInfoFlag<PreprocessorOpts<"AllowPCHWithDifferentModulesCachePath">>; def dump_deserialized_pch_decls : Flag<["-"], "dump-deserialized-decls">, HelpText<"Dump declarations that are deserialized from PCH, for testing">, MarshallingInfoFlag<PreprocessorOpts<"DumpDeserializedPCHDecls">>; @@ -5111,13 +5560,15 @@ def stack_protector : Separate<["-"], "stack-protector">, HelpText<"Enable stack protectors">, Values<"0,1,2,3">, NormalizedValuesScope<"LangOptions">, NormalizedValues<["SSPOff", "SSPOn", "SSPStrong", "SSPReq"]>, - MarshallingInfoString<LangOpts<"StackProtector">, "SSPOff">, AutoNormalizeEnum; + MarshallingInfoEnum<LangOpts<"StackProtector">, "SSPOff">; def stack_protector_buffer_size : Separate<["-"], "stack-protector-buffer-size">, HelpText<"Lower bound for a buffer to be considered for stack protection">, - MarshallingInfoStringInt<CodeGenOpts<"SSPBufferSize">, "8">; + MarshallingInfoInt<CodeGenOpts<"SSPBufferSize">, "8">; def fvisibility : Separate<["-"], "fvisibility">, HelpText<"Default type and symbol visibility">, - MarshallingInfoVisibility<LangOpts<"ValueVisibilityMode">, "DefaultVisibility">; + MarshallingInfoVisibility<LangOpts<"ValueVisibilityMode">, "DefaultVisibility">, + // Always emitting because of the relation to `-mignore-xcoff-visibility`. + AlwaysEmit; def ftype_visibility : Separate<["-"], "ftype-visibility">, HelpText<"Default type visibility">, MarshallingInfoVisibility<LangOpts<"TypeVisibilityMode">, fvisibility.KeyPath>; @@ -5126,19 +5577,19 @@ def fapply_global_visibility_to_externs : Flag<["-"], "fapply-global-visibility- MarshallingInfoFlag<LangOpts<"SetVisibilityForExternDecls">>; def ftemplate_depth : Separate<["-"], "ftemplate-depth">, HelpText<"Maximum depth of recursive template instantiation">, - MarshallingInfoStringInt<LangOpts<"InstantiationDepth">, "1024">; + MarshallingInfoInt<LangOpts<"InstantiationDepth">, "1024">; def foperator_arrow_depth : Separate<["-"], "foperator-arrow-depth">, HelpText<"Maximum number of 'operator->'s to call for a member access">, - MarshallingInfoStringInt<LangOpts<"ArrowDepth">, "256">; + MarshallingInfoInt<LangOpts<"ArrowDepth">, "256">; def fconstexpr_depth : Separate<["-"], "fconstexpr-depth">, HelpText<"Maximum depth of recursive constexpr function calls">, - MarshallingInfoStringInt<LangOpts<"ConstexprCallDepth">, "512">; + MarshallingInfoInt<LangOpts<"ConstexprCallDepth">, "512">; def fconstexpr_steps : Separate<["-"], "fconstexpr-steps">, HelpText<"Maximum number of steps in constexpr function evaluation">, - MarshallingInfoStringInt<LangOpts<"ConstexprStepLimit">, "1048576">; + MarshallingInfoInt<LangOpts<"ConstexprStepLimit">, "1048576">; def fbracket_depth : Separate<["-"], "fbracket-depth">, HelpText<"Maximum nesting level for parentheses, brackets, and braces">, - MarshallingInfoStringInt<LangOpts<"BracketDepth">, "256">; + MarshallingInfoInt<LangOpts<"BracketDepth">, "256">; defm const_strings : BoolOption<"f", "const-strings", LangOpts<"ConstStrings">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Use">, NegFlag<SetFalse, [], "Don't use">, @@ -5153,7 +5604,7 @@ def faddress_space_map_mangling_EQ : Joined<["-"], "faddress-space-map-mangling= HelpText<"Set the mode for address space map based mangling; OpenCL testing purposes only">, Values<"target,no,yes">, NormalizedValuesScope<"LangOptions">, NormalizedValues<["ASMM_Target", "ASMM_Off", "ASMM_On"]>, - MarshallingInfoString<LangOpts<"AddressSpaceMapMangling">, "ASMM_Target">, AutoNormalizeEnum; + MarshallingInfoEnum<LangOpts<"AddressSpaceMapMangling">, "ASMM_Target">; def funknown_anytype : Flag<["-"], "funknown-anytype">, HelpText<"Enable parser support for the __unknown_anytype type; for testing purposes only">, MarshallingInfoFlag<LangOpts<"ParseUnknownAnytype">>; @@ -5166,16 +5617,16 @@ def fdebugger_cast_result_to_id : Flag<["-"], "fdebugger-cast-result-to-id">, def fdebugger_objc_literal : Flag<["-"], "fdebugger-objc-literal">, HelpText<"Enable special debugger support for Objective-C subscripting and literals">, MarshallingInfoFlag<LangOpts<"DebuggerObjCLiteral">>; -def fdeprecated_macro : Flag<["-"], "fdeprecated-macro">, - HelpText<"Defines the __DEPRECATED macro">; -def fno_deprecated_macro : Flag<["-"], "fno-deprecated-macro">, - HelpText<"Undefines the __DEPRECATED macro">; +defm deprecated_macro : BoolOption<"f", "deprecated-macro", + LangOpts<"Deprecated">, DefaultFalse, + PosFlag<SetTrue, [], "Defines">, NegFlag<SetFalse, [], "Undefines">, + BothFlags<[], " the __DEPRECATED macro">>; def fobjc_subscripting_legacy_runtime : Flag<["-"], "fobjc-subscripting-legacy-runtime">, HelpText<"Allow Objective-C array and dictionary subscripting in legacy runtime">; // TODO: Enforce values valid for MSVtorDispMode. def vtordisp_mode_EQ : Joined<["-"], "vtordisp-mode=">, HelpText<"Control vtordisp placement on win32 targets">, - MarshallingInfoStringInt<LangOpts<"VtorDispMode">, "1">; + MarshallingInfoInt<LangOpts<"VtorDispMode">, "1">; def fnative_half_type: Flag<["-"], "fnative-half-type">, HelpText<"Use the native half type for __fp16 instead of promoting to float">, MarshallingInfoFlag<LangOpts<"NativeHalfType">>, @@ -5192,7 +5643,7 @@ def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">, HelpText<"Set default calling convention">, Values<"cdecl,fastcall,stdcall,vectorcall,regcall">, NormalizedValuesScope<"LangOptions">, NormalizedValues<["DCC_CDecl", "DCC_FastCall", "DCC_StdCall", "DCC_VectorCall", "DCC_RegCall"]>, - MarshallingInfoString<LangOpts<"DefaultCallingConv">, "DCC_None">, AutoNormalizeEnum; + MarshallingInfoEnum<LangOpts<"DefaultCallingConv">, "DCC_None">; // These options cannot be marshalled, because they are used to set up the LangOptions defaults. def finclude_default_header : Flag<["-"], "finclude-default-header">, @@ -5206,7 +5657,7 @@ def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">, def fwchar_type_EQ : Joined<["-"], "fwchar-type=">, HelpText<"Select underlying type for wchar_t">, Values<"char,short,int">, NormalizedValues<["1", "2", "4"]>, - MarshallingInfoString<LangOpts<"WCharSize">, "0">, AutoNormalizeEnum; + MarshallingInfoEnum<LangOpts<"WCharSize">, "0">; defm signed_wchar : BoolOption<"f", "signed-wchar", LangOpts<"WCharIsSigned">, DefaultTrue, NegFlag<SetFalse, [CC1Option], "Use an unsigned">, PosFlag<SetTrue, [], "Use a signed">, @@ -5322,11 +5773,22 @@ def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">, def fsycl_is_device : Flag<["-"], "fsycl-is-device">, HelpText<"Generate code for SYCL device.">, - MarshallingInfoFlag<LangOpts<"SYCLIsDevice">>, - ShouldParseIf<fsycl.KeyPath>; + MarshallingInfoFlag<LangOpts<"SYCLIsDevice">>; +def fsycl_is_host : Flag<["-"], "fsycl-is-host">, + HelpText<"SYCL host compilation">, + MarshallingInfoFlag<LangOpts<"SYCLIsHost">>; } // let Flags = [CC1Option, NoDriverOption] +def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group<sycl_Group>, + Flags<[CC1Option, NoArgumentUnused, CoreOption]>, + HelpText<"SYCL language standard to compile for.">, + Values<"2020,2017,121,1.2.1,sycl-1.2.1">, + NormalizedValues<["SYCL_2020", "SYCL_2017", "SYCL_2017", "SYCL_2017", "SYCL_2017"]>, + NormalizedValuesScope<"LangOptions">, + MarshallingInfoEnum<LangOpts<"SYCLVersion">, "SYCL_None">, + ShouldParseIf<!strconcat(fsycl_is_device.KeyPath, "||", fsycl_is_host.KeyPath)>; + defm cuda_approx_transcendentals : BoolFOption<"cuda-approx-transcendentals", LangOpts<"CUDADeviceApproxTranscendentals">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Use">, NegFlag<SetFalse, [], "Don't use">, @@ -5341,6 +5803,8 @@ let Group = Action_Group in { def emit_obj : Flag<["-"], "emit-obj">, HelpText<"Emit native object files">; +def init_only : Flag<["-"], "init-only">, + HelpText<"Only execute frontend initialization">; } // let Group = Action_Group } // let Flags = [CC1Option, FC1Option, NoDriverOption] @@ -5444,6 +5908,9 @@ def _SLASH_diagnostics_classic : CLFlag<"diagnostics:classic">, def _SLASH_D : CLJoinedOrSeparate<"D">, HelpText<"Define macro">, MetaVarName<"<macro[=value]>">, Alias<D>; def _SLASH_E : CLFlag<"E">, HelpText<"Preprocess to stdout">, Alias<E>; +def _SLASH_external_COLON_I : CLJoinedOrSeparate<"external:I">, Alias<isystem>, + HelpText<"Add directory to include search path with warnings suppressed">, + MetaVarName<"<dir>">; def _SLASH_fp_except : CLFlag<"fp:except">, HelpText<"">, Alias<ftrapping_math>; def _SLASH_fp_except_ : CLFlag<"fp:except-">, HelpText<"">, Alias<fno_trapping_math>; @@ -5451,6 +5918,9 @@ def _SLASH_fp_fast : CLFlag<"fp:fast">, HelpText<"">, Alias<ffast_math>; def _SLASH_fp_precise : CLFlag<"fp:precise">, HelpText<"">, Alias<fno_fast_math>; def _SLASH_fp_strict : CLFlag<"fp:strict">, HelpText<"">, Alias<fno_fast_math>; +def _SLASH_fsanitize_EQ_address : CLFlag<"fsanitize=address">, + HelpText<"Enable AddressSanitizer">, + Alias<fsanitize_EQ>, AliasArgs<["address"]>; def _SLASH_GA : CLFlag<"GA">, Alias<ftlsmodel_EQ>, AliasArgs<["local-exec"]>, HelpText<"Assume thread-local variables are defined in the executable">; def _SLASH_GR : CLFlag<"GR">, HelpText<"Emit RTTI data (default)">; @@ -5540,7 +6010,7 @@ def _SLASH_execution_charset : CLCompileJoined<"execution-charset:">, HelpText<"Set runtime encoding, supports only UTF-8">, Alias<fexec_charset_EQ>; def _SLASH_std : CLCompileJoined<"std:">, - HelpText<"Set C++ version (c++14,c++17,c++latest)">; + HelpText<"Set language version (c++14,c++17,c++20,c++latest,c11,c17)">; def _SLASH_U : CLJoinedOrSeparate<"U">, HelpText<"Undefine macro">, MetaVarName<"<macro>">, Alias<U>; def _SLASH_validate_charset : CLFlag<"validate-charset">, @@ -5633,6 +6103,9 @@ def _SLASH_openmp_experimental : CLFlag<"openmp:experimental">, def _SLASH_tune : CLCompileJoined<"tune:">, HelpText<"Set CPU for optimization without affecting instruction set">, Alias<mtune_EQ>; +def _SLASH_QIntel_jcc_erratum : CLFlag<"QIntel-jcc-erratum">, + HelpText<"Align branches within 32-byte boundaries to mitigate the performance impact of the Intel JCC erratum.">, + Alias<mbranches_within_32B_boundaries>; // Non-aliases: @@ -5646,13 +6119,14 @@ def _SLASH_volatile_Group : OptionGroup<"</volatile group>">, def _SLASH_EH : CLJoined<"EH">, HelpText<"Set exception handling model">; def _SLASH_EP : CLFlag<"EP">, HelpText<"Disable linemarker output and preprocess to stdout">; +def _SLASH_external_env : CLJoined<"external:env:">, + HelpText<"Add dirs in env var <var> to include search path with warnings suppressed">, + MetaVarName<"<var>">; def _SLASH_FA : CLFlag<"FA">, HelpText<"Output assembly code file during compilation">; def _SLASH_Fa : CLJoined<"Fa">, HelpText<"Set assembly output file name (with /FA)">, MetaVarName<"<file or dir/>">; -def _SLASH_fallback : CLCompileFlag<"fallback">, - HelpText<"Fall back to cl.exe if clang-cl fails to compile">; def _SLASH_FI : CLJoinedOrSeparate<"FI">, HelpText<"Include file before parsing">, Alias<include_>; def _SLASH_Fe : CLJoined<"Fe">, @@ -5666,7 +6140,8 @@ def _SLASH_Fo : CLCompileJoined<"Fo">, HelpText<"Set output object file (with /c)">, MetaVarName<"<file or dir/>">; def _SLASH_guard : CLJoined<"guard:">, - HelpText<"Enable Control Flow Guard with /guard:cf, or only the table with /guard:cf,nochecks">; + HelpText<"Enable Control Flow Guard with /guard:cf, or only the table with /guard:cf,nochecks. " + "Enable EH Continuation Guard with /guard:ehcont">; def _SLASH_GX : CLFlag<"GX">, HelpText<"Deprecated; use /EHsc">; def _SLASH_GX_ : CLFlag<"GX-">, @@ -5690,6 +6165,10 @@ def _SLASH_o : CLJoinedOrSeparate<"o">, HelpText<"Deprecated (set output file name); use /Fe or /Fe">, MetaVarName<"<file or dir/>">; def _SLASH_P : CLFlag<"P">, HelpText<"Preprocess to file">; +def _SLASH_permissive : CLFlag<"permissive">, + HelpText<"Enable some non conforming code to compile">; +def _SLASH_permissive_ : CLFlag<"permissive-">, + HelpText<"Disable non conforming code from compiling (default)">; def _SLASH_Tc : CLCompileJoinedOrSeparate<"Tc">, HelpText<"Treat <file> as C source file">, MetaVarName<"<file>">; def _SLASH_TC : CLCompileFlag<"TC">, HelpText<"Treat all source files as C">; @@ -5698,6 +6177,15 @@ def _SLASH_Tp : CLCompileJoinedOrSeparate<"Tp">, def _SLASH_TP : CLCompileFlag<"TP">, HelpText<"Treat all source files as C++">; def _SLASH_vctoolsdir : CLJoinedOrSeparate<"vctoolsdir">, HelpText<"Path to the VCToolChain">, MetaVarName<"<dir>">; +def _SLASH_vctoolsversion : CLJoinedOrSeparate<"vctoolsversion">, + HelpText<"For use with /winsysroot, defaults to newest found">; +def _SLASH_winsdkdir : CLJoinedOrSeparate<"winsdkdir">, + HelpText<"Path to the Windows SDK">, MetaVarName<"<dir>">; +def _SLASH_winsdkversion : CLJoinedOrSeparate<"winsdkversion">, + HelpText<"Full version of the Windows SDK, defaults to newest found">; +def _SLASH_winsysroot : CLJoinedOrSeparate<"winsysroot">, + HelpText<"Same as /vctoolsdir <dir>/VC/Tools/MSVC/<vctoolsversion> /winsdkdir <dir>/Windows Kits/10">, + MetaVarName<"<dir>">; def _SLASH_volatile_iso : Option<["/", "-"], "volatile:iso", KIND_FLAG>, Group<_SLASH_volatile_Group>, Flags<[CLOption, NoXarchOption]>, HelpText<"Volatile loads and stores have standard semantics">; @@ -5762,7 +6250,6 @@ def _SLASH_FS : CLIgnoredFlag<"FS">; def _SLASH_JMC : CLIgnoredFlag<"JMC">; def _SLASH_kernel_ : CLIgnoredFlag<"kernel-">; def _SLASH_nologo : CLIgnoredFlag<"nologo">; -def _SLASH_permissive_ : CLIgnoredFlag<"permissive-">; def _SLASH_RTC : CLIgnoredJoined<"RTC">; def _SLASH_sdl : CLIgnoredFlag<"sdl">; def _SLASH_sdl_ : CLIgnoredFlag<"sdl-">; @@ -5787,6 +6274,7 @@ def _SLASH_Zo_ : CLIgnoredFlag<"Zo-">; // Unsupported: def _SLASH_await : CLFlag<"await">; +def _SLASH_await_COLON : CLJoined<"await:">; def _SLASH_constexpr : CLJoined<"constexpr:">; def _SLASH_AI : CLJoinedOrSeparate<"AI">; def _SLASH_Bt : CLFlag<"Bt">; @@ -5794,8 +6282,13 @@ def _SLASH_Bt_plus : CLFlag<"Bt+">; def _SLASH_clr : CLJoined<"clr">; def _SLASH_d2 : CLJoined<"d2">; def _SLASH_doc : CLJoined<"doc">; +def _SLASH_experimental : CLJoined<"experimental:">; +def _SLASH_exportHeader : CLFlag<"exportHeader">; +def _SLASH_external : CLJoined<"external:">; def _SLASH_FA_joined : CLJoined<"FA">; def _SLASH_favor : CLJoined<"favor">; +def _SLASH_fsanitize_address_use_after_return : CLJoined<"fsanitize-address-use-after-return">; +def _SLASH_fno_sanitize_address_vcasan_lib : CLJoined<"fno-sanitize-address-vcasan-lib">; def _SLASH_F : CLJoinedOrSeparate<"F">; def _SLASH_Fm : CLJoined<"Fm">; def _SLASH_Fr : CLJoined<"Fr">; @@ -5814,6 +6307,10 @@ def _SLASH_Gm_ : CLFlag<"Gm-">; def _SLASH_GT : CLFlag<"GT">; def _SLASH_GZ : CLFlag<"GZ">; def _SLASH_H : CLFlag<"H">; +def _SLASH_headername : CLJoined<"headerName:">; +def _SLASH_headerUnit : CLJoinedOrSeparate<"headerUnit">; +def _SLASH_headerUnitAngle : CLJoinedOrSeparate<"headerUnit:angle">; +def _SLASH_headerUnitQuote : CLJoinedOrSeparate<"headerUnit:quote">; def _SLASH_homeparams : CLFlag<"homeparams">; def _SLASH_hotpatch : CLFlag<"hotpatch">; def _SLASH_kernel : CLFlag<"kernel">; @@ -5821,7 +6318,6 @@ def _SLASH_LN : CLFlag<"LN">; def _SLASH_MP : CLJoined<"MP">; def _SLASH_Qfast_transcendentals : CLFlag<"Qfast_transcendentals">; def _SLASH_QIfist : CLFlag<"QIfist">; -def _SLASH_QIntel_jcc_erratum : CLFlag<"QIntel-jcc-erratum">; def _SLASH_Qimprecise_fwaits : CLFlag<"Qimprecise_fwaits">; def _SLASH_Qpar : CLFlag<"Qpar">; def _SLASH_Qpar_report : CLJoined<"Qpar-report">; @@ -5830,6 +6326,10 @@ def _SLASH_Qspectre : CLFlag<"Qspectre">; def _SLASH_Qspectre_load : CLFlag<"Qspectre-load">; def _SLASH_Qspectre_load_cf : CLFlag<"Qspectre-load-cf">; def _SLASH_Qvec_report : CLJoined<"Qvec-report">; +def _SLASH_reference : CLJoinedOrSeparate<"reference">; +def _SLASH_sourceDependencies : CLJoinedOrSeparate<"sourceDependencies">; +def _SLASH_sourceDependenciesDirectives : CLJoinedOrSeparate<"sourceDependencies:directives">; +def _SLASH_translateInclude : CLFlag<"translateInclude">; def _SLASH_u : CLFlag<"u">; def _SLASH_V : CLFlag<"V">; def _SLASH_WL : CLFlag<"WL">; diff --git a/clang/include/clang/Driver/SanitizerArgs.h b/clang/include/clang/Driver/SanitizerArgs.h index ac2b817be1dc..e9e329e7cb53 100644 --- a/clang/include/clang/Driver/SanitizerArgs.h +++ b/clang/include/clang/Driver/SanitizerArgs.h @@ -12,6 +12,7 @@ #include "clang/Driver/Types.h" #include "llvm/Option/Arg.h" #include "llvm/Option/ArgList.h" +#include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h" #include <string> #include <vector> @@ -25,10 +26,10 @@ class SanitizerArgs { SanitizerSet RecoverableSanitizers; SanitizerSet TrapSanitizers; - std::vector<std::string> UserBlacklistFiles; - std::vector<std::string> SystemBlacklistFiles; + std::vector<std::string> UserIgnorelistFiles; + std::vector<std::string> SystemIgnorelistFiles; std::vector<std::string> CoverageAllowlistFiles; - std::vector<std::string> CoverageBlocklistFiles; + std::vector<std::string> CoverageIgnorelistFiles; int CoverageFeatures = 0; int MsanTrackOrigins = 0; bool MsanUseAfterDtor = true; @@ -43,6 +44,8 @@ class SanitizerArgs { bool AsanUseOdrIndicator = false; bool AsanInvalidPointerCmp = false; bool AsanInvalidPointerSub = false; + bool AsanOutlineInstrumentation = false; + llvm::AsanDtorKind AsanDtorKind = llvm::AsanDtorKind::Invalid; std::string HwasanAbi; bool LinkRuntimes = true; bool LinkCXXRuntimes = false; @@ -56,6 +59,9 @@ class SanitizerArgs { // True if cross-dso CFI support if provided by the system (i.e. Android). bool ImplicitCfiRuntime = false; bool NeedsMemProfRt = false; + bool HwasanUseAliases = false; + llvm::AsanDetectStackUseAfterReturnMode AsanUseAfterReturn = + llvm::AsanDetectStackUseAfterReturnMode::Invalid; public: /// Parses the sanitizer arguments from an argument list. @@ -68,6 +74,9 @@ public: bool needsHwasanRt() const { return Sanitizers.has(SanitizerKind::HWAddress); } + bool needsHwasanAliasesRt() const { + return needsHwasanRt() && HwasanUseAliases; + } bool needsTsanRt() const { return Sanitizers.has(SanitizerKind::Thread); } bool needsMsanRt() const { return Sanitizers.has(SanitizerKind::Memory); } bool needsFuzzer() const { return Sanitizers.has(SanitizerKind::Fuzzer); } diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index 28c37a44e1eb..882ae40086ce 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -166,6 +166,10 @@ private: EffectiveTriple = std::move(ET); } + mutable llvm::Optional<CXXStdlibType> cxxStdlibType; + mutable llvm::Optional<RuntimeLibType> runtimeLibType; + mutable llvm::Optional<UnwindLibType> unwindLibType; + protected: MultilibSet Multilibs; Multilib SelectedMultilib; @@ -180,6 +184,11 @@ protected: virtual Tool *buildStaticLibTool() const; virtual Tool *getTool(Action::ActionClass AC) const; + virtual std::string buildCompilerRTBasename(const llvm::opt::ArgList &Args, + StringRef Component, + FileType Type, + bool AddArch) const; + /// \name Utilities for implementing subclasses. ///@{ static void addSystemInclude(const llvm::opt::ArgList &DriverArgs, @@ -371,6 +380,10 @@ public: /// Check if the toolchain should use the integrated assembler. virtual bool useIntegratedAs() const; + /// Check if the toolchain should use AsmParser to parse inlineAsm when + /// integrated assembler is not default. + virtual bool parseInlineAsmUsingAsmParser() const { return false; } + /// IsMathErrnoDefault - Does this tool chain use -fmath-errno by default. virtual bool IsMathErrnoDefault() const { return true; } @@ -428,16 +441,15 @@ public: getCompilerRTArgString(const llvm::opt::ArgList &Args, StringRef Component, FileType Type = ToolChain::FT_Static) const; - virtual std::string - getCompilerRTBasename(const llvm::opt::ArgList &Args, StringRef Component, - FileType Type = ToolChain::FT_Static, - bool AddArch = true) const; + std::string getCompilerRTBasename(const llvm::opt::ArgList &Args, + StringRef Component, + FileType Type = ToolChain::FT_Static) const; // Returns target specific runtime path if it exists. - virtual Optional<std::string> getRuntimePath() const; + virtual std::string getRuntimePath() const; - // Returns target specific C++ library path if it exists. - virtual Optional<std::string> getCXXStdlibPath() const; + // Returns target specific standard library path if it exists. + virtual std::string getStdlibPath() const; // Returns <ResourceDir>/lib/<OSName>/<arch>. This is used by runtimes (such // as OpenMP) to find arch-specific libraries. @@ -456,6 +468,12 @@ public: /// by default. virtual bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const; + /// Test whether this toolchain supports outline atomics by default. + virtual bool + IsAArch64OutlineAtomicsDefault(const llvm::opt::ArgList &Args) const { + return false; + } + /// Test whether this toolchain defaults to PIC. virtual bool isPICDefault() const = 0; @@ -528,6 +546,12 @@ public: /// isThreadModelSupported() - Does this target support a thread model? virtual bool isThreadModelSupported(const StringRef Model) const; + virtual std::string getMultiarchTriple(const Driver &D, + const llvm::Triple &TargetTriple, + StringRef SysRoot) const { + return TargetTriple.str(); + } + /// ComputeLLVMTriple - Return the LLVM target triple to use, after taking /// command line arguments into account. virtual std::string @@ -589,6 +613,9 @@ public: // given compilation arguments. virtual UnwindLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const; + // Detect the highest available version of libc++ in include path. + virtual std::string detectLibcxxVersion(StringRef IncludePath) const; + /// AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set /// the include paths to use for the given C++ standard library type. virtual void @@ -653,6 +680,10 @@ public: virtual VersionTuple computeMSVCVersion(const Driver *D, const llvm::opt::ArgList &Args) const; + /// Get paths of HIP device libraries. + virtual llvm::SmallVector<std::string, 12> + getHIPDeviceLibs(const llvm::opt::ArgList &Args) const; + /// Return sanitizers which are available in this toolchain. virtual SanitizerMask getSupportedSanitizers() const; diff --git a/clang/include/clang/Driver/Types.def b/clang/include/clang/Driver/Types.def index 79e8d109cd97..997eea445c22 100644 --- a/clang/include/clang/Driver/Types.def +++ b/clang/include/clang/Driver/Types.def @@ -38,6 +38,7 @@ TYPE("cpp-output", PP_C, INVALID, "i", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("c", C, PP_C, "c", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("cl", CL, PP_C, "cl", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link) +TYPE("clcpp", CLCXX, PP_CXX, "clcpp", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("cuda-cpp-output", PP_CUDA, INVALID, "cui", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("cuda", CUDA, PP_CUDA, "cu", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("cuda", CUDA_DEVICE, PP_CUDA, "cu", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link) diff --git a/clang/include/clang/Driver/Types.h b/clang/include/clang/Driver/Types.h index 97bf5fd672ab..c9d63551090c 100644 --- a/clang/include/clang/Driver/Types.h +++ b/clang/include/clang/Driver/Types.h @@ -66,6 +66,14 @@ namespace types { /// isAcceptedByClang - Can clang handle this input type. bool isAcceptedByClang(ID Id); + /// isDerivedFromC - Is the input derived from C. + /// + /// That is, does the lexer follow the rules of + /// TokenConcatenation::AvoidConcat. If this is the case, the preprocessor may + /// add and remove whitespace between tokens. Used to determine whether the + /// input can be processed by -fminimize-whitespace. + bool isDerivedFromC(ID Id); + /// isCXX - Is this a "C++" input (C++ and Obj-C++ sources and headers). bool isCXX(ID Id); @@ -81,6 +89,9 @@ namespace types { /// isObjC - Is this an "ObjC" input (Obj-C and Obj-C++ sources and headers). bool isObjC(ID Id); + /// isOpenCL - Is this an "OpenCL" input. + bool isOpenCL(ID Id); + /// isFortran - Is this a Fortran input. bool isFortran(ID Id); diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index 96c2a74e97db..c424e79a971c 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -19,6 +19,7 @@ #include "clang/Tooling/Inclusions/IncludeStyle.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/Regex.h" +#include "llvm/Support/SourceMgr.h" #include <system_error> namespace llvm { @@ -52,6 +53,11 @@ std::error_code make_error_code(ParseError e); /// The ``FormatStyle`` is used to configure the formatting to follow /// specific guidelines. struct FormatStyle { + // If the BasedOn: was InheritParentConfig and this style needs the file from + // the parent directories. It is not part of the actual style for formatting. + // Thus the // instead of ///. + bool InheritsParentConfig; + /// The extra indent or outdent of access modifiers, e.g. ``public:``. int AccessModifierOffset; @@ -84,6 +90,35 @@ struct FormatStyle { /// brackets. BracketAlignmentStyle AlignAfterOpenBracket; + /// Different style for aligning array initializers. + enum ArrayInitializerAlignmentStyle { + /// Align array column and left justify the columns e.g.: + /// \code + /// struct test demo[] = + /// { + /// {56, 23, "hello"}, + /// {-1, 93463, "world"}, + /// {7, 5, "!!" } + /// }; + /// \endcode + AIAS_Left, + /// Align array column and right justify the columns e.g.: + /// \code + /// struct test demo[] = + /// { + /// {56, 23, "hello"}, + /// {-1, 93463, "world"}, + /// { 7, 5, "!!"} + /// }; + /// \endcode + AIAS_Right, + /// Don't align array initializer columns. + AIAS_None + }; + /// if not ``None``, when using initialization for an array of structs + /// aligns the fields into columns. + ArrayInitializerAlignmentStyle AlignArrayOfStructures; + /// Styles for alignment of consecutive tokens. Tokens can be assignment signs /// (see /// ``AlignConsecutiveAssignments``), bitfield member separators (see @@ -614,37 +649,74 @@ struct FormatStyle { /// single line. ShortFunctionStyle AllowShortFunctionsOnASingleLine; - /// Different styles for handling short if lines + /// Different styles for handling short if statements. enum ShortIfStyle : unsigned char { /// Never put short ifs on the same line. /// \code /// if (a) - /// return ; + /// return; + /// + /// if (b) + /// return; + /// else + /// return; + /// + /// if (c) + /// return; /// else { /// return; /// } /// \endcode SIS_Never, - /// Without else put short ifs on the same line only if - /// the else is not a compound statement. + /// Put short ifs on the same line only if there is no else statement. /// \code /// if (a) return; + /// + /// if (b) + /// return; /// else /// return; + /// + /// if (c) + /// return; + /// else { + /// return; + /// } /// \endcode SIS_WithoutElse, - /// Always put short ifs on the same line if - /// the else is not a compound statement or not. + /// Put short ifs, but not else ifs nor else statements, on the same line. /// \code /// if (a) return; + /// + /// if (b) return; + /// else if (b) + /// return; + /// else + /// return; + /// + /// if (c) return; /// else { /// return; /// } /// \endcode - SIS_Always, + SIS_OnlyFirstIf, + /// Always put short ifs, else ifs and else statements on the same + /// line. + /// \code + /// if (a) return; + /// + /// if (b) return; + /// else return; + /// + /// if (c) return; + /// else { + /// return; + /// } + /// \endcode + SIS_AllIfsAndElse, }; - /// If ``true``, ``if (a) return;`` can be put on a single line. + /// Dependent on the value, ``if (a) return;`` can be put on a single line. ShortIfStyle AllowShortIfStatementsOnASingleLine; /// Different styles for merging short lambdas containing at most one @@ -1786,7 +1858,14 @@ struct FormatStyle { /// Base2 /// {}; /// \endcode - BILS_AfterColon + BILS_AfterColon, + /// Break inheritance list only after the commas. + /// \code + /// class Foo : Base1, + /// Base2 + /// {}; + /// \endcode + BILS_AfterComma, }; /// The inheritance list style to use. @@ -1885,6 +1964,56 @@ struct FormatStyle { /// Disables formatting completely. bool DisableFormat; + /// Different styles for empty line after access modifiers. + /// ``EmptyLineBeforeAccessModifier`` configuration handles the number of + /// empty lines between two access modifiers. + enum EmptyLineAfterAccessModifierStyle : unsigned char { + /// Remove all empty lines after access modifiers. + /// \code + /// struct foo { + /// private: + /// int i; + /// protected: + /// int j; + /// /* comment */ + /// public: + /// foo() {} + /// private: + /// protected: + /// }; + /// \endcode + ELAAMS_Never, + /// Keep existing empty lines after access modifiers. + /// MaxEmptyLinesToKeep is applied instead. + ELAAMS_Leave, + /// Always add empty line after access modifiers if there are none. + /// MaxEmptyLinesToKeep is applied also. + /// \code + /// struct foo { + /// private: + /// + /// int i; + /// protected: + /// + /// int j; + /// /* comment */ + /// public: + /// + /// foo() {} + /// private: + /// + /// protected: + /// + /// }; + /// \endcode + ELAAMS_Always, + }; + + /// Defines when to put an empty line after access modifiers. + /// ``EmptyLineBeforeAccessModifier`` configuration handles the number of + /// empty lines between two access modifiers. + EmptyLineAfterAccessModifierStyle EmptyLineAfterAccessModifier; + /// Different styles for empty line before access modifiers. enum EmptyLineBeforeAccessModifierStyle : unsigned char { /// Remove all empty lines before access modifiers. @@ -1959,12 +2088,14 @@ struct FormatStyle { /// not use this in config files, etc. Use at your own risk. bool ExperimentalAutoDetectBinPacking; - /// If ``true``, clang-format adds missing namespace end comments and - /// fixes invalid existing ones. + /// If ``true``, clang-format adds missing namespace end comments for + /// short namespaces and fixes invalid existing ones. Short ones are + /// controlled by "ShortNamespaceLines". /// \code /// true: false: /// namespace a { vs. namespace a { /// foo(); foo(); + /// bar(); bar(); /// } // namespace a } /// \endcode bool FixNamespaceComments; @@ -1986,6 +2117,26 @@ struct FormatStyle { /// For example: BOOST_FOREACH. std::vector<std::string> ForEachMacros; + /// A vector of macros that should be interpreted as conditionals + /// instead of as function calls. + /// + /// These are expected to be macros of the form: + /// \code + /// IF(...) + /// <conditional-body> + /// else IF(...) + /// <conditional-body> + /// \endcode + /// + /// In the .clang-format configuration file, this can be configured like: + /// \code{.yaml} + /// IfMacros: ['IF'] + /// \endcode + /// + /// For example: `KJ_IF_MAYBE + /// <https://github.com/capnproto/capnproto/blob/master/kjdoc/tour.md#maybes>`_ + std::vector<std::string> IfMacros; + /// \brief A vector of macros that should be interpreted as type declarations /// instead of as function calls. /// @@ -2042,6 +2193,32 @@ struct FormatStyle { tooling::IncludeStyle IncludeStyle; + /// Specify whether access modifiers should have their own indentation level. + /// + /// When ``false``, access modifiers are indented (or outdented) relative to + /// the record members, respecting the ``AccessModifierOffset``. Record + /// members are indented one level below the record. + /// When ``true``, access modifiers get their own indentation level. As a + /// consequence, record members are always indented 2 levels below the record, + /// regardless of the access modifier presence. Value of the + /// ``AccessModifierOffset`` is ignored. + /// \code + /// false: true: + /// class C { vs. class C { + /// class D { class D { + /// void bar(); void bar(); + /// protected: protected: + /// D(); D(); + /// }; }; + /// public: public: + /// C(); C(); + /// }; }; + /// void foo() { void foo() { + /// return 1; return 1; + /// } } + /// \endcode + bool IndentAccessModifiers; + /// Indent case labels one level from the switch statement. /// /// When ``false``, use the same indentation level as for the switch @@ -2316,6 +2493,8 @@ struct FormatStyle { LK_Java, /// Should be used for JavaScript. LK_JavaScript, + /// Should be used for JSON. + LK_Json, /// Should be used for Objective-C, Objective-C++. LK_ObjC, /// Should be used for Protocol Buffers @@ -2329,10 +2508,43 @@ struct FormatStyle { }; bool isCpp() const { return Language == LK_Cpp || Language == LK_ObjC; } bool isCSharp() const { return Language == LK_CSharp; } + bool isJson() const { return Language == LK_Json; } /// Language, this format style is targeted at. LanguageKind Language; + /// Indentation logic for lambda bodies. + enum LambdaBodyIndentationKind : unsigned char { + /// Align lambda body relative to the lambda signature. This is the default. + /// \code + /// someMethod( + /// [](SomeReallyLongLambdaSignatureArgument foo) { + /// return; + /// }); + /// \endcode + LBI_Signature, + /// Align lambda body relative to the indentation level of the outer scope + /// the lambda signature resides in. + /// \code + /// someMethod( + /// [](SomeReallyLongLambdaSignatureArgument foo) { + /// return; + /// }); + /// \endcode + LBI_OuterScope, + }; + + /// The indentation style of lambda bodies. ``Signature`` (the default) + /// causes the lambda body to be indented one additional level relative to + /// the indentation level of the signature. ``OuterScope`` forces the lambda + /// body to be indented one additional level relative to the parent scope + /// containing the lambda signature. For callback-heavy code, it may improve + /// readability to have the signature indented two levels and to use + /// ``OuterScope``. The KJ style guide requires ``OuterScope``. + /// `KJ style guide + /// <https://github.com/capnproto/capnproto/blob/master/kjdoc/style-guide.md>`_ + LambdaBodyIndentationKind LambdaBodyIndentation; + /// A regular expression matching macros that start a block. /// \code /// # With: @@ -2516,7 +2728,7 @@ struct FormatStyle { /// (counted relative to leading non-whitespace column). unsigned PenaltyIndentedWhitespace; - /// The ``&`` and ``*`` alignment style. + /// The ``&``, ``&&`` and ``*`` alignment style. enum PointerAlignmentStyle : unsigned char { /// Align pointer to the left. /// \code @@ -2538,6 +2750,20 @@ struct FormatStyle { /// Pointer and reference alignment style. PointerAlignmentStyle PointerAlignment; + /// The number of columns to use for indentation of preprocessor statements. + /// When set to -1 (default) ``IndentWidth`` is used also for preprocessor + /// statements. + /// \code + /// PPIndentWidth: 1 + /// + /// #ifdef __linux__ + /// # define FOO + /// #else + /// # define BAR + /// #endif + /// \endcode + int PPIndentWidth; + /// See documentation of ``RawStringFormats``. struct RawStringFormat { /// The language of this raw string. @@ -2597,6 +2823,31 @@ struct FormatStyle { /// \endcode std::vector<RawStringFormat> RawStringFormats; + /// \brief The ``&`` and ``&&`` alignment style. + enum ReferenceAlignmentStyle { + /// Align reference like ``PointerAlignment``. + RAS_Pointer, + /// Align reference to the left. + /// \code + /// int& a; + /// \endcode + RAS_Left, + /// Align reference to the right. + /// \code + /// int &a; + /// \endcode + RAS_Right, + /// Align reference in the middle. + /// \code + /// int & a; + /// \endcode + RAS_Middle + }; + + /// \brief Reference alignment style (overrides ``PointerAlignment`` for + /// references). + ReferenceAlignmentStyle ReferenceAlignment; + // clang-format off /// If ``true``, clang-format will attempt to re-flow comments. /// \code @@ -2613,13 +2864,65 @@ struct FormatStyle { bool ReflowComments; // clang-format on - /// If ``true``, clang-format will sort ``#includes``. + /// The maximal number of unwrapped lines that a short namespace spans. + /// Defaults to 1. + /// + /// This determines the maximum length of short namespaces by counting + /// unwrapped lines (i.e. containing neither opening nor closing + /// namespace brace) and makes "FixNamespaceComments" omit adding + /// end comments for those. /// \code - /// false: true: - /// #include "b.h" vs. #include "a.h" - /// #include "a.h" #include "b.h" + /// ShortNamespaceLines: 1 vs. ShortNamespaceLines: 0 + /// namespace a { namespace a { + /// int foo; int foo; + /// } } // namespace a + /// + /// ShortNamespaceLines: 1 vs. ShortNamespaceLines: 0 + /// namespace b { namespace b { + /// int foo; int foo; + /// int bar; int bar; + /// } // namespace b } // namespace b /// \endcode - bool SortIncludes; + unsigned ShortNamespaceLines; + + /// Include sorting options. + enum SortIncludesOptions : unsigned char { + /// Includes are never sorted. + /// \code + /// #include "B/A.h" + /// #include "A/B.h" + /// #include "a/b.h" + /// #include "A/b.h" + /// #include "B/a.h" + /// \endcode + SI_Never, + /// Includes are sorted in an ASCIIbetical or case sensitive fashion. + /// \code + /// #include "A/B.h" + /// #include "A/b.h" + /// #include "B/A.h" + /// #include "B/a.h" + /// #include "a/b.h" + /// \endcode + SI_CaseSensitive, + /// Includes are sorted in an alphabetical or case insensitive fashion. + /// \code + /// #include "A/B.h" + /// #include "A/b.h" + /// #include "a/b.h" + /// #include "B/A.h" + /// #include "B/a.h" + /// \endcode + SI_CaseInsensitive, + }; + + /// Controls if and how clang-format will sort ``#includes``. + /// If ``Never``, includes are never sorted. + /// If ``CaseInsensitive``, includes are sorted in an ASCIIbetical or case + /// insensitive fashion. + /// If ``CaseSensitive``, includes are sorted in an alphabetical or case + /// sensitive fashion. + SortIncludesOptions SortIncludes; /// Position for Java Static imports. enum SortJavaStaticImportOptions : unsigned char { @@ -2778,8 +3081,10 @@ struct FormatStyle { /// \endcode SBPO_ControlStatements, /// Same as ``SBPO_ControlStatements`` except this option doesn't apply to - /// ForEach macros. This is useful in projects where ForEach macros are - /// treated as function calls instead of control statements. + /// ForEach and If macros. This is useful in projects where ForEach/If + /// macros are treated as function calls instead of control statements. + /// ``SBPO_ControlStatementsExceptForEachMacros`` remains an alias for + /// backward compatability. /// \code /// void f() { /// Q_FOREACH(...) { @@ -2787,7 +3092,7 @@ struct FormatStyle { /// } /// } /// \endcode - SBPO_ControlStatementsExceptForEachMacros, + SBPO_ControlStatementsExceptControlMacros, /// Put a space before opening parentheses only if the parentheses are not /// empty i.e. '()' /// \code @@ -2860,14 +3165,27 @@ struct FormatStyle { /// \endcode unsigned SpacesBeforeTrailingComments; - /// If ``true``, spaces will be inserted after ``<`` and before ``>`` - /// in template argument lists. - /// \code - /// true: false: - /// static_cast< int >(arg); vs. static_cast<int>(arg); - /// std::function< void(int) > fct; std::function<void(int)> fct; - /// \endcode - bool SpacesInAngles; + /// Styles for adding spacing after ``<`` and before ``>` + /// in template argument lists. + enum SpacesInAnglesStyle : unsigned char { + /// Remove spaces after ``<`` and before ``>``. + /// \code + /// static_cast<int>(arg); + /// std::function<void(int)> fct; + /// \endcode + SIAS_Never, + /// Add spaces after ``<`` and before ``>``. + /// \code + /// static_cast< int >(arg); + /// std::function< void(int) > fct; + /// \endcode + SIAS_Always, + /// Keep a single space after ``<`` and before ``>`` if any spaces were + /// present. Option ``Standard: Cpp03`` takes precedence. + SIAS_Leave + }; + /// The SpacesInAnglesStyle to use for template argument lists. + SpacesInAnglesStyle SpacesInAngles; /// If ``true``, spaces will be inserted around if/for/switch/while /// conditions. @@ -2894,6 +3212,43 @@ struct FormatStyle { /// \endcode bool SpacesInCStyleCastParentheses; + /// Control of spaces within a single line comment + struct SpacesInLineComment { + /// The minimum number of spaces at the start of the comment. + unsigned Minimum; + /// The maximum number of spaces at the start of the comment. + unsigned Maximum; + }; + + /// How many spaces are allowed at the start of a line comment. To disable the + /// maximum set it to ``-1``, apart from that the maximum takes precedence + /// over the minimum. + /// \code Minimum = 1 Maximum = -1 + /// // One space is forced + /// + /// // but more spaces are possible + /// + /// Minimum = 0 + /// Maximum = 0 + /// //Forces to start every comment directly after the slashes + /// \endcode + /// + /// Note that in line comment sections the relative indent of the subsequent + /// lines is kept, that means the following: + /// \code + /// before: after: + /// Minimum: 1 + /// //if (b) { // if (b) { + /// // return true; // return true; + /// //} // } + /// + /// Maximum: 0 + /// /// List: ///List: + /// /// - Foo /// - Foo + /// /// - Bar /// - Bar + /// \endcode + SpacesInLineComment SpacesInLineCommentPrefix; + /// If ``true``, spaces will be inserted after ``(`` and before ``)``. /// \code /// true: false: @@ -3028,6 +3383,7 @@ struct FormatStyle { bool operator==(const FormatStyle &R) const { return AccessModifierOffset == R.AccessModifierOffset && AlignAfterOpenBracket == R.AlignAfterOpenBracket && + AlignArrayOfStructures == R.AlignArrayOfStructures && AlignConsecutiveAssignments == R.AlignConsecutiveAssignments && AlignConsecutiveBitFields == R.AlignConsecutiveBitFields && AlignConsecutiveDeclarations == R.AlignConsecutiveDeclarations && @@ -3077,6 +3433,7 @@ struct FormatStyle { DeriveLineEnding == R.DeriveLineEnding && DerivePointerAlignment == R.DerivePointerAlignment && DisableFormat == R.DisableFormat && + EmptyLineAfterAccessModifier == R.EmptyLineAfterAccessModifier && EmptyLineBeforeAccessModifier == R.EmptyLineBeforeAccessModifier && ExperimentalAutoDetectBinPacking == R.ExperimentalAutoDetectBinPacking && @@ -3088,6 +3445,7 @@ struct FormatStyle { R.IncludeStyle.IncludeIsMainRegex && IncludeStyle.IncludeIsMainSourceRegex == R.IncludeStyle.IncludeIsMainSourceRegex && + IndentAccessModifiers == R.IndentAccessModifiers && IndentCaseLabels == R.IndentCaseLabels && IndentCaseBlocks == R.IndentCaseBlocks && IndentGotoLabels == R.IndentGotoLabels && @@ -3101,6 +3459,7 @@ struct FormatStyle { JavaScriptWrapImports == R.JavaScriptWrapImports && KeepEmptyLinesAtTheStartOfBlocks == R.KeepEmptyLinesAtTheStartOfBlocks && + LambdaBodyIndentation == R.LambdaBodyIndentation && MacroBlockBegin == R.MacroBlockBegin && MacroBlockEnd == R.MacroBlockEnd && MaxEmptyLinesToKeep == R.MaxEmptyLinesToKeep && @@ -3124,6 +3483,9 @@ struct FormatStyle { R.PenaltyBreakTemplateDeclaration && PointerAlignment == R.PointerAlignment && RawStringFormats == R.RawStringFormats && + ReferenceAlignment == R.ReferenceAlignment && + ShortNamespaceLines == R.ShortNamespaceLines && + SortIncludes == R.SortIncludes && SortJavaStaticImport == R.SortJavaStaticImport && SpaceAfterCStyleCast == R.SpaceAfterCStyleCast && SpaceAfterLogicalNot == R.SpaceAfterLogicalNot && @@ -3145,6 +3507,10 @@ struct FormatStyle { SpacesInConditionalStatement == R.SpacesInConditionalStatement && SpacesInContainerLiterals == R.SpacesInContainerLiterals && SpacesInCStyleCastParentheses == R.SpacesInCStyleCastParentheses && + SpacesInLineCommentPrefix.Minimum == + R.SpacesInLineCommentPrefix.Minimum && + SpacesInLineCommentPrefix.Maximum == + R.SpacesInLineCommentPrefix.Maximum && SpacesInParentheses == R.SpacesInParentheses && SpacesInSquareBrackets == R.SpacesInSquareBrackets && SpaceBeforeSquareBrackets == R.SpaceBeforeSquareBrackets && @@ -3191,9 +3557,11 @@ struct FormatStyle { private: FormatStyleSet StyleSet; - friend std::error_code parseConfiguration(llvm::MemoryBufferRef Config, - FormatStyle *Style, - bool AllowUnknownOptions); + friend std::error_code + parseConfiguration(llvm::MemoryBufferRef Config, FormatStyle *Style, + bool AllowUnknownOptions, + llvm::SourceMgr::DiagHandlerTy DiagHandler, + void *DiagHandlerCtxt); }; /// Returns a format style complying with the LLVM coding standards: @@ -3251,9 +3619,13 @@ bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language, /// /// If AllowUnknownOptions is true, no errors are emitted if unknown /// format options are occured. -std::error_code parseConfiguration(llvm::MemoryBufferRef Config, - FormatStyle *Style, - bool AllowUnknownOptions = false); +/// +/// If set all diagnostics are emitted through the DiagHandler. +std::error_code +parseConfiguration(llvm::MemoryBufferRef Config, FormatStyle *Style, + bool AllowUnknownOptions = false, + llvm::SourceMgr::DiagHandlerTy DiagHandler = nullptr, + void *DiagHandlerCtx = nullptr); /// Like above but accepts an unnamed buffer. inline std::error_code parseConfiguration(StringRef Config, FormatStyle *Style, @@ -3427,6 +3799,8 @@ inline StringRef getLanguageName(FormatStyle::LanguageKind Language) { return "Java"; case FormatStyle::LK_JavaScript: return "JavaScript"; + case FormatStyle::LK_Json: + return "Json"; case FormatStyle::LK_Proto: return "Proto"; case FormatStyle::LK_TableGen: diff --git a/clang/include/clang/Frontend/CommandLineSourceLoc.h b/clang/include/clang/Frontend/CommandLineSourceLoc.h index 0827433462e1..dfc4454b4baf 100644 --- a/clang/include/clang/Frontend/CommandLineSourceLoc.h +++ b/clang/include/clang/Frontend/CommandLineSourceLoc.h @@ -48,6 +48,13 @@ public: return PSL; } + + /// Serialize ParsedSourceLocation back to a string. + std::string ToString() const { + return (llvm::Twine(FileName == "<stdin>" ? "-" : FileName) + ":" + + Twine(Line) + ":" + Twine(Column)) + .str(); + } }; /// A source range that has been parsed on the command line. diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h index 57632f8770f0..861b15020329 100644 --- a/clang/include/clang/Frontend/CompilerInstance.h +++ b/clang/include/clang/Frontend/CompilerInstance.h @@ -22,6 +22,7 @@ #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/BuryPointer.h" +#include "llvm/Support/FileSystem.h" #include <cassert> #include <list> #include <memory> @@ -150,7 +151,7 @@ class CompilerInstance : public ModuleLoader { bool HaveFullGlobalModuleIndex = false; /// One or more modules failed to build. - bool ModuleBuildFailed = false; + bool DisableGeneratingGlobalModuleIndex = false; /// The stream for verbose output if owned, otherwise nullptr. std::unique_ptr<raw_ostream> OwnedVerboseOutputStream; @@ -165,11 +166,10 @@ class CompilerInstance : public ModuleLoader { /// failed. struct OutputFile { std::string Filename; - std::string TempFilename; + Optional<llvm::sys::fs::TempFile> File; - OutputFile(std::string filename, std::string tempFilename) - : Filename(std::move(filename)), TempFilename(std::move(tempFilename)) { - } + OutputFile(std::string filename, Optional<llvm::sys::fs::TempFile> file) + : Filename(std::move(filename)), File(std::move(file)) {} }; /// The list of active output files. @@ -382,6 +382,9 @@ public: /// Replace the current AuxTarget. void setAuxTarget(TargetInfo *Value); + // Create Target and AuxTarget based on current options + bool createTarget(); + /// } /// @name Virtual File System /// { @@ -693,15 +696,13 @@ public: /// The files created by this are usually removed on signal, and, depending /// on FrontendOptions, may also use a temporary file (that is, the data is /// written to a temporary file which will atomically replace the target - /// output on success). If a client (like libclang) needs to disable - /// RemoveFileOnSignal, temporary files will be forced on. + /// output on success). /// /// \return - Null on error. - std::unique_ptr<raw_pwrite_stream> - createDefaultOutputFile(bool Binary = true, StringRef BaseInput = "", - StringRef Extension = "", - bool RemoveFileOnSignal = true, - bool CreateMissingDirectories = false); + std::unique_ptr<raw_pwrite_stream> createDefaultOutputFile( + bool Binary = true, StringRef BaseInput = "", StringRef Extension = "", + bool RemoveFileOnSignal = true, bool CreateMissingDirectories = false, + bool ForceUseTemporary = false); /// Create a new output file, optionally deriving the output path name, and /// add it to the list of tracked output files. diff --git a/clang/include/clang/Frontend/CompilerInvocation.h b/clang/include/clang/Frontend/CompilerInvocation.h index 0d83a228c301..2245439d0632 100644 --- a/clang/include/clang/Frontend/CompilerInvocation.h +++ b/clang/include/clang/Frontend/CompilerInvocation.h @@ -61,7 +61,15 @@ bool ParseDiagnosticArgs(DiagnosticOptions &Opts, llvm::opt::ArgList &Args, DiagnosticsEngine *Diags = nullptr, bool DefaultDiagColor = true); -class CompilerInvocationBase { +/// The base class of CompilerInvocation with reference semantics. +/// +/// This class stores option objects behind reference-counted pointers. This is +/// useful for clients that want to keep some option object around even after +/// CompilerInvocation gets destroyed, without making a copy. +/// +/// This is a separate class so that we can implement the copy constructor and +/// assignment here and leave them defaulted in the rest of CompilerInvocation. +class CompilerInvocationRefBase { public: /// Options controlling the language variant. std::shared_ptr<LangOptions> LangOpts; @@ -78,10 +86,15 @@ public: /// Options controlling the preprocessor (aside from \#include handling). std::shared_ptr<PreprocessorOptions> PreprocessorOpts; - CompilerInvocationBase(); - CompilerInvocationBase(const CompilerInvocationBase &X); - CompilerInvocationBase &operator=(const CompilerInvocationBase &) = delete; - ~CompilerInvocationBase(); + /// Options controlling the static analyzer. + AnalyzerOptionsRef AnalyzerOpts; + + CompilerInvocationRefBase(); + CompilerInvocationRefBase(const CompilerInvocationRefBase &X); + CompilerInvocationRefBase(CompilerInvocationRefBase &&X); + CompilerInvocationRefBase &operator=(CompilerInvocationRefBase X); + CompilerInvocationRefBase &operator=(CompilerInvocationRefBase &&X); + ~CompilerInvocationRefBase(); LangOptions *getLangOpts() { return LangOpts.get(); } const LangOptions *getLangOpts() const { return LangOpts.get(); } @@ -110,17 +123,13 @@ public: const PreprocessorOptions &getPreprocessorOpts() const { return *PreprocessorOpts; } -}; -/// Helper class for holding the data necessary to invoke the compiler. -/// -/// This class is designed to represent an abstract "invocation" of the -/// compiler, including data such as the include paths, the code generation -/// options, the warning flags, and so on. -class CompilerInvocation : public CompilerInvocationBase { - /// Options controlling the static analyzer. - AnalyzerOptionsRef AnalyzerOpts; + AnalyzerOptionsRef getAnalyzerOpts() const { return AnalyzerOpts; } +}; +/// The base class of CompilerInvocation with value semantics. +class CompilerInvocationValueBase { +protected: MigratorOptions MigratorOpts; /// Options controlling IRgen and the backend. @@ -139,11 +148,46 @@ class CompilerInvocation : public CompilerInvocationBase { PreprocessorOutputOptions PreprocessorOutputOpts; public: - CompilerInvocation() : AnalyzerOpts(new AnalyzerOptions()) {} + MigratorOptions &getMigratorOpts() { return MigratorOpts; } + const MigratorOptions &getMigratorOpts() const { return MigratorOpts; } - /// @name Utility Methods - /// @{ + CodeGenOptions &getCodeGenOpts() { return CodeGenOpts; } + const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; } + + DependencyOutputOptions &getDependencyOutputOpts() { + return DependencyOutputOpts; + } + + const DependencyOutputOptions &getDependencyOutputOpts() const { + return DependencyOutputOpts; + } + + FileSystemOptions &getFileSystemOpts() { return FileSystemOpts; } + + const FileSystemOptions &getFileSystemOpts() const { + return FileSystemOpts; + } + + FrontendOptions &getFrontendOpts() { return FrontendOpts; } + const FrontendOptions &getFrontendOpts() const { return FrontendOpts; } + + PreprocessorOutputOptions &getPreprocessorOutputOpts() { + return PreprocessorOutputOpts; + } + + const PreprocessorOutputOptions &getPreprocessorOutputOpts() const { + return PreprocessorOutputOpts; + } +}; +/// Helper class for holding the data necessary to invoke the compiler. +/// +/// This class is designed to represent an abstract "invocation" of the +/// compiler, including data such as the include paths, the code generation +/// options, the warning flags, and so on. +class CompilerInvocation : public CompilerInvocationRefBase, + public CompilerInvocationValueBase { +public: /// Create a compiler invocation from a list of input options. /// \returns true on success. /// @@ -199,67 +243,41 @@ public: void generateCC1CommandLine(llvm::SmallVectorImpl<const char *> &Args, StringAllocator SA) const; - /// @} - /// @name Option Subgroups - /// @{ - - AnalyzerOptionsRef getAnalyzerOpts() const { return AnalyzerOpts; } - - MigratorOptions &getMigratorOpts() { return MigratorOpts; } - const MigratorOptions &getMigratorOpts() const { return MigratorOpts; } - - CodeGenOptions &getCodeGenOpts() { return CodeGenOpts; } - const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; } - - DependencyOutputOptions &getDependencyOutputOpts() { - return DependencyOutputOpts; - } - - const DependencyOutputOptions &getDependencyOutputOpts() const { - return DependencyOutputOpts; - } - - FileSystemOptions &getFileSystemOpts() { return FileSystemOpts; } - - const FileSystemOptions &getFileSystemOpts() const { - return FileSystemOpts; - } - - FrontendOptions &getFrontendOpts() { return FrontendOpts; } - const FrontendOptions &getFrontendOpts() const { return FrontendOpts; } - - PreprocessorOutputOptions &getPreprocessorOutputOpts() { - return PreprocessorOutputOpts; - } - - const PreprocessorOutputOptions &getPreprocessorOutputOpts() const { - return PreprocessorOutputOpts; - } - - /// @} - private: - /// Parse options for flags that expose marshalling information in their - /// table-gen definition - /// - /// \param Args - The argument list containing the arguments to parse - /// \param Diags - The DiagnosticsEngine associated with CreateFromArgs - /// \returns - True if parsing was successful, false otherwise - bool parseSimpleArgs(const llvm::opt::ArgList &Args, - DiagnosticsEngine &Diags); + static bool CreateFromArgsImpl(CompilerInvocation &Res, + ArrayRef<const char *> CommandLineArgs, + DiagnosticsEngine &Diags, const char *Argv0); + + /// Generate command line options from DiagnosticOptions. + static void GenerateDiagnosticArgs(const DiagnosticOptions &Opts, + SmallVectorImpl<const char *> &Args, + StringAllocator SA, bool DefaultDiagColor); /// Parse command line options that map to LangOptions. - static void ParseLangArgs(LangOptions &Opts, llvm::opt::ArgList &Args, + static bool ParseLangArgs(LangOptions &Opts, llvm::opt::ArgList &Args, InputKind IK, const llvm::Triple &T, std::vector<std::string> &Includes, DiagnosticsEngine &Diags); + /// Generate command line options from LangOptions. + static void GenerateLangArgs(const LangOptions &Opts, + SmallVectorImpl<const char *> &Args, + StringAllocator SA, const llvm::Triple &T, + InputKind IK); + /// Parse command line options that map to CodeGenOptions. static bool ParseCodeGenArgs(CodeGenOptions &Opts, llvm::opt::ArgList &Args, InputKind IK, DiagnosticsEngine &Diags, const llvm::Triple &T, const std::string &OutputFile, const LangOptions &LangOptsRef); + + // Generate command line options from CodeGenOptions. + static void GenerateCodeGenArgs(const CodeGenOptions &Opts, + SmallVectorImpl<const char *> &Args, + StringAllocator SA, const llvm::Triple &T, + const std::string &OutputFile, + const LangOptions *LangOpts); }; IntrusiveRefCntPtr<llvm::vfs::FileSystem> diff --git a/clang/include/clang/Frontend/DependencyOutputOptions.h b/clang/include/clang/Frontend/DependencyOutputOptions.h index 7a4f3337936f..78a2841d1e10 100644 --- a/clang/include/clang/Frontend/DependencyOutputOptions.h +++ b/clang/include/clang/Frontend/DependencyOutputOptions.h @@ -20,6 +20,14 @@ enum class ShowIncludesDestination { None, Stdout, Stderr }; /// DependencyOutputFormat - Format for the compiler dependency file. enum class DependencyOutputFormat { Make, NMake }; +/// ExtraDepKind - The kind of extra dependency file. +enum ExtraDepKind { + EDK_SanitizeIgnorelist, + EDK_ProfileList, + EDK_ModuleFile, + EDK_DepFileEntry, +}; + /// DependencyOutputOptions - Options for controlling the compiler dependency /// file generation. class DependencyOutputOptions { @@ -31,6 +39,10 @@ public: /// problems. unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to dependency list unsigned IncludeModuleFiles : 1; ///< Include module file dependencies. + unsigned ShowSkippedHeaderIncludes : 1; ///< With ShowHeaderIncludes, show + /// also includes that were skipped + /// due to the "include guard + /// optimization" or #pragma once. /// Destination of cl.exe style /showIncludes info. ShowIncludesDestination ShowIncludesDest = ShowIncludesDestination::None; @@ -51,8 +63,9 @@ public: /// must contain at least one entry. std::vector<std::string> Targets; - /// A list of filenames to be used as extra dependencies for every target. - std::vector<std::string> ExtraDeps; + /// A list of extra dependencies (filename and kind) to be used for every + /// target. + std::vector<std::pair<std::string, ExtraDepKind>> ExtraDeps; /// In /showIncludes mode, pretend the main TU is a header with this name. std::string ShowIncludesPretendHeader; @@ -66,7 +79,8 @@ public: public: DependencyOutputOptions() : IncludeSystemHeaders(0), ShowHeaderIncludes(0), UsePhonyTargets(0), - AddMissingHeaderDeps(0), IncludeModuleFiles(0) {} + AddMissingHeaderDeps(0), IncludeModuleFiles(0), + ShowSkippedHeaderIncludes(0) {} }; } // end namespace clang diff --git a/clang/include/clang/Frontend/FrontendAction.h b/clang/include/clang/Frontend/FrontendAction.h index 319b3bc62cc4..dfefddfb4527 100644 --- a/clang/include/clang/Frontend/FrontendAction.h +++ b/clang/include/clang/Frontend/FrontendAction.h @@ -234,7 +234,7 @@ public: /// Perform any per-file post processing, deallocate per-file /// objects, and run statistics and output file cleanup code. - void EndSourceFile(); + virtual void EndSourceFile(); /// @} }; @@ -302,15 +302,16 @@ public: /// some existing action's behavior. It implements every virtual method in /// the FrontendAction interface by forwarding to the wrapped action. class WrapperFrontendAction : public FrontendAction { +protected: std::unique_ptr<FrontendAction> WrappedAction; -protected: bool PrepareToExecuteAction(CompilerInstance &CI) override; std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override; bool BeginInvocation(CompilerInstance &CI) override; bool BeginSourceFileAction(CompilerInstance &CI) override; void ExecuteAction() override; + void EndSourceFile() override; void EndSourceFileAction() override; bool shouldEraseOutputFiles() override; diff --git a/clang/include/clang/Frontend/FrontendActions.h b/clang/include/clang/Frontend/FrontendActions.h index 25ca95980806..ff8d4417eaa4 100644 --- a/clang/include/clang/Frontend/FrontendActions.h +++ b/clang/include/clang/Frontend/FrontendActions.h @@ -34,6 +34,17 @@ public: bool usesPreprocessorOnly() const override { return false; } }; +/// Preprocessor-based frontend action that also loads PCH files. +class ReadPCHAndPreprocessAction : public FrontendAction { + void ExecuteAction() override; + + std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override; + +public: + bool usesPreprocessorOnly() const override { return false; } +}; + class DumpCompilerOptionsAction : public FrontendAction { std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override { diff --git a/clang/include/clang/Frontend/FrontendOptions.h b/clang/include/clang/Frontend/FrontendOptions.h index 223c1e05d053..15c905d712a3 100644 --- a/clang/include/clang/Frontend/FrontendOptions.h +++ b/clang/include/clang/Frontend/FrontendOptions.h @@ -15,10 +15,11 @@ #include "clang/Sema/CodeCompleteOptions.h" #include "clang/Serialization/ModuleFileExtension.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/MemoryBuffer.h" #include <cassert> +#include <map> #include <memory> #include <string> -#include <unordered_map> #include <vector> namespace llvm { @@ -374,6 +375,10 @@ public: std::string MTMigrateDir; std::string ARCMTMigrateReportOut; + /// The input kind, either specified via -x argument or deduced from the input + /// file name. + InputKind DashX; + /// The input files and their types. SmallVector<FrontendInputFile, 0> Inputs; @@ -400,7 +405,7 @@ public: std::string ActionName; /// Args to pass to the plugins - std::unordered_map<std::string,std::vector<std::string>> PluginArgs; + std::map<std::string, std::vector<std::string>> PluginArgs; /// The list of plugin actions to run in addition to the normal action. std::vector<std::string> AddPluginActions; diff --git a/clang/include/clang/Frontend/PreprocessorOutputOptions.h b/clang/include/clang/Frontend/PreprocessorOutputOptions.h index 72e5ad1137fb..257538ee0606 100644 --- a/clang/include/clang/Frontend/PreprocessorOutputOptions.h +++ b/clang/include/clang/Frontend/PreprocessorOutputOptions.h @@ -24,6 +24,7 @@ public: unsigned ShowIncludeDirectives : 1; ///< Print includes, imports etc. within preprocessed output. unsigned RewriteIncludes : 1; ///< Preprocess include directives only. unsigned RewriteImports : 1; ///< Include contents of transitively-imported modules. + unsigned MinimizeWhitespace : 1; ///< Ignore whitespace from input. public: PreprocessorOutputOptions() { @@ -36,6 +37,7 @@ public: ShowIncludeDirectives = 0; RewriteIncludes = 0; RewriteImports = 0; + MinimizeWhitespace = 0; } }; diff --git a/clang/include/clang/Frontend/TextDiagnostic.h b/clang/include/clang/Frontend/TextDiagnostic.h index 7cf54839afbe..a2eec46beccd 100644 --- a/clang/include/clang/Frontend/TextDiagnostic.h +++ b/clang/include/clang/Frontend/TextDiagnostic.h @@ -50,8 +50,7 @@ public: /// TextDiagnostic logic requires. static void printDiagnosticLevel(raw_ostream &OS, DiagnosticsEngine::Level Level, - bool ShowColors, - bool CLFallbackMode = false); + bool ShowColors); /// Pretty-print a diagnostic message to a raw_ostream. /// diff --git a/clang/include/clang/Index/CommentToXML.h b/clang/include/clang/Index/CommentToXML.h index 66b8650c5efb..29904f163dc7 100644 --- a/clang/include/clang/Index/CommentToXML.h +++ b/clang/include/clang/Index/CommentToXML.h @@ -10,7 +10,6 @@ #define LLVM_CLANG_INDEX_COMMENTTOXML_H #include "clang/Basic/LLVM.h" -#include <memory> namespace clang { class ASTContext; diff --git a/clang/include/clang/Index/DeclOccurrence.h b/clang/include/clang/Index/DeclOccurrence.h index 16f03a84579e..72f5799466bd 100644 --- a/clang/include/clang/Index/DeclOccurrence.h +++ b/clang/include/clang/Index/DeclOccurrence.h @@ -9,26 +9,31 @@ #ifndef LLVM_CLANG_INDEX_DECLOCCURRENCE_H #define LLVM_CLANG_INDEX_DECLOCCURRENCE_H +#include "clang/AST/DeclBase.h" #include "clang/Basic/LLVM.h" #include "clang/Index/IndexSymbol.h" +#include "clang/Lex/MacroInfo.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/SmallVector.h" namespace clang { -class Decl; - namespace index { struct DeclOccurrence { SymbolRoleSet Roles; unsigned Offset; - const Decl *Dcl; + llvm::PointerUnion<const Decl *, const MacroInfo *> DeclOrMacro; + const IdentifierInfo *MacroName = nullptr; SmallVector<SymbolRelation, 3> Relations; DeclOccurrence(SymbolRoleSet R, unsigned Offset, const Decl *D, ArrayRef<SymbolRelation> Relations) - : Roles(R), Offset(Offset), Dcl(D), + : Roles(R), Offset(Offset), DeclOrMacro(D), Relations(Relations.begin(), Relations.end()) {} + DeclOccurrence(SymbolRoleSet R, unsigned Offset, const IdentifierInfo *Name, + const MacroInfo *MI) + : Roles(R), Offset(Offset), DeclOrMacro(MI), MacroName(Name) {} friend bool operator<(const DeclOccurrence &LHS, const DeclOccurrence &RHS) { return LHS.Offset < RHS.Offset; diff --git a/clang/include/clang/Index/IndexSymbol.h b/clang/include/clang/Index/IndexSymbol.h index de98b8147e8a..2ba81986c2fe 100644 --- a/clang/include/clang/Index/IndexSymbol.h +++ b/clang/include/clang/Index/IndexSymbol.h @@ -75,6 +75,7 @@ enum class SymbolSubKind : uint8_t { AccessorSetter, UsingTypename, UsingValue, + UsingEnum, }; typedef uint16_t SymbolPropertySet; diff --git a/clang/include/clang/Index/IndexingOptions.h b/clang/include/clang/Index/IndexingOptions.h index 9f5c03d1b3b9..d19653848d59 100644 --- a/clang/include/clang/Index/IndexingOptions.h +++ b/clang/include/clang/Index/IndexingOptions.h @@ -28,6 +28,7 @@ struct IndexingOptions { SystemSymbolFilterKind::DeclarationsOnly; bool IndexFunctionLocals = false; bool IndexImplicitInstantiation = false; + bool IndexMacros = true; // Whether to index macro definitions in the Preprocesor when preprocessor // callback is not available (e.g. after parsing has finished). Note that // macro references are not available in Proprocessor. diff --git a/clang/include/clang/Interpreter/Interpreter.h b/clang/include/clang/Interpreter/Interpreter.h new file mode 100644 index 000000000000..020cbe2db3d0 --- /dev/null +++ b/clang/include/clang/Interpreter/Interpreter.h @@ -0,0 +1,71 @@ +//===--- Interpreter.h - Incremental Compilation and Execution---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines the component which performs incremental code +// compilation and execution. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_INTERPRETER_INTERPRETER_H +#define LLVM_CLANG_INTERPRETER_INTERPRETER_H + +#include "clang/Interpreter/PartialTranslationUnit.h" + +#include "llvm/Support/Error.h" + +#include <memory> +#include <vector> + +namespace llvm { +namespace orc { +class ThreadSafeContext; +} +class Module; +} // namespace llvm + +namespace clang { + +class CompilerInstance; +class DeclGroupRef; +class IncrementalExecutor; +class IncrementalParser; + +/// Create a pre-configured \c CompilerInstance for incremental processing. +class IncrementalCompilerBuilder { +public: + static llvm::Expected<std::unique_ptr<CompilerInstance>> + create(std::vector<const char *> &ClangArgv); +}; + +/// Provides top-level interfaces for incremental compilation and execution. +class Interpreter { + std::unique_ptr<llvm::orc::ThreadSafeContext> TSCtx; + std::unique_ptr<IncrementalParser> IncrParser; + std::unique_ptr<IncrementalExecutor> IncrExecutor; + + Interpreter(std::unique_ptr<CompilerInstance> CI, llvm::Error &Err); + +public: + ~Interpreter(); + static llvm::Expected<std::unique_ptr<Interpreter>> + create(std::unique_ptr<CompilerInstance> CI); + const CompilerInstance *getCompilerInstance() const; + llvm::Expected<PartialTranslationUnit &> Parse(llvm::StringRef Code); + llvm::Error Execute(PartialTranslationUnit &T); + llvm::Error ParseAndExecute(llvm::StringRef Code) { + auto PTU = Parse(Code); + if (!PTU) + return PTU.takeError(); + if (PTU->TheModule) + return Execute(*PTU); + return llvm::Error::success(); + } +}; +} // namespace clang + +#endif // LLVM_CLANG_INTERPRETER_INTERPRETER_H diff --git a/clang/include/clang/Interpreter/PartialTranslationUnit.h b/clang/include/clang/Interpreter/PartialTranslationUnit.h new file mode 100644 index 000000000000..bf91d559452b --- /dev/null +++ b/clang/include/clang/Interpreter/PartialTranslationUnit.h @@ -0,0 +1,37 @@ +//===--- Transaction.h - Incremental Compilation and Execution---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines utilities tracking the incrementally processed pieces of +// code. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_INTERPRETER_PARTIALTRANSLATIONUNIT_H +#define LLVM_CLANG_INTERPRETER_PARTIALTRANSLATIONUNIT_H + +#include <memory> + +namespace llvm { +class Module; +} + +namespace clang { + +class TranslationUnitDecl; + +/// The class keeps track of various objects created as part of processing +/// incremental inputs. +struct PartialTranslationUnit { + TranslationUnitDecl *TUPart = nullptr; + + /// The llvm IR produced for the input. + std::unique_ptr<llvm::Module> TheModule; +}; +} // namespace clang + +#endif // LLVM_CLANG_INTERPRETER_PARTIALTRANSLATIONUNIT_H diff --git a/clang/include/clang/Lex/DependencyDirectivesSourceMinimizer.h b/clang/include/clang/Lex/DependencyDirectivesSourceMinimizer.h index d832df6b6146..9bb820156c25 100644 --- a/clang/include/clang/Lex/DependencyDirectivesSourceMinimizer.h +++ b/clang/include/clang/Lex/DependencyDirectivesSourceMinimizer.h @@ -44,6 +44,8 @@ enum TokenKind { pp_ifdef, pp_ifndef, pp_elif, + pp_elifdef, + pp_elifndef, pp_else, pp_endif, decl_at_import, diff --git a/clang/include/clang/Lex/HeaderMap.h b/clang/include/clang/Lex/HeaderMap.h index accb061e51ba..53108b00bd16 100644 --- a/clang/include/clang/Lex/HeaderMap.h +++ b/clang/include/clang/Lex/HeaderMap.h @@ -16,6 +16,7 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/LLVM.h" #include "llvm/ADT/Optional.h" +#include "llvm/ADT/StringMap.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/MemoryBuffer.h" #include <memory> @@ -29,6 +30,7 @@ struct HMapHeader; class HeaderMapImpl { std::unique_ptr<const llvm::MemoryBuffer> FileBuffer; bool NeedsBSwap; + mutable llvm::StringMap<StringRef> ReverseMap; public: HeaderMapImpl(std::unique_ptr<const llvm::MemoryBuffer> File, bool NeedsBSwap) @@ -48,6 +50,9 @@ public: /// Print the contents of this headermap to stderr. void dump() const; + /// Return key for specifed path. + StringRef reverseLookupFilename(StringRef DestPath) const; + private: unsigned getEndianAdjustedWord(unsigned X) const; const HMapHeader &getHeader() const; @@ -79,9 +84,10 @@ public: /// ".." and a filename "../file.h" this would be "../../file.h". Optional<FileEntryRef> LookupFile(StringRef Filename, FileManager &FM) const; - using HeaderMapImpl::lookupFilename; - using HeaderMapImpl::getFileName; using HeaderMapImpl::dump; + using HeaderMapImpl::getFileName; + using HeaderMapImpl::lookupFilename; + using HeaderMapImpl::reverseLookupFilename; }; } // end namespace clang. diff --git a/clang/include/clang/Lex/LiteralSupport.h b/clang/include/clang/Lex/LiteralSupport.h index 0c4f0fe277b7..f131f045a73e 100644 --- a/clang/include/clang/Lex/LiteralSupport.h +++ b/clang/include/clang/Lex/LiteralSupport.h @@ -63,6 +63,7 @@ public: bool isUnsigned : 1; bool isLong : 1; // This is *not* set for long long. bool isLongLong : 1; + bool isSizeT : 1; // 1z, 1uz (C++2b) bool isHalf : 1; // 1.0h bool isFloat : 1; // 1.0f bool isImaginary : 1; // 1.0i diff --git a/clang/include/clang/Lex/MacroInfo.h b/clang/include/clang/Lex/MacroInfo.h index 550abf35c841..0347a7a37186 100644 --- a/clang/include/clang/Lex/MacroInfo.h +++ b/clang/include/clang/Lex/MacroInfo.h @@ -521,7 +521,7 @@ public: } static void Profile(llvm::FoldingSetNodeID &ID, Module *OwningModule, - IdentifierInfo *II) { + const IdentifierInfo *II) { ID.AddPointer(OwningModule); ID.AddPointer(II); } diff --git a/clang/include/clang/Lex/ModuleLoader.h b/clang/include/clang/Lex/ModuleLoader.h index c1f7f068c0f1..bf044e0e5f50 100644 --- a/clang/include/clang/Lex/ModuleLoader.h +++ b/clang/include/clang/Lex/ModuleLoader.h @@ -45,9 +45,6 @@ public: // The module exists but cannot be imported due to a configuration mismatch. ConfigMismatch, - - // We failed to load the module, but we shouldn't cache the failure. - OtherUncachedFailure, }; llvm::PointerIntPair<Module *, 2, LoadResultKind> Storage; diff --git a/clang/include/clang/Lex/ModuleMap.h b/clang/include/clang/Lex/ModuleMap.h index 6827408f10a3..41f85a1f572d 100644 --- a/clang/include/clang/Lex/ModuleMap.h +++ b/clang/include/clang/Lex/ModuleMap.h @@ -14,7 +14,6 @@ #ifndef LLVM_CLANG_LEX_MODULEMAP_H #define LLVM_CLANG_LEX_MODULEMAP_H -#include "clang/Basic/FileEntry.h" #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LangOptions.h" #include "clang/Basic/Module.h" @@ -38,6 +37,7 @@ namespace clang { class DiagnosticsEngine; class DirectoryEntry; +class FileEntry; class FileManager; class HeaderSearch; class SourceManager; @@ -648,13 +648,15 @@ public: /// Sets the umbrella header of the given module to the given /// header. - void setUmbrellaHeader(Module *Mod, FileEntryRef UmbrellaHeader, - Twine NameAsWritten); + void setUmbrellaHeader(Module *Mod, const FileEntry *UmbrellaHeader, + const Twine &NameAsWritten, + const Twine &PathRelativeToRootModuleDirectory); /// Sets the umbrella directory of the given module to the given /// directory. - void setUmbrellaDir(Module *Mod, DirectoryEntryRef UmbrellaDir, - Twine NameAsWritten); + void setUmbrellaDir(Module *Mod, const DirectoryEntry *UmbrellaDir, + const Twine &NameAsWritten, + const Twine &PathRelativeToRootModuleDirectory); /// Adds this header to the given module. /// \param Role The role of the header wrt the module. @@ -696,6 +698,9 @@ public: module_iterator module_begin() const { return Modules.begin(); } module_iterator module_end() const { return Modules.end(); } + llvm::iterator_range<module_iterator> modules() const { + return {module_begin(), module_end()}; + } /// Cache a module load. M might be nullptr. void cacheModuleLoad(const IdentifierInfo &II, Module *M) { diff --git a/clang/include/clang/Lex/PPCallbacks.h b/clang/include/clang/Lex/PPCallbacks.h index de5e8eb2ca22..bcf49c577735 100644 --- a/clang/include/clang/Lex/PPCallbacks.h +++ b/clang/include/clang/Lex/PPCallbacks.h @@ -191,6 +191,10 @@ public: StringRef Str) { } + /// Callback invoked when a \#pragma mark comment is read. + virtual void PragmaMark(SourceLocation Loc, StringRef Trivia) { + } + /// Callback invoked when a \#pragma detect_mismatch directive is /// read. virtual void PragmaDetectMismatch(SourceLocation Loc, StringRef Name, @@ -351,6 +355,22 @@ public: const MacroDefinition &MD) { } + /// Hook called whenever an \#elifdef branch is taken. + /// \param Loc the source location of the directive. + /// \param MacroNameTok Information on the token being tested. + /// \param MD The MacroDefinition if the name was a macro, null otherwise. + virtual void Elifdef(SourceLocation Loc, const Token &MacroNameTok, + const MacroDefinition &MD) { + } + /// Hook called whenever an \#elifdef is skipped. + /// \param Loc the source location of the directive. + /// \param ConditionRange The SourceRange of the expression being tested. + /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive. + // FIXME: better to pass in a list (or tree!) of Tokens. + virtual void Elifdef(SourceLocation Loc, SourceRange ConditionRange, + SourceLocation IfLoc) { + } + /// Hook called whenever an \#ifndef is seen. /// \param Loc the source location of the directive. /// \param MacroNameTok Information on the token being tested. @@ -359,6 +379,22 @@ public: const MacroDefinition &MD) { } + /// Hook called whenever an \#elifndef branch is taken. + /// \param Loc the source location of the directive. + /// \param MacroNameTok Information on the token being tested. + /// \param MD The MacroDefinition if the name was a macro, null otherwise. + virtual void Elifndef(SourceLocation Loc, const Token &MacroNameTok, + const MacroDefinition &MD) { + } + /// Hook called whenever an \#elifndef is skipped. + /// \param Loc the source location of the directive. + /// \param ConditionRange The SourceRange of the expression being tested. + /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive. + // FIXME: better to pass in a list (or tree!) of Tokens. + virtual void Elifndef(SourceLocation Loc, SourceRange ConditionRange, + SourceLocation IfLoc) { + } + /// Hook called whenever an \#else is seen. /// \param Loc the source location of the directive. /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive. @@ -586,6 +622,19 @@ public: Second->Ifdef(Loc, MacroNameTok, MD); } + /// Hook called whenever an \#elifdef is taken. + void Elifdef(SourceLocation Loc, const Token &MacroNameTok, + const MacroDefinition &MD) override { + First->Elifdef(Loc, MacroNameTok, MD); + Second->Elifdef(Loc, MacroNameTok, MD); + } + /// Hook called whenever an \#elifdef is skipped. + void Elifdef(SourceLocation Loc, SourceRange ConditionRange, + SourceLocation IfLoc) override { + First->Elifdef(Loc, ConditionRange, IfLoc); + Second->Elifdef(Loc, ConditionRange, IfLoc); + } + /// Hook called whenever an \#ifndef is seen. void Ifndef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override { @@ -593,6 +642,19 @@ public: Second->Ifndef(Loc, MacroNameTok, MD); } + /// Hook called whenever an \#elifndef is taken. + void Elifndef(SourceLocation Loc, const Token &MacroNameTok, + const MacroDefinition &MD) override { + First->Elifndef(Loc, MacroNameTok, MD); + Second->Elifndef(Loc, MacroNameTok, MD); + } + /// Hook called whenever an \#elifndef is skipped. + void Elifndef(SourceLocation Loc, SourceRange ConditionRange, + SourceLocation IfLoc) override { + First->Elifndef(Loc, ConditionRange, IfLoc); + Second->Elifndef(Loc, ConditionRange, IfLoc); + } + /// Hook called whenever an \#else is seen. void Else(SourceLocation Loc, SourceLocation IfLoc) override { First->Else(Loc, IfLoc); diff --git a/clang/include/clang/Lex/PPConditionalDirectiveRecord.h b/clang/include/clang/Lex/PPConditionalDirectiveRecord.h index 077437435303..d8c556ae2531 100644 --- a/clang/include/clang/Lex/PPConditionalDirectiveRecord.h +++ b/clang/include/clang/Lex/PPConditionalDirectiveRecord.h @@ -93,6 +93,14 @@ private: const MacroDefinition &MD) override; void Ifndef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override; + void Elifdef(SourceLocation Loc, const Token &MacroNameTok, + const MacroDefinition &MD) override; + void Elifdef(SourceLocation Loc, SourceRange ConditionRange, + SourceLocation IfLoc) override; + void Elifndef(SourceLocation Loc, const Token &MacroNameTok, + const MacroDefinition &MD) override; + void Elifndef(SourceLocation Loc, SourceRange ConditionRange, + SourceLocation IfLoc) override; void Else(SourceLocation Loc, SourceLocation IfLoc) override; void Endif(SourceLocation Loc, SourceLocation IfLoc) override; }; diff --git a/clang/include/clang/Lex/PreprocessingRecord.h b/clang/include/clang/Lex/PreprocessingRecord.h index 11607811dc8f..0137d871e916 100644 --- a/clang/include/clang/Lex/PreprocessingRecord.h +++ b/clang/include/clang/Lex/PreprocessingRecord.h @@ -539,6 +539,13 @@ class Token; void Ifndef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override; + using PPCallbacks::Elifdef; + using PPCallbacks::Elifndef; + void Elifdef(SourceLocation Loc, const Token &MacroNameTok, + const MacroDefinition &MD) override; + void Elifndef(SourceLocation Loc, const Token &MacroNameTok, + const MacroDefinition &MD) override; + /// Hook called whenever the 'defined' operator is seen. void Defined(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range) override; diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index 68139cb24b31..7ab13640ce2c 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -264,9 +264,11 @@ class Preprocessor { /// avoid tearing the Lexer and etc. down). bool IncrementalProcessing = false; +public: /// The kind of translation unit we are processing. - TranslationUnitKind TUKind; + const TranslationUnitKind TUKind; +private: /// The code-completion handler. CodeCompletionHandler *CodeComplete = nullptr; @@ -781,8 +783,7 @@ private: /// deserializing from PCH, we don't need to deserialize identifier & macros /// just so that we can report that they are unused, we just warn using /// the SourceLocations of this set (that will be filled by the ASTReader). - /// We are using SmallPtrSet instead of a vector for faster removal. - using WarnUnusedMacroLocsTy = llvm::SmallPtrSet<SourceLocation, 32>; + using WarnUnusedMacroLocsTy = llvm::SmallDenseSet<SourceLocation, 32>; WarnUnusedMacroLocsTy WarnUnusedMacroLocs; /// A "freelist" of MacroArg objects that can be @@ -1151,7 +1152,7 @@ public: /// Register an exported macro for a module and identifier. ModuleMacro *addModuleMacro(Module *Mod, IdentifierInfo *II, MacroInfo *Macro, ArrayRef<ModuleMacro *> Overrides, bool &IsNew); - ModuleMacro *getModuleMacro(Module *Mod, IdentifierInfo *II); + ModuleMacro *getModuleMacro(Module *Mod, const IdentifierInfo *II); /// Get the list of leaf (non-overridden) module macros for a name. ArrayRef<ModuleMacro*> getLeafModuleMacros(const IdentifierInfo *II) const { @@ -1163,6 +1164,11 @@ public: return None; } + /// Get the list of submodules that we're currently building. + ArrayRef<BuildingSubmoduleInfo> getBuildingSubmodules() const { + return BuildingSubmoduleStack; + } + /// \{ /// Iterators for the macro history table. Currently defined macros have /// IdentifierInfo::hasMacroDefinition() set and an empty @@ -2352,14 +2358,15 @@ private: bool ReadAnyTokensBeforeDirective); void HandleEndifDirective(Token &EndifToken); void HandleElseDirective(Token &Result, const Token &HashToken); - void HandleElifDirective(Token &ElifToken, const Token &HashToken); + void HandleElifFamilyDirective(Token &ElifToken, const Token &HashToken, + tok::PPKeywordKind Kind); // Pragmas. void HandlePragmaDirective(PragmaIntroducer Introducer); public: void HandlePragmaOnce(Token &OnceTok); - void HandlePragmaMark(); + void HandlePragmaMark(Token &MarkTok); void HandlePragmaPoison(); void HandlePragmaSystemHeader(Token &SysHeaderTok); void HandlePragmaDependency(Token &DependencyTok); diff --git a/clang/include/clang/Lex/PreprocessorOptions.h b/clang/include/clang/Lex/PreprocessorOptions.h index 7f024989bf9b..99085b98fc7a 100644 --- a/clang/include/clang/Lex/PreprocessorOptions.h +++ b/clang/include/clang/Lex/PreprocessorOptions.h @@ -106,6 +106,10 @@ public: /// When true, a PCH with compiler errors will not be rejected. bool AllowPCHWithCompilerErrors = false; + /// When true, a PCH with modules cache path different to the current + /// compilation will not be rejected. + bool AllowPCHWithDifferentModulesCachePath = false; + /// Dump declarations that are deserialized from PCH, for testing. bool DumpDeserializedPCHDecls = false; diff --git a/clang/include/clang/Lex/Token.h b/clang/include/clang/Lex/Token.h index 89042a674fec..00fbe6d18f72 100644 --- a/clang/include/clang/Lex/Token.h +++ b/clang/include/clang/Lex/Token.h @@ -33,7 +33,7 @@ class IdentifierInfo; /// information about the SourceRange of the tokens and the type object. class Token { /// The location of the token. This is actually a SourceLocation. - unsigned Loc; + SourceLocation::UIntTy Loc; // Conceptually these next two fields could be in a union. However, this // causes gcc 4.2 to pessimize LexTokenInternal, a very performance critical @@ -43,7 +43,7 @@ class Token { /// UintData - This holds either the length of the token text, when /// a normal token, or the end of the SourceRange when an annotation /// token. - unsigned UintData; + SourceLocation::UIntTy UintData; /// PtrData - This is a union of four different pointer types, which depends /// on what type of token this is: diff --git a/clang/include/clang/Lex/VariadicMacroSupport.h b/clang/include/clang/Lex/VariadicMacroSupport.h index 989e0ac703c9..119f02201fc6 100644 --- a/clang/include/clang/Lex/VariadicMacroSupport.h +++ b/clang/include/clang/Lex/VariadicMacroSupport.h @@ -39,17 +39,14 @@ namespace clang { assert(Ident__VA_ARGS__->isPoisoned() && "__VA_ARGS__ should be poisoned " "outside an ISO C/C++ variadic " "macro definition!"); - assert( - !Ident__VA_OPT__ || - (Ident__VA_OPT__->isPoisoned() && "__VA_OPT__ should be poisoned!")); + assert(Ident__VA_OPT__->isPoisoned() && "__VA_OPT__ should be poisoned!"); } /// Client code should call this function just before the Preprocessor is /// about to Lex tokens from the definition of a variadic (ISO C/C++) macro. void enterScope() { Ident__VA_ARGS__->setIsPoisoned(false); - if (Ident__VA_OPT__) - Ident__VA_OPT__->setIsPoisoned(false); + Ident__VA_OPT__->setIsPoisoned(false); } /// Client code should call this function as soon as the Preprocessor has @@ -58,8 +55,7 @@ namespace clang { /// (might be explicitly called, and then reinvoked via the destructor). void exitScope() { Ident__VA_ARGS__->setIsPoisoned(true); - if (Ident__VA_OPT__) - Ident__VA_OPT__->setIsPoisoned(true); + Ident__VA_OPT__->setIsPoisoned(true); } ~VariadicMacroScopeGuard() { exitScope(); } diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 02aab3b43be0..8eb3f9029d9d 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -114,14 +114,17 @@ class Parser : public CodeCompletionHandler { /// Contextual keywords for Microsoft extensions. IdentifierInfo *Ident__except; mutable IdentifierInfo *Ident_sealed; + mutable IdentifierInfo *Ident_abstract; /// Ident_super - IdentifierInfo for "super", to support fast /// comparison. IdentifierInfo *Ident_super; - /// Ident_vector, Ident_bool - cached IdentifierInfos for "vector" and - /// "bool" fast comparison. Only present if AltiVec or ZVector are enabled. + /// Ident_vector, Ident_bool, Ident_Bool - cached IdentifierInfos for "vector" + /// and "bool" fast comparison. Only present if AltiVec or ZVector are + /// enabled. IdentifierInfo *Ident_vector; IdentifierInfo *Ident_bool; + IdentifierInfo *Ident_Bool; /// Ident_pixel - cached IdentifierInfos for "pixel" fast comparison. /// Only present if AltiVec enabled. IdentifierInfo *Ident_pixel; @@ -879,6 +882,7 @@ private: if (Tok.getIdentifierInfo() != Ident_vector && Tok.getIdentifierInfo() != Ident_bool && + Tok.getIdentifierInfo() != Ident_Bool && (!getLangOpts().AltiVec || Tok.getIdentifierInfo() != Ident_pixel)) return false; @@ -941,8 +945,8 @@ private: bool isActive; public: - explicit TentativeParsingAction(Parser& p) : P(p) { - PrevPreferredType = P.PreferredType; + explicit TentativeParsingAction(Parser &p) + : P(p), PrevPreferredType(P.PreferredType) { PrevTok = P.Tok; PrevTentativelyDeclaredIdentifierCount = P.TentativelyDeclaredIdentifiers.size(); @@ -1572,27 +1576,6 @@ private: //===--------------------------------------------------------------------===// // C99 6.9: External Definitions. - struct ParsedAttributesWithRange : ParsedAttributes { - ParsedAttributesWithRange(AttributeFactory &factory) - : ParsedAttributes(factory) {} - - void clear() { - ParsedAttributes::clear(); - Range = SourceRange(); - } - - SourceRange Range; - }; - struct ParsedAttributesViewWithRange : ParsedAttributesView { - ParsedAttributesViewWithRange() : ParsedAttributesView() {} - void clearListOnly() { - ParsedAttributesView::clearListOnly(); - Range = SourceRange(); - } - - SourceRange Range; - }; - DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributesWithRange &attrs, ParsingDeclSpec *DS = nullptr); bool isDeclarationAfterDeclarator(); @@ -1818,6 +1801,7 @@ private: ExprResult ParsePostfixExpressionSuffix(ExprResult LHS); ExprResult ParseUnaryExprOrTypeTraitExpression(); ExprResult ParseBuiltinPrimaryExpression(); + ExprResult ParseSYCLUniqueStableNameExpression(); ExprResult ParseExprAfterUnaryExprOrTypeTrait(const Token &OpTok, bool &isCastExpr, @@ -1991,7 +1975,8 @@ private: Sema::ConditionResult ParseCXXCondition(StmtResult *InitStmt, SourceLocation Loc, Sema::ConditionKind CK, - ForRangeInfo *FRI = nullptr); + ForRangeInfo *FRI = nullptr, + bool EnterForConditionScope = false); //===--------------------------------------------------------------------===// // C++ Coroutines @@ -2018,8 +2003,11 @@ private: } bool MayBeDesignationStart(); ExprResult ParseBraceInitializer(); - ExprResult ParseInitializerWithPotentialDesignator( - llvm::function_ref<void(const Designation &)> CodeCompleteCB); + struct DesignatorCompletionInfo { + SmallVectorImpl<Expr *> &InitExprs; + QualType PreferredBaseType; + }; + ExprResult ParseInitializerWithPotentialDesignator(DesignatorCompletionInfo); //===--------------------------------------------------------------------===// // clang Expressions @@ -2635,7 +2623,8 @@ private: // which standard permits but we don't supported yet, for example, attributes // appertain to decl specifiers. void ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs, - unsigned DiagID); + unsigned DiagID, + bool DiagnoseEmptyAttrs = false); /// Skip C++11 and C2x attributes and return the end location of the /// last one. @@ -2646,6 +2635,10 @@ private: /// locations where attributes are not allowed. void DiagnoseAndSkipCXX11Attributes(); + /// Emit warnings for C++11 and C2x attributes that are in a position that + /// clang accepts as an extension. + void DiagnoseCXX11AttributeExtension(ParsedAttributesWithRange &Attrs); + /// Parses syntax-generic attribute arguments for attributes which are /// known to the implementation, and adds them to the given ParsedAttributes /// list with the given attribute syntax. Returns the number of arguments @@ -2656,6 +2649,61 @@ private: IdentifierInfo *ScopeName, SourceLocation ScopeLoc, ParsedAttr::Syntax Syntax); + enum ParseAttrKindMask { + PAKM_GNU = 1 << 0, + PAKM_Declspec = 1 << 1, + PAKM_CXX11 = 1 << 2, + }; + + /// \brief Parse attributes based on what syntaxes are desired, allowing for + /// the order to vary. e.g. with PAKM_GNU | PAKM_Declspec: + /// __attribute__((...)) __declspec(...) __attribute__((...))) + /// Note that Microsoft attributes (spelled with single square brackets) are + /// not supported by this because of parsing ambiguities with other + /// constructs. + /// + /// There are some attribute parse orderings that should not be allowed in + /// arbitrary order. e.g., + /// + /// [[]] __attribute__(()) int i; // OK + /// __attribute__(()) [[]] int i; // Not OK + /// + /// Such situations should use the specific attribute parsing functionality. + void ParseAttributes(unsigned WhichAttrKinds, + ParsedAttributesWithRange &Attrs, + SourceLocation *End = nullptr, + LateParsedAttrList *LateAttrs = nullptr); + void ParseAttributes(unsigned WhichAttrKinds, ParsedAttributes &Attrs, + SourceLocation *End = nullptr, + LateParsedAttrList *LateAttrs = nullptr) { + ParsedAttributesWithRange AttrsWithRange(AttrFactory); + ParseAttributes(WhichAttrKinds, AttrsWithRange, End, LateAttrs); + Attrs.takeAllFrom(AttrsWithRange); + } + /// \brief Possibly parse attributes based on what syntaxes are desired, + /// allowing for the order to vary. + bool MaybeParseAttributes(unsigned WhichAttrKinds, + ParsedAttributesWithRange &Attrs, + SourceLocation *End = nullptr, + LateParsedAttrList *LateAttrs = nullptr) { + if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec) || + (standardAttributesAllowed() && isCXX11AttributeSpecifier())) { + ParseAttributes(WhichAttrKinds, Attrs, End, LateAttrs); + return true; + } + return false; + } + bool MaybeParseAttributes(unsigned WhichAttrKinds, ParsedAttributes &Attrs, + SourceLocation *End = nullptr, + LateParsedAttrList *LateAttrs = nullptr) { + if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec) || + (standardAttributesAllowed() && isCXX11AttributeSpecifier())) { + ParseAttributes(WhichAttrKinds, Attrs, End, LateAttrs); + return true; + } + return false; + } + void MaybeParseGNUAttributes(Declarator &D, LateParsedAttrList *LateAttrs = nullptr) { if (Tok.is(tok::kw___attribute)) { @@ -2665,14 +2713,50 @@ private: D.takeAttributes(attrs, endLoc); } } - void MaybeParseGNUAttributes(ParsedAttributes &attrs, - SourceLocation *endLoc = nullptr, + + /// Parses GNU-style attributes and returns them without source range + /// information. + /// + /// This API is discouraged. Use the version that takes a + /// ParsedAttributesWithRange instead. + bool MaybeParseGNUAttributes(ParsedAttributes &Attrs, + SourceLocation *EndLoc = nullptr, LateParsedAttrList *LateAttrs = nullptr) { - if (Tok.is(tok::kw___attribute)) - ParseGNUAttributes(attrs, endLoc, LateAttrs); + if (Tok.is(tok::kw___attribute)) { + ParsedAttributesWithRange AttrsWithRange(AttrFactory); + ParseGNUAttributes(Attrs, EndLoc, LateAttrs); + Attrs.takeAllFrom(AttrsWithRange); + return true; + } + return false; } - void ParseGNUAttributes(ParsedAttributes &attrs, - SourceLocation *endLoc = nullptr, + + bool MaybeParseGNUAttributes(ParsedAttributesWithRange &Attrs, + SourceLocation *EndLoc = nullptr, + LateParsedAttrList *LateAttrs = nullptr) { + if (Tok.is(tok::kw___attribute)) { + ParseGNUAttributes(Attrs, EndLoc, LateAttrs); + return true; + } + return false; + } + + /// Parses GNU-style attributes and returns them without source range + /// information. + /// + /// This API is discouraged. Use the version that takes a + /// ParsedAttributesWithRange instead. + void ParseGNUAttributes(ParsedAttributes &Attrs, + SourceLocation *EndLoc = nullptr, + LateParsedAttrList *LateAttrs = nullptr, + Declarator *D = nullptr) { + ParsedAttributesWithRange AttrsWithRange(AttrFactory); + ParseGNUAttributes(AttrsWithRange, EndLoc, LateAttrs, D); + Attrs.takeAllFrom(AttrsWithRange); + } + + void ParseGNUAttributes(ParsedAttributesWithRange &Attrs, + SourceLocation *EndLoc = nullptr, LateParsedAttrList *LateAttrs = nullptr, Declarator *D = nullptr); void ParseGNUAttributeArgs(IdentifierInfo *AttrName, @@ -2688,6 +2772,16 @@ private: IdentifierInfo *ScopeName, SourceLocation ScopeLoc, ParsedAttr::Syntax Syntax); + void ReplayOpenMPAttributeTokens(CachedTokens &OpenMPTokens) { + // If parsing the attributes found an OpenMP directive, emit those tokens + // to the parse stream now. + if (!OpenMPTokens.empty()) { + PP.EnterToken(Tok, /*IsReinject*/ true); + PP.EnterTokenStream(OpenMPTokens, /*DisableMacroExpansion*/ true, + /*IsReinject*/ true); + ConsumeAnyToken(/*ConsumeCodeCompletionTok*/ true); + } + } void MaybeParseCXX11Attributes(Declarator &D) { if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) { ParsedAttributesWithRange attrs(AttrFactory); @@ -2706,16 +2800,29 @@ private: } return false; } - void MaybeParseCXX11Attributes(ParsedAttributesWithRange &attrs, + bool MaybeParseCXX11Attributes(ParsedAttributesWithRange &attrs, SourceLocation *endLoc = nullptr, bool OuterMightBeMessageSend = false) { if (standardAttributesAllowed() && - isCXX11AttributeSpecifier(false, OuterMightBeMessageSend)) + isCXX11AttributeSpecifier(false, OuterMightBeMessageSend)) { ParseCXX11Attributes(attrs, endLoc); + return true; + } + return false; } - void ParseCXX11AttributeSpecifier(ParsedAttributes &attrs, - SourceLocation *EndLoc = nullptr); + void ParseOpenMPAttributeArgs(IdentifierInfo *AttrName, + CachedTokens &OpenMPTokens); + + void ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs, + CachedTokens &OpenMPTokens, + SourceLocation *EndLoc = nullptr); + void ParseCXX11AttributeSpecifier(ParsedAttributes &Attrs, + SourceLocation *EndLoc = nullptr) { + CachedTokens OpenMPTokens; + ParseCXX11AttributeSpecifierInternal(Attrs, OpenMPTokens, EndLoc); + ReplayOpenMPAttributeTokens(OpenMPTokens); + } void ParseCXX11Attributes(ParsedAttributesWithRange &attrs, SourceLocation *EndLoc = nullptr); /// Parses a C++11 (or C2x)-style attribute argument list. Returns true @@ -2724,7 +2831,8 @@ private: SourceLocation AttrNameLoc, ParsedAttributes &Attrs, SourceLocation *EndLoc, IdentifierInfo *ScopeName, - SourceLocation ScopeLoc); + SourceLocation ScopeLoc, + CachedTokens &OpenMPTokens); IdentifierInfo *TryParseCXX11AttributeIdentifier(SourceLocation &Loc); @@ -2736,11 +2844,14 @@ private: void ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs); void ParseMicrosoftAttributes(ParsedAttributes &attrs, SourceLocation *endLoc = nullptr); - void MaybeParseMicrosoftDeclSpecs(ParsedAttributes &Attrs, + bool MaybeParseMicrosoftDeclSpecs(ParsedAttributes &Attrs, SourceLocation *End = nullptr) { const auto &LO = getLangOpts(); - if (LO.DeclSpecKeyword && Tok.is(tok::kw___declspec)) + if (LO.DeclSpecKeyword && Tok.is(tok::kw___declspec)) { ParseMicrosoftDeclSpecs(Attrs, End); + return true; + } + return false; } void ParseMicrosoftDeclSpecs(ParsedAttributes &Attrs, SourceLocation *End = nullptr); @@ -2754,17 +2865,6 @@ private: void ParseBorlandTypeAttributes(ParsedAttributes &attrs); void ParseOpenCLKernelAttributes(ParsedAttributes &attrs); void ParseOpenCLQualifiers(ParsedAttributes &Attrs); - /// Parses opencl_unroll_hint attribute if language is OpenCL v2.0 - /// or higher. - /// \return false if error happens. - bool MaybeParseOpenCLUnrollHintAttribute(ParsedAttributes &Attrs) { - if (getLangOpts().OpenCL) - return ParseOpenCLUnrollHintAttribute(Attrs); - return true; - } - /// Parses opencl_unroll_hint attribute. - /// \return false if error happens. - bool ParseOpenCLUnrollHintAttribute(ParsedAttributes &Attrs); void ParseNullabilityTypeSpecifiers(ParsedAttributes &attrs); VersionTuple ParseVersionTuple(SourceRange &Range); @@ -2839,6 +2939,7 @@ private: SourceLocation FriendLoc); bool isCXX11FinalKeyword() const; + bool isClassCompatibleKeyword() const; /// DeclaratorScopeObj - RAII object used in Parser::ParseDirectDeclarator to /// enter a new C++ declarator scope and exit it when the function is @@ -2985,6 +3086,7 @@ private: const ParsedTemplateInfo &TemplateInfo, SourceLocation UsingLoc, SourceLocation &DeclEnd, + ParsedAttributesWithRange &Attrs, AccessSpecifier AS = AS_none); Decl *ParseAliasDeclarationAfterDeclarator( const ParsedTemplateInfo &TemplateInfo, SourceLocation UsingLoc, @@ -3111,10 +3213,12 @@ private: /// Parse 'omp end assumes' directive. void ParseOpenMPEndAssumesDirective(SourceLocation Loc); - /// Parse clauses for '#pragma omp declare target'. - DeclGroupPtrTy ParseOMPDeclareTargetClauses(); + /// Parse clauses for '#pragma omp [begin] declare target'. + void ParseOMPDeclareTargetClauses(Sema::DeclareTargetContextInfo &DTCI); + /// Parse '#pragma omp end declare target'. - void ParseOMPEndDeclareTargetDirective(OpenMPDirectiveKind DKind, + void ParseOMPEndDeclareTargetDirective(OpenMPDirectiveKind BeginDKind, + OpenMPDirectiveKind EndDKind, SourceLocation Loc); /// Skip tokens until a `annot_pragma_openmp_end` was found. Emit a warning if @@ -3206,6 +3310,10 @@ private: OMPClause *ParseOpenMPSingleExprWithArgClause(OpenMPDirectiveKind DKind, OpenMPClauseKind Kind, bool ParseOnly); + + /// Parses the 'sizes' clause of a '#pragma omp tile' directive. + OMPClause *ParseOpenMPSizesClause(); + /// Parses clause without any additional arguments. /// /// \param Kind Kind of current clause. @@ -3232,6 +3340,14 @@ private: /// '(' { <allocator> [ '(' <allocator_traits> ')' ] }+ ')' OMPClause *ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind); + /// Parses clause with an interop variable of kind \a Kind. + /// + /// \param Kind Kind of current clause. + /// \param ParseOnly true to skip the clause's semantic actions and return + /// nullptr. + // + OMPClause *ParseOpenMPInteropClause(OpenMPClauseKind Kind, bool ParseOnly); + public: /// Parses simple expression in parens for single-expression clauses of OpenMP /// constructs. diff --git a/clang/include/clang/Rewrite/Core/RewriteRope.h b/clang/include/clang/Rewrite/Core/RewriteRope.h index 039927c48b08..8fa7af245eb8 100644 --- a/clang/include/clang/Rewrite/Core/RewriteRope.h +++ b/clang/include/clang/Rewrite/Core/RewriteRope.h @@ -83,8 +83,7 @@ namespace clang { /// over bytes that are in a RopePieceBTree. This first iterates over bytes /// in a RopePiece, then iterates over RopePiece's in a RopePieceBTreeLeaf, /// then iterates over RopePieceBTreeLeaf's in a RopePieceBTree. - class RopePieceBTreeIterator : - public std::iterator<std::forward_iterator_tag, const char, ptrdiff_t> { + class RopePieceBTreeIterator { /// CurNode - The current B+Tree node that we are inspecting. const void /*RopePieceBTreeLeaf*/ *CurNode = nullptr; @@ -96,6 +95,12 @@ namespace clang { unsigned CurChar = 0; public: + using iterator_category = std::forward_iterator_tag; + using value_type = const char; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + RopePieceBTreeIterator() = default; RopePieceBTreeIterator(const void /*RopePieceBTreeNode*/ *N); diff --git a/clang/include/clang/Sema/AnalysisBasedWarnings.h b/clang/include/clang/Sema/AnalysisBasedWarnings.h index e13fe955eaf4..49b69c585ff7 100644 --- a/clang/include/clang/Sema/AnalysisBasedWarnings.h +++ b/clang/include/clang/Sema/AnalysisBasedWarnings.h @@ -14,6 +14,7 @@ #define LLVM_CLANG_SEMA_ANALYSISBASEDWARNINGS_H #include "llvm/ADT/DenseMap.h" +#include <memory> namespace clang { @@ -47,6 +48,9 @@ private: Sema &S; Policy DefaultPolicy; + class InterProceduralData; + std::unique_ptr<InterProceduralData> IPData; + enum VisitFlag { NotVisited = 0, Visited = 1, Pending = 2 }; llvm::DenseMap<const FunctionDecl*, VisitFlag> VisitedFD; @@ -88,6 +92,7 @@ private: public: AnalysisBasedWarnings(Sema &s); + ~AnalysisBasedWarnings(); void IssueWarnings(Policy P, FunctionScopeInfo *fscope, const Decl *D, QualType BlockType); @@ -97,6 +102,7 @@ public: void PrintStats() const; }; -}} // end namespace clang::sema +} // namespace sema +} // namespace clang #endif diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h index 3b16295941e4..423f4f4ee7b7 100644 --- a/clang/include/clang/Sema/DeclSpec.h +++ b/clang/include/clang/Sema/DeclSpec.h @@ -2620,7 +2620,8 @@ public: VS_Final = 2, VS_Sealed = 4, // Represents the __final keyword, which is legal for gcc in pre-C++11 mode. - VS_GNU_Final = 8 + VS_GNU_Final = 8, + VS_Abstract = 16 }; VirtSpecifiers() : Specifiers(0), LastSpecifier(VS_None) { } @@ -2636,6 +2637,7 @@ public: bool isFinalSpecified() const { return Specifiers & (VS_Final | VS_Sealed | VS_GNU_Final); } bool isFinalSpelledSealed() const { return Specifiers & VS_Sealed; } SourceLocation getFinalLoc() const { return VS_finalLoc; } + SourceLocation getAbstractLoc() const { return VS_abstractLoc; } void clear() { Specifiers = 0; } @@ -2649,7 +2651,7 @@ private: unsigned Specifiers; Specifier LastSpecifier; - SourceLocation VS_overrideLoc, VS_finalLoc; + SourceLocation VS_overrideLoc, VS_finalLoc, VS_abstractLoc; SourceLocation FirstLocation; SourceLocation LastLocation; }; diff --git a/clang/include/clang/Sema/ExternalSemaSource.h b/clang/include/clang/Sema/ExternalSemaSource.h index 2854b4893484..9c18aa1398d3 100644 --- a/clang/include/clang/Sema/ExternalSemaSource.h +++ b/clang/include/clang/Sema/ExternalSemaSource.h @@ -199,8 +199,8 @@ public: /// and variable decls which may cause deferred diags. Note that this routine /// may be invoked multiple times; the external source should take care not to /// introduce the same declarations repeatedly. - virtual void ReadDeclsToCheckForDeferredDiags( - llvm::SmallVector<Decl *, 4> &Decls) {} + virtual void + ReadDeclsToCheckForDeferredDiags(llvm::SmallSetVector<Decl *, 4> &Decls) {} /// \copydoc Sema::CorrectTypo /// \note LookupKind must correspond to a valid Sema::LookupNameKind diff --git a/clang/include/clang/Sema/Initialization.h b/clang/include/clang/Sema/Initialization.h index dcdfa3c3cf64..8feb66995f95 100644 --- a/clang/include/clang/Sema/Initialization.h +++ b/clang/include/clang/Sema/Initialization.h @@ -187,8 +187,8 @@ private: ObjCMethodDecl *MethodDecl; /// When Kind == EK_Parameter, the ParmVarDecl, with the - /// low bit indicating whether the parameter is "consumed". - uintptr_t Parameter; + /// integer indicating whether the parameter is "consumed". + llvm::PointerIntPair<ParmVarDecl *, 1> Parameter; /// When Kind == EK_Temporary or EK_CompoundLiteralInit, the type /// source information for the temporary. @@ -197,9 +197,9 @@ private: struct LN LocAndNRVO; /// When Kind == EK_Base, the base specifier that provides the - /// base class. The lower bit specifies whether the base is an inherited + /// base class. The integer specifies whether the base is an inherited /// virtual base. - uintptr_t Base; + llvm::PointerIntPair<const CXXBaseSpecifier *, 1> Base; /// When Kind == EK_ArrayElement, EK_VectorElement, or /// EK_ComplexElement, the index of the array or vector element being @@ -252,15 +252,14 @@ public: /// Create the initialization entity for a parameter. static InitializedEntity InitializeParameter(ASTContext &Context, - const ParmVarDecl *Parm) { + ParmVarDecl *Parm) { return InitializeParameter(Context, Parm, Parm->getType()); } /// Create the initialization entity for a parameter, but use /// another type. - static InitializedEntity InitializeParameter(ASTContext &Context, - const ParmVarDecl *Parm, - QualType Type) { + static InitializedEntity + InitializeParameter(ASTContext &Context, ParmVarDecl *Parm, QualType Type) { bool Consumed = (Context.getLangOpts().ObjCAutoRefCount && Parm->hasAttr<NSConsumedAttr>()); @@ -269,8 +268,7 @@ public: Entity.Type = Context.getVariableArrayDecayedType(Type.getUnqualifiedType()); Entity.Parent = nullptr; - Entity.Parameter - = (static_cast<uintptr_t>(Consumed) | reinterpret_cast<uintptr_t>(Parm)); + Entity.Parameter = {Parm, Consumed}; return Entity; } @@ -283,7 +281,7 @@ public: Entity.Kind = EK_Parameter; Entity.Type = Context.getVariableArrayDecayedType(Type); Entity.Parent = nullptr; - Entity.Parameter = (Consumed); + Entity.Parameter = {nullptr, Consumed}; return Entity; } @@ -466,19 +464,19 @@ public: /// parameter. bool isParameterConsumed() const { assert(isParameterKind() && "Not a parameter"); - return (Parameter & 1); + return Parameter.getInt(); } /// Retrieve the base specifier. const CXXBaseSpecifier *getBaseSpecifier() const { assert(getKind() == EK_Base && "Not a base specifier"); - return reinterpret_cast<const CXXBaseSpecifier *>(Base & ~0x1); + return Base.getPointer(); } /// Return whether the base is an inherited virtual base. bool isInheritedVirtualBase() const { assert(getKind() == EK_Base && "Not a base specifier"); - return Base & 0x1; + return Base.getInt(); } /// Determine whether this is an array new with an unknown bound. @@ -806,7 +804,7 @@ public: SK_ResolveAddressOfOverloadedFunction, /// Perform a derived-to-base cast, producing an rvalue. - SK_CastDerivedToBaseRValue, + SK_CastDerivedToBasePRValue, /// Perform a derived-to-base cast, producing an xvalue. SK_CastDerivedToBaseXValue, @@ -833,8 +831,8 @@ public: /// function or via a constructor. SK_UserConversion, - /// Perform a qualification conversion, producing an rvalue. - SK_QualificationConversionRValue, + /// Perform a qualification conversion, producing a prvalue. + SK_QualificationConversionPRValue, /// Perform a qualification conversion, producing an xvalue. SK_QualificationConversionXValue, diff --git a/clang/include/clang/Sema/MultiplexExternalSemaSource.h b/clang/include/clang/Sema/MultiplexExternalSemaSource.h index b54a6283d640..78658dcf990c 100644 --- a/clang/include/clang/Sema/MultiplexExternalSemaSource.h +++ b/clang/include/clang/Sema/MultiplexExternalSemaSource.h @@ -337,7 +337,7 @@ public: /// may be invoked multiple times; the external source should take care not to /// introduce the same declarations repeatedly. void ReadDeclsToCheckForDeferredDiags( - llvm::SmallVector<Decl *, 4> &Decls) override; + llvm::SmallSetVector<Decl *, 4> &Decls) override; /// \copydoc ExternalSemaSource::CorrectTypo /// \note Returns the first nonempty correction. diff --git a/clang/include/clang/Sema/Overload.h b/clang/include/clang/Sema/Overload.h index 5be6a618711c..82661cb3d12a 100644 --- a/clang/include/clang/Sema/Overload.h +++ b/clang/include/clang/Sema/Overload.h @@ -760,9 +760,6 @@ class Sema; /// This candidate was not viable because its address could not be taken. ovl_fail_addr_not_available, - /// This candidate was not viable because its OpenCL extension is disabled. - ovl_fail_ext_disabled, - /// This inherited constructor is not viable because it would slice the /// argument. ovl_fail_inhctor_slice, @@ -1051,9 +1048,6 @@ class Sema; void destroyCandidates(); - /// Whether diagnostics should be deferred. - bool shouldDeferDiags(Sema &S, ArrayRef<Expr *> Args, SourceLocation OpLoc); - public: OverloadCandidateSet(SourceLocation Loc, CandidateSetKind CSK, OperatorRewriteInfo RewriteInfo = {}) @@ -1066,6 +1060,9 @@ class Sema; CandidateSetKind getKind() const { return Kind; } OperatorRewriteInfo getRewriteInfo() const { return RewriteInfo; } + /// Whether diagnostics should be deferred. + bool shouldDeferDiags(Sema &S, ArrayRef<Expr *> Args, SourceLocation OpLoc); + /// Determine when this overload candidate will be new to the /// overload set. bool isNewCandidate(Decl *F, OverloadCandidateParamOrder PO = diff --git a/clang/include/clang/Sema/ParsedAttr.h b/clang/include/clang/Sema/ParsedAttr.h index 43c21faaece9..f47f557adeb1 100644 --- a/clang/include/clang/Sema/ParsedAttr.h +++ b/clang/include/clang/Sema/ParsedAttr.h @@ -39,6 +39,7 @@ class IdentifierInfo; class LangOptions; class ParsedAttr; class Sema; +class Stmt; class TargetInfo; struct ParsedAttrInfo { @@ -80,6 +81,17 @@ struct ParsedAttrInfo { const Decl *D) const { return true; } + /// Check if this attribute appertains to St, and issue a diagnostic if not. + virtual bool diagAppertainsToStmt(Sema &S, const ParsedAttr &Attr, + const Stmt *St) const { + return true; + } + /// Check if the given attribute is mutually exclusive with other attributes + /// already applied to the given declaration. + virtual bool diagMutualExclusion(Sema &S, const ParsedAttr &A, + const Decl *D) const { + return true; + } /// Check if this attribute is allowed by the language we are compiling, and /// issue a diagnostic if not. virtual bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const { @@ -573,6 +585,16 @@ public: return MacroExpansionLoc; } + /// Check if the attribute has exactly as many args as Num. May output an + /// error. Returns false if a diagnostic is produced. + bool checkExactlyNumArgs(class Sema &S, unsigned Num) const; + /// Check if the attribute has at least as many args as Num. May output an + /// error. Returns false if a diagnostic is produced. + bool checkAtLeastNumArgs(class Sema &S, unsigned Num) const; + /// Check if the attribute has at most as many args as Num. May output an + /// error. Returns false if a diagnostic is produced. + bool checkAtMostNumArgs(class Sema &S, unsigned Num) const; + bool isTargetSpecificAttr() const; bool isTypeAttr() const; bool isStmtAttr() const; @@ -582,6 +604,14 @@ public: unsigned getMaxArgs() const; bool hasVariadicArg() const; bool diagnoseAppertainsTo(class Sema &S, const Decl *D) const; + bool diagnoseAppertainsTo(class Sema &S, const Stmt *St) const; + bool diagnoseMutualExclusion(class Sema &S, const Decl *D) const; + // This function stub exists for parity with the declaration checking code so + // that checkCommonAttributeFeatures() can work generically on declarations + // or statements. + bool diagnoseMutualExclusion(class Sema &S, const Stmt *St) const { + return true; + } bool appliesToDecl(const Decl *D, attr::SubjectMatchRule MatchRule) const; void getMatchRules(const LangOptions &LangOpts, SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> @@ -598,8 +628,8 @@ public: /// a Spelling enumeration, the value UINT_MAX is returned. unsigned getSemanticSpelling() const; - /// If this is an OpenCL addr space attribute returns its representation - /// in LangAS, otherwise returns default addr space. + /// If this is an OpenCL address space attribute returns its representation + /// in LangAS, otherwise returns default address space. LangAS asOpenCLLangAS() const { switch (getParsedKind()) { case ParsedAttr::AT_OpenCLConstantAddressSpace: @@ -621,6 +651,26 @@ public: } } + /// If this is an OpenCL address space attribute returns its SYCL + /// representation in LangAS, otherwise returns default address space. + LangAS asSYCLLangAS() const { + switch (getKind()) { + case ParsedAttr::AT_OpenCLGlobalAddressSpace: + return LangAS::sycl_global; + case ParsedAttr::AT_OpenCLGlobalDeviceAddressSpace: + return LangAS::sycl_global_device; + case ParsedAttr::AT_OpenCLGlobalHostAddressSpace: + return LangAS::sycl_global_host; + case ParsedAttr::AT_OpenCLLocalAddressSpace: + return LangAS::sycl_local; + case ParsedAttr::AT_OpenCLPrivateAddressSpace: + return LangAS::sycl_private; + case ParsedAttr::AT_OpenCLGenericAddressSpace: + default: + return LangAS::Default; + } + } + AttributeCommonInfo::Kind getKind() const { return AttributeCommonInfo::Kind(Info.AttrKind); } @@ -1017,6 +1067,27 @@ private: mutable AttributePool pool; }; +struct ParsedAttributesWithRange : ParsedAttributes { + ParsedAttributesWithRange(AttributeFactory &factory) + : ParsedAttributes(factory) {} + + void clear() { + ParsedAttributes::clear(); + Range = SourceRange(); + } + + SourceRange Range; +}; +struct ParsedAttributesViewWithRange : ParsedAttributesView { + ParsedAttributesViewWithRange() : ParsedAttributesView() {} + void clearListOnly() { + ParsedAttributesView::clearListOnly(); + Range = SourceRange(); + } + + SourceRange Range; +}; + /// These constants match the enumerated choices of /// err_attribute_argument_n_type and err_attribute_argument_type. enum AttributeArgumentNType { diff --git a/clang/include/clang/Sema/Scope.h b/clang/include/clang/Sema/Scope.h index b7260f15fe1b..b499ba1e7c2a 100644 --- a/clang/include/clang/Sema/Scope.h +++ b/clang/include/clang/Sema/Scope.h @@ -129,11 +129,17 @@ public: /// This is a compound statement scope. CompoundStmtScope = 0x400000, - /// We are between inheritance colon and the real class/struct definition scope. + /// We are between inheritance colon and the real class/struct definition + /// scope. ClassInheritanceScope = 0x800000, /// This is the scope of a C++ catch statement. CatchScope = 0x1000000, + + /// This is a scope in which a condition variable is currently being + /// parsed. If such a scope is a ContinueScope, it's invalid to jump to the + /// continue block from here. + ConditionVarScope = 0x2000000, }; private: @@ -247,6 +253,17 @@ public: return const_cast<Scope*>(this)->getContinueParent(); } + // Set whether we're in the scope of a condition variable, where 'continue' + // is disallowed despite being a continue scope. + void setIsConditionVarScope(bool InConditionVarScope) { + Flags = (Flags & ~ConditionVarScope) | + (InConditionVarScope ? ConditionVarScope : 0); + } + + bool isConditionVarScope() const { + return Flags & ConditionVarScope; + } + /// getBreakParent - Return the closest scope that a break statement /// would be affected by. Scope *getBreakParent() { diff --git a/clang/include/clang/Sema/ScopeInfo.h b/clang/include/clang/Sema/ScopeInfo.h index 8ec74cafeeca..98ed75acd9d2 100644 --- a/clang/include/clang/Sema/ScopeInfo.h +++ b/clang/include/clang/Sema/ScopeInfo.h @@ -118,6 +118,10 @@ public: /// Whether this function contains any indirect gotos. bool HasIndirectGoto : 1; + /// Whether this function contains any statement marked with + /// \c [[clang::musttail]]. + bool HasMustTail : 1; + /// Whether a statement was dropped because it was invalid. bool HasDroppedStmt : 1; @@ -370,14 +374,13 @@ protected: public: FunctionScopeInfo(DiagnosticsEngine &Diag) : Kind(SK_Function), HasBranchProtectedScope(false), - HasBranchIntoScope(false), HasIndirectGoto(false), + HasBranchIntoScope(false), HasIndirectGoto(false), HasMustTail(false), HasDroppedStmt(false), HasOMPDeclareReductionCombiner(false), HasFallthroughStmt(false), UsesFPIntrin(false), - HasPotentialAvailabilityViolations(false), - ObjCShouldCallSuper(false), ObjCIsDesignatedInit(false), - ObjCWarnForNoDesignatedInitChain(false), ObjCIsSecondaryInit(false), - ObjCWarnForNoInitDelegation(false), NeedsCoroutineSuspends(true), - ErrorTrap(Diag) {} + HasPotentialAvailabilityViolations(false), ObjCShouldCallSuper(false), + ObjCIsDesignatedInit(false), ObjCWarnForNoDesignatedInitChain(false), + ObjCIsSecondaryInit(false), ObjCWarnForNoInitDelegation(false), + NeedsCoroutineSuspends(true), ErrorTrap(Diag) {} virtual ~FunctionScopeInfo(); @@ -423,6 +426,8 @@ public: HasIndirectGoto = true; } + void setHasMustTail() { HasMustTail = true; } + void setHasDroppedStmt() { HasDroppedStmt = true; } @@ -450,9 +455,8 @@ public: } bool NeedsScopeChecking() const { - return !HasDroppedStmt && - (HasIndirectGoto || - (HasBranchProtectedScope && HasBranchIntoScope)); + return !HasDroppedStmt && (HasIndirectGoto || HasMustTail || + (HasBranchProtectedScope && HasBranchIntoScope)); } // Add a block introduced in this function. diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 7f7c84eb1b1d..83a2d132bf6a 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -32,9 +32,12 @@ #include "clang/AST/NSAPI.h" #include "clang/AST/PrettyPrinter.h" #include "clang/AST/StmtCXX.h" +#include "clang/AST/StmtOpenMP.h" #include "clang/AST/TypeLoc.h" #include "clang/AST/TypeOrdering.h" #include "clang/Basic/BitmaskEnum.h" +#include "clang/Basic/Builtins.h" +#include "clang/Basic/DarwinSDKInfo.h" #include "clang/Basic/ExpressionTraits.h" #include "clang/Basic/Module.h" #include "clang/Basic/OpenCLOptions.h" @@ -286,24 +289,29 @@ public: } }; -/// Keeps track of expected type during expression parsing. The type is tied to -/// a particular token, all functions that update or consume the type take a -/// start location of the token they are looking at as a parameter. This allows -/// to avoid updating the type on hot paths in the parser. +/// Tracks expected type during expression parsing, for use in code completion. +/// The type is tied to a particular token, all functions that update or consume +/// the type take a start location of the token they are looking at as a +/// parameter. This avoids updating the type on hot paths in the parser. class PreferredTypeBuilder { public: - PreferredTypeBuilder() = default; - explicit PreferredTypeBuilder(QualType Type) : Type(Type) {} + PreferredTypeBuilder(bool Enabled) : Enabled(Enabled) {} void enterCondition(Sema &S, SourceLocation Tok); void enterReturn(Sema &S, SourceLocation Tok); void enterVariableInit(SourceLocation Tok, Decl *D); + /// Handles e.g. BaseType{ .D = Tok... + void enterDesignatedInitializer(SourceLocation Tok, QualType BaseType, + const Designation &D); /// Computing a type for the function argument may require running /// overloading, so we postpone its computation until it is actually needed. /// /// Clients should be very careful when using this funciton, as it stores a /// function_ref, clients should make sure all calls to get() with the same /// location happen while function_ref is alive. + /// + /// The callback should also emit signature help as a side-effect, but only + /// if the completion point has been reached. void enterFunctionArgument(SourceLocation Tok, llvm::function_ref<QualType()> ComputeType); @@ -316,8 +324,14 @@ public: /// Handles all type casts, including C-style cast, C++ casts, etc. void enterTypeCast(SourceLocation Tok, QualType CastType); + /// Get the expected type associated with this location, if any. + /// + /// If the location is a function argument, determining the expected type + /// involves considering all function overloads and the arguments so far. + /// In this case, signature help for these function overloads will be reported + /// as a side-effect (only if the completion point has been reached). QualType get(SourceLocation Tok) const { - if (Tok != ExpectedLoc) + if (!Enabled || Tok != ExpectedLoc) return QualType(); if (!Type.isNull()) return Type; @@ -327,6 +341,7 @@ public: } private: + bool Enabled; /// Start position of a token for which we store expected type. SourceLocation ExpectedLoc; /// Expected type for a token starting at ExpectedLoc. @@ -341,9 +356,6 @@ class Sema final { Sema(const Sema &) = delete; void operator=(const Sema &) = delete; - /// A key method to reduce duplicate debug info from Sema. - virtual void anchor(); - ///Source of additional semantic information. ExternalSemaSource *ExternalSource; @@ -902,6 +914,10 @@ public: OpaqueParser = P; } + // Does the work necessary to deal with a SYCL kernel lambda. At the moment, + // this just marks the list of lambdas required to name the kernel. + void AddSYCLKernelLambda(const FunctionDecl *FD); + class DelayedDiagnostics; class DelayedDiagnosticsState { @@ -1362,7 +1378,7 @@ public: /// initializers for tentative definitions in C) once parsing has /// completed. Modules and precompiled headers perform different kinds of /// checks. - TranslationUnitKind TUKind; + const TranslationUnitKind TUKind; llvm::BumpPtrAllocator BumpAlloc; @@ -1505,6 +1521,13 @@ public: bool WarnedStackExhausted = false; + /// Increment when we find a reference; decrement when we find an ignored + /// assignment. Ultimately the value is 0 if every reference is an ignored + /// assignment. + llvm::DenseMap<const VarDecl *, int> RefsMinusAssignments; + + Optional<std::unique_ptr<DarwinSDKInfo>> CachedDarwinSDKInfo; + public: Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind = TU_Complete, @@ -1515,6 +1538,13 @@ public: /// initialized but before it parses anything. void Initialize(); + /// This virtual key function only exists to limit the emission of debug info + /// describing the Sema class. GCC and Clang only emit debug info for a class + /// with a vtable when the vtable is emitted. Sema is final and not + /// polymorphic, but the debug info size savings are so significant that it is + /// worth adding a vtable just to take advantage of this optimization. + virtual void anchor(); + const LangOptions &getLangOpts() const { return LangOpts; } OpenCLOptions &getOpenCLOptions() { return OpenCLFeatures; } FPOptions &getCurFPFeatures() { return CurFPFeatures; } @@ -1526,6 +1556,8 @@ public: ASTConsumer &getASTConsumer() const { return Consumer; } ASTMutationListener *getASTMutationListener() const; ExternalSemaSource* getExternalSource() const { return ExternalSource; } + DarwinSDKInfo *getDarwinSDKInfoForAvailabilityChecking(SourceLocation Loc, + StringRef Platform); ///Registers an external source. If an external source already exists, /// creates a multiplex external source and appends to it. @@ -1743,6 +1775,22 @@ public: /// Build a partial diagnostic. PartialDiagnostic PDiag(unsigned DiagID = 0); // in SemaInternal.h + /// Whether deferrable diagnostics should be deferred. + bool DeferDiags = false; + + /// RAII class to control scope of DeferDiags. + class DeferDiagsRAII { + Sema &S; + bool SavedDeferDiags = false; + + public: + DeferDiagsRAII(Sema &S, bool DeferDiags) + : S(S), SavedDeferDiags(S.DeferDiags) { + S.DeferDiags = DeferDiags; + } + ~DeferDiagsRAII() { S.DeferDiags = SavedDeferDiags; } + }; + /// Whether uncompilable error has occurred. This includes error happens /// in deferred diagnostics. bool hasUncompilableErrorOccurred() const; @@ -1770,7 +1818,7 @@ public: private: /// Function or variable declarations to be checked for whether the deferred /// diagnostics should be emitted. - SmallVector<Decl *, 4> DeclsToCheckForDeferredDiags; + llvm::SmallSetVector<Decl *, 4> DeclsToCheckForDeferredDiags; public: // Emit all deferred diagnostics. @@ -1836,6 +1884,7 @@ public: void setFunctionHasBranchIntoScope(); void setFunctionHasBranchProtectedScope(); void setFunctionHasIndirectGoto(); + void setFunctionHasMustTail(); void PushCompoundScope(bool IsStmtExpr); void PopCompoundScope(); @@ -1865,6 +1914,10 @@ public: /// Retrieve the current captured region, if any. sema::CapturedRegionScopeInfo *getCurCapturedRegion(); + /// Retrieve the current function, if any, that should be analyzed for + /// potential availability violations. + sema::FunctionScopeInfo *getCurFunctionAvailabilityContext(); + /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls SmallVectorImpl<Decl *> &WeakTopLevelDecls() { return WeakTopLevelDecl; } @@ -2281,6 +2334,7 @@ public: const CXXScopeSpec &SS, QualType T, TagDecl *OwnedTagDecl = nullptr); + QualType getDecltypeForParenthesizedExpr(Expr *E); QualType BuildTypeofExprType(Expr *E, SourceLocation Loc); /// If AsUnevaluated is false, E is treated as though it were an evaluated /// context, such as when building a type for decltype(auto). @@ -2572,10 +2626,15 @@ public: SourceLocation Less, SourceLocation Greater); + void warnOnReservedIdentifier(const NamedDecl *D); + Decl *ActOnDeclarator(Scope *S, Declarator &D); NamedDecl *HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists); + bool tryToFixVariablyModifiedVarType(TypeSourceInfo *&TInfo, + QualType &T, SourceLocation Loc, + unsigned FailedFoldDiagID); void RegisterLocallyScopedExternCDecl(NamedDecl *ND, Scope *S); bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info); bool diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC, @@ -2595,6 +2654,8 @@ public: NamedDecl *getShadowedDeclaration(const TypedefNameDecl *D, const LookupResult &R); NamedDecl *getShadowedDeclaration(const VarDecl *D, const LookupResult &R); + NamedDecl *getShadowedDeclaration(const BindingDecl *D, + const LookupResult &R); void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R); void CheckShadow(Scope *S, VarDecl *D); @@ -2688,8 +2749,7 @@ public: void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc); void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc); - ExprResult ConvertParamDefaultArgument(const ParmVarDecl *Param, - Expr *DefaultArg, + ExprResult ConvertParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc); void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc); @@ -3115,6 +3175,7 @@ public: void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, + bool IsAbstract, SourceLocation LBraceLoc); /// ActOnTagFinishDefinition - Invoked once we have finished parsing @@ -3231,6 +3292,9 @@ public: /// Merge availability attributes for an implementation of /// a protocol requirement. AMK_ProtocolImplementation, + /// Merge availability attributes for an implementation of + /// an optional protocol requirement. + AMK_OptionalProtocolImplementation }; /// Describes the kind of priority given to an availability attribute. @@ -3290,12 +3354,6 @@ public: const AttributeCommonInfo &CI, const IdentifierInfo *Ident); MinSizeAttr *mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI); - NoSpeculativeLoadHardeningAttr * - mergeNoSpeculativeLoadHardeningAttr(Decl *D, - const NoSpeculativeLoadHardeningAttr &AL); - SpeculativeLoadHardeningAttr * - mergeSpeculativeLoadHardeningAttr(Decl *D, - const SpeculativeLoadHardeningAttr &AL); SwiftNameAttr *mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA, StringRef Name); OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D, @@ -3303,8 +3361,6 @@ public: InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL); InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const InternalLinkageAttr &AL); - CommonAttr *mergeCommonAttr(Decl *D, const ParsedAttr &AL); - CommonAttr *mergeCommonAttr(Decl *D, const CommonAttr &AL); WebAssemblyImportNameAttr *mergeImportNameAttr( Decl *D, const WebAssemblyImportNameAttr &AL); WebAssemblyImportModuleAttr *mergeImportModuleAttr( @@ -3421,12 +3477,6 @@ public: bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType); bool isSameOrCompatibleFunctionType(CanQualType Param, CanQualType Arg); - ExprResult PerformMoveOrCopyInitialization(const InitializedEntity &Entity, - const VarDecl *NRVOCandidate, - QualType ResultType, - Expr *Value, - bool AllowNRVO = true); - bool CanPerformAggregateInitializationForOverloadResolution( const InitializedEntity &Entity, InitListExpr *From); @@ -3458,7 +3508,6 @@ public: CCEK_Enumerator, ///< Enumerator value with fixed underlying type. CCEK_TemplateArg, ///< Value of a non-type template parameter. CCEK_ArrayBound, ///< Array bound in array declarator or new-expression. - CCEK_ConstexprIf, ///< Condition in a constexpr if statement. CCEK_ExplicitBool ///< Condition in an explicit(bool) specifier. }; ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, @@ -4094,7 +4143,8 @@ public: bool RValueThis, unsigned ThisQuals); CXXDestructorDecl *LookupDestructor(CXXRecordDecl *Class); - bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id); + bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id, + bool IsUDSuffix); LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef<QualType> ArgTys, bool AllowRaw, bool AllowTemplate, @@ -4246,6 +4296,13 @@ public: void checkUnusedDeclAttributes(Declarator &D); + /// Handles semantic checking for features that are common to all attributes, + /// such as checking whether a parameter was properly specified, or the + /// correct number of arguments were passed, etc. Returns true if the + /// attribute has been diagnosed. + bool checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A); + bool checkCommonAttributeFeatures(const Stmt *S, const ParsedAttr &A); + /// Determine if type T is a valid subject for a nonnull and similar /// attributes. By default, we look through references (the behavior used by /// nonnull), but if the second parameter is true, then we treat a reference @@ -4260,6 +4317,7 @@ public: bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum, StringRef &Str, SourceLocation *ArgLocation = nullptr); + llvm::Error isValidSectionSpecifier(StringRef Str); bool checkSectionName(SourceLocation LiteralLoc, StringRef Str); bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str); bool checkMSInheritanceAttrOnDefinition( @@ -4283,10 +4341,11 @@ public: /// Valid types should not have multiple attributes with different CCs. const AttributedType *getCallingConvAttributedType(QualType T) const; - /// Stmt attributes - this routine is the top level dispatcher. - StmtResult ProcessStmtAttributes(Stmt *Stmt, - const ParsedAttributesView &Attrs, - SourceRange Range); + /// Process the attributes before creating an attributed statement. Returns + /// the semantic attributes that have been processed. + void ProcessStmtAttributes(Stmt *Stmt, + const ParsedAttributesWithRange &InAttrs, + SmallVectorImpl<const Attr *> &OutAttrs); void WarnConflictingTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl, @@ -4625,8 +4684,9 @@ public: StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt); - StmtResult ActOnAttributedStmt(SourceLocation AttrLoc, - ArrayRef<const Attr*> Attrs, + StmtResult BuildAttributedStmt(SourceLocation AttrsLoc, + ArrayRef<const Attr *> Attrs, Stmt *SubStmt); + StmtResult ActOnAttributedStmt(const ParsedAttributesWithRange &AttrList, Stmt *SubStmt); class ConditionResult; @@ -4716,26 +4776,33 @@ public: SourceLocation Loc, unsigned NumParams); - enum CopyElisionSemanticsKind { - CES_Strict = 0, - CES_AllowParameters = 1, - CES_AllowDifferentTypes = 2, - CES_AllowExceptionVariables = 4, - CES_FormerDefault = (CES_AllowParameters), - CES_Default = (CES_AllowParameters | CES_AllowDifferentTypes), - CES_AsIfByStdMove = (CES_AllowParameters | CES_AllowDifferentTypes | - CES_AllowExceptionVariables), + struct NamedReturnInfo { + const VarDecl *Candidate; + + enum Status : uint8_t { None, MoveEligible, MoveEligibleAndCopyElidable }; + Status S; + + bool isMoveEligible() const { return S != None; }; + bool isCopyElidable() const { return S == MoveEligibleAndCopyElidable; } }; + enum class SimplerImplicitMoveMode { ForceOff, Normal, ForceOn }; + NamedReturnInfo getNamedReturnInfo( + Expr *&E, SimplerImplicitMoveMode Mode = SimplerImplicitMoveMode::Normal); + NamedReturnInfo getNamedReturnInfo(const VarDecl *VD); + const VarDecl *getCopyElisionCandidate(NamedReturnInfo &Info, + QualType ReturnType); - VarDecl *getCopyElisionCandidate(QualType ReturnType, Expr *E, - CopyElisionSemanticsKind CESK); - bool isCopyElisionCandidate(QualType ReturnType, const VarDecl *VD, - CopyElisionSemanticsKind CESK); + ExprResult + PerformMoveOrCopyInitialization(const InitializedEntity &Entity, + const NamedReturnInfo &NRInfo, Expr *Value, + bool SupressSimplerImplicitMoves = false); StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, Scope *CurScope); StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp); - StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp); + StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, + NamedReturnInfo &NRInfo, + bool SupressSimplerImplicitMoves); StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, bool IsVolatile, unsigned NumOutputs, @@ -4830,6 +4897,10 @@ public: void DiagnoseUnusedNestedTypedefs(const RecordDecl *D); void DiagnoseUnusedDecl(const NamedDecl *ND); + /// If VD is set but not otherwise used, diagnose, for a parameter or a + /// variable. + void DiagnoseUnusedButSetDecl(const VarDecl *VD); + /// Emit \p DiagID if statement located on \p StmtLoc has a suspicious null /// statement as a \p Body, and it is located on the same line. /// @@ -5155,6 +5226,15 @@ public: ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind); ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val); + ExprResult BuildSYCLUniqueStableNameExpr(SourceLocation OpLoc, + SourceLocation LParen, + SourceLocation RParen, + TypeSourceInfo *TSI); + ExprResult ActOnSYCLUniqueStableNameExpr(SourceLocation OpLoc, + SourceLocation LParen, + SourceLocation RParen, + ParsedType ParsedTy); + bool CheckLoopHintExpr(Expr *E, SourceLocation Loc); ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr); @@ -5352,6 +5432,8 @@ public: Expr *ExecConfig = nullptr, bool IsExecConfig = false, bool AllowRecovery = false); + Expr *BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id, + MultiExprArg CallArgs); enum class AtomicArgumentOrder { API, AST }; ExprResult BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, @@ -5558,6 +5640,9 @@ public: ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc); + ExprResult BuildAsTypeExpr(Expr *E, QualType DestTy, + SourceLocation BuiltinLoc, + SourceLocation RParenLoc); //===---------------------------- C++ Features --------------------------===// @@ -5640,11 +5725,12 @@ public: SourceLocation IdentLoc, IdentifierInfo *Ident); + void FilterUsingLookup(Scope *S, LookupResult &lookup); void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow); - bool CheckUsingShadowDecl(UsingDecl *UD, NamedDecl *Target, + bool CheckUsingShadowDecl(BaseUsingDecl *BUD, NamedDecl *Target, const LookupResult &PreviousDecls, UsingShadowDecl *&PrevShadow); - UsingShadowDecl *BuildUsingShadowDecl(Scope *S, UsingDecl *UD, + UsingShadowDecl *BuildUsingShadowDecl(Scope *S, BaseUsingDecl *BUD, NamedDecl *Target, UsingShadowDecl *PrevDecl); @@ -5653,17 +5739,23 @@ public: const CXXScopeSpec &SS, SourceLocation NameLoc, const LookupResult &Previous); - bool CheckUsingDeclQualifier(SourceLocation UsingLoc, - bool HasTypename, + bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename, const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, - SourceLocation NameLoc); + SourceLocation NameLoc, + const LookupResult *R = nullptr, + const UsingDecl *UD = nullptr); NamedDecl *BuildUsingDeclaration( Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS, DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc, - const ParsedAttributesView &AttrList, bool IsInstantiation); + const ParsedAttributesView &AttrList, bool IsInstantiation, + bool IsUsingIfExists); + NamedDecl *BuildUsingEnumDeclaration(Scope *S, AccessSpecifier AS, + SourceLocation UsingLoc, + SourceLocation EnumLoc, + SourceLocation NameLoc, EnumDecl *ED); NamedDecl *BuildUsingPackDecl(NamedDecl *InstantiatedFrom, ArrayRef<NamedDecl *> Expansions); @@ -5681,6 +5773,9 @@ public: SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList); + Decl *ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, + SourceLocation UsingLoc, + SourceLocation EnumLoc, const DeclSpec &); Decl *ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, @@ -5978,9 +6073,9 @@ public: ExprResult CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl); bool CompleteConstructorCall(CXXConstructorDecl *Constructor, - MultiExprArg ArgsPtr, + QualType DeclInitType, MultiExprArg ArgsPtr, SourceLocation Loc, - SmallVectorImpl<Expr*> &ConvertedArgs, + SmallVectorImpl<Expr *> &ConvertedArgs, bool AllowExplicit = false, bool IsListInitialization = false); @@ -6004,6 +6099,12 @@ public: void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType, bool IsDereference, SourceRange Range); + // Checks that the vector type should be initialized from a scalar + // by splatting the value rather than populating a single element. + // This is the case for AltiVecVector types as well as with + // AltiVecPixel and AltiVecBool when -faltivec-src-compat=xl is specified. + bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy); + /// ActOnCXXNamedCast - Parse /// {dynamic,static,reinterpret,const,addrspace}_cast's. ExprResult ActOnCXXNamedCast(SourceLocation OpLoc, @@ -6335,6 +6436,9 @@ public: // Marks SS invalid if it represents an incomplete type. bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC); + // Complete an enum decl, maybe without a scope spec. + bool RequireCompleteEnumDecl(EnumDecl *D, SourceLocation L, + CXXScopeSpec *SS = nullptr); DeclContext *computeDeclContext(QualType T); DeclContext *computeDeclContext(const CXXScopeSpec &SS, @@ -6558,7 +6662,7 @@ public: /// Number lambda for linkage purposes if necessary. void handleLambdaNumbering( CXXRecordDecl *Class, CXXMethodDecl *Method, - Optional<std::tuple<unsigned, bool, Decl *>> Mangling = None); + Optional<std::tuple<bool, unsigned, unsigned, Decl *>> Mangling = None); /// Endow the lambda scope info with the relevant properties. void buildLambdaScope(sema::LambdaScopeInfo *LSI, @@ -7424,6 +7528,11 @@ public: TemplateIdAnnotation *TypeConstraint, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc); + bool BuildTypeConstraint(const CXXScopeSpec &SS, + TemplateIdAnnotation *TypeConstraint, + TemplateTypeParmDecl *ConstrainedParameter, + SourceLocation EllipsisLoc, + bool AllowUnexpandedPack); bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, @@ -10107,85 +10216,42 @@ public: bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend); //===--------------------------------------------------------------------===// - // OpenCL extensions. + // OpenMP directives and clauses. // private: - std::string CurrOpenCLExtension; - /// Extensions required by an OpenCL type. - llvm::DenseMap<const Type*, std::set<std::string>> OpenCLTypeExtMap; - /// Extensions required by an OpenCL declaration. - llvm::DenseMap<const Decl*, std::set<std::string>> OpenCLDeclExtMap; -public: - llvm::StringRef getCurrentOpenCLExtension() const { - return CurrOpenCLExtension; - } + void *VarDataSharingAttributesStack; - /// Check if a function declaration \p FD associates with any - /// extensions present in OpenCLDeclExtMap and if so return the - /// extension(s) name(s). - std::string getOpenCLExtensionsFromDeclExtMap(FunctionDecl *FD); + struct DeclareTargetContextInfo { + struct MapInfo { + OMPDeclareTargetDeclAttr::MapTypeTy MT; + SourceLocation Loc; + }; + /// Explicitly listed variables and functions in a 'to' or 'link' clause. + llvm::DenseMap<NamedDecl *, MapInfo> ExplicitlyMapped; - /// Check if a function type \p FT associates with any - /// extensions present in OpenCLTypeExtMap and if so return the - /// extension(s) name(s). - std::string getOpenCLExtensionsFromTypeExtMap(FunctionType *FT); + /// The 'device_type' as parsed from the clause. + OMPDeclareTargetDeclAttr::DevTypeTy DT = OMPDeclareTargetDeclAttr::DT_Any; - /// Find an extension in an appropriate extension map and return its name - template<typename T, typename MapT> - std::string getOpenCLExtensionsFromExtMap(T* FT, MapT &Map); + /// The directive kind, `begin declare target` or `declare target`. + OpenMPDirectiveKind Kind; - void setCurrentOpenCLExtension(llvm::StringRef Ext) { - CurrOpenCLExtension = std::string(Ext); - } + /// The directive location. + SourceLocation Loc; - /// Set OpenCL extensions for a type which can only be used when these - /// OpenCL extensions are enabled. If \p Exts is empty, do nothing. - /// \param Exts A space separated list of OpenCL extensions. - void setOpenCLExtensionForType(QualType T, llvm::StringRef Exts); - - /// Set OpenCL extensions for a declaration which can only be - /// used when these OpenCL extensions are enabled. If \p Exts is empty, do - /// nothing. - /// \param Exts A space separated list of OpenCL extensions. - void setOpenCLExtensionForDecl(Decl *FD, llvm::StringRef Exts); - - /// Set current OpenCL extensions for a type which can only be used - /// when these OpenCL extensions are enabled. If current OpenCL extension is - /// empty, do nothing. - void setCurrentOpenCLExtensionForType(QualType T); - - /// Set current OpenCL extensions for a declaration which - /// can only be used when these OpenCL extensions are enabled. If current - /// OpenCL extension is empty, do nothing. - void setCurrentOpenCLExtensionForDecl(Decl *FD); - - bool isOpenCLDisabledDecl(Decl *FD); - - /// Check if type \p T corresponding to declaration specifier \p DS - /// is disabled due to required OpenCL extensions being disabled. If so, - /// emit diagnostics. - /// \return true if type is disabled. - bool checkOpenCLDisabledTypeDeclSpec(const DeclSpec &DS, QualType T); - - /// Check if declaration \p D used by expression \p E - /// is disabled due to required OpenCL extensions being disabled. If so, - /// emit diagnostics. - /// \return true if type is disabled. - bool checkOpenCLDisabledDecl(const NamedDecl &D, const Expr &E); + DeclareTargetContextInfo(OpenMPDirectiveKind Kind, SourceLocation Loc) + : Kind(Kind), Loc(Loc) {} + }; - //===--------------------------------------------------------------------===// - // OpenMP directives and clauses. - // -private: - void *VarDataSharingAttributesStack; /// Number of nested '#pragma omp declare target' directives. - SmallVector<SourceLocation, 4> DeclareTargetNesting; + SmallVector<DeclareTargetContextInfo, 4> DeclareTargetNesting; + /// Initialization of data-sharing attributes stack. void InitDataSharingAttributesStack(); void DestroyDataSharingAttributesStack(); ExprResult VerifyPositiveIntegerConstantInClause(Expr *Op, OpenMPClauseKind CKind, - bool StrictlyPositive = true); + bool StrictlyPositive = true, + bool SuppressExprDiags = false); /// Returns OpenMP nesting level for current directive. unsigned getOpenMPNestingLevel() const; @@ -10203,20 +10269,24 @@ private: /// Pop OpenMP function region for non-capturing function. void popOpenMPFunctionRegion(const sema::FunctionScopeInfo *OldFSI); - /// Checks if a type or a declaration is disabled due to the owning extension - /// being disabled, and emits diagnostic messages if it is disabled. - /// \param D type or declaration to be checked. - /// \param DiagLoc source location for the diagnostic message. - /// \param DiagInfo information to be emitted for the diagnostic message. - /// \param SrcRange source range of the declaration. - /// \param Map maps type or declaration to the extensions. - /// \param Selector selects diagnostic message: 0 for type and 1 for - /// declaration. - /// \return true if the type or declaration is disabled. - template <typename T, typename DiagLocT, typename DiagInfoT, typename MapT> - bool checkOpenCLDisabledTypeOrDecl(T D, DiagLocT DiagLoc, DiagInfoT DiagInfo, - MapT &Map, unsigned Selector = 0, - SourceRange SrcRange = SourceRange()); + /// Analyzes and checks a loop nest for use by a loop transformation. + /// + /// \param Kind The loop transformation directive kind. + /// \param NumLoops How many nested loops the directive is expecting. + /// \param AStmt Associated statement of the transformation directive. + /// \param LoopHelpers [out] The loop analysis result. + /// \param Body [out] The body code nested in \p NumLoops loop. + /// \param OriginalInits [out] Collection of statements and declarations that + /// must have been executed/declared before entering the + /// loop. + /// + /// \return Whether there was any error. + bool checkTransformableLoopNest( + OpenMPDirectiveKind Kind, Stmt *AStmt, int NumLoops, + SmallVectorImpl<OMPLoopBasedDirective::HelperExprs> &LoopHelpers, + Stmt *&Body, + SmallVectorImpl<SmallVector<llvm::PointerUnion<Stmt *, Decl *>, 0>> + &OriginalInits); /// Helper to keep information about the current `omp begin/end declare /// variant` nesting. @@ -10445,19 +10515,28 @@ public: const ValueDecl *getOpenMPDeclareMapperVarName() const; /// Called on the start of target region i.e. '#pragma omp declare target'. - bool ActOnStartOpenMPDeclareTargetDirective(SourceLocation Loc); - /// Called at the end of target region i.e. '#pragme omp end declare target'. - void ActOnFinishOpenMPDeclareTargetDirective(); + bool ActOnStartOpenMPDeclareTargetContext(DeclareTargetContextInfo &DTCI); + + /// Called at the end of target region i.e. '#pragma omp end declare target'. + const DeclareTargetContextInfo ActOnOpenMPEndDeclareTargetDirective(); + + /// Called once a target context is completed, that can be when a + /// '#pragma omp end declare target' was encountered or when a + /// '#pragma omp declare target' without declaration-definition-seq was + /// encountered. + void ActOnFinishedOpenMPDeclareTargetContext(DeclareTargetContextInfo &DTCI); + /// Searches for the provided declaration name for OpenMP declare target /// directive. - NamedDecl * - lookupOpenMPDeclareTargetName(Scope *CurScope, CXXScopeSpec &ScopeSpec, - const DeclarationNameInfo &Id, - NamedDeclSetType &SameDirectiveDecls); + NamedDecl *lookupOpenMPDeclareTargetName(Scope *CurScope, + CXXScopeSpec &ScopeSpec, + const DeclarationNameInfo &Id); + /// Called on correct id-expression from the '#pragma omp declare target'. void ActOnOpenMPDeclareTargetName(NamedDecl *ND, SourceLocation Loc, OMPDeclareTargetDeclAttr::MapTypeTy MT, OMPDeclareTargetDeclAttr::DevTypeTy DT); + /// Check declaration inside target region. void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D, @@ -10479,6 +10558,11 @@ public: /// Initialization of captured region for OpenMP region. void ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope); + + /// Called for syntactical loops (ForStmt or CXXForRangeStmt) associated to + /// an OpenMP loop directive. + StmtResult ActOnOpenMPCanonicalLoop(Stmt *AStmt); + /// End of OpenMP region. /// /// \param S Statement associated with the current OpenMP region. @@ -10504,6 +10588,16 @@ public: ActOnOpenMPSimdDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); + /// Called on well-formed '#pragma omp tile' after parsing of its clauses and + /// the associated statement. + StmtResult ActOnOpenMPTileDirective(ArrayRef<OMPClause *> Clauses, + Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc); + /// Called on well-formed '#pragma omp unroll' after parsing of its clauses + /// and the associated statement. + StmtResult ActOnOpenMPUnrollDirective(ArrayRef<OMPClause *> Clauses, + Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc); /// Called on well-formed '\#pragma omp for' after parsing /// of the associated statement. StmtResult @@ -10764,6 +10858,20 @@ public: StmtResult ActOnOpenMPTargetTeamsDistributeSimdDirective( ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); + /// Called on well-formed '\#pragma omp interop'. + StmtResult ActOnOpenMPInteropDirective(ArrayRef<OMPClause *> Clauses, + SourceLocation StartLoc, + SourceLocation EndLoc); + /// Called on well-formed '\#pragma omp dispatch' after parsing of the + // /associated statement. + StmtResult ActOnOpenMPDispatchDirective(ArrayRef<OMPClause *> Clauses, + Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc); + /// Called on well-formed '\#pragma omp masked' after parsing of the + // /associated statement. + StmtResult ActOnOpenMPMaskedDirective(ArrayRef<OMPClause *> Clauses, + Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc); /// Checks correctness of linear modifiers. bool CheckOpenMPLinearModifier(OpenMPLinearClauseKind LinKind, @@ -10840,6 +10948,18 @@ public: OMPClause *ActOnOpenMPSimdlenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); + /// Called on well-form 'sizes' clause. + OMPClause *ActOnOpenMPSizesClause(ArrayRef<Expr *> SizeExprs, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); + /// Called on well-form 'full' clauses. + OMPClause *ActOnOpenMPFullClause(SourceLocation StartLoc, + SourceLocation EndLoc); + /// Called on well-form 'partial' clauses. + OMPClause *ActOnOpenMPPartialClause(Expr *FactorExpr, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); /// Called on well-formed 'collapse' clause. OMPClause *ActOnOpenMPCollapseClause(Expr *NumForLoops, SourceLocation StartLoc, @@ -10948,9 +11068,39 @@ public: /// Called on well-formed 'relaxed' clause. OMPClause *ActOnOpenMPRelaxedClause(SourceLocation StartLoc, SourceLocation EndLoc); + + /// Called on well-formed 'init' clause. + OMPClause *ActOnOpenMPInitClause(Expr *InteropVar, ArrayRef<Expr *> PrefExprs, + bool IsTarget, bool IsTargetSync, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation VarLoc, + SourceLocation EndLoc); + + /// Called on well-formed 'use' clause. + OMPClause *ActOnOpenMPUseClause(Expr *InteropVar, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation VarLoc, SourceLocation EndLoc); + /// Called on well-formed 'destroy' clause. - OMPClause *ActOnOpenMPDestroyClause(SourceLocation StartLoc, + OMPClause *ActOnOpenMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation VarLoc, SourceLocation EndLoc); + /// Called on well-formed 'novariants' clause. + OMPClause *ActOnOpenMPNovariantsClause(Expr *Condition, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); + /// Called on well-formed 'nocontext' clause. + OMPClause *ActOnOpenMPNocontextClause(Expr *Condition, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); + /// Called on well-formed 'filter' clause. + OMPClause *ActOnOpenMPFilterClause(Expr *ThreadID, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); /// Called on well-formed 'threads' clause. OMPClause *ActOnOpenMPThreadsClause(SourceLocation StartLoc, SourceLocation EndLoc); @@ -11199,11 +11349,11 @@ public: /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit /// cast. If there is already an implicit cast, merge into the existing one. /// If isLvalue, the result of the cast is an lvalue. - ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, - ExprValueKind VK = VK_RValue, - const CXXCastPath *BasePath = nullptr, - CheckedConversionKind CCK - = CCK_ImplicitConversion); + ExprResult + ImpCastExprToType(Expr *E, QualType Type, CastKind CK, + ExprValueKind VK = VK_PRValue, + const CXXCastPath *BasePath = nullptr, + CheckedConversionKind CCK = CCK_ImplicitConversion); /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding /// to the conversion from scalar type ScalarTy to the Boolean type. @@ -11277,6 +11427,18 @@ public: /// function, issuing a diagnostic if not. void checkVariadicArgument(const Expr *E, VariadicCallType CT); + /// Check whether the given statement can have musttail applied to it, + /// issuing a diagnostic and returning false if not. In the success case, + /// the statement is rewritten to remove implicit nodes from the return + /// value. + bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA); + +private: + /// Check whether the given statement can have musttail applied to it, + /// issuing a diagnostic and returning false if not. + bool checkMustTailAttr(const Stmt *St, const Attr &MTA); + +public: /// Check to see if a given expression could have '.c_str()' called on it. bool hasCStrMethod(const Expr *E); @@ -11476,7 +11638,7 @@ public: CheckedConversionKind CCK); ExprResult PerformQualificationConversion( - Expr *E, QualType Ty, ExprValueKind VK = VK_RValue, + Expr *E, QualType Ty, ExprValueKind VK = VK_PRValue, CheckedConversionKind CCK = CCK_ImplicitConversion); /// the following "Check" methods will return a valid/converted QualType @@ -11535,9 +11697,9 @@ public: QualType CXXCheckConditionalOperands( // C++ 5.16 ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc); - QualType CheckGNUVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS, - ExprResult &RHS, - SourceLocation QuestionLoc); + QualType CheckVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS, + ExprResult &RHS, + SourceLocation QuestionLoc); QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool ConvertArgs = true); QualType FindCompositePointerType(SourceLocation Loc, @@ -11581,6 +11743,9 @@ public: bool isValidSveBitcast(QualType srcType, QualType destType); + bool areMatrixTypesOfTheSameDimension(QualType srcTy, QualType destTy); + + bool areVectorTypesSameSize(QualType srcType, QualType destType); bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType); bool isLaxVectorConversion(QualType srcType, QualType destType); @@ -11639,6 +11804,13 @@ public: ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType ¶mType); + // CheckMatrixCast - Check type constraints for matrix casts. + // We allow casting between matrixes of the same dimensions i.e. when they + // have the same number of rows and column. Returns true if the cast is + // invalid. + bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy, + CastKind &Kind); + // CheckVectorCast - check type constraints for vectors. // Since vectors are an extension, there are no C standard reference for this. // We allow casting between vectors and integer datatypes of the same size. @@ -11948,8 +12120,8 @@ public: /// if (diagIfOpenMPDeviceCode(Loc, diag::err_vla_unsupported)) /// return ExprError(); /// // Otherwise, continue parsing as normal. - SemaDiagnosticBuilder diagIfOpenMPDeviceCode(SourceLocation Loc, - unsigned DiagID); + SemaDiagnosticBuilder + diagIfOpenMPDeviceCode(SourceLocation Loc, unsigned DiagID, FunctionDecl *FD); /// Creates a SemaDiagnosticBuilder that emits the diagnostic if the current /// context is "used as host code". @@ -11965,17 +12137,19 @@ public: /// return ExprError(); /// // Otherwise, continue parsing as normal. SemaDiagnosticBuilder diagIfOpenMPHostCode(SourceLocation Loc, - unsigned DiagID); + unsigned DiagID, FunctionDecl *FD); - SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID); + SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, + FunctionDecl *FD = nullptr); SemaDiagnosticBuilder targetDiag(SourceLocation Loc, - const PartialDiagnostic &PD) { - return targetDiag(Loc, PD.getDiagID()) << PD; + const PartialDiagnostic &PD, + FunctionDecl *FD = nullptr) { + return targetDiag(Loc, PD.getDiagID(), FD) << PD; } /// Check if the expression is allowed to be used in expressions for the /// offloading devices. - void checkDeviceDecl(const ValueDecl *D, SourceLocation Loc); + void checkDeviceDecl(ValueDecl *D, SourceLocation Loc); enum CUDAFunctionTarget { CFT_Device, @@ -11994,6 +12168,15 @@ public: bool IgnoreImplicitHDAttr = false); CUDAFunctionTarget IdentifyCUDATarget(const ParsedAttributesView &Attrs); + enum CUDAVariableTarget { + CVT_Device, /// Emitted on device side with a shadow variable on host side + CVT_Host, /// Emitted on host side only + CVT_Both, /// Emitted on both sides with different addresses + CVT_Unified, /// Emitted as a unified address, e.g. managed variables + }; + /// Determines whether the given variable is emitted on host or device side. + CUDAVariableTarget IdentifyCUDATarget(const VarDecl *D); + /// Gets the CUDA target for the current context. CUDAFunctionTarget CurrentCUDATarget() { return IdentifyCUDATarget(dyn_cast<FunctionDecl>(CurContext)); @@ -12192,8 +12375,14 @@ public: const VirtSpecifiers *VS = nullptr); void CodeCompleteBracketDeclarator(Scope *S); void CodeCompleteCase(Scope *S); - /// Reports signatures for a call to CodeCompleteConsumer and returns the - /// preferred type for the current argument. Returned type can be null. + /// Determines the preferred type of the current function argument, by + /// examining the signatures of all possible overloads. + /// Returns null if unknown or ambiguous, or if code completion is off. + /// + /// If the code completion point has been reached, also reports the function + /// signatures that were considered. + /// + /// FIXME: rename to GuessCallArgumentType to reduce confusion. QualType ProduceCallSignatureHelp(Scope *S, Expr *Fn, ArrayRef<Expr *> Args, SourceLocation OpenParLoc); QualType ProduceConstructorSignatureHelp(Scope *S, QualType Type, @@ -12328,10 +12517,12 @@ private: bool CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall, const FunctionProtoType *Proto); bool CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto); - void CheckConstructorCall(FunctionDecl *FDecl, + void CheckConstructorCall(FunctionDecl *FDecl, QualType ThisType, ArrayRef<const Expr *> Args, - const FunctionProtoType *Proto, - SourceLocation Loc); + const FunctionProtoType *Proto, SourceLocation Loc); + + void CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl, + StringRef ParamName, QualType ArgTy, QualType ParamTy); void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, const Expr *ThisArg, ArrayRef<const Expr *> Args, @@ -12386,6 +12577,9 @@ private: bool CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall); bool CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); + bool CheckRISCVLMUL(CallExpr *TheCall, unsigned ArgNum); + bool CheckRISCVBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, + CallExpr *TheCall); bool SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall); bool SemaBuiltinVAStartARMMicrosoft(CallExpr *Call); @@ -12394,6 +12588,7 @@ private: bool SemaBuiltinComplex(CallExpr *TheCall); bool SemaBuiltinVSX(CallExpr *TheCall); bool SemaBuiltinOSLogFormat(CallExpr *TheCall); + bool SemaValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum); public: // Used by C++ template instantiation. @@ -12405,6 +12600,7 @@ public: private: bool SemaBuiltinPrefetch(CallExpr *TheCall); bool SemaBuiltinAllocaWithAlign(CallExpr *TheCall); + bool SemaBuiltinArithmeticFence(CallExpr *TheCall); bool SemaBuiltinAssume(CallExpr *TheCall); bool SemaBuiltinAssumeAligned(CallExpr *TheCall); bool SemaBuiltinLongjmp(CallExpr *TheCall); diff --git a/clang/include/clang/Sema/Template.h b/clang/include/clang/Sema/Template.h index 0dcaf565591b..540d2c9aa87e 100644 --- a/clang/include/clang/Sema/Template.h +++ b/clang/include/clang/Sema/Template.h @@ -537,6 +537,8 @@ enum class TemplateSubstitutionKind : char { Decl *VisitDecl(Decl *D); Decl *VisitVarDecl(VarDecl *D, bool InstantiatingVarTemplate, ArrayRef<BindingDecl *> *Bindings = nullptr); + Decl *VisitBaseUsingDecls(BaseUsingDecl *D, BaseUsingDecl *Inst, + LookupResult *Lookup); // Enable late instantiation of attributes. Late instantiated attributes // will be stored in LA. diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index e9fc202f8d1d..027a981df22c 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -41,7 +41,7 @@ namespace serialization { /// Version 4 of AST files also requires that the version control branch and /// revision match exactly, since there is no backward compatibility of /// AST files at this time. -const unsigned VERSION_MAJOR = 11; +const unsigned VERSION_MAJOR = 15; /// AST file minor version number supported by this version of /// Clang. @@ -109,2017 +109,2028 @@ public: } }; - /// A structure for putting "fast"-unqualified QualTypes into a - /// DenseMap. This uses the standard pointer hash function. - struct UnsafeQualTypeDenseMapInfo { - static bool isEqual(QualType A, QualType B) { return A == B; } +/// A structure for putting "fast"-unqualified QualTypes into a +/// DenseMap. This uses the standard pointer hash function. +struct UnsafeQualTypeDenseMapInfo { + static bool isEqual(QualType A, QualType B) { return A == B; } - static QualType getEmptyKey() { - return QualType::getFromOpaquePtr((void*) 1); - } + static QualType getEmptyKey() { + return QualType::getFromOpaquePtr((void *)1); + } + + static QualType getTombstoneKey() { + return QualType::getFromOpaquePtr((void *)2); + } + + static unsigned getHashValue(QualType T) { + assert(!T.getLocalFastQualifiers() && + "hash invalid for types with fast quals"); + uintptr_t v = reinterpret_cast<uintptr_t>(T.getAsOpaquePtr()); + return (unsigned(v) >> 4) ^ (unsigned(v) >> 9); + } +}; + +/// An ID number that refers to an identifier in an AST file. +using IdentID = uint32_t; + +/// The number of predefined identifier IDs. +const unsigned int NUM_PREDEF_IDENT_IDS = 1; + +/// An ID number that refers to a macro in an AST file. +using MacroID = uint32_t; - static QualType getTombstoneKey() { - return QualType::getFromOpaquePtr((void*) 2); - } - - static unsigned getHashValue(QualType T) { - assert(!T.getLocalFastQualifiers() && - "hash invalid for types with fast quals"); - uintptr_t v = reinterpret_cast<uintptr_t>(T.getAsOpaquePtr()); - return (unsigned(v) >> 4) ^ (unsigned(v) >> 9); - } - }; - - /// An ID number that refers to an identifier in an AST file. - using IdentID = uint32_t; - - /// The number of predefined identifier IDs. - const unsigned int NUM_PREDEF_IDENT_IDS = 1; - - /// An ID number that refers to a macro in an AST file. - using MacroID = uint32_t; - - /// A global ID number that refers to a macro in an AST file. - using GlobalMacroID = uint32_t; - - /// A local to a module ID number that refers to a macro in an - /// AST file. - using LocalMacroID = uint32_t; - - /// The number of predefined macro IDs. - const unsigned int NUM_PREDEF_MACRO_IDS = 1; - - /// An ID number that refers to an ObjC selector in an AST file. - using SelectorID = uint32_t; - - /// The number of predefined selector IDs. - const unsigned int NUM_PREDEF_SELECTOR_IDS = 1; - - /// An ID number that refers to a set of CXXBaseSpecifiers in an - /// AST file. - using CXXBaseSpecifiersID = uint32_t; - - /// An ID number that refers to a list of CXXCtorInitializers in an - /// AST file. - using CXXCtorInitializersID = uint32_t; - - /// An ID number that refers to an entity in the detailed - /// preprocessing record. - using PreprocessedEntityID = uint32_t; - - /// An ID number that refers to a submodule in a module file. - using SubmoduleID = uint32_t; - - /// The number of predefined submodule IDs. - const unsigned int NUM_PREDEF_SUBMODULE_IDS = 1; - - /// Source range/offset of a preprocessed entity. - struct PPEntityOffset { - /// Raw source location of beginning of range. - unsigned Begin; - - /// Raw source location of end of range. - unsigned End; - - /// Offset in the AST file relative to ModuleFile::MacroOffsetsBase. - uint32_t BitOffset; - - PPEntityOffset(SourceRange R, uint32_t BitOffset) - : Begin(R.getBegin().getRawEncoding()), - End(R.getEnd().getRawEncoding()), BitOffset(BitOffset) {} - - SourceLocation getBegin() const { - return SourceLocation::getFromRawEncoding(Begin); - } - - SourceLocation getEnd() const { - return SourceLocation::getFromRawEncoding(End); - } - }; - - /// Source range of a skipped preprocessor region - struct PPSkippedRange { - /// Raw source location of beginning of range. - unsigned Begin; - /// Raw source location of end of range. - unsigned End; - - PPSkippedRange(SourceRange R) - : Begin(R.getBegin().getRawEncoding()), - End(R.getEnd().getRawEncoding()) { } - - SourceLocation getBegin() const { - return SourceLocation::getFromRawEncoding(Begin); - } - SourceLocation getEnd() const { - return SourceLocation::getFromRawEncoding(End); - } - }; - - /// Offset in the AST file. Use splitted 64-bit integer into low/high - /// parts to keep structure alignment 32-bit (it is important because - /// blobs in bitstream are 32-bit aligned). This structure is serialized - /// "as is" to the AST file. - struct UnderalignedInt64 { - uint32_t BitOffsetLow = 0; - uint32_t BitOffsetHigh = 0; - - UnderalignedInt64() = default; - UnderalignedInt64(uint64_t BitOffset) { setBitOffset(BitOffset); } - - void setBitOffset(uint64_t Offset) { - BitOffsetLow = Offset; - BitOffsetHigh = Offset >> 32; - } - - uint64_t getBitOffset() const { - return BitOffsetLow | (uint64_t(BitOffsetHigh) << 32); - } - }; - - /// Source location and bit offset of a declaration. - struct DeclOffset { - /// Raw source location. - unsigned Loc = 0; - - /// Offset relative to the start of the DECLTYPES_BLOCK block. Keep - /// structure alignment 32-bit and avoid padding gap because undefined - /// value in the padding affects AST hash. - UnderalignedInt64 BitOffset; - - DeclOffset() = default; - DeclOffset(SourceLocation Loc, uint64_t BitOffset, - uint64_t DeclTypesBlockStartOffset) { - setLocation(Loc); - setBitOffset(BitOffset, DeclTypesBlockStartOffset); - } - - void setLocation(SourceLocation L) { - Loc = L.getRawEncoding(); - } - - SourceLocation getLocation() const { - return SourceLocation::getFromRawEncoding(Loc); - } - - void setBitOffset(uint64_t Offset, - const uint64_t DeclTypesBlockStartOffset) { - BitOffset.setBitOffset(Offset - DeclTypesBlockStartOffset); - } - - uint64_t getBitOffset(const uint64_t DeclTypesBlockStartOffset) const { - return BitOffset.getBitOffset() + DeclTypesBlockStartOffset; - } - }; - - /// The number of predefined preprocessed entity IDs. - const unsigned int NUM_PREDEF_PP_ENTITY_IDS = 1; - - /// Describes the various kinds of blocks that occur within - /// an AST file. - enum BlockIDs { - /// The AST block, which acts as a container around the - /// full AST block. - AST_BLOCK_ID = llvm::bitc::FIRST_APPLICATION_BLOCKID, - - /// The block containing information about the source - /// manager. - SOURCE_MANAGER_BLOCK_ID, - - /// The block containing information about the - /// preprocessor. - PREPROCESSOR_BLOCK_ID, - - /// The block containing the definitions of all of the - /// types and decls used within the AST file. - DECLTYPES_BLOCK_ID, - - /// The block containing the detailed preprocessing record. - PREPROCESSOR_DETAIL_BLOCK_ID, - - /// The block containing the submodule structure. - SUBMODULE_BLOCK_ID, - - /// The block containing comments. - COMMENTS_BLOCK_ID, - - /// The control block, which contains all of the - /// information that needs to be validated prior to committing - /// to loading the AST file. - CONTROL_BLOCK_ID, - - /// The block of input files, which were used as inputs - /// to create this AST file. - /// - /// This block is part of the control block. - INPUT_FILES_BLOCK_ID, - - /// The block of configuration options, used to check that - /// a module is being used in a configuration compatible with the - /// configuration in which it was built. - /// - /// This block is part of the control block. - OPTIONS_BLOCK_ID, - - /// A block containing a module file extension. - EXTENSION_BLOCK_ID, - - /// A block with unhashed content. - /// - /// These records should not change the \a ASTFileSignature. See \a - /// UnhashedControlBlockRecordTypes for the list of records. - UNHASHED_CONTROL_BLOCK_ID, - }; - - /// Record types that occur within the control block. - enum ControlRecordTypes { - /// AST file metadata, including the AST file version number - /// and information about the compiler used to build this AST file. - METADATA = 1, - - /// Record code for the list of other AST files imported by - /// this AST file. - IMPORTS, - - /// Record code for the original file that was used to - /// generate the AST file, including both its file ID and its - /// name. - ORIGINAL_FILE, - - /// The directory that the PCH was originally created in. - ORIGINAL_PCH_DIR, - - /// Record code for file ID of the file or buffer that was used to - /// generate the AST file. - ORIGINAL_FILE_ID, - - /// Offsets into the input-files block where input files - /// reside. - INPUT_FILE_OFFSETS, - - /// Record code for the module name. - MODULE_NAME, - - /// Record code for the module map file that was used to build this - /// AST file. - MODULE_MAP_FILE, - - /// Record code for the module build directory. - MODULE_DIRECTORY, - }; - - /// Record types that occur within the options block inside - /// the control block. - enum OptionsRecordTypes { - /// Record code for the language options table. - /// - /// The record with this code contains the contents of the - /// LangOptions structure. We serialize the entire contents of - /// the structure, and let the reader decide which options are - /// actually important to check. - LANGUAGE_OPTIONS = 1, - - /// Record code for the target options table. - TARGET_OPTIONS, - - /// Record code for the filesystem options table. - FILE_SYSTEM_OPTIONS, - - /// Record code for the headers search options table. - HEADER_SEARCH_OPTIONS, - - /// Record code for the preprocessor options table. - PREPROCESSOR_OPTIONS, - }; - - /// Record codes for the unhashed control block. - enum UnhashedControlBlockRecordTypes { - /// Record code for the signature that identifiers this AST file. - SIGNATURE = 1, - - /// Record code for the content hash of the AST block. - AST_BLOCK_HASH, - - /// Record code for the diagnostic options table. - DIAGNOSTIC_OPTIONS, - - /// Record code for \#pragma diagnostic mappings. - DIAG_PRAGMA_MAPPINGS, - }; - - /// Record code for extension blocks. - enum ExtensionBlockRecordTypes { - /// Metadata describing this particular extension. - EXTENSION_METADATA = 1, - - /// The first record ID allocated to the extensions themselves. - FIRST_EXTENSION_RECORD_ID = 4 - }; - - /// Record types that occur within the input-files block - /// inside the control block. - enum InputFileRecordTypes { - /// An input file. - INPUT_FILE = 1, - - /// The input file content hash - INPUT_FILE_HASH - }; - - /// Record types that occur within the AST block itself. - enum ASTRecordTypes { - /// Record code for the offsets of each type. - /// - /// The TYPE_OFFSET constant describes the record that occurs - /// within the AST block. The record itself is an array of offsets that - /// point into the declarations and types block (identified by - /// DECLTYPES_BLOCK_ID). The index into the array is based on the ID - /// of a type. For a given type ID @c T, the lower three bits of - /// @c T are its qualifiers (const, volatile, restrict), as in - /// the QualType class. The upper bits, after being shifted and - /// subtracting NUM_PREDEF_TYPE_IDS, are used to index into the - /// TYPE_OFFSET block to determine the offset of that type's - /// corresponding record within the DECLTYPES_BLOCK_ID block. - TYPE_OFFSET = 1, - - /// Record code for the offsets of each decl. - /// - /// The DECL_OFFSET constant describes the record that occurs - /// within the block identified by DECL_OFFSETS_BLOCK_ID within - /// the AST block. The record itself is an array of offsets that - /// point into the declarations and types block (identified by - /// DECLTYPES_BLOCK_ID). The declaration ID is an index into this - /// record, after subtracting one to account for the use of - /// declaration ID 0 for a NULL declaration pointer. Index 0 is - /// reserved for the translation unit declaration. - DECL_OFFSET = 2, - - /// Record code for the table of offsets of each - /// identifier ID. - /// - /// The offset table contains offsets into the blob stored in - /// the IDENTIFIER_TABLE record. Each offset points to the - /// NULL-terminated string that corresponds to that identifier. - IDENTIFIER_OFFSET = 3, - - /// This is so that older clang versions, before the introduction - /// of the control block, can read and reject the newer PCH format. - /// *DON'T CHANGE THIS NUMBER*. - METADATA_OLD_FORMAT = 4, - - /// Record code for the identifier table. - /// - /// The identifier table is a simple blob that contains - /// NULL-terminated strings for all of the identifiers - /// referenced by the AST file. The IDENTIFIER_OFFSET table - /// contains the mapping from identifier IDs to the characters - /// in this blob. Note that the starting offsets of all of the - /// identifiers are odd, so that, when the identifier offset - /// table is loaded in, we can use the low bit to distinguish - /// between offsets (for unresolved identifier IDs) and - /// IdentifierInfo pointers (for already-resolved identifier - /// IDs). - IDENTIFIER_TABLE = 5, - - /// Record code for the array of eagerly deserialized decls. - /// - /// The AST file contains a list of all of the declarations that should be - /// eagerly deserialized present within the parsed headers, stored as an - /// array of declaration IDs. These declarations will be - /// reported to the AST consumer after the AST file has been - /// read, since their presence can affect the semantics of the - /// program (e.g., for code generation). - EAGERLY_DESERIALIZED_DECLS = 6, - - /// Record code for the set of non-builtin, special - /// types. - /// - /// This record contains the type IDs for the various type nodes - /// that are constructed during semantic analysis (e.g., - /// __builtin_va_list). The SPECIAL_TYPE_* constants provide - /// offsets into this record. - SPECIAL_TYPES = 7, - - /// Record code for the extra statistics we gather while - /// generating an AST file. - STATISTICS = 8, - - /// Record code for the array of tentative definitions. - TENTATIVE_DEFINITIONS = 9, - - // ID 10 used to be for a list of extern "C" declarations. - - /// Record code for the table of offsets into the - /// Objective-C method pool. - SELECTOR_OFFSETS = 11, - - /// Record code for the Objective-C method pool, - METHOD_POOL = 12, - - /// The value of the next __COUNTER__ to dispense. - /// [PP_COUNTER_VALUE, Val] - PP_COUNTER_VALUE = 13, - - /// Record code for the table of offsets into the block - /// of source-location information. - SOURCE_LOCATION_OFFSETS = 14, - - /// Record code for the set of source location entries - /// that need to be preloaded by the AST reader. - /// - /// This set contains the source location entry for the - /// predefines buffer and for any file entries that need to be - /// preloaded. - SOURCE_LOCATION_PRELOADS = 15, - - /// Record code for the set of ext_vector type names. - EXT_VECTOR_DECLS = 16, - - /// Record code for the array of unused file scoped decls. - UNUSED_FILESCOPED_DECLS = 17, - - /// Record code for the table of offsets to entries in the - /// preprocessing record. - PPD_ENTITIES_OFFSETS = 18, - - /// Record code for the array of VTable uses. - VTABLE_USES = 19, - - // ID 20 used to be for a list of dynamic classes. - - /// Record code for referenced selector pool. - REFERENCED_SELECTOR_POOL = 21, - - /// Record code for an update to the TU's lexically contained - /// declarations. - TU_UPDATE_LEXICAL = 22, - - // ID 23 used to be for a list of local redeclarations. - - /// Record code for declarations that Sema keeps references of. - SEMA_DECL_REFS = 24, - - /// Record code for weak undeclared identifiers. - WEAK_UNDECLARED_IDENTIFIERS = 25, +/// A global ID number that refers to a macro in an AST file. +using GlobalMacroID = uint32_t; - /// Record code for pending implicit instantiations. - PENDING_IMPLICIT_INSTANTIATIONS = 26, +/// A local to a module ID number that refers to a macro in an +/// AST file. +using LocalMacroID = uint32_t; - // ID 27 used to be for a list of replacement decls. +/// The number of predefined macro IDs. +const unsigned int NUM_PREDEF_MACRO_IDS = 1; - /// Record code for an update to a decl context's lookup table. - /// - /// In practice, this should only be used for the TU and namespaces. - UPDATE_VISIBLE = 28, +/// An ID number that refers to an ObjC selector in an AST file. +using SelectorID = uint32_t; - /// Record for offsets of DECL_UPDATES records for declarations - /// that were modified after being deserialized and need updates. - DECL_UPDATE_OFFSETS = 29, +/// The number of predefined selector IDs. +const unsigned int NUM_PREDEF_SELECTOR_IDS = 1; - // ID 30 used to be a decl update record. These are now in the DECLTYPES - // block. +/// An ID number that refers to a set of CXXBaseSpecifiers in an +/// AST file. +using CXXBaseSpecifiersID = uint32_t; + +/// An ID number that refers to a list of CXXCtorInitializers in an +/// AST file. +using CXXCtorInitializersID = uint32_t; + +/// An ID number that refers to an entity in the detailed +/// preprocessing record. +using PreprocessedEntityID = uint32_t; + +/// An ID number that refers to a submodule in a module file. +using SubmoduleID = uint32_t; + +/// The number of predefined submodule IDs. +const unsigned int NUM_PREDEF_SUBMODULE_IDS = 1; + +/// Source range/offset of a preprocessed entity. +struct PPEntityOffset { + /// Raw source location of beginning of range. + SourceLocation::UIntTy Begin; + + /// Raw source location of end of range. + SourceLocation::UIntTy End; + + /// Offset in the AST file relative to ModuleFile::MacroOffsetsBase. + uint32_t BitOffset; + + PPEntityOffset(SourceRange R, uint32_t BitOffset) + : Begin(R.getBegin().getRawEncoding()), End(R.getEnd().getRawEncoding()), + BitOffset(BitOffset) {} + + SourceLocation getBegin() const { + return SourceLocation::getFromRawEncoding(Begin); + } - // ID 31 used to be a list of offsets to DECL_CXX_BASE_SPECIFIERS records. + SourceLocation getEnd() const { + return SourceLocation::getFromRawEncoding(End); + } +}; - // ID 32 used to be the code for \#pragma diagnostic mappings. +/// Source range of a skipped preprocessor region +struct PPSkippedRange { + /// Raw source location of beginning of range. + SourceLocation::UIntTy Begin; + /// Raw source location of end of range. + SourceLocation::UIntTy End; - /// Record code for special CUDA declarations. - CUDA_SPECIAL_DECL_REFS = 33, + PPSkippedRange(SourceRange R) + : Begin(R.getBegin().getRawEncoding()), End(R.getEnd().getRawEncoding()) { + } - /// Record code for header search information. - HEADER_SEARCH_TABLE = 34, + SourceLocation getBegin() const { + return SourceLocation::getFromRawEncoding(Begin); + } + SourceLocation getEnd() const { + return SourceLocation::getFromRawEncoding(End); + } +}; - /// Record code for floating point \#pragma options. - FP_PRAGMA_OPTIONS = 35, +/// Offset in the AST file. Use splitted 64-bit integer into low/high +/// parts to keep structure alignment 32-bit (it is important because +/// blobs in bitstream are 32-bit aligned). This structure is serialized +/// "as is" to the AST file. +struct UnderalignedInt64 { + uint32_t BitOffsetLow = 0; + uint32_t BitOffsetHigh = 0; - /// Record code for enabled OpenCL extensions. - OPENCL_EXTENSIONS = 36, + UnderalignedInt64() = default; + UnderalignedInt64(uint64_t BitOffset) { setBitOffset(BitOffset); } - /// The list of delegating constructor declarations. - DELEGATING_CTORS = 37, + void setBitOffset(uint64_t Offset) { + BitOffsetLow = Offset; + BitOffsetHigh = Offset >> 32; + } - /// Record code for the set of known namespaces, which are used - /// for typo correction. - KNOWN_NAMESPACES = 38, + uint64_t getBitOffset() const { + return BitOffsetLow | (uint64_t(BitOffsetHigh) << 32); + } +}; - /// Record code for the remapping information used to relate - /// loaded modules to the various offsets and IDs(e.g., source location - /// offests, declaration and type IDs) that are used in that module to - /// refer to other modules. - MODULE_OFFSET_MAP = 39, +/// Source location and bit offset of a declaration. +struct DeclOffset { + /// Raw source location. + SourceLocation::UIntTy Loc = 0; + + /// Offset relative to the start of the DECLTYPES_BLOCK block. Keep + /// structure alignment 32-bit and avoid padding gap because undefined + /// value in the padding affects AST hash. + UnderalignedInt64 BitOffset; + + DeclOffset() = default; + DeclOffset(SourceLocation Loc, uint64_t BitOffset, + uint64_t DeclTypesBlockStartOffset) { + setLocation(Loc); + setBitOffset(BitOffset, DeclTypesBlockStartOffset); + } - /// Record code for the source manager line table information, - /// which stores information about \#line directives. - SOURCE_MANAGER_LINE_TABLE = 40, + void setLocation(SourceLocation L) { Loc = L.getRawEncoding(); } - /// Record code for map of Objective-C class definition IDs to the - /// ObjC categories in a module that are attached to that class. - OBJC_CATEGORIES_MAP = 41, + SourceLocation getLocation() const { + return SourceLocation::getFromRawEncoding(Loc); + } - /// Record code for a file sorted array of DeclIDs in a module. - FILE_SORTED_DECLS = 42, + void setBitOffset(uint64_t Offset, const uint64_t DeclTypesBlockStartOffset) { + BitOffset.setBitOffset(Offset - DeclTypesBlockStartOffset); + } - /// Record code for an array of all of the (sub)modules that were - /// imported by the AST file. - IMPORTED_MODULES = 43, + uint64_t getBitOffset(const uint64_t DeclTypesBlockStartOffset) const { + return BitOffset.getBitOffset() + DeclTypesBlockStartOffset; + } +}; - // ID 44 used to be a table of merged canonical declarations. - // ID 45 used to be a list of declaration IDs of local redeclarations. +/// The number of predefined preprocessed entity IDs. +const unsigned int NUM_PREDEF_PP_ENTITY_IDS = 1; + +/// Describes the various kinds of blocks that occur within +/// an AST file. +enum BlockIDs { + /// The AST block, which acts as a container around the + /// full AST block. + AST_BLOCK_ID = llvm::bitc::FIRST_APPLICATION_BLOCKID, + + /// The block containing information about the source + /// manager. + SOURCE_MANAGER_BLOCK_ID, + + /// The block containing information about the + /// preprocessor. + PREPROCESSOR_BLOCK_ID, + + /// The block containing the definitions of all of the + /// types and decls used within the AST file. + DECLTYPES_BLOCK_ID, + + /// The block containing the detailed preprocessing record. + PREPROCESSOR_DETAIL_BLOCK_ID, + + /// The block containing the submodule structure. + SUBMODULE_BLOCK_ID, + + /// The block containing comments. + COMMENTS_BLOCK_ID, + + /// The control block, which contains all of the + /// information that needs to be validated prior to committing + /// to loading the AST file. + CONTROL_BLOCK_ID, + + /// The block of input files, which were used as inputs + /// to create this AST file. + /// + /// This block is part of the control block. + INPUT_FILES_BLOCK_ID, + + /// The block of configuration options, used to check that + /// a module is being used in a configuration compatible with the + /// configuration in which it was built. + /// + /// This block is part of the control block. + OPTIONS_BLOCK_ID, + + /// A block containing a module file extension. + EXTENSION_BLOCK_ID, + + /// A block with unhashed content. + /// + /// These records should not change the \a ASTFileSignature. See \a + /// UnhashedControlBlockRecordTypes for the list of records. + UNHASHED_CONTROL_BLOCK_ID, +}; - /// Record code for the array of Objective-C categories (including - /// extensions). - /// - /// This array can only be interpreted properly using the Objective-C - /// categories map. - OBJC_CATEGORIES = 46, +/// Record types that occur within the control block. +enum ControlRecordTypes { + /// AST file metadata, including the AST file version number + /// and information about the compiler used to build this AST file. + METADATA = 1, - /// Record code for the table of offsets of each macro ID. - /// - /// The offset table contains offsets into the blob stored in - /// the preprocessor block. Each offset points to the corresponding - /// macro definition. - MACRO_OFFSET = 47, + /// Record code for the list of other AST files imported by + /// this AST file. + IMPORTS, - /// A list of "interesting" identifiers. Only used in C++ (where we - /// don't normally do lookups into the serialized identifier table). These - /// are eagerly deserialized. - INTERESTING_IDENTIFIERS = 48, + /// Record code for the original file that was used to + /// generate the AST file, including both its file ID and its + /// name. + ORIGINAL_FILE, - /// Record code for undefined but used functions and variables that - /// need a definition in this TU. - UNDEFINED_BUT_USED = 49, + /// The directory that the PCH was originally created in. + ORIGINAL_PCH_DIR, - /// Record code for late parsed template functions. - LATE_PARSED_TEMPLATE = 50, + /// Record code for file ID of the file or buffer that was used to + /// generate the AST file. + ORIGINAL_FILE_ID, - /// Record code for \#pragma optimize options. - OPTIMIZE_PRAGMA_OPTIONS = 51, + /// Offsets into the input-files block where input files + /// reside. + INPUT_FILE_OFFSETS, - /// Record code for potentially unused local typedef names. - UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES = 52, + /// Record code for the module name. + MODULE_NAME, - // ID 53 used to be a table of constructor initializer records. + /// Record code for the module map file that was used to build this + /// AST file. + MODULE_MAP_FILE, - /// Delete expressions that will be analyzed later. - DELETE_EXPRS_TO_ANALYZE = 54, + /// Record code for the module build directory. + MODULE_DIRECTORY, +}; - /// Record code for \#pragma ms_struct options. - MSSTRUCT_PRAGMA_OPTIONS = 55, +/// Record types that occur within the options block inside +/// the control block. +enum OptionsRecordTypes { + /// Record code for the language options table. + /// + /// The record with this code contains the contents of the + /// LangOptions structure. We serialize the entire contents of + /// the structure, and let the reader decide which options are + /// actually important to check. + LANGUAGE_OPTIONS = 1, - /// Record code for \#pragma ms_struct options. - POINTERS_TO_MEMBERS_PRAGMA_OPTIONS = 56, + /// Record code for the target options table. + TARGET_OPTIONS, - /// Number of unmatched #pragma clang cuda_force_host_device begin - /// directives we've seen. - CUDA_PRAGMA_FORCE_HOST_DEVICE_DEPTH = 57, + /// Record code for the filesystem options table. + FILE_SYSTEM_OPTIONS, - /// Record code for types associated with OpenCL extensions. - OPENCL_EXTENSION_TYPES = 58, + /// Record code for the headers search options table. + HEADER_SEARCH_OPTIONS, - /// Record code for declarations associated with OpenCL extensions. - OPENCL_EXTENSION_DECLS = 59, + /// Record code for the preprocessor options table. + PREPROCESSOR_OPTIONS, +}; - MODULAR_CODEGEN_DECLS = 60, +/// Record codes for the unhashed control block. +enum UnhashedControlBlockRecordTypes { + /// Record code for the signature that identifiers this AST file. + SIGNATURE = 1, - /// Record code for \#pragma align/pack options. - ALIGN_PACK_PRAGMA_OPTIONS = 61, + /// Record code for the content hash of the AST block. + AST_BLOCK_HASH, - /// The stack of open #ifs/#ifdefs recorded in a preamble. - PP_CONDITIONAL_STACK = 62, + /// Record code for the diagnostic options table. + DIAGNOSTIC_OPTIONS, - /// A table of skipped ranges within the preprocessing record. - PPD_SKIPPED_RANGES = 63, + /// Record code for \#pragma diagnostic mappings. + DIAG_PRAGMA_MAPPINGS, +}; - /// Record code for the Decls to be checked for deferred diags. - DECLS_TO_CHECK_FOR_DEFERRED_DIAGS = 64, +/// Record code for extension blocks. +enum ExtensionBlockRecordTypes { + /// Metadata describing this particular extension. + EXTENSION_METADATA = 1, - /// Record code for \#pragma float_control options. - FLOAT_CONTROL_PRAGMA_OPTIONS = 65, - }; + /// The first record ID allocated to the extensions themselves. + FIRST_EXTENSION_RECORD_ID = 4 +}; - /// Record types used within a source manager block. - enum SourceManagerRecordTypes { - /// Describes a source location entry (SLocEntry) for a - /// file. - SM_SLOC_FILE_ENTRY = 1, +/// Record types that occur within the input-files block +/// inside the control block. +enum InputFileRecordTypes { + /// An input file. + INPUT_FILE = 1, - /// Describes a source location entry (SLocEntry) for a - /// buffer. - SM_SLOC_BUFFER_ENTRY = 2, + /// The input file content hash + INPUT_FILE_HASH +}; - /// Describes a blob that contains the data for a buffer - /// entry. This kind of record always directly follows a - /// SM_SLOC_BUFFER_ENTRY record or a SM_SLOC_FILE_ENTRY with an - /// overridden buffer. - SM_SLOC_BUFFER_BLOB = 3, +/// Record types that occur within the AST block itself. +enum ASTRecordTypes { + /// Record code for the offsets of each type. + /// + /// The TYPE_OFFSET constant describes the record that occurs + /// within the AST block. The record itself is an array of offsets that + /// point into the declarations and types block (identified by + /// DECLTYPES_BLOCK_ID). The index into the array is based on the ID + /// of a type. For a given type ID @c T, the lower three bits of + /// @c T are its qualifiers (const, volatile, restrict), as in + /// the QualType class. The upper bits, after being shifted and + /// subtracting NUM_PREDEF_TYPE_IDS, are used to index into the + /// TYPE_OFFSET block to determine the offset of that type's + /// corresponding record within the DECLTYPES_BLOCK_ID block. + TYPE_OFFSET = 1, + + /// Record code for the offsets of each decl. + /// + /// The DECL_OFFSET constant describes the record that occurs + /// within the block identified by DECL_OFFSETS_BLOCK_ID within + /// the AST block. The record itself is an array of offsets that + /// point into the declarations and types block (identified by + /// DECLTYPES_BLOCK_ID). The declaration ID is an index into this + /// record, after subtracting one to account for the use of + /// declaration ID 0 for a NULL declaration pointer. Index 0 is + /// reserved for the translation unit declaration. + DECL_OFFSET = 2, + + /// Record code for the table of offsets of each + /// identifier ID. + /// + /// The offset table contains offsets into the blob stored in + /// the IDENTIFIER_TABLE record. Each offset points to the + /// NULL-terminated string that corresponds to that identifier. + IDENTIFIER_OFFSET = 3, + + /// This is so that older clang versions, before the introduction + /// of the control block, can read and reject the newer PCH format. + /// *DON'T CHANGE THIS NUMBER*. + METADATA_OLD_FORMAT = 4, + + /// Record code for the identifier table. + /// + /// The identifier table is a simple blob that contains + /// NULL-terminated strings for all of the identifiers + /// referenced by the AST file. The IDENTIFIER_OFFSET table + /// contains the mapping from identifier IDs to the characters + /// in this blob. Note that the starting offsets of all of the + /// identifiers are odd, so that, when the identifier offset + /// table is loaded in, we can use the low bit to distinguish + /// between offsets (for unresolved identifier IDs) and + /// IdentifierInfo pointers (for already-resolved identifier + /// IDs). + IDENTIFIER_TABLE = 5, + + /// Record code for the array of eagerly deserialized decls. + /// + /// The AST file contains a list of all of the declarations that should be + /// eagerly deserialized present within the parsed headers, stored as an + /// array of declaration IDs. These declarations will be + /// reported to the AST consumer after the AST file has been + /// read, since their presence can affect the semantics of the + /// program (e.g., for code generation). + EAGERLY_DESERIALIZED_DECLS = 6, + + /// Record code for the set of non-builtin, special + /// types. + /// + /// This record contains the type IDs for the various type nodes + /// that are constructed during semantic analysis (e.g., + /// __builtin_va_list). The SPECIAL_TYPE_* constants provide + /// offsets into this record. + SPECIAL_TYPES = 7, + + /// Record code for the extra statistics we gather while + /// generating an AST file. + STATISTICS = 8, + + /// Record code for the array of tentative definitions. + TENTATIVE_DEFINITIONS = 9, + + // ID 10 used to be for a list of extern "C" declarations. + + /// Record code for the table of offsets into the + /// Objective-C method pool. + SELECTOR_OFFSETS = 11, + + /// Record code for the Objective-C method pool, + METHOD_POOL = 12, + + /// The value of the next __COUNTER__ to dispense. + /// [PP_COUNTER_VALUE, Val] + PP_COUNTER_VALUE = 13, + + /// Record code for the table of offsets into the block + /// of source-location information. + SOURCE_LOCATION_OFFSETS = 14, + + /// Record code for the set of source location entries + /// that need to be preloaded by the AST reader. + /// + /// This set contains the source location entry for the + /// predefines buffer and for any file entries that need to be + /// preloaded. + SOURCE_LOCATION_PRELOADS = 15, + + /// Record code for the set of ext_vector type names. + EXT_VECTOR_DECLS = 16, + + /// Record code for the array of unused file scoped decls. + UNUSED_FILESCOPED_DECLS = 17, + + /// Record code for the table of offsets to entries in the + /// preprocessing record. + PPD_ENTITIES_OFFSETS = 18, + + /// Record code for the array of VTable uses. + VTABLE_USES = 19, + + // ID 20 used to be for a list of dynamic classes. + + /// Record code for referenced selector pool. + REFERENCED_SELECTOR_POOL = 21, + + /// Record code for an update to the TU's lexically contained + /// declarations. + TU_UPDATE_LEXICAL = 22, + + // ID 23 used to be for a list of local redeclarations. + + /// Record code for declarations that Sema keeps references of. + SEMA_DECL_REFS = 24, + + /// Record code for weak undeclared identifiers. + WEAK_UNDECLARED_IDENTIFIERS = 25, - /// Describes a zlib-compressed blob that contains the data for - /// a buffer entry. - SM_SLOC_BUFFER_BLOB_COMPRESSED = 4, + /// Record code for pending implicit instantiations. + PENDING_IMPLICIT_INSTANTIATIONS = 26, + + // ID 27 used to be for a list of replacement decls. + + /// Record code for an update to a decl context's lookup table. + /// + /// In practice, this should only be used for the TU and namespaces. + UPDATE_VISIBLE = 28, + + /// Record for offsets of DECL_UPDATES records for declarations + /// that were modified after being deserialized and need updates. + DECL_UPDATE_OFFSETS = 29, + + // ID 30 used to be a decl update record. These are now in the DECLTYPES + // block. + + // ID 31 used to be a list of offsets to DECL_CXX_BASE_SPECIFIERS records. + + // ID 32 used to be the code for \#pragma diagnostic mappings. + + /// Record code for special CUDA declarations. + CUDA_SPECIAL_DECL_REFS = 33, + + /// Record code for header search information. + HEADER_SEARCH_TABLE = 34, + + /// Record code for floating point \#pragma options. + FP_PRAGMA_OPTIONS = 35, + + /// Record code for enabled OpenCL extensions. + OPENCL_EXTENSIONS = 36, + + /// The list of delegating constructor declarations. + DELEGATING_CTORS = 37, + + /// Record code for the set of known namespaces, which are used + /// for typo correction. + KNOWN_NAMESPACES = 38, + + /// Record code for the remapping information used to relate + /// loaded modules to the various offsets and IDs(e.g., source location + /// offests, declaration and type IDs) that are used in that module to + /// refer to other modules. + MODULE_OFFSET_MAP = 39, + + /// Record code for the source manager line table information, + /// which stores information about \#line directives. + SOURCE_MANAGER_LINE_TABLE = 40, + + /// Record code for map of Objective-C class definition IDs to the + /// ObjC categories in a module that are attached to that class. + OBJC_CATEGORIES_MAP = 41, + + /// Record code for a file sorted array of DeclIDs in a module. + FILE_SORTED_DECLS = 42, + + /// Record code for an array of all of the (sub)modules that were + /// imported by the AST file. + IMPORTED_MODULES = 43, + + // ID 44 used to be a table of merged canonical declarations. + // ID 45 used to be a list of declaration IDs of local redeclarations. + + /// Record code for the array of Objective-C categories (including + /// extensions). + /// + /// This array can only be interpreted properly using the Objective-C + /// categories map. + OBJC_CATEGORIES = 46, + + /// Record code for the table of offsets of each macro ID. + /// + /// The offset table contains offsets into the blob stored in + /// the preprocessor block. Each offset points to the corresponding + /// macro definition. + MACRO_OFFSET = 47, + + /// A list of "interesting" identifiers. Only used in C++ (where we + /// don't normally do lookups into the serialized identifier table). These + /// are eagerly deserialized. + INTERESTING_IDENTIFIERS = 48, + + /// Record code for undefined but used functions and variables that + /// need a definition in this TU. + UNDEFINED_BUT_USED = 49, + + /// Record code for late parsed template functions. + LATE_PARSED_TEMPLATE = 50, + + /// Record code for \#pragma optimize options. + OPTIMIZE_PRAGMA_OPTIONS = 51, + + /// Record code for potentially unused local typedef names. + UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES = 52, + + // ID 53 used to be a table of constructor initializer records. + + /// Delete expressions that will be analyzed later. + DELETE_EXPRS_TO_ANALYZE = 54, + + /// Record code for \#pragma ms_struct options. + MSSTRUCT_PRAGMA_OPTIONS = 55, + + /// Record code for \#pragma ms_struct options. + POINTERS_TO_MEMBERS_PRAGMA_OPTIONS = 56, + + /// Number of unmatched #pragma clang cuda_force_host_device begin + /// directives we've seen. + CUDA_PRAGMA_FORCE_HOST_DEVICE_DEPTH = 57, + + /// Record code for types associated with OpenCL extensions. + OPENCL_EXTENSION_TYPES = 58, + + /// Record code for declarations associated with OpenCL extensions. + OPENCL_EXTENSION_DECLS = 59, + + MODULAR_CODEGEN_DECLS = 60, + + /// Record code for \#pragma align/pack options. + ALIGN_PACK_PRAGMA_OPTIONS = 61, + + /// The stack of open #ifs/#ifdefs recorded in a preamble. + PP_CONDITIONAL_STACK = 62, + + /// A table of skipped ranges within the preprocessing record. + PPD_SKIPPED_RANGES = 63, + + /// Record code for the Decls to be checked for deferred diags. + DECLS_TO_CHECK_FOR_DEFERRED_DIAGS = 64, + + /// Record code for \#pragma float_control options. + FLOAT_CONTROL_PRAGMA_OPTIONS = 65, +}; - /// Describes a source location entry (SLocEntry) for a - /// macro expansion. - SM_SLOC_EXPANSION_ENTRY = 5 - }; +/// Record types used within a source manager block. +enum SourceManagerRecordTypes { + /// Describes a source location entry (SLocEntry) for a + /// file. + SM_SLOC_FILE_ENTRY = 1, + + /// Describes a source location entry (SLocEntry) for a + /// buffer. + SM_SLOC_BUFFER_ENTRY = 2, + + /// Describes a blob that contains the data for a buffer + /// entry. This kind of record always directly follows a + /// SM_SLOC_BUFFER_ENTRY record or a SM_SLOC_FILE_ENTRY with an + /// overridden buffer. + SM_SLOC_BUFFER_BLOB = 3, + + /// Describes a zlib-compressed blob that contains the data for + /// a buffer entry. + SM_SLOC_BUFFER_BLOB_COMPRESSED = 4, + + /// Describes a source location entry (SLocEntry) for a + /// macro expansion. + SM_SLOC_EXPANSION_ENTRY = 5 +}; - /// Record types used within a preprocessor block. - enum PreprocessorRecordTypes { - // The macros in the PP section are a PP_MACRO_* instance followed by a - // list of PP_TOKEN instances for each token in the definition. +/// Record types used within a preprocessor block. +enum PreprocessorRecordTypes { + // The macros in the PP section are a PP_MACRO_* instance followed by a + // list of PP_TOKEN instances for each token in the definition. - /// An object-like macro definition. - /// [PP_MACRO_OBJECT_LIKE, IdentInfoID, SLoc, IsUsed] - PP_MACRO_OBJECT_LIKE = 1, + /// An object-like macro definition. + /// [PP_MACRO_OBJECT_LIKE, IdentInfoID, SLoc, IsUsed] + PP_MACRO_OBJECT_LIKE = 1, - /// A function-like macro definition. - /// [PP_MACRO_FUNCTION_LIKE, \<ObjectLikeStuff>, IsC99Varargs, - /// IsGNUVarars, NumArgs, ArgIdentInfoID* ] - PP_MACRO_FUNCTION_LIKE = 2, + /// A function-like macro definition. + /// [PP_MACRO_FUNCTION_LIKE, \<ObjectLikeStuff>, IsC99Varargs, + /// IsGNUVarars, NumArgs, ArgIdentInfoID* ] + PP_MACRO_FUNCTION_LIKE = 2, - /// Describes one token. - /// [PP_TOKEN, SLoc, Length, IdentInfoID, Kind, Flags] - PP_TOKEN = 3, + /// Describes one token. + /// [PP_TOKEN, SLoc, Length, IdentInfoID, Kind, Flags] + PP_TOKEN = 3, - /// The macro directives history for a particular identifier. - PP_MACRO_DIRECTIVE_HISTORY = 4, + /// The macro directives history for a particular identifier. + PP_MACRO_DIRECTIVE_HISTORY = 4, - /// A macro directive exported by a module. - /// [PP_MODULE_MACRO, SubmoduleID, MacroID, (Overridden SubmoduleID)*] - PP_MODULE_MACRO = 5, - }; + /// A macro directive exported by a module. + /// [PP_MODULE_MACRO, SubmoduleID, MacroID, (Overridden SubmoduleID)*] + PP_MODULE_MACRO = 5, +}; - /// Record types used within a preprocessor detail block. - enum PreprocessorDetailRecordTypes { - /// Describes a macro expansion within the preprocessing record. - PPD_MACRO_EXPANSION = 0, +/// Record types used within a preprocessor detail block. +enum PreprocessorDetailRecordTypes { + /// Describes a macro expansion within the preprocessing record. + PPD_MACRO_EXPANSION = 0, - /// Describes a macro definition within the preprocessing record. - PPD_MACRO_DEFINITION = 1, + /// Describes a macro definition within the preprocessing record. + PPD_MACRO_DEFINITION = 1, - /// Describes an inclusion directive within the preprocessing - /// record. - PPD_INCLUSION_DIRECTIVE = 2 - }; + /// Describes an inclusion directive within the preprocessing + /// record. + PPD_INCLUSION_DIRECTIVE = 2 +}; - /// Record types used within a submodule description block. - enum SubmoduleRecordTypes { - /// Metadata for submodules as a whole. - SUBMODULE_METADATA = 0, +/// Record types used within a submodule description block. +enum SubmoduleRecordTypes { + /// Metadata for submodules as a whole. + SUBMODULE_METADATA = 0, - /// Defines the major attributes of a submodule, including its - /// name and parent. - SUBMODULE_DEFINITION = 1, + /// Defines the major attributes of a submodule, including its + /// name and parent. + SUBMODULE_DEFINITION = 1, - /// Specifies the umbrella header used to create this module, - /// if any. - SUBMODULE_UMBRELLA_HEADER = 2, + /// Specifies the umbrella header used to create this module, + /// if any. + SUBMODULE_UMBRELLA_HEADER = 2, - /// Specifies a header that falls into this (sub)module. - SUBMODULE_HEADER = 3, + /// Specifies a header that falls into this (sub)module. + SUBMODULE_HEADER = 3, - /// Specifies a top-level header that falls into this (sub)module. - SUBMODULE_TOPHEADER = 4, + /// Specifies a top-level header that falls into this (sub)module. + SUBMODULE_TOPHEADER = 4, - /// Specifies an umbrella directory. - SUBMODULE_UMBRELLA_DIR = 5, + /// Specifies an umbrella directory. + SUBMODULE_UMBRELLA_DIR = 5, - /// Specifies the submodules that are imported by this - /// submodule. - SUBMODULE_IMPORTS = 6, + /// Specifies the submodules that are imported by this + /// submodule. + SUBMODULE_IMPORTS = 6, - /// Specifies the submodules that are re-exported from this - /// submodule. - SUBMODULE_EXPORTS = 7, + /// Specifies the submodules that are re-exported from this + /// submodule. + SUBMODULE_EXPORTS = 7, - /// Specifies a required feature. - SUBMODULE_REQUIRES = 8, + /// Specifies a required feature. + SUBMODULE_REQUIRES = 8, - /// Specifies a header that has been explicitly excluded - /// from this submodule. - SUBMODULE_EXCLUDED_HEADER = 9, + /// Specifies a header that has been explicitly excluded + /// from this submodule. + SUBMODULE_EXCLUDED_HEADER = 9, - /// Specifies a library or framework to link against. - SUBMODULE_LINK_LIBRARY = 10, + /// Specifies a library or framework to link against. + SUBMODULE_LINK_LIBRARY = 10, - /// Specifies a configuration macro for this module. - SUBMODULE_CONFIG_MACRO = 11, + /// Specifies a configuration macro for this module. + SUBMODULE_CONFIG_MACRO = 11, - /// Specifies a conflict with another module. - SUBMODULE_CONFLICT = 12, + /// Specifies a conflict with another module. + SUBMODULE_CONFLICT = 12, - /// Specifies a header that is private to this submodule. - SUBMODULE_PRIVATE_HEADER = 13, + /// Specifies a header that is private to this submodule. + SUBMODULE_PRIVATE_HEADER = 13, - /// Specifies a header that is part of the module but must be - /// textually included. - SUBMODULE_TEXTUAL_HEADER = 14, + /// Specifies a header that is part of the module but must be + /// textually included. + SUBMODULE_TEXTUAL_HEADER = 14, - /// Specifies a header that is private to this submodule but - /// must be textually included. - SUBMODULE_PRIVATE_TEXTUAL_HEADER = 15, + /// Specifies a header that is private to this submodule but + /// must be textually included. + SUBMODULE_PRIVATE_TEXTUAL_HEADER = 15, - /// Specifies some declarations with initializers that must be - /// emitted to initialize the module. - SUBMODULE_INITIALIZERS = 16, + /// Specifies some declarations with initializers that must be + /// emitted to initialize the module. + SUBMODULE_INITIALIZERS = 16, - /// Specifies the name of the module that will eventually - /// re-export the entities in this module. - SUBMODULE_EXPORT_AS = 17, - }; + /// Specifies the name of the module that will eventually + /// re-export the entities in this module. + SUBMODULE_EXPORT_AS = 17, +}; - /// Record types used within a comments block. - enum CommentRecordTypes { - COMMENTS_RAW_COMMENT = 0 - }; +/// Record types used within a comments block. +enum CommentRecordTypes { COMMENTS_RAW_COMMENT = 0 }; - /// \defgroup ASTAST AST file AST constants - /// - /// The constants in this group describe various components of the - /// abstract syntax tree within an AST file. - /// - /// @{ +/// \defgroup ASTAST AST file AST constants +/// +/// The constants in this group describe various components of the +/// abstract syntax tree within an AST file. +/// +/// @{ - /// Predefined type IDs. - /// - /// These type IDs correspond to predefined types in the AST - /// context, such as built-in types (int) and special place-holder - /// types (the \<overload> and \<dependent> type markers). Such - /// types are never actually serialized, since they will be built - /// by the AST context when it is created. - enum PredefinedTypeIDs { - /// The NULL type. - PREDEF_TYPE_NULL_ID = 0, +/// Predefined type IDs. +/// +/// These type IDs correspond to predefined types in the AST +/// context, such as built-in types (int) and special place-holder +/// types (the \<overload> and \<dependent> type markers). Such +/// types are never actually serialized, since they will be built +/// by the AST context when it is created. +enum PredefinedTypeIDs { + /// The NULL type. + PREDEF_TYPE_NULL_ID = 0, - /// The void type. - PREDEF_TYPE_VOID_ID = 1, + /// The void type. + PREDEF_TYPE_VOID_ID = 1, - /// The 'bool' or '_Bool' type. - PREDEF_TYPE_BOOL_ID = 2, + /// The 'bool' or '_Bool' type. + PREDEF_TYPE_BOOL_ID = 2, - /// The 'char' type, when it is unsigned. - PREDEF_TYPE_CHAR_U_ID = 3, + /// The 'char' type, when it is unsigned. + PREDEF_TYPE_CHAR_U_ID = 3, - /// The 'unsigned char' type. - PREDEF_TYPE_UCHAR_ID = 4, + /// The 'unsigned char' type. + PREDEF_TYPE_UCHAR_ID = 4, - /// The 'unsigned short' type. - PREDEF_TYPE_USHORT_ID = 5, + /// The 'unsigned short' type. + PREDEF_TYPE_USHORT_ID = 5, - /// The 'unsigned int' type. - PREDEF_TYPE_UINT_ID = 6, + /// The 'unsigned int' type. + PREDEF_TYPE_UINT_ID = 6, - /// The 'unsigned long' type. - PREDEF_TYPE_ULONG_ID = 7, + /// The 'unsigned long' type. + PREDEF_TYPE_ULONG_ID = 7, - /// The 'unsigned long long' type. - PREDEF_TYPE_ULONGLONG_ID = 8, + /// The 'unsigned long long' type. + PREDEF_TYPE_ULONGLONG_ID = 8, - /// The 'char' type, when it is signed. - PREDEF_TYPE_CHAR_S_ID = 9, + /// The 'char' type, when it is signed. + PREDEF_TYPE_CHAR_S_ID = 9, - /// The 'signed char' type. - PREDEF_TYPE_SCHAR_ID = 10, + /// The 'signed char' type. + PREDEF_TYPE_SCHAR_ID = 10, - /// The C++ 'wchar_t' type. - PREDEF_TYPE_WCHAR_ID = 11, + /// The C++ 'wchar_t' type. + PREDEF_TYPE_WCHAR_ID = 11, - /// The (signed) 'short' type. - PREDEF_TYPE_SHORT_ID = 12, + /// The (signed) 'short' type. + PREDEF_TYPE_SHORT_ID = 12, - /// The (signed) 'int' type. - PREDEF_TYPE_INT_ID = 13, + /// The (signed) 'int' type. + PREDEF_TYPE_INT_ID = 13, - /// The (signed) 'long' type. - PREDEF_TYPE_LONG_ID = 14, + /// The (signed) 'long' type. + PREDEF_TYPE_LONG_ID = 14, - /// The (signed) 'long long' type. - PREDEF_TYPE_LONGLONG_ID = 15, + /// The (signed) 'long long' type. + PREDEF_TYPE_LONGLONG_ID = 15, - /// The 'float' type. - PREDEF_TYPE_FLOAT_ID = 16, + /// The 'float' type. + PREDEF_TYPE_FLOAT_ID = 16, - /// The 'double' type. - PREDEF_TYPE_DOUBLE_ID = 17, + /// The 'double' type. + PREDEF_TYPE_DOUBLE_ID = 17, - /// The 'long double' type. - PREDEF_TYPE_LONGDOUBLE_ID = 18, + /// The 'long double' type. + PREDEF_TYPE_LONGDOUBLE_ID = 18, - /// The placeholder type for overloaded function sets. - PREDEF_TYPE_OVERLOAD_ID = 19, + /// The placeholder type for overloaded function sets. + PREDEF_TYPE_OVERLOAD_ID = 19, - /// The placeholder type for dependent types. - PREDEF_TYPE_DEPENDENT_ID = 20, + /// The placeholder type for dependent types. + PREDEF_TYPE_DEPENDENT_ID = 20, - /// The '__uint128_t' type. - PREDEF_TYPE_UINT128_ID = 21, + /// The '__uint128_t' type. + PREDEF_TYPE_UINT128_ID = 21, - /// The '__int128_t' type. - PREDEF_TYPE_INT128_ID = 22, + /// The '__int128_t' type. + PREDEF_TYPE_INT128_ID = 22, - /// The type of 'nullptr'. - PREDEF_TYPE_NULLPTR_ID = 23, + /// The type of 'nullptr'. + PREDEF_TYPE_NULLPTR_ID = 23, - /// The C++ 'char16_t' type. - PREDEF_TYPE_CHAR16_ID = 24, + /// The C++ 'char16_t' type. + PREDEF_TYPE_CHAR16_ID = 24, - /// The C++ 'char32_t' type. - PREDEF_TYPE_CHAR32_ID = 25, + /// The C++ 'char32_t' type. + PREDEF_TYPE_CHAR32_ID = 25, - /// The ObjC 'id' type. - PREDEF_TYPE_OBJC_ID = 26, + /// The ObjC 'id' type. + PREDEF_TYPE_OBJC_ID = 26, - /// The ObjC 'Class' type. - PREDEF_TYPE_OBJC_CLASS = 27, + /// The ObjC 'Class' type. + PREDEF_TYPE_OBJC_CLASS = 27, - /// The ObjC 'SEL' type. - PREDEF_TYPE_OBJC_SEL = 28, + /// The ObjC 'SEL' type. + PREDEF_TYPE_OBJC_SEL = 28, - /// The 'unknown any' placeholder type. - PREDEF_TYPE_UNKNOWN_ANY = 29, + /// The 'unknown any' placeholder type. + PREDEF_TYPE_UNKNOWN_ANY = 29, - /// The placeholder type for bound member functions. - PREDEF_TYPE_BOUND_MEMBER = 30, + /// The placeholder type for bound member functions. + PREDEF_TYPE_BOUND_MEMBER = 30, - /// The "auto" deduction type. - PREDEF_TYPE_AUTO_DEDUCT = 31, + /// The "auto" deduction type. + PREDEF_TYPE_AUTO_DEDUCT = 31, - /// The "auto &&" deduction type. - PREDEF_TYPE_AUTO_RREF_DEDUCT = 32, + /// The "auto &&" deduction type. + PREDEF_TYPE_AUTO_RREF_DEDUCT = 32, - /// The OpenCL 'half' / ARM NEON __fp16 type. - PREDEF_TYPE_HALF_ID = 33, + /// The OpenCL 'half' / ARM NEON __fp16 type. + PREDEF_TYPE_HALF_ID = 33, - /// ARC's unbridged-cast placeholder type. - PREDEF_TYPE_ARC_UNBRIDGED_CAST = 34, + /// ARC's unbridged-cast placeholder type. + PREDEF_TYPE_ARC_UNBRIDGED_CAST = 34, - /// The pseudo-object placeholder type. - PREDEF_TYPE_PSEUDO_OBJECT = 35, + /// The pseudo-object placeholder type. + PREDEF_TYPE_PSEUDO_OBJECT = 35, - /// The placeholder type for builtin functions. - PREDEF_TYPE_BUILTIN_FN = 36, + /// The placeholder type for builtin functions. + PREDEF_TYPE_BUILTIN_FN = 36, - /// OpenCL event type. - PREDEF_TYPE_EVENT_ID = 37, + /// OpenCL event type. + PREDEF_TYPE_EVENT_ID = 37, - /// OpenCL clk event type. - PREDEF_TYPE_CLK_EVENT_ID = 38, + /// OpenCL clk event type. + PREDEF_TYPE_CLK_EVENT_ID = 38, - /// OpenCL sampler type. - PREDEF_TYPE_SAMPLER_ID = 39, + /// OpenCL sampler type. + PREDEF_TYPE_SAMPLER_ID = 39, - /// OpenCL queue type. - PREDEF_TYPE_QUEUE_ID = 40, + /// OpenCL queue type. + PREDEF_TYPE_QUEUE_ID = 40, - /// OpenCL reserve_id type. - PREDEF_TYPE_RESERVE_ID_ID = 41, + /// OpenCL reserve_id type. + PREDEF_TYPE_RESERVE_ID_ID = 41, - /// The placeholder type for OpenMP array section. - PREDEF_TYPE_OMP_ARRAY_SECTION = 42, + /// The placeholder type for OpenMP array section. + PREDEF_TYPE_OMP_ARRAY_SECTION = 42, - /// The '__float128' type - PREDEF_TYPE_FLOAT128_ID = 43, + /// The '__float128' type + PREDEF_TYPE_FLOAT128_ID = 43, - /// The '_Float16' type - PREDEF_TYPE_FLOAT16_ID = 44, + /// The '_Float16' type + PREDEF_TYPE_FLOAT16_ID = 44, - /// The C++ 'char8_t' type. - PREDEF_TYPE_CHAR8_ID = 45, + /// The C++ 'char8_t' type. + PREDEF_TYPE_CHAR8_ID = 45, - /// \brief The 'short _Accum' type - PREDEF_TYPE_SHORT_ACCUM_ID = 46, + /// \brief The 'short _Accum' type + PREDEF_TYPE_SHORT_ACCUM_ID = 46, - /// \brief The '_Accum' type - PREDEF_TYPE_ACCUM_ID = 47, + /// \brief The '_Accum' type + PREDEF_TYPE_ACCUM_ID = 47, - /// \brief The 'long _Accum' type - PREDEF_TYPE_LONG_ACCUM_ID = 48, + /// \brief The 'long _Accum' type + PREDEF_TYPE_LONG_ACCUM_ID = 48, - /// \brief The 'unsigned short _Accum' type - PREDEF_TYPE_USHORT_ACCUM_ID = 49, + /// \brief The 'unsigned short _Accum' type + PREDEF_TYPE_USHORT_ACCUM_ID = 49, - /// \brief The 'unsigned _Accum' type - PREDEF_TYPE_UACCUM_ID = 50, + /// \brief The 'unsigned _Accum' type + PREDEF_TYPE_UACCUM_ID = 50, - /// \brief The 'unsigned long _Accum' type - PREDEF_TYPE_ULONG_ACCUM_ID = 51, + /// \brief The 'unsigned long _Accum' type + PREDEF_TYPE_ULONG_ACCUM_ID = 51, - /// \brief The 'short _Fract' type - PREDEF_TYPE_SHORT_FRACT_ID = 52, + /// \brief The 'short _Fract' type + PREDEF_TYPE_SHORT_FRACT_ID = 52, - /// \brief The '_Fract' type - PREDEF_TYPE_FRACT_ID = 53, + /// \brief The '_Fract' type + PREDEF_TYPE_FRACT_ID = 53, - /// \brief The 'long _Fract' type - PREDEF_TYPE_LONG_FRACT_ID = 54, + /// \brief The 'long _Fract' type + PREDEF_TYPE_LONG_FRACT_ID = 54, - /// \brief The 'unsigned short _Fract' type - PREDEF_TYPE_USHORT_FRACT_ID = 55, + /// \brief The 'unsigned short _Fract' type + PREDEF_TYPE_USHORT_FRACT_ID = 55, - /// \brief The 'unsigned _Fract' type - PREDEF_TYPE_UFRACT_ID = 56, + /// \brief The 'unsigned _Fract' type + PREDEF_TYPE_UFRACT_ID = 56, - /// \brief The 'unsigned long _Fract' type - PREDEF_TYPE_ULONG_FRACT_ID = 57, + /// \brief The 'unsigned long _Fract' type + PREDEF_TYPE_ULONG_FRACT_ID = 57, - /// \brief The '_Sat short _Accum' type - PREDEF_TYPE_SAT_SHORT_ACCUM_ID = 58, + /// \brief The '_Sat short _Accum' type + PREDEF_TYPE_SAT_SHORT_ACCUM_ID = 58, - /// \brief The '_Sat _Accum' type - PREDEF_TYPE_SAT_ACCUM_ID = 59, + /// \brief The '_Sat _Accum' type + PREDEF_TYPE_SAT_ACCUM_ID = 59, - /// \brief The '_Sat long _Accum' type - PREDEF_TYPE_SAT_LONG_ACCUM_ID = 60, + /// \brief The '_Sat long _Accum' type + PREDEF_TYPE_SAT_LONG_ACCUM_ID = 60, - /// \brief The '_Sat unsigned short _Accum' type - PREDEF_TYPE_SAT_USHORT_ACCUM_ID = 61, + /// \brief The '_Sat unsigned short _Accum' type + PREDEF_TYPE_SAT_USHORT_ACCUM_ID = 61, - /// \brief The '_Sat unsigned _Accum' type - PREDEF_TYPE_SAT_UACCUM_ID = 62, + /// \brief The '_Sat unsigned _Accum' type + PREDEF_TYPE_SAT_UACCUM_ID = 62, - /// \brief The '_Sat unsigned long _Accum' type - PREDEF_TYPE_SAT_ULONG_ACCUM_ID = 63, + /// \brief The '_Sat unsigned long _Accum' type + PREDEF_TYPE_SAT_ULONG_ACCUM_ID = 63, - /// \brief The '_Sat short _Fract' type - PREDEF_TYPE_SAT_SHORT_FRACT_ID = 64, + /// \brief The '_Sat short _Fract' type + PREDEF_TYPE_SAT_SHORT_FRACT_ID = 64, - /// \brief The '_Sat _Fract' type - PREDEF_TYPE_SAT_FRACT_ID = 65, + /// \brief The '_Sat _Fract' type + PREDEF_TYPE_SAT_FRACT_ID = 65, - /// \brief The '_Sat long _Fract' type - PREDEF_TYPE_SAT_LONG_FRACT_ID = 66, + /// \brief The '_Sat long _Fract' type + PREDEF_TYPE_SAT_LONG_FRACT_ID = 66, - /// \brief The '_Sat unsigned short _Fract' type - PREDEF_TYPE_SAT_USHORT_FRACT_ID = 67, + /// \brief The '_Sat unsigned short _Fract' type + PREDEF_TYPE_SAT_USHORT_FRACT_ID = 67, - /// \brief The '_Sat unsigned _Fract' type - PREDEF_TYPE_SAT_UFRACT_ID = 68, + /// \brief The '_Sat unsigned _Fract' type + PREDEF_TYPE_SAT_UFRACT_ID = 68, - /// \brief The '_Sat unsigned long _Fract' type - PREDEF_TYPE_SAT_ULONG_FRACT_ID = 69, + /// \brief The '_Sat unsigned long _Fract' type + PREDEF_TYPE_SAT_ULONG_FRACT_ID = 69, - /// The placeholder type for OpenMP array shaping operation. - PREDEF_TYPE_OMP_ARRAY_SHAPING = 70, + /// The placeholder type for OpenMP array shaping operation. + PREDEF_TYPE_OMP_ARRAY_SHAPING = 70, - /// The placeholder type for OpenMP iterator expression. - PREDEF_TYPE_OMP_ITERATOR = 71, + /// The placeholder type for OpenMP iterator expression. + PREDEF_TYPE_OMP_ITERATOR = 71, - /// A placeholder type for incomplete matrix index operations. - PREDEF_TYPE_INCOMPLETE_MATRIX_IDX = 72, + /// A placeholder type for incomplete matrix index operations. + PREDEF_TYPE_INCOMPLETE_MATRIX_IDX = 72, - /// \brief The '__bf16' type - PREDEF_TYPE_BFLOAT16_ID = 73, + /// \brief The '__bf16' type + PREDEF_TYPE_BFLOAT16_ID = 73, - /// OpenCL image types with auto numeration -#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ - PREDEF_TYPE_##Id##_ID, +/// OpenCL image types with auto numeration +#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ + PREDEF_TYPE_##Id##_ID, #include "clang/Basic/OpenCLImageTypes.def" - /// \brief OpenCL extension types with auto numeration -#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ - PREDEF_TYPE_##Id##_ID, +/// \brief OpenCL extension types with auto numeration +#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) PREDEF_TYPE_##Id##_ID, #include "clang/Basic/OpenCLExtensionTypes.def" - // \brief SVE types with auto numeration +// \brief SVE types with auto numeration #define SVE_TYPE(Name, Id, SingletonId) PREDEF_TYPE_##Id##_ID, #include "clang/Basic/AArch64SVEACLETypes.def" - // \brief PowerPC MMA types with auto numeration +// \brief PowerPC MMA types with auto numeration #define PPC_VECTOR_TYPE(Name, Id, Size) PREDEF_TYPE_##Id##_ID, #include "clang/Basic/PPCTypes.def" - }; - - /// The number of predefined type IDs that are reserved for - /// the PREDEF_TYPE_* constants. - /// - /// Type IDs for non-predefined types will start at - /// NUM_PREDEF_TYPE_IDs. - const unsigned NUM_PREDEF_TYPE_IDS = 200; - - /// Record codes for each kind of type. - /// - /// These constants describe the type records that can occur within a - /// block identified by DECLTYPES_BLOCK_ID in the AST file. Each - /// constant describes a record for a specific type class in the - /// AST. Note that DeclCode values share this code space. - enum TypeCode { -#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \ - TYPE_##CODE_ID = CODE_VALUE, +// \brief RISC-V V types with auto numeration +#define RVV_TYPE(Name, Id, SingletonId) PREDEF_TYPE_##Id##_ID, +#include "clang/Basic/RISCVVTypes.def" +}; + +/// The number of predefined type IDs that are reserved for +/// the PREDEF_TYPE_* constants. +/// +/// Type IDs for non-predefined types will start at +/// NUM_PREDEF_TYPE_IDs. +const unsigned NUM_PREDEF_TYPE_IDS = 300; + +/// Record codes for each kind of type. +/// +/// These constants describe the type records that can occur within a +/// block identified by DECLTYPES_BLOCK_ID in the AST file. Each +/// constant describes a record for a specific type class in the +/// AST. Note that DeclCode values share this code space. +enum TypeCode { +#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \ + TYPE_##CODE_ID = CODE_VALUE, #include "clang/Serialization/TypeBitCodes.def" - /// An ExtQualType record. - TYPE_EXT_QUAL = 1 - }; + /// An ExtQualType record. + TYPE_EXT_QUAL = 1 +}; + +/// The type IDs for special types constructed by semantic +/// analysis. +/// +/// The constants in this enumeration are indices into the +/// SPECIAL_TYPES record. +enum SpecialTypeIDs { + /// CFConstantString type + SPECIAL_TYPE_CF_CONSTANT_STRING = 0, + + /// C FILE typedef type + SPECIAL_TYPE_FILE = 1, + + /// C jmp_buf typedef type + SPECIAL_TYPE_JMP_BUF = 2, + + /// C sigjmp_buf typedef type + SPECIAL_TYPE_SIGJMP_BUF = 3, + + /// Objective-C "id" redefinition type + SPECIAL_TYPE_OBJC_ID_REDEFINITION = 4, + + /// Objective-C "Class" redefinition type + SPECIAL_TYPE_OBJC_CLASS_REDEFINITION = 5, - /// The type IDs for special types constructed by semantic - /// analysis. - /// - /// The constants in this enumeration are indices into the - /// SPECIAL_TYPES record. - enum SpecialTypeIDs { - /// CFConstantString type - SPECIAL_TYPE_CF_CONSTANT_STRING = 0, + /// Objective-C "SEL" redefinition type + SPECIAL_TYPE_OBJC_SEL_REDEFINITION = 6, - /// C FILE typedef type - SPECIAL_TYPE_FILE = 1, + /// C ucontext_t typedef type + SPECIAL_TYPE_UCONTEXT_T = 7 +}; + +/// The number of special type IDs. +const unsigned NumSpecialTypeIDs = 8; + +/// Predefined declaration IDs. +/// +/// These declaration IDs correspond to predefined declarations in the AST +/// context, such as the NULL declaration ID. Such declarations are never +/// actually serialized, since they will be built by the AST context when +/// it is created. +enum PredefinedDeclIDs { + /// The NULL declaration. + PREDEF_DECL_NULL_ID = 0, + + /// The translation unit. + PREDEF_DECL_TRANSLATION_UNIT_ID = 1, - /// C jmp_buf typedef type - SPECIAL_TYPE_JMP_BUF = 2, + /// The Objective-C 'id' type. + PREDEF_DECL_OBJC_ID_ID = 2, - /// C sigjmp_buf typedef type - SPECIAL_TYPE_SIGJMP_BUF = 3, + /// The Objective-C 'SEL' type. + PREDEF_DECL_OBJC_SEL_ID = 3, - /// Objective-C "id" redefinition type - SPECIAL_TYPE_OBJC_ID_REDEFINITION = 4, + /// The Objective-C 'Class' type. + PREDEF_DECL_OBJC_CLASS_ID = 4, - /// Objective-C "Class" redefinition type - SPECIAL_TYPE_OBJC_CLASS_REDEFINITION = 5, + /// The Objective-C 'Protocol' type. + PREDEF_DECL_OBJC_PROTOCOL_ID = 5, - /// Objective-C "SEL" redefinition type - SPECIAL_TYPE_OBJC_SEL_REDEFINITION = 6, + /// The signed 128-bit integer type. + PREDEF_DECL_INT_128_ID = 6, - /// C ucontext_t typedef type - SPECIAL_TYPE_UCONTEXT_T = 7 - }; + /// The unsigned 128-bit integer type. + PREDEF_DECL_UNSIGNED_INT_128_ID = 7, - /// The number of special type IDs. - const unsigned NumSpecialTypeIDs = 8; + /// The internal 'instancetype' typedef. + PREDEF_DECL_OBJC_INSTANCETYPE_ID = 8, - /// Predefined declaration IDs. - /// - /// These declaration IDs correspond to predefined declarations in the AST - /// context, such as the NULL declaration ID. Such declarations are never - /// actually serialized, since they will be built by the AST context when - /// it is created. - enum PredefinedDeclIDs { - /// The NULL declaration. - PREDEF_DECL_NULL_ID = 0, + /// The internal '__builtin_va_list' typedef. + PREDEF_DECL_BUILTIN_VA_LIST_ID = 9, - /// The translation unit. - PREDEF_DECL_TRANSLATION_UNIT_ID = 1, + /// The internal '__va_list_tag' struct, if any. + PREDEF_DECL_VA_LIST_TAG = 10, - /// The Objective-C 'id' type. - PREDEF_DECL_OBJC_ID_ID = 2, + /// The internal '__builtin_ms_va_list' typedef. + PREDEF_DECL_BUILTIN_MS_VA_LIST_ID = 11, - /// The Objective-C 'SEL' type. - PREDEF_DECL_OBJC_SEL_ID = 3, + /// The predeclared '_GUID' struct. + PREDEF_DECL_BUILTIN_MS_GUID_ID = 12, - /// The Objective-C 'Class' type. - PREDEF_DECL_OBJC_CLASS_ID = 4, + /// The extern "C" context. + PREDEF_DECL_EXTERN_C_CONTEXT_ID = 13, + + /// The internal '__make_integer_seq' template. + PREDEF_DECL_MAKE_INTEGER_SEQ_ID = 14, + + /// The internal '__NSConstantString' typedef. + PREDEF_DECL_CF_CONSTANT_STRING_ID = 15, + + /// The internal '__NSConstantString' tag type. + PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID = 16, + + /// The internal '__type_pack_element' template. + PREDEF_DECL_TYPE_PACK_ELEMENT_ID = 17, +}; - /// The Objective-C 'Protocol' type. - PREDEF_DECL_OBJC_PROTOCOL_ID = 5, +/// The number of declaration IDs that are predefined. +/// +/// For more information about predefined declarations, see the +/// \c PredefinedDeclIDs type and the PREDEF_DECL_*_ID constants. +const unsigned int NUM_PREDEF_DECL_IDS = 18; - /// The signed 128-bit integer type. - PREDEF_DECL_INT_128_ID = 6, +/// Record of updates for a declaration that was modified after +/// being deserialized. This can occur within DECLTYPES_BLOCK_ID. +const unsigned int DECL_UPDATES = 49; - /// The unsigned 128-bit integer type. - PREDEF_DECL_UNSIGNED_INT_128_ID = 7, +/// Record code for a list of local redeclarations of a declaration. +/// This can occur within DECLTYPES_BLOCK_ID. +const unsigned int LOCAL_REDECLARATIONS = 50; - /// The internal 'instancetype' typedef. - PREDEF_DECL_OBJC_INSTANCETYPE_ID = 8, +/// Record codes for each kind of declaration. +/// +/// These constants describe the declaration records that can occur within +/// a declarations block (identified by DECLTYPES_BLOCK_ID). Each +/// constant describes a record for a specific declaration class +/// in the AST. Note that TypeCode values share this code space. +enum DeclCode { + /// A TypedefDecl record. + DECL_TYPEDEF = 51, + /// A TypeAliasDecl record. - /// The internal '__builtin_va_list' typedef. - PREDEF_DECL_BUILTIN_VA_LIST_ID = 9, + DECL_TYPEALIAS, - /// The internal '__va_list_tag' struct, if any. - PREDEF_DECL_VA_LIST_TAG = 10, + /// An EnumDecl record. + DECL_ENUM, - /// The internal '__builtin_ms_va_list' typedef. - PREDEF_DECL_BUILTIN_MS_VA_LIST_ID = 11, + /// A RecordDecl record. + DECL_RECORD, - /// The predeclared '_GUID' struct. - PREDEF_DECL_BUILTIN_MS_GUID_ID = 12, + /// An EnumConstantDecl record. + DECL_ENUM_CONSTANT, - /// The extern "C" context. - PREDEF_DECL_EXTERN_C_CONTEXT_ID = 13, + /// A FunctionDecl record. + DECL_FUNCTION, - /// The internal '__make_integer_seq' template. - PREDEF_DECL_MAKE_INTEGER_SEQ_ID = 14, + /// A ObjCMethodDecl record. + DECL_OBJC_METHOD, - /// The internal '__NSConstantString' typedef. - PREDEF_DECL_CF_CONSTANT_STRING_ID = 15, + /// A ObjCInterfaceDecl record. + DECL_OBJC_INTERFACE, - /// The internal '__NSConstantString' tag type. - PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID = 16, + /// A ObjCProtocolDecl record. + DECL_OBJC_PROTOCOL, - /// The internal '__type_pack_element' template. - PREDEF_DECL_TYPE_PACK_ELEMENT_ID = 17, - }; + /// A ObjCIvarDecl record. + DECL_OBJC_IVAR, - /// The number of declaration IDs that are predefined. - /// - /// For more information about predefined declarations, see the - /// \c PredefinedDeclIDs type and the PREDEF_DECL_*_ID constants. - const unsigned int NUM_PREDEF_DECL_IDS = 18; + /// A ObjCAtDefsFieldDecl record. + DECL_OBJC_AT_DEFS_FIELD, - /// Record of updates for a declaration that was modified after - /// being deserialized. This can occur within DECLTYPES_BLOCK_ID. - const unsigned int DECL_UPDATES = 49; + /// A ObjCCategoryDecl record. + DECL_OBJC_CATEGORY, - /// Record code for a list of local redeclarations of a declaration. - /// This can occur within DECLTYPES_BLOCK_ID. - const unsigned int LOCAL_REDECLARATIONS = 50; + /// A ObjCCategoryImplDecl record. + DECL_OBJC_CATEGORY_IMPL, - /// Record codes for each kind of declaration. - /// - /// These constants describe the declaration records that can occur within - /// a declarations block (identified by DECLTYPES_BLOCK_ID). Each - /// constant describes a record for a specific declaration class - /// in the AST. Note that TypeCode values share this code space. - enum DeclCode { - /// A TypedefDecl record. - DECL_TYPEDEF = 51, - /// A TypeAliasDecl record. + /// A ObjCImplementationDecl record. + DECL_OBJC_IMPLEMENTATION, - DECL_TYPEALIAS, + /// A ObjCCompatibleAliasDecl record. + DECL_OBJC_COMPATIBLE_ALIAS, - /// An EnumDecl record. - DECL_ENUM, + /// A ObjCPropertyDecl record. + DECL_OBJC_PROPERTY, - /// A RecordDecl record. - DECL_RECORD, + /// A ObjCPropertyImplDecl record. + DECL_OBJC_PROPERTY_IMPL, - /// An EnumConstantDecl record. - DECL_ENUM_CONSTANT, + /// A FieldDecl record. + DECL_FIELD, - /// A FunctionDecl record. - DECL_FUNCTION, + /// A MSPropertyDecl record. + DECL_MS_PROPERTY, - /// A ObjCMethodDecl record. - DECL_OBJC_METHOD, + /// A MSGuidDecl record. + DECL_MS_GUID, - /// A ObjCInterfaceDecl record. - DECL_OBJC_INTERFACE, + /// A TemplateParamObjectDecl record. + DECL_TEMPLATE_PARAM_OBJECT, - /// A ObjCProtocolDecl record. - DECL_OBJC_PROTOCOL, + /// A VarDecl record. + DECL_VAR, - /// A ObjCIvarDecl record. - DECL_OBJC_IVAR, + /// An ImplicitParamDecl record. + DECL_IMPLICIT_PARAM, - /// A ObjCAtDefsFieldDecl record. - DECL_OBJC_AT_DEFS_FIELD, + /// A ParmVarDecl record. + DECL_PARM_VAR, - /// A ObjCCategoryDecl record. - DECL_OBJC_CATEGORY, + /// A DecompositionDecl record. + DECL_DECOMPOSITION, - /// A ObjCCategoryImplDecl record. - DECL_OBJC_CATEGORY_IMPL, + /// A BindingDecl record. + DECL_BINDING, - /// A ObjCImplementationDecl record. - DECL_OBJC_IMPLEMENTATION, + /// A FileScopeAsmDecl record. + DECL_FILE_SCOPE_ASM, - /// A ObjCCompatibleAliasDecl record. - DECL_OBJC_COMPATIBLE_ALIAS, + /// A BlockDecl record. + DECL_BLOCK, - /// A ObjCPropertyDecl record. - DECL_OBJC_PROPERTY, + /// A CapturedDecl record. + DECL_CAPTURED, - /// A ObjCPropertyImplDecl record. - DECL_OBJC_PROPERTY_IMPL, + /// A record that stores the set of declarations that are + /// lexically stored within a given DeclContext. + /// + /// The record itself is a blob that is an array of declaration IDs, + /// in the order in which those declarations were added to the + /// declaration context. This data is used when iterating over + /// the contents of a DeclContext, e.g., via + /// DeclContext::decls_begin() and DeclContext::decls_end(). + DECL_CONTEXT_LEXICAL, - /// A FieldDecl record. - DECL_FIELD, + /// A record that stores the set of declarations that are + /// visible from a given DeclContext. + /// + /// The record itself stores a set of mappings, each of which + /// associates a declaration name with one or more declaration + /// IDs. This data is used when performing qualified name lookup + /// into a DeclContext via DeclContext::lookup. + DECL_CONTEXT_VISIBLE, - /// A MSPropertyDecl record. - DECL_MS_PROPERTY, + /// A LabelDecl record. + DECL_LABEL, - /// A MSGuidDecl record. - DECL_MS_GUID, + /// A NamespaceDecl record. + DECL_NAMESPACE, - /// A TemplateParamObjectDecl record. - DECL_TEMPLATE_PARAM_OBJECT, + /// A NamespaceAliasDecl record. + DECL_NAMESPACE_ALIAS, - /// A VarDecl record. - DECL_VAR, + /// A UsingDecl record. + DECL_USING, - /// An ImplicitParamDecl record. - DECL_IMPLICIT_PARAM, + /// A UsingEnumDecl record. + DECL_USING_ENUM, - /// A ParmVarDecl record. - DECL_PARM_VAR, + /// A UsingPackDecl record. + DECL_USING_PACK, - /// A DecompositionDecl record. - DECL_DECOMPOSITION, + /// A UsingShadowDecl record. + DECL_USING_SHADOW, - /// A BindingDecl record. - DECL_BINDING, + /// A ConstructorUsingShadowDecl record. + DECL_CONSTRUCTOR_USING_SHADOW, - /// A FileScopeAsmDecl record. - DECL_FILE_SCOPE_ASM, + /// A UsingDirecitveDecl record. + DECL_USING_DIRECTIVE, - /// A BlockDecl record. - DECL_BLOCK, + /// An UnresolvedUsingValueDecl record. + DECL_UNRESOLVED_USING_VALUE, - /// A CapturedDecl record. - DECL_CAPTURED, + /// An UnresolvedUsingTypenameDecl record. + DECL_UNRESOLVED_USING_TYPENAME, - /// A record that stores the set of declarations that are - /// lexically stored within a given DeclContext. - /// - /// The record itself is a blob that is an array of declaration IDs, - /// in the order in which those declarations were added to the - /// declaration context. This data is used when iterating over - /// the contents of a DeclContext, e.g., via - /// DeclContext::decls_begin() and DeclContext::decls_end(). - DECL_CONTEXT_LEXICAL, + /// A LinkageSpecDecl record. + DECL_LINKAGE_SPEC, - /// A record that stores the set of declarations that are - /// visible from a given DeclContext. - /// - /// The record itself stores a set of mappings, each of which - /// associates a declaration name with one or more declaration - /// IDs. This data is used when performing qualified name lookup - /// into a DeclContext via DeclContext::lookup. - DECL_CONTEXT_VISIBLE, + /// An ExportDecl record. + DECL_EXPORT, - /// A LabelDecl record. - DECL_LABEL, + /// A CXXRecordDecl record. + DECL_CXX_RECORD, - /// A NamespaceDecl record. - DECL_NAMESPACE, + /// A CXXDeductionGuideDecl record. + DECL_CXX_DEDUCTION_GUIDE, - /// A NamespaceAliasDecl record. - DECL_NAMESPACE_ALIAS, + /// A CXXMethodDecl record. + DECL_CXX_METHOD, - /// A UsingDecl record. - DECL_USING, + /// A CXXConstructorDecl record. + DECL_CXX_CONSTRUCTOR, - /// A UsingPackDecl record. - DECL_USING_PACK, + /// A CXXDestructorDecl record. + DECL_CXX_DESTRUCTOR, - /// A UsingShadowDecl record. - DECL_USING_SHADOW, + /// A CXXConversionDecl record. + DECL_CXX_CONVERSION, - /// A ConstructorUsingShadowDecl record. - DECL_CONSTRUCTOR_USING_SHADOW, + /// An AccessSpecDecl record. + DECL_ACCESS_SPEC, - /// A UsingDirecitveDecl record. - DECL_USING_DIRECTIVE, + /// A FriendDecl record. + DECL_FRIEND, - /// An UnresolvedUsingValueDecl record. - DECL_UNRESOLVED_USING_VALUE, + /// A FriendTemplateDecl record. + DECL_FRIEND_TEMPLATE, - /// An UnresolvedUsingTypenameDecl record. - DECL_UNRESOLVED_USING_TYPENAME, + /// A ClassTemplateDecl record. + DECL_CLASS_TEMPLATE, - /// A LinkageSpecDecl record. - DECL_LINKAGE_SPEC, + /// A ClassTemplateSpecializationDecl record. + DECL_CLASS_TEMPLATE_SPECIALIZATION, - /// An ExportDecl record. - DECL_EXPORT, + /// A ClassTemplatePartialSpecializationDecl record. + DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION, - /// A CXXRecordDecl record. - DECL_CXX_RECORD, + /// A VarTemplateDecl record. + DECL_VAR_TEMPLATE, - /// A CXXDeductionGuideDecl record. - DECL_CXX_DEDUCTION_GUIDE, + /// A VarTemplateSpecializationDecl record. + DECL_VAR_TEMPLATE_SPECIALIZATION, - /// A CXXMethodDecl record. - DECL_CXX_METHOD, + /// A VarTemplatePartialSpecializationDecl record. + DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION, - /// A CXXConstructorDecl record. - DECL_CXX_CONSTRUCTOR, + /// A FunctionTemplateDecl record. + DECL_FUNCTION_TEMPLATE, - /// A CXXDestructorDecl record. - DECL_CXX_DESTRUCTOR, + /// A TemplateTypeParmDecl record. + DECL_TEMPLATE_TYPE_PARM, - /// A CXXConversionDecl record. - DECL_CXX_CONVERSION, + /// A NonTypeTemplateParmDecl record. + DECL_NON_TYPE_TEMPLATE_PARM, - /// An AccessSpecDecl record. - DECL_ACCESS_SPEC, + /// A TemplateTemplateParmDecl record. + DECL_TEMPLATE_TEMPLATE_PARM, - /// A FriendDecl record. - DECL_FRIEND, + /// A TypeAliasTemplateDecl record. + DECL_TYPE_ALIAS_TEMPLATE, - /// A FriendTemplateDecl record. - DECL_FRIEND_TEMPLATE, + /// \brief A ConceptDecl record. + DECL_CONCEPT, - /// A ClassTemplateDecl record. - DECL_CLASS_TEMPLATE, + /// An UnresolvedUsingIfExistsDecl record. + DECL_UNRESOLVED_USING_IF_EXISTS, - /// A ClassTemplateSpecializationDecl record. - DECL_CLASS_TEMPLATE_SPECIALIZATION, + /// \brief A StaticAssertDecl record. + DECL_STATIC_ASSERT, - /// A ClassTemplatePartialSpecializationDecl record. - DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION, + /// A record containing CXXBaseSpecifiers. + DECL_CXX_BASE_SPECIFIERS, - /// A VarTemplateDecl record. - DECL_VAR_TEMPLATE, + /// A record containing CXXCtorInitializers. + DECL_CXX_CTOR_INITIALIZERS, - /// A VarTemplateSpecializationDecl record. - DECL_VAR_TEMPLATE_SPECIALIZATION, + /// A IndirectFieldDecl record. + DECL_INDIRECTFIELD, - /// A VarTemplatePartialSpecializationDecl record. - DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION, + /// A NonTypeTemplateParmDecl record that stores an expanded + /// non-type template parameter pack. + DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK, - /// A FunctionTemplateDecl record. - DECL_FUNCTION_TEMPLATE, + /// A TemplateTemplateParmDecl record that stores an expanded + /// template template parameter pack. + DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK, - /// A TemplateTypeParmDecl record. - DECL_TEMPLATE_TYPE_PARM, + /// A ClassScopeFunctionSpecializationDecl record a class scope + /// function specialization. (Microsoft extension). + DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION, - /// A NonTypeTemplateParmDecl record. - DECL_NON_TYPE_TEMPLATE_PARM, + /// An ImportDecl recording a module import. + DECL_IMPORT, - /// A TemplateTemplateParmDecl record. - DECL_TEMPLATE_TEMPLATE_PARM, + /// An OMPThreadPrivateDecl record. + DECL_OMP_THREADPRIVATE, - /// A TypeAliasTemplateDecl record. - DECL_TYPE_ALIAS_TEMPLATE, + /// An OMPRequiresDecl record. + DECL_OMP_REQUIRES, - /// \brief A ConceptDecl record. - DECL_CONCEPT, + /// An OMPAllocateDcl record. + DECL_OMP_ALLOCATE, - /// \brief A StaticAssertDecl record. - DECL_STATIC_ASSERT, + /// An EmptyDecl record. + DECL_EMPTY, - /// A record containing CXXBaseSpecifiers. - DECL_CXX_BASE_SPECIFIERS, + /// An LifetimeExtendedTemporaryDecl record. + DECL_LIFETIME_EXTENDED_TEMPORARY, - /// A record containing CXXCtorInitializers. - DECL_CXX_CTOR_INITIALIZERS, + /// A RequiresExprBodyDecl record. + DECL_REQUIRES_EXPR_BODY, - /// A IndirectFieldDecl record. - DECL_INDIRECTFIELD, + /// An ObjCTypeParamDecl record. + DECL_OBJC_TYPE_PARAM, - /// A NonTypeTemplateParmDecl record that stores an expanded - /// non-type template parameter pack. - DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK, + /// An OMPCapturedExprDecl record. + DECL_OMP_CAPTUREDEXPR, - /// A TemplateTemplateParmDecl record that stores an expanded - /// template template parameter pack. - DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK, + /// A PragmaCommentDecl record. + DECL_PRAGMA_COMMENT, - /// A ClassScopeFunctionSpecializationDecl record a class scope - /// function specialization. (Microsoft extension). - DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION, + /// A PragmaDetectMismatchDecl record. + DECL_PRAGMA_DETECT_MISMATCH, - /// An ImportDecl recording a module import. - DECL_IMPORT, + /// An OMPDeclareMapperDecl record. + DECL_OMP_DECLARE_MAPPER, - /// An OMPThreadPrivateDecl record. - DECL_OMP_THREADPRIVATE, + /// An OMPDeclareReductionDecl record. + DECL_OMP_DECLARE_REDUCTION, - /// An OMPRequiresDecl record. - DECL_OMP_REQUIRES, + DECL_LAST = DECL_OMP_DECLARE_REDUCTION +}; - /// An OMPAllocateDcl record. - DECL_OMP_ALLOCATE, +/// Record codes for each kind of statement or expression. +/// +/// These constants describe the records that describe statements +/// or expressions. These records occur within type and declarations +/// block, so they begin with record values of 128. Each constant +/// describes a record for a specific statement or expression class in the +/// AST. +enum StmtCode { + /// A marker record that indicates that we are at the end + /// of an expression. + STMT_STOP = DECL_LAST + 1, - /// An EmptyDecl record. - DECL_EMPTY, + /// A NULL expression. + STMT_NULL_PTR, - /// An LifetimeExtendedTemporaryDecl record. - DECL_LIFETIME_EXTENDED_TEMPORARY, + /// A reference to a previously [de]serialized Stmt record. + STMT_REF_PTR, - /// A RequiresExprBodyDecl record. - DECL_REQUIRES_EXPR_BODY, + /// A NullStmt record. + STMT_NULL, - /// An ObjCTypeParamDecl record. - DECL_OBJC_TYPE_PARAM, + /// A CompoundStmt record. + STMT_COMPOUND, - /// An OMPCapturedExprDecl record. - DECL_OMP_CAPTUREDEXPR, + /// A CaseStmt record. + STMT_CASE, - /// A PragmaCommentDecl record. - DECL_PRAGMA_COMMENT, + /// A DefaultStmt record. + STMT_DEFAULT, - /// A PragmaDetectMismatchDecl record. - DECL_PRAGMA_DETECT_MISMATCH, + /// A LabelStmt record. + STMT_LABEL, - /// An OMPDeclareMapperDecl record. - DECL_OMP_DECLARE_MAPPER, + /// An AttributedStmt record. + STMT_ATTRIBUTED, - /// An OMPDeclareReductionDecl record. - DECL_OMP_DECLARE_REDUCTION, + /// An IfStmt record. + STMT_IF, - DECL_LAST = DECL_OMP_DECLARE_REDUCTION - }; + /// A SwitchStmt record. + STMT_SWITCH, - /// Record codes for each kind of statement or expression. - /// - /// These constants describe the records that describe statements - /// or expressions. These records occur within type and declarations - /// block, so they begin with record values of 128. Each constant - /// describes a record for a specific statement or expression class in the - /// AST. - enum StmtCode { - /// A marker record that indicates that we are at the end - /// of an expression. - STMT_STOP = DECL_LAST + 1, + /// A WhileStmt record. + STMT_WHILE, - /// A NULL expression. - STMT_NULL_PTR, + /// A DoStmt record. + STMT_DO, - /// A reference to a previously [de]serialized Stmt record. - STMT_REF_PTR, + /// A ForStmt record. + STMT_FOR, - /// A NullStmt record. - STMT_NULL, + /// A GotoStmt record. + STMT_GOTO, - /// A CompoundStmt record. - STMT_COMPOUND, + /// An IndirectGotoStmt record. + STMT_INDIRECT_GOTO, - /// A CaseStmt record. - STMT_CASE, + /// A ContinueStmt record. + STMT_CONTINUE, - /// A DefaultStmt record. - STMT_DEFAULT, + /// A BreakStmt record. + STMT_BREAK, - /// A LabelStmt record. - STMT_LABEL, + /// A ReturnStmt record. + STMT_RETURN, - /// An AttributedStmt record. - STMT_ATTRIBUTED, + /// A DeclStmt record. + STMT_DECL, - /// An IfStmt record. - STMT_IF, + /// A CapturedStmt record. + STMT_CAPTURED, - /// A SwitchStmt record. - STMT_SWITCH, + /// A GCC-style AsmStmt record. + STMT_GCCASM, - /// A WhileStmt record. - STMT_WHILE, + /// A MS-style AsmStmt record. + STMT_MSASM, - /// A DoStmt record. - STMT_DO, + /// A constant expression context. + EXPR_CONSTANT, - /// A ForStmt record. - STMT_FOR, + /// A PredefinedExpr record. + EXPR_PREDEFINED, - /// A GotoStmt record. - STMT_GOTO, + /// A DeclRefExpr record. + EXPR_DECL_REF, - /// An IndirectGotoStmt record. - STMT_INDIRECT_GOTO, + /// An IntegerLiteral record. + EXPR_INTEGER_LITERAL, - /// A ContinueStmt record. - STMT_CONTINUE, + /// A FloatingLiteral record. + EXPR_FLOATING_LITERAL, - /// A BreakStmt record. - STMT_BREAK, + /// An ImaginaryLiteral record. + EXPR_IMAGINARY_LITERAL, - /// A ReturnStmt record. - STMT_RETURN, + /// A StringLiteral record. + EXPR_STRING_LITERAL, - /// A DeclStmt record. - STMT_DECL, + /// A CharacterLiteral record. + EXPR_CHARACTER_LITERAL, - /// A CapturedStmt record. - STMT_CAPTURED, + /// A ParenExpr record. + EXPR_PAREN, - /// A GCC-style AsmStmt record. - STMT_GCCASM, + /// A ParenListExpr record. + EXPR_PAREN_LIST, - /// A MS-style AsmStmt record. - STMT_MSASM, + /// A UnaryOperator record. + EXPR_UNARY_OPERATOR, - /// A constant expression context. - EXPR_CONSTANT, + /// An OffsetOfExpr record. + EXPR_OFFSETOF, - /// A PredefinedExpr record. - EXPR_PREDEFINED, + /// A SizefAlignOfExpr record. + EXPR_SIZEOF_ALIGN_OF, - /// A DeclRefExpr record. - EXPR_DECL_REF, + /// An ArraySubscriptExpr record. + EXPR_ARRAY_SUBSCRIPT, - /// An IntegerLiteral record. - EXPR_INTEGER_LITERAL, + /// An MatrixSubscriptExpr record. + EXPR_MATRIX_SUBSCRIPT, - /// A FloatingLiteral record. - EXPR_FLOATING_LITERAL, + /// A CallExpr record. + EXPR_CALL, - /// An ImaginaryLiteral record. - EXPR_IMAGINARY_LITERAL, + /// A MemberExpr record. + EXPR_MEMBER, - /// A StringLiteral record. - EXPR_STRING_LITERAL, + /// A BinaryOperator record. + EXPR_BINARY_OPERATOR, - /// A CharacterLiteral record. - EXPR_CHARACTER_LITERAL, + /// A CompoundAssignOperator record. + EXPR_COMPOUND_ASSIGN_OPERATOR, - /// A ParenExpr record. - EXPR_PAREN, + /// A ConditionOperator record. + EXPR_CONDITIONAL_OPERATOR, - /// A ParenListExpr record. - EXPR_PAREN_LIST, + /// An ImplicitCastExpr record. + EXPR_IMPLICIT_CAST, - /// A UnaryOperator record. - EXPR_UNARY_OPERATOR, + /// A CStyleCastExpr record. + EXPR_CSTYLE_CAST, - /// An OffsetOfExpr record. - EXPR_OFFSETOF, + /// A CompoundLiteralExpr record. + EXPR_COMPOUND_LITERAL, - /// A SizefAlignOfExpr record. - EXPR_SIZEOF_ALIGN_OF, + /// An ExtVectorElementExpr record. + EXPR_EXT_VECTOR_ELEMENT, - /// An ArraySubscriptExpr record. - EXPR_ARRAY_SUBSCRIPT, + /// An InitListExpr record. + EXPR_INIT_LIST, - /// An MatrixSubscriptExpr record. - EXPR_MATRIX_SUBSCRIPT, + /// A DesignatedInitExpr record. + EXPR_DESIGNATED_INIT, - /// A CallExpr record. - EXPR_CALL, + /// A DesignatedInitUpdateExpr record. + EXPR_DESIGNATED_INIT_UPDATE, - /// A MemberExpr record. - EXPR_MEMBER, + /// An NoInitExpr record. + EXPR_NO_INIT, - /// A BinaryOperator record. - EXPR_BINARY_OPERATOR, + /// An ArrayInitLoopExpr record. + EXPR_ARRAY_INIT_LOOP, - /// A CompoundAssignOperator record. - EXPR_COMPOUND_ASSIGN_OPERATOR, + /// An ArrayInitIndexExpr record. + EXPR_ARRAY_INIT_INDEX, - /// A ConditionOperator record. - EXPR_CONDITIONAL_OPERATOR, + /// An ImplicitValueInitExpr record. + EXPR_IMPLICIT_VALUE_INIT, - /// An ImplicitCastExpr record. - EXPR_IMPLICIT_CAST, + /// A VAArgExpr record. + EXPR_VA_ARG, - /// A CStyleCastExpr record. - EXPR_CSTYLE_CAST, + /// An AddrLabelExpr record. + EXPR_ADDR_LABEL, - /// A CompoundLiteralExpr record. - EXPR_COMPOUND_LITERAL, + /// A StmtExpr record. + EXPR_STMT, - /// An ExtVectorElementExpr record. - EXPR_EXT_VECTOR_ELEMENT, + /// A ChooseExpr record. + EXPR_CHOOSE, - /// An InitListExpr record. - EXPR_INIT_LIST, + /// A GNUNullExpr record. + EXPR_GNU_NULL, - /// A DesignatedInitExpr record. - EXPR_DESIGNATED_INIT, + /// A SourceLocExpr record. + EXPR_SOURCE_LOC, - /// A DesignatedInitUpdateExpr record. - EXPR_DESIGNATED_INIT_UPDATE, + /// A ShuffleVectorExpr record. + EXPR_SHUFFLE_VECTOR, - /// An NoInitExpr record. - EXPR_NO_INIT, + /// A ConvertVectorExpr record. + EXPR_CONVERT_VECTOR, - /// An ArrayInitLoopExpr record. - EXPR_ARRAY_INIT_LOOP, + /// BlockExpr + EXPR_BLOCK, - /// An ArrayInitIndexExpr record. - EXPR_ARRAY_INIT_INDEX, + /// A GenericSelectionExpr record. + EXPR_GENERIC_SELECTION, - /// An ImplicitValueInitExpr record. - EXPR_IMPLICIT_VALUE_INIT, + /// A PseudoObjectExpr record. + EXPR_PSEUDO_OBJECT, - /// A VAArgExpr record. - EXPR_VA_ARG, + /// An AtomicExpr record. + EXPR_ATOMIC, - /// An AddrLabelExpr record. - EXPR_ADDR_LABEL, + /// A RecoveryExpr record. + EXPR_RECOVERY, - /// A StmtExpr record. - EXPR_STMT, + // Objective-C - /// A ChooseExpr record. - EXPR_CHOOSE, + /// An ObjCStringLiteral record. + EXPR_OBJC_STRING_LITERAL, - /// A GNUNullExpr record. - EXPR_GNU_NULL, + EXPR_OBJC_BOXED_EXPRESSION, + EXPR_OBJC_ARRAY_LITERAL, + EXPR_OBJC_DICTIONARY_LITERAL, - /// A SourceLocExpr record. - EXPR_SOURCE_LOC, + /// An ObjCEncodeExpr record. + EXPR_OBJC_ENCODE, - /// A ShuffleVectorExpr record. - EXPR_SHUFFLE_VECTOR, + /// An ObjCSelectorExpr record. + EXPR_OBJC_SELECTOR_EXPR, - /// A ConvertVectorExpr record. - EXPR_CONVERT_VECTOR, + /// An ObjCProtocolExpr record. + EXPR_OBJC_PROTOCOL_EXPR, - /// BlockExpr - EXPR_BLOCK, + /// An ObjCIvarRefExpr record. + EXPR_OBJC_IVAR_REF_EXPR, - /// A GenericSelectionExpr record. - EXPR_GENERIC_SELECTION, + /// An ObjCPropertyRefExpr record. + EXPR_OBJC_PROPERTY_REF_EXPR, - /// A PseudoObjectExpr record. - EXPR_PSEUDO_OBJECT, + /// An ObjCSubscriptRefExpr record. + EXPR_OBJC_SUBSCRIPT_REF_EXPR, - /// An AtomicExpr record. - EXPR_ATOMIC, + /// UNUSED + EXPR_OBJC_KVC_REF_EXPR, - /// A RecoveryExpr record. - EXPR_RECOVERY, + /// An ObjCMessageExpr record. + EXPR_OBJC_MESSAGE_EXPR, - // Objective-C + /// An ObjCIsa Expr record. + EXPR_OBJC_ISA, - /// An ObjCStringLiteral record. - EXPR_OBJC_STRING_LITERAL, + /// An ObjCIndirectCopyRestoreExpr record. + EXPR_OBJC_INDIRECT_COPY_RESTORE, - EXPR_OBJC_BOXED_EXPRESSION, - EXPR_OBJC_ARRAY_LITERAL, - EXPR_OBJC_DICTIONARY_LITERAL, + /// An ObjCForCollectionStmt record. + STMT_OBJC_FOR_COLLECTION, - /// An ObjCEncodeExpr record. - EXPR_OBJC_ENCODE, + /// An ObjCAtCatchStmt record. + STMT_OBJC_CATCH, - /// An ObjCSelectorExpr record. - EXPR_OBJC_SELECTOR_EXPR, + /// An ObjCAtFinallyStmt record. + STMT_OBJC_FINALLY, - /// An ObjCProtocolExpr record. - EXPR_OBJC_PROTOCOL_EXPR, + /// An ObjCAtTryStmt record. + STMT_OBJC_AT_TRY, - /// An ObjCIvarRefExpr record. - EXPR_OBJC_IVAR_REF_EXPR, + /// An ObjCAtSynchronizedStmt record. + STMT_OBJC_AT_SYNCHRONIZED, - /// An ObjCPropertyRefExpr record. - EXPR_OBJC_PROPERTY_REF_EXPR, + /// An ObjCAtThrowStmt record. + STMT_OBJC_AT_THROW, - /// An ObjCSubscriptRefExpr record. - EXPR_OBJC_SUBSCRIPT_REF_EXPR, + /// An ObjCAutoreleasePoolStmt record. + STMT_OBJC_AUTORELEASE_POOL, - /// UNUSED - EXPR_OBJC_KVC_REF_EXPR, + /// An ObjCBoolLiteralExpr record. + EXPR_OBJC_BOOL_LITERAL, - /// An ObjCMessageExpr record. - EXPR_OBJC_MESSAGE_EXPR, + /// An ObjCAvailabilityCheckExpr record. + EXPR_OBJC_AVAILABILITY_CHECK, - /// An ObjCIsa Expr record. - EXPR_OBJC_ISA, + // C++ - /// An ObjCIndirectCopyRestoreExpr record. - EXPR_OBJC_INDIRECT_COPY_RESTORE, + /// A CXXCatchStmt record. + STMT_CXX_CATCH, - /// An ObjCForCollectionStmt record. - STMT_OBJC_FOR_COLLECTION, + /// A CXXTryStmt record. + STMT_CXX_TRY, + /// A CXXForRangeStmt record. - /// An ObjCAtCatchStmt record. - STMT_OBJC_CATCH, + STMT_CXX_FOR_RANGE, - /// An ObjCAtFinallyStmt record. - STMT_OBJC_FINALLY, + /// A CXXOperatorCallExpr record. + EXPR_CXX_OPERATOR_CALL, - /// An ObjCAtTryStmt record. - STMT_OBJC_AT_TRY, + /// A CXXMemberCallExpr record. + EXPR_CXX_MEMBER_CALL, - /// An ObjCAtSynchronizedStmt record. - STMT_OBJC_AT_SYNCHRONIZED, + /// A CXXRewrittenBinaryOperator record. + EXPR_CXX_REWRITTEN_BINARY_OPERATOR, - /// An ObjCAtThrowStmt record. - STMT_OBJC_AT_THROW, + /// A CXXConstructExpr record. + EXPR_CXX_CONSTRUCT, - /// An ObjCAutoreleasePoolStmt record. - STMT_OBJC_AUTORELEASE_POOL, + /// A CXXInheritedCtorInitExpr record. + EXPR_CXX_INHERITED_CTOR_INIT, - /// An ObjCBoolLiteralExpr record. - EXPR_OBJC_BOOL_LITERAL, + /// A CXXTemporaryObjectExpr record. + EXPR_CXX_TEMPORARY_OBJECT, - /// An ObjCAvailabilityCheckExpr record. - EXPR_OBJC_AVAILABILITY_CHECK, + /// A CXXStaticCastExpr record. + EXPR_CXX_STATIC_CAST, - // C++ + /// A CXXDynamicCastExpr record. + EXPR_CXX_DYNAMIC_CAST, - /// A CXXCatchStmt record. - STMT_CXX_CATCH, + /// A CXXReinterpretCastExpr record. + EXPR_CXX_REINTERPRET_CAST, - /// A CXXTryStmt record. - STMT_CXX_TRY, - /// A CXXForRangeStmt record. + /// A CXXConstCastExpr record. + EXPR_CXX_CONST_CAST, - STMT_CXX_FOR_RANGE, + /// A CXXAddrspaceCastExpr record. + EXPR_CXX_ADDRSPACE_CAST, + + /// A CXXFunctionalCastExpr record. + EXPR_CXX_FUNCTIONAL_CAST, + + /// A BuiltinBitCastExpr record. + EXPR_BUILTIN_BIT_CAST, + + /// A UserDefinedLiteral record. + EXPR_USER_DEFINED_LITERAL, + + /// A CXXStdInitializerListExpr record. + EXPR_CXX_STD_INITIALIZER_LIST, + + /// A CXXBoolLiteralExpr record. + EXPR_CXX_BOOL_LITERAL, + + EXPR_CXX_NULL_PTR_LITERAL, // CXXNullPtrLiteralExpr + EXPR_CXX_TYPEID_EXPR, // CXXTypeidExpr (of expr). + EXPR_CXX_TYPEID_TYPE, // CXXTypeidExpr (of type). + EXPR_CXX_THIS, // CXXThisExpr + EXPR_CXX_THROW, // CXXThrowExpr + EXPR_CXX_DEFAULT_ARG, // CXXDefaultArgExpr + EXPR_CXX_DEFAULT_INIT, // CXXDefaultInitExpr + EXPR_CXX_BIND_TEMPORARY, // CXXBindTemporaryExpr + + EXPR_CXX_SCALAR_VALUE_INIT, // CXXScalarValueInitExpr + EXPR_CXX_NEW, // CXXNewExpr + EXPR_CXX_DELETE, // CXXDeleteExpr + EXPR_CXX_PSEUDO_DESTRUCTOR, // CXXPseudoDestructorExpr + + EXPR_EXPR_WITH_CLEANUPS, // ExprWithCleanups + + EXPR_CXX_DEPENDENT_SCOPE_MEMBER, // CXXDependentScopeMemberExpr + EXPR_CXX_DEPENDENT_SCOPE_DECL_REF, // DependentScopeDeclRefExpr + EXPR_CXX_UNRESOLVED_CONSTRUCT, // CXXUnresolvedConstructExpr + EXPR_CXX_UNRESOLVED_MEMBER, // UnresolvedMemberExpr + EXPR_CXX_UNRESOLVED_LOOKUP, // UnresolvedLookupExpr + + EXPR_CXX_EXPRESSION_TRAIT, // ExpressionTraitExpr + EXPR_CXX_NOEXCEPT, // CXXNoexceptExpr + + EXPR_OPAQUE_VALUE, // OpaqueValueExpr + EXPR_BINARY_CONDITIONAL_OPERATOR, // BinaryConditionalOperator + EXPR_TYPE_TRAIT, // TypeTraitExpr + EXPR_ARRAY_TYPE_TRAIT, // ArrayTypeTraitIntExpr + + EXPR_PACK_EXPANSION, // PackExpansionExpr + EXPR_SIZEOF_PACK, // SizeOfPackExpr + EXPR_SUBST_NON_TYPE_TEMPLATE_PARM, // SubstNonTypeTemplateParmExpr + EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK, // SubstNonTypeTemplateParmPackExpr + EXPR_FUNCTION_PARM_PACK, // FunctionParmPackExpr + EXPR_MATERIALIZE_TEMPORARY, // MaterializeTemporaryExpr + EXPR_CXX_FOLD, // CXXFoldExpr + EXPR_CONCEPT_SPECIALIZATION, // ConceptSpecializationExpr + EXPR_REQUIRES, // RequiresExpr + + // CUDA + EXPR_CUDA_KERNEL_CALL, // CUDAKernelCallExpr + + // OpenCL + EXPR_ASTYPE, // AsTypeExpr + + // Microsoft + EXPR_CXX_PROPERTY_REF_EXPR, // MSPropertyRefExpr + EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR, // MSPropertySubscriptExpr + EXPR_CXX_UUIDOF_EXPR, // CXXUuidofExpr (of expr). + EXPR_CXX_UUIDOF_TYPE, // CXXUuidofExpr (of type). + STMT_SEH_LEAVE, // SEHLeaveStmt + STMT_SEH_EXCEPT, // SEHExceptStmt + STMT_SEH_FINALLY, // SEHFinallyStmt + STMT_SEH_TRY, // SEHTryStmt + + // OpenMP directives + STMT_OMP_CANONICAL_LOOP, + STMT_OMP_PARALLEL_DIRECTIVE, + STMT_OMP_SIMD_DIRECTIVE, + STMT_OMP_TILE_DIRECTIVE, + STMT_OMP_UNROLL_DIRECTIVE, + STMT_OMP_FOR_DIRECTIVE, + STMT_OMP_FOR_SIMD_DIRECTIVE, + STMT_OMP_SECTIONS_DIRECTIVE, + STMT_OMP_SECTION_DIRECTIVE, + STMT_OMP_SINGLE_DIRECTIVE, + STMT_OMP_MASTER_DIRECTIVE, + STMT_OMP_CRITICAL_DIRECTIVE, + STMT_OMP_PARALLEL_FOR_DIRECTIVE, + STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE, + STMT_OMP_PARALLEL_MASTER_DIRECTIVE, + STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE, + STMT_OMP_TASK_DIRECTIVE, + STMT_OMP_TASKYIELD_DIRECTIVE, + STMT_OMP_BARRIER_DIRECTIVE, + STMT_OMP_TASKWAIT_DIRECTIVE, + STMT_OMP_FLUSH_DIRECTIVE, + STMT_OMP_DEPOBJ_DIRECTIVE, + STMT_OMP_SCAN_DIRECTIVE, + STMT_OMP_ORDERED_DIRECTIVE, + STMT_OMP_ATOMIC_DIRECTIVE, + STMT_OMP_TARGET_DIRECTIVE, + STMT_OMP_TARGET_DATA_DIRECTIVE, + STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE, + STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE, + STMT_OMP_TARGET_PARALLEL_DIRECTIVE, + STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE, + STMT_OMP_TEAMS_DIRECTIVE, + STMT_OMP_TASKGROUP_DIRECTIVE, + STMT_OMP_CANCELLATION_POINT_DIRECTIVE, + STMT_OMP_CANCEL_DIRECTIVE, + STMT_OMP_TASKLOOP_DIRECTIVE, + STMT_OMP_TASKLOOP_SIMD_DIRECTIVE, + STMT_OMP_MASTER_TASKLOOP_DIRECTIVE, + STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE, + STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE, + STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE, + STMT_OMP_DISTRIBUTE_DIRECTIVE, + STMT_OMP_TARGET_UPDATE_DIRECTIVE, + STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE, + STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE, + STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE, + STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE, + STMT_OMP_TARGET_SIMD_DIRECTIVE, + STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE, + STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE, + STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE, + STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE, + STMT_OMP_TARGET_TEAMS_DIRECTIVE, + STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE, + STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE, + STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE, + STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE, + STMT_OMP_INTEROP_DIRECTIVE, + STMT_OMP_DISPATCH_DIRECTIVE, + STMT_OMP_MASKED_DIRECTIVE, + EXPR_OMP_ARRAY_SECTION, + EXPR_OMP_ARRAY_SHAPING, + EXPR_OMP_ITERATOR, + + // ARC + EXPR_OBJC_BRIDGED_CAST, // ObjCBridgedCastExpr + + STMT_MS_DEPENDENT_EXISTS, // MSDependentExistsStmt + EXPR_LAMBDA, // LambdaExpr + STMT_COROUTINE_BODY, + STMT_CORETURN, + EXPR_COAWAIT, + EXPR_COYIELD, + EXPR_DEPENDENT_COAWAIT, + + // FixedPointLiteral + EXPR_FIXEDPOINT_LITERAL, + + // SYCLUniqueStableNameExpr + EXPR_SYCL_UNIQUE_STABLE_NAME, +}; - /// A CXXOperatorCallExpr record. - EXPR_CXX_OPERATOR_CALL, +/// The kinds of designators that can occur in a +/// DesignatedInitExpr. +enum DesignatorTypes { + /// Field designator where only the field name is known. + DESIG_FIELD_NAME = 0, - /// A CXXMemberCallExpr record. - EXPR_CXX_MEMBER_CALL, + /// Field designator where the field has been resolved to + /// a declaration. + DESIG_FIELD_DECL = 1, - /// A CXXRewrittenBinaryOperator record. - EXPR_CXX_REWRITTEN_BINARY_OPERATOR, + /// Array designator. + DESIG_ARRAY = 2, - /// A CXXConstructExpr record. - EXPR_CXX_CONSTRUCT, + /// GNU array range designator. + DESIG_ARRAY_RANGE = 3 +}; - /// A CXXInheritedCtorInitExpr record. - EXPR_CXX_INHERITED_CTOR_INIT, +/// The different kinds of data that can occur in a +/// CtorInitializer. +enum CtorInitializerType { + CTOR_INITIALIZER_BASE, + CTOR_INITIALIZER_DELEGATING, + CTOR_INITIALIZER_MEMBER, + CTOR_INITIALIZER_INDIRECT_MEMBER +}; - /// A CXXTemporaryObjectExpr record. - EXPR_CXX_TEMPORARY_OBJECT, +/// Kinds of cleanup objects owned by ExprWithCleanups. +enum CleanupObjectKind { COK_Block, COK_CompoundLiteral }; - /// A CXXStaticCastExpr record. - EXPR_CXX_STATIC_CAST, +/// Describes the redeclarations of a declaration. +struct LocalRedeclarationsInfo { + // The ID of the first declaration + DeclID FirstID; - /// A CXXDynamicCastExpr record. - EXPR_CXX_DYNAMIC_CAST, + // Offset into the array of redeclaration chains. + unsigned Offset; - /// A CXXReinterpretCastExpr record. - EXPR_CXX_REINTERPRET_CAST, + friend bool operator<(const LocalRedeclarationsInfo &X, + const LocalRedeclarationsInfo &Y) { + return X.FirstID < Y.FirstID; + } - /// A CXXConstCastExpr record. - EXPR_CXX_CONST_CAST, + friend bool operator>(const LocalRedeclarationsInfo &X, + const LocalRedeclarationsInfo &Y) { + return X.FirstID > Y.FirstID; + } - /// A CXXAddrspaceCastExpr record. - EXPR_CXX_ADDRSPACE_CAST, - - /// A CXXFunctionalCastExpr record. - EXPR_CXX_FUNCTIONAL_CAST, - - /// A BuiltinBitCastExpr record. - EXPR_BUILTIN_BIT_CAST, - - /// A UserDefinedLiteral record. - EXPR_USER_DEFINED_LITERAL, - - /// A CXXStdInitializerListExpr record. - EXPR_CXX_STD_INITIALIZER_LIST, - - /// A CXXBoolLiteralExpr record. - EXPR_CXX_BOOL_LITERAL, - - EXPR_CXX_NULL_PTR_LITERAL, // CXXNullPtrLiteralExpr - EXPR_CXX_TYPEID_EXPR, // CXXTypeidExpr (of expr). - EXPR_CXX_TYPEID_TYPE, // CXXTypeidExpr (of type). - EXPR_CXX_THIS, // CXXThisExpr - EXPR_CXX_THROW, // CXXThrowExpr - EXPR_CXX_DEFAULT_ARG, // CXXDefaultArgExpr - EXPR_CXX_DEFAULT_INIT, // CXXDefaultInitExpr - EXPR_CXX_BIND_TEMPORARY, // CXXBindTemporaryExpr - - EXPR_CXX_SCALAR_VALUE_INIT, // CXXScalarValueInitExpr - EXPR_CXX_NEW, // CXXNewExpr - EXPR_CXX_DELETE, // CXXDeleteExpr - EXPR_CXX_PSEUDO_DESTRUCTOR, // CXXPseudoDestructorExpr - - EXPR_EXPR_WITH_CLEANUPS, // ExprWithCleanups - - EXPR_CXX_DEPENDENT_SCOPE_MEMBER, // CXXDependentScopeMemberExpr - EXPR_CXX_DEPENDENT_SCOPE_DECL_REF, // DependentScopeDeclRefExpr - EXPR_CXX_UNRESOLVED_CONSTRUCT, // CXXUnresolvedConstructExpr - EXPR_CXX_UNRESOLVED_MEMBER, // UnresolvedMemberExpr - EXPR_CXX_UNRESOLVED_LOOKUP, // UnresolvedLookupExpr - - EXPR_CXX_EXPRESSION_TRAIT, // ExpressionTraitExpr - EXPR_CXX_NOEXCEPT, // CXXNoexceptExpr - - EXPR_OPAQUE_VALUE, // OpaqueValueExpr - EXPR_BINARY_CONDITIONAL_OPERATOR, // BinaryConditionalOperator - EXPR_TYPE_TRAIT, // TypeTraitExpr - EXPR_ARRAY_TYPE_TRAIT, // ArrayTypeTraitIntExpr - - EXPR_PACK_EXPANSION, // PackExpansionExpr - EXPR_SIZEOF_PACK, // SizeOfPackExpr - EXPR_SUBST_NON_TYPE_TEMPLATE_PARM, // SubstNonTypeTemplateParmExpr - EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK,// SubstNonTypeTemplateParmPackExpr - EXPR_FUNCTION_PARM_PACK, // FunctionParmPackExpr - EXPR_MATERIALIZE_TEMPORARY, // MaterializeTemporaryExpr - EXPR_CXX_FOLD, // CXXFoldExpr - EXPR_CONCEPT_SPECIALIZATION,// ConceptSpecializationExpr - EXPR_REQUIRES, // RequiresExpr - - // CUDA - EXPR_CUDA_KERNEL_CALL, // CUDAKernelCallExpr - - // OpenCL - EXPR_ASTYPE, // AsTypeExpr - - // Microsoft - EXPR_CXX_PROPERTY_REF_EXPR, // MSPropertyRefExpr - EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR, // MSPropertySubscriptExpr - EXPR_CXX_UUIDOF_EXPR, // CXXUuidofExpr (of expr). - EXPR_CXX_UUIDOF_TYPE, // CXXUuidofExpr (of type). - STMT_SEH_LEAVE, // SEHLeaveStmt - STMT_SEH_EXCEPT, // SEHExceptStmt - STMT_SEH_FINALLY, // SEHFinallyStmt - STMT_SEH_TRY, // SEHTryStmt - - // OpenMP directives - STMT_OMP_PARALLEL_DIRECTIVE, - STMT_OMP_SIMD_DIRECTIVE, - STMT_OMP_FOR_DIRECTIVE, - STMT_OMP_FOR_SIMD_DIRECTIVE, - STMT_OMP_SECTIONS_DIRECTIVE, - STMT_OMP_SECTION_DIRECTIVE, - STMT_OMP_SINGLE_DIRECTIVE, - STMT_OMP_MASTER_DIRECTIVE, - STMT_OMP_CRITICAL_DIRECTIVE, - STMT_OMP_PARALLEL_FOR_DIRECTIVE, - STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE, - STMT_OMP_PARALLEL_MASTER_DIRECTIVE, - STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE, - STMT_OMP_TASK_DIRECTIVE, - STMT_OMP_TASKYIELD_DIRECTIVE, - STMT_OMP_BARRIER_DIRECTIVE, - STMT_OMP_TASKWAIT_DIRECTIVE, - STMT_OMP_FLUSH_DIRECTIVE, - STMT_OMP_DEPOBJ_DIRECTIVE, - STMT_OMP_SCAN_DIRECTIVE, - STMT_OMP_ORDERED_DIRECTIVE, - STMT_OMP_ATOMIC_DIRECTIVE, - STMT_OMP_TARGET_DIRECTIVE, - STMT_OMP_TARGET_DATA_DIRECTIVE, - STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE, - STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE, - STMT_OMP_TARGET_PARALLEL_DIRECTIVE, - STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE, - STMT_OMP_TEAMS_DIRECTIVE, - STMT_OMP_TASKGROUP_DIRECTIVE, - STMT_OMP_CANCELLATION_POINT_DIRECTIVE, - STMT_OMP_CANCEL_DIRECTIVE, - STMT_OMP_TASKLOOP_DIRECTIVE, - STMT_OMP_TASKLOOP_SIMD_DIRECTIVE, - STMT_OMP_MASTER_TASKLOOP_DIRECTIVE, - STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE, - STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE, - STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE, - STMT_OMP_DISTRIBUTE_DIRECTIVE, - STMT_OMP_TARGET_UPDATE_DIRECTIVE, - STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE, - STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE, - STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE, - STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE, - STMT_OMP_TARGET_SIMD_DIRECTIVE, - STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE, - STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE, - STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE, - STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE, - STMT_OMP_TARGET_TEAMS_DIRECTIVE, - STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE, - STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE, - STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE, - STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE, - EXPR_OMP_ARRAY_SECTION, - EXPR_OMP_ARRAY_SHAPING, - EXPR_OMP_ITERATOR, - - // ARC - EXPR_OBJC_BRIDGED_CAST, // ObjCBridgedCastExpr - - STMT_MS_DEPENDENT_EXISTS, // MSDependentExistsStmt - EXPR_LAMBDA, // LambdaExpr - STMT_COROUTINE_BODY, - STMT_CORETURN, - EXPR_COAWAIT, - EXPR_COYIELD, - EXPR_DEPENDENT_COAWAIT, - - // FixedPointLiteral - EXPR_FIXEDPOINT_LITERAL, - }; - - /// The kinds of designators that can occur in a - /// DesignatedInitExpr. - enum DesignatorTypes { - /// Field designator where only the field name is known. - DESIG_FIELD_NAME = 0, - - /// Field designator where the field has been resolved to - /// a declaration. - DESIG_FIELD_DECL = 1, - - /// Array designator. - DESIG_ARRAY = 2, - - /// GNU array range designator. - DESIG_ARRAY_RANGE = 3 - }; - - /// The different kinds of data that can occur in a - /// CtorInitializer. - enum CtorInitializerType { - CTOR_INITIALIZER_BASE, - CTOR_INITIALIZER_DELEGATING, - CTOR_INITIALIZER_MEMBER, - CTOR_INITIALIZER_INDIRECT_MEMBER - }; - - /// Kinds of cleanup objects owned by ExprWithCleanups. - enum CleanupObjectKind { COK_Block, COK_CompoundLiteral }; - - /// Describes the redeclarations of a declaration. - struct LocalRedeclarationsInfo { - // The ID of the first declaration - DeclID FirstID; - - // Offset into the array of redeclaration chains. - unsigned Offset; - - friend bool operator<(const LocalRedeclarationsInfo &X, - const LocalRedeclarationsInfo &Y) { - return X.FirstID < Y.FirstID; - } - - friend bool operator>(const LocalRedeclarationsInfo &X, - const LocalRedeclarationsInfo &Y) { - return X.FirstID > Y.FirstID; - } - - friend bool operator<=(const LocalRedeclarationsInfo &X, - const LocalRedeclarationsInfo &Y) { - return X.FirstID <= Y.FirstID; - } - - friend bool operator>=(const LocalRedeclarationsInfo &X, - const LocalRedeclarationsInfo &Y) { - return X.FirstID >= Y.FirstID; - } - }; - - /// Describes the categories of an Objective-C class. - struct ObjCCategoriesInfo { - // The ID of the definition - DeclID DefinitionID; - - // Offset into the array of category lists. - unsigned Offset; - - friend bool operator<(const ObjCCategoriesInfo &X, - const ObjCCategoriesInfo &Y) { - return X.DefinitionID < Y.DefinitionID; - } - - friend bool operator>(const ObjCCategoriesInfo &X, - const ObjCCategoriesInfo &Y) { - return X.DefinitionID > Y.DefinitionID; - } - - friend bool operator<=(const ObjCCategoriesInfo &X, - const ObjCCategoriesInfo &Y) { - return X.DefinitionID <= Y.DefinitionID; - } - - friend bool operator>=(const ObjCCategoriesInfo &X, - const ObjCCategoriesInfo &Y) { - return X.DefinitionID >= Y.DefinitionID; - } - }; - - /// A key used when looking up entities by \ref DeclarationName. - /// - /// Different \ref DeclarationNames are mapped to different keys, but the - /// same key can occasionally represent multiple names (for names that - /// contain types, in particular). - class DeclarationNameKey { - using NameKind = unsigned; - - NameKind Kind = 0; - uint64_t Data = 0; - - public: - DeclarationNameKey() = default; - DeclarationNameKey(DeclarationName Name); - DeclarationNameKey(NameKind Kind, uint64_t Data) - : Kind(Kind), Data(Data) {} - - NameKind getKind() const { return Kind; } - - IdentifierInfo *getIdentifier() const { - assert(Kind == DeclarationName::Identifier || - Kind == DeclarationName::CXXLiteralOperatorName || - Kind == DeclarationName::CXXDeductionGuideName); - return (IdentifierInfo *)Data; - } - - Selector getSelector() const { - assert(Kind == DeclarationName::ObjCZeroArgSelector || - Kind == DeclarationName::ObjCOneArgSelector || - Kind == DeclarationName::ObjCMultiArgSelector); - return Selector(Data); - } - - OverloadedOperatorKind getOperatorKind() const { - assert(Kind == DeclarationName::CXXOperatorName); - return (OverloadedOperatorKind)Data; - } - - /// Compute a fingerprint of this key for use in on-disk hash table. - unsigned getHash() const; - - friend bool operator==(const DeclarationNameKey &A, - const DeclarationNameKey &B) { - return A.Kind == B.Kind && A.Data == B.Data; - } - }; - - /// @} + friend bool operator<=(const LocalRedeclarationsInfo &X, + const LocalRedeclarationsInfo &Y) { + return X.FirstID <= Y.FirstID; + } + + friend bool operator>=(const LocalRedeclarationsInfo &X, + const LocalRedeclarationsInfo &Y) { + return X.FirstID >= Y.FirstID; + } +}; + +/// Describes the categories of an Objective-C class. +struct ObjCCategoriesInfo { + // The ID of the definition + DeclID DefinitionID; + + // Offset into the array of category lists. + unsigned Offset; + + friend bool operator<(const ObjCCategoriesInfo &X, + const ObjCCategoriesInfo &Y) { + return X.DefinitionID < Y.DefinitionID; + } + + friend bool operator>(const ObjCCategoriesInfo &X, + const ObjCCategoriesInfo &Y) { + return X.DefinitionID > Y.DefinitionID; + } + + friend bool operator<=(const ObjCCategoriesInfo &X, + const ObjCCategoriesInfo &Y) { + return X.DefinitionID <= Y.DefinitionID; + } + + friend bool operator>=(const ObjCCategoriesInfo &X, + const ObjCCategoriesInfo &Y) { + return X.DefinitionID >= Y.DefinitionID; + } +}; + +/// A key used when looking up entities by \ref DeclarationName. +/// +/// Different \ref DeclarationNames are mapped to different keys, but the +/// same key can occasionally represent multiple names (for names that +/// contain types, in particular). +class DeclarationNameKey { + using NameKind = unsigned; + + NameKind Kind = 0; + uint64_t Data = 0; + +public: + DeclarationNameKey() = default; + DeclarationNameKey(DeclarationName Name); + DeclarationNameKey(NameKind Kind, uint64_t Data) : Kind(Kind), Data(Data) {} + + NameKind getKind() const { return Kind; } + + IdentifierInfo *getIdentifier() const { + assert(Kind == DeclarationName::Identifier || + Kind == DeclarationName::CXXLiteralOperatorName || + Kind == DeclarationName::CXXDeductionGuideName); + return (IdentifierInfo *)Data; + } + + Selector getSelector() const { + assert(Kind == DeclarationName::ObjCZeroArgSelector || + Kind == DeclarationName::ObjCOneArgSelector || + Kind == DeclarationName::ObjCMultiArgSelector); + return Selector(Data); + } + + OverloadedOperatorKind getOperatorKind() const { + assert(Kind == DeclarationName::CXXOperatorName); + return (OverloadedOperatorKind)Data; + } + + /// Compute a fingerprint of this key for use in on-disk hash table. + unsigned getHash() const; + + friend bool operator==(const DeclarationNameKey &A, + const DeclarationNameKey &B) { + return A.Kind == B.Kind && A.Data == B.Data; + } +}; + +/// @} } // namespace serialization } // namespace clang namespace llvm { - template <> struct DenseMapInfo<clang::serialization::DeclarationNameKey> { - static clang::serialization::DeclarationNameKey getEmptyKey() { - return clang::serialization::DeclarationNameKey(-1, 1); - } - - static clang::serialization::DeclarationNameKey getTombstoneKey() { - return clang::serialization::DeclarationNameKey(-1, 2); - } - - static unsigned - getHashValue(const clang::serialization::DeclarationNameKey &Key) { - return Key.getHash(); - } - - static bool isEqual(const clang::serialization::DeclarationNameKey &L, - const clang::serialization::DeclarationNameKey &R) { - return L == R; - } - }; +template <> struct DenseMapInfo<clang::serialization::DeclarationNameKey> { + static clang::serialization::DeclarationNameKey getEmptyKey() { + return clang::serialization::DeclarationNameKey(-1, 1); + } + + static clang::serialization::DeclarationNameKey getTombstoneKey() { + return clang::serialization::DeclarationNameKey(-1, 2); + } + + static unsigned + getHashValue(const clang::serialization::DeclarationNameKey &Key) { + return Key.getHash(); + } + + static bool isEqual(const clang::serialization::DeclarationNameKey &L, + const clang::serialization::DeclarationNameKey &R) { + return L == R; + } +}; } // namespace llvm diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index d0d2a68114c7..242b75baca6c 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -767,21 +767,21 @@ private: /// This contains the data loaded from all EAGERLY_DESERIALIZED_DECLS blocks /// in the chain. The referenced declarations are deserialized and passed to /// the consumer eagerly. - SmallVector<uint64_t, 16> EagerlyDeserializedDecls; + SmallVector<serialization::DeclID, 16> EagerlyDeserializedDecls; /// The IDs of all tentative definitions stored in the chain. /// /// Sema keeps track of all tentative definitions in a TU because it has to /// complete them and pass them on to CodeGen. Thus, tentative definitions in /// the PCH chain must be eagerly deserialized. - SmallVector<uint64_t, 16> TentativeDefinitions; + SmallVector<serialization::DeclID, 16> TentativeDefinitions; /// The IDs of all CXXRecordDecls stored in the chain whose VTables are /// used. /// /// CodeGen has to emit VTables for these records, so they have to be eagerly /// deserialized. - SmallVector<uint64_t, 64> VTableUses; + SmallVector<serialization::DeclID, 64> VTableUses; /// A snapshot of the pending instantiations in the chain. /// @@ -789,7 +789,7 @@ private: /// end of the TU. It consists of a pair of values for every pending /// instantiation where the first value is the ID of the decl and the second /// is the instantiation location. - SmallVector<uint64_t, 64> PendingInstantiations; + SmallVector<serialization::DeclID, 64> PendingInstantiations; //@} @@ -799,24 +799,24 @@ private: /// A snapshot of Sema's unused file-scoped variable tracking, for /// generating warnings. - SmallVector<uint64_t, 16> UnusedFileScopedDecls; + SmallVector<serialization::DeclID, 16> UnusedFileScopedDecls; /// A list of all the delegating constructors we've seen, to diagnose /// cycles. - SmallVector<uint64_t, 4> DelegatingCtorDecls; + SmallVector<serialization::DeclID, 4> DelegatingCtorDecls; /// Method selectors used in a @selector expression. Used for /// implementation of -Wselector. - SmallVector<uint64_t, 64> ReferencedSelectorsData; + SmallVector<serialization::SelectorID, 64> ReferencedSelectorsData; /// A snapshot of Sema's weak undeclared identifier tracking, for /// generating warnings. - SmallVector<uint64_t, 64> WeakUndeclaredIdentifiers; + SmallVector<serialization::IdentifierID, 64> WeakUndeclaredIdentifiers; /// The IDs of type aliases for ext_vectors that exist in the chain. /// /// Used by Sema for finding sugared names for ext_vectors in diagnostics. - SmallVector<uint64_t, 4> ExtVectorDecls; + SmallVector<serialization::DeclID, 4> ExtVectorDecls; //@} @@ -827,7 +827,7 @@ private: /// The IDs of all potentially unused typedef names in the chain. /// /// Sema tracks these to emit warnings. - SmallVector<uint64_t, 16> UnusedLocalTypedefNameCandidates; + SmallVector<serialization::DeclID, 16> UnusedLocalTypedefNameCandidates; /// Our current depth in #pragma cuda force_host_device begin/end /// macros. @@ -836,18 +836,18 @@ private: /// The IDs of the declarations Sema stores directly. /// /// Sema tracks a few important decls, such as namespace std, directly. - SmallVector<uint64_t, 4> SemaDeclRefs; + SmallVector<serialization::DeclID, 4> SemaDeclRefs; /// The IDs of the types ASTContext stores directly. /// /// The AST context tracks a few important types, such as va_list, directly. - SmallVector<uint64_t, 16> SpecialTypes; + SmallVector<serialization::TypeID, 16> SpecialTypes; /// The IDs of CUDA-specific declarations ASTContext stores directly. /// /// The AST context tracks a few important decls, currently cudaConfigureCall, /// directly. - SmallVector<uint64_t, 2> CUDASpecialDeclRefs; + SmallVector<serialization::DeclID, 2> CUDASpecialDeclRefs; /// The floating point pragma option settings. SmallVector<uint64_t, 1> FPPragmaOptions; @@ -896,11 +896,11 @@ private: llvm::DenseMap<const Decl *, std::set<std::string>> OpenCLDeclExtMap; /// A list of the namespaces we've seen. - SmallVector<uint64_t, 4> KnownNamespaces; + SmallVector<serialization::DeclID, 4> KnownNamespaces; /// A list of undefined decls with internal linkage followed by the /// SourceLocation of a matching ODR-use. - SmallVector<uint64_t, 8> UndefinedButUsed; + SmallVector<serialization::DeclID, 8> UndefinedButUsed; /// Delete expressions to analyze at the end of translation unit. SmallVector<uint64_t, 8> DelayedDeleteExprs; @@ -912,8 +912,7 @@ private: /// The IDs of all decls to be checked for deferred diags. /// /// Sema tracks these to emit deferred diags. - SmallVector<uint64_t, 4> DeclsToCheckForDeferredDiags; - + llvm::SmallSetVector<serialization::DeclID, 4> DeclsToCheckForDeferredDiags; public: struct ImportedSubmodule { @@ -1402,6 +1401,9 @@ private: llvm::iterator_range<PreprocessingRecord::iterator> getModulePreprocessedEntities(ModuleFile &Mod) const; + bool canRecoverFromOutOfDate(StringRef ModuleFileName, + unsigned ClientLoadCapabilities); + public: class ModuleDeclIterator : public llvm::iterator_adaptor_base< @@ -1543,7 +1545,11 @@ public: /// The client can handle an AST file that cannot load because it's /// compiled configuration doesn't match that of the context it was /// loaded into. - ARR_ConfigurationMismatch = 0x8 + ARR_ConfigurationMismatch = 0x8, + + /// If a module file is marked with errors treat it as out-of-date so the + /// caller can rebuild it. + ARR_TreatModuleWithErrorsAsOutOfDate = 0x10 }; /// Load the AST file designated by the given file name. @@ -2012,7 +2018,7 @@ public: llvm::SmallSetVector<const TypedefNameDecl *, 4> &Decls) override; void ReadDeclsToCheckForDeferredDiags( - llvm::SmallVector<Decl *, 4> &Decls) override; + llvm::SmallSetVector<Decl *, 4> &Decls) override; void ReadReferencedSelectors( SmallVectorImpl<std::pair<Selector, SourceLocation>> &Sels) override; @@ -2133,12 +2139,15 @@ public: /// Read a source location from raw form and return it in its /// originating module file's source location space. - SourceLocation ReadUntranslatedSourceLocation(uint32_t Raw) const { - return SourceLocation::getFromRawEncoding((Raw >> 1) | (Raw << 31)); + SourceLocation + ReadUntranslatedSourceLocation(SourceLocation::UIntTy Raw) const { + return SourceLocation::getFromRawEncoding((Raw >> 1) | + (Raw << (8 * sizeof(Raw) - 1))); } /// Read a source location from raw form. - SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, uint32_t Raw) const { + SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, + SourceLocation::UIntTy Raw) const { SourceLocation Loc = ReadUntranslatedSourceLocation(Raw); return TranslateSourceLocation(ModuleFile, Loc); } @@ -2152,7 +2161,8 @@ public: assert(ModuleFile.SLocRemap.find(Loc.getOffset()) != ModuleFile.SLocRemap.end() && "Cannot find offset to remap."); - int Remap = ModuleFile.SLocRemap.find(Loc.getOffset())->second; + SourceLocation::IntTy Remap = + ModuleFile.SLocRemap.find(Loc.getOffset())->second; return Loc.getLocWithOffset(Remap); } diff --git a/clang/include/clang/Serialization/ASTWriter.h b/clang/include/clang/Serialization/ASTWriter.h index 12073a38a77a..ac88cb0a3177 100644 --- a/clang/include/clang/Serialization/ASTWriter.h +++ b/clang/include/clang/Serialization/ASTWriter.h @@ -84,7 +84,7 @@ class RecordDecl; class Sema; class SourceManager; class Stmt; -struct StoredDeclsList; +class StoredDeclsList; class SwitchCase; class TemplateParameterList; class Token; @@ -347,7 +347,7 @@ private: union { const Decl *Dcl; void *Type; - unsigned Loc; + SourceLocation::UIntTy Loc; unsigned Val; Module *Mod; const Attr *Attribute; @@ -402,8 +402,8 @@ private: /// headers. The declarations themselves are stored as declaration /// IDs, since they will be written out to an EAGERLY_DESERIALIZED_DECLS /// record. - SmallVector<uint64_t, 16> EagerlyDeserializedDecls; - SmallVector<uint64_t, 16> ModularCodegenDecls; + SmallVector<serialization::DeclID, 16> EagerlyDeserializedDecls; + SmallVector<serialization::DeclID, 16> ModularCodegenDecls; /// DeclContexts that have received extensions since their serialized /// form. @@ -450,7 +450,7 @@ private: /// A mapping from each known submodule to its ID number, which will /// be a positive integer. - llvm::DenseMap<Module *, unsigned> SubmoduleIDs; + llvm::DenseMap<const Module *, unsigned> SubmoduleIDs; /// A list of the module file extension writers. std::vector<std::unique_ptr<ModuleFileExtensionWriter>> @@ -510,8 +510,6 @@ private: void WriteDeclContextVisibleUpdate(const DeclContext *DC); void WriteFPPragmaOptions(const FPOptionsOverride &Opts); void WriteOpenCLExtensions(Sema &SemaRef); - void WriteOpenCLExtensionTypes(Sema &SemaRef); - void WriteOpenCLExtensionDecls(Sema &SemaRef); void WriteCUDAPragmas(Sema &SemaRef); void WriteObjCCategories(); void WriteLateParsedTemplates(Sema &SemaRef); @@ -673,7 +671,7 @@ public: /// Retrieve or create a submodule ID for this module, or return 0 if /// the submodule is neither local (a submodle of the currently-written module) /// nor from an imported module. - unsigned getLocalOrImportedSubmoduleID(Module *Mod); + unsigned getLocalOrImportedSubmoduleID(const Module *Mod); /// Note that the identifier II occurs at the given offset /// within the identifier table. diff --git a/clang/include/clang/Serialization/ModuleFile.h b/clang/include/clang/Serialization/ModuleFile.h index a641a26661ae..b1c8a8c8e72b 100644 --- a/clang/include/clang/Serialization/ModuleFile.h +++ b/clang/include/clang/Serialization/ModuleFile.h @@ -260,7 +260,7 @@ public: int SLocEntryBaseID = 0; /// The base offset in the source manager's view of this module. - unsigned SLocEntryBaseOffset = 0; + SourceLocation::UIntTy SLocEntryBaseOffset = 0; /// Base file offset for the offsets in SLocEntryOffsets. Real file offset /// for the entry is SLocEntryOffsetsBase + SLocEntryOffsets[i]. @@ -274,7 +274,8 @@ public: SmallVector<uint64_t, 4> PreloadSLocEntries; /// Remapping table for source locations in this module. - ContinuousRangeMap<uint32_t, int, 2> SLocRemap; + ContinuousRangeMap<SourceLocation::UIntTy, SourceLocation::IntTy, 2> + SLocRemap; // === Identifiers === @@ -298,7 +299,7 @@ public: /// /// This pointer points into a memory buffer, where the on-disk hash /// table for identifiers actually lives. - const char *IdentifierTableData = nullptr; + const unsigned char *IdentifierTableData = nullptr; /// A pointer to an on-disk hash table of opaque type /// IdentifierHashTable. diff --git a/clang/include/clang/Serialization/ModuleFileExtension.h b/clang/include/clang/Serialization/ModuleFileExtension.h index 63562c0d6bd2..34ea870724a4 100644 --- a/clang/include/clang/Serialization/ModuleFileExtension.h +++ b/clang/include/clang/Serialization/ModuleFileExtension.h @@ -10,6 +10,7 @@ #define LLVM_CLANG_SERIALIZATION_MODULEFILEEXTENSION_H #include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/Support/ExtensibleRTTI.h" #include <memory> #include <string> @@ -59,8 +60,14 @@ class ModuleFileExtensionWriter; /// compiled module files (.pcm) and precompiled headers (.pch) via a /// custom writer that can then be accessed via a custom reader when /// the module file or precompiled header is loaded. -class ModuleFileExtension { +/// +/// Subclasses must use LLVM RTTI for open class hierarchies. +class ModuleFileExtension + : public llvm::RTTIExtends<ModuleFileExtension, llvm::RTTIRoot> { public: + /// Discriminator for LLVM RTTI. + static char ID; + virtual ~ModuleFileExtension(); /// Retrieves the metadata for this module file extension. diff --git a/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h b/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h index 0f33909daec0..31a4ed50a723 100644 --- a/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h +++ b/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h @@ -65,7 +65,7 @@ public: } std::string VisitLocConcreteInt(loc::ConcreteInt V) { - llvm::APSInt I = V.getValue(); + const llvm::APSInt &I = V.getValue(); std::string Str; llvm::raw_string_ostream OS(Str); OS << "concrete memory address '" << I << "'"; @@ -77,7 +77,7 @@ public: } std::string VisitNonLocConcreteInt(nonloc::ConcreteInt V) { - llvm::APSInt I = V.getValue(); + const llvm::APSInt &I = V.getValue(); std::string Str; llvm::raw_string_ostream OS(Str); OS << (I.isSigned() ? "signed " : "unsigned ") << I.getBitWidth() diff --git a/clang/include/clang/StaticAnalyzer/Core/Analyses.def b/clang/include/clang/StaticAnalyzer/Core/Analyses.def index c4e5f5be6fd7..88c375ce0925 100644 --- a/clang/include/clang/StaticAnalyzer/Core/Analyses.def +++ b/clang/include/clang/StaticAnalyzer/Core/Analyses.def @@ -52,9 +52,14 @@ ANALYSIS_DIAGNOSTICS(PLIST_HTML, "plist-html", "Output analysis results using HTML wrapped with Plists", createPlistHTMLDiagnosticConsumer) -ANALYSIS_DIAGNOSTICS(SARIF, "sarif", "Output analysis results in a SARIF file", +ANALYSIS_DIAGNOSTICS(SARIF, "sarif", "Output analysis results using SARIF", createSarifDiagnosticConsumer) +ANALYSIS_DIAGNOSTICS(SARIF_HTML, "sarif-html", + "Output analysis results using both SARIF and HTML " + "output files", + createSarifHTMLDiagnosticConsumer) + ANALYSIS_DIAGNOSTICS(TEXT, "text", "Text output of analysis results to stderr", createTextPathDiagnosticConsumer) diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h index 27bc0dda1f1c..3c93ebeccde8 100644 --- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h +++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h @@ -432,6 +432,8 @@ public: void markInteresting(SymbolRef sym, bugreporter::TrackingKind TKind = bugreporter::TrackingKind::Thorough); + void markNotInteresting(SymbolRef sym); + /// Marks a region as interesting. Different kinds of interestingness will /// be processed differently by visitors (e.g. if the tracking kind is /// condition, will append "will be used as a condition" to the message). @@ -439,6 +441,8 @@ public: const MemRegion *R, bugreporter::TrackingKind TKind = bugreporter::TrackingKind::Thorough); + void markNotInteresting(const MemRegion *R); + /// Marks a symbolic value as interesting. Different kinds of interestingness /// will be processed differently by visitors (e.g. if the tracking kind is /// condition, will append "will be used as a condition" to the message). @@ -489,11 +493,16 @@ public: /// /// The visitors should be used when the default trace is not sufficient. /// For example, they allow constructing a more elaborate trace. - /// \sa registerConditionVisitor(), registerTrackNullOrUndefValue(), - /// registerFindLastStore(), registerNilReceiverVisitor(), and - /// registerVarDeclsLastStore(). + /// @{ void addVisitor(std::unique_ptr<BugReporterVisitor> visitor); + template <class VisitorType, class... Args> + void addVisitor(Args &&... ConstructorArgs) { + addVisitor( + std::make_unique<VisitorType>(std::forward<Args>(ConstructorArgs)...)); + } + /// @} + /// Remove all visitors attached to this bug report. void clearVisitors(); @@ -720,14 +729,43 @@ public: } }; +/// The tag that carries some information with it. +/// +/// It can be valuable to produce tags with some bits of information and later +/// reuse them for a better diagnostic. +/// +/// Please make sure that derived class' constuctor is private and that the user +/// can only create objects using DataTag::Factory. This also means that +/// DataTag::Factory should be friend for every derived class. +class DataTag : public ProgramPointTag { +public: + StringRef getTagDescription() const override { return "Data Tag"; } + + // Manage memory for DataTag objects. + class Factory { + std::vector<std::unique_ptr<DataTag>> Tags; + + public: + template <class DataTagType, class... Args> + const DataTagType *make(Args &&... ConstructorArgs) { + // We cannot use std::make_unique because we cannot access the private + // constructor from inside it. + Tags.emplace_back( + new DataTagType(std::forward<Args>(ConstructorArgs)...)); + return static_cast<DataTagType *>(Tags.back().get()); + } + }; + +protected: + DataTag(void *TagKind) : ProgramPointTag(TagKind) {} +}; /// The tag upon which the TagVisitor reacts. Add these in order to display /// additional PathDiagnosticEventPieces along the path. -class NoteTag : public ProgramPointTag { +class NoteTag : public DataTag { public: - using Callback = - std::function<std::string(BugReporterContext &, - PathSensitiveBugReport &)>; + using Callback = std::function<std::string(BugReporterContext &, + PathSensitiveBugReport &)>; private: static int Kind; @@ -736,7 +774,7 @@ private: const bool IsPrunable; NoteTag(Callback &&Cb, bool IsPrunable) - : ProgramPointTag(&Kind), Cb(std::move(Cb)), IsPrunable(IsPrunable) {} + : DataTag(&Kind), Cb(std::move(Cb)), IsPrunable(IsPrunable) {} public: static bool classof(const ProgramPointTag *T) { @@ -761,20 +799,7 @@ public: bool isPrunable() const { return IsPrunable; } - // Manage memory for NoteTag objects. - class Factory { - std::vector<std::unique_ptr<NoteTag>> Tags; - - public: - const NoteTag *makeNoteTag(Callback &&Cb, bool IsPrunable = false) { - // We cannot use std::make_unique because we cannot access the private - // constructor from inside it. - std::unique_ptr<NoteTag> T(new NoteTag(std::move(Cb), IsPrunable)); - Tags.push_back(std::move(T)); - return Tags.back().get(); - } - }; - + friend class Factory; friend class TagVisitor; }; diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h index 58a88f452ed9..24cae12af24a 100644 --- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h +++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h @@ -19,9 +19,12 @@ #include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h" #include "llvm/ADT/FoldingSet.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" +#include <list> #include <memory> +#include <utility> namespace clang { @@ -93,74 +96,293 @@ enum class TrackingKind { /// gathered about the tracked expression value as possible. Thorough, /// Specifies that a more moderate tracking should be used for the expression - /// value. This will essentially make sure that functions relevant to the it + /// value. This will essentially make sure that functions relevant to it /// aren't pruned, but otherwise relies on the user reading the code or /// following the arrows. Condition }; -/// Attempts to add visitors to track expression value back to its point of -/// origin. -/// -/// \param N A node "downstream" from the evaluation of the statement. -/// \param E The expression value which we are tracking -/// \param R The bug report to which visitors should be attached. -/// \param EnableNullFPSuppression Whether we should employ false positive -/// suppression (inlined defensive checks, returned null). +/// Defines a set of options altering tracking behavior. +struct TrackingOptions { + /// Specifies the kind of tracking. + TrackingKind Kind = TrackingKind::Thorough; + /// Specifies whether we should employ false positive suppression + /// (inlined defensive checks, returned null). + bool EnableNullFPSuppression = true; +}; + +/// Describes an event when the value got stored into a memory region. /// -/// \return Whether or not the function was able to add visitors for this -/// statement. Note that returning \c true does not actually imply -/// that any visitors were added. -bool trackExpressionValue(const ExplodedNode *N, const Expr *E, - PathSensitiveBugReport &R, - TrackingKind TKind = TrackingKind::Thorough, - bool EnableNullFPSuppression = true); +/// As opposed to checker checkBind API, it reacts also to binds +/// generated by the checker as well. It can be useful when the binding +/// happened as a result of evalCall, for example. +struct StoreInfo { + enum Kind { + /// The value got stored into the region during initialization: + /// int x = 42; + Initialization, + /// The value got stored into the region during assignment: + /// int x; + /// x = 42; + Assignment, + /// The value got stored into the parameter region as the result + /// of a call. + CallArgument, + /// The value got stored into the region as block capture. + /// Block data is modeled as a separate region, thus whenever + /// the analyzer sees a captured variable, its value is copied + /// into a special block region. + BlockCapture + }; + + /// The type of store operation. + Kind StoreKind; + /// The node where the store happened. + const ExplodedNode *StoreSite; + /// The expression where the value comes from. + /// NOTE: might be null. + const Expr *SourceOfTheValue; + /// Symbolic value that is being stored. + SVal Value; + /// Memory regions involved in the store operation. + /// Dest <- Origin + /// NOTE: Origin might be null, when the stored value doesn't come + /// from another region. + const MemRegion *Dest, *Origin; +}; -const Expr *getDerefExpr(const Stmt *S); +class Tracker; +using TrackerRef = llvm::IntrusiveRefCntPtr<Tracker>; -} // namespace bugreporter +class ExpressionHandler; +class StoreHandler; -/// Finds last store into the given region, -/// which is different from a given symbolic value. -class FindLastStoreBRVisitor final : public BugReporterVisitor { - const MemRegion *R; - SVal V; - bool Satisfied = false; +/// A generalized component for tracking expressions, values, and stores. +/// +/// Tracker aimes at providing a sensible set of default behaviors that can be +/// used by any checker, while providing mechanisms to hook into any part of the +/// tracking process and insert checker-specific logic. +class Tracker : public llvm::RefCountedBase<Tracker> { +private: + using ExpressionHandlerPtr = std::unique_ptr<ExpressionHandler>; + using StoreHandlerPtr = std::unique_ptr<StoreHandler>; - /// If the visitor is tracking the value directly responsible for the - /// bug, we are going to employ false positive suppression. - bool EnableNullFPSuppression; + PathSensitiveBugReport &Report; + std::list<ExpressionHandlerPtr> ExpressionHandlers; + std::list<StoreHandlerPtr> StoreHandlers; - using TrackingKind = bugreporter::TrackingKind; - TrackingKind TKind; - const StackFrameContext *OriginSFC; +protected: + /// \param Report The bug report to which visitors should be attached. + Tracker(PathSensitiveBugReport &Report); public: + virtual ~Tracker() = default; + + static TrackerRef create(PathSensitiveBugReport &Report) { + return new Tracker(Report); + } + + PathSensitiveBugReport &getReport() { return Report; } + + /// Describes a tracking result with the most basic information of what was + /// actually done (or not done). + struct Result { + /// Usually it means that the tracker added visitors. + bool FoundSomethingToTrack = false; + /// Signifies that the tracking was interrupted at some point. + /// Usually this information is important only for sub-trackers. + bool WasInterrupted = false; + + /// Combines the current result with the given result. + void combineWith(const Result &Other) { + // If we found something in one of the cases, we can + // say we found something overall. + FoundSomethingToTrack |= Other.FoundSomethingToTrack; + // The same goes to the interruption. + WasInterrupted |= Other.WasInterrupted; + } + }; + + /// Track expression value back to its point of origin. + /// + /// \param E The expression value which we are tracking + /// \param N A node "downstream" from the evaluation of the statement. + /// \param Opts Tracking options specifying how we want to track the value. + virtual Result track(const Expr *E, const ExplodedNode *N, + TrackingOptions Opts = {}); + + /// Track how the value got stored into the given region and where it came + /// from. + /// /// \param V We're searching for the store where \c R received this value. /// \param R The region we're tracking. - /// \param TKind May limit the amount of notes added to the bug report. - /// \param OriginSFC Only adds notes when the last store happened in a + /// \param Opts Tracking options specifying how we want to track the value. + /// \param Origin Only adds notes when the last store happened in a /// different stackframe to this one. Disregarded if the tracking kind /// is thorough. /// This is useful, because for non-tracked regions, notes about /// changes to its value in a nested stackframe could be pruned, and /// this visitor can prevent that without polluting the bugpath too /// much. - FindLastStoreBRVisitor(KnownSVal V, const MemRegion *R, - bool InEnableNullFPSuppression, TrackingKind TKind, - const StackFrameContext *OriginSFC = nullptr) - : R(R), V(V), EnableNullFPSuppression(InEnableNullFPSuppression), - TKind(TKind), OriginSFC(OriginSFC) { - assert(R); + virtual Result track(SVal V, const MemRegion *R, TrackingOptions Opts = {}, + const StackFrameContext *Origin = nullptr); + + /// Handle the store operation and produce the note. + /// + /// \param SI The information fully describing the store. + /// \param Opts Tracking options specifying how we got to it. + /// + /// NOTE: this method is designed for sub-trackers and visitors. + virtual PathDiagnosticPieceRef handle(StoreInfo SI, BugReporterContext &BRC, + TrackingOptions Opts); + + /// Add custom expression handler with the highest priority. + /// + /// It means that it will be asked for handling first, and can prevent + /// other handlers from running if decides to interrupt. + void addHighPriorityHandler(ExpressionHandlerPtr SH) { + ExpressionHandlers.push_front(std::move(SH)); } - void Profile(llvm::FoldingSetNodeID &ID) const override; + /// Add custom expression handler with the lowest priority. + /// + /// It means that it will be asked for handling last, and other handlers can + /// prevent it from running if any of them decides to interrupt. + void addLowPriorityHandler(ExpressionHandlerPtr SH) { + ExpressionHandlers.push_back(std::move(SH)); + } - PathDiagnosticPieceRef VisitNode(const ExplodedNode *N, - BugReporterContext &BRC, - PathSensitiveBugReport &BR) override; + /// Add custom store handler with the highest priority. + /// + /// It means that it will be asked for handling first, and will prevent + /// other handlers from running if it produces non-null note. + void addHighPriorityHandler(StoreHandlerPtr SH) { + StoreHandlers.push_front(std::move(SH)); + } + + /// Add custom store handler with the lowest priority. + /// + /// It means that it will be asked for handling last, only + /// if all other handlers failed to produce the note. + void addLowPriorityHandler(StoreHandlerPtr SH) { + StoreHandlers.push_back(std::move(SH)); + } + + /// Add custom expression/store handler with the highest priority + /// + /// See other overloads for explanation. + template <class HandlerType, class... Args> + void addHighPriorityHandler(Args &&... ConstructorArgs) { + addHighPriorityHandler(std::make_unique<HandlerType>( + *this, std::forward<Args>(ConstructorArgs)...)); + } + + /// Add custom expression/store handler with the lowest priority + /// + /// See other overloads for explanation. + template <class HandlerType, class... Args> + void addLowPriorityHandler(Args &&... ConstructorArgs) { + addLowPriorityHandler(std::make_unique<HandlerType>( + *this, std::forward<Args>(ConstructorArgs)...)); + } +}; + +/// Handles expressions during the tracking. +class ExpressionHandler { +private: + Tracker &ParentTracker; + +public: + ExpressionHandler(Tracker &ParentTracker) : ParentTracker(ParentTracker) {} + virtual ~ExpressionHandler() {} + + /// Handle the given expression from the given node. + /// + /// \param E The expression value which we are tracking + /// \param Original A node "downstream" where the tracking started. + /// \param ExprNode A node where the evaluation of \c E actually happens. + /// \param Opts Tracking options specifying how we are tracking the value. + virtual Tracker::Result handle(const Expr *E, const ExplodedNode *Original, + const ExplodedNode *ExprNode, + TrackingOptions Opts) = 0; + + /// \Return the tracker that initiated the process. + Tracker &getParentTracker() { return ParentTracker; } +}; + +/// Handles stores during the tracking. +class StoreHandler { +private: + Tracker &ParentTracker; + +public: + StoreHandler(Tracker &ParentTracker) : ParentTracker(ParentTracker) {} + virtual ~StoreHandler() {} + + /// Handle the given store and produce the node. + /// + /// \param SI The information fully describing the store. + /// \param Opts Tracking options specifying how we are tracking the value. + /// + /// \return the produced note, null if the handler doesn't support this kind + /// of stores. + virtual PathDiagnosticPieceRef handle(StoreInfo SI, BugReporterContext &BRC, + TrackingOptions Opts) = 0; + + Tracker &getParentTracker() { return ParentTracker; } + +protected: + PathDiagnosticPieceRef constructNote(StoreInfo SI, BugReporterContext &BRC, + StringRef NodeText); }; +/// Visitor that tracks expressions and values. +class TrackingBugReporterVisitor : public BugReporterVisitor { +private: + TrackerRef ParentTracker; + +public: + TrackingBugReporterVisitor(TrackerRef ParentTracker) + : ParentTracker(ParentTracker) {} + + Tracker &getParentTracker() { return *ParentTracker; } +}; + +/// Attempts to add visitors to track expression value back to its point of +/// origin. +/// +/// \param N A node "downstream" from the evaluation of the statement. +/// \param E The expression value which we are tracking +/// \param R The bug report to which visitors should be attached. +/// \param Opts Tracking options specifying how we are tracking the value. +/// +/// \return Whether or not the function was able to add visitors for this +/// statement. Note that returning \c true does not actually imply +/// that any visitors were added. +bool trackExpressionValue(const ExplodedNode *N, const Expr *E, + PathSensitiveBugReport &R, TrackingOptions Opts = {}); + +/// Track how the value got stored into the given region and where it came +/// from. +/// +/// \param V We're searching for the store where \c R received this value. +/// \param R The region we're tracking. +/// \param Opts Tracking options specifying how we want to track the value. +/// \param Origin Only adds notes when the last store happened in a +/// different stackframe to this one. Disregarded if the tracking kind +/// is thorough. +/// This is useful, because for non-tracked regions, notes about +/// changes to its value in a nested stackframe could be pruned, and +/// this visitor can prevent that without polluting the bugpath too +/// much. +void trackStoredValue(KnownSVal V, const MemRegion *R, + PathSensitiveBugReport &Report, TrackingOptions Opts = {}, + const StackFrameContext *Origin = nullptr); + +const Expr *getDerefExpr(const Stmt *S); + +} // namespace bugreporter + class TrackConstraintBRVisitor final : public BugReporterVisitor { DefinedSVal Constraint; bool Assumption; diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h index 637b89fd9036..392bc484bf62 100644 --- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h +++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h @@ -19,7 +19,9 @@ extern const char *const MemoryRefCount; extern const char *const MemoryError; extern const char *const UnixAPI; extern const char *const CXXObjectLifecycle; +extern const char *const CXXMoveSemantics; extern const char *const SecurityError; +extern const char *const UnusedCode; } // namespace categories } // namespace ento } // namespace clang diff --git a/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h b/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h index f40f88eb32ff..71a590d9e9a2 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h @@ -21,7 +21,9 @@ namespace clang { class AnalyzerOptions; +class MacroExpansionContext; class Preprocessor; + namespace cross_tu { class CrossTranslationUnitContext; } @@ -35,7 +37,8 @@ typedef std::vector<PathDiagnosticConsumer*> PathDiagnosticConsumers; void CREATEFN(PathDiagnosticConsumerOptions Diagopts, \ PathDiagnosticConsumers &C, const std::string &Prefix, \ const Preprocessor &PP, \ - const cross_tu::CrossTranslationUnitContext &CTU); + const cross_tu::CrossTranslationUnitContext &CTU, \ + const MacroExpansionContext &MacroExpansions); #include "clang/StaticAnalyzer/Core/Analyses.def" } // end 'ento' namespace diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h index 142b1ab11750..bb598af68166 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h @@ -52,6 +52,8 @@ public: iterator begin() const { return L.begin(); } iterator end() const { return L.end(); } + QualType getType() const { return T; } + static void Profile(llvm::FoldingSetNodeID& ID, QualType T, llvm::ImmutableList<SVal> L); @@ -139,6 +141,12 @@ public: /// Returns the type of the APSInt used to store values of the given QualType. APSIntType getAPSIntType(QualType T) const { + // For the purposes of the analysis and constraints, we treat atomics + // as their underlying types. + if (const AtomicType *AT = T->getAs<AtomicType>()) { + T = AT->getValueType(); + } + assert(T->isIntegralOrEnumerationType() || Loc::isLocType(T)); return APSIntType(Ctx.getIntWidth(T), !T->isSignedIntegerOrEnumerationType()); @@ -258,9 +266,9 @@ public: return CXXBaseListFactory.add(CBS, L); } - const PointerToMemberData *accumCXXBase( - llvm::iterator_range<CastExpr::path_const_iterator> PathRange, - const nonloc::PointerToMember &PTM); + const PointerToMemberData * + accumCXXBase(llvm::iterator_range<CastExpr::path_const_iterator> PathRange, + const nonloc::PointerToMember &PTM, const clang::CastKind &kind); const llvm::APSInt* evalAPSInt(BinaryOperator::Opcode Op, const llvm::APSInt& V1, diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h index 54572bd81f20..a383012dc351 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h @@ -255,7 +255,7 @@ public: /// to omit the note from the report if it would make the displayed /// bug path significantly shorter. const NoteTag *getNoteTag(NoteTag::Callback &&Cb, bool IsPrunable = false) { - return Eng.getNoteTags().makeNoteTag(std::move(Cb), IsPrunable); + return Eng.getDataTags().make<NoteTag>(std::move(Cb), IsPrunable); } /// A shorthand version of getNoteTag that doesn't require you to accept diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h index f253c14cc487..a81d67ab3063 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h @@ -13,7 +13,9 @@ #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CHECKERHELPERS_H #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CHECKERHELPERS_H +#include "clang/AST/OperationKinds.h" #include "clang/AST/Stmt.h" +#include "clang/Basic/OperatorKinds.h" #include "llvm/ADT/Optional.h" #include <tuple> @@ -69,6 +71,45 @@ Nullability getNullabilityAnnotation(QualType Type); /// token for an integer. If we cannot parse the value then None is returned. llvm::Optional<int> tryExpandAsInteger(StringRef Macro, const Preprocessor &PP); +class OperatorKind { + union { + BinaryOperatorKind Bin; + UnaryOperatorKind Un; + } Op; + bool IsBinary; + +public: + explicit OperatorKind(BinaryOperatorKind Bin) : Op{Bin}, IsBinary{true} {} + explicit OperatorKind(UnaryOperatorKind Un) : IsBinary{false} { Op.Un = Un; } + bool IsBinaryOp() const { return IsBinary; } + + BinaryOperatorKind GetBinaryOpUnsafe() const { + assert(IsBinary && "cannot get binary operator - we have a unary operator"); + return Op.Bin; + } + + Optional<BinaryOperatorKind> GetBinaryOp() const { + if (IsBinary) + return Op.Bin; + return {}; + } + + UnaryOperatorKind GetUnaryOpUnsafe() const { + assert(!IsBinary && + "cannot get unary operator - we have a binary operator"); + return Op.Un; + } + + Optional<UnaryOperatorKind> GetUnaryOp() const { + if (!IsBinary) + return Op.Un; + return {}; + } +}; + +OperatorKind operationKindFromOverloadedOperator(OverloadedOperatorKind OOK, + bool IsBinary); + } // namespace ento } // namespace clang diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h index 2aca2c99ef4f..9898b9b42f4b 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h @@ -96,9 +96,10 @@ private: /// (This data is owned by AnalysisConsumer.) FunctionSummariesTy *FunctionSummaries; - /// Add path note tags along the path when we see that something interesting - /// is happening. This field is the allocator for such tags. - NoteTag::Factory NoteTags; + /// Add path tags with some useful data along the path when we see that + /// something interesting is happening. This field is the allocator for such + /// tags. + DataTag::Factory DataTags; void generateNode(const ProgramPoint &Loc, ProgramStateRef State, @@ -200,7 +201,7 @@ public: /// Enqueue a single node created as a result of statement processing. void enqueueStmtNode(ExplodedNode *N, const CFGBlock *Block, unsigned Idx); - NoteTag::Factory &getNoteTags() { return NoteTags; } + DataTag::Factory &getDataTags() { return DataTags; } }; // TODO: Turn into a class. diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicExtent.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicExtent.h new file mode 100644 index 000000000000..cfd7aa9664b6 --- /dev/null +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicExtent.h @@ -0,0 +1,59 @@ +//===- DynamicExtent.h - Dynamic extent related APIs ------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines APIs that track and query dynamic extent information. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICEXTENT_H +#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICEXTENT_H + +#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h" + +namespace clang { +namespace ento { + +/// \returns The stored dynamic extent for the region \p MR. +DefinedOrUnknownSVal getDynamicExtent(ProgramStateRef State, + const MemRegion *MR, SValBuilder &SVB); + +/// \returns The element extent of the type \p Ty. +DefinedOrUnknownSVal getElementExtent(QualType Ty, SValBuilder &SVB); + +/// \returns The stored element count of the region \p MR. +DefinedOrUnknownSVal getDynamicElementCount(ProgramStateRef State, + const MemRegion *MR, + SValBuilder &SVB, QualType Ty); + +/// Set the dynamic extent \p Extent of the region \p MR. +ProgramStateRef setDynamicExtent(ProgramStateRef State, const MemRegion *MR, + DefinedOrUnknownSVal Extent, SValBuilder &SVB); + +/// Get the dynamic extent for a symbolic value that represents a buffer. If +/// there is an offsetting to the underlying buffer we consider that too. +/// Returns with an SVal that represents the extent, this is Unknown if the +/// engine cannot deduce the extent. +/// E.g. +/// char buf[3]; +/// (buf); // extent is 3 +/// (buf + 1); // extent is 2 +/// (buf + 3); // extent is 0 +/// (buf + 4); // extent is -1 +/// +/// char *bufptr; +/// (bufptr) // extent is unknown +SVal getDynamicExtentWithOffset(ProgramStateRef State, SVal BufV); + +} // namespace ento +} // namespace clang + +#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICEXTENT_H diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h deleted file mode 100644 index 398f9b6ac33a..000000000000 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h +++ /dev/null @@ -1,53 +0,0 @@ -//===- DynamicSize.h - Dynamic size related APIs ----------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file defines APIs that track and query dynamic size information. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICSIZE_H -#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICSIZE_H - -#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h" - -namespace clang { -namespace ento { - -/// Get the stored dynamic size for the region \p MR. -DefinedOrUnknownSVal getDynamicSize(ProgramStateRef State, const MemRegion *MR, - SValBuilder &SVB); - -/// Get the stored element count of the region \p MR. -DefinedOrUnknownSVal getDynamicElementCount(ProgramStateRef State, - const MemRegion *MR, - SValBuilder &SVB, - QualType ElementTy); - -/// Get the dynamic size for a symbolic value that represents a buffer. If -/// there is an offsetting to the underlying buffer we consider that too. -/// Returns with an SVal that represents the size, this is Unknown if the -/// engine cannot deduce the size. -/// E.g. -/// char buf[3]; -/// (buf); // size is 3 -/// (buf + 1); // size is 2 -/// (buf + 3); // size is 0 -/// (buf + 4); // size is -1 -/// -/// char *bufptr; -/// (bufptr) // size is unknown -SVal getDynamicSizeWithOffset(ProgramStateRef State, const SVal &BufV); - -} // namespace ento -} // namespace clang - -#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICSIZE_H diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h index 2679339537e8..ffe1fe846be1 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h @@ -24,7 +24,6 @@ #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h" #include "llvm/ADT/ImmutableMap.h" #include "llvm/ADT/Optional.h" -#include <utility> namespace clang { namespace ento { diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h index 582a56cbee1e..cef7dda172f3 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h @@ -428,8 +428,7 @@ public: SymbolManager &getSymbolManager() { return SymMgr; } MemRegionManager &getRegionManager() { return MRMgr; } - NoteTag::Factory &getNoteTags() { return Engine.getNoteTags(); } - + DataTag::Factory &getDataTags() { return Engine.getDataTags(); } // Functions for external checking of whether we have unfinished work bool wasBlocksExhausted() const { return Engine.wasBlocksExhausted(); } diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h index d25d26435454..53b221cb53c9 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -/// +/// \file /// This header contains the declarations of functions which are used to decide /// which loops should be completely unrolled and mark their corresponding /// CFGBlocks. It is done by tracking a stack of loops in the ProgramState. This @@ -18,7 +18,6 @@ /// has to be initialized by a literal in the corresponding initStmt. /// - Does not contain goto, switch and returnStmt. /// -/// //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPUNROLLING_H diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h index 7484a51b1eda..e75228f92a8e 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -/// +/// \file /// This header contains the declarations of functions which are used to widen /// loops which do not otherwise exit. The widening is done by invalidating /// anything which might be modified by the body of the loop. diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h index bc5d5f57cd68..c67df1e51b4f 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h @@ -16,6 +16,8 @@ #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h" +#include "llvm/ADT/APSInt.h" +#include "llvm/Support/Allocator.h" namespace clang { @@ -24,21 +26,19 @@ namespace ento { /// A Range represents the closed range [from, to]. The caller must /// guarantee that from <= to. Note that Range is immutable, so as not /// to subvert RangeSet's immutability. -class Range : public std::pair<const llvm::APSInt *, const llvm::APSInt *> { +class Range { public: - Range(const llvm::APSInt &from, const llvm::APSInt &to) - : std::pair<const llvm::APSInt *, const llvm::APSInt *>(&from, &to) { - assert(from <= to); + Range(const llvm::APSInt &From, const llvm::APSInt &To) : Impl(&From, &To) { + assert(From <= To); } - Range(const llvm::APSInt &point) - : std::pair<const llvm::APSInt *, const llvm::APSInt *>(&point, &point) {} + Range(const llvm::APSInt &Point) : Range(Point, Point) {} - bool Includes(const llvm::APSInt &v) const { - return *first <= v && v <= *second; + bool Includes(const llvm::APSInt &Point) const { + return From() <= Point && Point <= To(); } - const llvm::APSInt &From() const { return *first; } - const llvm::APSInt &To() const { return *second; } + const llvm::APSInt &From() const { return *Impl.first; } + const llvm::APSInt &To() const { return *Impl.second; } const llvm::APSInt *getConcreteValue() const { return &From() == &To() ? &From() : nullptr; } @@ -47,93 +47,267 @@ public: ID.AddPointer(&From()); ID.AddPointer(&To()); } -}; + void dump(raw_ostream &OS) const; -class RangeTrait : public llvm::ImutContainerInfo<Range> { -public: - // When comparing if one Range is less than another, we should compare - // the actual APSInt values instead of their pointers. This keeps the order - // consistent (instead of comparing by pointer values) and can potentially - // be used to speed up some of the operations in RangeSet. - static inline bool isLess(key_type_ref lhs, key_type_ref rhs) { - return *lhs.first < *rhs.first || - (!(*rhs.first < *lhs.first) && *lhs.second < *rhs.second); - } + // In order to keep non-overlapping ranges sorted, we can compare only From + // points. + bool operator<(const Range &RHS) const { return From() < RHS.From(); } + + bool operator==(const Range &RHS) const { return Impl == RHS.Impl; } + bool operator!=(const Range &RHS) const { return !operator==(RHS); } + +private: + std::pair<const llvm::APSInt *, const llvm::APSInt *> Impl; }; -/// RangeSet contains a set of ranges. If the set is empty, then -/// there the value of a symbol is overly constrained and there are no -/// possible values for that symbol. +/// @class RangeSet is a persistent set of non-overlapping ranges. +/// +/// New RangeSet objects can be ONLY produced by RangeSet::Factory object, which +/// also supports the most common operations performed on range sets. +/// +/// Empty set corresponds to an overly constrained symbol meaning that there +/// are no possible values for that symbol. class RangeSet { - typedef llvm::ImmutableSet<Range, RangeTrait> PrimRangeSet; - PrimRangeSet ranges; // no need to make const, since it is an - // ImmutableSet - this allows default operator= - // to work. public: - typedef PrimRangeSet::Factory Factory; - typedef PrimRangeSet::iterator iterator; - - RangeSet(PrimRangeSet RS) : ranges(RS) {} - - /// Create a new set with all ranges of this set and RS. - /// Possible intersections are not checked here. - RangeSet addRange(Factory &F, const RangeSet &RS) { - PrimRangeSet Ranges(RS.ranges); - for (const auto &range : ranges) - Ranges = F.add(Ranges, range); - return RangeSet(Ranges); - } - - iterator begin() const { return ranges.begin(); } - iterator end() const { return ranges.end(); } + class Factory; - bool isEmpty() const { return ranges.isEmpty(); } +private: + // We use llvm::SmallVector as the underlying container for the following + // reasons: + // + // * Range sets are usually very simple, 1 or 2 ranges. + // That's why llvm::ImmutableSet is not perfect. + // + // * Ranges in sets are NOT overlapping, so it is natural to keep them + // sorted for efficient operations and queries. For this reason, + // llvm::SmallSet doesn't fit the requirements, it is not sorted when it + // is a vector. + // + // * Range set operations usually a bit harder than add/remove a range. + // Complex operations might do many of those for just one range set. + // Formerly it used to be llvm::ImmutableSet, which is inefficient for our + // purposes as we want to make these operations BOTH immutable AND + // efficient. + // + // * Iteration over ranges is widespread and a more cache-friendly + // structure is preferred. + using ImplType = llvm::SmallVector<Range, 4>; + + struct ContainerType : public ImplType, public llvm::FoldingSetNode { + void Profile(llvm::FoldingSetNodeID &ID) const { + for (const Range &It : *this) { + It.Profile(ID); + } + } + }; + // This is a non-owning pointer to an actual container. + // The memory is fully managed by the factory and is alive as long as the + // factory itself is alive. + // It is a pointer as opposed to a reference, so we can easily reassign + // RangeSet objects. + using UnderlyingType = const ContainerType *; + UnderlyingType Impl; - /// Construct a new RangeSet representing '{ [from, to] }'. - RangeSet(Factory &F, const llvm::APSInt &from, const llvm::APSInt &to) - : ranges(F.add(F.getEmptySet(), Range(from, to))) {} +public: + using const_iterator = ImplType::const_iterator; + + const_iterator begin() const { return Impl->begin(); } + const_iterator end() const { return Impl->end(); } + size_t size() const { return Impl->size(); } + + bool isEmpty() const { return Impl->empty(); } + + class Factory { + public: + Factory(BasicValueFactory &BV) : ValueFactory(BV) {} + + /// Create a new set with all ranges from both LHS and RHS. + /// Possible intersections are not checked here. + /// + /// Complexity: O(N + M) + /// where N = size(LHS), M = size(RHS) + RangeSet add(RangeSet LHS, RangeSet RHS); + /// Create a new set with all ranges from the original set plus the new one. + /// Possible intersections are not checked here. + /// + /// Complexity: O(N) + /// where N = size(Original) + RangeSet add(RangeSet Original, Range Element); + /// Create a new set with all ranges from the original set plus the point. + /// Possible intersections are not checked here. + /// + /// Complexity: O(N) + /// where N = size(Original) + RangeSet add(RangeSet Original, const llvm::APSInt &Point); + + RangeSet getEmptySet() { return &EmptySet; } + + /// Create a new set with just one range. + /// @{ + RangeSet getRangeSet(Range Origin); + RangeSet getRangeSet(const llvm::APSInt &From, const llvm::APSInt &To) { + return getRangeSet(Range(From, To)); + } + RangeSet getRangeSet(const llvm::APSInt &Origin) { + return getRangeSet(Origin, Origin); + } + /// @} + + /// Intersect the given range sets. + /// + /// Complexity: O(N + M) + /// where N = size(LHS), M = size(RHS) + RangeSet intersect(RangeSet LHS, RangeSet RHS); + /// Intersect the given set with the closed range [Lower, Upper]. + /// + /// Unlike the Range type, this range uses modular arithmetic, corresponding + /// to the common treatment of C integer overflow. Thus, if the Lower bound + /// is greater than the Upper bound, the range is taken to wrap around. This + /// is equivalent to taking the intersection with the two ranges [Min, + /// Upper] and [Lower, Max], or, alternatively, /removing/ all integers + /// between Upper and Lower. + /// + /// Complexity: O(N) + /// where N = size(What) + RangeSet intersect(RangeSet What, llvm::APSInt Lower, llvm::APSInt Upper); + /// Intersect the given range with the given point. + /// + /// The result can be either an empty set or a set containing the given + /// point depending on whether the point is in the range set. + /// + /// Complexity: O(logN) + /// where N = size(What) + RangeSet intersect(RangeSet What, llvm::APSInt Point); + + /// Delete the given point from the range set. + /// + /// Complexity: O(N) + /// where N = size(From) + RangeSet deletePoint(RangeSet From, const llvm::APSInt &Point); + /// Negate the given range set. + /// + /// Turn all [A, B] ranges to [-B, -A], when "-" is a C-like unary minus + /// operation under the values of the type. + /// + /// We also handle MIN because applying unary minus to MIN does not change + /// it. + /// Example 1: + /// char x = -128; // -128 is a MIN value in a range of 'char' + /// char y = -x; // y: -128 + /// + /// Example 2: + /// unsigned char x = 0; // 0 is a MIN value in a range of 'unsigned char' + /// unsigned char y = -x; // y: 0 + /// + /// And it makes us to separate the range + /// like [MIN, N] to [MIN, MIN] U [-N, MAX]. + /// For instance, whole range is {-128..127} and subrange is [-128,-126], + /// thus [-128,-127,-126,...] negates to [-128,...,126,127]. + /// + /// Negate restores disrupted ranges on bounds, + /// e.g. [MIN, B] => [MIN, MIN] U [-B, MAX] => [MIN, B]. + /// + /// Negate is a self-inverse function, i.e. negate(negate(R)) == R. + /// + /// Complexity: O(N) + /// where N = size(What) + RangeSet negate(RangeSet What); + + /// Return associated value factory. + BasicValueFactory &getValueFactory() const { return ValueFactory; } + + private: + /// Return a persistent version of the given container. + RangeSet makePersistent(ContainerType &&From); + /// Construct a new persistent version of the given container. + ContainerType *construct(ContainerType &&From); + + RangeSet intersect(const ContainerType &LHS, const ContainerType &RHS); + + // Many operations include producing new APSInt values and that's why + // we need this factory. + BasicValueFactory &ValueFactory; + // Allocator for all the created containers. + // Containers might own their own memory and that's why it is specific + // for the type, so it calls container destructors upon deletion. + llvm::SpecificBumpPtrAllocator<ContainerType> Arena; + // Usually we deal with the same ranges and range sets over and over. + // Here we track all created containers and try not to repeat ourselves. + llvm::FoldingSet<ContainerType> Cache; + static ContainerType EmptySet; + }; + + RangeSet(const RangeSet &) = default; + RangeSet &operator=(const RangeSet &) = default; + RangeSet(RangeSet &&) = default; + RangeSet &operator=(RangeSet &&) = default; + ~RangeSet() = default; + + /// Construct a new RangeSet representing '{ [From, To] }'. + RangeSet(Factory &F, const llvm::APSInt &From, const llvm::APSInt &To) + : RangeSet(F.getRangeSet(From, To)) {} /// Construct a new RangeSet representing the given point as a range. - RangeSet(Factory &F, const llvm::APSInt &point) : RangeSet(F, point, point) {} + RangeSet(Factory &F, const llvm::APSInt &Point) + : RangeSet(F.getRangeSet(Point)) {} + + static void Profile(llvm::FoldingSetNodeID &ID, const RangeSet &RS) { + ID.AddPointer(RS.Impl); + } /// Profile - Generates a hash profile of this RangeSet for use /// by FoldingSet. - void Profile(llvm::FoldingSetNodeID &ID) const { ranges.Profile(ID); } + void Profile(llvm::FoldingSetNodeID &ID) const { Profile(ID, *this); } - /// getConcreteValue - If a symbol is contrained to equal a specific integer + /// getConcreteValue - If a symbol is constrained to equal a specific integer /// constant then this method returns that value. Otherwise, it returns /// NULL. const llvm::APSInt *getConcreteValue() const { - return ranges.isSingleton() ? ranges.begin()->getConcreteValue() : nullptr; + return Impl->size() == 1 ? begin()->getConcreteValue() : nullptr; } - /// Get a minimal value covered by the ranges in the set + /// Get the minimal value covered by the ranges in the set. + /// + /// Complexity: O(1) const llvm::APSInt &getMinValue() const; - /// Get a maximal value covered by the ranges in the set + /// Get the maximal value covered by the ranges in the set. + /// + /// Complexity: O(1) const llvm::APSInt &getMaxValue() const; -private: - void IntersectInRange(BasicValueFactory &BV, Factory &F, - const llvm::APSInt &Lower, const llvm::APSInt &Upper, - PrimRangeSet &newRanges, PrimRangeSet::iterator &i, - PrimRangeSet::iterator &e) const; + /// Test whether the given point is contained by any of the ranges. + /// + /// Complexity: O(logN) + /// where N = size(this) + bool contains(llvm::APSInt Point) const { return containsImpl(Point); } + + void dump(raw_ostream &OS) const; + + bool operator==(const RangeSet &Other) const { return *Impl == *Other.Impl; } + bool operator!=(const RangeSet &Other) const { return !(*this == Other); } +private: + /* implicit */ RangeSet(ContainerType *RawContainer) : Impl(RawContainer) {} + /* implicit */ RangeSet(UnderlyingType Ptr) : Impl(Ptr) {} + + /// Pin given points to the type represented by the current range set. + /// + /// This makes parameter points to be in-out parameters. + /// In order to maintain consistent types across all of the ranges in the set + /// and to keep all the operations to compare ONLY points of the same type, we + /// need to pin every point before any operation. + /// + /// @Returns true if the given points can be converted to the target type + /// without changing the values (i.e. trivially) and false otherwise. + /// @{ bool pin(llvm::APSInt &Lower, llvm::APSInt &Upper) const; + bool pin(llvm::APSInt &Point) const; + /// @} -public: - RangeSet Intersect(BasicValueFactory &BV, Factory &F, llvm::APSInt Lower, - llvm::APSInt Upper) const; - RangeSet Intersect(BasicValueFactory &BV, Factory &F, - const RangeSet &Other) const; - RangeSet Negate(BasicValueFactory &BV, Factory &F) const; - RangeSet Delete(BasicValueFactory &BV, Factory &F, - const llvm::APSInt &Point) const; - - void print(raw_ostream &os) const; - - bool operator==(const RangeSet &other) const { - return ranges == other.ranges; - } + // This version of this function modifies its arguments (pins it). + bool containsImpl(llvm::APSInt &Point) const; + + friend class Factory; }; using ConstraintMap = llvm::ImmutableMap<SymbolRef, RangeSet>; @@ -213,6 +387,11 @@ private: static void computeAdjustment(SymbolRef &Sym, llvm::APSInt &Adjustment); }; +/// Try to simplify a given symbolic expression's associated value based on the +/// constraints in State. This is needed because the Environment bindings are +/// not getting updated when a new constraint is added to the State. +SymbolRef simplify(ProgramStateRef State, SymbolRef Sym); + } // namespace ento } // namespace clang diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h index 07fc73a670f3..e4878d4e0156 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h @@ -146,7 +146,7 @@ public: Solver->addConstraint(NotExp); Optional<bool> isNotSat = Solver->check(); - if (!isSat.hasValue() || isNotSat.getValue()) + if (!isNotSat.hasValue() || isNotSat.getValue()) return nullptr; // This is the only solution, store it diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h index 4ea85f9730bb..87a49cf4ffe9 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h @@ -72,13 +72,27 @@ protected: /// The width of the scalar type used for array indices. const unsigned ArrayIndexWidth; - virtual SVal evalCastFromNonLoc(NonLoc val, QualType castTy) = 0; - virtual SVal evalCastFromLoc(Loc val, QualType castTy) = 0; - -public: - // FIXME: Make these protected again once RegionStoreManager correctly - // handles loads from different bound value types. - virtual SVal dispatchCast(SVal val, QualType castTy) = 0; + SVal evalCastKind(UndefinedVal V, QualType CastTy, QualType OriginalTy); + SVal evalCastKind(UnknownVal V, QualType CastTy, QualType OriginalTy); + SVal evalCastKind(Loc V, QualType CastTy, QualType OriginalTy); + SVal evalCastKind(NonLoc V, QualType CastTy, QualType OriginalTy); + SVal evalCastSubKind(loc::ConcreteInt V, QualType CastTy, + QualType OriginalTy); + SVal evalCastSubKind(loc::GotoLabel V, QualType CastTy, QualType OriginalTy); + SVal evalCastSubKind(loc::MemRegionVal V, QualType CastTy, + QualType OriginalTy); + SVal evalCastSubKind(nonloc::CompoundVal V, QualType CastTy, + QualType OriginalTy); + SVal evalCastSubKind(nonloc::ConcreteInt V, QualType CastTy, + QualType OriginalTy); + SVal evalCastSubKind(nonloc::LazyCompoundVal V, QualType CastTy, + QualType OriginalTy); + SVal evalCastSubKind(nonloc::LocAsInteger V, QualType CastTy, + QualType OriginalTy); + SVal evalCastSubKind(nonloc::SymbolVal V, QualType CastTy, + QualType OriginalTy); + SVal evalCastSubKind(nonloc::PointerToMember V, QualType CastTy, + QualType OriginalTy); public: SValBuilder(llvm::BumpPtrAllocator &alloc, ASTContext &context, @@ -102,7 +116,7 @@ public: Ty2->isIntegralOrEnumerationType())); } - SVal evalCast(SVal val, QualType castTy, QualType originalType); + SVal evalCast(SVal V, QualType CastTy, QualType OriginalTy); // Handles casts of type CK_IntegralCast. SVal evalIntegralCast(ProgramStateRef state, SVal val, QualType castTy, @@ -224,6 +238,14 @@ public: const LocationContext *LCtx, unsigned Count); + /// Conjure a symbol representing heap allocated memory region. + /// + /// Note, now, the expression *doesn't* need to represent a location. + /// But the type need to! + DefinedOrUnknownSVal getConjuredHeapSymbolVal(const Expr *E, + const LocationContext *LCtx, + QualType type, unsigned Count); + DefinedOrUnknownSVal getDerivedRegionValueSymbolVal( SymbolRef parentSymbol, const TypedValueRegion *region); @@ -366,6 +388,10 @@ public: return loc::ConcreteInt(BasicVals.getValue(integer)); } + /// Return MemRegionVal on success cast, otherwise return None. + Optional<loc::MemRegionVal> getCastedMemRegionVal(const MemRegion *region, + QualType type); + /// Make an SVal that represents the given symbol. This follows the convention /// of representing Loc-type symbols (symbolic pointers and references) /// as Loc values wrapping the symbol rather than as plain symbol values. diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h index bb295ab591d4..6199c8d8d179 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h @@ -201,6 +201,19 @@ public: SymExpr::symbol_iterator symbol_end() const { return SymExpr::symbol_end(); } + + /// Try to get a reasonable type for the given value. + /// + /// \returns The best approximation of the value type or Null. + /// In theory, all symbolic values should be typed, but this function + /// is still a WIP and might have a few blind spots. + /// + /// \note This function should not be used when the user has access to the + /// bound expression AST node as well, since AST always has exact types. + /// + /// \note Loc values are interpreted as pointer rvalues for the purposes of + /// this method. + QualType getType(const ASTContext &) const; }; inline raw_ostream &operator<<(raw_ostream &os, clang::ento::SVal V) { @@ -511,10 +524,11 @@ private: /// This value is qualified as NonLoc because neither loading nor storing /// operations are applied to it. Instead, the analyzer uses the L-value coming /// from pointer-to-member applied to an object. -/// This SVal is represented by a DeclaratorDecl which can be a member function -/// pointer or a member data pointer and a list of CXXBaseSpecifiers. This list -/// is required to accumulate the pointer-to-member cast history to figure out -/// the correct subobject field. +/// This SVal is represented by a NamedDecl which can be a member function +/// pointer or a member data pointer and an optional list of CXXBaseSpecifiers. +/// This list is required to accumulate the pointer-to-member cast history to +/// figure out the correct subobject field. In particular, implicit casts grow +/// this list and explicit casts like static_cast shrink this list. class PointerToMember : public NonLoc { friend class ento::SValBuilder; diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h index c3b590e4784e..d2461705d128 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h @@ -181,7 +181,8 @@ public: /// castRegion - Used by ExprEngine::VisitCast to handle casts from /// a MemRegion* to a specific location type. 'R' is the region being /// casted and 'CastToTy' the result type of the cast. - const MemRegion *castRegion(const MemRegion *region, QualType CastToTy); + Optional<const MemRegion *> castRegion(const MemRegion *region, + QualType CastToTy); virtual StoreRef removeDeadBindings(Store store, const StackFrameContext *LCtx, SymbolReaper &SymReaper) = 0; @@ -280,12 +281,6 @@ protected: QualType pointeeTy, uint64_t index = 0); - /// CastRetrievedVal - Used by subclasses of StoreManager to implement - /// implicit casts that arise from loads from regions that are reinterpreted - /// as another region. - SVal CastRetrievedVal(SVal val, const TypedValueRegion *region, - QualType castTy); - private: SVal getLValueFieldOrIvar(const Decl *decl, SVal base); }; diff --git a/clang/include/clang/Tooling/ArgumentsAdjusters.h b/clang/include/clang/Tooling/ArgumentsAdjusters.h index c48a8725aae9..bf0886034324 100644 --- a/clang/include/clang/Tooling/ArgumentsAdjusters.h +++ b/clang/include/clang/Tooling/ArgumentsAdjusters.h @@ -43,10 +43,6 @@ ArgumentsAdjuster getClangSyntaxOnlyAdjuster(); /// arguments. ArgumentsAdjuster getClangStripOutputAdjuster(); -/// Gets an argument adjuster which removes command line arguments related to -/// diagnostic serialization. -ArgumentsAdjuster getClangStripSerializeDiagnosticAdjuster(); - /// Gets an argument adjuster which removes dependency-file /// related command line arguments. ArgumentsAdjuster getClangStripDependencyFileAdjuster(); diff --git a/clang/include/clang/Tooling/CommonOptionsParser.h b/clang/include/clang/Tooling/CommonOptionsParser.h index a5bfeeeaf77f..0f072c2886ab 100644 --- a/clang/include/clang/Tooling/CommonOptionsParser.h +++ b/clang/include/clang/Tooling/CommonOptionsParser.h @@ -63,21 +63,8 @@ namespace tooling { /// } /// \endcode class CommonOptionsParser { -public: - /// Parses command-line, initializes a compilation database. - /// - /// This constructor can change argc and argv contents, e.g. consume - /// command-line options used for creating FixedCompilationDatabase. - /// - /// All options not belonging to \p Category become hidden. - /// - /// This constructor exits program in case of error. - CommonOptionsParser(int &argc, const char **argv, - llvm::cl::OptionCategory &Category, - const char *Overview = nullptr) - : CommonOptionsParser(argc, argv, Category, llvm::cl::OneOrMore, - Overview) {} +protected: /// Parses command-line, initializes a compilation database. /// /// This constructor can change argc and argv contents, e.g. consume @@ -86,16 +73,17 @@ public: /// All options not belonging to \p Category become hidden. /// /// It also allows calls to set the required number of positional parameters. - CommonOptionsParser(int &argc, const char **argv, - llvm::cl::OptionCategory &Category, - llvm::cl::NumOccurrencesFlag OccurrencesFlag, - const char *Overview = nullptr); + CommonOptionsParser( + int &argc, const char **argv, llvm::cl::OptionCategory &Category, + llvm::cl::NumOccurrencesFlag OccurrencesFlag = llvm::cl::OneOrMore, + const char *Overview = nullptr); +public: /// A factory method that is similar to the above constructor, except /// this returns an error instead exiting the program on error. static llvm::Expected<CommonOptionsParser> create(int &argc, const char **argv, llvm::cl::OptionCategory &Category, - llvm::cl::NumOccurrencesFlag OccurrencesFlag, + llvm::cl::NumOccurrencesFlag OccurrencesFlag = llvm::cl::OneOrMore, const char *Overview = nullptr); /// Returns a reference to the loaded compilations database. diff --git a/clang/include/clang/Tooling/CompilationDatabase.h b/clang/include/clang/Tooling/CompilationDatabase.h index 44af236347b3..90af15536961 100644 --- a/clang/include/clang/Tooling/CompilationDatabase.h +++ b/clang/include/clang/Tooling/CompilationDatabase.h @@ -213,6 +213,12 @@ private: std::vector<CompileCommand> CompileCommands; }; +/// Transforms a compile command so that it applies the same configuration to +/// a different file. Most args are left intact, but tweaks may be needed +/// to certain flags (-x, -std etc). +tooling::CompileCommand transferCompileCommand(tooling::CompileCommand, + StringRef Filename); + /// Returns a wrapped CompilationDatabase that defers to the provided one, /// but getCompileCommands() will infer commands for unknown files. /// The return value of getAllFiles() or getAllCompileCommands() is unchanged. diff --git a/clang/include/clang/Tooling/Core/Diagnostic.h b/clang/include/clang/Tooling/Core/Diagnostic.h index 123874f9ccf7..4553380bcf00 100644 --- a/clang/include/clang/Tooling/Core/Diagnostic.h +++ b/clang/include/clang/Tooling/Core/Diagnostic.h @@ -26,6 +26,17 @@ namespace clang { namespace tooling { +/// Represents a range within a specific source file. +struct FileByteRange { + FileByteRange() = default; + + FileByteRange(const SourceManager &Sources, CharSourceRange Range); + + std::string FilePath; + unsigned FileOffset; + unsigned Length; +}; + /// Represents the diagnostic message with the error message associated /// and the information on the location of the problem. struct DiagnosticMessage { @@ -39,29 +50,24 @@ struct DiagnosticMessage { /// DiagnosticMessage(llvm::StringRef Message, const SourceManager &Sources, SourceLocation Loc); + std::string Message; std::string FilePath; unsigned FileOffset; /// Fixes for this diagnostic, grouped by file path. llvm::StringMap<Replacements> Fix; -}; - -/// Represents a range within a specific source file. -struct FileByteRange { - FileByteRange() = default; - FileByteRange(const SourceManager &Sources, CharSourceRange Range); - - std::string FilePath; - unsigned FileOffset; - unsigned Length; + /// Extra source ranges associated with the note, in addition to the location + /// of the Message itself. + llvm::SmallVector<FileByteRange, 1> Ranges; }; /// Represents the diagnostic with the level of severity and possible /// fixes to be applied. struct Diagnostic { enum Level { + Remark = DiagnosticsEngine::Remark, Warning = DiagnosticsEngine::Warning, Error = DiagnosticsEngine::Error }; @@ -73,8 +79,7 @@ struct Diagnostic { Diagnostic(llvm::StringRef DiagnosticName, const DiagnosticMessage &Message, const SmallVector<DiagnosticMessage, 1> &Notes, Level DiagLevel, - llvm::StringRef BuildDirectory, - const SmallVector<FileByteRange, 1> &Ranges); + llvm::StringRef BuildDirectory); /// Name identifying the Diagnostic. std::string DiagnosticName; @@ -96,10 +101,6 @@ struct Diagnostic { /// /// Note: it is empty in unittest. std::string BuildDirectory; - - /// Extra source ranges associated with the diagnostic (in addition to the - /// location of the Message above). - SmallVector<FileByteRange, 1> Ranges; }; /// Collection of Diagnostics generated from a single translation unit. diff --git a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h index 7d0881343478..c52da3305f7c 100644 --- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h +++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h @@ -65,7 +65,7 @@ public: return MaybeStat.getError(); assert(!MaybeStat->isDirectory() && "not a file"); assert(isValid() && "not initialized"); - return StringRef(Contents); + return Contents.str(); } /// \returns The error or the status of the entry. @@ -103,7 +103,8 @@ private: }; /// This class is a shared cache, that caches the 'stat' and 'open' calls to the -/// underlying real file system. +/// underlying real file system. It distinguishes between minimized and original +/// files. /// /// It is sharded based on the hash of the key to reduce the lock contention for /// the worker threads. @@ -114,21 +115,62 @@ public: CachedFileSystemEntry Value; }; - DependencyScanningFilesystemSharedCache(); - /// Returns a cache entry for the corresponding key. /// /// A new cache entry is created if the key is not in the cache. This is a /// thread safe call. - SharedFileSystemEntry &get(StringRef Key); + SharedFileSystemEntry &get(StringRef Key, bool Minimized); private: - struct CacheShard { - std::mutex CacheLock; - llvm::StringMap<SharedFileSystemEntry, llvm::BumpPtrAllocator> Cache; + class SingleCache { + public: + SingleCache(); + + SharedFileSystemEntry &get(StringRef Key); + + private: + struct CacheShard { + std::mutex CacheLock; + llvm::StringMap<SharedFileSystemEntry, llvm::BumpPtrAllocator> Cache; + }; + std::unique_ptr<CacheShard[]> CacheShards; + unsigned NumShards; }; - std::unique_ptr<CacheShard[]> CacheShards; - unsigned NumShards; + + SingleCache CacheMinimized; + SingleCache CacheOriginal; +}; + +/// This class is a local cache, that caches the 'stat' and 'open' calls to the +/// underlying real file system. It distinguishes between minimized and original +/// files. +class DependencyScanningFilesystemLocalCache { +private: + using SingleCache = + llvm::StringMap<const CachedFileSystemEntry *, llvm::BumpPtrAllocator>; + + SingleCache CacheMinimized; + SingleCache CacheOriginal; + + SingleCache &selectCache(bool Minimized) { + return Minimized ? CacheMinimized : CacheOriginal; + } + +public: + void setCachedEntry(StringRef Filename, bool Minimized, + const CachedFileSystemEntry *Entry) { + SingleCache &Cache = selectCache(Minimized); + bool IsInserted = Cache.try_emplace(Filename, Entry).second; + (void)IsInserted; + assert(IsInserted && "local cache is updated more than once"); + } + + const CachedFileSystemEntry *getCachedEntry(StringRef Filename, + bool Minimized) { + SingleCache &Cache = selectCache(Minimized); + auto It = Cache.find(Filename); + return It == Cache.end() ? nullptr : It->getValue(); + } }; /// A virtual file system optimized for the dependency discovery. @@ -153,32 +195,26 @@ public: llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>> openFileForRead(const Twine &Path) override; - /// The set of files that should not be minimized. - llvm::StringSet<> IgnoredFiles; + void clearIgnoredFiles() { IgnoredFiles.clear(); } + void ignoreFile(StringRef Filename); private: - void setCachedEntry(StringRef Filename, const CachedFileSystemEntry *Entry) { - bool IsInserted = Cache.try_emplace(Filename, Entry).second; - (void)IsInserted; - assert(IsInserted && "local cache is updated more than once"); - } - - const CachedFileSystemEntry *getCachedEntry(StringRef Filename) { - auto It = Cache.find(Filename); - return It == Cache.end() ? nullptr : It->getValue(); - } + bool shouldIgnoreFile(StringRef Filename); llvm::ErrorOr<const CachedFileSystemEntry *> getOrCreateFileSystemEntry(const StringRef Filename); + /// The global cache shared between worker threads. DependencyScanningFilesystemSharedCache &SharedCache; /// The local cache is used by the worker thread to cache file system queries /// locally instead of querying the global cache every time. - llvm::StringMap<const CachedFileSystemEntry *, llvm::BumpPtrAllocator> Cache; + DependencyScanningFilesystemLocalCache Cache; /// The optional mapping structure which records information about the /// excluded conditional directive skip mappings that are used by the /// currently active preprocessor. ExcludedPreprocessorDirectiveSkipMapping *PPSkipMappings; + /// The set of files that should not be minimized. + llvm::StringSet<> IgnoredFiles; }; } // end namespace dependencies diff --git a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h index 1c106ed4b765..f88dc472c80b 100644 --- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h +++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h @@ -22,51 +22,45 @@ namespace dependencies{ /// The full dependencies and module graph for a specific input. struct FullDependencies { - /// The name of the C++20 module this translation unit exports. This may - /// include `:` for C++20 module partitons. + /// The identifier of the C++20 module this translation unit exports. /// - /// If the translation unit is not a module then this will be empty. - std::string ExportedModuleName; - - /// The context hash represents the set of compiler options that may make one - /// version of a module incompatible with another. This includes things like - /// language mode, predefined macros, header search paths, etc... - /// - /// Modules with the same name but a different \c ContextHash should be - /// treated as separate modules for the purpose of a build. - std::string ContextHash; + /// If the translation unit is not a module then \c ID.ModuleName is empty. + ModuleID ID; /// A collection of absolute paths to files that this translation unit /// directly depends on, not including transitive dependencies. std::vector<std::string> FileDeps; + /// A collection of prebuilt modules this translation unit directly depends + /// on, not including transitive dependencies. + std::vector<PrebuiltModuleDep> PrebuiltModuleDeps; + /// A list of modules this translation unit directly depends on, not including /// transitive dependencies. /// /// This may include modules with a different context hash when it can be /// determined that the differences are benign for this compilation. - std::vector<ClangModuleDep> ClangModuleDeps; - - /// A partial addtional set of command line arguments that can be used to - /// build this translation unit. - /// - /// Call \c getFullAdditionalCommandLine() to get a command line suitable for - /// appending to the original command line to pass to clang. - std::vector<std::string> AdditionalNonPathCommandLine; + std::vector<ModuleID> ClangModuleDeps; - /// Gets the full addtional command line suitable for appending to the - /// original command line to pass to clang. + /// Get additional arguments suitable for appending to the original Clang + /// command line. /// - /// \param LookupPCMPath this function is called to fill in `-fmodule-file=` - /// flags and for the `-o` flag. It needs to return a - /// path for where the PCM for the given module is to + /// \param LookupPCMPath This function is called to fill in "-fmodule-file=" + /// arguments and the "-o" argument. It needs to return + /// a path for where the PCM for the given module is to /// be located. - /// \param LookupModuleDeps this fucntion is called to collect the full + /// \param LookupModuleDeps This function is called to collect the full /// transitive set of dependencies for this - /// compilation. - std::vector<std::string> getAdditionalCommandLine( - std::function<StringRef(ClangModuleDep)> LookupPCMPath, - std::function<const ModuleDeps &(ClangModuleDep)> LookupModuleDeps) const; + /// compilation and fill in "-fmodule-map-file=" + /// arguments. + std::vector<std::string> getAdditionalArgs( + std::function<StringRef(ModuleID)> LookupPCMPath, + std::function<const ModuleDeps &(ModuleID)> LookupModuleDeps) const; + + /// Get additional arguments suitable for appending to the original Clang + /// command line, excluding arguments containing modules-related paths: + /// "-fmodule-file=", "-fmodule-map-file=". + std::vector<std::string> getAdditionalArgsWithoutModulePaths() const; }; struct FullDependenciesResult { @@ -91,15 +85,14 @@ public: getDependencyFile(const tooling::CompilationDatabase &Compilations, StringRef CWD); - /// Collect the full module depenedency graph for the input, ignoring any + /// Collect the full module dependency graph for the input, ignoring any /// modules which have already been seen. /// - /// \param AlreadySeen this is used to not report modules that have previously - /// been reported. Use the same `llvm::StringSet<>` for all - /// calls to `getFullDependencies` for a single - /// `DependencyScanningTool` for a single build. Use a - /// different one for different tools, and clear it between - /// builds. + /// \param AlreadySeen This stores modules which have previously been + /// reported. Use the same instance for all calls to this + /// function for a single \c DependencyScanningTool in a + /// single build. Use a different one for different tools, + /// and clear it between builds. /// /// \returns a \c StringError with the diagnostic output if clang errors /// occurred, \c FullDependencies otherwise. diff --git a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h index 689119330c41..5903ad13c1d8 100644 --- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h +++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h @@ -34,8 +34,12 @@ class DependencyConsumer { public: virtual ~DependencyConsumer() {} - virtual void handleFileDependency(const DependencyOutputOptions &Opts, - StringRef Filename) = 0; + virtual void + handleDependencyOutputOpts(const DependencyOutputOptions &Opts) = 0; + + virtual void handleFileDependency(StringRef Filename) = 0; + + virtual void handlePrebuiltModuleDependency(PrebuiltModuleDep PMD) = 0; virtual void handleModuleDependency(ModuleDeps MD) = 0; diff --git a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h index c490bb38c167..a9f2b4d0c6fc 100644 --- a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h +++ b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h @@ -12,6 +12,7 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/SourceManager.h" +#include "clang/Frontend/CompilerInvocation.h" #include "clang/Frontend/Utils.h" #include "clang/Lex/HeaderSearch.h" #include "clang/Lex/PPCallbacks.h" @@ -28,16 +29,21 @@ namespace dependencies { class DependencyConsumer; -/// This is used to refer to a specific module. -/// -/// See \c ModuleDeps for details about what these members mean. -struct ClangModuleDep { +/// Modular dependency that has already been built prior to the dependency scan. +struct PrebuiltModuleDep { std::string ModuleName; - std::string ContextHash; + std::string PCMFile; + std::string ModuleMapFile; + + explicit PrebuiltModuleDep(const Module *M) + : ModuleName(M->getTopLevelModuleName()), + PCMFile(M->getASTFile()->getName()), + ModuleMapFile(M->PresumedModuleMapFile) {} }; -struct ModuleDeps { - /// The name of the module. This may include `:` for C++20 module partitons, +/// This is used to identify a specific module. +struct ModuleID { + /// The name of the module. This may include `:` for C++20 module partitions, /// or a header-name for C++20 header units. std::string ModuleName; @@ -49,6 +55,24 @@ struct ModuleDeps { /// treated as separate modules for the purpose of a build. std::string ContextHash; + bool operator==(const ModuleID &Other) const { + return ModuleName == Other.ModuleName && ContextHash == Other.ContextHash; + } +}; + +struct ModuleIDHasher { + std::size_t operator()(const ModuleID &MID) const { + return llvm::hash_combine(MID.ModuleName, MID.ContextHash); + } +}; + +struct ModuleDeps { + /// The identifier of the module. + ModuleID ID; + + /// Whether this is a "system" module. + bool IsSystem; + /// The path to the modulemap file which defines this module. /// /// This can be used to explicitly build this module. This file will @@ -62,50 +86,60 @@ struct ModuleDeps { /// on, not including transitive dependencies. llvm::StringSet<> FileDeps; - /// A list of modules this module directly depends on, not including - /// transitive dependencies. + /// A collection of prebuilt modular dependencies this module directly depends + /// on, not including transitive dependencies. + std::vector<PrebuiltModuleDep> PrebuiltModuleDeps; + + /// A list of module identifiers this module directly depends on, not + /// including transitive dependencies. /// /// This may include modules with a different context hash when it can be /// determined that the differences are benign for this compilation. - std::vector<ClangModuleDep> ClangModuleDeps; - - /// A partial command line that can be used to build this module. - /// - /// Call \c getFullCommandLine() to get a command line suitable for passing to - /// clang. - std::vector<std::string> NonPathCommandLine; + std::vector<ModuleID> ClangModuleDeps; // Used to track which modules that were discovered were directly imported by // the primary TU. bool ImportedByMainFile = false; - /// Gets the full command line suitable for passing to clang. + /// Compiler invocation that can be used to build this module (without paths). + CompilerInvocation Invocation; + + /// Gets the canonical command line suitable for passing to clang. /// - /// \param LookupPCMPath this function is called to fill in `-fmodule-file=` - /// flags and for the `-o` flag. It needs to return a - /// path for where the PCM for the given module is to + /// \param LookupPCMPath This function is called to fill in "-fmodule-file=" + /// arguments and the "-o" argument. It needs to return + /// a path for where the PCM for the given module is to /// be located. - /// \param LookupModuleDeps this fucntion is called to collect the full + /// \param LookupModuleDeps This function is called to collect the full /// transitive set of dependencies for this - /// compilation. - std::vector<std::string> getFullCommandLine( - std::function<StringRef(ClangModuleDep)> LookupPCMPath, - std::function<const ModuleDeps &(ClangModuleDep)> LookupModuleDeps) const; + /// compilation and fill in "-fmodule-map-file=" + /// arguments. + std::vector<std::string> getCanonicalCommandLine( + std::function<StringRef(ModuleID)> LookupPCMPath, + std::function<const ModuleDeps &(ModuleID)> LookupModuleDeps) const; + + /// Gets the canonical command line suitable for passing to clang, excluding + /// arguments containing modules-related paths: "-fmodule-file=", "-o", + /// "-fmodule-map-file=". + std::vector<std::string> getCanonicalCommandLineWithoutModulePaths() const; }; namespace detail { -/// Append the `-fmodule-file=` and `-fmodule-map-file=` arguments for the -/// modules in \c Modules transitively, along with other needed arguments to -/// use explicitly built modules. -void appendCommonModuleArguments( - llvm::ArrayRef<ClangModuleDep> Modules, - std::function<StringRef(ClangModuleDep)> LookupPCMPath, - std::function<const ModuleDeps &(ClangModuleDep)> LookupModuleDeps, - std::vector<std::string> &Result); +/// Collect the paths of PCM and module map files for the modules in \c Modules +/// transitively. +void collectPCMAndModuleMapPaths( + llvm::ArrayRef<ModuleID> Modules, + std::function<StringRef(ModuleID)> LookupPCMPath, + std::function<const ModuleDeps &(ModuleID)> LookupModuleDeps, + std::vector<std::string> &PCMPaths, std::vector<std::string> &ModMapPaths); } // namespace detail class ModuleDepCollector; +/// Callback that records textual includes and direct modular includes/imports +/// during preprocessing. At the end of the main file, it also collects +/// transitive modular dependencies and passes everything to the +/// \c DependencyConsumer of the parent \c ModuleDepCollector. class ModuleDepCollectorPP final : public PPCallbacks { public: ModuleDepCollectorPP(CompilerInstance &I, ModuleDepCollector &MDC) @@ -126,22 +160,38 @@ public: void EndOfMainFile() override; private: + /// The compiler instance for the current translation unit. CompilerInstance &Instance; + /// The parent dependency collector. ModuleDepCollector &MDC; - llvm::DenseSet<const Module *> DirectDeps; + /// Working set of direct modular dependencies. + llvm::DenseSet<const Module *> DirectModularDeps; + /// Working set of direct modular dependencies that have already been built. + llvm::DenseSet<const Module *> DirectPrebuiltModularDeps; void handleImport(const Module *Imported); - void handleTopLevelModule(const Module *M); + + /// Adds direct modular dependencies that have already been built to the + /// ModuleDeps instance. + void addDirectPrebuiltModuleDeps(const Module *M, ModuleDeps &MD); + + /// Traverses the previously collected direct modular dependencies to discover + /// transitive modular dependencies and fills the parent \c ModuleDepCollector + /// with both. + ModuleID handleTopLevelModule(const Module *M); void addAllSubmoduleDeps(const Module *M, ModuleDeps &MD, llvm::DenseSet<const Module *> &AddedModules); void addModuleDep(const Module *M, ModuleDeps &MD, llvm::DenseSet<const Module *> &AddedModules); }; +/// Collects modular and non-modular dependencies of the main file by attaching +/// \c ModuleDepCollectorPP to the preprocessor. class ModuleDepCollector final : public DependencyCollector { public: ModuleDepCollector(std::unique_ptr<DependencyOutputOptions> Opts, - CompilerInstance &I, DependencyConsumer &C); + CompilerInstance &I, DependencyConsumer &C, + CompilerInvocation &&OriginalCI); void attachToPreprocessor(Preprocessor &PP) override; void attachToASTReader(ASTReader &R) override; @@ -149,13 +199,32 @@ public: private: friend ModuleDepCollectorPP; + /// The compiler instance for the current translation unit. CompilerInstance &Instance; + /// The consumer of collected dependency information. DependencyConsumer &Consumer; + /// Path to the main source file. std::string MainFile; + /// Hash identifying the compilation conditions of the current TU. std::string ContextHash; - std::vector<std::string> MainDeps; - std::unordered_map<std::string, ModuleDeps> Deps; + /// Non-modular file dependencies. This includes the main source file and + /// textually included header files. + std::vector<std::string> FileDeps; + /// Direct and transitive modular dependencies of the main source file. + std::unordered_map<const Module *, ModuleDeps> ModularDeps; + /// Options that control the dependency output generation. std::unique_ptr<DependencyOutputOptions> Opts; + /// The original Clang invocation passed to dependency scanner. + CompilerInvocation OriginalInvocation; + + /// Checks whether the module is known as being prebuilt. + bool isPrebuiltModule(const Module *M); + + /// Constructs a CompilerInvocation that can be used to build the given + /// module, excluding paths to discovered modular dependencies that are yet to + /// be built. + CompilerInvocation + makeInvocationForModuleBuildWithoutPaths(const ModuleDeps &Deps) const; }; } // end namespace dependencies diff --git a/clang/include/clang/Tooling/DiagnosticsYaml.h b/clang/include/clang/Tooling/DiagnosticsYaml.h index 38fbcfc1da95..3f257d84f813 100644 --- a/clang/include/clang/Tooling/DiagnosticsYaml.h +++ b/clang/include/clang/Tooling/DiagnosticsYaml.h @@ -54,6 +54,7 @@ template <> struct MappingTraits<clang::tooling::DiagnosticMessage> { << llvm::toString(std::move(Err)) << "\n"; } } + Io.mapOptional("Ranges", M.Ranges); } }; @@ -67,12 +68,11 @@ template <> struct MappingTraits<clang::tooling::Diagnostic> { NormalizedDiagnostic(const IO &, const clang::tooling::Diagnostic &D) : DiagnosticName(D.DiagnosticName), Message(D.Message), Notes(D.Notes), - DiagLevel(D.DiagLevel), BuildDirectory(D.BuildDirectory), - Ranges(D.Ranges) {} + DiagLevel(D.DiagLevel), BuildDirectory(D.BuildDirectory) {} clang::tooling::Diagnostic denormalize(const IO &) { return clang::tooling::Diagnostic(DiagnosticName, Message, Notes, - DiagLevel, BuildDirectory, Ranges); + DiagLevel, BuildDirectory); } std::string DiagnosticName; @@ -80,7 +80,6 @@ template <> struct MappingTraits<clang::tooling::Diagnostic> { SmallVector<clang::tooling::DiagnosticMessage, 1> Notes; clang::tooling::Diagnostic::Level DiagLevel; std::string BuildDirectory; - SmallVector<clang::tooling::FileByteRange, 1> Ranges; }; static void mapping(IO &Io, clang::tooling::Diagnostic &D) { @@ -91,7 +90,6 @@ template <> struct MappingTraits<clang::tooling::Diagnostic> { Io.mapOptional("Notes", Keys->Notes); Io.mapOptional("Level", Keys->DiagLevel); Io.mapOptional("BuildDirectory", Keys->BuildDirectory); - Io.mapOptional("Ranges", Keys->Ranges); } }; @@ -108,6 +106,7 @@ template <> struct ScalarEnumerationTraits<clang::tooling::Diagnostic::Level> { static void enumeration(IO &IO, clang::tooling::Diagnostic::Level &Value) { IO.enumCase(Value, "Warning", clang::tooling::Diagnostic::Warning); IO.enumCase(Value, "Error", clang::tooling::Diagnostic::Error); + IO.enumCase(Value, "Remark", clang::tooling::Diagnostic::Remark); } }; diff --git a/clang/include/clang/Tooling/NodeIntrospection.h b/clang/include/clang/Tooling/NodeIntrospection.h new file mode 100644 index 000000000000..91552cad2eca --- /dev/null +++ b/clang/include/clang/Tooling/NodeIntrospection.h @@ -0,0 +1,101 @@ +//===- NodeIntrospection.h ------------------------------------*- C++ -*---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file contains the implementation of the NodeIntrospection. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_TOOLING_NODEINTROSPECTION_H +#define LLVM_CLANG_TOOLING_NODEINTROSPECTION_H + +#include "clang/AST/ASTTypeTraits.h" +#include "clang/AST/DeclarationName.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include <set> + +namespace clang { + +class Stmt; +class Decl; +class CXXCtorInitializer; +class NestedNameSpecifierLoc; +class TemplateArgumentLoc; +class CXXBaseSpecifier; +struct DeclarationNameInfo; + +namespace tooling { + +class LocationCall; +using SharedLocationCall = llvm::IntrusiveRefCntPtr<LocationCall>; + +class LocationCall : public llvm::ThreadSafeRefCountedBase<LocationCall> { +public: + enum LocationCallFlags { NoFlags, ReturnsPointer, IsCast }; + LocationCall(SharedLocationCall on, std::string name, + LocationCallFlags flags = NoFlags) + : m_flags(flags), m_on(std::move(on)), m_name(std::move(name)) {} + + LocationCall *on() const { return m_on.get(); } + StringRef name() const { return m_name; } + bool returnsPointer() const { return m_flags & ReturnsPointer; } + bool isCast() const { return m_flags & IsCast; } + +private: + LocationCallFlags m_flags; + SharedLocationCall m_on; + std::string m_name; +}; + +class LocationCallFormatterCpp { +public: + static void print(const LocationCall &Call, llvm::raw_ostream &OS); + static std::string format(const LocationCall &Call); +}; + +namespace internal { +struct RangeLessThan { + bool operator()(std::pair<SourceRange, SharedLocationCall> const &LHS, + std::pair<SourceRange, SharedLocationCall> const &RHS) const; + bool + operator()(std::pair<SourceLocation, SharedLocationCall> const &LHS, + std::pair<SourceLocation, SharedLocationCall> const &RHS) const; +}; + +} // namespace internal + +// Note that this container stores unique results in a deterministic, but +// the location calls are in an unspecified order. Clients which desire +// a particular order for the location calls, such as alphabetical, +// should sort results after retrieval, because the order is dependent +// on how the LocationCalls are formatted. +template <typename T, typename U> +using UniqueMultiMap = std::set<std::pair<T, U>, internal::RangeLessThan>; + +using SourceLocationMap = UniqueMultiMap<SourceLocation, SharedLocationCall>; +using SourceRangeMap = UniqueMultiMap<SourceRange, SharedLocationCall>; + +struct NodeLocationAccessors { + SourceLocationMap LocationAccessors; + SourceRangeMap RangeAccessors; +}; + +namespace NodeIntrospection { +bool hasIntrospectionSupport(); +NodeLocationAccessors GetLocations(clang::Stmt const *Object); +NodeLocationAccessors GetLocations(clang::Decl const *Object); +NodeLocationAccessors GetLocations(clang::CXXCtorInitializer const *Object); +NodeLocationAccessors GetLocations(clang::NestedNameSpecifierLoc const &); +NodeLocationAccessors GetLocations(clang::TemplateArgumentLoc const &); +NodeLocationAccessors GetLocations(clang::CXXBaseSpecifier const *); +NodeLocationAccessors GetLocations(clang::TypeLoc const &); +NodeLocationAccessors GetLocations(clang::DeclarationNameInfo const &); +NodeLocationAccessors GetLocations(clang::DynTypedNode const &Node); +} // namespace NodeIntrospection +} // namespace tooling +} // namespace clang +#endif diff --git a/clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h b/clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h index c0f995d85c14..63d46abc2034 100644 --- a/clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h +++ b/clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h @@ -122,6 +122,17 @@ public: return BaseType::TraverseNestedNameSpecifierLoc(NNS); } + bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) { + for (const DesignatedInitExpr::Designator &D : E->designators()) { + if (D.isFieldDesignator() && D.getField()) { + const FieldDecl *Decl = D.getField(); + if (!visit(Decl, D.getFieldLoc(), D.getFieldLoc())) + return false; + } + } + return true; + } + private: const SourceManager &SM; const LangOptions &LangOpts; diff --git a/clang/include/clang/Tooling/Refactoring/RefactoringActionRule.h b/clang/include/clang/Tooling/Refactoring/RefactoringActionRule.h index 0c6e38af381f..57dffa945acc 100644 --- a/clang/include/clang/Tooling/Refactoring/RefactoringActionRule.h +++ b/clang/include/clang/Tooling/Refactoring/RefactoringActionRule.h @@ -12,7 +12,6 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" -#include <vector> namespace clang { namespace tooling { diff --git a/clang/include/clang/Tooling/Syntax/Tokens.h b/clang/include/clang/Tooling/Syntax/Tokens.h index 98320bd54d6f..e4bc1553c2d6 100644 --- a/clang/include/clang/Tooling/Syntax/Tokens.h +++ b/clang/include/clang/Tooling/Syntax/Tokens.h @@ -34,6 +34,7 @@ #include "clang/Basic/TokenKinds.h" #include "clang/Lex/Token.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Compiler.h" @@ -192,8 +193,13 @@ public: return ExpandedTokens; } + /// Builds a cache to make future calls to expandedToken(SourceRange) faster. + /// Creates an index only once. Further calls to it will be no-op. + void indexExpandedTokens(); + /// Returns the subrange of expandedTokens() corresponding to the closed /// token range R. + /// Consider calling indexExpandedTokens() before for faster lookups. llvm::ArrayRef<syntax::Token> expandedTokens(SourceRange R) const; /// Returns the subrange of spelled tokens corresponding to AST node spanning @@ -366,6 +372,8 @@ private: /// same stream as 'clang -E' (excluding the preprocessor directives like /// #file, etc.). std::vector<syntax::Token> ExpandedTokens; + // Index of ExpandedTokens for faster lookups by SourceLocation. + llvm::DenseMap<SourceLocation, unsigned> ExpandedTokIndex; llvm::DenseMap<FileID, MarkedFile> Files; // The value is never null, pointer instead of reference to avoid disabling // implicit assignment operator. diff --git a/clang/include/clang/Tooling/Tooling.h b/clang/include/clang/Tooling/Tooling.h index 8b3b2e5ad002..73d09662562b 100644 --- a/clang/include/clang/Tooling/Tooling.h +++ b/clang/include/clang/Tooling/Tooling.h @@ -66,6 +66,14 @@ namespace tooling { class CompilationDatabase; +/// Retrieves the flags of the `-cc1` job in `Compilation` that has only source +/// files as its inputs. +/// Returns nullptr if there are no such jobs or multiple of them. Note that +/// offloading jobs are ignored. +const llvm::opt::ArgStringList * +getCC1Arguments(DiagnosticsEngine *Diagnostics, + driver::Compilation *Compilation); + /// Interface to process a clang::CompilerInvocation. /// /// If your tool is based on FrontendAction, you should be deriving from diff --git a/clang/include/clang/Tooling/Transformer/Parsing.h b/clang/include/clang/Tooling/Transformer/Parsing.h index 8e51f595cd5b..b143f63d8ca8 100644 --- a/clang/include/clang/Tooling/Transformer/Parsing.h +++ b/clang/include/clang/Tooling/Transformer/Parsing.h @@ -21,7 +21,6 @@ #include "clang/Tooling/Transformer/RangeSelector.h" #include "llvm/Support/Error.h" #include <functional> -#include <string> namespace clang { namespace transformer { diff --git a/clang/include/clang/Tooling/Transformer/RangeSelector.h b/clang/include/clang/Tooling/Transformer/RangeSelector.h index f17fb8c7b5c6..8ff31f7a0342 100644 --- a/clang/include/clang/Tooling/Transformer/RangeSelector.h +++ b/clang/include/clang/Tooling/Transformer/RangeSelector.h @@ -73,9 +73,9 @@ RangeSelector statement(std::string ID); /// binding in the match result. RangeSelector member(std::string ID); -/// Given a node with a "name", (like \c NamedDecl, \c DeclRefExpr or \c -/// CxxCtorInitializer) selects the name's token. Only selects the final -/// identifier of a qualified name, but not any qualifiers or template +/// Given a node with a "name", (like \c NamedDecl, \c DeclRefExpr, \c +/// CxxCtorInitializer, and \c TypeLoc) selects the name's token. Only selects +/// the final identifier of a qualified name, but not any qualifiers or template /// arguments. For example, for `::foo::bar::baz` and `::foo::bar::baz<int>`, /// it selects only `baz`. /// diff --git a/clang/include/clang/module.modulemap b/clang/include/clang/module.modulemap index 332e533f0347..33fcf9dc7576 100644 --- a/clang/include/clang/module.modulemap +++ b/clang/include/clang/module.modulemap @@ -40,11 +40,11 @@ module Clang_Basic { textual header "Basic/BuiltinsHexagon.def" textual header "Basic/BuiltinsHexagonDep.def" textual header "Basic/BuiltinsHexagonMapCustomDep.def" - textual header "Basic/BuiltinsLe64.def" textual header "Basic/BuiltinsMips.def" textual header "Basic/BuiltinsNEON.def" textual header "Basic/BuiltinsNVPTX.def" textual header "Basic/BuiltinsPPC.def" + textual header "Basic/BuiltinsRISCV.def" textual header "Basic/BuiltinsSVE.def" textual header "Basic/BuiltinsSystemZ.def" textual header "Basic/BuiltinsWebAssembly.def" @@ -63,7 +63,9 @@ module Clang_Basic { textual header "Basic/OpenMPKinds.def" textual header "Basic/OperatorKinds.def" textual header "Basic/PPCTypes.def" + textual header "Basic/RISCVVTypes.def" textual header "Basic/Sanitizers.def" + textual header "Basic/TargetCXXABI.def" textual header "Basic/TokenKinds.def" textual header "Basic/X86Target.def" |