MLIR-AIE 1.4.5.dev
XLLVMToLLVMIRTranslation.cpp
Go to the documentation of this file.
1//===- XLLVMToLLVMIRTranslation.cpp - Translate AIEVec to LLVM IR ---------===//
2//
3// Copyright (C) 2024 Advanced Micro Devices, Inc.
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5//
6//===----------------------------------------------------------------------===//
7//
8// This file implements a translation between the AIEVec dialect and LLVM IR.
9//
10//===----------------------------------------------------------------------===//
11
14#include "mlir/IR/Operation.h"
15#include "mlir/Target/LLVMIR/ModuleTranslation.h"
16
17#include "llvm/IR/IRBuilder.h"
18#include "llvm/IR/IntrinsicsAArch64.h"
19
20using namespace xilinx;
21using namespace mlir;
22using namespace mlir::LLVM;
23
24namespace {
25/// Implementation of the dialect interface that converts operations belonging
26/// to the XLLVM dialect to LLVM IR.
27class XLLVMDialectLLVMIRTranslationInterface
28 : public LLVMTranslationDialectInterface {
29public:
30 using LLVMTranslationDialectInterface::LLVMTranslationDialectInterface;
31
32 /// Translates the given operation to LLVM IR using the provided IR builder
33 /// and saving the state in `moduleTranslation`.
34 LogicalResult
35 convertOperation(Operation *op, llvm::IRBuilderBase &builder,
36 LLVM::ModuleTranslation &moduleTranslation) const final {
37 Operation &opInst = *op;
38#include "aie/Dialect/XLLVM/IR/XLLVMConversions.inc"
39
40 return failure();
41 }
42};
43} // namespace
44
45void xilinx::xllvm::registerXLLVMDialectTranslation(DialectRegistry &registry) {
46 registry.insert<xllvm::XLLVMDialect>();
47 registry.addExtension(+[](MLIRContext *ctx, xllvm::XLLVMDialect *dialect) {
48 dialect->addInterfaces<XLLVMDialectLLVMIRTranslationInterface>();
49 });
50}
51
52void xilinx::xllvm::registerXLLVMDialectTranslation(MLIRContext &context) {
53 DialectRegistry registry;
55 context.appendDialectRegistry(registry);
56}
void registerXLLVMDialectTranslation(mlir::DialectRegistry &registry)
Register the AIEVec dialect and the translation from it to the LLVM dialect in the given registry.