MLIR 22.0.0git
LLVMIR.h
Go to the documentation of this file.
1//===-- LLVMIR.h - C Interface for MLIR LLVMIR Target -------------*- C -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM
4// Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9//
10// This header declares the C interface to target LLVMIR with MLIR.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef MLIR_C_TARGET_LLVMIR_H
15#define MLIR_C_TARGET_LLVMIR_H
16
17#include "mlir-c/IR.h"
18#include "mlir-c/Support.h"
19#include "llvm-c/Core.h"
20#include "llvm-c/Support.h"
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26/// Translate operation that satisfies LLVM dialect module requirements into an
27/// LLVM IR module living in the given context. This translates operations from
28/// any dilalect that has a registered implementation of
29/// LLVMTranslationDialectInterface.
30///
31/// \returns the generated LLVM IR Module from the translated MLIR module, it is
32/// owned by the caller.
33MLIR_CAPI_EXPORTED LLVMModuleRef
34mlirTranslateModuleToLLVMIR(MlirOperation module, LLVMContextRef context);
35
37mlirTranslateModuleToLLVMIRToString(MlirOperation module);
38
42
44
45/// Create an LLVM::TypeFromLLVMIRTranslator and transfer ownership to the
46/// caller.
49
50/// Takes an LLVM::TypeFromLLVMIRTranslator owned by the caller and destroys it.
51/// It is the responsibility of the user to only pass an
52/// LLVM::TypeFromLLVMIRTranslator class.
55
56/// Translates the given LLVM IR type to the MLIR LLVM dialect.
58 MlirTypeFromLLVMIRTranslator translator, LLVMTypeRef llvmType);
59
63
65
66/// Create an LLVM::TypeToLLVMIRTranslator and transfer ownership to the
67/// caller.
70
71/// Takes an LLVM::TypeToLLVMIRTranslator owned by the caller and destroys it.
72/// It is the responsibility of the user to only pass an
73/// LLVM::TypeToLLVMIRTranslator class.
76
77/// Translates the given MLIR LLVM dialect to the LLVM IR type.
79 MlirTypeToLLVMIRTranslator translator, MlirType mlirType);
80
81#ifdef __cplusplus
82}
83#endif
84
85#endif // MLIR_C_TARGET_LLVMIR_H
MLIR_CAPI_EXPORTED MlirTypeFromLLVMIRTranslator mlirTypeFromLLVMIRTranslatorCreate(MlirContext ctx)
Create an LLVM::TypeFromLLVMIRTranslator and transfer ownership to the caller.
MLIR_CAPI_EXPORTED MlirType mlirTypeFromLLVMIRTranslatorTranslateType(MlirTypeFromLLVMIRTranslator translator, LLVMTypeRef llvmType)
Translates the given LLVM IR type to the MLIR LLVM dialect.
Definition LLVMIR.cpp:61
MLIR_CAPI_EXPORTED MlirTypeToLLVMIRTranslator mlirTypeToLLVMIRTranslatorCreate(LLVMContextRef ctx)
Create an LLVM::TypeToLLVMIRTranslator and transfer ownership to the caller.
MLIR_CAPI_EXPORTED LLVMTypeRef mlirTypeToLLVMIRTranslatorTranslateType(MlirTypeToLLVMIRTranslator translator, MlirType mlirType)
Translates the given MLIR LLVM dialect to the LLVM IR type.
Definition LLVMIR.cpp:83
MLIR_CAPI_EXPORTED void mlirTypeFromLLVMIRTranslatorDestroy(MlirTypeFromLLVMIRTranslator translator)
Takes an LLVM::TypeFromLLVMIRTranslator owned by the caller and destroys it.
Definition LLVMIR.cpp:56
MLIR_CAPI_EXPORTED char * mlirTranslateModuleToLLVMIRToString(MlirOperation module)
Definition LLVMIR.cpp:37
MLIR_CAPI_EXPORTED LLVMModuleRef mlirTranslateModuleToLLVMIR(MlirOperation module, LLVMContextRef context)
Translate operation that satisfies LLVM dialect module requirements into an LLVM IR module living in ...
Definition LLVMIR.cpp:23
MLIR_CAPI_EXPORTED void mlirTypeToLLVMIRTranslatorDestroy(MlirTypeToLLVMIRTranslator translator)
Takes an LLVM::TypeToLLVMIRTranslator owned by the caller and destroys it.
Definition LLVMIR.cpp:78
#define MLIR_CAPI_EXPORTED
Definition Support.h:46