MLIR-AIE 1.4.6.dev
AIEPacketIdSpace.cpp
Go to the documentation of this file.
1//===- AIEPacketIdSpace.cpp -------------------------------------*- C++ -*-===//
2//
3// Copyright (C) 2026 Advanced Micro Devices, Inc.
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5//
6//===----------------------------------------------------------------------===//
7
9
10using namespace xilinx;
11using namespace xilinx::AIE;
12
14 : max(static_cast<int>(device.getTargetModel().getMaxPacketId())) {
15 if (AIEDialect::ReserveControllerPacketIdsAttrHelper(device.getContext())
16 .isAttrPresent(device)) {
17 for (auto [tile, id] :
18 device.getTargetModel().getTileToControllerIdMap(true))
19 taken.insert(id);
20 for (auto tile : device.getOps<TileOp>())
21 if (auto id = tile->getAttrOfType<PacketInfoAttr>("controller_id");
22 id && id.isAssigned())
23 taken.insert(id.assignedId());
24 }
25 device.walk([&](PacketFlowOp flow) { taken.insert(flow.IDInt()); });
26 device.walk([&](TracePacketOp packet) {
27 if (std::optional<int32_t> id = packet.getId()) {
28 taken.insert(*id);
29 }
30 });
31 auto pinned = [&](PacketInfoAttr header) {
32 if (header && header.isAssigned()) {
33 taken.insert(header.assignedId());
34 }
35 };
36 for (auto route : device.getOps<RouteOp>()) {
37 pinned(route.getPacketAttr());
38 }
39 for (auto fifo : device.getOps<ObjectFifoCreateOp>()) {
40 pinned(fifo.packetHeader());
41 }
42}
43
44std::optional<int> PacketIdSpace::takeLowestFrom(int from) {
45 for (int id = from; id <= max; id++) {
46 if (taken.insert(id).second) {
47 return id;
48 }
49 }
50 return std::nullopt;
51}
std::optional< int > takeLowestFrom(int from=0)
Takes and returns the lowest free id at or above from, or nothing when the field is exhausted.
const AIETargetModel & getTargetModel(mlir::Operation *op)