aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/ASTWriterStmt.cpp
diff options
context:
space:
mode:
authorChris B <chris.bieneman@me.com>2024-08-31 10:59:08 -0500
committerGitHub <noreply@github.com>2024-08-31 10:59:08 -0500
commit89fb8490a99e612f7a574e8678b21a90f689f5b4 (patch)
tree213165d8d6b5bc6c0bd0cca5ce2ff30b144a4df8 /clang/lib/Serialization/ASTWriterStmt.cpp
parente41579a31f77008eb76c418df5d192d0974421d2 (diff)
downloadllvm-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/Serialization/ASTWriterStmt.cpp')
-rw-r--r--clang/lib/Serialization/ASTWriterStmt.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp
index c292d0a..8371366 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -2911,6 +2911,19 @@ void ASTStmtWriter::VisitOpenACCLoopConstruct(OpenACCLoopConstruct *S) {
}
//===----------------------------------------------------------------------===//
+// HLSL Constructs/Directives.
+//===----------------------------------------------------------------------===//
+
+void ASTStmtWriter::VisitHLSLOutArgExpr(HLSLOutArgExpr *S) {
+ VisitExpr(S);
+ Record.AddStmt(S->getOpaqueArgLValue());
+ Record.AddStmt(S->getCastedTemporary());
+ Record.AddStmt(S->getWritebackCast());
+ Record.writeBool(S->isInOut());
+ Code = serialization::EXPR_HLSL_OUT_ARG;
+}
+
+//===----------------------------------------------------------------------===//
// ASTWriter Implementation
//===----------------------------------------------------------------------===//