[Mlir-commits] [mlir] [mlir] Add mlirTranslateModuleToLLVMIR to MLIR-C (PR #73117)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Wed Nov 22 06:17:56 PST 2023


================
@@ -0,0 +1,34 @@
+//===- LLVMIR.cpp - C Interface for MLIR LLVMIR Target -------------------===//
+//
+// 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-c/Target/LLVMIR.h"
+#include "llvm-c/Support.h"
+
+#include "llvm/IR/LLVMContext.h"
+#include <memory>
+
+#include "mlir/CAPI/IR.h"
+#include "mlir/CAPI/Support.h"
+#include "mlir/CAPI/Wrap.h"
+#include "mlir/Target/LLVMIR/ModuleTranslation.h"
+
+using namespace mlir;
+
+LLVMModuleRef mlirTranslateModuleToLLVMIR(MlirOperation module,
+                                          LLVMContextRef context) {
+  Operation *moduleOp = unwrap(module);
+
+  llvm::LLVMContext *ctx = reinterpret_cast<llvm::LLVMContext *>(context);
+
+  auto llvmModule = mlir::translateModuleToLLVMIR(moduleOp, *ctx);
----------------
ftynse wrote:

Please expand `auto`. LLVM uses `auto` when type is obvious from statement-level context (e.g. the RHS of an assignment is a cast expression) or the type is difficult to spell (iterators, lambdas).

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


More information about the Mlir-commits mailing list