diff --git a/include/aie/Conversion/AIEToTransaction/AIEToTransaction.h b/include/aie/Conversion/AIEToTransaction/AIEToTransaction.h new file mode 100644 index 0000000000..f8ff679d11 --- /dev/null +++ b/include/aie/Conversion/AIEToTransaction/AIEToTransaction.h @@ -0,0 +1,28 @@ +//===- AIEToTransaction.h ---------------------------------------*- C++ -*-===// +// +// This file is licensed under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// Copyright (C) 2024, Advanced Micro Devices, Inc. All rights reserved. +// +//===----------------------------------------------------------------------===// + +#ifndef AIE_CONVERSION_AIETOTRANSACTION_AIETOTRANSACTION_H +#define AIE_CONVERSION_AIETOTRANSACTION_AIETOTRANSACTION_H + +#include "aie/Dialect/AIE/IR/AIEDialect.h" +#include "aie/Dialect/AIEX/IR/AIEXDialect.h" + +#include "mlir/Pass/Pass.h" + +#include + +namespace xilinx::AIE { + +std::unique_ptr> +createConvertAIEToTransactionPass(); + +} // namespace xilinx::AIE + +#endif // AIE_CONVERSION_AIETOTRANSACTION_AIETOTRANSACTION_H diff --git a/include/aie/Conversion/Passes.h b/include/aie/Conversion/Passes.h index 53797352cf..7c84c7e319 100644 --- a/include/aie/Conversion/Passes.h +++ b/include/aie/Conversion/Passes.h @@ -11,6 +11,7 @@ #ifndef AIE_CONVERSION_PASSES_H #define AIE_CONVERSION_PASSES_H +#include "aie/Conversion/AIEToTransaction/AIEToTransaction.h" #include "aie/Conversion/AIEVecToLLVM/AIEVecToLLVM.h" #include "aie/Conversion/PassesEnums.h.inc" diff --git a/include/aie/Conversion/Passes.td b/include/aie/Conversion/Passes.td index 4dc6247b30..87d69f2698 100644 --- a/include/aie/Conversion/Passes.td +++ b/include/aie/Conversion/Passes.td @@ -51,4 +51,24 @@ def ConvertAIEVecToLLVM : Pass<"convert-aievec-to-llvm", "mlir::ModuleOp"> { ]; } +//===----------------------------------------------------------------------===// +// AIEToTransaction +//===----------------------------------------------------------------------===// + +def ConvertAIEToTransaction : Pass<"convert-aie-to-transaction", + "xilinx::AIE::DeviceOp"> { + let summary = "Convert AIE dialect to npu transaction operations"; + let description = [{ + This pass converts aie.device operations to a sequence of transaction binary + operations (writes, masked writes, and block writes) that can be used to + to configure the npu device. The transaction operations are emitted as + `npu.write32`, `npu.maskwrite32`, and `npu.blockwrite` operations. A new + `aiex.runtime_sequence` operation is inserted into the `aie.device` to + contain the new transaction operations sequence. + }]; + let constructor = "xilinx::AIE::createConvertAIEToTransactionPass()"; + let dependentDialects = ["xilinx::AIE::AIEDialect", + "xilinx::AIEX::AIEXDialect"]; +} + #endif // AIE_CONVERSION_PASSES diff --git a/include/aie/Dialect/AIEX/Transforms/AIEXPasses.h b/include/aie/Dialect/AIEX/Transforms/AIEXPasses.h index 14d7e87a5a..489b019999 100644 --- a/include/aie/Dialect/AIEX/Transforms/AIEXPasses.h +++ b/include/aie/Dialect/AIEX/Transforms/AIEXPasses.h @@ -1,4 +1,4 @@ -//===- AIEPasses.h ----------------------------------------------*- C++ -*-===// +//===- AIEXPasses.h ---------------------------------------------*- C++ -*-===// // // This file is licensed under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/lib/CAPI/CMakeLists.txt b/lib/CAPI/CMakeLists.txt index 342ea0ac19..ceb5d475d6 100644 --- a/lib/CAPI/CMakeLists.txt +++ b/lib/CAPI/CMakeLists.txt @@ -15,6 +15,7 @@ add_mlir_public_c_api_library(AIECAPI AIEX AIEXTransforms AIEXUtils + MLIRAIEToTransaction MLIRAIEVecDialect MLIRAIEVecAIE1Dialect MLIRAIEVecToLLVM diff --git a/lib/Conversion/AIEToTransaction/AIEToTransaction.cpp b/lib/Conversion/AIEToTransaction/AIEToTransaction.cpp new file mode 100644 index 0000000000..c1b7f8dfb6 --- /dev/null +++ b/lib/Conversion/AIEToTransaction/AIEToTransaction.cpp @@ -0,0 +1,23 @@ + +#include "../PassDetail.h" + +#include "aie/Conversion/AIEToTransaction/AIEToTransaction.h" + +using namespace mlir; + +namespace { + +struct ConvertAIEToTransactionPass + : ConvertAIEToTransactionBase { + void runOnOperation() override { + auto device = getOperation(); + device.dump(); + } +}; + +} // end anonymous namespace + +std::unique_ptr> +xilinx::AIE::createConvertAIEToTransactionPass() { + return std::make_unique(); +} diff --git a/lib/Conversion/AIEToTransaction/CMakeLists.txt b/lib/Conversion/AIEToTransaction/CMakeLists.txt new file mode 100644 index 0000000000..87e0c826c3 --- /dev/null +++ b/lib/Conversion/AIEToTransaction/CMakeLists.txt @@ -0,0 +1,15 @@ +add_mlir_conversion_library(MLIRAIEToTransaction + AIEToTransaction.cpp + + ADDITIONAL_HEADER_DIRS + $(CMAKE_CURRENT_SRC_DIR)/../../../../include/aie/Conversion/AIEToTransaction + + DEPENDS + MLIRAIEConversionPassIncGen + + LINK_COMPONENTS + Core + + LINK_LIBS PUBLIC + AIERTX + ) diff --git a/lib/Conversion/CMakeLists.txt b/lib/Conversion/CMakeLists.txt index 8c78b250dc..7dfda13f60 100644 --- a/lib/Conversion/CMakeLists.txt +++ b/lib/Conversion/CMakeLists.txt @@ -1 +1,2 @@ -add_subdirectory(AIEVecToLLVM) +add_subdirectory(AIEToTransaction) +add_subdirectory(AIEVecToLLVM) \ No newline at end of file diff --git a/lib/Conversion/PassDetail.h b/lib/Conversion/PassDetail.h index 537986193e..dc31948472 100644 --- a/lib/Conversion/PassDetail.h +++ b/lib/Conversion/PassDetail.h @@ -12,6 +12,7 @@ #define AIE_CONVERSION_PASSDETAIL_H_ #include "aie/Conversion/Passes.h" + #include "mlir/Dialect/Arith/IR/Arith.h" #include "mlir/Dialect/Vector/IR/VectorOps.h" #include "mlir/IR/BuiltinOps.h" diff --git a/tools/aie-opt/CMakeLists.txt b/tools/aie-opt/CMakeLists.txt index 53b08c2eea..1d9c75f2f4 100644 --- a/tools/aie-opt/CMakeLists.txt +++ b/tools/aie-opt/CMakeLists.txt @@ -30,6 +30,7 @@ set(LIBS AIEX AIEXTransforms AIEXUtils + MLIRAIEToTransaction MLIRAIEVecDialect MLIRAIEVecAIE1Dialect MLIRAIEVecTransformOps