Skip to content

[NFC] Rename variable recordKeeper to records #110989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions mlir/include/mlir/TableGen/GenInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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
Expand Down
17 changes: 8 additions & 9 deletions mlir/tools/mlir-tblgen/DialectGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -390,18 +389,18 @@ 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;

SmallVector<Dialect> dialects(dialectDefs.begin(), dialectDefs.end());
std::optional<Dialect> dialect = findDialectToGenerate(dialects);
if (!dialect)
return true;
emitDialectDef(*dialect, recordKeeper, os);
emitDialectDef(*dialect, records, os);
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions mlir/tools/mlir-tblgen/DirectiveCommonGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions mlir/tools/mlir-tblgen/EnumPythonBindingGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions mlir/tools/mlir-tblgen/EnumsGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
29 changes: 11 additions & 18 deletions mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down
11 changes: 5 additions & 6 deletions mlir/tools/mlir-tblgen/OmpOpGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
Expand Down
36 changes: 18 additions & 18 deletions mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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) {
Expand Down Expand Up @@ -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);

Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
Loading
Loading