This is an archive of the discontinued LLVM Phabricator instance.

[HLSL] Support register binding attribute on global variable
ClosedPublic

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

Details

Summary

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 https://github.com/llvm/llvm-project/issues/57886.

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
clang/include/clang/Parse/Parser.h
2884–2885

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

clang/test/SemaHLSL/resource_binding_attr_error.hlsl
44
51

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

clang/test/SemaHLSL/resource_binding_attr_error.hlsl
51

Nice catch.
Never know you could do this.

aaron.ballman added inline comments.Oct 4 2022, 11:45 AM
clang/include/clang/Parse/Parser.h
2884–2885

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.
clang/include/clang/Parse/Parser.h
2884–2885

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.