[llvm-branch-commits] [DirectX] Lower `@llvm.dx.typedBufferStore` to DXIL ops (PR #104253)

Justin Bogner via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Aug 15 03:05:52 PDT 2024


================
@@ -289,6 +289,43 @@ class OpLowerer {
     });
   }
 
+  void lowerTypedBufferStore(Function &F) {
+    IRBuilder<> &IRB = OpBuilder.getIRB();
+    Type *Int8Ty = IRB.getInt8Ty();
+    Type *Int32Ty = IRB.getInt32Ty();
+
+    replaceFunction(F, [&](CallInst *CI) -> Error {
+      IRB.SetInsertPoint(CI);
+
+      Value *Handle =
+          createTmpHandleCast(CI->getArgOperand(0), OpBuilder.getHandleType());
+      Value *Index0 = CI->getArgOperand(1);
+      Value *Index1 = UndefValue::get(Int32Ty);
+      // For typed stores, the mask must always cover all four elements.
+      Constant *Mask = ConstantInt::get(Int8Ty, 0xF);
+
+      Value *Data = CI->getArgOperand(2);
----------------
bogner wrote:

The argument to `typedBufferStore` must be a vector of 4 elements, as we must store 16 bytes exactly. The only exception to this is a vector of 2 doubles, which isn't supported yet (I've filed #104423 for that).

That said, it'd probably be nice to get decent errors here if we get bad textual IR or a frontend other than clang messes up, so I've added better errors in the latest.

https://github.com/llvm/llvm-project/pull/104253


More information about the llvm-branch-commits mailing list