MLIR
23.0.0git
lib
Target
LLVMIR
Dialect
XeVM
XeVMToLLVMIRTranslation.cpp
Go to the documentation of this file.
1
//===-- XeVMToLLVMIRTranslation.cpp - Translate XeVM to LLVM IR -*- C++ -*-===//
2
//
3
// This file is licensed 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 XeVM dialect and
10
// LLVM IR.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#include "
mlir/Target/LLVMIR/Dialect/XeVM/XeVMToLLVMIRTranslation.h
"
15
#include "
mlir/Dialect/LLVMIR/XeVMDialect.h
"
16
#include "
mlir/IR/BuiltinAttributes.h
"
17
#include "
mlir/IR/Operation.h
"
18
#include "
mlir/Target/LLVMIR/ModuleTranslation.h
"
19
20
#include "llvm/ADT/TypeSwitch.h"
21
#include "llvm/IR/Constants.h"
22
#include "llvm/IR/LLVMContext.h"
23
#include "llvm/IR/Metadata.h"
24
25
#include "llvm/IR/ConstantRange.h"
26
#include "llvm/IR/IRBuilder.h"
27
#include "llvm/Support/raw_ostream.h"
28
29
using namespace
mlir
;
30
using namespace
mlir::LLVM
;
31
32
namespace
{
33
/// Implementation of the dialect interface that converts operations belonging
34
/// to the XeVM dialect to LLVM IR.
35
class
XeVMDialectLLVMIRTranslationInterface
36
:
public
LLVMTranslationDialectInterface {
37
public
:
38
using
LLVMTranslationDialectInterface::LLVMTranslationDialectInterface;
39
40
/// Empty amendOperation implementation, can be extended in the future.
41
LogicalResult
42
amendOperation(Operation *op, ArrayRef<llvm::Instruction *> instructions,
43
NamedAttribute attribute,
44
LLVM::ModuleTranslation &moduleTranslation)
const
final
{
45
return
success
();
46
}
47
48
private
:
49
};
50
}
// namespace
51
52
void
mlir::registerXeVMDialectTranslation
(
::mlir::DialectRegistry
®istry) {
53
registry.
insert
<xevm::XeVMDialect>();
54
registry.
addExtension
(+[](
MLIRContext
*ctx, xevm::XeVMDialect *dialect) {
55
dialect->addInterfaces<XeVMDialectLLVMIRTranslationInterface>();
56
});
57
}
58
59
void
mlir::registerXeVMDialectTranslation
(
::mlir::MLIRContext
&context) {
60
DialectRegistry
registry;
61
registerXeVMDialectTranslation
(registry);
62
context.
appendDialectRegistry
(registry);
63
}
success
return success()
Operation.h
ModuleTranslation.h
XeVMDialect.h
XeVMToLLVMIRTranslation.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:215
mlir::DialectRegistry::insert
void insert()
Definition
DialectRegistry.h:152
mlir::MLIRContext
MLIRContext is the top-level object for a collection of MLIR operations.
Definition
MLIRContext.h:63
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:416
BuiltinAttributes.h
mlir::LLVM
Definition
ConvertFuncToLLVM.h:21
mlir
Include the generated interface declarations.
Definition
AliasAnalysis.h:19
mlir::registerXeVMDialectTranslation
void registerXeVMDialectTranslation(mlir::DialectRegistry ®istry)
Register the XeVM dialect and the translation from it to the LLVM IR in the given registry;.
Generated on
for MLIR by
1.14.0