summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMukund Keshava <mkeshava@nvidia.com>2025-03-11 21:40:05 +0530
committerGitHub <noreply@github.com>2025-03-11 16:10:05 +0000
commitf59e0ef409844f2514435a8df8ceeff3663e5db3 (patch)
tree7f8f7514ed140a49f03923d84a549fdbfdcbcc84 /tests
parentff55a569a0bff44a6f8abb105c07cbc2484bc007 (diff)
IR: Add SPIR-V disassembly for embedded downstream IR dumps (#6529)
* IR: Add SPIR-V disassembly for embedded downstream IR dumps When dumping IR that contains embedded downstream SPIR-V code (via EmbeddedDownstreamIR instructions), display the disassembled SPIR-V instead of just showing "<binary blob>". This CL also does: - Adds a new interface for disassembly and get result. - Modify export-library-generics.slang test test to check for the disassembled SPIR-V Fixes #6513 * Add module-dual-target-verify test Fixes #6517 Adds a new test to verify that dxil and spirv targets are stored separately in the precompiled blob. * Fix review comments from cheneym2 * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/library/export-library-generics.slang11
-rw-r--r--tests/modules/multi-target-module.slang45
2 files changed, 55 insertions, 1 deletions
diff --git a/tests/library/export-library-generics.slang b/tests/library/export-library-generics.slang
index 3f17e0664..de683031e 100644
--- a/tests/library/export-library-generics.slang
+++ b/tests/library/export-library-generics.slang
@@ -1,4 +1,6 @@
-//TEST_IGNORE_FILE:
+// This test checks the SPIR-V output when compiling a library containing generics with embedded downstream IR.
+
+//TEST:SIMPLE(filecheck=CHECK): -o tests/library/export-library-generics-test.slang-module -target spirv -embed-downstream-ir -profile lib_6_6 -incomplete-library -dump-ir -verbose-paths
// export-library-generics.slang
@@ -37,3 +39,10 @@ public int normalFunc(int a, float b)
{
return a - floor(b);
}
+
+// CHECK:[availableInDownstreamIR(6 : Int)]
+// CHECK:EmbeddedDownstreamIR(6 : Int,
+// CHECK: OpCapability Linkage
+// CHECK:OpDecorate %SLANG_ParameterGroup_Constants__init LinkageAttributes "_SR29export_2Dxlibrary_2Dxgenerics30SLANG_ParameterGroup_ConstantsR8_24xinitp2pi_fi_f" Export
+// CHECK: OpDecorate %MyType_myMethod LinkageAttributes "_SR29export_2Dxlibrary_2Dxgenerics6MyType8myMethodp1pi_ii" Export
+// CHECK: OpDecorate %normalFuncUsesGeneric LinkageAttributes "_SR29export_2Dxlibrary_2Dxgenerics21normalFuncUsesGenericp1pi_ii" Export \ No newline at end of file
diff --git a/tests/modules/multi-target-module.slang b/tests/modules/multi-target-module.slang
new file mode 100644
index 000000000..68b774b87
--- /dev/null
+++ b/tests/modules/multi-target-module.slang
@@ -0,0 +1,45 @@
+// multi-target-module.slang
+ // Test that a slang-module can store both SPIR-V and DXIL blobs separately
+
+ //TEST:SIMPLE(filecheck=CHECK): -o tests/modules/multi-target-module.slang-module -target dxil -embed-downstream-ir -target spirv -embed-downstream-ir -profile lib_6_6 -incomplete-library -dump-ir -verbose-paths
+
+ module multi_target_module;
+
+ // Simple function that will work on both SPIR-V and DXIL targets
+ public float4 addVectors(float4 a, float4 b)
+ {
+ return a + b;
+ }
+
+ // Another function that should be compatible with both targets
+ public float3 normalizeVector(float3 v)
+ {
+ return normalize(v);
+ }
+
+ [shader("compute")]
+ [numthreads(8, 8, 1)]
+ void main(uint3 dispatchThreadID : SV_DispatchThreadID)
+ {
+ float4 a = float4(1.0, 2.0, 3.0, 4.0);
+ float4 b = float4(5.0, 6.0, 7.0, 8.0);
+
+ float4 result = addVectors(a, b);
+
+ float3 v = float3(1.0, 1.0, 1.0);
+ float3 n = normalizeVector(v);
+ }
+
+ // Check for the first occurrence of availableInDownstreamIR for addVectors in this section
+ // Check that there are two entries, one for dxil and one for spirv.
+ // CHECK: [availableInDownstreamIR(6 : Int)]
+ // CHECK: [availableInDownstreamIR(10 : Int)]
+ // CHECK: [public]
+ // CHECK: [export("_S19multi_target_module10addVectorsp2pi_v4fi_v4fv4f")]
+
+ // Check for the second occurrence of availableInDownstreamIR for normalizeVector in this section
+ // Check that there are two entries, one for dxil and one for spirv.
+ // CHECK: [availableInDownstreamIR(6 : Int)]
+ // CHECK: [availableInDownstreamIR(10 : Int)]
+ // CHECK: [public]
+ // CHECK: [export("_S19multi_target_module15normalizeVectorp1pi_v3fv3f")] \ No newline at end of file