MLIR 22.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
19namespace llvm {
20class DataLayout;
21class LLVMContext;
22class Type;
23} // namespace llvm
24
25namespace mlir {
26
27class Type;
28class MLIRContext;
29
30namespace LLVM {
31
32namespace detail {
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.
40public:
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
53private:
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
unsigned getPreferredAlignment(Type type, const llvm::DataLayout &layout)
Returns the preferred alignment for the type given the data layout.
llvm::Type * translateType(Type type)
Translates the given MLIR LLVM dialect type to LLVM IR.
TypeToLLVMIRTranslator(llvm::LLVMContext &context)
Support for translating MLIR LLVM dialect types to LLVM IR.
MLIRContext is the top-level object for a collection of MLIR operations.
Definition MLIRContext.h:63
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition Types.h:74
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Definition CallGraph.h:229
Include the generated interface declarations.