MLIR-AIE 1.4.6.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 BD blocks that require use_next_bd=0 during configuration.
47llvm::SmallPtrSet<mlir::Block *, 8>
48collectUnchainedBlocks(const llvm::SetVector<mlir::Block *> &blockVector);
49
50/// A buffer's `initial_value` as the bytes to write to its tile memory, in
51/// element order. Every path that delivers that value to the device calls this
52/// -- the CDO and transaction writer, and the aiesim configuration source -- so
53/// one buffer is initialized one way.
54///
55/// Returns nullopt for an element type with no byte image, meaning neither
56/// integer nor float. The callers report that type.
57std::optional<std::vector<char>>
58denseAttrToBytes(mlir::DenseElementsAttr denseInit);
59
60/// The extent the core compiler gets for its own .data, .rodata and .bss,
61/// tile-relative. A `core_data` buffer among `buffers` fixes the extent;
62/// otherwise it is the largest run the buffers leave above the stack.
63///
64/// The linker script emitter and the aiecc driver both need this, so a
65/// diagnostic about the region names the bytes the script grants.
66MemoryRun coreDataRegion(TileOp tile, llvm::ArrayRef<BufferOp> buffers);
67
68/// One extent per memory bank for the core's bank-pinned statics, tile-relative
69/// and indexed by bank. Each is the largest run that bank has left once the
70/// stack, the buffers and `dataRun` are accounted for, so a bank with nothing
71/// spare yields a zero-sized extent rather than dropping out.
72///
73/// Pass an empty `dataRun` when no data reservation exists; the linker then
74/// bounds ordinary data using the actual bank-section extents.
75llvm::SmallVector<MemoryRun> coreBankRegions(TileOp tile,
76 llvm::ArrayRef<BufferOp> buffers,
77 MemoryRun dataRun);
78
79} // namespace AIE
80} // namespace xilinx
81
82#endif
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::SmallPtrSet< mlir::Block *, 8 > collectUnchainedBlocks(const llvm::SetVector< mlir::Block * > &blockVector)
Collect BD blocks that require use_next_bd=0 during configuration.
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)