[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
Mon Sep 9 17:24:33 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 {
----------------
bogner wrote:

We aren't doing methods sometimes and lambdas others, we have a method on the `OpLowerer` called `replaceFunction` that takes a lambda `ReplaceCall` that replaces an individual call, and then each kind of function we want to replace specializes behaviour through that. The idea here is that we can share the boilerplate for looping through the users, constructing an error message, and erasing the function itself once it's been replaced.

The other "obvious" way to structure this would be to have some kind of "FunctionReplacer" class that does the boilerplate and then subclass it for each of what are currently lambdas. I don't like this as much since it makes it harder to access the shared state of the OpLowerer in that model.

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


More information about the llvm-branch-commits mailing list