12#include "llvm/IR/LLVMContext.h"
13#include "llvm/IR/Module.h"
14#include "llvm/IR/Type.h"
24 LLVMContextRef context) {
27 llvm::LLVMContext *ctx = llvm::unwrap(context);
29 std::unique_ptr<llvm::Module> llvmModule =
32 LLVMModuleRef moduleRef = llvm::wrap(llvmModule.release());
38 LLVMContextRef llvmCtx = LLVMContextCreate();
40 char *llvmir = LLVMPrintModuleToString(llvmModule);
41 LLVMDisposeModule(llvmModule);
42 LLVMContextDispose(llvmCtx);
53 return wrap(translator);
73 llvm::LLVMContext *context = llvm::unwrap(ctx);
75 return wrap(translator);
87 return llvm::wrap(type);
MlirType mlirTypeFromLLVMIRTranslatorTranslateType(MlirTypeFromLLVMIRTranslator translator, LLVMTypeRef llvmType)
Translates the given LLVM IR type to the MLIR LLVM dialect.
char * mlirTranslateModuleToLLVMIRToString(MlirOperation module)
void mlirTypeToLLVMIRTranslatorDestroy(MlirTypeToLLVMIRTranslator translator)
Takes an LLVM::TypeToLLVMIRTranslator owned by the caller and destroys it.
LLVMTypeRef mlirTypeToLLVMIRTranslatorTranslateType(MlirTypeToLLVMIRTranslator translator, MlirType mlirType)
Translates the given MLIR LLVM dialect to the LLVM IR type.
void mlirTypeFromLLVMIRTranslatorDestroy(MlirTypeFromLLVMIRTranslator translator)
Takes an LLVM::TypeFromLLVMIRTranslator owned by the caller and destroys it.
LLVMModuleRef mlirTranslateModuleToLLVMIR(MlirOperation module, LLVMContextRef context)
Translate operation that satisfies LLVM dialect module requirements into an LLVM IR module living in ...
MLIR_CAPI_EXPORTED MlirTypeFromLLVMIRTranslator mlirTypeFromLLVMIRTranslatorCreate(MlirContext ctx)
Create an LLVM::TypeFromLLVMIRTranslator and transfer ownership to the caller.
MLIR_CAPI_EXPORTED MlirTypeToLLVMIRTranslator mlirTypeToLLVMIRTranslatorCreate(LLVMContextRef ctx)
Create an LLVM::TypeToLLVMIRTranslator and transfer ownership to the caller.
#define DEFINE_C_API_PTR_METHODS(name, cpptype)
Utility class to translate LLVM IR types to the MLIR LLVM dialect.
Type translateType(llvm::Type *type)
Translates the given LLVM IR type to the MLIR LLVM dialect.
Utility class to translate MLIR LLVM dialect types to LLVM IR.
llvm::Type * translateType(Type type)
Translates the given MLIR LLVM dialect type to LLVM IR.
MLIRContext is the top-level object for a collection of MLIR operations.
Operation is the basic unit of execution within MLIR.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
Include the generated interface declarations.
std::unique_ptr< llvm::Module > translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext, llvm::StringRef name="LLVMDialectModule", bool disableVerification=false)
Translates a given LLVM dialect module into an LLVM IR module living in the given context.