MLIR 22.0.0git
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//===----------------------------------------------------------------------===//
15#include "mlir/IR/BuiltinOps.h"
17
18using namespace mlir;
19
20namespace {
21
22class BuiltinDialectLLVMIRTranslationInterface
24public:
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
37 registry.addExtension(+[](MLIRContext *ctx, BuiltinDialect *dialect) {
38 dialect->addInterfaces<BuiltinDialectLLVMIRTranslationInterface>();
39 });
40}
41
return success()
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
bool addExtension(TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
Base class for dialect interfaces providing translation to LLVM IR.
MLIRContext is the top-level object for a collection of MLIR operations.
Definition MLIRContext.h:63
void appendDialectRegistry(const DialectRegistry &registry)
Append the contents of the given dialect registry to the registry associated with this context.
Include the generated interface declarations.
void registerBuiltinDialectTranslation(DialectRegistry &registry)
Register the translation from the builtin dialect to the LLVM IR in the given registry.