Allow the use of the $cppClass template variable in verifier code blocks.
authorBen Vanik <benvanik@google.com>
Wed, 14 Aug 2019 17:30:30 +0000 (10:30 -0700)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Wed, 14 Aug 2019 17:30:59 +0000 (10:30 -0700)
PiperOrigin-RevId: 263378198

mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

index 1a96ddd..d5e6cf4 100644 (file)
@@ -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,