MLIR-AIE 1.4.5.dev
AIETargetShared.h
Go to the documentation of this file.
1//===- AIETargetShared.h ----------------------------------------*- C++ -*-===//
2//
3// Copyright (C) 2023 Advanced Micro Devices, Inc.
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5//
6//===----------------------------------------------------------------------===//
7
8#ifndef AIETargetShared_XAIEV2_CDO_H
9#define AIETargetShared_XAIEV2_CDO_H
10
13
14#include "llvm/ADT/SmallPtrSet.h"
15
16namespace xilinx {
17namespace AIE {
18
19std::string tileLocStr(llvm::StringRef col, llvm::StringRef row);
20
21std::string tileLocStr(int col, int row);
22
23std::string tileDMAInstStr(llvm::StringRef col, llvm::StringRef row,
24 llvm::StringRef bdNum);
25
26std::string tileDMAInstStr(int col, int row, int bdNum);
27
28std::string tileDMAInstRefStr(llvm::StringRef col, llvm::StringRef row,
29 llvm::StringRef bdNum);
30
31std::string tileDMAInstRefStr(int col, int row, int bdNum);
32
33std::string packetStr(llvm::StringRef id, llvm::StringRef type);
34
35std::string packetStr(int id, int type);
36
37void generateXAieDmaSetMultiDimAddr(llvm::raw_ostream &output, int ndims,
38 llvm::ArrayRef<BDDimLayoutAttr> dims,
39 int col, int row, int bdNum, int baseAddrA,
40 int64_t offsetA, uint32_t lenA,
41 int elementWidthInBytes,
42 const char *errorRet);
43
44llvm::SetVector<mlir::Block *> getOrderedChainOfBlocks(mlir::Region *region);
45
46/// Collect every BD block reached from an out-of-order aie.dma_start channel.
47/// These BDs use use_next_bd=0 (placement is by header id, not the chain).
48llvm::SmallPtrSet<mlir::Block *, 8>
49collectOutOfOrderBlocks(const llvm::SetVector<mlir::Block *> &blockVector);
50
51/// A buffer's `initial_value` as the bytes to write to its tile memory, in
52/// element order. Every path that delivers that value to the device calls this
53/// -- the CDO and transaction writer, and the aiesim configuration source -- so
54/// one buffer is initialized one way.
55///
56/// Returns nullopt for an element type with no byte image, meaning neither
57/// integer nor float. The callers report that type.
58std::optional<std::vector<char>>
59denseAttrToBytes(mlir::DenseElementsAttr denseInit);
60
61/// The extent the core compiler gets for its own .data, .rodata and .bss,
62/// tile-relative. A `core_data` buffer among `buffers` fixes the extent;
63/// otherwise it is the largest run the buffers leave above the stack.
64///
65/// The linker script emitter and the aiecc driver both need this, so a
66/// diagnostic about the region names the bytes the script grants.
67MemoryRun coreDataRegion(TileOp tile, llvm::ArrayRef<BufferOp> buffers);
68
69/// One extent per memory bank for the core's bank-pinned statics, tile-relative
70/// and indexed by bank. Each is the largest run that bank has left once the
71/// stack, the buffers and `dataRun` are accounted for, so a bank with nothing
72/// spare yields a zero-sized extent rather than dropping out.
73///
74/// Pass an empty `dataRun` when no data reservation exists; the linker then
75/// bounds ordinary data using the actual bank-section extents.
76llvm::SmallVector<MemoryRun> coreBankRegions(TileOp tile,
77 llvm::ArrayRef<BufferOp> buffers,
78 MemoryRun dataRun);
79
80} // namespace AIE
81} // namespace xilinx
82
83#endif
llvm::SmallPtrSet< mlir::Block *, 8 > collectOutOfOrderBlocks(const llvm::SetVector< mlir::Block * > &blockVector)
Collect every BD block reached from an out-of-order aie.dma_start channel.
std::string tileDMAInstStr(llvm::StringRef col, llvm::StringRef row, llvm::StringRef bdNum)
llvm::SmallVector< MemoryRun > coreBankRegions(TileOp tile, llvm::ArrayRef< BufferOp > buffers, MemoryRun dataRun)
One extent per memory bank for the core's bank-pinned statics, tile-relative and indexed by bank.
void generateXAieDmaSetMultiDimAddr(llvm::raw_ostream &output, int ndims, llvm::ArrayRef< BDDimLayoutAttr > dims, int col, int row, int bdNum, int baseAddrA, int64_t offsetA, uint32_t lenA, int elementWidthInBytes, const char *errorRet)
std::optional< std::vector< char > > denseAttrToBytes(mlir::DenseElementsAttr denseInit)
A buffer's initial_value as the bytes to write to its tile memory, in element order.
MemoryRun coreDataRegion(TileOp tile, llvm::ArrayRef< BufferOp > buffers)
The extent the core compiler gets for its own .data, .rodata and .bss, tile-relative.
std::string tileDMAInstRefStr(llvm::StringRef col, llvm::StringRef row, llvm::StringRef bdNum)
llvm::SetVector< mlir::Block * > getOrderedChainOfBlocks(mlir::Region *region)
std::string tileLocStr(llvm::StringRef col, llvm::StringRef row)
std::string packetStr(llvm::StringRef id, llvm::StringRef type)