================
@@ -1915,10 +1915,11 @@ void InitListChecker::CheckMatrixType(const 
InitializedEntity &Entity,
 
   while (Index < IList->getNumInits()) {
     // Not a sublist: just consume directly.
-    unsigned ColMajorIndex = (Index % MT->getNumRows()) * MT->getNumColumns() +
-                             (Index / MT->getNumRows());
-    ElemEnt.setElementIndex(ColMajorIndex);
-    CheckSubElementType(ElemEnt, IList, ElemTy, ColMajorIndex, StructuredList,
+    // Note: In HLSL, elements of the InitListExpr are in row-major order, so 
no
----------------
Icohedron wrote:

Still waiting on @fhahn for input.

However, I don't think it is that significant of a change if someone wants to 
change the layout of matrix initializer lists in the AST back to column-major.
There are only three source code locations that would need to change to adapt 
to the matrix initializer list layout:
1. The `ConstantMatrixType` case in `ScalarExprEmitter::VisitInitListExpr` from 
`clang/lib/CodeGen/CGExprScalar.cpp` (introduced by this PR): 
https://github.com/llvm/llvm-project/pull/182904/changes#diff-50b983ec3169e1130e770b565e669f170deff5e646501cae56ac936681400ee3R2454-R2465
2. `MatrixExprEvaluator::VisitInitListExpr` from 
`clang/lib/AST/ExprConstant.cpp` (introduced by #178762): 
https://github.com/llvm/llvm-project/pull/178762/changes#diff-255a21a02a8966766225831836d482547787baf9a770fbf67178ebb7d7347e27R14640-R14658
3. and the `ConstantMatrixType` case in  `Compiler<Emitter>::visitInitList` 
from `clang/lib/AST/ByteCode/Compiler.cpp` (introduced by #183424): 
https://github.com/llvm/llvm-project/pull/183424/changes#diff-8a0932d99562480551dc1d7aa51882014cef28219d55e04508351e765dc6b513R2339-R2356

So I think this PR is fine to merge as is. If we need to change the matrix 
initializer list order in the AST, it won't be much work to do so.

https://github.com/llvm/llvm-project/pull/182904
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to