MLIR-AIE
TranslateRegistration.cpp
Go to the documentation of this file.
1//===- TranslateRegistration.cpp - Register translation ---------*- 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// (c) Copyright 2022 Xilinx Inc.
8//
9//===----------------------------------------------------------------------===//
10
14
15#include "mlir/Dialect/Arith/IR/Arith.h"
16#include "mlir/Dialect/ControlFlow/IR/ControlFlow.h"
17#include "mlir/Dialect/DLTI/DLTI.h"
18#include "mlir/Dialect/EmitC/IR/EmitC.h"
19#include "mlir/Dialect/Func/IR/FuncOps.h"
20#include "mlir/Dialect/Index/IR/IndexDialect.h"
21#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
22#include "mlir/Dialect/Math/IR/Math.h"
23#include "mlir/Dialect/MemRef/IR/MemRef.h"
24#include "mlir/Dialect/SCF/IR/SCF.h"
25#include "mlir/Dialect/Vector/IR/VectorOps.h"
26#include "mlir/IR/BuiltinOps.h"
27#include "mlir/IR/Dialect.h"
28#include "mlir/Tools/mlir-translate/Translation.h"
29
30using namespace mlir;
31
32namespace xilinx {
33namespace aievec {
34
35//===----------------------------------------------------------------------===//
36// AIEVec to Cpp translation registration
37//===----------------------------------------------------------------------===//
38
39static llvm::cl::opt<bool> AIE2("aie2",
40 llvm::cl::desc("AIE2 (i.e. AI Engine-ML)"),
41 llvm::cl::init(false));
42
44 TranslateFromMLIRRegistration reg(
45 "aievec-to-cpp", "Translate AIEVecDialect dialect to C++",
46 [](ModuleOp module, raw_ostream &output) {
47 return aievec::translateAIEVecToCpp(module, AIE2.getValue(), output);
48 },
49 [](DialectRegistry &registry) {
50 // clang-format off
51 registry.insert<arith::ArithDialect,
52 emitc::EmitCDialect,
53 LLVM::LLVMDialect,
54 math::MathDialect,
55 memref::MemRefDialect,
56 func::FuncDialect,
57 cf::ControlFlowDialect,
58 DLTIDialect,
59 scf::SCFDialect,
60 vector::VectorDialect,
61 xilinx::aievec::aie1::AIEVecAIE1Dialect,
62 xilinx::aievec::AIEVecDialect,
63 index::IndexDialect>();
64 // clang-format on
65 });
66}
67
68} // namespace aievec
69} // namespace xilinx
mlir::LogicalResult translateAIEVecToCpp(mlir::Operation *op, bool aie2, mlir::raw_ostream &os)
Translates the AIE vector dialect MLIR to C++ code.