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

Marius Brehler llvmlistbot at llvm.org
Wed Apr 30 09:37:40 PDT 2025


================
@@ -0,0 +1,223 @@
+//===- ConvertToEmitCPass.cpp - Conversion to EmitC pass --------*- C++ -*-===//
+//
+// 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/ConvertToEmitC/ToEmitCInterface.h"
+#include "mlir/Conversion/LLVMCommon/ConversionTarget.h"
+#include "mlir/Conversion/LLVMCommon/TypeConverter.h"
+#include "mlir/Dialect/EmitC/IR/EmitC.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Transforms/DialectConversion.h"
+#include "llvm/Support/Debug.h"
+
+#include <memory>
+
+#define DEBUG_TYPE "convert-to-emitc"
+
+namespace mlir {
+#define GEN_PASS_DEF_CONVERTTOEMITC
+#include "mlir/Conversion/Passes.h.inc"
+} // namespace mlir
+
+using namespace mlir;
+
+namespace {
+/// Base class for creating the internal implementation of `convert-to-emitc`
+/// passes.
+class ConvertToEmitCPassInterface {
+public:
+  ConvertToEmitCPassInterface(MLIRContext *context,
+                              ArrayRef<std::string> filterDialects);
+  virtual ~ConvertToEmitCPassInterface() = default;
+
+  /// Get the dependent dialects used by `convert-to-emitc`.
+  static void getDependentDialects(DialectRegistry &registry);
+
+  /// Initialize the internal state of the `convert-to-emitc` pass
+  /// implementation. This method is invoked by `ConvertToEmitC::initialize`.
+  /// This method returns whether the initialization process failed.
+  virtual LogicalResult initialize() = 0;
+
+  /// Transform `op` to the EMitC dialect with the conversions available in the
----------------
marbre wrote:

NIT
```suggestion
  /// Transform `op` to the EmitC dialect with the conversions available in the
```

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


More information about the Mlir-commits mailing list