Skip to content

Commit 6c2e22d

Browse files
committed
make semantics case insensitive. update tests. add new tests
1 parent 25713ed commit 6c2e22d

File tree

6 files changed

+47
-27
lines changed

6 files changed

+47
-27
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4724,21 +4724,21 @@ def HLSLNumThreads: InheritableAttr {
47244724
}
47254725

47264726
def HLSLSV_GroupThreadID: HLSLAnnotationAttr {
4727-
let Spellings = [HLSLAnnotation<"SV_GroupThreadID">];
4727+
let Spellings = [HLSLAnnotation<"sv_groupthreadid">];
47284728
let Subjects = SubjectList<[ParmVar, Field]>;
47294729
let LangOpts = [HLSL];
47304730
let Documentation = [HLSLSV_GroupThreadIDDocs];
47314731
}
47324732

47334733
def HLSLSV_GroupID: HLSLAnnotationAttr {
4734-
let Spellings = [HLSLAnnotation<"SV_GroupID">];
4734+
let Spellings = [HLSLAnnotation<"sv_groupid">];
47354735
let Subjects = SubjectList<[ParmVar, Field]>;
47364736
let LangOpts = [HLSL];
47374737
let Documentation = [HLSLSV_GroupIDDocs];
47384738
}
47394739

47404740
def HLSLSV_GroupIndex: HLSLAnnotationAttr {
4741-
let Spellings = [HLSLAnnotation<"SV_GroupIndex">];
4741+
let Spellings = [HLSLAnnotation<"sv_groupindex">];
47424742
let Subjects = SubjectList<[ParmVar, GlobalVar]>;
47434743
let LangOpts = [HLSL];
47444744
let Documentation = [HLSLSV_GroupIndexDocs];
@@ -4790,7 +4790,7 @@ def HLSLPackOffset: HLSLAnnotationAttr {
47904790
}
47914791

47924792
def HLSLSV_DispatchThreadID: HLSLAnnotationAttr {
4793-
let Spellings = [HLSLAnnotation<"SV_DispatchThreadID">];
4793+
let Spellings = [HLSLAnnotation<"sv_dispatchthreadid">];
47944794
let Subjects = SubjectList<[ParmVar, Field]>;
47954795
let LangOpts = [HLSL];
47964796
let Documentation = [HLSLSV_DispatchThreadIDDocs];

clang/lib/Parse/ParseHLSL.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ void Parser::ParseHLSLAnnotations(ParsedAttributes &Attrs,
141141
return;
142142
}
143143

144+
II = PP.getIdentifierInfo(II->getName().lower());
145+
144146
SourceLocation Loc = ConsumeToken();
145147
if (EndLoc)
146148
*EndLoc = Tok.getLocation();

clang/test/ParserHLSL/semantic_parsing.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
// expected-error@+1 {{expected HLSL Semantic identifier}}
44
void Entry(int GI : ) { }
55

6-
// expected-error@+1 {{unknown HLSL semantic 'SV_IWantAPony'}}
6+
// expected-error@+1 {{unknown HLSL semantic 'sv_iwantapony'}}
77
void Pony(int GI : SV_IWantAPony) { }

clang/test/SemaHLSL/Semantics/groupindex.hlsl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44
[shader("compute")][numthreads(32,1,1)]
55
void compute(int GI : SV_GroupIndex) {}
66

7-
// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'pixel' shaders}}
7+
// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'pixel' shaders}}
88
[shader("pixel")]
99
void pixel(int GI : SV_GroupIndex) {}
1010

11-
// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'vertex' shaders}}
11+
// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'vertex' shaders}}
1212
[shader("vertex")]
1313
void vertex(int GI : SV_GroupIndex) {}
1414

15-
// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'geometry' shaders}}
15+
// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'geometry' shaders}}
1616
[shader("geometry")]
1717
void geometry(int GI : SV_GroupIndex) {}
1818

19-
// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'domain' shaders}}
19+
// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'domain' shaders}}
2020
[shader("domain")]
2121
void domain(int GI : SV_GroupIndex) {}
2222

23-
// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'amplification' shaders}}
23+
// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'amplification' shaders}}
2424
[shader("amplification")][numthreads(32,1,1)]
2525
void amplification(int GI : SV_GroupIndex) {}
2626

27-
// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'mesh' shaders}}
27+
// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'mesh' shaders}}
2828
[shader("mesh")][numthreads(32,1,1)]
2929
void mesh(int GI : SV_GroupIndex) {}
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -finclude-default-header -x hlsl -ast-dump -verify -o - %s
22

33
[numthreads(8,8,1)]
4-
// expected-error@+1 {{attribute 'SV_DispatchThreadID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
4+
// expected-error@+1 {{attribute 'sv_dispatchthreadid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
55
void CSMain(float ID : SV_DispatchThreadID) {
66

77
}
@@ -11,71 +11,71 @@ struct ST {
1111
float b;
1212
};
1313
[numthreads(8,8,1)]
14-
// expected-error@+1 {{attribute 'SV_DispatchThreadID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
14+
// expected-error@+1 {{attribute 'sv_dispatchthreadid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
1515
void CSMain2(ST ID : SV_DispatchThreadID) {
1616

1717
}
1818

1919
void foo() {
20-
// expected-warning@+1 {{'SV_DispatchThreadID' attribute only applies to parameters and non-static data members}}
20+
// expected-warning@+1 {{'sv_dispatchthreadid' attribute only applies to parameters and non-static data members}}
2121
uint V : SV_DispatchThreadID;
2222

2323
}
2424

2525
struct ST2 {
26-
// expected-warning@+1 {{'SV_DispatchThreadID' attribute only applies to parameters and non-static data members}}
26+
// expected-warning@+1 {{'sv_dispatchthreadid' attribute only applies to parameters and non-static data members}}
2727
static uint X : SV_DispatchThreadID;
2828
uint s : SV_DispatchThreadID;
2929
};
3030

3131
[numthreads(8,8,1)]
32-
// expected-error@+1 {{attribute 'SV_GroupID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
32+
// expected-error@+1 {{attribute 'sv_groupid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
3333
void CSMain_GID(float ID : SV_GroupID) {
3434
}
3535

3636
[numthreads(8,8,1)]
37-
// expected-error@+1 {{attribute 'SV_GroupID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
37+
// expected-error@+1 {{attribute 'sv_groupid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
3838
void CSMain2_GID(ST GID : SV_GroupID) {
3939

4040
}
4141

4242
void foo_GID() {
43-
// expected-warning@+1 {{'SV_GroupID' attribute only applies to parameters and non-static data members}}
43+
// expected-warning@+1 {{'sv_groupid' attribute only applies to parameters and non-static data members}}
4444
uint GIS : SV_GroupID;
4545
}
4646

4747
struct ST2_GID {
48-
// expected-warning@+1 {{'SV_GroupID' attribute only applies to parameters and non-static data members}}
48+
// expected-warning@+1 {{'sv_groupid' attribute only applies to parameters and non-static data members}}
4949
static uint GID : SV_GroupID;
5050
uint s_gid : SV_GroupID;
5151
};
5252

5353
[numthreads(8,8,1)]
54-
// expected-error@+1 {{attribute 'SV_GroupThreadID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
54+
// expected-error@+1 {{attribute 'sv_groupthreadid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
5555
void CSMain_GThreadID(float ID : SV_GroupThreadID) {
5656
}
5757

5858
[numthreads(8,8,1)]
59-
// expected-error@+1 {{attribute 'SV_GroupThreadID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
59+
// expected-error@+1 {{attribute 'sv_groupthreadid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
6060
void CSMain2_GThreadID(ST GID : SV_GroupThreadID) {
6161

6262
}
6363

6464
void foo_GThreadID() {
65-
// expected-warning@+1 {{'SV_GroupThreadID' attribute only applies to parameters and non-static data members}}
65+
// expected-warning@+1 {{'sv_groupthreadid' attribute only applies to parameters and non-static data members}}
6666
uint GThreadIS : SV_GroupThreadID;
6767
}
6868

6969
struct ST2_GThreadID {
70-
// expected-warning@+1 {{'SV_GroupThreadID' attribute only applies to parameters and non-static data members}}
70+
// expected-warning@+1 {{'sv_groupthreadid' attribute only applies to parameters and non-static data members}}
7171
static uint GThreadID : SV_GroupThreadID;
7272
uint s_gthreadid : SV_GroupThreadID;
7373
};
7474

7575

7676
[shader("vertex")]
77-
// expected-error@+4 {{attribute 'SV_GroupIndex' is unsupported in 'vertex' shaders, requires compute}}
78-
// expected-error@+3 {{attribute 'SV_DispatchThreadID' is unsupported in 'vertex' shaders, requires compute}}
79-
// expected-error@+2 {{attribute 'SV_GroupID' is unsupported in 'vertex' shaders, requires compute}}
80-
// expected-error@+1 {{attribute 'SV_GroupThreadID' is unsupported in 'vertex' shaders, requires compute}}
77+
// expected-error@+4 {{attribute 'sv_groupindex' is unsupported in 'vertex' shaders, requires compute}}
78+
// expected-error@+3 {{attribute 'sv_dispatchthreadid' is unsupported in 'vertex' shaders, requires compute}}
79+
// expected-error@+2 {{attribute 'sv_groupid' is unsupported in 'vertex' shaders, requires compute}}
80+
// expected-error@+1 {{attribute 'sv_groupthreadid' is unsupported in 'vertex' shaders, requires compute}}
8181
void vs_main(int GI : SV_GroupIndex, uint ID : SV_DispatchThreadID, uint GID : SV_GroupID, uint GThreadID : SV_GroupThreadID) {}

clang/test/SemaHLSL/Semantics/valid_entry_parameter.hlsl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ void CSMain3(uint3 : SV_DispatchThreadID) {
2424
// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:20 'uint3'
2525
// CHECK-NEXT: HLSLSV_DispatchThreadIDAttr
2626
}
27+
[numthreads(8,8,1)]
28+
void CSMain4(uint3 : SV_DispatchThreadId) {
29+
// CHECK: FunctionDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> line:[[@LINE-1]]:6 CSMain4 'void (uint3)'
30+
// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:20 'uint3'
31+
// CHECK-NEXT: HLSLSV_DispatchThreadIDAttr
32+
}
2733

2834
[numthreads(8,8,1)]
2935
void CSMain_GID(uint ID : SV_GroupID) {
@@ -49,6 +55,12 @@ void CSMain3_GID(uint3 : SV_GroupID) {
4955
// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:24 'uint3'
5056
// CHECK-NEXT: HLSLSV_GroupIDAttr
5157
}
58+
[numthreads(8,8,1)]
59+
void CSMain4_GID(uint3 : Sv_GroupId) {
60+
// CHECK: FunctionDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> line:[[@LINE-1]]:6 CSMain4_GID 'void (uint3)'
61+
// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:24 'uint3'
62+
// CHECK-NEXT: HLSLSV_GroupIDAttr
63+
}
5264

5365
[numthreads(8,8,1)]
5466
void CSMain_GThreadID(uint ID : SV_GroupThreadID) {
@@ -74,3 +86,9 @@ void CSMain3_GThreadID(uint3 : SV_GroupThreadID) {
7486
// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:30 'uint3'
7587
// CHECK-NEXT: HLSLSV_GroupThreadIDAttr
7688
}
89+
[numthreads(8,8,1)]
90+
void CSMain4_GThreadID(uint3 : sv_GroupThreadid) {
91+
// CHECK: FunctionDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> line:[[@LINE-1]]:6 CSMain4_GThreadID 'void (uint3)'
92+
// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:30 'uint3'
93+
// CHECK-NEXT: HLSLSV_GroupThreadIDAttr
94+
}

0 commit comments

Comments
 (0)