6 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
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
88788dcd5b
[HLSL][Matrix] Implement dynamic single subscript swizzle (#173201)
fixes #170777

If we don't use vector type and instead continue to pass on the matrix
type when we enter `EmitExtVectorElementExpr` Then we don't need to
store the row and column length on the LValue.

Using the Matrix type means we can reuse the isMatrixRow() cases in
EmitLoadOfLValue and EmitStoreThroughLValue and not have to support a
new lValue that is a hybrid between the ExtVectorElt and MatrixRow
cases.

All we need to do to support this is pass the list of column indices as
a `ConstantDataVector` and check the size of this Vector to know how
many column iterations we need to do. Further just index into the vector
to fetch the right encoded element index value.
2026-01-07 11:57:04 -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