Commit dba8507
authored
[HLSL] Rework semantic handling as attributes (#166796)
Previously, we had 2 level of attributes:
- HLSLUnparsedSemantic
- N attributes, one for each known system semantic.
The first was assigned during parsing, and carried no other meaning than
"there is a semantic token". It was then converted to one of the N
attributes later during Sema.
Those attributes also carried informations like "is indexable" or "is
index explicit".
This had a few issues:
- there was no difference between a semantic attribute applied to a
decl, and the effective semantic in the entrypoint use context.
- having the indexable bit was not useful.
- semantic constraints checks were split between .td files and sema.
Also, existing implementation had effective attributes attached to the
type decl or parameters, meaning struct decl reuse across entrypoints of
in a nested type was not supported, even if legal in HLSL.
This PR tried to simplifies semantic attribute by having 3 attributes:
- HLSLUnpasedSemantic
- HLSLParsedSemantic
- HLSLAppliedSemantic
Initial parsing emits an `HLSLUnparsedSemantic`. We simply say "here is
an HLSL semantic token", but we don't do any semantic check.
Then, Sema does initial validation and transforms an UnparseSemantic
into a ParsedSemantic. This validates a system semantic is known, or
that the associated type is valid (like uint3 for a ThreadIndex).
Then, once we parse an actual shader entrypoint, we can know how
semantics are used in a real context. This step emits a list of
AppliedSemantic. Those are the actual semantic in use for this specific
entrypoint.
Those attributes are attached to each entrypoint parameter, as a flat
list matching the semantic structure flattening HLSL defines. At this
stage of sema, index collision or other stage compabitility checkes are
carried.
This allows codegen to simply iterate over this list and emit the proper
DXIL or SPIR-V codegen.1 parent 9ba738a commit dba8507
File tree
20 files changed
+277
-365
lines changed- clang
- include/clang
- AST
- Basic
- Sema
- lib
- CodeGen
- Sema
- test
- CodeGenHLSL/semantics
- ParserHLSL
- SemaHLSL/Semantics
- TableGen
- utils/TableGen
20 files changed
+277
-365
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
| 236 | + | |
245 | 237 | | |
246 | | - | |
247 | | - | |
248 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
249 | 241 | | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
| 242 | + | |
254 | 243 | | |
255 | 244 | | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | 245 | | |
271 | 246 | | |
272 | | - | |
273 | | - | |
| 247 | + | |
| 248 | + | |
274 | 249 | | |
275 | 250 | | |
276 | 251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
783 | 783 | | |
784 | 784 | | |
785 | 785 | | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | | - | |
792 | | - | |
793 | | - | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | | - | |
798 | 786 | | |
799 | 787 | | |
800 | 788 | | |
| |||
5021 | 5009 | | |
5022 | 5010 | | |
5023 | 5011 | | |
5024 | | - | |
5025 | | - | |
5026 | | - | |
5027 | | - | |
5028 | | - | |
5029 | | - | |
5030 | | - | |
| 5012 | + | |
| 5013 | + | |
5031 | 5014 | | |
5032 | | - | |
5033 | | - | |
5034 | | - | |
| 5015 | + | |
| 5016 | + | |
| 5017 | + | |
5035 | 5018 | | |
5036 | | - | |
5037 | | - | |
| 5019 | + | |
5038 | 5020 | | |
5039 | 5021 | | |
5040 | | - | |
5041 | | - | |
| 5022 | + | |
| 5023 | + | |
| 5024 | + | |
| 5025 | + | |
| 5026 | + | |
5042 | 5027 | | |
5043 | 5028 | | |
5044 | | - | |
5045 | | - | |
| 5029 | + | |
| 5030 | + | |
| 5031 | + | |
| 5032 | + | |
| 5033 | + | |
5046 | 5034 | | |
5047 | 5035 | | |
5048 | 5036 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8672 | 8672 | | |
8673 | 8673 | | |
8674 | 8674 | | |
8675 | | - | |
8676 | | - | |
8677 | | - | |
8678 | | - | |
8679 | | - | |
8680 | | - | |
8681 | | - | |
8682 | | - | |
8683 | | - | |
8684 | | - | |
8685 | | - | |
8686 | | - | |
8687 | | - | |
8688 | | - | |
8689 | | - | |
8690 | | - | |
8691 | | - | |
8692 | | - | |
8693 | | - | |
8694 | | - | |
8695 | | - | |
8696 | | - | |
8697 | | - | |
8698 | | - | |
8699 | | - | |
8700 | | - | |
8701 | | - | |
8702 | | - | |
8703 | | - | |
8704 | | - | |
8705 | | - | |
8706 | | - | |
8707 | 8675 | | |
8708 | 8676 | | |
8709 | 8677 | | |
| |||
8750 | 8718 | | |
8751 | 8719 | | |
8752 | 8720 | | |
8753 | | - | |
8754 | | - | |
8755 | | - | |
8756 | | - | |
8757 | | - | |
8758 | | - | |
8759 | | - | |
8760 | | - | |
8761 | | - | |
8762 | | - | |
8763 | | - | |
8764 | | - | |
8765 | | - | |
8766 | | - | |
8767 | | - | |
8768 | | - | |
8769 | | - | |
8770 | | - | |
8771 | | - | |
8772 | | - | |
8773 | | - | |
8774 | | - | |
8775 | | - | |
8776 | | - | |
8777 | | - | |
8778 | | - | |
8779 | | - | |
8780 | | - | |
8781 | | - | |
8782 | 8721 | | |
8783 | 8722 | | |
8784 | 8723 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
182 | 182 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
193 | 186 | | |
194 | 187 | | |
195 | 188 | | |
| |||
247 | 240 | | |
248 | 241 | | |
249 | 242 | | |
250 | | - | |
| 243 | + | |
251 | 244 | | |
252 | 245 | | |
253 | 246 | | |
| |||
257 | 250 | | |
258 | 251 | | |
259 | 252 | | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
264 | 257 | | |
265 | 258 | | |
266 | | - | |
267 | | - | |
| 259 | + | |
| 260 | + | |
268 | 261 | | |
269 | 262 | | |
270 | 263 | | |
| |||
0 commit comments