brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · ec5ae88 Raw
86 lines · c
1//===-- LLVMIR.h - C Interface for MLIR LLVMIR Target -------------*- C -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM4// Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9//10// This header declares the C interface to target LLVMIR with MLIR.11//12//===----------------------------------------------------------------------===//13 14#ifndef MLIR_C_TARGET_LLVMIR_H15#define MLIR_C_TARGET_LLVMIR_H16 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 __cplusplus23extern "C" {24#endif25 26/// Translate operation that satisfies LLVM dialect module requirements into an27/// LLVM IR module living in the given context. This translates operations from28/// any dilalect that has a registered implementation of29/// LLVMTranslationDialectInterface.30///31/// \returns the generated LLVM IR Module from the translated MLIR module, it is32/// owned by the caller.33MLIR_CAPI_EXPORTED LLVMModuleRef34mlirTranslateModuleToLLVMIR(MlirOperation module, LLVMContextRef context);35 36MLIR_CAPI_EXPORTED char *37mlirTranslateModuleToLLVMIRToString(MlirOperation module);38 39struct MlirTypeFromLLVMIRTranslator {40  void *ptr;41};42 43typedef struct MlirTypeFromLLVMIRTranslator MlirTypeFromLLVMIRTranslator;44 45/// Create an LLVM::TypeFromLLVMIRTranslator and transfer ownership to the46/// caller.47MLIR_CAPI_EXPORTED MlirTypeFromLLVMIRTranslator48mlirTypeFromLLVMIRTranslatorCreate(MlirContext ctx);49 50/// Takes an LLVM::TypeFromLLVMIRTranslator owned by the caller and destroys it.51/// It is the responsibility of the user to only pass an52/// LLVM::TypeFromLLVMIRTranslator class.53MLIR_CAPI_EXPORTED void54mlirTypeFromLLVMIRTranslatorDestroy(MlirTypeFromLLVMIRTranslator translator);55 56/// Translates the given LLVM IR type to the MLIR LLVM dialect.57MLIR_CAPI_EXPORTED MlirType mlirTypeFromLLVMIRTranslatorTranslateType(58    MlirTypeFromLLVMIRTranslator translator, LLVMTypeRef llvmType);59 60struct MlirTypeToLLVMIRTranslator {61  void *ptr;62};63 64typedef struct MlirTypeToLLVMIRTranslator MlirTypeToLLVMIRTranslator;65 66/// Create an LLVM::TypeToLLVMIRTranslator and transfer ownership to the67/// caller.68MLIR_CAPI_EXPORTED MlirTypeToLLVMIRTranslator69mlirTypeToLLVMIRTranslatorCreate(LLVMContextRef ctx);70 71/// Takes an LLVM::TypeToLLVMIRTranslator owned by the caller and destroys it.72/// It is the responsibility of the user to only pass an73/// LLVM::TypeToLLVMIRTranslator class.74MLIR_CAPI_EXPORTED void75mlirTypeToLLVMIRTranslatorDestroy(MlirTypeToLLVMIRTranslator translator);76 77/// Translates the given MLIR LLVM dialect to the LLVM IR type.78MLIR_CAPI_EXPORTED LLVMTypeRef mlirTypeToLLVMIRTranslatorTranslateType(79    MlirTypeToLLVMIRTranslator translator, MlirType mlirType);80 81#ifdef __cplusplus82}83#endif84 85#endif // MLIR_C_TARGET_LLVMIR_H86