| Issue |
185049
|
| Summary |
[HLSL][Matrix] implement row_major and column_major Keywords
|
| Labels |
HLSL
|
| Assignees |
|
| Reporter |
farzonl
|
## Background
See https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-per-component-math#matrix-ordering
HLSL supports per matrix memory layout orderings via the following keywords `row_major` and `column_major`.
## Prior art
currently clang/llvm support column major loads and stores only via the clang builtins
- BI__builtin_matrix_column_major_load
- BI__builtin_matrix_column_major_store
And the intrinsics
- int_matrix_column_major_load
- int_matrix_column_major_store
We will need to implement row major equivalents of these that we can use to convert from one memory layout to the chosen default memory layout specified by /Zpr or /Zpc.
## Implementation
- [ ] Add a `Sema::BuiltinMatrixRowMajorLoad` to `clang/lib/Sema/SemaChecking.cpp`
- [ ] Add a `Sema::BuiltinMatrixRowMajorStore` to `clang/lib/Sema/SemaChecking.cpp`
- [ ] Add a `int_matrix_row_major_load `and `int_matrix_row_major_store` to `llvm/include/llvm/IR/Intrinsics.td`
- [ ] In `CodeGenFunction::EmitBuiltinExpr` `clang/lib/CodeGen/CGBuiltin.cpp` handle the two new intrinsics
- [ ] In `llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp` add the proper codegen for the row major matrix loads and stores
- [ ] Add meta data to matrix types that indicates memory layout
- [ ] Find all Invocation.getLangOpts().getDefaultMatrixMemoryLayout() in code base and add alternative lookup for memory layout meta data so we know if we should be doing a column major or row major load or store.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs