[all-commits] [llvm/llvm-project] 761d42: [HLSL] Implement HLSL intialization list support (...
Chris B via All-commits
all-commits at lists.llvm.org
Sat Feb 15 11:21:57 PST 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 761d422441c0e6822abb233d339fab4f3cf7f60a
https://github.com/llvm/llvm-project/commit/761d422441c0e6822abb233d339fab4f3cf7f60a
Author: Chris B <chris.bieneman at me.com>
Date: 2025-02-15 (Sat, 15 Feb 2025)
Changed paths:
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/include/clang/Sema/SemaHLSL.h
M clang/lib/AST/DeclCXX.cpp
M clang/lib/CodeGen/CGExpr.cpp
M clang/lib/CodeGen/CGExprAgg.cpp
M clang/lib/CodeGen/CGHLSLRuntime.cpp
M clang/lib/CodeGen/CGHLSLRuntime.h
M clang/lib/CodeGen/CodeGenFunction.h
M clang/lib/Sema/SemaChecking.cpp
M clang/lib/Sema/SemaHLSL.cpp
M clang/lib/Sema/SemaInit.cpp
M clang/test/CodeGenHLSL/ArrayTemporary.hlsl
A clang/test/CodeGenHLSL/BasicFeatures/InitLists.hlsl
M clang/test/SemaHLSL/ArrayTemporary.hlsl
M clang/test/SemaHLSL/Language/ElementwiseCast-errors.hlsl
A clang/test/SemaHLSL/Language/InitListAST.hlsl
A clang/test/SemaHLSL/Language/InitLists.hlsl
Log Message:
-----------
[HLSL] Implement HLSL intialization list support (#123141)
This PR implements HLSL's initialization list behvaior as specified in
the draft language specifcation under
[*Decl.Init.Agg*](https://microsoft.github.io/hlsl-specs/specs/hlsl.html#Decl.Init.Agg).
This behavior is a bit unusual for C/C++ because intermediate braces in
initializer lists are ignored and a whole array of additional
conversions occur unintuitively to how initializaiton works in C.
The implementaiton in this PR generates a valid C/C++ initialization
list AST for the HLSL initializer so that there are no changes required
to Clang's CodeGen to support this. This design will also allow us to
use Clang's rewrite to convert HLSL initializers to valid C/C++
initializers that are equivalent. It does have the downside that it will
generate often redundant accesses during codegen. The IR optimizer is
extremely good at eliminating those so this will have no impact on the
final executable performance.
There is some opportunity for optimizing the initializer list generation
that we could consider in subsequent commits. One notable opportunity
would be to identify aggregate objects that occur in the same place in
both initializers and do not require converison, those aggregates could
be initialized as aggregates rather than fully scalarized.
Closes #56067
---------
Co-authored-by: Finn Plummer <50529406+inbelic at users.noreply.github.com>
Co-authored-by: Helena Kotas <hekotas at microsoft.com>
Co-authored-by: Justin Bogner <mail at justinbogner.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list