[flang-commits] [flang] [FIR] add a fir.shape_extents operation (PR #199361)
via flang-commits
flang-commits at lists.llvm.org
Tue Jun 2 09:49:30 PDT 2026
================
@@ -316,6 +323,36 @@ void FIRToMemRef::populateShape(SmallVectorImpl<Value> &vec,
vec.append(shape.getExtents().begin(), shape.getExtents().end());
}
+bool FIRToMemRef::materializeShapeExtents(
+ Value shapeVal, PatternRewriter &rewriter, Location loc,
+ SmallVectorImpl<Value> &shapeVec) const {
+ if (!shapeVal)
+ return false;
+
+ while (auto convertOp = shapeVal.getDefiningOp<fir::ConvertOp>())
+ shapeVal = convertOp.getOperand();
+
+ if (auto shapeOp = shapeVal.getDefiningOp<fir::ShapeOp>()) {
+ shapeVec.append(shapeOp.getExtents().begin(), shapeOp.getExtents().end());
+ return true;
+ }
+
+ if (auto extentsOp = shapeVal.getDefiningOp<fir::ShapeExtentsOp>()) {
+ shapeVec.append(extentsOp.getExtents().begin(),
+ extentsOp.getExtents().end());
+ return true;
+ }
+
+ if (mlir::isa<fir::ShapeType>(shapeVal.getType())) {
----------------
yebinchon wrote:
Do you mean having a separate shape_shift_extents op, or extending this op to accept fir.shape_shift and only extract the extent?
https://github.com/llvm/llvm-project/pull/199361
More information about the flang-commits
mailing list