[clang] [HLSL] Implement output parameter (PR #101083)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 31 07:13:57 PDT 2024


================
@@ -5318,3 +5319,13 @@ OMPIteratorExpr *OMPIteratorExpr::CreateEmpty(const ASTContext &Context,
       alignof(OMPIteratorExpr));
   return new (Mem) OMPIteratorExpr(EmptyShell(), NumIterators);
 }
+
+HLSLOutArgExpr *HLSLOutArgExpr::Create(const ASTContext &C, QualType Ty,
+                                       Expr *Base, bool IsInOut, Expr *WB,
+                                       OpaqueValueExpr *OpV) {
+  return new (C) HLSLOutArgExpr(Ty, Base, WB, OpV, IsInOut);
----------------
llvm-beanz wrote:

Generally `C.Allocate` is used in contexts where the new operator won't know the full size you're allocating. In some AST nodes we allocate extra space after the node to store trailing pointers to sub-expressions. That can be valuable for reducing the size of the AST if a node can have a variable number of sub-expressions.

In this case we always have two sub-expressions, and we always have an `OpaqueValueExpr`. I could reduce the size of the AST node by not caching the `OpaqueValueExpr` and instead traversing down to it when we need it, but I'm unsure that memory savings is worthwhile.

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


More information about the cfe-commits mailing list