This is an archive of the discontinued LLVM Phabricator instance.

[HLSL] Support register binding attribute on global variable

Authored by python3kgae on Sep 25 2022, 5:42 PM.



Allow register binding attribute on variables.

Report warning when register binding attribute applies to local variable or static variable.
It will be ignored in this case.

Type check for register binding is tracked with

Diff Detail

Event Timeline

python3kgae created this revision.Sep 25 2022, 5:42 PM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: Anastasia. · View Herald Transcript
python3kgae requested review of this revision.Sep 25 2022, 5:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 25 2022, 5:42 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Remove empty line.

aaron.ballman added inline comments.Sep 30 2022, 10:42 AM

Let's assert we're in HLSL mode here so that we don't accidentally call this from non-HLSL parsing contexts.


Let's add another test for a local extern, like:

void func() {
  extern RWBuffer<float> U : register(u5);
python3kgae marked 3 inline comments as done.

Ignore local extern decl when check ExternalGlobalVar


Nice catch.
Never know you could do this.

aaron.ballman added inline comments.Oct 4 2022, 11:45 AM

Precommit CI finds a way to trigger this assert, so it looks like we caught a case we didn't know about (yay asserts!).

Limit MaybeParseHLSLSemantics to HLSL.

python3kgae marked an inline comment as done.Oct 4 2022, 1:21 PM
python3kgae added inline comments.

Yeah. Pre-commit CI is really cool. :)

It would be nice if there's an optional config so we can let it test experimental targets too.

This revision is now accepted and ready to land.Oct 5 2022, 5:53 AM
This revision was automatically updated to reflect the committed changes.
python3kgae marked an inline comment as done.