Skip to content

Commit f0f3c6f

Browse files
committed
pr-feedback
1 parent 3d4cce9 commit f0f3c6f

File tree

8 files changed

+119
-9
lines changed

8 files changed

+119
-9
lines changed

clang/lib/CodeGen/CGHLSLRuntime.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,8 @@ llvm::Value *CGHLSLRuntime::emitSystemSemanticLoad(
745745
}
746746
}
747747

748-
llvm_unreachable("non-handled system semantic. FIXME.");
748+
llvm_unreachable(
749+
"Load hasn't been implemented yet for this system semantic. FIXME");
749750
}
750751

751752
static void createSPIRVBuiltinStore(IRBuilder<> &B, llvm::Module &M,
@@ -769,14 +770,21 @@ void CGHLSLRuntime::emitSystemSemanticStore(IRBuilder<> &B, llvm::Value *Source,
769770

770771
std::string SemanticName = Semantic->getAttrName()->getName().upper();
771772
if (SemanticName == "SV_POSITION") {
772-
if (CGM.getTarget().getTriple().isDXIL())
773+
if (CGM.getTarget().getTriple().isDXIL()) {
773774
emitDXILUserSemanticStore(B, Source, Semantic, Index);
774-
else if (CGM.getTarget().getTriple().isSPIRV())
775+
return;
776+
}
777+
778+
if (CGM.getTarget().getTriple().isSPIRV()) {
775779
createSPIRVBuiltinStore(B, CGM.getModule(), Source,
776780
Semantic->getAttrName()->getName(),
777781
/* BuiltIn::Position */ 0);
778-
} else
779-
llvm_unreachable("non-handled system semantic. FIXME.");
782+
return;
783+
}
784+
}
785+
786+
llvm_unreachable(
787+
"Store hasn't been implemented yet for this system semantic. FIXME");
780788
}
781789

