MLIR  21.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
23 extern "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.
33 MLIR_CAPI_EXPORTED LLVMModuleRef
34 mlirTranslateModuleToLLVMIR(MlirOperation module, LLVMContextRef context);
35 
37  void *ptr;
38 };
39 
41 
42 /// Create an LLVM::TypeFromLLVMIRTranslator and transfer ownership to the
43 /// caller.
46 
47 /// Takes an LLVM::TypeFromLLVMIRTranslator owned by the caller and destroys it.
48 /// It is the responsibility of the user to only pass an
49 /// LLVM::TypeFromLLVMIRTranslator class.
52 
53 /// Translates the given LLVM IR type to the MLIR LLVM dialect.
55  MlirTypeFromLLVMIRTranslator translator, LLVMTypeRef llvmType);
56 
58  void *ptr;
59 };
60 
62 
63 /// Create an LLVM::TypeToLLVMIRTranslator and transfer ownership to the
64 /// caller.
67 
68 /// Takes an LLVM::TypeToLLVMIRTranslator owned by the caller and destroys it.
69 /// It is the responsibility of the user to only pass an
70 /// LLVM::TypeToLLVMIRTranslator class.
73 
74 /// Translates the given MLIR LLVM dialect to the LLVM IR type.
76  MlirTypeToLLVMIRTranslator translator, MlirType mlirType);
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #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:52
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:74
MLIR_CAPI_EXPORTED void mlirTypeFromLLVMIRTranslatorDestroy(MlirTypeFromLLVMIRTranslator translator)
Takes an LLVM::TypeFromLLVMIRTranslator owned by the caller and destroys it.
Definition: LLVMIR.cpp:47
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:69
#define MLIR_CAPI_EXPORTED
Definition: Support.h:46