[flang-commits] [flang] afb30fc - [fir][NFC] Move fir.shape verifier to cpp file
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Thu Sep 30 07:26:49 PDT 2021
Author: Valentin Clement
Date: 2021-09-30T16:26:44+02:00
New Revision: afb30fcdf672d0d8dcdfe04d9d235b950112b622
URL: https://github.com/llvm/llvm-project/commit/afb30fcdf672d0d8dcdfe04d9d235b950112b622
DIFF: https://github.com/llvm/llvm-project/commit/afb30fcdf672d0d8dcdfe04d9d235b950112b622.diff
LOG: [fir][NFC] Move fir.shape verifier to cpp file
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
Added:
Modified:
flang/include/flang/Optimizer/Dialect/FIROps.td
flang/lib/Optimizer/Dialect/FIROps.cpp
Removed:
################################################################################
diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 4ae39c41f9b2..761bc9903c8c 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -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() {
diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp
index e3757b63e106..eca9f144eb3c 100644
--- a/flang/lib/Optimizer/Dialect/FIROps.cpp
+++ b/flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -2606,6 +2606,19 @@ static mlir::LogicalResult verify(fir::SelectTypeOp &op) {
return mlir::success();
}
+//===----------------------------------------------------------------------===//
+// 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
//===----------------------------------------------------------------------===//
More information about the flang-commits
mailing list