-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[HLSL] make semantic matching case insensitive #129773
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
Conversation
@llvm/pr-subscribers-hlsl @llvm/pr-subscribers-clang Author: Sarah Spall (spall) ChangesMake semantic matching case insensitive Full diff: https://github.com/llvm/llvm-project/pull/129773.diff 6 Files Affected:
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 458747a1f7155..973e6a6015e98 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -4724,21 +4724,21 @@ def HLSLNumThreads: InheritableAttr {
}
def HLSLSV_GroupThreadID: HLSLAnnotationAttr {
- let Spellings = [HLSLAnnotation<"SV_GroupThreadID">];
+ let Spellings = [HLSLAnnotation<"sv_groupthreadid">];
let Subjects = SubjectList<[ParmVar, Field]>;
let LangOpts = [HLSL];
let Documentation = [HLSLSV_GroupThreadIDDocs];
}
def HLSLSV_GroupID: HLSLAnnotationAttr {
- let Spellings = [HLSLAnnotation<"SV_GroupID">];
+ let Spellings = [HLSLAnnotation<"sv_groupid">];
let Subjects = SubjectList<[ParmVar, Field]>;
let LangOpts = [HLSL];
let Documentation = [HLSLSV_GroupIDDocs];
}
def HLSLSV_GroupIndex: HLSLAnnotationAttr {
- let Spellings = [HLSLAnnotation<"SV_GroupIndex">];
+ let Spellings = [HLSLAnnotation<"sv_groupindex">];
let Subjects = SubjectList<[ParmVar, GlobalVar]>;
let LangOpts = [HLSL];
let Documentation = [HLSLSV_GroupIndexDocs];
@@ -4790,7 +4790,7 @@ def HLSLPackOffset: HLSLAnnotationAttr {
}
def HLSLSV_DispatchThreadID: HLSLAnnotationAttr {
- let Spellings = [HLSLAnnotation<"SV_DispatchThreadID">];
+ let Spellings = [HLSLAnnotation<"sv_dispatchthreadid">];
let Subjects = SubjectList<[ParmVar, Field]>;
let LangOpts = [HLSL];
let Documentation = [HLSLSV_DispatchThreadIDDocs];
diff --git a/clang/lib/Parse/ParseHLSL.cpp b/clang/lib/Parse/ParseHLSL.cpp
index f4c109f9a81a2..423b919ffbbee 100644
--- a/clang/lib/Parse/ParseHLSL.cpp
+++ b/clang/lib/Parse/ParseHLSL.cpp
@@ -141,6 +141,8 @@ void Parser::ParseHLSLAnnotations(ParsedAttributes &Attrs,
return;
}
+ II = PP.getIdentifierInfo(II->getName().lower());
+
SourceLocation Loc = ConsumeToken();
if (EndLoc)
*EndLoc = Tok.getLocation();
diff --git a/clang/test/ParserHLSL/semantic_parsing.hlsl b/clang/test/ParserHLSL/semantic_parsing.hlsl
index 34df1805c5a95..0a921773c1d6f 100644
--- a/clang/test/ParserHLSL/semantic_parsing.hlsl
+++ b/clang/test/ParserHLSL/semantic_parsing.hlsl
@@ -3,5 +3,5 @@
// expected-error@+1 {{expected HLSL Semantic identifier}}
void Entry(int GI : ) { }
-// expected-error@+1 {{unknown HLSL semantic 'SV_IWantAPony'}}
+// expected-error@+1 {{unknown HLSL semantic 'sv_iwantapony'}}
void Pony(int GI : SV_IWantAPony) { }
diff --git a/clang/test/SemaHLSL/Semantics/groupindex.hlsl b/clang/test/SemaHLSL/Semantics/groupindex.hlsl
index a33e060c82906..d5f28f066cc65 100644
--- a/clang/test/SemaHLSL/Semantics/groupindex.hlsl
+++ b/clang/test/SemaHLSL/Semantics/groupindex.hlsl
@@ -4,26 +4,26 @@
[shader("compute")][numthreads(32,1,1)]
void compute(int GI : SV_GroupIndex) {}
-// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'pixel' shaders}}
+// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'pixel' shaders}}
[shader("pixel")]
void pixel(int GI : SV_GroupIndex) {}
-// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'vertex' shaders}}
+// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'vertex' shaders}}
[shader("vertex")]
void vertex(int GI : SV_GroupIndex) {}
-// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'geometry' shaders}}
+// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'geometry' shaders}}
[shader("geometry")]
void geometry(int GI : SV_GroupIndex) {}
-// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'domain' shaders}}
+// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'domain' shaders}}
[shader("domain")]
void domain(int GI : SV_GroupIndex) {}
-// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'amplification' shaders}}
+// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'amplification' shaders}}
[shader("amplification")][numthreads(32,1,1)]
void amplification(int GI : SV_GroupIndex) {}
-// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'mesh' shaders}}
+// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'mesh' shaders}}
[shader("mesh")][numthreads(32,1,1)]
void mesh(int GI : SV_GroupIndex) {}
diff --git a/clang/test/SemaHLSL/Semantics/invalid_entry_parameter.hlsl b/clang/test/SemaHLSL/Semantics/invalid_entry_parameter.hlsl
index 1bb4ee5182d62..71131754fa4f1 100644
--- a/clang/test/SemaHLSL/Semantics/invalid_entry_parameter.hlsl
+++ b/clang/test/SemaHLSL/Semantics/invalid_entry_parameter.hlsl
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -finclude-default-header -x hlsl -ast-dump -verify -o - %s
[numthreads(8,8,1)]
-// expected-error@+1 {{attribute 'SV_DispatchThreadID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
+// expected-error@+1 {{attribute 'sv_dispatchthreadid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
void CSMain(float ID : SV_DispatchThreadID) {
}
@@ -11,71 +11,71 @@ struct ST {
float b;
};
[numthreads(8,8,1)]
-// expected-error@+1 {{attribute 'SV_DispatchThreadID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
+// expected-error@+1 {{attribute 'sv_dispatchthreadid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
void CSMain2(ST ID : SV_DispatchThreadID) {
}
void foo() {
-// expected-warning@+1 {{'SV_DispatchThreadID' attribute only applies to parameters and non-static data members}}
+// expected-warning@+1 {{'sv_dispatchthreadid' attribute only applies to parameters and non-static data members}}
uint V : SV_DispatchThreadID;
}
struct ST2 {
-// expected-warning@+1 {{'SV_DispatchThreadID' attribute only applies to parameters and non-static data members}}
+// expected-warning@+1 {{'sv_dispatchthreadid' attribute only applies to parameters and non-static data members}}
static uint X : SV_DispatchThreadID;
uint s : SV_DispatchThreadID;
};
[numthreads(8,8,1)]
-// expected-error@+1 {{attribute 'SV_GroupID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
+// expected-error@+1 {{attribute 'sv_groupid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
void CSMain_GID(float ID : SV_GroupID) {
}
[numthreads(8,8,1)]
-// expected-error@+1 {{attribute 'SV_GroupID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
+// expected-error@+1 {{attribute 'sv_groupid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
void CSMain2_GID(ST GID : SV_GroupID) {
}
void foo_GID() {
-// expected-warning@+1 {{'SV_GroupID' attribute only applies to parameters and non-static data members}}
+// expected-warning@+1 {{'sv_groupid' attribute only applies to parameters and non-static data members}}
uint GIS : SV_GroupID;
}
struct ST2_GID {
-// expected-warning@+1 {{'SV_GroupID' attribute only applies to parameters and non-static data members}}
+// expected-warning@+1 {{'sv_groupid' attribute only applies to parameters and non-static data members}}
static uint GID : SV_GroupID;
uint s_gid : SV_GroupID;
};
[numthreads(8,8,1)]
-// expected-error@+1 {{attribute 'SV_GroupThreadID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
+// expected-error@+1 {{attribute 'sv_groupthreadid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
void CSMain_GThreadID(float ID : SV_GroupThreadID) {
}
[numthreads(8,8,1)]
-// expected-error@+1 {{attribute 'SV_GroupThreadID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
+// expected-error@+1 {{attribute 'sv_groupthreadid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
void CSMain2_GThreadID(ST GID : SV_GroupThreadID) {
}
void foo_GThreadID() {
-// expected-warning@+1 {{'SV_GroupThreadID' attribute only applies to parameters and non-static data members}}
+// expected-warning@+1 {{'sv_groupthreadid' attribute only applies to parameters and non-static data members}}
uint GThreadIS : SV_GroupThreadID;
}
struct ST2_GThreadID {
-// expected-warning@+1 {{'SV_GroupThreadID' attribute only applies to parameters and non-static data members}}
+// expected-warning@+1 {{'sv_groupthreadid' attribute only applies to parameters and non-static data members}}
static uint GThreadID : SV_GroupThreadID;
uint s_gthreadid : SV_GroupThreadID;
};
[shader("vertex")]
-// expected-error@+4 {{attribute 'SV_GroupIndex' is unsupported in 'vertex' shaders, requires compute}}
-// expected-error@+3 {{attribute 'SV_DispatchThreadID' is unsupported in 'vertex' shaders, requires compute}}
-// expected-error@+2 {{attribute 'SV_GroupID' is unsupported in 'vertex' shaders, requires compute}}
-// expected-error@+1 {{attribute 'SV_GroupThreadID' is unsupported in 'vertex' shaders, requires compute}}
+// expected-error@+4 {{attribute 'sv_groupindex' is unsupported in 'vertex' shaders, requires compute}}
+// expected-error@+3 {{attribute 'sv_dispatchthreadid' is unsupported in 'vertex' shaders, requires compute}}
+// expected-error@+2 {{attribute 'sv_groupid' is unsupported in 'vertex' shaders, requires compute}}
+// expected-error@+1 {{attribute 'sv_groupthreadid' is unsupported in 'vertex' shaders, requires compute}}
void vs_main(int GI : SV_GroupIndex, uint ID : SV_DispatchThreadID, uint GID : SV_GroupID, uint GThreadID : SV_GroupThreadID) {}
diff --git a/clang/test/SemaHLSL/Semantics/valid_entry_parameter.hlsl b/clang/test/SemaHLSL/Semantics/valid_entry_parameter.hlsl
index 6781f9241df24..a2203692b582b 100644
--- a/clang/test/SemaHLSL/Semantics/valid_entry_parameter.hlsl
+++ b/clang/test/SemaHLSL/Semantics/valid_entry_parameter.hlsl
@@ -24,6 +24,12 @@ void CSMain3(uint3 : SV_DispatchThreadID) {
// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:20 'uint3'
// CHECK-NEXT: HLSLSV_DispatchThreadIDAttr
}
+[numthreads(8,8,1)]
+void CSMain4(uint3 : SV_DispatchThreadId) {
+// CHECK: FunctionDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> line:[[@LINE-1]]:6 CSMain4 'void (uint3)'
+// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:20 'uint3'
+// CHECK-NEXT: HLSLSV_DispatchThreadIDAttr
+}
[numthreads(8,8,1)]
void CSMain_GID(uint ID : SV_GroupID) {
@@ -49,6 +55,12 @@ void CSMain3_GID(uint3 : SV_GroupID) {
// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:24 'uint3'
// CHECK-NEXT: HLSLSV_GroupIDAttr
}
+[numthreads(8,8,1)]
+void CSMain4_GID(uint3 : Sv_GroupId) {
+// CHECK: FunctionDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> line:[[@LINE-1]]:6 CSMain4_GID 'void (uint3)'
+// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:24 'uint3'
+// CHECK-NEXT: HLSLSV_GroupIDAttr
+}
[numthreads(8,8,1)]
void CSMain_GThreadID(uint ID : SV_GroupThreadID) {
@@ -74,3 +86,9 @@ void CSMain3_GThreadID(uint3 : SV_GroupThreadID) {
// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:30 'uint3'
// CHECK-NEXT: HLSLSV_GroupThreadIDAttr
}
+[numthreads(8,8,1)]
+void CSMain4_GThreadID(uint3 : sv_GroupThreadid) {
+// CHECK: FunctionDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> line:[[@LINE-1]]:6 CSMain4_GThreadID 'void (uint3)'
+// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:30 'uint3'
+// CHECK-NEXT: HLSLSV_GroupThreadIDAttr
+}
|
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.
LGTM
…re in capitalization the user wrote
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.
nit: is there a way to check that the spelling is consistent in the error messages? Asking since I am no familiar with this part of the code.
I'm not sure I understand what you mean. |
I think the point (and my earlier comment) is to use the spelling as it is written in the source so that the user can grep their code for the string that occurs in the error message rather than providing consistent capitalization in the error messages. |
Make semantic matching case insensitive
update tests to reflect semantic printed as all lower case in error messages
add new tests to show case insensitivity
Closes #128063