@@ -2040,19 +2040,20 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
2040
2040
getBaseAddrFromBox (loc, inputBoxTyPair, loweredBox, rewriter);
2041
2041
2042
2042
if (!rebox.getSlice ().empty () || !rebox.getSubcomponent ().empty ())
2043
- return sliceBox (rebox, boxTy, dest, baseAddr, inputExtents, inputStrides ,
2044
- operands, rewriter);
2045
- return reshapeBox (rebox, boxTy, dest, baseAddr, inputExtents, inputStrides ,
2046
- operands, rewriter);
2043
+ return sliceBox (rebox, adaptor, boxTy, dest, baseAddr, inputExtents,
2044
+ inputStrides, operands, rewriter);
2045
+ return reshapeBox (rebox, adaptor, boxTy, dest, baseAddr, inputExtents,
2046
+ inputStrides, operands, rewriter);
2047
2047
}
2048
2048
2049
2049
private:
2050
2050
// / Write resulting shape and base address in descriptor, and replace rebox
2051
2051
// / op.
2052
2052
llvm::LogicalResult
2053
- finalizeRebox (fir::cg::XReboxOp rebox, mlir::Type destBoxTy, mlir::Value dest,
2054
- mlir::Value base, mlir::ValueRange lbounds,
2055
- mlir::ValueRange extents, mlir::ValueRange strides,
2053
+ finalizeRebox (fir::cg::XReboxOp rebox, OpAdaptor adaptor,
2054
+ mlir::Type destBoxTy, mlir::Value dest, mlir::Value base,
2055
+ mlir::ValueRange lbounds, mlir::ValueRange extents,
2056
+ mlir::ValueRange strides,
2056
2057
mlir::ConversionPatternRewriter &rewriter) const {
2057
2058
mlir::Location loc = rebox.getLoc ();
2058
2059
mlir::Value zero =
@@ -2075,15 +2076,15 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
2075
2076
dest = insertBaseAddress (rewriter, loc, dest, base);
2076
2077
mlir::Value result = placeInMemoryIfNotGlobalInit (
2077
2078
rewriter, rebox.getLoc (), destBoxTy, dest,
2078
- isDeviceAllocation (rebox.getBox (), rebox .getBox ()));
2079
+ isDeviceAllocation (rebox.getBox (), adaptor .getBox ()));
2079
2080
rewriter.replaceOp (rebox, result);
2080
2081
return mlir::success ();
2081
2082
}
2082
2083
2083
2084
// Apply slice given the base address, extents and strides of the input box.
2084
2085
llvm::LogicalResult
2085
- sliceBox (fir::cg::XReboxOp rebox, mlir::Type destBoxTy , mlir::Value dest ,
2086
- mlir::Value base, mlir::ValueRange inputExtents,
2086
+ sliceBox (fir::cg::XReboxOp rebox, OpAdaptor adaptor , mlir::Type destBoxTy ,
2087
+ mlir::Value dest, mlir::Value base, mlir::ValueRange inputExtents,
2087
2088
mlir::ValueRange inputStrides, mlir::ValueRange operands,
2088
2089
mlir::ConversionPatternRewriter &rewriter) const {
2089
2090
mlir::Location loc = rebox.getLoc ();
@@ -2109,7 +2110,7 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
2109
2110
if (rebox.getSlice ().empty ())
2110
2111
// The array section is of the form array[%component][substring], keep
2111
2112
// the input array extents and strides.
2112
- return finalizeRebox (rebox, destBoxTy, dest, base,
2113
+ return finalizeRebox (rebox, adaptor, destBoxTy, dest, base,
2113
2114
/* lbounds*/ std::nullopt, inputExtents, inputStrides,
2114
2115
rewriter);
2115
2116
@@ -2158,15 +2159,16 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
2158
2159
slicedStrides.emplace_back (stride);
2159
2160
}
2160
2161
}
2161
- return finalizeRebox (rebox, destBoxTy, dest, base, /* lbounds*/ std::nullopt,
2162
- slicedExtents, slicedStrides, rewriter);
2162
+ return finalizeRebox (rebox, adaptor, destBoxTy, dest, base,
2163
+ /* lbounds*/ std::nullopt, slicedExtents, slicedStrides,
2164
+ rewriter);
2163
2165
}
2164
2166
2165
2167
// / Apply a new shape to the data described by a box given the base address,
2166
2168
// / extents and strides of the box.
2167
2169
llvm::LogicalResult
2168
- reshapeBox (fir::cg::XReboxOp rebox, mlir::Type destBoxTy , mlir::Value dest ,
2169
- mlir::Value base, mlir::ValueRange inputExtents,
2170
+ reshapeBox (fir::cg::XReboxOp rebox, OpAdaptor adaptor , mlir::Type destBoxTy ,
2171
+ mlir::Value dest, mlir::Value base, mlir::ValueRange inputExtents,
2170
2172
mlir::ValueRange inputStrides, mlir::ValueRange operands,
2171
2173
mlir::ConversionPatternRewriter &rewriter) const {
2172
2174
mlir::ValueRange reboxShifts{
@@ -2175,7 +2177,7 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
2175
2177
rebox.getShift ().size ()};
2176
2178
if (rebox.getShape ().empty ()) {
2177
2179
// Only setting new lower bounds.
2178
- return finalizeRebox (rebox, destBoxTy, dest, base, reboxShifts,
2180
+ return finalizeRebox (rebox, adaptor, destBoxTy, dest, base, reboxShifts,
2179
2181
inputExtents, inputStrides, rewriter);
2180
2182
}
2181
2183
@@ -2199,8 +2201,8 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
2199
2201
// nextStride = extent * stride;
2200
2202
stride = rewriter.create <mlir::LLVM::MulOp>(loc, idxTy, extent, stride);
2201
2203
}
2202
- return finalizeRebox (rebox, destBoxTy, dest, base, reboxShifts, newExtents ,
2203
- newStrides, rewriter);
2204
+ return finalizeRebox (rebox, adaptor, destBoxTy, dest, base, reboxShifts,
2205
+ newExtents, newStrides, rewriter);
2204
2206
}
2205
2207
2206
2208
// / Return scalar element type of the input box.
0 commit comments