20#include "mlir/Pass/Pass.h"
21#include "llvm/ADT/MapVector.h"
22#include "llvm/ADT/SmallVector.h"
25#define GEN_PASS_DEF_AIERESERVERUNTIMEBDIDS
26#include "aie/Dialect/AIEX/Transforms/AIEXPasses.h.inc"
36struct AIEReserveRuntimeBDIDsPass
37 : xilinx::AIEX::impl::AIEReserveRuntimeBDIDsBase<
38 AIEReserveRuntimeBDIDsPass> {
40 void runOnOperation()
override {
41 DeviceOp device = getOperation();
43 const AIETargetModel &targetModel = device.getTargetModel();
44 llvm::MapVector<TileOp, SmallVector<ReservedBdId>> reserved;
46 device, [&](Operation *, Operation *tile, std::optional<int> channel,
47 std::optional<DMAChannelDir> dir, int32_t
id) {
48 auto placed = dyn_cast<TileOp>(tile);
52 ReservedBdId r{std::nullopt,
id};
53 BdIdGenerator gen(placed.getCol(), placed.getRow(), targetModel);
54 if (channel && dir &&
id >= 0 &&
55 !gen.
holdsTileWide(*channel, *dir,
static_cast<uint32_t
>(
id)))
56 r.
channel = std::make_pair(*channel, *dir);
57 reserved[placed].push_back(r);
60 for (
auto &[tile, ids] : reserved)
67std::unique_ptr<mlir::OperationPass<AIE::DeviceOp>>
69 return std::make_unique<AIEReserveRuntimeBDIDsPass>();
std::unique_ptr< mlir::OperationPass< AIE::DeviceOp > > createAIEReserveRuntimeBDIDsPass()
void forEachRuntimePinnedBdId(AIE::DeviceOp device, llvm::function_ref< void(Operation *op, Operation *tile, std::optional< int > channel, std::optional< AIE::DMAChannelDir > dir, int32_t id)> pinned)
void setReservedBdIds(TileOp tile, llvm::ArrayRef< ReservedBdId > ids)
bool holdsTileWide(int channelIndex, DMAChannelDir dir, uint32_t bdId) const
std::optional< std::pair< int, DMAChannelDir > > channel