1//===- TypeFromLLVM.h - Translate types from LLVM to MLIR --*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file declares the type translation function going from MLIR LLVM dialect
10// to LLVM IR and back.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef MLIR_TARGET_LLVMIR_TYPEFROMLLVM_H
15#define MLIR_TARGET_LLVMIR_TYPEFROMLLVM_H
16
17#include <memory>
18
19namespace llvm {
20class Type;
21} // namespace llvm
22
23namespace mlir {
24
25class Type;
26class MLIRContext;
27
28namespace LLVM {
29
30namespace detail {
31class TypeFromLLVMIRTranslatorImpl;
32} // namespace detail
33
34/// Utility class to translate LLVM IR types to the MLIR LLVM dialect. Stores
35/// the translation state, in particular any identified structure types that are
36/// reused across translations.
37class TypeFromLLVMIRTranslator {
38public:
39 TypeFromLLVMIRTranslator(MLIRContext &context,
40 bool importStructsAsLiterals = false);
41 ~TypeFromLLVMIRTranslator();
42
43 /// Translates the given LLVM IR type to the MLIR LLVM dialect.
44 Type translateType(llvm::Type *type);
45
46private:
47 /// Private implementation.
48 std::unique_ptr<detail::TypeFromLLVMIRTranslatorImpl> impl;
49};
50
51} // namespace LLVM
52} // namespace mlir
53
54#endif // MLIR_TARGET_LLVMIR_TYPEFROMLLVM_H
55