[Mlir-commits] [mlir] [mlir][EmitC] Add pass that combines all available emitc conversions (PR #117549)

Matthias Gehre llvmlistbot at llvm.org
Mon Nov 25 05:03:11 PST 2024


================
@@ -0,0 +1,77 @@
+//===- ConvertToEmitCPass.cpp - MLIR EmitC Conversion ---------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Conversion/ConvertToEmitC/ConvertToEmitCPass.h"
+#include "mlir/Conversion/ArithToEmitC/ArithToEmitC.h"
+#include "mlir/Conversion/FuncToEmitC/FuncToEmitC.h"
+#include "mlir/Conversion/MemRefToEmitC/MemRefToEmitC.h"
+#include "mlir/Conversion/SCFToEmitC/SCFToEmitC.h"
+#include "mlir/Dialect/Arith/IR/Arith.h"
+#include "mlir/Dialect/EmitC/IR/EmitC.h"
+#include "mlir/Dialect/Func/IR/FuncOps.h"
+#include "mlir/Dialect/MemRef/IR/MemRef.h"
+#include "mlir/Dialect/SCF/IR/SCF.h"
+#include "mlir/IR/PatternMatch.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Rewrite/FrozenRewritePatternSet.h"
+#include "mlir/Transforms/DialectConversion.h"
+#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+
+#define DEBUG_TYPE "convert-to-emitc"
+
+namespace mlir {
+#define GEN_PASS_DEF_CONVERTTOEMITCPASS
+#include "mlir/Conversion/Passes.h.inc"
+} // namespace mlir
+
+using namespace mlir;
+
+namespace {
+
+/// Populate patterns for each dialect.
+void populateConvertToEmitCPatterns(TypeConverter &typeConverter,
+                                    RewritePatternSet &patterns) {
+  populateArithToEmitCPatterns(typeConverter, patterns);
+  populateFuncToEmitCPatterns(patterns);
+  populateMemRefToEmitCTypeConversion(typeConverter);
----------------
mgehre-amd wrote:

nit: I would split this line together with `typeConverter.addConversion([](Type type) { return type; });` into a `populateConverToEmitCTypeConverter` function or similar for clarity.

https://github.com/llvm/llvm-project/pull/117549


More information about the Mlir-commits mailing list