summaryrefslogtreecommitdiff
path: root/clang/test/CodeGenHLSL/BasicFeatures
AgeCommit message (Collapse)Author
2025-11-04[HLSL] Layout Initalizer list in Column order via index conversion (#166277)Farzon Lotfi
fixes #165663 The bug was that we were using the initalizer lists index to populate the matrix. This meant that [0..n] would coorelate to [0..n] indicies of the flattened matrix. Hence why we were seeing the Row-major order: [ 0 1 2 3 4 5 ]. To fix this we can simply converted these indicies to the Column-major order: [ 0 3 1 4 2 5 ]. The net effect of this is the layout of the matrix is now correct and we don't need to change the MatrixSubscriptExpr indexing scheme. --------- Co-authored-by: Deric C. <cheung.deric@gmail.com> Co-authored-by: Helena Kotas <hekotas@microsoft.com>
2025-10-31[HLSL] Add NativeInt16Type langopt to control whether short type is ↵Sarah Spall
supported. Enabled by default for all but HLSL. (#165584) Add a new langopt NativeInt16Type to control support for 16 bit integers. Enable by default for all languages but HLSL. HLSL defines uint16_t and int16_t as a typedef of short. If -enable-16bit-types is not used, the typedefs don't exist so int16_t and uint16_t can't be used. However, short was still allowed. This change will produce an error 'unknown type name short' if -enable-16bit-types isn't used. Update failing tests. Add new test. Closes #81779
2025-10-06[HLSL] Fix vector list initialization (#161421)Chris B
This simplifies and cleans up the vector list initialization behavior. This simplifies the work we do in SemaInit by just relying on SemaHLSL's initialization list flattening. This change fixes some outstanding limitations by supporting structure to vector initialization, but re-introduces HLSL's limitations around overload resolution in initializers. --------- Co-authored-by: Helena Kotas <hekotas@microsoft.com>
2025-10-06[HLSL] Add support for elementwise and aggregate splat casting struct types ↵Sarah Spall
with bitfields (#161263) Adds support for elementwise and aggregate splat casting struct types with bitfields. Replacing existing Flattening function which used to produce a list of GEPs representing a flattened object with one that produces a list of LValues representing a flattened object. The LValues can be used by EmitStoreThroughLValue and EmitLoadOfLValue, ensuring bitfields are properly loaded and stored. This also simplifies the code in the elementwise and aggregate splat casting functions. Closes #125986
2025-09-23[HLSL] Enable InitList code to handle zero sized structs (#160355)Sarah Spall
Enable InitList code to handle zero sized structs; this includes structs with no fields and those with only unnamed bitfields. Closes #157920
2025-09-23[HLSL] avoid unnamed bit fields when dealing with InitLists in HLSL (#159212)Sarah Spall
In HLSL Init List code avoid initializing unnamed bitfields and avoid initializing using unnamed bit fields. Add tests. Closes #157922
2025-07-24[HLSL] Avoid putting the byval attribute on out and inout parameters (#150495)Deric C.
Fixes #148063 by preventing the ByVal attribute from being placed on out and inout function parameters which causes them to be eliminated by the Dead Store Elimination (DSE) pass.
2025-06-16[HLSL] Use hidden visibility for external linkage. (#140292)Steven Perron
Implements https://github.com/llvm/wg-hlsl/blob/main/proposals/0026-symbol-visibility.md. The change is to stop using the `hlsl.export` attribute. Instead, symbols with "program linkage" in HLSL will have export linkage with default visibility, and symbols with "external linkage" in HLSL will have export linkage with hidden visibility.
2025-05-05[HLSL] Handle init list with OpaqueValueExprs in CGExprScalar (#138541)Sarah Spall
When an HLSL Init list is producing a Scalar, handle OpaqueValueExprs in the Init List with 'emitInitListOpaqueValues' Copied from 'AggExprEmitter::VisitCXXParenListOrInitListExpr' Closes #136408 --------- Co-authored-by: Chris B <beanz@abolishcrlf.org>
2025-04-28[HLSL] Treat classes and structs as packed by default (#137391)Justin Bogner
Fixes #121010.
2025-04-10[HLSL] Add support for modulo of floating point scalar and vectors (#135125)Farzon Lotfi
fixes #135122 SemaExpr.cpp - Make all doubles fail. Add sema support for float scalars and vectors when language mode is HLSL. CGExprScalar.cpp - Allow emit frem when language mode is HLSL.
2025-03-11[HLSL] Make memory representation of boolean vectors in HLSL, vectors of ↵Sarah Spall
i32. Add support for boolean swizzling. (#123977) Make the memory representation of boolean vectors in HLSL, vectors of i32. Allow boolean swizzling for boolean vectors in HLSL. Add tests for boolean vectors and boolean vector swizzling. Closes #91639
2025-02-24[HLSL] Allow arrays to be returned by value in HLSL (#127896)Sarah Spall
Enable Arrays to be returned in HLSL, and a test for this. Closes #126568
2025-02-15[HLSL] Implement HLSL intialization list support (#123141)Chris B
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@users.noreply.github.com> Co-authored-by: Helena Kotas <hekotas@microsoft.com> Co-authored-by: Justin Bogner <mail@justinbogner.com>
2025-02-14[HLSL] Implement HLSL Aggregate splatting (#118992)Sarah Spall
Implement HLSL Aggregate Splat casting that handles splatting for arrays and structs, and vectors if splatting from a vec1. Closes #100609 and Closes #100619 Depends on #118842
2025-02-07[HLSL] Implement HLSL Elementwise casting (excluding splat cases); Re-land ↵Sarah Spall
#118842 (#126258) Implement HLSLElementwiseCast excluding support for splat cases Do not support casting types that contain bitfields. Partly closes https://github.com/llvm/llvm-project/issues/100609 and partly closes https://github.com/llvm/llvm-project/issues/100619 Re-land #118842 after fixing warning as an error, found by a buildbot.
2025-02-06Revert "[HLSL] Implement HLSL Flat casting (excluding splat cases)" (#126149)Sarah Spall
Reverts llvm/llvm-project#118842
2025-02-06[HLSL] Implement HLSL Flat casting (excluding splat cases) (#118842)Sarah Spall
Implement HLSLElementwiseCast excluding support for splat cases Do not support casting types that contain bitfields. Partly closes #100609 and partly closes #100619
2025-01-09[HLSL] Make fast math the default for HLSL (#119820)Sarah Spall
Make fast math the default for HLSL Repair test cases broken by this change. Closes #108597
2024-12-03[HLSL] get inout/out ABI for array parameters working (#111047)Sarah Spall
Get inout/out parameters working for HLSL Arrays. Utilizes the fix from #109323, and corrects the assignment behavior slightly to allow for Non-LValues on the RHS. Closes #106917 --------- Co-authored-by: Chris B <beanz@abolishcrlf.org>
2024-11-06[LLVM][IR] Use splat syntax when printing Constant[Data]Vector. (#112548)Paul Walker
2024-10-10Switch DirectX Target to use the Itanium ABI (#111632)Greg Roth
To consolidate behavior of function mangling and limit the number of places that ABI changes will need to be made, this switches the DirectX target used for HLSL to use the Itanium ABI from the Microsoft ABI. The Itanium ABI has greater flexibility in decisions regarding mangling of new types of which we have more than a few yet to add. One effect of this will be that linking library shaders compiled with DXC will not be possible with shaders compiled with clang. That isn't considered a terribly interesting use case and one that would likely have been onerous to maintain anyway. This involved adding a function to call all global destructors as the Microsoft ABI had done. This requires a few changes to tests. Most notably the mangling style has changed which accounts for most of the changes. In making those changes, I took the opportunity to harmonize some very similar tests for greater consistency. I also shaved off some unneeded run flags that had probably been copied over from one test to another. Other changes effected by using the new ABI include using different types when manipulating smaller bitfields, eliminating an unnecessary alloca in one instance in this-assignment.hlsl, changing the way static local initialization is guarded, and changing the order of inout parameters getting copied in and out. That last is a subtle change in functionality, but one where there was sufficient inconsistency in the past that standardizing is important, but the particular direction of the standardization is less important for the sake of existing shaders. fixes #110736
2024-09-20[CVP] Infer range return attribute (#99620)Nikita Popov
We already infer this in IPSCCP (which runs very early, so cannot benefit from inlining and simplifications) and SCCP (which runs without PredicateInfo, so does not use assumes). Do it in CVP as well, so it can handle cases that IPSCCP/SCCP can't. Fixes https://github.com/llvm/llvm-project/issues/98946 (everything apart from f2, where the assume is dropped by the frontend).
2024-09-11[HLSL] Allow truncation to scalar (#104844)Chris B
HLSL allows implicit conversions to truncate vectors to scalar pr-values. These conversions are scored as vector truncations and should warn appropriately. This change allows forming a truncation cast to a pr-value, but not an l-value. Truncating a vector to a scalar is performed by loading the first element of the vector and disregarding the remaining elements. Fixes #102964
2024-08-31[HLSL] Implement output parameter (#101083)Chris B
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>
2024-07-13[HLSL] Rework implicit conversion sequences (#96011)Chris B
This PR reworks HLSL's implicit conversion sequences. Initially I was seeking to match DXC's behavior more closely, but that was leading to a pile of special case rules to tie-break ambiguous cases that should really be left as ambiguous. We've decided that we're going to break compatibility with DXC here, and we may port this new behavior over to DXC instead. This change is a bit closer to C++'s overload resolution rules, but it does have a bit of nuance around how dimension adjustment conversions are ranked. Conversion sequence ranks for HLSL are: * Exact match * Scalar Widening (i.e. splat) * Promotion * Scalar Widening with Promotion * Conversion * Scalar Widening with Conversion * Dimension Reduction (i.e. truncation) * Dimension Reduction with Promotion * Dimension Reduction with Conversion In this implementation I've folded the disambiguation into the conversion sequence ranks which does add some complexity as compared to C++, however this avoids needing to add special casing in `CompareStandardConversionSequences`. I believe the added conversion rank values provide a simpler approach, but feedback is appreciated. The HLSL language spec updates are in the PR here: https://github.com/microsoft/hlsl-specs/pull/261
2024-02-15[HLSL] Vector standard conversions (#71098)Chris B
HLSL supports vector truncation and element conversions as part of standard conversion sequences. The vector truncation conversion is a C++ second conversion in the conversion sequence. If a vector truncation is in a conversion sequence an element conversion may occur after it before the standard C++ third conversion. Vector element conversions can be boolean conversions, floating point or integral conversions or promotions. [HLSL Draft Specification](https://microsoft.github.io/hlsl-specs/specs/hlsl.pdf) --------- Co-authored-by: Aaron Ballman <aaron@aaronballman.com>