2222
2323using namespace mlir ;
2424using namespace mlir ::tblgen;
25+ using llvm::Record;
26+ using llvm::RecordKeeper;
2527
2628// ===----------------------------------------------------------------------===//
2729// Utility Functions
@@ -30,14 +32,14 @@ using namespace mlir::tblgen;
3032// / Find all the AttrOrTypeDef for the specified dialect. If no dialect
3133// / specified and can only find one dialect's defs, use that.
3234static void collectAllDefs (StringRef selectedDialect,
33- ArrayRef<const llvm:: Record *> records,
35+ ArrayRef<const Record *> records,
3436 SmallVectorImpl<AttrOrTypeDef> &resultDefs) {
3537 // Nothing to do if no defs were found.
3638 if (records.empty ())
3739 return ;
3840
3941 auto defs = llvm::map_range (
40- records, [&](const llvm:: Record *rec) { return AttrOrTypeDef (rec); });
42+ records, [&](const Record *rec) { return AttrOrTypeDef (rec); });
4143 if (selectedDialect.empty ()) {
4244 // If a dialect was not specified, ensure that all found defs belong to the
4345 // same dialect.
@@ -690,15 +692,14 @@ class DefGenerator {
690692 bool emitDefs (StringRef selectedDialect);
691693
692694protected:
693- DefGenerator (ArrayRef<const llvm:: Record *> defs, raw_ostream &os,
695+ DefGenerator (ArrayRef<const Record *> defs, raw_ostream &os,
694696 StringRef defType, StringRef valueType, bool isAttrGenerator)
695697 : defRecords(defs), os(os), defType(defType), valueType(valueType),
696698 isAttrGenerator (isAttrGenerator) {
697699 // Sort by occurrence in file.
698- llvm::sort (defRecords,
699- [](const llvm::Record *lhs, const llvm::Record *rhs) {
700- return lhs->getID () < rhs->getID ();
701- });
700+ llvm::sort (defRecords, [](const Record *lhs, const Record *rhs) {
701+ return lhs->getID () < rhs->getID ();
702+ });
702703 }
703704
704705 // / Emit the list of def type names.
@@ -707,7 +708,7 @@ class DefGenerator {
707708 void emitParsePrintDispatch (ArrayRef<AttrOrTypeDef> defs);
708709
709710 // / The set of def records to emit.
710- std::vector<const llvm:: Record *> defRecords;
711+ std::vector<const Record *> defRecords;
711712 // / The attribute or type class to emit.
712713 // / The stream to emit to.
713714 raw_ostream &os;
@@ -722,13 +723,13 @@ class DefGenerator {
722723
723724// / A specialized generator for AttrDefs.
724725struct AttrDefGenerator : public DefGenerator {
725- AttrDefGenerator (const llvm:: RecordKeeper &records, raw_ostream &os)
726+ AttrDefGenerator (const RecordKeeper &records, raw_ostream &os)
726727 : DefGenerator(records.getAllDerivedDefinitionsIfDefined(" AttrDef" ), os,
727728 " Attr" , " Attribute" , /* isAttrGenerator=*/ true ) {}
728729};
729730// / A specialized generator for TypeDefs.
730731struct TypeDefGenerator : public DefGenerator {
731- TypeDefGenerator (const llvm:: RecordKeeper &records, raw_ostream &os)
732+ TypeDefGenerator (const RecordKeeper &records, raw_ostream &os)
732733 : DefGenerator(records.getAllDerivedDefinitionsIfDefined(" TypeDef" ), os,
733734 " Type" , " Type" , /* isAttrGenerator=*/ false ) {}
734735};
@@ -1030,9 +1031,9 @@ bool DefGenerator::emitDefs(StringRef selectedDialect) {
10301031
10311032// / Find all type constraints for which a C++ function should be generated.
10321033static std::vector<Constraint>
1033- getAllTypeConstraints (const llvm:: RecordKeeper &records) {
1034+ getAllTypeConstraints (const RecordKeeper &records) {
10341035 std::vector<Constraint> result;
1035- for (const llvm:: Record *def :
1036+ for (const Record *def :
10361037 records.getAllDerivedDefinitionsIfDefined (" TypeConstraint" )) {
10371038 // Ignore constraints defined outside of the top-level file.
10381039 if (llvm::SrcMgr.FindBufferContainingLoc (def->getLoc ()[0 ]) !=
@@ -1047,7 +1048,7 @@ getAllTypeConstraints(const llvm::RecordKeeper &records) {
10471048 return result;
10481049}
10491050
1050- static void emitTypeConstraintDecls (const llvm:: RecordKeeper &records,
1051+ static void emitTypeConstraintDecls (const RecordKeeper &records,
10511052 raw_ostream &os) {
10521053 static const char *const typeConstraintDecl = R"(
10531054bool {0}(::mlir::Type type);
@@ -1057,7 +1058,7 @@ bool {0}(::mlir::Type type);
10571058 os << strfmt (typeConstraintDecl, *constr.getCppFunctionName ());
10581059}
10591060
1060- static void emitTypeConstraintDefs (const llvm:: RecordKeeper &records,
1061+ static void emitTypeConstraintDefs (const RecordKeeper &records,
10611062 raw_ostream &os) {
10621063 static const char *const typeConstraintDef = R"(
10631064bool {0}(::mlir::Type type) {
@@ -1088,13 +1089,13 @@ static llvm::cl::opt<std::string>
10881089
10891090static mlir::GenRegistration
10901091 genAttrDefs (" gen-attrdef-defs" , " Generate AttrDef definitions" ,
1091- [](const llvm:: RecordKeeper &records, raw_ostream &os) {
1092+ [](const RecordKeeper &records, raw_ostream &os) {
10921093 AttrDefGenerator generator (records, os);
10931094 return generator.emitDefs (attrDialect);
10941095 });
10951096static mlir::GenRegistration
10961097 genAttrDecls (" gen-attrdef-decls" , " Generate AttrDef declarations" ,
1097- [](const llvm:: RecordKeeper &records, raw_ostream &os) {
1098+ [](const RecordKeeper &records, raw_ostream &os) {
10981099 AttrDefGenerator generator (records, os);
10991100 return generator.emitDecls (attrDialect);
11001101 });
@@ -1110,28 +1111,28 @@ static llvm::cl::opt<std::string>
11101111
11111112static mlir::GenRegistration
11121113 genTypeDefs (" gen-typedef-defs" , " Generate TypeDef definitions" ,
1113- [](const llvm:: RecordKeeper &records, raw_ostream &os) {
1114+ [](const RecordKeeper &records, raw_ostream &os) {
11141115 TypeDefGenerator generator (records, os);
11151116 return generator.emitDefs (typeDialect);
11161117 });
11171118static mlir::GenRegistration
11181119 genTypeDecls (" gen-typedef-decls" , " Generate TypeDef declarations" ,
1119- [](const llvm:: RecordKeeper &records, raw_ostream &os) {
1120+ [](const RecordKeeper &records, raw_ostream &os) {
11201121 TypeDefGenerator generator (records, os);
11211122 return generator.emitDecls (typeDialect);
11221123 });
11231124
11241125static mlir::GenRegistration
11251126 genTypeConstrDefs (" gen-type-constraint-defs" ,
11261127 " Generate type constraint definitions" ,
1127- [](const llvm:: RecordKeeper &records, raw_ostream &os) {
1128+ [](const RecordKeeper &records, raw_ostream &os) {
11281129 emitTypeConstraintDefs (records, os);
11291130 return false ;
11301131 });
11311132static mlir::GenRegistration
11321133 genTypeConstrDecls (" gen-type-constraint-decls" ,
11331134 " Generate type constraint declarations" ,
1134- [](const llvm:: RecordKeeper &records, raw_ostream &os) {
1135+ [](const RecordKeeper &records, raw_ostream &os) {
11351136 emitTypeConstraintDecls (records, os);
11361137 return false ;
11371138 });
0 commit comments