@@ -64,8 +64,8 @@ llvm::cl::opt<ActionType> action(
6464
6565// Returns the associated option name for the given op definition.
6666static inline std::string GetOperatorOptionName (const Record &def) {
67- assert (def.getName ().startswith (" CIR_" ) && " unexpected op prefix" );
68- assert (def.getName ().endswith (" Op" ) && " unexpected op suffix" );
67+ assert (def.getName ().starts_with (" CIR_" ) && " unexpected op prefix" );
68+ assert (def.getName ().ends_with (" Op" ) && " unexpected op suffix" );
6969
7070 auto *custom_option = dyn_cast<StringInit>(def.getValueInit (" customOption" ));
7171 std::ostringstream oss;
@@ -78,8 +78,8 @@ static inline std::string GetOperatorOptionName(const Record &def) {
7878
7979// Returns the builder function name for the given op definition.
8080static inline std::string GetOperatorBuilderName (StringRef op_name) {
81- assert (op_name.startswith (" CIR_" ) && " unexpected op prefix" );
82- assert (op_name.endswith (" Op" ) && " unexpected op suffix" );
81+ assert (op_name.starts_with (" CIR_" ) && " unexpected op prefix" );
82+ assert (op_name.ends_with (" Op" ) && " unexpected op suffix" );
8383
8484 // E.g., AddOp -> CreateAddOperator
8585 std::ostringstream oss;
@@ -92,7 +92,7 @@ static inline bool IsLstmOp(const StringRef op_name) {
9292}
9393
9494static void EmitOptionBuilders (const RecordKeeper &record_keeper,
95- const std::vector<Record *> &defs,
95+ const std::vector<const Record *> &defs,
9696 raw_ostream *ostream) {
9797 raw_ostream &os = *ostream;
9898
@@ -117,7 +117,7 @@ static void EmitOptionBuilders(const RecordKeeper &record_keeper,
117117 mlir::tblgen::Operator op (*def);
118118 for (unsigned i = 0 , e = arg_values->getNumArgs (); i != e; ++i) {
119119 auto arg = arg_values->getArg (i);
120- DefInit *arg_def = dyn_cast<DefInit>(arg);
120+ const auto *arg_def = dyn_cast<DefInit>(arg);
121121 if (!arg_def) continue ;
122122 if (arg_def->getDef ()->isSubClassOf (attr_type)) {
123123 // This binds the name of the attribute in the TD file with the name
@@ -175,7 +175,7 @@ static void EmitOptionBuilders(const RecordKeeper &record_keeper,
175175// arguments that depend on op definitions should be auto-generated and then
176176// operator should be built by the caller because it does not require
177177// auto-generation.
178- static void EmitOperatorBuilders (const std::vector<Record *> &defs,
178+ static void EmitOperatorBuilders (const std::vector<const Record *> &defs,
179179 raw_ostream *ostream) {
180180 raw_ostream &os = *ostream;
181181
@@ -240,7 +240,7 @@ static inline std::string GetOperatorName(const Record &def) {
240240//
241241// TODO(hinsu): Consider converting this to a static constant associative
242242// container instead of a series of if conditions, if required.
243- static void EmitGetBuiltinOpCode (const std::vector<Record *> &defs,
243+ static void EmitGetBuiltinOpCode (const std::vector<const Record *> &defs,
244244 raw_ostream *ostream) {
245245 raw_ostream &os = *ostream;
246246
@@ -279,7 +279,7 @@ static void EmitGetBuiltinOpCode(const std::vector<Record *> &defs,
279279// return {0, 0};
280280// }
281281static void EmitOperandNumbers (const RecordKeeper &record_keeper,
282- const std::vector<Record *> &defs,
282+ const std::vector<const Record *> &defs,
283283 raw_ostream *ostream) {
284284 raw_ostream &os = *ostream;
285285 const auto attr_type = record_keeper.getClass (" Attr" );
@@ -324,7 +324,7 @@ static void EmitOperandNumbers(const RecordKeeper &record_keeper,
324324// const std::vector<int32_t>& results,
325325// const std::vector<int32_t>& intermediates,
326326// flatbuffers::FlatBufferBuilder *fbb);
327- static void EmitBuildOperator (const std::vector<Record *> &defs,
327+ static void EmitBuildOperator (const std::vector<const Record *> &defs,
328328 raw_ostream *ostream) {
329329 raw_ostream &os = *ostream;
330330
@@ -360,7 +360,7 @@ static void EmitBuildOperator(const std::vector<Record *> &defs,
360360// mlir::Builder builder,
361361// llvm::SmallVectorImpl<mlir::NamedAttribute> &attributes);
362362static void EmitBuiltinOptionsToAttributes (const RecordKeeper &record_keeper,
363- const std::vector<Record *> &defs,
363+ const std::vector<const Record *> &defs,
364364 raw_ostream *ostream) {
365365 raw_ostream &os = *ostream;
366366
@@ -385,7 +385,7 @@ static void EmitBuiltinOptionsToAttributes(const RecordKeeper &record_keeper,
385385 auto *arg_values = def->getValueAsDag (" arguments" );
386386 for (unsigned i = 0 , e = arg_values->getNumArgs (); i != e; ++i) {
387387 auto arg = arg_values->getArg (i);
388- DefInit *arg_def = dyn_cast<DefInit>(arg);
388+ const auto *arg_def = dyn_cast<DefInit>(arg);
389389 if (!arg_def) continue ;
390390 if (arg_def->getDef ()->isSubClassOf (attr_type)) {
391391 StringRef arg_name = arg_values->getArgNameStr (i);
@@ -411,11 +411,11 @@ static void EmitBuiltinOptionsToAttributes(const RecordKeeper &record_keeper,
411411// The function below has a non-constant reference as that is required by LLVM's
412412// TableGenMain.
413413// NOLINTNEXTLINE
414- static bool OperatorWritersMain (raw_ostream &os, RecordKeeper &records) {
414+ static bool OperatorWritersMain (raw_ostream &os, const RecordKeeper &records) {
415415 emitSourceFileHeader (" MLIR Circle FlatBuffer Builders" , os);
416416
417417 // Retrieve all the definitions derived from CIR_Op and sort by record name.
418- std::vector<Record *> defs = records.getAllDerivedDefinitions (" CIR_Op" );
418+ std::vector<const Record *> defs = records.getAllDerivedDefinitions (" CIR_Op" );
419419 llvm::sort (defs, LessRecord ());
420420
421421 for (const auto *def : defs) {
@@ -424,10 +424,10 @@ static bool OperatorWritersMain(raw_ostream &os, RecordKeeper &records) {
424424 // The generated Circle op C++ class should be circle::<OpName>Op.
425425 // The generated operator's options should be circle::<OpName>Options.
426426 // The option builder should be Create<OpName>Options.
427- if (!def->getName ().startswith (" CIR_" ))
427+ if (!def->getName ().starts_with (" CIR_" ))
428428 PrintFatalError (def->getLoc (),
429429 " unexpected op name format: 'CIR_' prefix missing" );
430- if (!def->getName ().endswith (" Op" ))
430+ if (!def->getName ().ends_with (" Op" ))
431431 PrintFatalError (def->getLoc (),
432432 " unexpected op name format: 'Op' suffix missing" );
433433 }
@@ -448,7 +448,7 @@ static bool OperatorWritersMain(raw_ostream &os, RecordKeeper &records) {
448448}
449449
450450static void GenOperandResultVerifier (raw_ostream &os,
451- llvm::ArrayRef<llvm::Init *> values,
451+ llvm::ArrayRef<const llvm::Init *> values,
452452 StringRef valueKind) {
453453 mlir::tblgen::FmtContext fctx;
454454
@@ -496,11 +496,12 @@ static void GenOperandResultVerifier(raw_ostream &os,
496496}
497497
498498// NOLINTNEXTLINE
499- static bool RuntimeVerifierWriterMain (raw_ostream &os, RecordKeeper &records) {
499+ static bool RuntimeVerifierWriterMain (raw_ostream &os,
500+ const RecordKeeper &records) {
500501 emitSourceFileHeader (" MLIR Circle Runtime Verifiers" , os);
501502
502503 // Retrieve all the definitions derived from CIR_Op and sort by record name.
503- std::vector<Record *> defs = records.getAllDerivedDefinitions (" Op" );
504+ std::vector<const Record *> defs = records.getAllDerivedDefinitions (" Op" );
504505 llvm::sort (defs, LessRecord ());
505506
506507 // Iterate through all the ops defined.
0 commit comments