-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attach resource attributes to handle within record, instead of record #101433
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b17ddcc
add attrs to handle in record decl, add ast dump test to verify
bob80905 df4db59
clang format
bob80905 5885434
update ast test
bob80905 16fc4c7
pass attrs to add to addmembervar fxn
bob80905 6fa2c42
use const ref
bob80905 2987266
Update clang/lib/Sema/HLSLExternalSemaSource.cpp
bob80905 f303bd1
use array ref
bob80905 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,7 @@ struct BuiltinTypeDeclBuilder { | |
|
||
BuiltinTypeDeclBuilder & | ||
addMemberVariable(StringRef Name, QualType Type, | ||
const llvm::SmallVector<Attr *, 2> &Attrs, | ||
bob80905 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
AccessSpecifier Access = AccessSpecifier::AS_private) { | ||
if (Record->isCompleteDefinition()) | ||
return *this; | ||
|
@@ -96,13 +97,16 @@ struct BuiltinTypeDeclBuilder { | |
nullptr, false, InClassInitStyle::ICIS_NoInit); | ||
Field->setAccess(Access); | ||
Field->setImplicit(true); | ||
for (Attr *A : Attrs) | ||
Field->addAttr(A); | ||
Record->addDecl(Field); | ||
Fields[Name] = Field; | ||
return *this; | ||
} | ||
|
||
BuiltinTypeDeclBuilder & | ||
addHandleMember(AccessSpecifier Access = AccessSpecifier::AS_private) { | ||
addHandleMember(ResourceClass RC, ResourceKind RK, bool IsROV, | ||
AccessSpecifier Access = AccessSpecifier::AS_private) { | ||
if (Record->isCompleteDefinition()) | ||
return *this; | ||
QualType Ty = Record->getASTContext().VoidPtrTy; | ||
|
@@ -112,17 +116,13 @@ struct BuiltinTypeDeclBuilder { | |
Ty = Record->getASTContext().getPointerType( | ||
QualType(TTD->getTypeForDecl(), 0)); | ||
} | ||
return addMemberVariable("h", Ty, Access); | ||
} | ||
|
||
BuiltinTypeDeclBuilder &annotateHLSLResource(ResourceClass RC, | ||
ResourceKind RK, bool IsROV) { | ||
if (Record->isCompleteDefinition()) | ||
return *this; | ||
Record->addAttr( | ||
// add handle member | ||
llvm::SmallVector<Attr *, 2> Attrs; | ||
Attrs.push_back( | ||
HLSLResourceClassAttr::CreateImplicit(Record->getASTContext(), RC)); | ||
Record->addAttr( | ||
Attrs.push_back( | ||
HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RK, IsROV)); | ||
addMemberVariable("h", Ty, Attrs, Access); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the change to use Attr *ResourceClassAttr =
HLSLResourceClassAttr::CreateImplicit(Record->getASTContext(), RC);
Attr *ResourceAttr =
HLSLResourceClassAttr::CreateImplicit(Record->getASTContext(), RC);
addMemberVariable("h", Ty, {ResourceClassAttr, ResourceAttr}, Access); |
||
return *this; | ||
} | ||
|
||
|
@@ -489,9 +489,8 @@ static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl *Decl, Sema &S, | |
ResourceClass RC, ResourceKind RK, | ||
bool IsROV) { | ||
return BuiltinTypeDeclBuilder(Decl) | ||
.addHandleMember() | ||
.addDefaultHandleConstructor(S, RC) | ||
.annotateHLSLResource(RC, RK, IsROV); | ||
.addHandleMember(RC, RK, IsROV) | ||
.addDefaultHandleConstructor(S, RC); | ||
} | ||
|
||
void HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -ast-dump -o - %s | FileCheck %s | ||
|
||
// CHECK: -ClassTemplateDecl 0x{{[0-9a-f]+}} <<invalid sloc>> <invalid sloc> implicit RWBuffer | ||
// CHECK: -CXXRecordDecl 0x{{[0-9a-f]+}} <<invalid sloc>> <invalid sloc> implicit class RWBuffer definition | ||
// CHECK: -FieldDecl 0x{{[0-9a-f]+}} <<invalid sloc>> <invalid sloc> implicit h 'element_type *' | ||
// CHECK: -HLSLResourceClassAttr 0x{{[0-9a-f]+}} <<invalid sloc>> Implicit UAV | ||
// CHECK: -HLSLResourceAttr 0x{{[0-9a-f]+}} <<invalid sloc>> Implicit TypedBuffer | ||
RasterizerOrderedBuffer<vector<float, 4> > BufferArray3[4] : register(u4, space1); | ||
|
||
// CHECK: -ClassTemplateSpecializationDecl 0x{{[0-9a-f]+}} <<invalid sloc>> <invalid sloc> class RWBuffer definition implicit_instantiation | ||
// CHECK: -FieldDecl 0x{{[0-9a-f]+}} <<invalid sloc>> <invalid sloc> implicit referenced h 'float *' | ||
// CHECK: -HLSLResourceClassAttr 0x{{[0-9a-f]+}} <<invalid sloc>> Implicit UAV | ||
// CHECK: -HLSLResourceAttr 0x{{[0-9a-f]+}} <<invalid sloc>> Implicit TypedBuffer | ||
RWBuffer<float> Buffer1; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is too remedial, but for someone with my limited experience a comment along the lines of "If this variable's type is actually an HLSL resource then annotate it appropriately" would have helped me greatly in understanding it.