Skip to content

Commit f935477

Browse files
committed
break out region verifier helpers into a separate function
1 parent a6369fb commit f935477

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

mlir/lib/Target/IRDLToCpp/IRDLToCpp.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -359,24 +359,13 @@ static LogicalResult generateInclude(irdl::DialectOp dialect,
359359
return success();
360360
}
361361

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) {
366366
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)
378368
return;
379-
}
380369

381370
for (size_t i = 0; i < strings.opRegionNames.size(); ++i) {
382371
std::string regionName = strings.opRegionNames[i];
@@ -447,6 +436,15 @@ ::llvm::LogicalResult {0}::verifyInvariantsImpl() {{
447436
helperFnName, i, regionName)
448437
.str());
449438
}
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);
450448

451449
// Add an overall verifier that sequences the helper calls
452450
std::string verifierDef =

0 commit comments

Comments
 (0)