OSDN Git Service

[mlir][ods] Fix ops with both attribute-sized operands and results
authorKuangyuan Chen <chky@google.com>
Wed, 20 May 2020 00:24:28 +0000 (20:24 -0400)
committerLei Zhang <antiagainst@google.com>
Wed, 20 May 2020 00:29:54 +0000 (20:29 -0400)
Enclose verifier code for AttrSizedOperandSegments and AttrSizedResultSegments
in a nested code block to avoid symbol collision.

Differential Revision: https://reviews.llvm.org/D80250

mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

index fc66313..8709760 100644 (file)
@@ -1464,11 +1464,13 @@ void OpEmitter::genVerifier() {
   auto &body = method.body();
 
   const char *checkAttrSizedValueSegmentsCode = R"(
-  auto sizeAttr = getAttrOfType<DenseIntElementsAttr>("{0}");
-  auto numElements = sizeAttr.getType().cast<ShapedType>().getNumElements();
-  if (numElements != {1}) {{
-    return emitOpError("'{0}' attribute for specifying {2} segments "
-                       "must have {1} elements");
+  {
+    auto sizeAttr = getAttrOfType<DenseIntElementsAttr>("{0}");
+    auto numElements = sizeAttr.getType().cast<ShapedType>().getNumElements();
+    if (numElements != {1}) {{
+      return emitOpError("'{0}' attribute for specifying {2} segments "
+                         "must have {1} elements");
+    }
   }
   )";