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