[flang-commits] [PATCH] D140031: [flang][NFC] add builder to simplify fir.shape creationDepends on D140023
Jean Perier via Phabricator via flang-commits
flang-commits at lists.llvm.org
Wed Dec 14 08:47:10 PST 2022
jeanPerier created this revision.
jeanPerier added reviewers: clementval, PeteSteinfeld.
jeanPerier added a project: Flang.
Herald added subscribers: mehdi_amini, jdoerfert.
Herald added a project: All.
jeanPerier requested review of this revision.
Herald added a reviewer: nicolasvasilache.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D140031
Files:
flang/include/flang/Optimizer/Dialect/FIROps.td
flang/lib/Lower/ConvertExpr.cpp
flang/lib/Optimizer/Builder/FIRBuilder.cpp
flang/lib/Optimizer/Builder/MutableBox.cpp
flang/lib/Optimizer/Dialect/FIROps.cpp
flang/unittests/Optimizer/FortranVariableTest.cpp
Index: flang/unittests/Optimizer/FortranVariableTest.cpp
===================================================================
--- flang/unittests/Optimizer/FortranVariableTest.cpp
+++ flang/unittests/Optimizer/FortranVariableTest.cpp
@@ -36,8 +36,7 @@
}
mlir::Value createShape(llvm::ArrayRef<mlir::Value> extents) {
- mlir::Type shapeType = fir::ShapeType::get(&context, extents.size());
- return builder->create<fir::ShapeOp>(getLoc(), shapeType, extents);
+ return builder->create<fir::ShapeOp>(getLoc(), extents);
}
mlir::MLIRContext context;
std::unique_ptr<mlir::OpBuilder> builder;
Index: flang/lib/Optimizer/Dialect/FIROps.cpp
===================================================================
--- flang/lib/Optimizer/Dialect/FIROps.cpp
+++ flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -3087,6 +3087,12 @@
return mlir::success();
}
+void fir::ShapeOp::build(mlir::OpBuilder &builder, mlir::OperationState &result,
+ mlir::ValueRange extents) {
+ auto type = fir::ShapeType::get(builder.getContext(), extents.size());
+ build(builder, result, type, extents);
+}
+
//===----------------------------------------------------------------------===//
// ShapeShiftOp
//===----------------------------------------------------------------------===//
Index: flang/lib/Optimizer/Builder/MutableBox.cpp
===================================================================
--- flang/lib/Optimizer/Builder/MutableBox.cpp
+++ flang/lib/Optimizer/Builder/MutableBox.cpp
@@ -34,9 +34,7 @@
mlir::Value shape;
if (!extents.empty()) {
if (lbounds.empty()) {
- auto shapeType =
- fir::ShapeType::get(builder.getContext(), extents.size());
- shape = builder.create<fir::ShapeOp>(loc, shapeType, extents);
+ shape = builder.create<fir::ShapeOp>(loc, extents);
} else {
llvm::SmallVector<mlir::Value> shapeShiftBounds;
for (auto [lb, extent] : llvm::zip(lbounds, extents)) {
Index: flang/lib/Optimizer/Builder/FIRBuilder.cpp
===================================================================
--- flang/lib/Optimizer/Builder/FIRBuilder.cpp
+++ flang/lib/Optimizer/Builder/FIRBuilder.cpp
@@ -379,8 +379,7 @@
mlir::Value fir::FirOpBuilder::genShape(mlir::Location loc,
llvm::ArrayRef<mlir::Value> exts) {
- auto shapeType = fir::ShapeType::get(getContext(), exts.size());
- return create<fir::ShapeOp>(loc, shapeType, exts);
+ return create<fir::ShapeOp>(loc, exts);
}
mlir::Value fir::FirOpBuilder::genShape(mlir::Location loc,
Index: flang/lib/Lower/ConvertExpr.cpp
===================================================================
--- flang/lib/Lower/ConvertExpr.cpp
+++ flang/lib/Lower/ConvertExpr.cpp
@@ -4375,8 +4375,7 @@
llvm::SmallVector<mlir::Value> idxShape;
for (auto s : shape)
idxShape.push_back(builder.createConvert(loc, idxTy, s));
- auto shapeTy = fir::ShapeType::get(builder.getContext(), idxShape.size());
- return builder.create<fir::ShapeOp>(loc, shapeTy, idxShape);
+ return builder.create<fir::ShapeOp>(loc, idxShape);
}
fir::ShapeOp genShapeOp(llvm::ArrayRef<mlir::Value> shape) {
@@ -7273,7 +7272,7 @@
}
bool isParentComponent(const Fortran::lower::SomeExpr &expr) {
- if (const Fortran::semantics::Symbol * symbol{GetLastSymbol(expr)}) {
+ if (const Fortran::semantics::Symbol *symbol{GetLastSymbol(expr)}) {
if (symbol->test(Fortran::semantics::Symbol::Flag::ParentComp))
return true;
}
Index: flang/include/flang/Optimizer/Dialect/FIROps.td
===================================================================
--- flang/include/flang/Optimizer/Dialect/FIROps.td
+++ flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -1773,6 +1773,8 @@
}];
let hasVerifier = 1;
+
+ let builders = [OpBuilder<(ins "mlir::ValueRange":$extents)>];
}
def fir_ShapeShiftOp : fir_Op<"shape_shift", [NoMemoryEffect]> {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140031.482876.patch
Type: text/x-patch
Size: 3936 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221214/9d510001/attachment-0001.bin>
More information about the flang-commits
mailing list