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