MLIR-AIE 1.4.5.dev
AIEVecShuffleModes.h
Go to the documentation of this file.
1//===- AIEVecShuffleModes.h - Semantics of aievec.shuffle modes -*- C++ -*-===//
2//
3// Copyright (C) 2026 Advanced Micro Devices, Inc.
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5//
6//===----------------------------------------------------------------------===//
7// What each aievec.shuffle mode does, derived from the mode name.
8//===----------------------------------------------------------------------===//
9
10#ifndef AIE_DIALECT_AIEVEC_IR_AIEVECSHUFFLEMODES_H
11#define AIE_DIALECT_AIEVEC_IR_AIEVECSHUFFLEMODES_H
12
14
15#include <array>
16#include <cstdint>
17
18namespace xilinx::aievec {
19
20// The name of a mode, t<elemBits>_<rows>x<cols>[_lo|_hi|_flip], read as a
21// matrix of rows x cols elements.
23 unsigned elemBits;
24 unsigned rows;
25 unsigned cols;
26 // Reverses each group of `cols` elements instead of transposing.
27 bool flip;
28 // Returns the upper 512 bits of the 1024-bit result.
29 bool hi;
30
31 unsigned blockBits() const { return elemBits * rows * cols; }
32 // The matrix spans lhs:rhs, so the mode reads both operands.
33 bool isTwoInput() const { return blockBits() == 1024; }
34};
35
36ShuffleModeShape getShuffleModeShape(ShuffleMode mode);
37
38// Whether the mode exists on AIE2P only.
39bool isAIE2POnlyShuffleMode(ShuffleMode mode);
40
41// Byte i of the 512-bit result is byte perm[i] of the 128-byte lhs:rhs. The
42// matrix is transposed as out[j*rows+i] = in[i*cols+j]. A matrix smaller than
43// 512 bits is transposed in each block of lhs of its size.
44std::array<uint8_t, 64> getShuffleModeBytePermutation(ShuffleMode mode);
45
46} // namespace xilinx::aievec
47
48#endif // AIE_DIALECT_AIEVEC_IR_AIEVECSHUFFLEMODES_H
bool isAIE2POnlyShuffleMode(ShuffleMode mode)
ShuffleModeShape getShuffleModeShape(ShuffleMode mode)
std::array< uint8_t, 64 > getShuffleModeBytePermutation(ShuffleMode mode)