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

John McCall via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 30 14:58:05 PDT 2024


================
@@ -5432,6 +5434,57 @@ LValue CodeGenFunction::EmitOpaqueValueLValue(const OpaqueValueExpr *e) {
   return getOrCreateOpaqueLValueMapping(e);
 }
 
+LValue CodeGenFunction::BindHLSLOutArgExpr(const HLSLOutArgExpr *E,
+                                           Address OutTemp) {
+  LValue Result = MakeAddrLValue(OutTemp, E->getType());
+  OpaqueValueMappingData::bind(*this, E->getCastedTemporary(), Result);
+  return Result;
+}
+
+void CodeGenFunction::EmitHLSLOutArgExpr(const HLSLOutArgExpr *E,
+                                         CallArgList &Args, QualType Ty) {
+
+  // Emitting the casted temporary through an opaque value.
+  LValue BaseLV = EmitLValue(E->getArgLValue());
+  OpaqueValueMappingData::bind(*this, E->getOpaqueArgLValue(), BaseLV);
+
+  LValue TempLV;
+
+  if (E->isInOut()) {
----------------
rjmccall wrote:

I was hoping you'd extract that as a helper function you'd just call rather than duplicating the logic here.

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


More information about the cfe-commits mailing list