782790
llvm::Value *CGHLSLRuntime::handleScalarSemanticLoad(

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -967,10 +967,8 @@ void SemaHLSL::checkSemanticAnnotation(
967967
}
968968

969969
if (SemanticName == "SV_POSITION") {
970-
// SV_Position can is I/O for vertex shaders.
971-
// For pixel shaders, only valid as input.
972-
// Note: for SPIR-V, not backed by a builtin when used as input in a vertex
973-
// shaders.
970+
// SV_Position can be an input or output in vertex shaders,
971+
// but only an input in pixel shaders.
974972
if (ST == llvm::Triple::Vertex || (ST == llvm::Triple::Pixel && IsInput))
975973
return;
976974
DiagnoseAttrStageMismatch(SemanticAttr, ST,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %clang_cc1 -triple spirv-unknown-vulkan1.3-vertex -finclude-default-header -ast-dump -o - %s | FileCheck %s
2+
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.8-vertex -finclude-default-header -ast-dump -o - %s | FileCheck %s
3+
4+
5+
// CHECK: CXXRecordDecl {{.*}} referenced struct S definition
6+
// CHECK: FieldDecl {{.*}} field1 'int'
7+
// CHECK-NEXT: HLSLParsedSemanticAttr {{.*}} "A" 0
8+
// CHECK: FieldDecl {{.*}} field2 'int'
9+
// CHECK-NEXT: HLSLParsedSemanticAttr {{.*}} "B" 4
10+
11+
struct S {
12+
int field1 : A;
13+
int field2 : B4;
14+
};
15+
16+
// CHECK: FunctionDecl {{.*}} main 'void (S)'
17+
// CHECK-NEXT: ParmVarDecl {{.*}} s 'S'
18+
// CHECK-NEXT: HLSLParsedSemanticAttr {{.*}} "C" 0
19+
// CHECK-NEXT: HLSLAppliedSemanticAttr {{.*}} "C" 0
20+
// CHECK-NEXT: HLSLAppliedSemanticAttr {{.*}} "C" 1
21+
void main(S s : C) {}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %clang_cc1 -triple spirv-unknown-vulkan1.3-vertex -finclude-default-header -ast-dump -o - %s | FileCheck %s
2+
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.8-vertex -finclude-default-header -ast-dump -o - %s | FileCheck %s
3+
4+
5+
// CHECK: CXXRecordDecl {{.*}} referenced struct S definition
6+
// CHECK: FieldDecl {{.*}} field1 'int'
7+
// CHECK-NEXT: HLSLParsedSemanticAttr {{.*}} "A" 0
8+
// CHECK: FieldDecl {{.*}} field2 'int'
9+
// CHECK-NEXT: HLSLParsedSemanticAttr {{.*}} "B" 4
10+
11+
struct S {
12+
int field1 : A;
13+
int field2 : B4;
14+
};
15+
16+
// CHECK: FunctionDecl {{.*}} main 'void (S)'
17+
// CHECK-NEXT: ParmVarDecl {{.*}} s 'S'
18+
// CHECK-NEXT: HLSLAppliedSemanticAttr {{.*}} "A" 0
19+
// CHECK-NEXT: HLSLAppliedSemanticAttr {{.*}} "B" 4
20+
void main(S s) {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %clang_cc1 -triple spirv-unknown-vulkan1.3-vertex -finclude-default-header -ast-dump -o - %s | FileCheck %s
2+
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.8-vertex -finclude-default-header -ast-dump -o - %s | FileCheck %s
3+
4+
// CHECK: ParmVarDecl {{.*}} a 'float4':'vector<float, 4>'
5+
// CHECK-NEXT: HLSLParsedSemanticAttr {{.*}} "ABC" 0
6+
// CHECK-NEXT: HLSLAppliedSemanticAttr {{.*}} "ABC" 0
7+
8+
void main(float4 a : ABC) {
9+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %clang_cc1 -triple spirv-unknown-vulkan1.3-vertex -finclude-default-header -ast-dump -o - %s | FileCheck %s
2+
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.8-vertex -finclude-default-header -ast-dump -o - %s | FileCheck %s
3+
4+
5+
// CHECK: CXXRecordDecl {{.*}} referenced struct S definition
6+
// CHECK: FieldDecl {{.*}} referenced field1 'int'
7+
// CHECK-NEXT: HLSLParsedSemanticAttr {{.*}} "A" 0
8+
// CHECK: FieldDecl {{.*}} referenced field2 'int'
9+
// CHECK-NEXT: HLSLParsedSemanticAttr {{.*}} "B" 4
10+
11+
struct S {
12+
int field1 : A;
13+
int field2 : B4;
14+
};
15+
16+
// CHECK: FunctionDecl {{.*}} main 'S ()'
17+
// CHECK: HLSLParsedSemanticAttr {{.*}} "DEF" 0
18+
// CHECK: HLSLAppliedSemanticAttr {{.*}} "DEF" 0
19+
// CHECK-NEXT: HLSLAppliedSemanticAttr {{.*}} "DEF" 1
20+
S main() : DEF {
21+
S tmp;
22+
return tmp;
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %clang_cc1 -triple spirv-unknown-vulkan1.3-vertex -finclude-default-header -ast-dump -o - %s | FileCheck %s
2+
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.8-vertex -finclude-default-header -ast-dump -o - %s | FileCheck %s
3+
4+
5+
// CHECK: CXXRecordDecl {{.*}} referenced struct S definition
6+
// CHECK: FieldDecl {{.*}} referenced field1 'int'
7+
// CHECK-NEXT: HLSLParsedSemanticAttr {{.*}} "A" 0
8+
// CHECK: FieldDecl {{.*}} referenced field2 'int'
9+
// CHECK-NEXT: HLSLParsedSemanticAttr {{.*}} "B" 4
10+
11+
struct S {
12+
int field1 : A;
13+
int field2 : B4;
14+
};
15+
16+
// CHECK: FunctionDecl {{.*}} main 'S ()'
17+
// CHECK: HLSLAppliedSemanticAttr {{.*}} "A" 0
18+
// CHECK-NEXT: HLSLAppliedSemanticAttr {{.*}} "B" 4
19+
S main() {
20+
S tmp;
21+
return tmp;
22+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %clang_cc1 -triple spirv-unknown-vulkan1.3-vertex -finclude-default-header -ast-dump -o - %s | FileCheck %s
2+
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.8-vertex -finclude-default-header -ast-dump -o - %s | FileCheck %s
3+
4+
// CHECK: FunctionDecl {{.*}} main 'uint ()'
5+
// CHECK: HLSLParsedSemanticAttr {{.*}} "ABC" 0
6+
// CHECK: HLSLAppliedSemanticAttr {{.*}} "ABC" 0
7+
uint main() : ABC {
8+
return 0;
9+
}

0 commit comments

Comments
 (0)