[fir][NFC] Move fir.shape verifier to cpp file
authorValentin Clement <clementval@gmail.com>
Thu, 30 Sep 2021 14:26:29 +0000 (16:26 +0200)
committerValentin Clement <clementval@gmail.com>
Thu, 30 Sep 2021 14:26:44 +0000 (16:26 +0200)
Move verifier code to the .cpp file.

Follow up to https://reviews.llvm.org/D110626.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

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

flang/include/flang/Optimizer/Dialect/FIROps.td
flang/lib/Optimizer/Dialect/FIROps.cpp

index 4ae39c4..761bc99 100644 (file)
@@ -1841,14 +1841,7 @@ def fir_ShapeOp : fir_Op<"shape", [NoSideEffect]> {
     operands attr-dict `:` functional-type(operands, results)
   }];
 
-  let verifier = [{
-    auto size = extents().size();
-    auto shapeTy = getType().dyn_cast<fir::ShapeType>();
-    assert(shapeTy && "must be a shape type");
-    if (shapeTy.getRank() != size)
-      return emitOpError("shape type rank mismatch");
-    return mlir::success();
-  }];
+  let verifier = "return ::verify(*this);";
 
   let extraClassDeclaration = [{
     std::vector<mlir::Value> getExtents() {
index e3757b6..eca9f14 100644 (file)
@@ -2607,6 +2607,19 @@ static mlir::LogicalResult verify(fir::SelectTypeOp &op) {
 }
 
 //===----------------------------------------------------------------------===//
+// ShapeOp
+//===----------------------------------------------------------------------===//
+
+static mlir::LogicalResult verify(fir::ShapeOp &op) {
+  auto size = op.extents().size();
+  auto shapeTy = op.getType().dyn_cast<fir::ShapeType>();
+  assert(shapeTy && "must be a shape type");
+  if (shapeTy.getRank() != size)
+    return op.emitOpError("shape type rank mismatch");
+  return mlir::success();
+}
+
+//===----------------------------------------------------------------------===//
 // ShapeShiftOp
 //===----------------------------------------------------------------------===//