MLIR-AIE 1.4.6.dev
TransactionBinary.h
Go to the documentation of this file.
1//===- TransactionBinary.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// Private transaction parser shared by configuration conversion and
9// core-issued DMA lowering. The latter records aie-rt calls as transactions
10// and reuses this parser to extract the register writes executed by the core.
11
12#ifndef AIE_CONVERSION_AIETOCONFIGURATION_TRANSACTIONBINARY_H
13#define AIE_CONVERSION_AIETOCONFIGURATION_TRANSACTIONBINARY_H
14
15#include "mlir/IR/Location.h"
16
17#include <cstdint>
18#include <optional>
19#include <vector>
20
21extern "C" {
22#include "xaiengine/xaiegbl.h"
23// xaie_txn.h needs the types and declarations from xaiegbl.h first.
24#include "xaiengine/xaie_txn.h"
25}
26
27namespace xilinx::AIE {
28
29// A TransactionBinaryOperation encapsulates an aie-rt XAie_TxnCmd struct and
30// any additional metadata needed for custom operations that do not map cleanly
31// onto the core command fields.
33 struct XAie_TxnCmd cmd = {};
34
35 struct SyncPayload {
36 int32_t column;
37 int32_t row;
38 int32_t direction;
39 int32_t channel;
40 int32_t columnCount;
41 int32_t rowCount;
42 };
43
45 uint32_t id;
46 uint32_t size;
47 uint64_t address;
48 };
49
51 uint32_t action;
52 uint32_t addr;
53 int32_t argIdx;
54 // Words 10-11 of the op; see txn_append_address_patch.
55 uint64_t argPlus;
56 };
57
58 std::optional<SyncPayload> sync;
59 std::optional<LoadPdiPayload> loadPdi;
60 std::optional<AddressPatchPayload> addressPatch;
61 std::optional<mlir::Location> sourceLoc;
62
64
65 TransactionBinaryOperation(XAie_TxnOpcode opc, uint32_t mask, uint64_t addr,
66 uint32_t value, const uint8_t *data,
67 uint32_t size) {
68 cmd.Opcode = opc;
69 cmd.Mask = mask;
70 cmd.RegOff = addr;
71 cmd.Value = value;
72 cmd.DataPtr = reinterpret_cast<uint64_t>(data);
73 cmd.Size = size;
74 }
75};
76
77/// Parse an exported transaction. Returns the header's column count and fills
78/// `ops`, or std::nullopt when the blob does not parse.
79std::optional<int>
80parseTransactionBinary(const std::vector<uint8_t> &data,
81 std::vector<TransactionBinaryOperation> &ops);
82
83} // namespace xilinx::AIE
84
85#endif // AIE_CONVERSION_AIETOCONFIGURATION_TRANSACTIONBINARY_H
std::optional< int > parseTransactionBinary(const std::vector< uint8_t > &data, std::vector< TransactionBinaryOperation > &ops)
Parse an exported transaction.
std::optional< LoadPdiPayload > loadPdi
std::optional< mlir::Location > sourceLoc
TransactionBinaryOperation(XAie_TxnOpcode opc, uint32_t mask, uint64_t addr, uint32_t value, const uint8_t *data, uint32_t size)
std::optional< AddressPatchPayload > addressPatch