2222
2323using namespace mlir ;
2424using namespace mlir ::tblgen;
25+ using llvm::Record;
26+ using llvm::RecordKeeper;
27+ namespace cl = llvm::cl;
2528
2629// ===----------------------------------------------------------------------===//
2730// Utility Functions
@@ -30,14 +33,14 @@ using namespace mlir::tblgen;
3033// / Find all the AttrOrTypeDef for the specified dialect. If no dialect
3134// / specified and can only find one dialect's defs, use that.
3235static void collectAllDefs (StringRef selectedDialect,
33- ArrayRef<const llvm:: Record *> records,
36+ ArrayRef<const Record *> records,
3437 SmallVectorImpl<AttrOrTypeDef> &resultDefs) {
3538 // Nothing to do if no defs were found.
3639 if (records.empty ())
3740 return ;
3841
3942 auto defs = llvm::map_range (
40- records, [&](const llvm:: Record *rec) { return AttrOrTypeDef (rec); });
43+ records, [&](const Record *rec) { return AttrOrTypeDef (rec); });
4144 if (selectedDialect.empty ()) {
4245 // If a dialect was not specified, ensure that all found defs belong to the
4346 // same dialect.
@@ -690,15 +693,14 @@ class DefGenerator {
690693 bool emitDefs (StringRef selectedDialect);
691694
692695protected:
693- DefGenerator (ArrayRef<const llvm:: Record *> defs, raw_ostream &os,
696+ DefGenerator (ArrayRef<const Record *> defs, raw_ostream &os,
694697 StringRef defType, StringRef valueType, bool isAttrGenerator)
695698 : defRecords(defs), os(os), defType(defType), valueType(valueType),
696699 isAttrGenerator (isAttrGenerator) {
697700 // 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- });
701+ llvm::sort (defRecords, [](const Record *lhs, const Record *rhs) {
702+ return lhs->getID () < rhs->getID ();
703+ });
702704 }
703705
704706 // / Emit the list of def type names.
@@ -707,7 +709,7 @@ class DefGenerator {
707709 void emitParsePrintDispatch (ArrayRef<AttrOrTypeDef> defs);
708710
709711 // / The set of def records to emit.
710- std::vector<const llvm:: Record *> defRecords;
712+ std::vector<const Record *> defRecords;
711713 // / The attribute or type class to emit.
712714 // / The stream to emit to.
713715 raw_ostream &os;
@@ -722,13 +724,13 @@ class DefGenerator {
722724
723725// / A specialized generator for AttrDefs.
724726struct AttrDefGenerator : public DefGenerator {
725- AttrDefGenerator (const llvm:: RecordKeeper &records, raw_ostream &os)
727+ AttrDefGenerator (const RecordKeeper &records, raw_ostream &os)
726728 : DefGenerator(records.getAllDerivedDefinitionsIfDefined(" AttrDef" ), os,
727729 " Attr" , " Attribute" , /* isAttrGenerator=*/ true ) {}
728730};
729731// / A specialized generator for TypeDefs.
730732struct TypeDefGenerator : public DefGenerator {
731- TypeDefGenerator (const llvm:: RecordKeeper &records, raw_ostream &os)
733+ TypeDefGenerator (const RecordKeeper &records, raw_ostream &os)
732734 : DefGenerator(records.getAllDerivedDefinitionsIfDefined(" TypeDef" ), os,
733735 " Type" , " Type" , /* isAttrGenerator=*/ false ) {}
734736};
@@ -1030,9 +1032,9 @@ bool DefGenerator::emitDefs(StringRef selectedDialect) {
10301032
10311033// / Find all type constraints for which a C++ function should be generated.
10321034static std::vector<Constraint>
1033- getAllTypeConstraints (const llvm:: RecordKeeper &records) {
1035+ getAllTypeConstraints (const RecordKeeper &records) {
10341036 std::vector<Constraint> result;
1035- for (const llvm:: Record *def :
1037+ for (const Record *def :
10361038 records.getAllDerivedDefinitionsIfDefined (" TypeConstraint" )) {
10371039 // Ignore constraints defined outside of the top-level file.
10381040 if (llvm::SrcMgr.FindBufferContainingLoc (def->getLoc ()[0 ]) !=
@@ -1047,7 +1049,7 @@ getAllTypeConstraints(const llvm::RecordKeeper &records) {
10471049 return result;
10481050}
10491051
1050- static void emitTypeConstraintDecls (const llvm:: RecordKeeper &records,
1052+ static void emitTypeConstraintDecls (const RecordKeeper &records,
10511053 raw_ostream &os) {
10521054 static const char *const typeConstraintDecl = R"(
10531055bool {0}(::mlir::Type type);
@@ -1057,7 +1059,7 @@ bool {0}(::mlir::Type type);
10571059 os << strfmt (typeConstraintDecl, *constr.getCppFunctionName ());
10581060}
10591061
1060- static void emitTypeConstraintDefs (const llvm:: RecordKeeper &records,
1062+ static void emitTypeConstraintDefs (const RecordKeeper &records,
10611063 raw_ostream &os) {
10621064 static const char *const typeConstraintDef = R"(
10631065bool {0}(::mlir::Type type) {
@@ -1080,58 +1082,57 @@ bool {0}(::mlir::Type type) {
10801082// ===----------------------------------------------------------------------===//
10811083// AttrDef
10821084
1083- static llvm:: cl::OptionCategory attrdefGenCat (" Options for -gen-attrdef-*" );
1084- static llvm:: cl::opt<std::string>
1085+ static cl::OptionCategory attrdefGenCat (" Options for -gen-attrdef-*" );
1086+ static cl::opt<std::string>
10851087 attrDialect (" attrdefs-dialect" ,
1086- llvm:: cl::desc (" Generate attributes for this dialect" ),
1087- llvm:: cl::cat(attrdefGenCat), llvm:: cl::CommaSeparated);
1088+ cl::desc (" Generate attributes for this dialect" ),
1089+ cl::cat(attrdefGenCat), cl::CommaSeparated);
10881090
10891091static mlir::GenRegistration
10901092 genAttrDefs (" gen-attrdef-defs" , " Generate AttrDef definitions" ,
1091- [](const llvm:: RecordKeeper &records, raw_ostream &os) {
1093+ [](const RecordKeeper &records, raw_ostream &os) {
10921094 AttrDefGenerator generator (records, os);
10931095 return generator.emitDefs (attrDialect);
10941096 });
10951097static mlir::GenRegistration
10961098 genAttrDecls (" gen-attrdef-decls" , " Generate AttrDef declarations" ,
1097- [](const llvm:: RecordKeeper &records, raw_ostream &os) {
1099+ [](const RecordKeeper &records, raw_ostream &os) {
10981100 AttrDefGenerator generator (records, os);
10991101 return generator.emitDecls (attrDialect);
11001102 });
11011103
11021104// ===----------------------------------------------------------------------===//
11031105// TypeDef
11041106
1105- static llvm::cl::OptionCategory typedefGenCat (" Options for -gen-typedef-*" );
1106- static llvm::cl::opt<std::string>
1107- typeDialect (" typedefs-dialect" ,
1108- llvm::cl::desc (" Generate types for this dialect" ),
1109- llvm::cl::cat(typedefGenCat), llvm::cl::CommaSeparated);
1107+ static cl::OptionCategory typedefGenCat (" Options for -gen-typedef-*" );
1108+ static cl::opt<std::string>
1109+ typeDialect (" typedefs-dialect" , cl::desc(" Generate types for this dialect" ),
1110+ cl::cat(typedefGenCat), cl::CommaSeparated);
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