[all-commits] [llvm/llvm-project] 2630d7: [HLSL] Support vector swizzles on scalars (#67700)
Chris B via All-commits
all-commits at lists.llvm.org
Wed Nov 29 09:25:19 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 2630d72cb343fed771e505c1bb0e4f334aed66ce
https://github.com/llvm/llvm-project/commit/2630d72cb343fed771e505c1bb0e4f334aed66ce
Author: Chris B <chris.bieneman at me.com>
Date: 2023-11-29 (Wed, 29 Nov 2023)
Changed paths:
M clang/lib/CodeGen/CGExpr.cpp
M clang/lib/Lex/Lexer.cpp
M clang/lib/Lex/LiteralSupport.cpp
M clang/lib/Sema/SemaExprMember.cpp
A clang/test/CodeGenHLSL/builtins/ScalarSwizzles.hlsl
A clang/test/SemaHLSL/Types/BuiltinVector/ScalarSwizzleErrors.hlsl
A clang/test/SemaHLSL/Types/BuiltinVector/ScalarSwizzles.hlsl
Log Message:
-----------
[HLSL] Support vector swizzles on scalars (#67700)
HLSL supports vector swizzles on scalars by implicitly converting the
scalar to a single-element vector. This syntax is a convienent way to
initialize vectors based on filling a scalar value.
There are two parts of this change. The first part in the Lexer splits
numeric constant tokens when a `.x` or `.r` suffix is encountered. This
splitting is a bit hacky but allows the numeric constant to be parsed
separately from the vector element expression. There is an ambiguity
here with the `r` suffix used by fixed point types, however fixed point
types aren't supported in HLSL so this should not cause any exposable
problems (a separate issue has been filed to track validating language
options for HLSL: #67689).
The second part of this change is in Sema::LookupMemberExpr. For HLSL,
if the base type is a scalar, we implicit cast the scalar to a
one-element vector then call back to perform the vector lookup.
Fixes #56658 and #67511
More information about the All-commits
mailing list