MLIR-AIE
1.4.5.dev
include
aie
Dialect
AIE
Transforms
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
11
#include "
aie/Dialect/AIE/IR/AIEDialect.h
"
12
13
#include "llvm/ADT/DenseSet.h"
14
15
#include <optional>
16
17
namespace
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.
25
class
PacketIdSpace
{
26
public
:
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
39
private
:
40
llvm::SmallDenseSet<int> taken;
41
int
max;
42
};
43
44
}
// namespace xilinx::AIE
45
46
#endif
// AIE_DIALECT_AIE_TRANSFORMS_AIEPACKETIDSPACE_H
AIEDialect.h
xilinx::AIE::PacketIdSpace::takeLowestFrom
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.
Definition
AIEPacketIdSpace.cpp:34
xilinx::AIE::PacketIdSpace::maxId
int maxId() const
The largest id the target's header field holds.
Definition
AIEPacketIdSpace.h:30
xilinx::AIE::PacketIdSpace::take
void take(int id)
Definition
AIEPacketIdSpace.h:33
xilinx::AIE::PacketIdSpace::PacketIdSpace
PacketIdSpace(DeviceOp device)
Definition
AIEPacketIdSpace.cpp:13
xilinx::AIE::PacketIdSpace::isTaken
bool isTaken(int id) const
Definition
AIEPacketIdSpace.h:32
xilinx::AIE
Definition
AIEToConfiguration.h:19
Generated by
1.15.0