MLIR-AIE 1.4.6.dev
AIEPasses.h
Go to the documentation of this file.
1//===- AIEPasses.h ----------------------------------------------*- C++ -*-===//
2//
3// Copyright (C) 2021-2022 Xilinx, Inc.
4// Copyright (C) 2022-2026 Advanced Micro Devices, Inc.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef AIE_PASSES_H
10#define AIE_PASSES_H
11
14
15#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
16#include "mlir/Dialect/SCF/IR/SCF.h"
17#include "mlir/Pass/Pass.h"
18
19namespace xilinx::AIE {
20std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
22
23/// Discardable attribute set by `--aie-objectfifo-lower-cores` on `scf.for`
24/// and forever `scf.while` loops containing ObjectFifo accesses -- the loop
25/// unroll factor (the least common multiple of the depths of the objectFifos
26/// accessed within the loop) consumed by the `AIEObjectFifoUnroll` pass.
27inline constexpr llvm::StringLiteral kObjectFifoUnrollHintAttrName =
28 "aie.unroll_hint";
29
30/// Discardable attribute set by `--aie-objectfifo-lower-cores` on the rank-0
31/// `memref.alloca`s that hold a core's objects of an objectFifo in rotation
32/// order. The `AIEObjectFifoUnroll` pass promotes them to SSA on each core
33/// where every object then folds to its buffer. Otherwise they stay in memory,
34/// so that LLVM's SROA carries only the buffer pointer around the loop rather
35/// than the whole memref descriptor.
36inline constexpr llvm::StringLiteral kObjectFifoObjectSlotAttrName =
37 "aie.objectfifo.object_slot";
38
39/// How `--aie-objectfifo-allocate` says a pool's buffers fit no memory its
40/// users reach; the diagnostic's symbol argument names the pool's objectFIFO,
41/// nested in its device.
42inline constexpr llvm::StringLiteral kNoBufferRoom =
43 "could not place buffers in accessible memory with available capacity";
44/// The note on it naming, as its symbol arguments, the mem tile pools channel
45/// turns walked whole: one buffer each, where the SA placer counts objects.
46inline constexpr llvm::StringLiteral kTurnWalkedNote =
47 "channel turns walked these objectFIFOs' mem tile pools whole: ";
48
49/// How `--aie-assign-buffer-addresses` says a buffer fits no tile memory left,
50/// and the note it adds, at the core, when a core on that tile keeps its own
51/// sections there; the note's symbol argument names the core's device.
52inline constexpr llvm::StringLiteral kNoTileRoom = "could not be placed: ";
53inline constexpr llvm::StringLiteral kCoreSectionsNote =
54 "this core keeps its own sections in ";
55
56/// Whether `whileOp` repeats forever: its condition is a constant true, and its
57/// condition region does nothing but forward its arguments to the body. This is
58/// how IRON's `Worker` writes a core that runs until reconfiguration. Such a
59/// loop can be unrolled by repeating its body.
60bool isForeverLoop(mlir::scf::WhileOp whileOp);
61
62/// Whether `forOp` counts from 0 to INT64_MAX in steps of 1 and never reads its
63/// induction variable. INT64_MAX iterations never finish, so the loop repeats
64/// forever; a smaller bound such as 2^32-1 can be reached.
65bool isForeverForLoop(mlir::scf::ForOp forOp);
66
67/// Replace `forOp`, which `isForeverForLoop` accepts, with an `scf.while` that
68/// `isForeverLoop` accepts and that carries the same values.
69mlir::scf::WhileOp replaceWithForeverLoop(mlir::scf::ForOp forOp);
70
71/// Whether `op` is a loop that objectFifo lowering unrolls by the rotation
72/// period of the objectFifos accessed in it: an `scf.for`, or an `scf.while`
73/// that repeats forever.
74bool isObjectFifoLoop(mlir::Operation *op);
75
76/// The innermost loop around `op` that `isObjectFifoLoop` accepts, or null.
77mlir::Operation *getObjectFifoLoopParent(mlir::Operation *op);
78
79#define GEN_PASS_DECL
80#include "aie/Dialect/AIE/Transforms/AIEPasses.h.inc"
81
82std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>> createAIEPlaceTilesPass();
83std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
84createAIEPlaceTilesPass(const AIEPlaceTilesOptions &options);
85std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIEPrepareBuffersPass();
86std::unique_ptr<mlir::OperationPass<DeviceOp>>
88std::unique_ptr<mlir::OperationPass<DeviceOp>>
90 const AIEAssignBufferAddressesOptions &options);
91std::unique_ptr<mlir::OperationPass<DeviceOp>>
93std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIEAssignLockIDsPass();
94std::unique_ptr<mlir::OperationPass<DeviceOp>>
96std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
98std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
100std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
101createAIECoreToStandardPass(const AIECoreToStandardOptions &options);
102std::unique_ptr<mlir::OperationPass<DeviceOp>>
104std::unique_ptr<mlir::OperationPass<DeviceOp>>
106std::unique_ptr<mlir::OperationPass<DeviceOp>>
108 const AIEObjectFifoInsertCoreQueuePushesOptions &options);
109std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIEFindFlowsPass();
110std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIESplitFlowViasPass();
111std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIELocalizeLocksPass();
112std::unique_ptr<mlir::OperationPass<DeviceOp>>
114std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>> createAIERouteFlowsPass();
115std::unique_ptr<mlir::OperationPass<DeviceOp>>
117std::unique_ptr<mlir::OperationPass<DeviceOp>>
119std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
121std::unique_ptr<mlir::OperationPass<DeviceOp>>
123std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIEPathfinderPass();
124std::unique_ptr<mlir::OperationPass<DeviceOp>>
125createAIEPathfinderPass(const AIERoutePathfinderFlowsOptions &options);
126std::unique_ptr<mlir::OperationPass<DeviceOp>>
127createAIEPathfinderPass(const AIERoutePathfinderFlowsOptions &options,
128 llvm::ArrayRef<std::pair<TileID, Port>> avoidedPorts);
129std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIEObjectFifoUnrollPass();
130std::unique_ptr<mlir::OperationPass<DeviceOp>>
131createAIEObjectFifoUnrollPass(const AIEObjectFifoUnrollOptions &options);
132std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIEObjectFifoSplitPass();
133std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIEObjectFifoVerifyPass();
134std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIEAssignPacketIdsPass();
135std::unique_ptr<mlir::OperationPass<DeviceOp>>
136createAIEAssignPacketIdsPass(bool packetSwitched,
137 bool reserveControllerPacketIds = false);
138std::unique_ptr<mlir::OperationPass<DeviceOp>>
140std::unique_ptr<mlir::OperationPass<DeviceOp>>
142std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
144std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
145createAIECheckAgainstImagePass(const AIECheckAgainstImageOptions &options);
146std::unique_ptr<mlir::OperationPass<DeviceOp>>
148std::unique_ptr<mlir::OperationPass<DeviceOp>>
150std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIELowerCascadeFlowsPass();
151std::unique_ptr<mlir::OperationPass<DeviceOp>>
153std::unique_ptr<mlir::OperationPass<DeviceOp>>
155std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
157std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
159std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
161 const AIEGenerateColumnControlOverlayOptions &options);
162bool getsColumnControlOverlay(DeviceOp device, bool configuration);
163std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIEAssignTileCtrlIDsPass();
164std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIETraceToConfigPass();
165std::unique_ptr<mlir::OperationPass<DeviceOp>>
167std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIEInsertTraceFlowsPass();
168
169/// Generate the code for registering passes.
170#define GEN_PASS_REGISTRATION
171#include "aie/Dialect/AIE/Transforms/AIEPasses.h.inc"
172
173/// Adds the passes of `aie-objectFifo-stateful-transform` to `pm`, which
174/// anchors on DeviceOp.
175void addObjectFifoLoweringPasses(mlir::OpPassManager &pm, bool packetSwitched,
176 bool skipVerify,
177 bool reserveControllerPacketIds = false,
178 bool checkQueueSpace = true);
179
180/// Register `aie-objectFifo-stateful-transform` as a pipeline over the passes
181/// that lower `aie.objectfifo`.
183
184} // namespace xilinx::AIE
185
186#endif // AIE_PASSES_H
bool isForeverForLoop(mlir::scf::ForOp forOp)
Whether forOp counts from 0 to INT64_MAX in steps of 1 and never reads its induction variable.
void addObjectFifoLoweringPasses(mlir::OpPassManager &pm, bool packetSwitched, bool skipVerify, bool reserveControllerPacketIds=false, bool checkQueueSpace=true)
Adds the passes of aie-objectFifo-stateful-transform to pm, which anchors on DeviceOp.
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEInsertTraceFlowsPass()
std::unique_ptr< mlir::OperationPass< mlir::ModuleOp > > createAIEHoistVectorTransferPointersPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIETraceRegPackWritesPass()
constexpr llvm::StringLiteral kNoTileRoom
How --aie-assign-buffer-addresses says a buffer fits no tile memory left, and the note it adds,...
Definition AIEPasses.h:52
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEPrepareBuffersPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIECoreIntRangeNarrowingPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEObjectFifoLowerCoresPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIELowerCoreIssuedConfigurationPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEObjectFifoInsertCoreQueuePushesPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEAssignTileCtrlIDsPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIELowerCascadeFlowsPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEObjectFifoAllocatePass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIENormalizeDmaBdDimsPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEFindFlowsPass()
std::unique_ptr< mlir::OperationPass< mlir::ModuleOp > > createAIECoreToStandardPass()
bool getsColumnControlOverlay(DeviceOp device, bool configuration)
constexpr llvm::StringLiteral kObjectFifoObjectSlotAttrName
Discardable attribute set by --aie-objectfifo-lower-cores on the rank-0 memref.allocas that hold a co...
Definition AIEPasses.h:36
std::unique_ptr< mlir::OperationPass< mlir::ModuleOp > > createAIECheckAgainstImagePass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEObjectFifoLivenessPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEVectorToPointerLoopsPass()
std::unique_ptr< mlir::OperationPass< mlir::ModuleOp > > createAIEGenerateColumnControlOverlayPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEAssignLockIDsPass()
mlir::scf::WhileOp replaceWithForeverLoop(mlir::scf::ForOp forOp)
Replace forOp, which isForeverForLoop accepts, with an scf.while that isForeverLoop accepts and that ...
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEObjectFifoUnrollPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIENormalizeAddressSpacesPass()
std::unique_ptr< mlir::OperationPass< mlir::ModuleOp > > createAIERouteFlowsPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEAssignPacketIdsPass()
std::unique_ptr< mlir::OperationPass< mlir::ModuleOp > > createAIEAnnotateShimSharingPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIESplitFlowViasPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEAssignCoreLinkFilesPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEObjectFifoErasePoolsPass()
std::unique_ptr< mlir::OperationPass< mlir::ModuleOp > > createAIECanonicalizeDevicePass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEAssignBufferAddressesPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEObjectFifoVerifyPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIELocalizeLocksPass()
constexpr llvm::StringLiteral kTurnWalkedNote
The note on it naming, as its symbol arguments, the mem tile pools channel turns walked whole: one bu...
Definition AIEPasses.h:46
constexpr llvm::StringLiteral kNoBufferRoom
How --aie-objectfifo-allocate says a pool's buffers fit no memory its users reach; the diagnostic's s...
Definition AIEPasses.h:42
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIETraceToConfigPass()
constexpr llvm::StringLiteral kObjectFifoUnrollHintAttrName
Discardable attribute set by --aie-objectfifo-lower-cores on scf.for and forever scf....
Definition AIEPasses.h:27
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEAssignBufferDescriptorIDsPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEObjectFifoLowerDMAsPass()
bool isForeverLoop(mlir::scf::WhileOp whileOp)
Whether whileOp repeats forever: its condition is a constant true, and its condition region does noth...
void registerAIEObjectFifoPipeline()
Register aie-objectFifo-stateful-transform as a pipeline over the passes that lower aie....
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEPathfinderPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEVectorTransferLoweringPass()
std::unique_ptr< mlir::OperationPass< DeviceOp > > createAIEObjectFifoSplitPass()
mlir::Operation * getObjectFifoLoopParent(mlir::Operation *op)
The innermost loop around op that isObjectFifoLoop accepts, or null.
std::unique_ptr< mlir::OperationPass< mlir::ModuleOp > > createAIEImportOverlayPass()
bool isObjectFifoLoop(mlir::Operation *op)
Whether op is a loop that objectFifo lowering unrolls by the rotation period of the objectFifos acces...
std::unique_ptr< mlir::OperationPass< mlir::ModuleOp > > createAIEPlaceTilesPass()
constexpr llvm::StringLiteral kCoreSectionsNote
Definition AIEPasses.h:53