diff options
Diffstat (limited to 'clang/utils/TableGen')
| -rw-r--r-- | clang/utils/TableGen/ASTTableGen.h | 2 | ||||
| -rw-r--r-- | clang/utils/TableGen/ClangSACheckersEmitter.cpp | 49 | ||||
| -rw-r--r-- | clang/utils/TableGen/ClangTypeNodesEmitter.cpp | 24 | ||||
| -rw-r--r-- | clang/utils/TableGen/RISCVVEmitter.cpp | 26 |
4 files changed, 61 insertions, 40 deletions
diff --git a/clang/utils/TableGen/ASTTableGen.h b/clang/utils/TableGen/ASTTableGen.h index 02b97636cf5f..e9a86f3d5edd 100644 --- a/clang/utils/TableGen/ASTTableGen.h +++ b/clang/utils/TableGen/ASTTableGen.h @@ -38,7 +38,7 @@ #define AlwaysDependentClassName "AlwaysDependent" #define NeverCanonicalClassName "NeverCanonical" #define NeverCanonicalUnlessDependentClassName "NeverCanonicalUnlessDependent" -#define LeafTypeClassName "LeafType" +#define AlwaysCanonicalTypeClassName "AlwaysCanonical" // Cases of various non-ASTNode structured types like DeclarationName. #define TypeKindClassName "PropertyTypeKind" diff --git a/clang/utils/TableGen/ClangSACheckersEmitter.cpp b/clang/utils/TableGen/ClangSACheckersEmitter.cpp index dcb3cac3850b..8353ef7fb20d 100644 --- a/clang/utils/TableGen/ClangSACheckersEmitter.cpp +++ b/clang/utils/TableGen/ClangSACheckersEmitter.cpp @@ -202,19 +202,22 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) { // Emit a package option. // - // PACKAGE_OPTION(OPTIONTYPE, PACKAGENAME, OPTIONNAME, DESCRIPTION, DEFAULT) - // - OPTIONTYPE: Type of the option, whether it's integer or boolean etc. + // PACKAGE_OPTION(TYPE, FULLNAME, CMDFLAG, DESC, DEFAULT_VAL, + // DEVELOPMENT_STATUS, IS_HIDDEN) + // - TYPE: Type of the option, whether it's integer or boolean etc. // This is important for validating user input. Note that // it's a string, rather than an actual type: since we can // load checkers runtime, we can't use template hackery for // sorting this out compile-time. - // - PACKAGENAME: Name of the package. - // - OPTIONNAME: Name of the option. - // - DESCRIPTION - // - DEFAULT: The default value for this option. + // - FULLNAME: Name of the package. + // - CMDFLAG: Name of the option. + // - DESC: The description of the option. + // - DEFAULT_VAL: The default value for this option as a string. + // - DEVELOPMENT_STATUS: "released" or "alpha". + // - IS_HIDDEN: Boolean (true or false) marking if the option is hidden. // // The full option can be specified in the command like this: - // -analyzer-config PACKAGENAME:OPTIONNAME=VALUE + // -analyzer-config FULLNAME:CMDFLAG=VALUE OS << "\n" "#ifdef GET_PACKAGE_OPTIONS\n"; for (const Record *Package : packages) { @@ -233,12 +236,21 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) { // Emit checkers. // - // CHECKER(FULLNAME, CLASS, HELPTEXT) + // CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) // - FULLNAME: The full name of the checker, including packages, e.g.: // alpha.cplusplus.UninitializedObject - // - CLASS: The name of the checker, with "Checker" appended, e.g.: - // UninitializedObjectChecker + // - CLASS: The common ending of the name of the register... and + // shouldRegister... functions. Traditionally coincides with the + // name of the class that implements the checker, but can be + // anything else e.g. in checker families. // - HELPTEXT: The description of the checker. + // - DOC_URI: If the checker is NotDocumented, an empty string; if the + // checker HasDocumentation, the concatenation of the fixed URL + // https://clang.llvm.org/docs/analyzer/checkers.html# and + // a html id derived from the full name by writing '-' instead + // of '.' and lowercasing. + // - IS_HIDDEN: Boolean (true or false) marking if the checker is hidden. + OS << "\n" "#ifdef GET_CHECKERS\n" "\n"; @@ -300,19 +312,22 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) { // Emit a package option. // - // CHECKER_OPTION(OPTIONTYPE, CHECKERNAME, OPTIONNAME, DESCRIPTION, DEFAULT) - // - OPTIONTYPE: Type of the option, whether it's integer or boolean etc. + // CHECKER_OPTION(TYPE, FULLNAME, CMDFLAG, DESC, DEFAULT_VAL, + // DEVELOPMENT_STATUS, IS_HIDDEN) + // - TYPE: Type of the option, whether it's integer or boolean etc. // This is important for validating user input. Note that // it's a string, rather than an actual type: since we can // load checkers runtime, we can't use template hackery for // sorting this out compile-time. - // - CHECKERNAME: Name of the package. - // - OPTIONNAME: Name of the option. - // - DESCRIPTION - // - DEFAULT: The default value for this option. + // - FULLNAME: Name of the checker. + // - CMDFLAG: Name of the option. + // - DESC: The description of the option. + // - DEFAULT_VAL: The default value for this option as a string. + // - DEVELOPMENT_STATUS: "released" or "alpha". + // - IS_HIDDEN: Boolean (true or false) marking if the option is hidden. // // The full option can be specified in the command like this: - // -analyzer-config CHECKERNAME:OPTIONNAME=VALUE + // -analyzer-config FULLNAME:CMDFLAG=VALUE OS << "\n" "#ifdef GET_CHECKER_OPTIONS\n"; for (const Record *Checker : checkers) { diff --git a/clang/utils/TableGen/ClangTypeNodesEmitter.cpp b/clang/utils/TableGen/ClangTypeNodesEmitter.cpp index 37039361cfc2..2e1eaef6c182 100644 --- a/clang/utils/TableGen/ClangTypeNodesEmitter.cpp +++ b/clang/utils/TableGen/ClangTypeNodesEmitter.cpp @@ -40,8 +40,9 @@ // There is a sixth macro, independent of the others. Most clients // will not need to use it. // -// LEAF_TYPE(Class) - A type that never has inner types. Clients -// which can operate on such types more efficiently may wish to do so. +// ALWAYS_CANONICAL_TYPE(Class) - A type which is always identical to its +// canonical type. Clients which can operate on such types more efficiently +// may wish to do so. // //===----------------------------------------------------------------------===// @@ -66,7 +67,7 @@ using namespace clang::tblgen; #define NonCanonicalUnlessDependentTypeMacroName "NON_CANONICAL_UNLESS_DEPENDENT_TYPE" #define TypeMacroArgs "(Class, Base)" #define LastTypeMacroName "LAST_TYPE" -#define LeafTypeMacroName "LEAF_TYPE" +#define AlwaysCanonicalTypeMacroName "ALWAYS_CANONICAL_TYPE" #define TypeClassName "Type" @@ -90,7 +91,7 @@ private: void emitNodeInvocations(); void emitLastNodeInvocation(TypeNode lastType); - void emitLeafNodeInvocations(); + void emitAlwaysCanonicalNodeInvocations(); void addMacroToUndef(StringRef macroName); void emitUndefs(); @@ -109,12 +110,12 @@ void TypeNodeEmitter::emit() { emitFallbackDefine(AbstractTypeMacroName, TypeMacroName, TypeMacroArgs); emitFallbackDefine(NonCanonicalTypeMacroName, TypeMacroName, TypeMacroArgs); emitFallbackDefine(DependentTypeMacroName, TypeMacroName, TypeMacroArgs); - emitFallbackDefine(NonCanonicalUnlessDependentTypeMacroName, TypeMacroName, + emitFallbackDefine(NonCanonicalUnlessDependentTypeMacroName, TypeMacroName, TypeMacroArgs); // Invocations. emitNodeInvocations(); - emitLeafNodeInvocations(); + emitAlwaysCanonicalNodeInvocations(); // Postmatter emitUndefs(); @@ -178,15 +179,16 @@ void TypeNodeEmitter::emitLastNodeInvocation(TypeNode type) { "#endif\n"; } -void TypeNodeEmitter::emitLeafNodeInvocations() { - Out << "#ifdef " LeafTypeMacroName "\n"; +void TypeNodeEmitter::emitAlwaysCanonicalNodeInvocations() { + Out << "#ifdef " AlwaysCanonicalTypeMacroName "\n"; for (TypeNode type : Types) { - if (!type.isSubClassOf(LeafTypeClassName)) continue; - Out << LeafTypeMacroName "(" << type.getId() << ")\n"; + if (!type.isSubClassOf(AlwaysCanonicalTypeClassName)) + continue; + Out << AlwaysCanonicalTypeMacroName "(" << type.getId() << ")\n"; } - Out << "#undef " LeafTypeMacroName "\n" + Out << "#undef " AlwaysCanonicalTypeMacroName "\n" "#endif\n"; } diff --git a/clang/utils/TableGen/RISCVVEmitter.cpp b/clang/utils/TableGen/RISCVVEmitter.cpp index 17f0c8280bde..f73b0aecc3b6 100644 --- a/clang/utils/TableGen/RISCVVEmitter.cpp +++ b/clang/utils/TableGen/RISCVVEmitter.cpp @@ -166,6 +166,8 @@ static VectorTypeModifier getTupleVTM(unsigned NF) { static_cast<uint8_t>(VectorTypeModifier::Tuple2) + (NF - 2)); } +static const unsigned UnknownIndex = (unsigned)-1; + static unsigned getIndexedLoadStorePtrIdx(const RVVIntrinsic *RVVI) { // We need a special rule for segment load/store since the data width is not // encoded in the intrinsic name itself. @@ -183,7 +185,7 @@ static unsigned getIndexedLoadStorePtrIdx(const RVVIntrinsic *RVVI) { if (IRName.starts_with("vsoxseg") || IRName.starts_with("vsuxseg")) return RVVI->isMasked() ? 1 : 0; - return (unsigned)-1; + return UnknownIndex; } // This function is used to get the log2SEW of each segment load/store, this @@ -249,19 +251,21 @@ void emitCodeGenSwitchBody(const RVVIntrinsic *RVVI, raw_ostream &OS) { OS << " ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n"; OS << " PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n"; - OS << " SegInstSEW = " << getSegInstLog2SEW(RVVI->getOverloadedName()) - << ";\n"; + unsigned IndexedLoadStorePtrIdx = getIndexedLoadStorePtrIdx(RVVI); + if (IndexedLoadStorePtrIdx != UnknownIndex) { + OS << " {\n"; + OS << " auto PointeeType = E->getArg(" << IndexedLoadStorePtrIdx + << ")->getType()->getPointeeType();\n"; + OS << " SegInstSEW = " + "llvm::Log2_64(getContext().getTypeSize(PointeeType));\n"; + OS << " }\n"; + } else { + OS << " SegInstSEW = " << getSegInstLog2SEW(RVVI->getOverloadedName()) + << ";\n"; + } if (RVVI->hasManualCodegen()) { OS << "IsMasked = " << (RVVI->isMasked() ? "true" : "false") << ";\n"; - - // Skip the non-indexed load/store and compatible header load/store. - OS << "if (SegInstSEW == (unsigned)-1) {\n"; - OS << " auto PointeeType = E->getArg(" << getIndexedLoadStorePtrIdx(RVVI) - << " )->getType()->getPointeeType();\n"; - OS << " SegInstSEW = " - " llvm::Log2_64(getContext().getTypeSize(PointeeType));\n}\n"; - OS << RVVI->getManualCodegen(); OS << "break;\n"; return; |
