@@ -359,24 +359,13 @@ static LogicalResult generateInclude(irdl::DialectOp dialect,
359
359
return success ();
360
360
}
361
361
362
- static void generateVerifiers (irdl::detail::dictionary &dict,
363
- irdl::OperationOp op, const OpStrings &strings) {
364
- SmallVector <std::string> verifierHelpers;
365
- SmallVector <std::string> verifierCalls;
362
+ static void generateRegionConstraintVerifiers (
363
+ irdl::detail::dictionary &dict, irdl::OperationOp op,
364
+ const OpStrings &strings, SmallVectorImpl <std::string> & verifierHelpers,
365
+ SmallVectorImpl <std::string> & verifierCalls) {
366
366
auto regionsOp = op.getOp <irdl::RegionsOp>();
367
- if (strings.opRegionNames .empty () || !regionsOp) {
368
- // Currently IRDL regions are the only reason to generate a nontrivial
369
- // verifier, though this will likely change as
370
- // https://github.com/llvm/llvm-project/issues/158040 is implemented
371
- std::string verifierDef = llvm::formatv (R"(
372
- ::llvm::LogicalResult {0}::verifyInvariantsImpl() {{
373
- return ::mlir::success();
374
- })" ,
375
- strings.opCppName );
376
- dict[" OP_VERIFIER_HELPERS" ] = " " ;
377
- dict[" OP_VERIFIER" ] = verifierDef;
367
+ if (strings.opRegionNames .empty () || !regionsOp)
378
368
return ;
379
- }
380
369
381
370
for (size_t i = 0 ; i < strings.opRegionNames .size (); ++i) {
382
371
std::string regionName = strings.opRegionNames [i];
@@ -447,6 +436,15 @@ ::llvm::LogicalResult {0}::verifyInvariantsImpl() {{
447
436
helperFnName, i, regionName)
448
437
.str ());
449
438
}
439
+ }
440
+
441
+ static void generateVerifiers (irdl::detail::dictionary &dict,
442
+ irdl::OperationOp op, const OpStrings &strings) {
443
+ SmallVector<std::string> verifierHelpers;
444
+ SmallVector<std::string> verifierCalls;
445
+
446
+ generateRegionConstraintVerifiers (dict, op, strings, verifierHelpers,
447
+ verifierCalls);
450
448
451
449
// Add an overall verifier that sequences the helper calls
452
450
std::string verifierDef =
0 commit comments