diff options
author | Chris B <chris.bieneman@me.com> | 2024-08-31 10:59:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-31 10:59:08 -0500 |
commit | 89fb8490a99e612f7a574e8678b21a90f689f5b4 (patch) | |
tree | 213165d8d6b5bc6c0bd0cca5ce2ff30b144a4df8 /clang/lib/CodeGen/CodeGenFunction.h | |
parent | e41579a31f77008eb76c418df5d192d0974421d2 (diff) | |
download | llvm-89fb8490a99e612f7a574e8678b21a90f689f5b4.zip llvm-89fb8490a99e612f7a574e8678b21a90f689f5b4.tar.gz llvm-89fb8490a99e612f7a574e8678b21a90f689f5b4.tar.bz2 |
[HLSL] Implement output parameter (#101083)
HLSL output parameters are denoted with the `inout` and `out` keywords
in the function declaration. When an argument to an output parameter is
constructed a temporary value is constructed for the argument.
For `inout` pamameters the argument is initialized via copy-initialization
from the argument lvalue expression to the parameter type. For `out`
parameters the argument is not initialized before the call.
In both cases on return of the function the temporary value is written
back to the argument lvalue expression through an implicit assignment
binary operator with casting as required.
This change introduces a new HLSLOutArgExpr ast node which represents
the output argument behavior. The OutArgExpr has three defined children:
- An OpaqueValueExpr of the argument lvalue expression.
- An OpaqueValueExpr of the copy-initialized parameter.
- A BinaryOpExpr assigning the first with the value of the second.
Fixes #87526
---------
Co-authored-by: Damyan Pepper <damyanp@microsoft.com>
Co-authored-by: John McCall <rjmccall@gmail.com>
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 05f85f8b..368fc11 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -2927,6 +2927,11 @@ public: void EmitAnyExprToExn(const Expr *E, Address Addr); + /// EmitInitializationToLValue - Emit an initializer to an LValue. + void EmitInitializationToLValue( + const Expr *E, LValue LV, + AggValueSlot::IsZeroed_t IsZeroed = AggValueSlot::IsNotZeroed); + /// EmitExprAsInit - Emits the code necessary to initialize a /// location in memory with the given initializer. void EmitExprAsInit(const Expr *init, const ValueDecl *D, LValue lvalue, @@ -4294,6 +4299,8 @@ public: LValue EmitCastLValue(const CastExpr *E); LValue EmitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E); LValue EmitOpaqueValueLValue(const OpaqueValueExpr *e); + void EmitHLSLOutArgExpr(const HLSLOutArgExpr *E, CallArgList &Args, + QualType Ty); Address EmitExtVectorElementLValue(LValue V); |