Skip to content

Commit fa76460

Browse files
joaosaffranjoaosaffran
andauthored
[DirectX] Add Root Signature Version Support and Update Test IR Format (#144957)
Updates the Root Signature metadata parser to extract version information. This requirement was added after the initial parser implementation. --------- Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
1 parent efd42b9 commit fa76460

24 files changed

+70
-30
lines changed

llvm/lib/Target/DirectX/DXILRootSignature.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ analyzeModule(Module &M) {
309309
return RSDMap;
310310

311311
for (const auto &RSDefNode : RootSignatureNode->operands()) {
312-
if (RSDefNode->getNumOperands() != 2) {
312+
if (RSDefNode->getNumOperands() != 3) {
313313
reportError(Ctx, "Invalid format for Root Signature Definition. Pairs "
314314
"of function, root signature expected.");
315315
continue;
@@ -348,8 +348,14 @@ analyzeModule(Module &M) {
348348
reportError(Ctx, "Root Element is not a metadata node.");
349349
continue;
350350
}
351-
352351
mcdxbc::RootSignatureDesc RSD;
352+
if (std::optional<uint32_t> Version = extractMdIntValue(RSDefNode, 2))
353+
RSD.Version = *Version;
354+
else {
355+
reportError(Ctx, "Invalid RSDefNode value, expected constant int");
356+
continue;
357+
}
358+
353359
// Clang emits the root signature data in dxcontainer following a specific
354360
// sequence. First the header, then the root parameters. So the header
355361
// offset will always equal to the header size.

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Error-is-not-function.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ entry:
1818
attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1919

2020
!dx.rootsignatures = !{!2, !5} ; list of function/root signature pairs
21-
!2 = !{ ptr @main, !3 } ; function, root signature
21+
!2 = !{ ptr @main, !3, i32 2 } ; function, root signature
2222
!3 = !{ !4 } ; list of root signature elements
2323
!4 = !{ !"RootFlags", i32 1 } ; 1 = allow_input_assembler_input_layout
24-
!5 = !{ i32 -1, !6 } ; function, root signature
24+
!5 = !{ i32 -1, !6, i32 2 } ; function, root signature
2525
!6 = !{ !7 } ; list of root signature elements
2626
!7 = !{ !"RootFlags", i32 2 } ; 1 = allow_input_assembler_input_layout

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Error-is-not-value.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ entry:
1818
attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1919

2020
!dx.rootsignatures = !{!2, !5} ; list of function/root signature pairs
21-
!2 = !{ ptr @main, !3 } ; function, root signature
21+
!2 = !{ ptr @main, !3, i32 2 } ; function, root signature
2222
!3 = !{ !4 } ; list of root signature elements
2323
!4 = !{ !"RootFlags", i32 1 } ; 1 = allow_input_assembler_input_layout
24-
!5 = !{ !3, !6 } ; function, root signature
24+
!5 = !{ !3, !6, i32 2 } ; function, root signature
2525
!6 = !{ !7 } ; list of root signature elements
2626
!7 = !{ !"RootFlags", i32 2 } ; 1 = allow_input_assembler_input_layout

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Error-no-root-element-list.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ entry:
1818
attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1919

2020
!dx.rootsignatures = !{!2, !5} ; list of function/root signature pairs
21-
!2 = !{ ptr @main, null } ; function, root signature
21+
!2 = !{ ptr @main, null, i32 2 } ; function, root signature
2222
!3 = !{ !4 } ; list of root signature elements
2323
!4 = !{ !"RootFlags", i32 1 } ; 1 = allow_input_assembler_input_layout
24-
!5 = !{ i32 -1, !6 } ; function, root signature
24+
!5 = !{ i32 -1, !6, i32 2 } ; function, root signature
2525
!6 = !{ !7 } ; list of root signature elements
2626
!7 = !{ !"RootFlags", i32 2 } ; 1 = allow_input_assembler_input_layout

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Error-root-element-not-mdnode.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ entry:
1818
attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1919

2020
!dx.rootsignatures = !{!2, !5} ; list of function/root signature pairs
21-
!2 = !{ ptr @main, i32 -1 } ; function, root signature
21+
!2 = !{ ptr @main, i32 -1, i32 2 } ; function, root signature
2222
!3 = !{ !4 } ; list of root signature elements
2323
!4 = !{ !"RootFlags", i32 1 } ; 1 = allow_input_assembler_input_layout
24-
!5 = !{ i32 -1, !6 } ; function, root signature
24+
!5 = !{ i32 -1, !6, i32 2 } ; function, root signature
2525
!6 = !{ !7 } ; list of root signature elements
2626
!7 = !{ !"RootFlags", i32 2 } ; 1 = allow_input_assembler_input_layout

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Flags-Error.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1515

1616

1717
!dx.rootsignatures = !{!2} ; list of function/root signature pairs
18-
!2 = !{ ptr @main, !3 } ; function, root signature
18+
!2 = !{ ptr @main, !3, i32 2 } ; function, root signature
1919
!3 = !{ !4 } ; list of root signature elements
2020
!4 = !{ !"NOTRootFlags", i32 1 } ; 1 = allow_input_assembler_input_layout

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Flags.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1313

1414

1515
!dx.rootsignatures = !{!2} ; list of function/root signature pairs
16-
!2 = !{ ptr @main, !3 } ; function, root signature
16+
!2 = !{ ptr @main, !3, i32 2 } ; function, root signature
1717
!3 = !{ !4 } ; list of root signature elements
1818
!4 = !{ !"RootFlags", i32 1 } ; 1 = allow_input_assembler_input_layout
1919

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-MultipleEntryFunctions.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ entry:
1616
attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1717

1818
!dx.rootsignatures = !{!2, !5} ; list of function/root signature pairs
19-
!2 = !{ ptr @main, !3 } ; function, root signature
19+
!2 = !{ ptr @main, !3, i32 2 } ; function, root signature
2020
!3 = !{ !4 } ; list of root signature elements
2121
!4 = !{ !"RootFlags", i32 1 } ; 1 = allow_input_assembler_input_layout
22-
!5 = !{ ptr @anotherMain, !6 } ; function, root signature
22+
!5 = !{ ptr @anotherMain, !6, i32 2 } ; function, root signature
2323
!6 = !{ !7 } ; list of root signature elements
2424
!7 = !{ !"RootFlags", i32 2 } ; 1 = allow_input_assembler_input_layout
2525

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-NullFunction-Error.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ entry:
1313
attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1414

1515
!dx.rootsignatures = !{!2, !5} ; list of function/root signature pairs
16-
!2 = !{ ptr @main, !3 } ; function, root signature
16+
!2 = !{ ptr @main, !3, i32 2 } ; function, root signature
1717
!3 = !{ !4 } ; list of root signature elements
1818
!4 = !{ !"RootFlags", i32 1 } ; 1 = allow_input_assembler_input_layout
19-
!5 = !{ null, !6 } ; function, root signature
19+
!5 = !{ null, !6, i32 2 } ; function, root signature
2020
!6 = !{ !7 } ; list of root signature elements
2121
!7 = !{ !"RootFlags", i32 2 } ; 1 = allow_input_assembler_input_layout

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Parameters-Invalid-ParameterIsNotString.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ entry:
1414
attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1515

1616
!dx.rootsignatures = !{!0}
17-
!0 = !{ ptr @main, !1 }
17+
!0 = !{ ptr @main, !1, i32 2 }
1818
!1 = !{ !2 }
1919
!2 = !{ i32 0 }

0 commit comments

Comments
 (0)