8 Commits

Author SHA1 Message Date
Justin Bogner
de2bf130e3
[clang][DirectX] Specify element-aligned vectors in TargetInfo (#185954)
Add a bit to TargetInfo to specify that vectors are element-aligned
rather than naturally aligned. This is needed to match DirectX's Data
Layout in LLVM.

Note that this removes the `Opts.HLSL` early exit from
`checkDataLayoutConsistency` so that we actually get these checks when
compiling HLSL. This check looks like it was put there because of
similarity between OpenCL and HLSL, but it isn't actually necessary.

Resolves #123968
2026-03-13 16:35:39 -07:00
Farzon Lotfi
04f0935cf4
[Matrix] For MatrixRow with constant index use Indices.size() instead of getNumColumns() (#185530)
fixes #184380

Three changes
-  Use Indices.size()
- Construct a new QualType if Indices.size()  != MT->getNumColumns()
- Add a new test case
2026-03-10 12:27:30 -04:00
Farzon Lotfi
51d128fb1e
[Matrix][HLSL] Allow memory layout to change via flags (#181866)
fixes #181859

This also fixes an issue introduced in
https://github.com/llvm/llvm-project/pull/179861

where we were doing the array vector layout in row major as DXC would
define it.
2026-02-17 14:11:13 -05:00
Farzon Lotfi
1bb916c9af
[HLSL] Represent Matrix as arrays of vectors in memory (#179861)
fixes https://github.com/llvm/llvm-project/issues/179859

For matrix types we need to check the language mode so we can change the
matrix memory layout to arrays of vectors. To make this play nice with
how the rest of clang treats matrices we need to modify the
MaybeConvertMatrixAddress and the CreateMemTemp function to know how to
reconstruct a flattened vector.

Rest of changes is just test updates.
2026-02-06 16:25:20 -05:00
Deric C.
255af949a7
[HLSL][Matrix] Update indexed matrix elements individually (#176216)
Fixes #174629

This PR is similar to that of #169144 but for matrices.

When storing to a matrix element or matrix row, `insertelement`
instructions have been replaced by GEPs followed by stores to individual
matrix elements. There is no longer storing of the entire matrix to
memory all at once, thus avoiding data races when writing to independent
matrix elements from multiple threads.
2026-01-16 13:05:52 -08:00
Farzon Lotfi
d48050ab27
[Matrix][HLSL] Implement Matrix single constant index swizzle (#173044)
fixes #172805

For the constant case if we know the row index then we can compute the
offsets via `E->getEncodedElementAccess(Elts)`. We had to also add
column and row sizes to LValue so that we could compute the right index.
the emitter for `MatrixSingleSubscriptExpr` collects the sizes off the
type and passes it to `MakeMatrixRow`.

---------

Co-authored-by: Justin Bogner <mail@justinbogner.com>
2025-12-21 14:09:20 -05:00
Farzon Lotfi
c7b86a625e
[Matrix][HLSL] Revert Constant Matrix single subscript handling (#172887)
This change creates an XFAIL that will be addressed by #172805

This part of the change was not intended to make it in. It was a way to
optimize for constant index setters\getters but had the unintended
consequence of doing swizzles without considering the encoded element
offsets.

We need to be calling `MakeExtVectorElt` in `EmitExtVectorElementExpr`
so that we can call `E->getEncodedElementAccess(Elts);` off of the
`ExtVectorElementExpr` Node.

Calling it in `EmitMatrixSingleSubscriptExpr` was wrong because we doing
have the vector encoded elementts yet. But also to get the right index
we need a way to pass on the matrix column and row lengths so
`MakeMatrixRow` needed to be expanded to store row and column sizes on
the LValue.
2025-12-18 14:48:13 -05:00
Farzon Lotfi
60b6c53f25
[HLSL][Matrix] Add support for single subscript accessor (#170779)
fixes #166206

- Add swizzle support if row index is constant
- Add test cases
- Add new AST type
- Add new LValue for Matrix Row Type
- TODO: Make the new LValue a dynamic index version of ExtVectorElt
2025-12-17 17:04:28 -05:00