12 #include "llvm/IR/LLVMContext.h"
13 #include "llvm/IR/Module.h"
14 #include "llvm/IR/Type.h"
24 LLVMContextRef context) {
29 std::unique_ptr<llvm::Module> llvmModule =
32 LLVMModuleRef moduleRef =
llvm::wrap(llvmModule.release());
43 auto *translator =
new LLVM::TypeFromLLVMIRTranslator(*context);
44 return wrap(translator);
49 delete static_cast<LLVM::TypeFromLLVMIRTranslator *
>(
unwrap(translator));
54 LLVM::TypeFromLLVMIRTranslator *translator_ =
unwrap(translator);
65 auto *translator =
new LLVM::TypeToLLVMIRTranslator(*context);
66 return wrap(translator);
70 delete static_cast<LLVM::TypeToLLVMIRTranslator *
>(
unwrap(translator));
76 LLVM::TypeToLLVMIRTranslator *translator_ =
unwrap(translator);
77 llvm::Type *type = translator_->translateType(
unwrap(mlirType));
MlirType mlirTypeFromLLVMIRTranslatorTranslateType(MlirTypeFromLLVMIRTranslator translator, LLVMTypeRef llvmType)
Translates the given LLVM IR type to the MLIR LLVM dialect.
DEFINE_C_API_PTR_METHODS(MlirTypeFromLLVMIRTranslator, mlir::LLVM::TypeFromLLVMIRTranslator) MlirTypeFromLLVMIRTranslator mlirTypeFromLLVMIRTranslatorCreate(MlirContext ctx)
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.
Utility class to translate LLVM IR types to the MLIR LLVM dialect.
Utility class to translate MLIR LLVM dialect types 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...
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
MlirDiagnostic wrap(mlir::Diagnostic &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.