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

Tina Jung llvmlistbot at llvm.org
Thu Mar 7 02:26:01 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) {
----------------
TinaAMD wrote:

Yes, I agreed the check should be used more widely. I propose we do the following:
1) We restrict the types in the EmitC dialect (tablegen) by a function like this, which aligns with what the emitter currently supports. Later on, we could consider to restrict the types further if it makes sense. I can create a separate PR for this.
2) We drop the check in the conversion for now, and after 1) lands, we enable it again in the conversion such that the conversion rejects invalid types rather than generating invalid EmitC.
What do you think?

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


More information about the Mlir-commits mailing list