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(isSuccess: isa<ModuleOp>(Val: op)); |
31 | } |
32 | }; |
33 | |
34 | } // namespace |
35 | |
36 | void mlir::registerBuiltinDialectTranslation(DialectRegistry ®istry) { |
37 | registry.addExtension(extensionFn: +[](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 | } |
47 |