[Mlir-commits] [mlir] e813750 - [NFC] Rename variable `recordKeeper` to `records` (#110989)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Oct 3 06:30:35 PDT 2024
Author: Rahul Joshi
Date: 2024-10-03T06:30:31-07:00
New Revision: e813750354bbc08551cf23ff559a54b4a9ea1f29
URL: https://github.com/llvm/llvm-project/commit/e813750354bbc08551cf23ff559a54b4a9ea1f29
DIFF: https://github.com/llvm/llvm-project/commit/e813750354bbc08551cf23ff559a54b4a9ea1f29.diff
LOG: [NFC] Rename variable `recordKeeper` to `records` (#110989)
Added:
Modified:
mlir/include/mlir/TableGen/GenInfo.h
mlir/tools/mlir-tblgen/DialectGen.cpp
mlir/tools/mlir-tblgen/DirectiveCommonGen.cpp
mlir/tools/mlir-tblgen/EnumPythonBindingGen.cpp
mlir/tools/mlir-tblgen/EnumsGen.cpp
mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp
mlir/tools/mlir-tblgen/OmpOpGen.cpp
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
mlir/tools/mlir-tblgen/OpDocGen.cpp
mlir/tools/mlir-tblgen/OpGenHelpers.cpp
mlir/tools/mlir-tblgen/OpGenHelpers.h
mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
mlir/tools/mlir-tblgen/PassDocGen.cpp
mlir/tools/mlir-tblgen/PassGen.cpp
mlir/tools/mlir-tblgen/RewriterGen.cpp
mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
mlir/tools/tblgen-to-irdl/OpDefinitionsGen.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/TableGen/GenInfo.h b/mlir/include/mlir/TableGen/GenInfo.h
index ef2e12f07df16d..9dec0e4f1bd919 100644
--- a/mlir/include/mlir/TableGen/GenInfo.h
+++ b/mlir/include/mlir/TableGen/GenInfo.h
@@ -21,8 +21,8 @@ class RecordKeeper;
namespace mlir {
/// Generator function to invoke.
-using GenFunction = std::function<bool(const llvm::RecordKeeper &recordKeeper,
- raw_ostream &os)>;
+using GenFunction =
+ std::function<bool(const llvm::RecordKeeper &records, raw_ostream &os)>;
/// Structure to group information about a generator (argument to invoke via
/// mlir-tblgen, description, and generator function).
@@ -34,9 +34,9 @@ class GenInfo {
: arg(arg), description(description), generator(std::move(generator)) {}
/// Invokes the generator and returns whether the generator failed.
- bool invoke(const llvm::RecordKeeper &recordKeeper, raw_ostream &os) const {
+ bool invoke(const llvm::RecordKeeper &records, raw_ostream &os) const {
assert(generator && "Cannot call generator with null generator");
- return generator(recordKeeper, os);
+ return generator(records, os);
}
/// Returns the command line option that may be passed to 'mlir-tblgen' to
diff --git a/mlir/tools/mlir-tblgen/DialectGen.cpp b/mlir/tools/mlir-tblgen/DialectGen.cpp
index 76da9d7cea4e8d..55c3d9da259005 100644
--- a/mlir/tools/mlir-tblgen/DialectGen.cpp
+++ b/mlir/tools/mlir-tblgen/DialectGen.cpp
@@ -297,11 +297,10 @@ static void emitDialectDecl(Dialect &dialect, raw_ostream &os) {
<< "::" << dialect.getCppClassName() << ")\n";
}
-static bool emitDialectDecls(const RecordKeeper &recordKeeper,
- raw_ostream &os) {
- emitSourceFileHeader("Dialect Declarations", os, recordKeeper);
+static bool emitDialectDecls(const RecordKeeper &records, raw_ostream &os) {
+ emitSourceFileHeader("Dialect Declarations", os, records);
- auto dialectDefs = recordKeeper.getAllDerivedDefinitions("Dialect");
+ auto dialectDefs = records.getAllDerivedDefinitions("Dialect");
if (dialectDefs.empty())
return false;
@@ -342,7 +341,7 @@ static const char *const dialectDestructorStr = R"(
)";
-static void emitDialectDef(Dialect &dialect, const RecordKeeper &recordKeeper,
+static void emitDialectDef(Dialect &dialect, const RecordKeeper &records,
raw_ostream &os) {
std::string cppClassName = dialect.getCppClassName();
@@ -390,10 +389,10 @@ static void emitDialectDef(Dialect &dialect, const RecordKeeper &recordKeeper,
os << llvm::formatv(dialectDestructorStr, cppClassName);
}
-static bool emitDialectDefs(const RecordKeeper &recordKeeper, raw_ostream &os) {
- emitSourceFileHeader("Dialect Definitions", os, recordKeeper);
+static bool emitDialectDefs(const RecordKeeper &records, raw_ostream &os) {
+ emitSourceFileHeader("Dialect Definitions", os, records);
- auto dialectDefs = recordKeeper.getAllDerivedDefinitions("Dialect");
+ auto dialectDefs = records.getAllDerivedDefinitions("Dialect");
if (dialectDefs.empty())
return false;
@@ -401,7 +400,7 @@ static bool emitDialectDefs(const RecordKeeper &recordKeeper, raw_ostream &os) {
std::optional<Dialect> dialect = findDialectToGenerate(dialects);
if (!dialect)
return true;
- emitDialectDef(*dialect, recordKeeper, os);
+ emitDialectDef(*dialect, records, os);
return false;
}
diff --git a/mlir/tools/mlir-tblgen/DirectiveCommonGen.cpp b/mlir/tools/mlir-tblgen/DirectiveCommonGen.cpp
index 26de95fcc57736..09c068fb766935 100644
--- a/mlir/tools/mlir-tblgen/DirectiveCommonGen.cpp
+++ b/mlir/tools/mlir-tblgen/DirectiveCommonGen.cpp
@@ -42,7 +42,7 @@ using llvm::RecordKeeper;
// Clause record in OMP.td. This name can be used to specify the type of the
// OpenMP operation's operand. The allowedClauseValues field provides the list
// of ClauseValues which are part of the enumeration.
-static bool emitDecls(const RecordKeeper &recordKeeper, llvm::StringRef dialect,
+static bool emitDecls(const RecordKeeper &records, llvm::StringRef dialect,
raw_ostream &os) {
// A dialect must be selected for the generated attributes.
if (dialect.empty()) {
@@ -51,10 +51,10 @@ static bool emitDecls(const RecordKeeper &recordKeeper, llvm::StringRef dialect,
}
const auto directiveLanguages =
- recordKeeper.getAllDerivedDefinitions("DirectiveLanguage");
+ records.getAllDerivedDefinitions("DirectiveLanguage");
assert(!directiveLanguages.empty() && "DirectiveLanguage missing.");
- for (const Clause c : recordKeeper.getAllDerivedDefinitions("Clause")) {
+ for (const Clause c : records.getAllDerivedDefinitions("Clause")) {
const auto &clauseVals = c.getClauseVals();
if (clauseVals.empty())
continue;
diff --git a/mlir/tools/mlir-tblgen/EnumPythonBindingGen.cpp b/mlir/tools/mlir-tblgen/EnumPythonBindingGen.cpp
index 189487794f8f7c..3f660ae151c749 100644
--- a/mlir/tools/mlir-tblgen/EnumPythonBindingGen.cpp
+++ b/mlir/tools/mlir-tblgen/EnumPythonBindingGen.cpp
@@ -132,16 +132,16 @@ static bool emitDialectEnumAttributeBuilder(StringRef attrDefName,
/// Emits Python bindings for all enums in the record keeper. Returns
/// `false` on success, `true` on failure.
-static bool emitPythonEnums(const RecordKeeper &recordKeeper, raw_ostream &os) {
+static bool emitPythonEnums(const RecordKeeper &records, raw_ostream &os) {
os << fileHeader;
for (const Record *it :
- recordKeeper.getAllDerivedDefinitionsIfDefined("EnumAttrInfo")) {
+ records.getAllDerivedDefinitionsIfDefined("EnumAttrInfo")) {
EnumAttr enumAttr(*it);
emitEnumClass(enumAttr, os);
emitAttributeBuilder(enumAttr, os);
}
for (const Record *it :
- recordKeeper.getAllDerivedDefinitionsIfDefined("EnumAttr")) {
+ records.getAllDerivedDefinitionsIfDefined("EnumAttr")) {
AttrOrTypeDef attr(&*it);
if (!attr.getMnemonic()) {
llvm::errs() << "enum case " << attr
diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp
index 5f2008818e3eb7..47ffd291cae687 100644
--- a/mlir/tools/mlir-tblgen/EnumsGen.cpp
+++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp
@@ -641,11 +641,11 @@ class {1} : public ::mlir::{2} {
emitDenseMapInfo(qualName, underlyingType, cppNamespace, os);
}
-static bool emitEnumDecls(const RecordKeeper &recordKeeper, raw_ostream &os) {
- llvm::emitSourceFileHeader("Enum Utility Declarations", os, recordKeeper);
+static bool emitEnumDecls(const RecordKeeper &records, raw_ostream &os) {
+ llvm::emitSourceFileHeader("Enum Utility Declarations", os, records);
for (const Record *def :
- recordKeeper.getAllDerivedDefinitionsIfDefined("EnumAttrInfo"))
+ records.getAllDerivedDefinitionsIfDefined("EnumAttrInfo"))
emitEnumDecl(*def, os);
return false;
@@ -679,11 +679,11 @@ static void emitEnumDef(const Record &enumDef, raw_ostream &os) {
os << "\n";
}
-static bool emitEnumDefs(const RecordKeeper &recordKeeper, raw_ostream &os) {
- llvm::emitSourceFileHeader("Enum Utility Definitions", os, recordKeeper);
+static bool emitEnumDefs(const RecordKeeper &records, raw_ostream &os) {
+ llvm::emitSourceFileHeader("Enum Utility Definitions", os, records);
for (const Record *def :
- recordKeeper.getAllDerivedDefinitionsIfDefined("EnumAttrInfo"))
+ records.getAllDerivedDefinitionsIfDefined("EnumAttrInfo"))
emitEnumDef(*def, os);
return false;
diff --git a/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp b/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp
index 4e7ddab75fc1dd..9e19f479d673a0 100644
--- a/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp
+++ b/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp
@@ -177,9 +177,8 @@ static LogicalResult emitOneBuilder(const Record &record, raw_ostream &os) {
// Emit all builders. Returns false on success because of the generator
// registration requirements.
-static bool emitBuilders(const RecordKeeper &recordKeeper, raw_ostream &os) {
- for (const Record *def :
- recordKeeper.getAllDerivedDefinitions("LLVM_OpBase")) {
+static bool emitBuilders(const RecordKeeper &records, raw_ostream &os) {
+ for (const Record *def : records.getAllDerivedDefinitions("LLVM_OpBase")) {
if (failed(emitOneBuilder(*def, os)))
return true;
}
@@ -305,15 +304,14 @@ static LogicalResult emitOneMLIRBuilder(const Record &record, raw_ostream &os,
// Emit all intrinsic MLIR builders. Returns false on success because of the
// generator registration requirements.
-static bool emitIntrMLIRBuilders(const RecordKeeper &recordKeeper,
- raw_ostream &os) {
+static bool emitIntrMLIRBuilders(const RecordKeeper &records, raw_ostream &os) {
// Emit condition to check if "llvmEnumName" matches the intrinsic id.
auto emitIntrCond = [](const Record &record) {
return "intrinsicID == llvm::Intrinsic::" +
record.getValueAsString("llvmEnumName");
};
for (const Record *def :
- recordKeeper.getAllDerivedDefinitions("LLVM_IntrOpBase")) {
+ records.getAllDerivedDefinitions("LLVM_IntrOpBase")) {
if (failed(emitOneMLIRBuilder(*def, os, emitIntrCond)))
return true;
}
@@ -322,15 +320,13 @@ static bool emitIntrMLIRBuilders(const RecordKeeper &recordKeeper,
// Emit all op builders. Returns false on success because of the
// generator registration requirements.
-static bool emitOpMLIRBuilders(const RecordKeeper &recordKeeper,
- raw_ostream &os) {
+static bool emitOpMLIRBuilders(const RecordKeeper &records, raw_ostream &os) {
// Emit condition to check if "llvmInstName" matches the instruction opcode.
auto emitOpcodeCond = [](const Record &record) {
return "inst->getOpcode() == llvm::Instruction::" +
record.getValueAsString("llvmInstName");
};
- for (const Record *def :
- recordKeeper.getAllDerivedDefinitions("LLVM_OpBase")) {
+ for (const Record *def : records.getAllDerivedDefinitions("LLVM_OpBase")) {
if (failed(emitOneMLIRBuilder(*def, os, emitOpcodeCond)))
return true;
}
@@ -536,17 +532,15 @@ static void emitOneCEnumFromConversion(const Record *record, raw_ostream &os) {
// Emits conversion functions between MLIR enum attribute case and corresponding
// LLVM API enumerants for all registered LLVM dialect enum attributes.
template <bool ConvertTo>
-static bool emitEnumConversionDefs(const RecordKeeper &recordKeeper,
+static bool emitEnumConversionDefs(const RecordKeeper &records,
raw_ostream &os) {
- for (const Record *def :
- recordKeeper.getAllDerivedDefinitions("LLVM_EnumAttr"))
+ for (const Record *def : records.getAllDerivedDefinitions("LLVM_EnumAttr"))
if (ConvertTo)
emitOneEnumToConversion(def, os);
else
emitOneEnumFromConversion(def, os);
- for (const Record *def :
- recordKeeper.getAllDerivedDefinitions("LLVM_CEnumAttr"))
+ for (const Record *def : records.getAllDerivedDefinitions("LLVM_CEnumAttr"))
if (ConvertTo)
emitOneCEnumToConversion(def, os);
else
@@ -562,10 +556,9 @@ static void emitOneIntrinsic(const Record &record, raw_ostream &os) {
// Emit the list of LLVM IR intrinsics identifiers that are convertible to a
// matching MLIR LLVM dialect intrinsic operation.
-static bool emitConvertibleIntrinsics(const RecordKeeper &recordKeeper,
+static bool emitConvertibleIntrinsics(const RecordKeeper &records,
raw_ostream &os) {
- for (const Record *def :
- recordKeeper.getAllDerivedDefinitions("LLVM_IntrOpBase"))
+ for (const Record *def : records.getAllDerivedDefinitions("LLVM_IntrOpBase"))
emitOneIntrinsic(*def, os);
return false;
diff --git a/mlir/tools/mlir-tblgen/OmpOpGen.cpp b/mlir/tools/mlir-tblgen/OmpOpGen.cpp
index 68bb5ddca153a6..1c20a6a9bcf4e8 100644
--- a/mlir/tools/mlir-tblgen/OmpOpGen.cpp
+++ b/mlir/tools/mlir-tblgen/OmpOpGen.cpp
@@ -328,8 +328,8 @@ static void genOperandsDef(const Record *op, raw_ostream &os) {
/// Verify that all properties of `OpenMP_Clause`s of records deriving from
/// `OpenMP_Op`s have been inherited by the latter.
-static bool verifyDecls(const RecordKeeper &recordKeeper, raw_ostream &) {
- for (const Record *op : recordKeeper.getAllDerivedDefinitions("OpenMP_Op")) {
+static bool verifyDecls(const RecordKeeper &records, raw_ostream &) {
+ for (const Record *op : records.getAllDerivedDefinitions("OpenMP_Op")) {
for (const Record *clause : op->getValueAsListOfDefs("clauseList"))
verifyClause(op, clause);
}
@@ -341,16 +341,15 @@ static bool verifyDecls(const RecordKeeper &recordKeeper, raw_ostream &) {
/// `OpenMP_Clause` definitions and aggregate them into operation-specific
/// structures according to the `clauses` argument of each definition deriving
/// from `OpenMP_Op`.
-static bool genClauseOps(const RecordKeeper &recordKeeper, raw_ostream &os) {
+static bool genClauseOps(const RecordKeeper &records, raw_ostream &os) {
mlir::tblgen::NamespaceEmitter ns(os, "mlir::omp");
- for (const Record *clause :
- recordKeeper.getAllDerivedDefinitions("OpenMP_Clause"))
+ for (const Record *clause : records.getAllDerivedDefinitions("OpenMP_Clause"))
genClauseOpsStruct(clause, os);
// Produce base mixin class.
os << baseMixinClass;
- for (const Record *op : recordKeeper.getAllDerivedDefinitions("OpenMP_Op"))
+ for (const Record *op : records.getAllDerivedDefinitions("OpenMP_Op"))
genOperandsDef(op, os);
return false;
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index cbe8a055958567..67df002ce38181 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -4498,7 +4498,7 @@ void OpOperandAdaptorEmitter::emitDef(
/// Emit the class declarations or definitions for the given op defs.
static void
-emitOpClasses(const RecordKeeper &recordKeeper,
+emitOpClasses(const RecordKeeper &records,
const std::vector<const Record *> &defs, raw_ostream &os,
const StaticVerifierFunctionEmitter &staticVerifierEmitter,
bool emitDecl) {
@@ -4535,7 +4535,7 @@ emitOpClasses(const RecordKeeper &recordKeeper,
}
/// Emit the declarations for the provided op classes.
-static void emitOpClassDecls(const RecordKeeper &recordKeeper,
+static void emitOpClassDecls(const RecordKeeper &records,
const std::vector<const Record *> &defs,
raw_ostream &os) {
// First emit forward declaration for each class, this allows them to refer
@@ -4550,37 +4550,37 @@ static void emitOpClassDecls(const RecordKeeper &recordKeeper,
IfDefScope scope("GET_OP_CLASSES", os);
if (defs.empty())
return;
- StaticVerifierFunctionEmitter staticVerifierEmitter(os, recordKeeper);
+ StaticVerifierFunctionEmitter staticVerifierEmitter(os, records);
staticVerifierEmitter.collectOpConstraints(defs);
- emitOpClasses(recordKeeper, defs, os, staticVerifierEmitter,
+ emitOpClasses(records, defs, os, staticVerifierEmitter,
/*emitDecl=*/true);
}
/// Emit the definitions for the provided op classes.
-static void emitOpClassDefs(const RecordKeeper &recordKeeper,
+static void emitOpClassDefs(const RecordKeeper &records,
ArrayRef<const Record *> defs, raw_ostream &os,
StringRef constraintPrefix = "") {
if (defs.empty())
return;
// Generate all of the locally instantiated methods first.
- StaticVerifierFunctionEmitter staticVerifierEmitter(os, recordKeeper,
+ StaticVerifierFunctionEmitter staticVerifierEmitter(os, records,
constraintPrefix);
os << formatv(opCommentHeader, "Local Utility Method", "Definitions");
staticVerifierEmitter.collectOpConstraints(defs);
staticVerifierEmitter.emitOpConstraints(defs);
// Emit the classes.
- emitOpClasses(recordKeeper, defs, os, staticVerifierEmitter,
+ emitOpClasses(records, defs, os, staticVerifierEmitter,
/*emitDecl=*/false);
}
/// Emit op declarations for all op records.
-static bool emitOpDecls(const RecordKeeper &recordKeeper, raw_ostream &os) {
- emitSourceFileHeader("Op Declarations", os, recordKeeper);
+static bool emitOpDecls(const RecordKeeper &records, raw_ostream &os) {
+ emitSourceFileHeader("Op Declarations", os, records);
- std::vector<const Record *> defs = getRequestedOpDefinitions(recordKeeper);
- emitOpClassDecls(recordKeeper, defs, os);
+ std::vector<const Record *> defs = getRequestedOpDefinitions(records);
+ emitOpClassDecls(records, defs, os);
// If we are generating sharded op definitions, emit the sharded op
// registration hooks.
@@ -4606,7 +4606,7 @@ static bool emitOpDecls(const RecordKeeper &recordKeeper, raw_ostream &os) {
/// Generate the dialect op registration hook and the op class definitions for a
/// shard of ops.
-static void emitOpDefShard(const RecordKeeper &recordKeeper,
+static void emitOpDefShard(const RecordKeeper &records,
ArrayRef<const Record *> defs,
const Dialect &dialect, unsigned shardIndex,
unsigned shardCount, raw_ostream &os) {
@@ -4640,14 +4640,14 @@ static void emitOpDefShard(const RecordKeeper &recordKeeper,
os << "}\n";
// Generate the per-shard op definitions.
- emitOpClassDefs(recordKeeper, defs, os, indexStr);
+ emitOpClassDefs(records, defs, os, indexStr);
}
/// Emit op definitions for all op records.
-static bool emitOpDefs(const RecordKeeper &recordKeeper, raw_ostream &os) {
- emitSourceFileHeader("Op Definitions", os, recordKeeper);
+static bool emitOpDefs(const RecordKeeper &records, raw_ostream &os) {
+ emitSourceFileHeader("Op Definitions", os, records);
- std::vector<const Record *> defs = getRequestedOpDefinitions(recordKeeper);
+ std::vector<const Record *> defs = getRequestedOpDefinitions(records);
SmallVector<ArrayRef<const Record *>, 4> shardedDefs;
shardOpDefinitions(defs, shardedDefs);
@@ -4662,7 +4662,7 @@ static bool emitOpDefs(const RecordKeeper &recordKeeper, raw_ostream &os) {
}
{
IfDefScope scope("GET_OP_CLASSES", os);
- emitOpClassDefs(recordKeeper, defs, os);
+ emitOpClassDefs(records, defs, os);
}
return false;
}
@@ -4671,7 +4671,7 @@ static bool emitOpDefs(const RecordKeeper &recordKeeper, raw_ostream &os) {
return false;
Dialect dialect = Operator(defs.front()).getDialect();
for (auto [idx, value] : llvm::enumerate(shardedDefs)) {
- emitOpDefShard(recordKeeper, value, dialect, idx, shardedDefs.size(), os);
+ emitOpDefShard(records, value, dialect, idx, shardedDefs.size(), os);
}
return false;
}
diff --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp
index 5171e3fad9e84b..ff3c6b16bb6ebc 100644
--- a/mlir/tools/mlir-tblgen/OpDocGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp
@@ -282,11 +282,11 @@ static void emitSourceLink(StringRef inputFilename, raw_ostream &os) {
<< inputFromMlirInclude << ")\n\n";
}
-static void emitOpDoc(const RecordKeeper &recordKeeper, raw_ostream &os) {
- auto opDefs = getRequestedOpDefinitions(recordKeeper);
+static void emitOpDoc(const RecordKeeper &records, raw_ostream &os) {
+ auto opDefs = getRequestedOpDefinitions(records);
os << "<!-- Autogenerated by mlir-tblgen; don't manually edit -->\n";
- emitSourceLink(recordKeeper.getInputFilename(), os);
+ emitSourceLink(records.getInputFilename(), os);
for (const Record *opDef : opDefs)
emitOpDoc(Operator(opDef), os);
}
@@ -371,9 +371,9 @@ static void emitAttrOrTypeDefDoc(const AttrOrTypeDef &def, raw_ostream &os) {
os << "\n";
}
-static void emitAttrOrTypeDefDoc(const RecordKeeper &recordKeeper,
- raw_ostream &os, StringRef recordTypeName) {
- auto defs = recordKeeper.getAllDerivedDefinitions(recordTypeName);
+static void emitAttrOrTypeDefDoc(const RecordKeeper &records, raw_ostream &os,
+ StringRef recordTypeName) {
+ auto defs = records.getAllDerivedDefinitions(recordTypeName);
os << "<!-- Autogenerated by mlir-tblgen; don't manually edit -->\n";
for (const Record *def : defs)
@@ -404,9 +404,9 @@ static void emitEnumDoc(const EnumAttr &def, raw_ostream &os) {
os << "\n";
}
-static void emitEnumDoc(const RecordKeeper &recordKeeper, raw_ostream &os) {
+static void emitEnumDoc(const RecordKeeper &records, raw_ostream &os) {
os << "<!-- Autogenerated by mlir-tblgen; don't manually edit -->\n";
- for (const Record *def : recordKeeper.getAllDerivedDefinitions("EnumAttr"))
+ for (const Record *def : records.getAllDerivedDefinitions("EnumAttr"))
emitEnumDoc(EnumAttr(def), os);
}
@@ -514,20 +514,19 @@ static void emitDialectDoc(const Dialect &dialect, StringRef inputFilename,
os);
}
-static bool emitDialectDoc(const RecordKeeper &recordKeeper, raw_ostream &os) {
- auto dialectDefs = recordKeeper.getAllDerivedDefinitionsIfDefined("Dialect");
+static bool emitDialectDoc(const RecordKeeper &records, raw_ostream &os) {
+ auto dialectDefs = records.getAllDerivedDefinitionsIfDefined("Dialect");
SmallVector<Dialect> dialects(dialectDefs.begin(), dialectDefs.end());
std::optional<Dialect> dialect = findDialectToGenerate(dialects);
if (!dialect)
return true;
- std::vector<const Record *> opDefs = getRequestedOpDefinitions(recordKeeper);
- auto attrDefs = recordKeeper.getAllDerivedDefinitionsIfDefined("DialectAttr");
- auto typeDefs = recordKeeper.getAllDerivedDefinitionsIfDefined("DialectType");
- auto typeDefDefs = recordKeeper.getAllDerivedDefinitionsIfDefined("TypeDef");
- auto attrDefDefs = recordKeeper.getAllDerivedDefinitionsIfDefined("AttrDef");
- auto enumDefs =
- recordKeeper.getAllDerivedDefinitionsIfDefined("EnumAttrInfo");
+ std::vector<const Record *> opDefs = getRequestedOpDefinitions(records);
+ auto attrDefs = records.getAllDerivedDefinitionsIfDefined("DialectAttr");
+ auto typeDefs = records.getAllDerivedDefinitionsIfDefined("DialectType");
+ auto typeDefDefs = records.getAllDerivedDefinitionsIfDefined("TypeDef");
+ auto attrDefDefs = records.getAllDerivedDefinitionsIfDefined("AttrDef");
+ auto enumDefs = records.getAllDerivedDefinitionsIfDefined("EnumAttrInfo");
std::vector<Attribute> dialectAttrs;
std::vector<AttrDef> dialectAttrDefs;
@@ -565,7 +564,7 @@ static bool emitDialectDoc(const RecordKeeper &recordKeeper, raw_ostream &os) {
}
}
for (const Record *rec :
- recordKeeper.getAllDerivedDefinitionsIfDefined("OpDocGroup")) {
+ records.getAllDerivedDefinitionsIfDefined("OpDocGroup")) {
if (opDocGroup[rec].ops.empty())
continue;
opDocGroup[rec].summary = rec->getValueAsString("summary");
@@ -595,7 +594,7 @@ static bool emitDialectDoc(const RecordKeeper &recordKeeper, raw_ostream &os) {
});
os << "<!-- Autogenerated by mlir-tblgen; don't manually edit -->\n";
- emitDialectDoc(*dialect, recordKeeper.getInputFilename(), dialectAttrs,
+ emitDialectDoc(*dialect, records.getInputFilename(), dialectAttrs,
dialectAttrDefs, dialectOps, dialectTypes, dialectTypeDefs,
dialectEnums, os);
return false;
diff --git a/mlir/tools/mlir-tblgen/OpGenHelpers.cpp b/mlir/tools/mlir-tblgen/OpGenHelpers.cpp
index 18e42285bdde91..44dbacf19fffd4 100644
--- a/mlir/tools/mlir-tblgen/OpGenHelpers.cpp
+++ b/mlir/tools/mlir-tblgen/OpGenHelpers.cpp
@@ -45,14 +45,14 @@ static std::string getOperationName(const Record &def) {
}
std::vector<const Record *>
-mlir::tblgen::getRequestedOpDefinitions(const RecordKeeper &recordKeeper) {
- const Record *classDef = recordKeeper.getClass("Op");
+mlir::tblgen::getRequestedOpDefinitions(const RecordKeeper &records) {
+ const Record *classDef = records.getClass("Op");
if (!classDef)
PrintFatalError("ERROR: Couldn't find the 'Op' class!\n");
Regex includeRegex(opIncFilter), excludeRegex(opExcFilter);
std::vector<const Record *> defs;
- for (const auto &def : recordKeeper.getDefs()) {
+ for (const auto &def : records.getDefs()) {
if (!def.second->isSubClassOf(classDef))
continue;
// Include if no include filter or include filter matches.
diff --git a/mlir/tools/mlir-tblgen/OpGenHelpers.h b/mlir/tools/mlir-tblgen/OpGenHelpers.h
index b7c9fe3a7b799c..62ae32cacc688c 100644
--- a/mlir/tools/mlir-tblgen/OpGenHelpers.h
+++ b/mlir/tools/mlir-tblgen/OpGenHelpers.h
@@ -23,7 +23,7 @@ namespace tblgen {
/// Returns all the op definitions filtered by the user. The filtering is via
/// command-line option "op-include-regex" and "op-exclude-regex".
std::vector<const llvm::Record *>
-getRequestedOpDefinitions(const llvm::RecordKeeper &recordKeeper);
+getRequestedOpDefinitions(const llvm::RecordKeeper &records);
/// Checks whether `str` is a Python keyword or would shadow builtin function.
/// Regenerate using python -c"print(set(sorted(__import__('keyword').kwlist)))"
diff --git a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
index 8fa286f14dc5ed..1f1b1d9a340391 100644
--- a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
@@ -64,9 +64,9 @@ static void emitMethodNameAndArgs(const InterfaceMethod &method,
/// Get an array of all OpInterface definitions but exclude those subclassing
/// "DeclareOpInterfaceMethods".
static std::vector<const Record *>
-getAllInterfaceDefinitions(const RecordKeeper &recordKeeper, StringRef name) {
+getAllInterfaceDefinitions(const RecordKeeper &records, StringRef name) {
std::vector<const Record *> defs =
- recordKeeper.getAllDerivedDefinitions((name + "Interface").str());
+ records.getAllDerivedDefinitions((name + "Interface").str());
std::string declareName = ("Declare" + name + "InterfaceMethods").str();
llvm::erase_if(defs, [&](const Record *def) {
diff --git a/mlir/tools/mlir-tblgen/PassDocGen.cpp b/mlir/tools/mlir-tblgen/PassDocGen.cpp
index 914112e926d8b8..a2cb514ece3eba 100644
--- a/mlir/tools/mlir-tblgen/PassDocGen.cpp
+++ b/mlir/tools/mlir-tblgen/PassDocGen.cpp
@@ -57,9 +57,9 @@ static void emitDoc(const Pass &pass, raw_ostream &os) {
}
}
-static void emitDocs(const RecordKeeper &recordKeeper, raw_ostream &os) {
+static void emitDocs(const RecordKeeper &records, raw_ostream &os) {
os << "<!-- Autogenerated by mlir-tblgen; don't manually edit -->\n";
- auto passDefs = recordKeeper.getAllDerivedDefinitions("PassBase");
+ auto passDefs = records.getAllDerivedDefinitions("PassBase");
// Collect the registered passes, sorted by argument name.
SmallVector<Pass, 16> passes(passDefs.begin(), passDefs.end());
diff --git a/mlir/tools/mlir-tblgen/PassGen.cpp b/mlir/tools/mlir-tblgen/PassGen.cpp
index 295f01b0875469..4b4ac41b9effb8 100644
--- a/mlir/tools/mlir-tblgen/PassGen.cpp
+++ b/mlir/tools/mlir-tblgen/PassGen.cpp
@@ -30,10 +30,10 @@ static llvm::cl::opt<std::string>
llvm::cl::cat(passGenCat));
/// Extract the list of passes from the TableGen records.
-static std::vector<Pass> getPasses(const RecordKeeper &recordKeeper) {
+static std::vector<Pass> getPasses(const RecordKeeper &records) {
std::vector<Pass> passes;
- for (const auto *def : recordKeeper.getAllDerivedDefinitions("PassBase"))
+ for (const auto *def : records.getAllDerivedDefinitions("PassBase"))
passes.emplace_back(def);
return passes;
@@ -446,8 +446,8 @@ static void emitOldPassDecl(const Pass &pass, raw_ostream &os) {
os << "};\n";
}
-static void emitPasses(const RecordKeeper &recordKeeper, raw_ostream &os) {
- std::vector<Pass> passes = getPasses(recordKeeper);
+static void emitPasses(const RecordKeeper &records, raw_ostream &os) {
+ std::vector<Pass> passes = getPasses(records);
os << "/* Autogenerated by mlir-tblgen; don't manually edit */\n";
os << "\n";
diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp
index 598eb8ea12fcc1..e2764f8493cd8a 100644
--- a/mlir/tools/mlir-tblgen/RewriterGen.cpp
+++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp
@@ -268,7 +268,7 @@ class PatternEmitter {
// inlining them.
class StaticMatcherHelper {
public:
- StaticMatcherHelper(raw_ostream &os, const RecordKeeper &recordKeeper,
+ StaticMatcherHelper(raw_ostream &os, const RecordKeeper &records,
RecordOperatorMap &mapper);
// Determine if we should inline the match logic or delegate to a static
@@ -1886,9 +1886,9 @@ void PatternEmitter::createAggregateLocalVarsForOpArgs(
}
StaticMatcherHelper::StaticMatcherHelper(raw_ostream &os,
- const RecordKeeper &recordKeeper,
+ const RecordKeeper &records,
RecordOperatorMap &mapper)
- : opMap(mapper), staticVerifierEmitter(os, recordKeeper) {}
+ : opMap(mapper), staticVerifierEmitter(os, records) {}
void StaticMatcherHelper::populateStaticMatchers(raw_ostream &os) {
// PatternEmitter will use the static matcher if there's one generated. To
@@ -1951,17 +1951,17 @@ StringRef StaticMatcherHelper::getVerifierName(DagLeaf leaf) {
return staticVerifierEmitter.getTypeConstraintFn(leaf.getAsConstraint());
}
-static void emitRewriters(const RecordKeeper &recordKeeper, raw_ostream &os) {
- emitSourceFileHeader("Rewriters", os, recordKeeper);
+static void emitRewriters(const RecordKeeper &records, raw_ostream &os) {
+ emitSourceFileHeader("Rewriters", os, records);
- auto patterns = recordKeeper.getAllDerivedDefinitions("Pattern");
+ auto patterns = records.getAllDerivedDefinitions("Pattern");
// We put the map here because it can be shared among multiple patterns.
RecordOperatorMap recordOpMap;
// Exam all the patterns and generate static matcher for the duplicated
// DagNode.
- StaticMatcherHelper staticMatcher(os, recordKeeper, recordOpMap);
+ StaticMatcherHelper staticMatcher(os, records, recordOpMap);
for (const Record *p : patterns)
staticMatcher.addPattern(p);
staticMatcher.populateStaticConstraintFunctions(os);
diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
index a92f05455be1b2..3480c81ff7d4bb 100644
--- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
+++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
@@ -196,12 +196,10 @@ static void emitInterfaceDef(const Availability &availability,
<< "}\n";
}
-static bool emitInterfaceDefs(const RecordKeeper &recordKeeper,
- raw_ostream &os) {
- llvm::emitSourceFileHeader("Availability Interface Definitions", os,
- recordKeeper);
+static bool emitInterfaceDefs(const RecordKeeper &records, raw_ostream &os) {
+ llvm::emitSourceFileHeader("Availability Interface Definitions", os, records);
- auto defs = recordKeeper.getAllDerivedDefinitions("Availability");
+ auto defs = records.getAllDerivedDefinitions("Availability");
SmallVector<const Record *, 1> handledClasses;
for (const Record *def : defs) {
SmallVector<const Record *, 1> parent;
@@ -286,12 +284,11 @@ static void emitInterfaceDecl(const Availability &availability,
os << "};\n\n";
}
-static bool emitInterfaceDecls(const RecordKeeper &recordKeeper,
- raw_ostream &os) {
+static bool emitInterfaceDecls(const RecordKeeper &records, raw_ostream &os) {
llvm::emitSourceFileHeader("Availability Interface Declarations", os,
- recordKeeper);
+ records);
- auto defs = recordKeeper.getAllDerivedDefinitions("Availability");
+ auto defs = records.getAllDerivedDefinitions("Availability");
SmallVector<const Record *, 4> handledClasses;
for (const Record *def : defs) {
SmallVector<const Record *, 1> parent;
@@ -451,11 +448,11 @@ static void emitEnumDecl(const Record &enumDef, raw_ostream &os) {
os << "} // namespace " << ns << "\n";
}
-static bool emitEnumDecls(const RecordKeeper &recordKeeper, raw_ostream &os) {
+static bool emitEnumDecls(const RecordKeeper &records, raw_ostream &os) {
llvm::emitSourceFileHeader("SPIR-V Enum Availability Declarations", os,
- recordKeeper);
+ records);
- auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttrInfo");
+ auto defs = records.getAllDerivedDefinitions("EnumAttrInfo");
for (const auto *def : defs)
emitEnumDecl(*def, os);
@@ -483,11 +480,11 @@ static void emitEnumDef(const Record &enumDef, raw_ostream &os) {
os << "\n";
}
-static bool emitEnumDefs(const RecordKeeper &recordKeeper, raw_ostream &os) {
+static bool emitEnumDefs(const RecordKeeper &records, raw_ostream &os) {
llvm::emitSourceFileHeader("SPIR-V Enum Availability Definitions", os,
- recordKeeper);
+ records);
- auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttrInfo");
+ auto defs = records.getAllDerivedDefinitions("EnumAttrInfo");
for (const auto *def : defs)
emitEnumDef(*def, os);
@@ -1121,9 +1118,8 @@ static void initExtendedSetDeserializationDispatch(StringRef extensionSetName,
extensionSetName, instructionID, words);
}
-static void
-emitExtendedSetDeserializationDispatch(const RecordKeeper &recordKeeper,
- raw_ostream &os) {
+static void emitExtendedSetDeserializationDispatch(const RecordKeeper &records,
+ raw_ostream &os) {
StringRef extensionSetName("extensionSetName"),
instructionID("instructionID"), words("words");
@@ -1139,7 +1135,7 @@ emitExtendedSetDeserializationDispatch(const RecordKeeper &recordKeeper,
initExtendedSetDeserializationDispatch(extensionSetName, instructionID, words,
os);
- auto defs = recordKeeper.getAllDerivedDefinitions("SPIRV_ExtInstOp");
+ auto defs = records.getAllDerivedDefinitions("SPIRV_ExtInstOp");
for (const auto *def : defs) {
if (!def->getValueAsBit("autogenSerialization")) {
continue;
@@ -1180,16 +1176,15 @@ emitExtendedSetDeserializationDispatch(const RecordKeeper &recordKeeper,
/// Emits all the autogenerated serialization/deserializations functions for the
/// SPIRV_Ops.
-static bool emitSerializationFns(const RecordKeeper &recordKeeper,
- raw_ostream &os) {
+static bool emitSerializationFns(const RecordKeeper &records, raw_ostream &os) {
llvm::emitSourceFileHeader("SPIR-V Serialization Utilities/Functions", os,
- recordKeeper);
+ records);
std::string dSerFnString, dDesFnString, serFnString, deserFnString,
utilsString;
raw_string_ostream dSerFn(dSerFnString), dDesFn(dDesFnString),
serFn(serFnString), deserFn(deserFnString);
- Record *attrClass = recordKeeper.getClass("Attr");
+ Record *attrClass = records.getClass("Attr");
// Emit the serialization and deserialization functions simultaneously.
StringRef opVar("op");
@@ -1198,7 +1193,7 @@ static bool emitSerializationFns(const RecordKeeper &recordKeeper,
// Handle the SPIR-V ops.
initDispatchSerializationFn(opVar, dSerFn);
initDispatchDeserializationFn(opcode, words, dDesFn);
- auto defs = recordKeeper.getAllDerivedDefinitions("SPIRV_Op");
+ auto defs = records.getAllDerivedDefinitions("SPIRV_Op");
for (const auto *def : defs) {
Operator op(def);
emitSerializationFunction(attrClass, def, op, serFn);
@@ -1214,7 +1209,7 @@ static bool emitSerializationFns(const RecordKeeper &recordKeeper,
finalizeDispatchSerializationFn(opVar, dSerFn);
finalizeDispatchDeserializationFn(opcode, dDesFn);
- emitExtendedSetDeserializationDispatch(recordKeeper, dDesFn);
+ emitExtendedSetDeserializationDispatch(records, dDesFn);
os << "#ifdef GET_SERIALIZATION_FNS\n\n";
os << serFn.str();
@@ -1261,10 +1256,10 @@ static void emitEnumGetAttrNameFnDefn(const EnumAttr &enumAttr,
os << "}\n";
}
-static bool emitAttrUtils(const RecordKeeper &recordKeeper, raw_ostream &os) {
- llvm::emitSourceFileHeader("SPIR-V Attribute Utilities", os, recordKeeper);
+static bool emitAttrUtils(const RecordKeeper &records, raw_ostream &os) {
+ llvm::emitSourceFileHeader("SPIR-V Attribute Utilities", os, records);
- auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttrInfo");
+ auto defs = records.getAllDerivedDefinitions("EnumAttrInfo");
os << "#ifndef MLIR_DIALECT_SPIRV_IR_ATTR_UTILS_H_\n";
os << "#define MLIR_DIALECT_SPIRV_IR_ATTR_UTILS_H_\n";
emitEnumGetAttrNameFnDecl(os);
@@ -1405,12 +1400,11 @@ static void emitAvailabilityImpl(const Operator &srcOp, raw_ostream &os) {
}
}
-static bool emitAvailabilityImpl(const RecordKeeper &recordKeeper,
- raw_ostream &os) {
+static bool emitAvailabilityImpl(const RecordKeeper &records, raw_ostream &os) {
llvm::emitSourceFileHeader("SPIR-V Op Availability Implementations", os,
- recordKeeper);
+ records);
- auto defs = recordKeeper.getAllDerivedDefinitions("SPIRV_Op");
+ auto defs = records.getAllDerivedDefinitions("SPIRV_Op");
for (const auto *def : defs) {
Operator op(def);
if (def->getValueAsBit("autogenAvailability"))
@@ -1434,12 +1428,12 @@ static mlir::GenRegistration
// SPIR-V Capability Implication AutoGen
//===----------------------------------------------------------------------===//
-static bool emitCapabilityImplication(const RecordKeeper &recordKeeper,
+static bool emitCapabilityImplication(const RecordKeeper &records,
raw_ostream &os) {
- llvm::emitSourceFileHeader("SPIR-V Capability Implication", os, recordKeeper);
+ llvm::emitSourceFileHeader("SPIR-V Capability Implication", os, records);
EnumAttr enumAttr(
- recordKeeper.getDef("SPIRV_CapabilityAttr")->getValueAsDef("enum"));
+ records.getDef("SPIRV_CapabilityAttr")->getValueAsDef("enum"));
os << "ArrayRef<spirv::Capability> "
"spirv::getDirectImpliedCapabilities(spirv::Capability cap) {\n"
diff --git a/mlir/tools/tblgen-to-irdl/OpDefinitionsGen.cpp b/mlir/tools/tblgen-to-irdl/OpDefinitionsGen.cpp
index ace1029b4e7ff0..a763105fa0fd6a 100644
--- a/mlir/tools/tblgen-to-irdl/OpDefinitionsGen.cpp
+++ b/mlir/tools/tblgen-to-irdl/OpDefinitionsGen.cpp
@@ -484,8 +484,7 @@ static irdl::DialectOp createIRDLDialect(OpBuilder &builder) {
StringAttr::get(ctx, selectedDialect));
}
-static bool emitDialectIRDLDefs(const RecordKeeper &recordKeeper,
- raw_ostream &os) {
+static bool emitDialectIRDLDefs(const RecordKeeper &records, raw_ostream &os) {
// Initialize.
MLIRContext ctx;
ctx.getOrLoadDialect<irdl::IRDLDialect>();
@@ -501,7 +500,7 @@ static bool emitDialectIRDLDefs(const RecordKeeper &recordKeeper,
builder = builder.atBlockBegin(&dialect.getBody().emplaceBlock());
for (const Record *type :
- recordKeeper.getAllDerivedDefinitionsIfDefined("TypeDef")) {
+ records.getAllDerivedDefinitionsIfDefined("TypeDef")) {
tblgen::TypeDef tblgenType(type);
if (tblgenType.getDialect().getName() != selectedDialect)
continue;
@@ -509,15 +508,14 @@ static bool emitDialectIRDLDefs(const RecordKeeper &recordKeeper,
}
for (const Record *attr :
- recordKeeper.getAllDerivedDefinitionsIfDefined("AttrDef")) {
+ records.getAllDerivedDefinitionsIfDefined("AttrDef")) {
tblgen::AttrDef tblgenAttr(attr);
if (tblgenAttr.getDialect().getName() != selectedDialect)
continue;
createIRDLAttr(builder, tblgenAttr);
}
- for (const Record *def :
- recordKeeper.getAllDerivedDefinitionsIfDefined("Op")) {
+ for (const Record *def : records.getAllDerivedDefinitionsIfDefined("Op")) {
tblgen::Operator tblgenOp(def);
if (tblgenOp.getDialectName() != selectedDialect)
continue;
More information about the Mlir-commits
mailing list