MLIR-AIE 1.4.5.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 device.walk([&](PacketFlowOp flow) { taken.insert(flow.IDInt()); });
16 device.walk([&](TracePacketOp packet) {
17 if (std::optional<int32_t> id = packet.getId()) {
18 taken.insert(*id);
19 }
20 });
21 auto pinned = [&](PacketInfoAttr header) {
22 if (header && header.isAssigned()) {
23 taken.insert(header.assignedId());
24 }
25 };
26 for (auto route : device.getOps<RouteOp>()) {
27 pinned(route.getPacketAttr());
28 }
29 for (auto fifo : device.getOps<ObjectFifoCreateOp>()) {
30 pinned(fifo.packetHeader());
31 }
32}
33
34std::optional<int> PacketIdSpace::takeLowestFrom(int from) {
35 for (int id = from; id <= max; id++) {
36 if (taken.insert(id).second) {
37 return id;
38 }
39 }
40 return std::nullopt;
41}
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)