MLIR-AIE 1.4.6.dev
AIEPacketIdSpace.h
Go to the documentation of this file.
1//===- AIEPacketIdSpace.h ---------------------------------------*- C++ -*-===//
2//
3// Copyright (C) 2026 Advanced Micro Devices, Inc.
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5//
6//===----------------------------------------------------------------------===//
7
8#ifndef AIE_DIALECT_AIE_TRANSFORMS_AIEPACKETIDSPACE_H
9#define AIE_DIALECT_AIE_TRANSFORMS_AIEPACKETIDSPACE_H
10
12
13#include "llvm/ADT/DenseSet.h"
14
15#include <optional>
16
17namespace xilinx::AIE {
18
19/// The packet ids a device has already spoken for. Every switchbox rule on a
20/// stream matches on the id, so two flows sharing one is a routing hazard, and
21/// whoever hands out ids reads this first. It counts every holder, whatever
22/// stage the design is at: an `aie.packet_flow`, the pinned header of an
23/// `aie.route` or of an `aie.objectfifo` not yet split, and an
24/// `aie.trace.packet` with an id.
26public:
27 /// Controller ids are taken when the device carries
28 /// aie.reserve_controller_packet_ids or `reserveControllerIds` is set.
29 explicit PacketIdSpace(DeviceOp device, bool reserveControllerIds = false);
30
31 /// The largest id the target's header field holds.
32 int maxId() const { return max; }
33
34 bool isTaken(int id) const { return taken.contains(id); }
35 void take(int id) { taken.insert(id); }
36
37 /// Takes and returns the lowest free id at or above `from`, or nothing when
38 /// the field is exhausted.
39 std::optional<int> takeLowestFrom(int from = 0);
40
41private:
42 llvm::SmallDenseSet<int> taken;
43 int max;
44};
45
46} // namespace xilinx::AIE
47
48#endif // AIE_DIALECT_AIE_TRANSFORMS_AIEPACKETIDSPACE_H
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.
int maxId() const
The largest id the target's header field holds.
PacketIdSpace(DeviceOp device, bool reserveControllerIds=false)
Controller ids are taken when the device carries aie.reserve_controller_packet_ids or reserveControll...