@@ -195,6 +195,8 @@ template <typename SourceOp>
195
195
class FIROpConversion : public ConvertFIRToLLVMPattern {
196
196
public:
197
197
using OpAdaptor = typename SourceOp::Adaptor;
198
+ using OneToNOpAdaptor = typename SourceOp::template GenericAdaptor<
199
+ mlir::ArrayRef<mlir::ValueRange>>;
198
200
199
201
explicit FIROpConversion (const LLVMTypeConverter &typeConverter,
200
202
const fir::FIRToLLVMPassOptions &options,
@@ -209,6 +211,12 @@ class FIROpConversion : public ConvertFIRToLLVMPattern {
209
211
rewrite (mlir::cast<SourceOp>(op),
210
212
OpAdaptor (operands, mlir::cast<SourceOp>(op)), rewriter);
211
213
}
214
+ void rewrite (mlir::Operation *op, mlir::ArrayRef<mlir::ValueRange> operands,
215
+ mlir::ConversionPatternRewriter &rewriter) const final {
216
+ auto sourceOp = llvm::cast<SourceOp>(op);
217
+ rewrite (llvm::cast<SourceOp>(op), OneToNOpAdaptor (operands, sourceOp),
218
+ rewriter);
219
+ }
212
220
llvm::LogicalResult match (mlir::Operation *op) const final {
213
221
return match (mlir::cast<SourceOp>(op));
214
222
}
@@ -219,7 +227,14 @@ class FIROpConversion : public ConvertFIRToLLVMPattern {
219
227
OpAdaptor (operands, mlir::cast<SourceOp>(op)),
220
228
rewriter);
221
229
}
222
-
230
+ llvm::LogicalResult
231
+ matchAndRewrite (mlir::Operation *op,
232
+ mlir::ArrayRef<mlir::ValueRange> operands,
233
+ mlir::ConversionPatternRewriter &rewriter) const final {
234
+ auto sourceOp = mlir::cast<SourceOp>(op);
235
+ return matchAndRewrite (sourceOp, OneToNOpAdaptor (operands, sourceOp),
236
+ rewriter);
237
+ }
223
238
// / Rewrite and Match methods that operate on the SourceOp type. These must be
224
239
// / overridden by the derived pattern class.
225
240
virtual llvm::LogicalResult match (SourceOp op) const {
@@ -229,6 +244,12 @@ class FIROpConversion : public ConvertFIRToLLVMPattern {
229
244
mlir::ConversionPatternRewriter &rewriter) const {
230
245
llvm_unreachable (" must override rewrite or matchAndRewrite" );
231
246
}
247
+ virtual void rewrite (SourceOp op, OneToNOpAdaptor adaptor,
248
+ mlir::ConversionPatternRewriter &rewriter) const {
249
+ llvm::SmallVector<mlir::Value> oneToOneOperands =
250
+ getOneToOneAdaptorOperands (adaptor.getOperands ());
251
+ rewrite (op, OpAdaptor (oneToOneOperands, adaptor), rewriter);
252
+ }
232
253
virtual llvm::LogicalResult
233
254
matchAndRewrite (SourceOp op, OpAdaptor adaptor,
234
255
mlir::ConversionPatternRewriter &rewriter) const {
@@ -237,6 +258,13 @@ class FIROpConversion : public ConvertFIRToLLVMPattern {
237
258
rewrite (op, adaptor, rewriter);
238
259
return mlir::success ();
239
260
}
261
+ virtual llvm::LogicalResult
262
+ matchAndRewrite (SourceOp op, OneToNOpAdaptor adaptor,
263
+ mlir::ConversionPatternRewriter &rewriter) const {
264
+ llvm::SmallVector<mlir::Value> oneToOneOperands =
265
+ getOneToOneAdaptorOperands (adaptor.getOperands ());
266
+ return matchAndRewrite (op, OpAdaptor (oneToOneOperands, adaptor), rewriter);
267
+ }
240
268
241
269
private:
242
270
using ConvertFIRToLLVMPattern::matchAndRewrite;
0 commit comments