================
@@ -2716,6 +2716,37 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src,
LValue Dst,
return EmitStoreThroughGlobalRegLValue(Src, Dst);
if (Dst.isMatrixElt()) {
+ if (getLangOpts().HLSL) {
+ // HLSL allows direct access to matrix elements, so storing to
+ // individual elements of a matrix through MatrixElt is handled as
+ // separate store instructions.
+ Address DstAddr = Dst.getMatrixAddress();
+ llvm::Type *DestAddrTy = DstAddr.getElementType();
+ llvm::Type *ElemTy = DestAddrTy->getScalarType();
+ CharUnits ElemAlign = CharUnits::fromQuantity(
+ CGM.getDataLayout().getPrefTypeAlign(ElemTy));
+
+ assert(ElemTy->getScalarSizeInBits() >= 8 &&
+ "matrix element type must be at least byte-sized");
+
+ llvm::Value *Val = Src.getScalarVal();
+ if (Val->getType()->getPrimitiveSizeInBits() <
+ ElemTy->getScalarSizeInBits())
+ Val = Builder.CreateZExt(Val, ElemTy->getScalarType());
+
+ llvm::Value *Idx = Dst.getMatrixIdx();
+ if (CGM.getCodeGenOpts().OptimizationLevel > 0) {
+ const auto *const MatTy =
Dst.getType()->castAs<ConstantMatrixType>();
----------------
Icohedron wrote:
It's fine; it's more concise. It's a const pointer to a const type.
Also this line is copy paste from the non-HLSL store to a MatrixElt LValue, so
I see no need to make it different.
https://github.com/llvm/llvm-project/pull/176216/changes#diff-09a56362f11b1d6447e14a762cd294e32c308ada102b6993fb968f14de8906c4L2721
https://github.com/llvm/llvm-project/pull/176216
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits