[Mlir-commits] [mlir] [mlir][emitc] Arith to EmitC conversion pass (PR #83798)

Marius Brehler llvmlistbot at llvm.org
Wed Mar 6 03:38:54 PST 2024


================
@@ -0,0 +1,104 @@
+//===- ArithToEmitC.cpp - Arith to 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements a pass to convert arith ops into emitc ops.
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Conversion/ArithToEmitC/ArithToEmitC.h"
+
+#include "mlir/Dialect/Arith/IR/Arith.h"
+#include "mlir/Dialect/EmitC/IR/EmitC.h"
+#include "mlir/IR/BuiltinTypes.h"
+#include "mlir/Support/LogicalResult.h"
+#include "mlir/Transforms/DialectConversion.h"
+
+namespace mlir {
+#define GEN_PASS_DEF_ARITHTOEMITCCONVERSIONPASS
+#include "mlir/Conversion/Passes.h.inc"
+} // namespace mlir
+
+using namespace mlir;
+
+namespace {
+
+static bool isConvertibleToEmitC(Type type) {
----------------
marbre wrote:

This is a rather broad check which could also be reused in other conversions. Furthermore, it mainly models a restriction which is introduced by the emitter but not the dialect itself, where both can change. Thus I think this check at least needs to be move to a more accessible location to be reused by other conversions and ideally verifiers or even the emitter. And validation pass could be another alternative, at least until the EmitC dialect and the emitter match more closely.

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


More information about the Mlir-commits mailing list