MLIR-AIE 1.4.6.dev
AIEStructuralRank.h
Go to the documentation of this file.
1//===- AIEStructuralRank.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_TRANSFORMS_AIESTRUCTURALRANK_H
9#define AIE_TRANSFORMS_AIESTRUCTURALRANK_H
10
12
13#include "llvm/ADT/DenseMap.h"
14#include "llvm/ADT/SmallVector.h"
15
16#include <string>
17#include <utility>
18
19namespace xilinx::AIE {
20
21/// Ops and the labelled links between them, for ranking them by structure
22/// where a pass would otherwise fall back on op order.
24 llvm::SmallVector<mlir::Operation *> nodes;
25 /// What each node is, before anything it links to is considered.
26 llvm::DenseMap<mlir::Operation *, std::string> features;
27 llvm::DenseMap<mlir::Operation *,
28 llvm::SmallVector<std::pair<std::string, mlir::Operation *>>>
30
31 /// Add `op` as a node whose features are its name and attributes, symbol
32 /// names and references left out. Returns the features to extend.
33 std::string &add(mlir::Operation *op);
34
35 /// Link `from` to `to` under `label`, and `to` back to `from`.
36 void link(mlir::Operation *from, mlir::Operation *to, llvm::StringRef label);
37
38 /// Rank the nodes by their features and then, a round at a time until no
39 /// class splits, by the ranks of the nodes they link to. Neither op order
40 /// nor symbol names play a part, so a permuted or renamed design ranks
41 /// alike, and nodes left with one rank cannot be told apart.
42 llvm::DenseMap<mlir::Operation *, unsigned> rank() const;
43
44 /// The ops directly in `device` but its runtime sequences, each with the
45 /// ops nested in it, linked to the ops whose results or symbols they use.
46 /// The runtime sequence is left out, so a device ranks the same whatever
47 /// sequence drives it.
48 static StructuralGraph of(DeviceOp device);
49
50 /// Each device of `module` with its graph (of(DeviceOp)), the device a node
51 /// linked to every op in it, so devices rank by what they hold.
52 static StructuralGraph of(mlir::ModuleOp module);
53};
54
55} // namespace xilinx::AIE
56
57#endif // AIE_TRANSFORMS_AIESTRUCTURALRANK_H
Ops and the labelled links between them, for ranking them by structure where a pass would otherwise f...
void link(mlir::Operation *from, mlir::Operation *to, llvm::StringRef label)
Link from to to under label, and to back to from.
llvm::SmallVector< mlir::Operation * > nodes
std::string & add(mlir::Operation *op)
Add op as a node whose features are its name and attributes, symbol names and references left out.
llvm::DenseMap< mlir::Operation *, unsigned > rank() const
Rank the nodes by their features and then, a round at a time until no class splits,...
llvm::DenseMap< mlir::Operation *, std::string > features
What each node is, before anything it links to is considered.
static StructuralGraph of(mlir::ModuleOp module)
Each device of module with its graph (of(DeviceOp)), the device a node linked to every op in it,...
static StructuralGraph of(DeviceOp device)
The ops directly in device but its runtime sequences, each with the ops nested in it,...
llvm::DenseMap< mlir::Operation *, llvm::SmallVector< std::pair< std::string, mlir::Operation * > > > links