MLIR-AIE 1.4.5.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 explicit PacketIdSpace(DeviceOp device);
28
29 /// The largest id the target's header field holds.
30 int maxId() const { return max; }
31
32 bool isTaken(int id) const { return taken.contains(id); }
33 void take(int id) { taken.insert(id); }
34
35 /// Takes and returns the lowest free id at or above `from`, or nothing when
36 /// the field is exhausted.
37 std::optional<int> takeLowestFrom(int from = 0);
38
39private:
40 llvm::SmallDenseSet<int> taken;
41 int max;
42};
43
44} // namespace xilinx::AIE
45
46#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.