From ae9ec43e4631d1624afd36f7618c0f7bbf9bd2a5 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Wed, 14 Aug 2019 10:30:30 -0700 Subject: [PATCH] Allow the use of the $cppClass template variable in verifier code blocks. PiperOrigin-RevId: 263378198 --- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp index 1a96ddd829c0..d5e6cf4a7716 100644 --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -1141,10 +1141,14 @@ void OpEmitter::genVerifier() { genRegionVerifier(body); - if (hasCustomVerify) - body << codeInit->getValue() << "\n"; - else + if (hasCustomVerify) { + FmtContext fctx; + fctx.addSubst("cppClass", opClass.getClassName()); + auto printer = codeInit->getValue().ltrim().rtrim(" \t\v\f\r"); + body << " " << tgfmt(printer, &fctx); + } else { body << " return mlir::success();\n"; + } } void OpEmitter::genOperandResultVerifier(OpMethodBody &body,