Skip to content

Commit 7f24f5d

Browse files
adding aditional data to attributes
1 parent 1abebd3 commit 7f24f5d

File tree

5 files changed

+28
-2
lines changed

5 files changed

+28
-2
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4314,6 +4314,10 @@ def HLSLRootSignature: Attr {
43144314
ErrorDiag, "'function'">;
43154315
let LangOpts = [HLSL];
43164316
let Documentation = [HLSLLoopHintDocs];
4317+
let AdditionalMembers = [{
4318+
public:
4319+
llvm::hlsl::HLSLRootElement Elements;
4320+
}];
43174321
}
43184322

43194323
def CapturedRecord : InheritableAttr {

clang/include/clang/Sema/HLSLRootSignature.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ struct RSTknInfo {
4242
class RootSignaturParser {
4343

4444
public:
45-
RootSignaturParser(StringRef Signature) : Signature(Signature) {}
45+
RootSignaturParser(HLSLRootSignatureAttr *Attr, StringRef Signature)
46+
: Signature(Signature), Attr(Attr) {}
4647

4748
void ParseRootDefinition();
4849

4950
private:
5051
StringRef Signature;
52+
HLSLRootSignatureAttr *Attr;
5153

5254
RSTknInfo CurTok;
5355
std::string IdentifierStr;

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,9 +712,14 @@ void SemaHLSL::handleHLSLRootSignature(Decl *D, const ParsedAttr &AL) {
712712
if (!SemaRef.checkStringLiteralArgumentAttr(AL, 0, Signature))
713713
return;
714714

715-
RootSignaturParser Parser(Signature);
715+
HLSLRootSignatureAttr *NewAttr = ::new (getASTContext())
716+
HLSLRootSignatureAttr(getASTContext(), AL, Signature);
716717

718+
RootSignaturParser Parser(NewAttr, Signature);
717719
Parser.ParseRootDefinition();
720+
721+
if (NewAttr)
722+
D->addAttr(NewAttr);
718723
}
719724

720725
void SemaHLSL::handleWaveSizeAttr(Decl *D, const ParsedAttr &AL) {

llvm/include/llvm/Frontend/HLSL/HLSLResource.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ class FrontendResource {
4444
uint32_t getSpace();
4545
MDNode *getMetadata() { return Entry; }
4646
};
47+
48+
class HLSLRootElement {
49+
public:
50+
HLSLRootElement() {}
51+
StringRef getName();
52+
53+
~HLSLRootElement() {}
54+
};
55+
56+
class HLSLRootFlag : public HLSLRootElement {
57+
public:
58+
std::size_t Flag = 0x111;
59+
};
4760
} // namespace hlsl
4861
} // namespace llvm
4962

llvm/lib/Frontend/HLSL/HLSLResource.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,5 @@ FrontendResource::FrontendResource(GlobalVariable *GV, ResourceKind RK,
6767
ConstantAsMetadata::get(B.getInt32(ResIndex)),
6868
ConstantAsMetadata::get(B.getInt32(Space))});
6969
}
70+
71+
llvm::StringRef llvm::hlsl::HLSLRootElement::getName() { return StringRef(""); }

0 commit comments

Comments
 (0)