From 69067bccb0ff577106e25e977209b8678c4ed2e6 Mon Sep 17 00:00:00 2001 From: Simon Camphausen Date: Mon, 23 Oct 2023 16:30:33 +0200 Subject: [PATCH] [EmitC][NFC] Introduce common baseclass for conversions and simplify pattern insertion (#14717) This makes future refactoring like adding constructor arguments to conversions easier. Additionally pattern insertion is now sorted alphabetically per macro group, as the ordering by extension wasn't fully followed anyhow. --- .../Conversion/VMToEmitC/ConvertVMToEmitC.cpp | 897 +++++++----------- 1 file changed, 356 insertions(+), 541 deletions(-) diff --git a/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/ConvertVMToEmitC.cpp b/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/ConvertVMToEmitC.cpp index ada92d945c4a..e42dbab06e0e 100644 --- a/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/ConvertVMToEmitC.cpp +++ b/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/ConvertVMToEmitC.cpp @@ -1243,22 +1243,33 @@ void updateResultUses(Operation *op, ConversionPatternRewriter &rewriter, } } +template +class EmitCConversionPattern : public OpConversionPattern { +public: + using Adaptor = typename OpTy::Adaptor; + using OpConversionPattern::OpConversionPattern; + + EmitCConversionPattern(const TypeConverter &typeConverter, + MLIRContext *context) + : OpConversionPattern(typeConverter, context) {} +}; + // Convert vm operations to emitc calls. The resultiong call has the ops // operands as arguments followed by an argument for every attribute. -template -class GenericOpConversion : public OpConversionPattern { - using Adaptor = typename SrcOpTy::Adaptor; - using OpConversionPattern::OpConversionPattern; +template +class GenericOpConversion : public EmitCConversionPattern { + using Adaptor = typename OpTy::Adaptor; + using EmitCConversionPattern::EmitCConversionPattern; public: - GenericOpConversion(TypeConverter &typeConverter, MLIRContext *context, + GenericOpConversion(const TypeConverter &typeConverter, MLIRContext *context, StringRef funcName) - : OpConversionPattern(typeConverter, context), + : EmitCConversionPattern(typeConverter, context), funcName(funcName) {} private: LogicalResult - matchAndRewrite(SrcOpTy op, Adaptor adaptor, + matchAndRewrite(OpTy op, Adaptor adaptor, ConversionPatternRewriter &rewriter) const override { auto ctx = op.getContext(); @@ -1293,22 +1304,22 @@ class GenericOpConversion : public OpConversionPattern { StringRef funcName; }; -template -class DeleteOpConversion : public OpConversionPattern { - using Adaptor = typename SrcOpTy::Adaptor; - using OpConversionPattern::OpConversionPattern; +template +class DeleteOpConversion : public EmitCConversionPattern { + using Adaptor = typename OpTy::Adaptor; + using EmitCConversionPattern::EmitCConversionPattern; LogicalResult - matchAndRewrite(SrcOpTy op, Adaptor adaptor, + matchAndRewrite(OpTy op, Adaptor adaptor, ConversionPatternRewriter &rewriter) const override { rewriter.eraseOp(op); return success(); } }; -class FuncOpConversion : public OpConversionPattern { - using OpConversionPattern::OpConversionPattern; +class FuncOpConversion : public EmitCConversionPattern { using Adaptor = mlir::func::FuncOp::Adaptor; + using EmitCConversionPattern::EmitCConversionPattern; LogicalResult matchAndRewrite(mlir::func::FuncOp funcOp, Adaptor adaptor, @@ -1335,9 +1346,9 @@ class FuncOpConversion : public OpConversionPattern { } }; -class ExportOpConversion : public OpConversionPattern { +class ExportOpConversion : public EmitCConversionPattern { using Adaptor = IREE::VM::ExportOp::Adaptor; - using OpConversionPattern::OpConversionPattern; + using EmitCConversionPattern::EmitCConversionPattern; struct GeneratedStruct { std::optional value = std::nullopt; @@ -2346,13 +2357,13 @@ class ImportOpConverter { SmallVector &importShims; }; -template -class CallOpConversion : public OpConversionPattern { - using Adaptor = typename CallOpTy::Adaptor; - using OpConversionPattern::OpConversionPattern; +template +class CallOpConversion : public EmitCConversionPattern { + using Adaptor = typename OpTy::Adaptor; + using EmitCConversionPattern::EmitCConversionPattern; LogicalResult - matchAndRewrite(CallOpTy op, Adaptor adaptor, + matchAndRewrite(OpTy op, Adaptor adaptor, ConversionPatternRewriter &rewriter) const override { mlir::func::FuncOp funcOp = lookupSymbolRef(op.getOperation(), "callee"); @@ -2606,20 +2617,20 @@ class CallOpConversion : public OpConversionPattern { } }; -template -class CompareRefOpConversion : public OpConversionPattern { - using Adaptor = typename CmpOpTy::Adaptor; - using OpConversionPattern::OpConversionPattern; +template +class CompareRefOpConversion : public EmitCConversionPattern { + using Adaptor = typename OpTy::Adaptor; + using EmitCConversionPattern::EmitCConversionPattern; public: - CompareRefOpConversion(TypeConverter &typeConverter, MLIRContext *context, - StringRef funcName) - : OpConversionPattern(typeConverter, context), + CompareRefOpConversion(const TypeConverter &typeConverter, + MLIRContext *context, StringRef funcName) + : EmitCConversionPattern(typeConverter, context), funcName(funcName) {} private: LogicalResult - matchAndRewrite(CmpOpTy cmpOp, Adaptor adaptor, + matchAndRewrite(OpTy cmpOp, Adaptor adaptor, ConversionPatternRewriter &rewriter) const override { auto ctx = cmpOp.getContext(); auto loc = cmpOp.getLoc(); @@ -2678,9 +2689,9 @@ class CompareRefOpConversion : public OpConversionPattern { }; class CompareRefNotZeroOpConversion - : public OpConversionPattern { + : public EmitCConversionPattern { using Adaptor = IREE::VM::CmpNZRefOp::Adaptor; - using OpConversionPattern::OpConversionPattern; + using EmitCConversionPattern::EmitCConversionPattern; LogicalResult matchAndRewrite(IREE::VM::CmpNZRefOp cmpOp, Adaptor adaptor, @@ -2725,13 +2736,13 @@ class CompareRefNotZeroOpConversion } }; -template -class ConstOpConversion : public OpConversionPattern { - using Adaptor = typename ConstOpTy::Adaptor; - using OpConversionPattern::OpConversionPattern; +template +class ConstOpConversion : public EmitCConversionPattern { + using Adaptor = typename OpTy::Adaptor; + using EmitCConversionPattern::EmitCConversionPattern; LogicalResult - matchAndRewrite(ConstOpTy constOp, Adaptor adaptor, + matchAndRewrite(OpTy constOp, Adaptor adaptor, ConversionPatternRewriter &rewriter) const override { rewriter.replaceOpWithNewOp(constOp, constOp.getType(), constOp.getValue()); @@ -2739,13 +2750,13 @@ class ConstOpConversion : public OpConversionPattern { } }; -template -class ConstZeroOpConversion : public OpConversionPattern { - using Adaptor = typename ConstZeroOpTy::Adaptor; - using OpConversionPattern::OpConversionPattern; +template +class ConstZeroOpConversion : public EmitCConversionPattern { + using Adaptor = typename OpTy::Adaptor; + using EmitCConversionPattern::EmitCConversionPattern; LogicalResult - matchAndRewrite(ConstZeroOpTy constZeroOp, Adaptor adaptor, + matchAndRewrite(OpTy constZeroOp, Adaptor adaptor, ConversionPatternRewriter &rewriter) const override { auto type = constZeroOp.getType(); @@ -2757,9 +2768,10 @@ class ConstZeroOpConversion : public OpConversionPattern { }; class ConstRefZeroOpConversion - : public OpConversionPattern { + : public EmitCConversionPattern { using Adaptor = IREE::VM::ConstRefZeroOp::Adaptor; - using OpConversionPattern::OpConversionPattern; + using EmitCConversionPattern< + IREE::VM::ConstRefZeroOp>::EmitCConversionPattern; LogicalResult matchAndRewrite(IREE::VM::ConstRefZeroOp constRefZeroOp, Adaptor adaptor, @@ -2786,9 +2798,10 @@ class ConstRefZeroOpConversion }; class ConstRefRodataOpConversion - : public OpConversionPattern { + : public EmitCConversionPattern { using Adaptor = IREE::VM::ConstRefRodataOp::Adaptor; - using OpConversionPattern::OpConversionPattern; + using EmitCConversionPattern< + IREE::VM::ConstRefRodataOp>::EmitCConversionPattern; LogicalResult matchAndRewrite(IREE::VM::ConstRefRodataOp constRefRodataOp, Adaptor adaptor, @@ -2860,9 +2873,9 @@ class ConstRefRodataOpConversion } }; -class BranchOpConversion : public OpConversionPattern { +class BranchOpConversion : public EmitCConversionPattern { using Adaptor = IREE::VM::BranchOp::Adaptor; - using OpConversionPattern::OpConversionPattern; + using EmitCConversionPattern::EmitCConversionPattern; LogicalResult matchAndRewrite(IREE::VM::BranchOp op, Adaptor adaptor, @@ -2970,9 +2983,9 @@ class BranchOpConversion : public OpConversionPattern { // ... // clang-format on class CondBranchOpConversion - : public OpConversionPattern { + : public EmitCConversionPattern { using Adaptor = IREE::VM::CondBranchOp::Adaptor; - using OpConversionPattern::OpConversionPattern; + using EmitCConversionPattern::EmitCConversionPattern; LogicalResult matchAndRewrite(IREE::VM::CondBranchOp op, Adaptor adaptor, @@ -3051,9 +3064,9 @@ class CondBranchOpConversion } }; -class ReturnOpConversion : public OpConversionPattern { +class ReturnOpConversion : public EmitCConversionPattern { using Adaptor = IREE::VM::ReturnOp::Adaptor; - using OpConversionPattern::OpConversionPattern; + using EmitCConversionPattern::EmitCConversionPattern; LogicalResult matchAndRewrite(IREE::VM::ReturnOp op, Adaptor adaptor, @@ -3115,13 +3128,10 @@ class ReturnOpConversion : public OpConversionPattern { }; class ImportResolvedOpConversion - : public OpConversionPattern { + : public EmitCConversionPattern { using Adaptor = IREE::VM::ImportResolvedOp::Adaptor; - using OpConversionPattern::OpConversionPattern; - -public: - ImportResolvedOpConversion(TypeConverter &typeConverter, MLIRContext *context) - : OpConversionPattern(typeConverter, context) {} + using EmitCConversionPattern< + IREE::VM::ImportResolvedOp>::EmitCConversionPattern; private: LogicalResult @@ -3184,9 +3194,9 @@ class ImportResolvedOpConversion } }; -class FailOpConversion : public OpConversionPattern { +class FailOpConversion : public EmitCConversionPattern { using Adaptor = IREE::VM::FailOp::Adaptor; - using OpConversionPattern::OpConversionPattern; + using EmitCConversionPattern::EmitCConversionPattern; LogicalResult matchAndRewrite(IREE::VM::FailOp op, Adaptor adaptor, @@ -3284,20 +3294,20 @@ class FailOpConversion : public OpConversionPattern { } }; -template -class GlobalLoadOpConversion : public OpConversionPattern { - using Adaptor = typename LoadOpTy::Adaptor; - using OpConversionPattern::OpConversionPattern; +template +class GlobalLoadOpConversion : public EmitCConversionPattern { + using Adaptor = typename OpTy::Adaptor; + using EmitCConversionPattern::EmitCConversionPattern; public: - GlobalLoadOpConversion(TypeConverter &typeConverter, MLIRContext *context, - StringRef funcName) - : OpConversionPattern(typeConverter, context), + GlobalLoadOpConversion(const TypeConverter &typeConverter, + MLIRContext *context, StringRef funcName) + : EmitCConversionPattern(typeConverter, context), funcName(funcName) {} private: LogicalResult - matchAndRewrite(LoadOpTy loadOp, Adaptor adaptor, + matchAndRewrite(OpTy loadOp, Adaptor adaptor, ConversionPatternRewriter &rewriter) const override { auto ctx = loadOp.getContext(); auto loc = loadOp.getLoc(); @@ -3338,14 +3348,13 @@ class GlobalLoadOpConversion : public OpConversionPattern { StringRef funcName; }; -template -class GlobalLoadStoreRefOpConversion - : public OpConversionPattern { - using Adaptor = typename LoadStoreOpTy::Adaptor; - using OpConversionPattern::OpConversionPattern; +template +class GlobalLoadStoreRefOpConversion : public EmitCConversionPattern { + using Adaptor = typename OpTy::Adaptor; + using EmitCConversionPattern::EmitCConversionPattern; LogicalResult - matchAndRewrite(LoadStoreOpTy op, Adaptor adaptor, + matchAndRewrite(OpTy op, Adaptor adaptor, ConversionPatternRewriter &rewriter) const override { if (isa(op)) { return rewriteOp(op.getOperation(), adaptor, rewriter, true); @@ -3456,20 +3465,20 @@ class GlobalLoadStoreRefOpConversion } }; -template -class GlobalStoreOpConversion : public OpConversionPattern { - using Adaptor = typename StoreOpTy::Adaptor; - using OpConversionPattern::OpConversionPattern; +template +class GlobalStoreOpConversion : public EmitCConversionPattern { + using Adaptor = typename OpTy::Adaptor; + using EmitCConversionPattern::EmitCConversionPattern; public: - GlobalStoreOpConversion(TypeConverter &typeConverter, MLIRContext *context, - StringRef funcName) - : OpConversionPattern(typeConverter, context), + GlobalStoreOpConversion(const TypeConverter &typeConverter, + MLIRContext *context, StringRef funcName) + : EmitCConversionPattern(typeConverter, context), funcName(funcName) {} private: LogicalResult - matchAndRewrite(StoreOpTy storeOp, Adaptor adaptor, + matchAndRewrite(OpTy storeOp, Adaptor adaptor, ConversionPatternRewriter &rewriter) const override { auto ctx = storeOp.getContext(); auto loc = storeOp.getLoc(); @@ -3515,22 +3524,22 @@ class GlobalStoreOpConversion : public OpConversionPattern { // Convert vm operations with wrapped containers to multiple emitc calls. The // wrapping ref pointers are first dereferenced and the results are used as the // arguments of the specified function name. -template -class ContainerOpConversion : public OpConversionPattern { - using Adaptor = typename SrcOpTy::Adaptor; - using OpConversionPattern::OpConversionPattern; +template +class ContainerOpConversion : public EmitCConversionPattern { + using Adaptor = typename OpTy::Adaptor; + using EmitCConversionPattern::EmitCConversionPattern; public: - ContainerOpConversion(TypeConverter &typeConverter, MLIRContext *context, - StringRef funcName, DenseSet refArgumentIndices, - bool failable) - : OpConversionPattern(typeConverter, context), + ContainerOpConversion(const TypeConverter &typeConverter, + MLIRContext *context, StringRef funcName, + DenseSet refArgumentIndices, bool failable) + : EmitCConversionPattern(typeConverter, context), funcName(funcName), refArgumentIndices(refArgumentIndices), failable(failable) {} private: LogicalResult - matchAndRewrite(SrcOpTy op, Adaptor adaptor, + matchAndRewrite(OpTy op, Adaptor adaptor, ConversionPatternRewriter &rewriter) const override { auto ctx = op.getContext(); auto loc = op.getLoc(); @@ -3672,10 +3681,10 @@ class ContainerOpConversion : public OpConversionPattern { bool failable; }; -template -class ContainerAllocOpConversion : public OpConversionPattern { - using Adaptor = typename SrcOpTy::Adaptor; - using OpConversionPattern::OpConversionPattern; +template +class ContainerAllocOpConversion : public EmitCConversionPattern { + using Adaptor = typename OpTy::Adaptor; + using EmitCConversionPattern::EmitCConversionPattern; // Bundle function and type names based on the container type struct CNames { @@ -3685,7 +3694,7 @@ class ContainerAllocOpConversion : public OpConversionPattern { }; LogicalResult - matchAndRewrite(SrcOpTy op, Adaptor adaptor, + matchAndRewrite(OpTy op, Adaptor adaptor, ConversionPatternRewriter &rewriter) const override { auto ctx = op.getContext(); auto loc = op.getLoc(); @@ -3777,7 +3786,7 @@ class ContainerAllocOpConversion : public OpConversionPattern { return std::nullopt; } - std::optional extractCNames(SrcOpTy op) const { + std::optional extractCNames(OpTy op) const { if (isa(op)) { return CNames{"iree_vm_list_t", "iree_vm_list_type", "iree_vm_list_create"}; @@ -3910,13 +3919,13 @@ class ContainerAllocOpConversion : public OpConversionPattern { } }; -template -class ListGetOpConversion : public OpConversionPattern { - using Adaptor = typename GetOpTy::Adaptor; - using OpConversionPattern::OpConversionPattern; +template +class ListGetOpConversion : public EmitCConversionPattern { + using Adaptor = typename OpTy::Adaptor; + using EmitCConversionPattern::EmitCConversionPattern; LogicalResult - matchAndRewrite(GetOpTy getOp, Adaptor adaptor, + matchAndRewrite(OpTy getOp, Adaptor adaptor, ConversionPatternRewriter &rewriter) const override { auto ctx = getOp.getContext(); auto loc = getOp.getLoc(); @@ -3991,9 +4000,9 @@ class ListGetOpConversion : public OpConversionPattern { }; class ListGetRefOpConversion - : public OpConversionPattern { + : public EmitCConversionPattern { using Adaptor = IREE::VM::ListGetRefOp::Adaptor; - using OpConversionPattern::OpConversionPattern; + using EmitCConversionPattern::EmitCConversionPattern; LogicalResult matchAndRewrite(IREE::VM::ListGetRefOp getOp, Adaptor adaptor, @@ -4146,13 +4155,13 @@ class ListGetRefOpConversion } }; -template -class ListSetOpConversion : public OpConversionPattern { - using Adaptor = typename SetOpTy::Adaptor; - using OpConversionPattern::OpConversionPattern; +template +class ListSetOpConversion : public EmitCConversionPattern { + using Adaptor = typename OpTy::Adaptor; + using EmitCConversionPattern::EmitCConversionPattern; LogicalResult - matchAndRewrite(SetOpTy setOp, Adaptor adaptor, + matchAndRewrite(OpTy setOp, Adaptor adaptor, ConversionPatternRewriter &rewriter) const override { auto ctx = setOp.getContext(); auto loc = setOp.getLoc(); @@ -4213,9 +4222,9 @@ class ListSetOpConversion : public OpConversionPattern { }; class ListSetRefOpConversion - : public OpConversionPattern { + : public EmitCConversionPattern { using Adaptor = IREE::VM::ListSetRefOp::Adaptor; - using OpConversionPattern::OpConversionPattern; + using EmitCConversionPattern::EmitCConversionPattern; LogicalResult matchAndRewrite(IREE::VM::ListSetRefOp setOp, Adaptor adaptor, @@ -4276,438 +4285,244 @@ void populateVMToEmitCPatterns(ConversionTarget &conversionTarget, populateUtilConversionPatterns(context, conversionTarget, typeConverter, patterns); - // CFG - patterns.add(typeConverter, context); - patterns.add>(typeConverter, context); - patterns.add>(typeConverter, - context); - patterns.add(typeConverter, context); - patterns.add(typeConverter, context); - patterns.add(typeConverter, context); - patterns.add(typeConverter, context); - patterns.add(typeConverter, context); - patterns.add(typeConverter, context); - - // Globals - // Globals get packed into the state struct and are referenced by their - // ordinal only after the conversion. - patterns.add>(typeConverter, - context); - patterns.add>(typeConverter, - context); - patterns.add>(typeConverter, - context); - patterns.add>(typeConverter, - context); - - patterns.add< - GlobalLoadOpConversion>( - typeConverter, context, "vm_global_load_i32"); - patterns.add>( - typeConverter, context, "vm_global_store_i32"); - - patterns.add>( - typeConverter, context); - patterns.add>( - typeConverter, context); - - // Constants - patterns.add>(typeConverter, context); - patterns.add>(typeConverter, - context); - patterns.add(typeConverter, context); - patterns.add(typeConverter, context); - - // List ops - patterns.add>(typeConverter, - context); - patterns.add>( - typeConverter, context, "iree_vm_list_reserve", DenseSet({0}), - true); - patterns.add>( - typeConverter, context, "iree_vm_list_resize", DenseSet({0}), - true); - patterns.add>( - typeConverter, context, "iree_vm_list_size", DenseSet({0}), - false); - patterns.add>(typeConverter, - context); - patterns.add(typeConverter, context); - patterns.add>(typeConverter, - context); - patterns.add(typeConverter, context); - - // Buffer ops - patterns.add>( - typeConverter, context); - patterns.add>( - typeConverter, context); - patterns.add>( - typeConverter, context, "iree_vm_buffer_length", DenseSet({0}), - false); - patterns.add>( - typeConverter, context, "vm_buffer_compare", DenseSet({0, 2}), - true); - patterns.add>( - typeConverter, context, "iree_vm_buffer_copy_bytes", - DenseSet({0, 2}), true); - patterns.add>( - typeConverter, context, "vm_buffer_fill_i8", DenseSet({0}), true); - patterns.add>( - typeConverter, context, "vm_buffer_fill_i16", DenseSet({0}), - true); - patterns.add>( - typeConverter, context, "vm_buffer_fill_i32", DenseSet({0}), - true); - patterns.add>( - typeConverter, context, "vm_buffer_load_i8s", DenseSet({0}), - true); - patterns.add>( - typeConverter, context, "vm_buffer_load_i8u", DenseSet({0}), - true); - patterns.add>( - typeConverter, context, "vm_buffer_store_i8", DenseSet({0}), - true); - patterns.add>( - typeConverter, context, "vm_buffer_load_i16s", DenseSet({0}), - true); - patterns.add>( - typeConverter, context, "vm_buffer_load_i16u", DenseSet({0}), - true); - patterns.add>( - typeConverter, context, "vm_buffer_store_i16", DenseSet({0}), - true); - patterns.add>( - typeConverter, context, "vm_buffer_load_i32", DenseSet({0}), - true); - patterns.add>( - typeConverter, context, "vm_buffer_store_i32", DenseSet({0}), - true); - - // Conditional assignment ops - patterns.add>( - typeConverter, context, "vm_select_i32"); - - // Native integer arithmetic ops - patterns.add>(typeConverter, context, - "vm_add_i32"); - patterns.add>(typeConverter, context, - "vm_sub_i32"); - patterns.add>(typeConverter, context, - "vm_mul_i32"); - patterns.add>(typeConverter, context, - "vm_div_i32s"); - patterns.add>(typeConverter, context, - "vm_div_i32u"); - patterns.add>(typeConverter, context, - "vm_rem_i32s"); - patterns.add>(typeConverter, context, - "vm_rem_i32u"); - patterns.add>(typeConverter, context, - "vm_fma_i32"); - patterns.add>(typeConverter, context, - "vm_abs_i32"); - patterns.add>(typeConverter, context, - "vm_min_i32s"); - patterns.add>(typeConverter, context, - "vm_min_i32u"); - patterns.add>(typeConverter, context, - "vm_max_i32s"); - patterns.add>(typeConverter, context, - "vm_max_i32u"); - patterns.add>(typeConverter, context, - "vm_not_i32"); - patterns.add>(typeConverter, context, - "vm_and_i32"); - patterns.add>(typeConverter, context, - "vm_or_i32"); - patterns.add>(typeConverter, context, - "vm_xor_i32"); - patterns.add>(typeConverter, context, - "vm_ctlz_i32"); - - // Casting and type conversion/emulation ops - patterns.add>( - typeConverter, context, "vm_trunc_i16i8"); - patterns.add>( - typeConverter, context, "vm_trunc_i32i8"); - patterns.add>( - typeConverter, context, "vm_trunc_i32i16"); - patterns.add>( - typeConverter, context, "vm_ext_i8i32s"); - patterns.add>( - typeConverter, context, "vm_ext_i8i32u"); - patterns.add>( - typeConverter, context, "vm_ext_i16i32s"); - patterns.add>( - typeConverter, context, "vm_ext_i16i32u"); - - // Native bitwise shift and rotate ops - patterns.add>(typeConverter, context, - "vm_shl_i32"); - patterns.add>(typeConverter, context, - "vm_shr_i32s"); - patterns.add>(typeConverter, context, - "vm_shr_i32u"); - - // Comparison ops - patterns.add>( - typeConverter, context, "vm_cmp_eq_i32"); - patterns.add>( - typeConverter, context, "vm_cmp_ne_i32"); - patterns.add>( - typeConverter, context, "vm_cmp_lt_i32s"); - patterns.add>( - typeConverter, context, "vm_cmp_lt_i32u"); - patterns.add>( - typeConverter, context, "vm_cmp_nz_i32"); - patterns.add>( - typeConverter, context, "vm_cmp_eq_ref"); - patterns.add>( - typeConverter, context, "vm_cmp_ne_ref"); - patterns.add(typeConverter, context); - - // ExtF32: Globals - patterns.add< - GlobalLoadOpConversion>( - typeConverter, context, "vm_global_load_f32"); - patterns.add>( - typeConverter, context, "vm_global_store_f32"); - - // ExtF32: Native floating-point constants - patterns.add>(typeConverter, context); - patterns.add>(typeConverter, - context); - - // ExtF32: Buffer ops - patterns.add>( - typeConverter, context, "vm_buffer_fill_f32", DenseSet({0}), - true); - patterns.add>( - typeConverter, context, "vm_buffer_load_f32", DenseSet({0}), - true); - patterns.add>( - typeConverter, context, "vm_buffer_store_f32", DenseSet({0}), - true); - - // ExtF32: Conditional assignment - patterns.add>( - typeConverter, context, "vm_select_f32"); - - // ExtF32: Native floating-point arithmetic - patterns.add>(typeConverter, context, - "vm_add_f32"); - patterns.add>(typeConverter, context, - "vm_sub_f32"); - patterns.add>(typeConverter, context, - "vm_mul_f32"); - patterns.add>(typeConverter, context, - "vm_div_f32"); - patterns.add>(typeConverter, context, - "vm_rem_f32"); - patterns.add>(typeConverter, context, - "vm_fma_f32"); - patterns.add>(typeConverter, context, - "vm_abs_f32"); - patterns.add>(typeConverter, context, - "vm_neg_f32"); - patterns.add>(typeConverter, context, - "vm_ceil_f32"); - patterns.add>( - typeConverter, context, "vm_floor_f32"); - patterns.add>( - typeConverter, context, "vm_round_f32"); - patterns.add>( - typeConverter, context, "vm_round_f32_even"); - patterns.add>(typeConverter, context, - "vm_min_f32"); - patterns.add>(typeConverter, context, - "vm_max_f32"); - - patterns.add>(typeConverter, context, - "vm_atan_f32"); - patterns.add>( - typeConverter, context, "vm_atan2_f32"); - patterns.add>(typeConverter, context, - "vm_cos_f32"); - patterns.add>(typeConverter, context, - "vm_sin_f32"); - patterns.add>(typeConverter, context, - "vm_exp_f32"); - patterns.add>(typeConverter, context, - "vm_exp2_f32"); - patterns.add>( - typeConverter, context, "vm_expm1_f32"); - patterns.add>(typeConverter, context, - "vm_log_f32"); - patterns.add>( - typeConverter, context, "vm_log10_f32"); - patterns.add>( - typeConverter, context, "vm_log1p_f32"); - patterns.add>(typeConverter, context, - "vm_log2_f32"); - patterns.add>(typeConverter, context, - "vm_pow_f32"); - patterns.add>( - typeConverter, context, "vm_rsqrt_f32"); - patterns.add>(typeConverter, context, - "vm_sqrt_f32"); - patterns.add>(typeConverter, context, - "vm_tanh_f32"); - patterns.add>(typeConverter, context, - "vm_erf_f32"); - - // ExtF32: Casting and type conversion/emulation - patterns.add>( - typeConverter, context, "vm_cast_si32f32"); - patterns.add>( - typeConverter, context, "vm_cast_ui32f32"); - patterns.add>( - typeConverter, context, "vm_cast_f32si32"); - patterns.add>( - typeConverter, context, "vm_cast_f32ui32"); - patterns.add>( - typeConverter, context, "vm_bitcast_i32f32"); - patterns.add>( - typeConverter, context, "vm_bitcast_f32i32"); - - // ExtF32: Comparison ops - patterns.add>( - typeConverter, context, "vm_cmp_eq_f32o"); - patterns.add>( - typeConverter, context, "vm_cmp_eq_f32u"); - patterns.add>( - typeConverter, context, "vm_cmp_ne_f32o"); - patterns.add>( - typeConverter, context, "vm_cmp_ne_f32u"); - patterns.add>( - typeConverter, context, "vm_cmp_lt_f32o"); - patterns.add>( - typeConverter, context, "vm_cmp_lt_f32u"); - patterns.add>( - typeConverter, context, "vm_cmp_lte_f32o"); - patterns.add>( - typeConverter, context, "vm_cmp_lte_f32u"); - patterns.add>( - typeConverter, context, "vm_cmp_nan_f32"); - - // ExtI64: Globals + // Patterns +#define ADD_GENERIC_PATTERN(Op, FuncName) \ + patterns.add>(typeConverter, context, FuncName) +#define ADD_CONTAINER_PATTERN(Op, FuncName, IndexSet, Failable) \ + patterns.add>(typeConverter, context, FuncName, \ + IndexSet, Failable); +#define ADD_GLOBAL_LOAD_PATTERN(Op, GlobalOp, FuncName) \ + patterns.add>(typeConverter, context, \ + FuncName); +#define ADD_GLOBAL_STORE_PATTERN(Op, GlobalOp, FuncName) \ + patterns.add>(typeConverter, context, \ + FuncName); + + // argument free patterns + // clang-format off patterns.add< - GlobalLoadOpConversion>( - typeConverter, context, "vm_global_load_i64"); - patterns.add>( - typeConverter, context, "vm_global_store_i64"); - - // ExtI64: Constants - patterns.add>(typeConverter, context); - patterns.add>(typeConverter, - context); - - // ExtI64: List ops - patterns.add>(typeConverter, - context); - patterns.add>(typeConverter, - context); - - // ExtI64: Buffer ops - patterns.add>( - typeConverter, context, "vm_buffer_fill_i64", DenseSet({0}), - true); - patterns.add>( - typeConverter, context, "vm_buffer_load_i64", DenseSet({0}), - true); - patterns.add>( - typeConverter, context, "vm_buffer_store_i64", DenseSet({0}), - true); - - // ExtI64: Conditional assignment ops - patterns.add>( - typeConverter, context, "vm_select_i64"); - - // ExtI64: Native integer arithmetic ops - patterns.add>(typeConverter, context, - "vm_add_i64"); - patterns.add>(typeConverter, context, - "vm_sub_i64"); - patterns.add>(typeConverter, context, - "vm_mul_i64"); - patterns.add>(typeConverter, context, - "vm_div_i64s"); - patterns.add>(typeConverter, context, - "vm_div_i64u"); - patterns.add>(typeConverter, context, - "vm_rem_i64s"); - patterns.add>(typeConverter, context, - "vm_rem_i64u"); - patterns.add>(typeConverter, context, - "vm_fma_i64"); - patterns.add>(typeConverter, context, - "vm_abs_i64"); - patterns.add>(typeConverter, context, - "vm_min_i64s"); - patterns.add>(typeConverter, context, - "vm_min_i64u"); - patterns.add>(typeConverter, context, - "vm_max_i64s"); - patterns.add>(typeConverter, context, - "vm_max_i64u"); - patterns.add>(typeConverter, context, - "vm_not_i64"); - patterns.add>(typeConverter, context, - "vm_and_i64"); - patterns.add>(typeConverter, context, - "vm_or_i64"); - patterns.add>(typeConverter, context, - "vm_xor_i64"); - patterns.add>(typeConverter, context, - "vm_ctlz_i64"); - - // ExtI64: Casting and type conversion/emulation ops - patterns.add>( - typeConverter, context, "vm_trunc_i64i32"); - patterns.add>( - typeConverter, context, "vm_ext_i32i64s"); - patterns.add>( - typeConverter, context, "vm_ext_i32i64u"); - - // ExtI64: Native bitwise shift and rotate ops - patterns.add>(typeConverter, context, - "vm_shl_i64"); - patterns.add>(typeConverter, context, - "vm_shr_i64s"); - patterns.add>(typeConverter, context, - "vm_shr_i64u"); - - // ExtI64: Comparison ops - patterns.add>( - typeConverter, context, "vm_cmp_eq_i64"); - patterns.add>( - typeConverter, context, "vm_cmp_ne_i64"); - patterns.add>( - typeConverter, context, "vm_cmp_lt_i64s"); - patterns.add>( - typeConverter, context, "vm_cmp_lt_i64u"); - patterns.add>( - typeConverter, context, "vm_cmp_nz_i64"); - - // ExtF64: - // ExtI64: Constants - patterns.add>(typeConverter, context); - patterns.add>(typeConverter, - context); - // ExtF64: Buffer ops - patterns.add>( - typeConverter, context, "vm_buffer_fill_f64", DenseSet({0}), - true); - patterns.add>( - typeConverter, context, "vm_buffer_load_f64", DenseSet({0}), - true); - patterns.add>( - typeConverter, context, "vm_buffer_store_f64", DenseSet({0}), - true); + BranchOpConversion, + CallOpConversion, + CallOpConversion, + CompareRefNotZeroOpConversion, + CondBranchOpConversion, + ConstOpConversion, + ConstOpConversion, + ConstOpConversion, + ConstOpConversion, + ConstRefRodataOpConversion, + ConstRefZeroOpConversion, + ConstZeroOpConversion, + ConstZeroOpConversion, + ConstZeroOpConversion, + ConstZeroOpConversion, + ContainerAllocOpConversion, + ContainerAllocOpConversion, + ContainerAllocOpConversion, + DeleteOpConversion, + DeleteOpConversion, + DeleteOpConversion, + DeleteOpConversion, + ExportOpConversion, + FailOpConversion, + FuncOpConversion, + GlobalLoadStoreRefOpConversion, + GlobalLoadStoreRefOpConversion, + ImportResolvedOpConversion, + ListGetOpConversion, + ListGetOpConversion, + ListGetRefOpConversion, + ListSetOpConversion, + ListSetOpConversion, + ListSetRefOpConversion, + ReturnOpConversion + >(typeConverter, context); + // clang-format on + + // generic conversions + ADD_GENERIC_PATTERN(IREE::VM::AbsF32Op, "vm_abs_f32"); + ADD_GENERIC_PATTERN(IREE::VM::AbsI32Op, "vm_abs_i32"); + ADD_GENERIC_PATTERN(IREE::VM::AbsI64Op, "vm_abs_i64"); + ADD_GENERIC_PATTERN(IREE::VM::AddF32Op, "vm_add_f32"); + ADD_GENERIC_PATTERN(IREE::VM::AddI32Op, "vm_add_i32"); + ADD_GENERIC_PATTERN(IREE::VM::AddI64Op, "vm_add_i64"); + ADD_GENERIC_PATTERN(IREE::VM::AndI32Op, "vm_and_i32"); + ADD_GENERIC_PATTERN(IREE::VM::AndI64Op, "vm_and_i64"); + ADD_GENERIC_PATTERN(IREE::VM::Atan2F32Op, "vm_atan2_f32"); + ADD_GENERIC_PATTERN(IREE::VM::AtanF32Op, "vm_atan_f32"); + ADD_GENERIC_PATTERN(IREE::VM::BitcastF32I32Op, "vm_bitcast_f32i32"); + ADD_GENERIC_PATTERN(IREE::VM::BitcastI32F32Op, "vm_bitcast_i32f32"); + ADD_GENERIC_PATTERN(IREE::VM::CastF32SI32Op, "vm_cast_f32si32"); + ADD_GENERIC_PATTERN(IREE::VM::CastF32UI32Op, "vm_cast_f32ui32"); + ADD_GENERIC_PATTERN(IREE::VM::CastSI32F32Op, "vm_cast_si32f32"); + ADD_GENERIC_PATTERN(IREE::VM::CastUI32F32Op, "vm_cast_ui32f32"); + ADD_GENERIC_PATTERN(IREE::VM::CeilF32Op, "vm_ceil_f32"); + ADD_GENERIC_PATTERN(IREE::VM::CmpEQF32OOp, "vm_cmp_eq_f32o"); + ADD_GENERIC_PATTERN(IREE::VM::CmpEQF32UOp, "vm_cmp_eq_f32u"); + ADD_GENERIC_PATTERN(IREE::VM::CmpEQI32Op, "vm_cmp_eq_i32"); + ADD_GENERIC_PATTERN(IREE::VM::CmpEQI64Op, "vm_cmp_eq_i64"); + ADD_GENERIC_PATTERN(IREE::VM::CmpEQRefOp, "vm_cmp_eq_ref"); + ADD_GENERIC_PATTERN(IREE::VM::CmpLTEF32OOp, "vm_cmp_lte_f32o"); + ADD_GENERIC_PATTERN(IREE::VM::CmpLTEF32UOp, "vm_cmp_lte_f32u"); + ADD_GENERIC_PATTERN(IREE::VM::CmpLTF32OOp, "vm_cmp_lt_f32o"); + ADD_GENERIC_PATTERN(IREE::VM::CmpLTF32UOp, "vm_cmp_lt_f32u"); + ADD_GENERIC_PATTERN(IREE::VM::CmpLTI32SOp, "vm_cmp_lt_i32s"); + ADD_GENERIC_PATTERN(IREE::VM::CmpLTI32UOp, "vm_cmp_lt_i32u"); + ADD_GENERIC_PATTERN(IREE::VM::CmpLTI64SOp, "vm_cmp_lt_i64s"); + ADD_GENERIC_PATTERN(IREE::VM::CmpLTI64UOp, "vm_cmp_lt_i64u"); + ADD_GENERIC_PATTERN(IREE::VM::CmpNaNF32Op, "vm_cmp_nan_f32"); + ADD_GENERIC_PATTERN(IREE::VM::CmpNEF32OOp, "vm_cmp_ne_f32o"); + ADD_GENERIC_PATTERN(IREE::VM::CmpNEF32UOp, "vm_cmp_ne_f32u"); + ADD_GENERIC_PATTERN(IREE::VM::CmpNEI32Op, "vm_cmp_ne_i32"); + ADD_GENERIC_PATTERN(IREE::VM::CmpNEI64Op, "vm_cmp_ne_i64"); + ADD_GENERIC_PATTERN(IREE::VM::CmpNERefOp, "vm_cmp_ne_ref"); + ADD_GENERIC_PATTERN(IREE::VM::CmpNZI32Op, "vm_cmp_nz_i32"); + ADD_GENERIC_PATTERN(IREE::VM::CmpNZI64Op, "vm_cmp_nz_i64"); + ADD_GENERIC_PATTERN(IREE::VM::CosF32Op, "vm_cos_f32"); + ADD_GENERIC_PATTERN(IREE::VM::CtlzI32Op, "vm_ctlz_i32"); + ADD_GENERIC_PATTERN(IREE::VM::CtlzI64Op, "vm_ctlz_i64"); + ADD_GENERIC_PATTERN(IREE::VM::DivF32Op, "vm_div_f32"); + ADD_GENERIC_PATTERN(IREE::VM::DivI32SOp, "vm_div_i32s"); + ADD_GENERIC_PATTERN(IREE::VM::DivI32UOp, "vm_div_i32u"); + ADD_GENERIC_PATTERN(IREE::VM::DivI64SOp, "vm_div_i64s"); + ADD_GENERIC_PATTERN(IREE::VM::DivI64UOp, "vm_div_i64u"); + ADD_GENERIC_PATTERN(IREE::VM::ErfF32Op, "vm_erf_f32"); + ADD_GENERIC_PATTERN(IREE::VM::Exp2F32Op, "vm_exp2_f32"); + ADD_GENERIC_PATTERN(IREE::VM::ExpF32Op, "vm_exp_f32"); + ADD_GENERIC_PATTERN(IREE::VM::ExpM1F32Op, "vm_expm1_f32"); + ADD_GENERIC_PATTERN(IREE::VM::ExtI8I32SOp, "vm_ext_i8i32s"); + ADD_GENERIC_PATTERN(IREE::VM::ExtI8I32UOp, "vm_ext_i8i32u"); + ADD_GENERIC_PATTERN(IREE::VM::ExtI16I32SOp, "vm_ext_i16i32s"); + ADD_GENERIC_PATTERN(IREE::VM::ExtI16I32UOp, "vm_ext_i16i32u"); + ADD_GENERIC_PATTERN(IREE::VM::ExtI32I64SOp, "vm_ext_i32i64s"); + ADD_GENERIC_PATTERN(IREE::VM::ExtI32I64UOp, "vm_ext_i32i64u"); + ADD_GENERIC_PATTERN(IREE::VM::FloorF32Op, "vm_floor_f32"); + ADD_GENERIC_PATTERN(IREE::VM::FMAF32Op, "vm_fma_f32"); + ADD_GENERIC_PATTERN(IREE::VM::FMAI32Op, "vm_fma_i32"); + ADD_GENERIC_PATTERN(IREE::VM::FMAI64Op, "vm_fma_i64"); + ADD_GENERIC_PATTERN(IREE::VM::Log1pF32Op, "vm_log1p_f32"); + ADD_GENERIC_PATTERN(IREE::VM::Log2F32Op, "vm_log2_f32"); + ADD_GENERIC_PATTERN(IREE::VM::Log10F32Op, "vm_log10_f32"); + ADD_GENERIC_PATTERN(IREE::VM::LogF32Op, "vm_log_f32"); + ADD_GENERIC_PATTERN(IREE::VM::MaxF32Op, "vm_max_f32"); + ADD_GENERIC_PATTERN(IREE::VM::MaxI32SOp, "vm_max_i32s"); + ADD_GENERIC_PATTERN(IREE::VM::MaxI32UOp, "vm_max_i32u"); + ADD_GENERIC_PATTERN(IREE::VM::MaxI64SOp, "vm_max_i64s"); + ADD_GENERIC_PATTERN(IREE::VM::MaxI64UOp, "vm_max_i64u"); + ADD_GENERIC_PATTERN(IREE::VM::MinF32Op, "vm_min_f32"); + ADD_GENERIC_PATTERN(IREE::VM::MinI32SOp, "vm_min_i32s"); + ADD_GENERIC_PATTERN(IREE::VM::MinI32UOp, "vm_min_i32u"); + ADD_GENERIC_PATTERN(IREE::VM::MinI64SOp, "vm_min_i64s"); + ADD_GENERIC_PATTERN(IREE::VM::MinI64UOp, "vm_min_i64u"); + ADD_GENERIC_PATTERN(IREE::VM::MulF32Op, "vm_mul_f32"); + ADD_GENERIC_PATTERN(IREE::VM::MulI32Op, "vm_mul_i32"); + ADD_GENERIC_PATTERN(IREE::VM::MulI64Op, "vm_mul_i64"); + ADD_GENERIC_PATTERN(IREE::VM::NegF32Op, "vm_neg_f32"); + ADD_GENERIC_PATTERN(IREE::VM::NotI32Op, "vm_not_i32"); + ADD_GENERIC_PATTERN(IREE::VM::NotI64Op, "vm_not_i64"); + ADD_GENERIC_PATTERN(IREE::VM::OrI32Op, "vm_or_i32"); + ADD_GENERIC_PATTERN(IREE::VM::OrI64Op, "vm_or_i64"); + ADD_GENERIC_PATTERN(IREE::VM::PowF32Op, "vm_pow_f32"); + ADD_GENERIC_PATTERN(IREE::VM::RemF32Op, "vm_rem_f32"); + ADD_GENERIC_PATTERN(IREE::VM::RemI32SOp, "vm_rem_i32s"); + ADD_GENERIC_PATTERN(IREE::VM::RemI32UOp, "vm_rem_i32u"); + ADD_GENERIC_PATTERN(IREE::VM::RemI64SOp, "vm_rem_i64s"); + ADD_GENERIC_PATTERN(IREE::VM::RemI64UOp, "vm_rem_i64u"); + ADD_GENERIC_PATTERN(IREE::VM::RoundF32EvenOp, "vm_round_f32_even"); + ADD_GENERIC_PATTERN(IREE::VM::RoundF32Op, "vm_round_f32"); + ADD_GENERIC_PATTERN(IREE::VM::RsqrtF32Op, "vm_rsqrt_f32"); + ADD_GENERIC_PATTERN(IREE::VM::SelectF32Op, "vm_select_f32"); + ADD_GENERIC_PATTERN(IREE::VM::SelectI32Op, "vm_select_i32"); + ADD_GENERIC_PATTERN(IREE::VM::SelectI64Op, "vm_select_i64"); + ADD_GENERIC_PATTERN(IREE::VM::ShlI32Op, "vm_shl_i32"); + ADD_GENERIC_PATTERN(IREE::VM::ShlI64Op, "vm_shl_i64"); + ADD_GENERIC_PATTERN(IREE::VM::ShrI32SOp, "vm_shr_i32s"); + ADD_GENERIC_PATTERN(IREE::VM::ShrI32UOp, "vm_shr_i32u"); + ADD_GENERIC_PATTERN(IREE::VM::ShrI64SOp, "vm_shr_i64s"); + ADD_GENERIC_PATTERN(IREE::VM::ShrI64UOp, "vm_shr_i64u"); + ADD_GENERIC_PATTERN(IREE::VM::SinF32Op, "vm_sin_f32"); + ADD_GENERIC_PATTERN(IREE::VM::SqrtF32Op, "vm_sqrt_f32"); + ADD_GENERIC_PATTERN(IREE::VM::SubF32Op, "vm_sub_f32"); + ADD_GENERIC_PATTERN(IREE::VM::SubI32Op, "vm_sub_i32"); + ADD_GENERIC_PATTERN(IREE::VM::SubI64Op, "vm_sub_i64"); + ADD_GENERIC_PATTERN(IREE::VM::TanhF32Op, "vm_tanh_f32"); + ADD_GENERIC_PATTERN(IREE::VM::TruncI32I8Op, "vm_trunc_i32i8"); + ADD_GENERIC_PATTERN(IREE::VM::TruncI32I16Op, "vm_trunc_i32i16"); + ADD_GENERIC_PATTERN(IREE::VM::TruncI64I32Op, "vm_trunc_i64i32"); + ADD_GENERIC_PATTERN(IREE::VM::XorI32Op, "vm_xor_i32"); + ADD_GENERIC_PATTERN(IREE::VM::XorI64Op, "vm_xor_i64"); + + // containers wrapped in ref types + ADD_CONTAINER_PATTERN(IREE::VM::BufferCompareOp, "vm_buffer_compare", + DenseSet({0, 2}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferCopyOp, "iree_vm_buffer_copy_bytes", + DenseSet({0, 2}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferFillF32Op, "vm_buffer_fill_f32", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferFillF64Op, "vm_buffer_fill_f64", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferFillI8Op, "vm_buffer_fill_i8", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferFillI16Op, "vm_buffer_fill_i16", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferFillI32Op, "vm_buffer_fill_i32", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferFillI64Op, "vm_buffer_fill_i64", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferLengthOp, "iree_vm_buffer_length", + DenseSet({0}), false); + ADD_CONTAINER_PATTERN(IREE::VM::BufferLoadF32Op, "vm_buffer_load_f32", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferLoadF64Op, "vm_buffer_load_f64", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferLoadI8SOp, "vm_buffer_load_i8s", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferLoadI8UOp, "vm_buffer_load_i8u", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferLoadI16SOp, "vm_buffer_load_i16s", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferLoadI16UOp, "vm_buffer_load_i16u", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferLoadI32Op, "vm_buffer_load_i32", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferLoadI64Op, "vm_buffer_load_i64", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferStoreF32Op, "vm_buffer_store_f32", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferStoreF64Op, "vm_buffer_store_f64", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferStoreI8Op, "vm_buffer_store_i8", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferStoreI16Op, "vm_buffer_store_i16", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferStoreI32Op, "vm_buffer_store_i32", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::BufferStoreI64Op, "vm_buffer_store_i64", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::ListReserveOp, "iree_vm_list_reserve", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::ListResizeOp, "iree_vm_list_resize", + DenseSet({0}), true); + ADD_CONTAINER_PATTERN(IREE::VM::ListSizeOp, "iree_vm_list_size", + DenseSet({0}), false); + // global patterns + ADD_GLOBAL_LOAD_PATTERN(IREE::VM::GlobalLoadF32Op, IREE::VM::GlobalF32Op, + "vm_global_load_f32"); + ADD_GLOBAL_LOAD_PATTERN(IREE::VM::GlobalLoadI32Op, IREE::VM::GlobalI32Op, + "vm_global_load_i32"); + ADD_GLOBAL_LOAD_PATTERN(IREE::VM::GlobalLoadI64Op, IREE::VM::GlobalI64Op, + "vm_global_load_i64"); + ADD_GLOBAL_STORE_PATTERN(IREE::VM::GlobalStoreF32Op, IREE::VM::GlobalF32Op, + "vm_global_store_f32"); + ADD_GLOBAL_STORE_PATTERN(IREE::VM::GlobalStoreI32Op, IREE::VM::GlobalI32Op, + "vm_global_store_i32"); + ADD_GLOBAL_STORE_PATTERN(IREE::VM::GlobalStoreI64Op, IREE::VM::GlobalI64Op, + "vm_global_store_i64"); + +#undef ADD_GENERIC_PATTERN +#undef ADD_CONTAINER_PATTERN +#undef ADD_GLOBAL_LOAD_PATTERN +#undef ADD_GLOBAL_STORE_PATTERN } namespace IREE {