MLIR  19.0.0git
TypeToLLVM.h
Go to the documentation of this file.
1 //===- TypeToLLVM.h - Translate types from MLIR to LLVM --*- 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_TYPETOLLVM_H
15 #define MLIR_TARGET_LLVMIR_TYPETOLLVM_H
16 
17 #include <memory>
18 
19 namespace llvm {
20 class DataLayout;
21 class LLVMContext;
22 class Type;
23 } // namespace llvm
24 
25 namespace mlir {
26 
27 class Type;
28 class MLIRContext;
29 
30 namespace LLVM {
31 
32 namespace detail {
33 class TypeToLLVMIRTranslatorImpl;
34 } // namespace detail
35 
36 /// Utility class to translate MLIR LLVM dialect types to LLVM IR. Stores the
37 /// translation state, in particular any identified structure types that can be
38 /// reused in further translation.
40 public:
41  TypeToLLVMIRTranslator(llvm::LLVMContext &context);
43 
44  /// Returns the preferred alignment for the type given the data layout. Note
45  /// that this will perform type conversion and store its results for future
46  /// uses.
47  // TODO: this should be removed when MLIR has proper data layout.
48  unsigned getPreferredAlignment(Type type, const llvm::DataLayout &layout);
49 
50  /// Translates the given MLIR LLVM dialect type to LLVM IR.
51  llvm::Type *translateType(Type type);
52 
53 private:
54  /// Private implementation.
55  std::unique_ptr<detail::TypeToLLVMIRTranslatorImpl> impl;
56 };
57 
58 } // namespace LLVM
59 } // namespace mlir
60 
61 #endif // MLIR_TARGET_LLVMIR_TYPETOLLVM_H
Utility class to translate MLIR LLVM dialect types to LLVM IR.
Definition: TypeToLLVM.h:39
unsigned getPreferredAlignment(Type type, const llvm::DataLayout &layout)
Returns the preferred alignment for the type given the data layout.
Definition: TypeToLLVM.cpp:196
llvm::Type * translateType(Type type)
Translates the given MLIR LLVM dialect type to LLVM IR.
Definition: TypeToLLVM.cpp:192
TypeToLLVMIRTranslator(llvm::LLVMContext &context)
Definition: TypeToLLVM.cpp:187
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition: Types.h:74
Include the generated interface declarations.
Definition: CallGraph.h:229
@ Type
An inlay hint that for a type annotation.
Include the generated interface declarations.