MLIR
20.0.0git
lib
Target
LLVMIR
Dialect
Builtin
BuiltinToLLVMIRTranslation.cpp
Go to the documentation of this file.
1
//===- BuiltinToLLVMIRTranslation.cpp - Translate builtin to LLVM IR ------===//
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 implements a translation between the MLIR builtin dialect and LLVM
10
// IR.
11
//
12
//===----------------------------------------------------------------------===//
13
#include "
mlir/Target/LLVMIR/Dialect/Builtin/BuiltinToLLVMIRTranslation.h
"
14
#include "
mlir/IR/BuiltinDialect.h
"
15
#include "
mlir/IR/BuiltinOps.h
"
16
#include "
mlir/Target/LLVMIR/LLVMTranslationInterface.h
"
17
18
using namespace
mlir
;
19
20
namespace
{
21
22
class
BuiltinDialectLLVMIRTranslationInterface
23
:
public
LLVMTranslationDialectInterface
{
24
public
:
25
using
LLVMTranslationDialectInterface::LLVMTranslationDialectInterface
;
26
27
LogicalResult
28
convertOperation(
Operation
*op, llvm::IRBuilderBase &builder,
29
LLVM::ModuleTranslation
&moduleTranslation)
const override
{
30
return
success(isa<ModuleOp>(op));
31
}
32
};
33
34
}
// namespace
35
36
void
mlir::registerBuiltinDialectTranslation
(
DialectRegistry
®istry) {
37
registry.
addExtension
(+[](
MLIRContext
*ctx, BuiltinDialect *dialect) {
38
dialect->addInterfaces<BuiltinDialectLLVMIRTranslationInterface>();
39
});
40
}
41
42
void
mlir::registerBuiltinDialectTranslation
(
MLIRContext
&context) {
43
DialectRegistry
registry;
44
registerBuiltinDialectTranslation
(registry);
45
context.
appendDialectRegistry
(registry);
46
}
BuiltinDialect.h
BuiltinOps.h
BuiltinToLLVMIRTranslation.h
LLVMTranslationInterface.h
mlir::DialectRegistry
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
Definition:
DialectRegistry.h:139
mlir::DialectRegistry::addExtension
bool addExtension(TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
Definition:
DialectRegistry.h:211
mlir::LLVMTranslationDialectInterface
Base class for dialect interfaces providing translation to LLVM IR.
Definition:
LLVMTranslationInterface.h:38
mlir::LLVMTranslationDialectInterface::LLVMTranslationDialectInterface
LLVMTranslationDialectInterface(Dialect *dialect)
Definition:
LLVMTranslationInterface.h:40
mlir::LLVM::ModuleTranslation
Implementation class for module translation.
Definition:
ModuleTranslation.h:58
mlir::MLIRContext
MLIRContext is the top-level object for a collection of MLIR operations.
Definition:
MLIRContext.h:60
mlir::MLIRContext::appendDialectRegistry
void appendDialectRegistry(const DialectRegistry ®istry)
Append the contents of the given dialect registry to the registry associated with this context.
Definition:
MLIRContext.cpp:419
mlir::Operation
Operation is the basic unit of execution within MLIR.
Definition:
Operation.h:88
mlir
Include the generated interface declarations.
Definition:
LocalAliasAnalysis.h:20
mlir::registerBuiltinDialectTranslation
void registerBuiltinDialectTranslation(DialectRegistry ®istry)
Register the translation from the builtin dialect to the LLVM IR in the given registry.
Definition:
BuiltinToLLVMIRTranslation.cpp:36
Generated on Sat Dec 21 2024 16:31:47 for MLIR by
1.9.1