[clang] [HLSL][Matrix] Make matrix truncation respect default matrix memory layout (PR #184280)
Deric C. via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 3 10:47:34 PST 2026
================
@@ -4457,6 +4457,29 @@ class ConstantMatrixType final : public MatrixType {
return Column * NumRows + Row;
}
+ /// Given a row-major flattened index \p Index, return the corresponding
+ /// {row, column} position.
+ std::pair<unsigned, unsigned> getRowMajorRowAndColumn(unsigned Index) const {
+ return {Index / NumColumns, Index % NumColumns};
+ }
+
+ /// Given a column-major flattened index \p Index, return the corresponding
+ /// {row, column} position.
+ std::pair<unsigned, unsigned>
+ getColumnMajorRowAndColumn(unsigned Index) const {
+ return {Index % NumRows, Index / NumRows};
+ }
+
+ /// Given a flattened index \p Index, return the corresponding {row, column}
+ /// position. If \p IsRowMajor is true, interprets \p Index as a row-major
+ /// flattened index. Otherwise, interprets it as a column-major flattened
+ /// index.
+ std::pair<unsigned, unsigned> getRowAndColumn(unsigned Index,
+ bool IsRowMajor = false) const {
+ return IsRowMajor ? getRowMajorRowAndColumn(Index)
+ : getColumnMajorRowAndColumn(Index);
+ }
+
----------------
Icohedron wrote:
Could be useful in the future, but yea I can just reintroduce these when they are actually needed.
https://github.com/llvm/llvm-project/pull/184280
More information about the cfe-commits
mailing list