Skip to content

Commit 9408f86

Browse files
committed
update RootSignatureDecl to store version
1 parent 8c2fd96 commit 9408f86

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

clang/include/clang/AST/Decl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5179,6 +5179,8 @@ class HLSLRootSignatureDecl final
51795179
llvm::hlsl::rootsig::RootElement> {
51805180
friend TrailingObjects;
51815181

5182+
llvm::dxil::RootSignatureVersion RootSigVer;
5183+
51825184
unsigned NumElems;
51835185

51845186
llvm::hlsl::rootsig::RootElement *getElems() { return getTrailingObjects(); }
@@ -5188,16 +5190,20 @@ class HLSLRootSignatureDecl final
51885190
}
51895191

51905192
HLSLRootSignatureDecl(DeclContext *DC, SourceLocation Loc, IdentifierInfo *ID,
5193+
llvm::dxil::RootSignatureVersion RootSigVer,
51915194
unsigned NumElems);
51925195

51935196
public:
51945197
static HLSLRootSignatureDecl *
51955198
Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, IdentifierInfo *ID,
5199+
llvm::dxil::RootSignatureVersion RootSigVer,
51965200
ArrayRef<llvm::hlsl::rootsig::RootElement> RootElements);
51975201

51985202
static HLSLRootSignatureDecl *CreateDeserialized(ASTContext &C,
51995203
GlobalDeclID ID);
52005204

5205+
llvm::dxil::RootSignatureVersion getVersion() const { return RootSigVer; }
5206+
52015207
ArrayRef<llvm::hlsl::rootsig::RootElement> getRootElements() const {
52025208
return {getElems(), NumElems};
52035209
}

clang/lib/AST/Decl.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5853,21 +5853,21 @@ bool HLSLBufferDecl::buffer_decls_empty() {
58535853
// HLSLRootSignatureDecl Implementation
58545854
//===----------------------------------------------------------------------===//
58555855

5856-
HLSLRootSignatureDecl::HLSLRootSignatureDecl(DeclContext *DC,
5857-
SourceLocation Loc,
5858-
IdentifierInfo *ID,
5859-
unsigned NumElems)
5856+
HLSLRootSignatureDecl::HLSLRootSignatureDecl(
5857+
DeclContext *DC, SourceLocation Loc, IdentifierInfo *ID,
5858+
llvm::dxil::RootSignatureVersion RootSigVer, unsigned NumElems)
58605859
: NamedDecl(Decl::Kind::HLSLRootSignature, DC, Loc, DeclarationName(ID)),
5861-
NumElems(NumElems) {}
5860+
RootSigVer(RootSigVer), NumElems(NumElems) {}
58625861

58635862
HLSLRootSignatureDecl *HLSLRootSignatureDecl::Create(
58645863
ASTContext &C, DeclContext *DC, SourceLocation Loc, IdentifierInfo *ID,
5864+
llvm::dxil::RootSignatureVersion RootSigVer,
58655865
ArrayRef<llvm::hlsl::rootsig::RootElement> RootElements) {
58665866
HLSLRootSignatureDecl *RSDecl =
58675867
new (C, DC,
58685868
additionalSizeToAlloc<llvm::hlsl::rootsig::RootElement>(
58695869
RootElements.size()))
5870-
HLSLRootSignatureDecl(DC, Loc, ID, RootElements.size());
5870+
HLSLRootSignatureDecl(DC, Loc, ID, RootSigVer, RootElements.size());
58715871
auto *StoredElems = RSDecl->getElems();
58725872
std::uninitialized_copy(RootElements.begin(), RootElements.end(),
58735873
StoredElems);
@@ -5876,8 +5876,10 @@ HLSLRootSignatureDecl *HLSLRootSignatureDecl::Create(
58765876

58775877
HLSLRootSignatureDecl *
58785878
HLSLRootSignatureDecl::CreateDeserialized(ASTContext &C, GlobalDeclID ID) {
5879-
HLSLRootSignatureDecl *Result = new (C, ID)
5880-
HLSLRootSignatureDecl(nullptr, SourceLocation(), nullptr, /*NumElems=*/0);
5879+
HLSLRootSignatureDecl *Result = new (C, ID) HLSLRootSignatureDecl(
5880+
nullptr, SourceLocation(), nullptr,
5881+
/*RootSigVer*/ llvm::dxil::RootSignatureVersion::rootsig_1_0,
5882+
/*NumElems=*/0);
58815883
return Result;
58825884
}
58835885

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ void SemaHLSL::ActOnFinishRootSignatureDecl(
997997

998998
auto *SignatureDecl = HLSLRootSignatureDecl::Create(
999999
SemaRef.getASTContext(), /*DeclContext=*/SemaRef.CurContext, Loc,
1000-
DeclIdent, Elements);
1000+
DeclIdent, SemaRef.getLangOpts().HLSLRootSigVer, Elements);
10011001

10021002
SignatureDecl->setImplicit();
10031003
SemaRef.PushOnScopeChains(SignatureDecl, SemaRef.getCurScope());

0 commit comments

Comments
 (0)