diff options
| author | jarcherNV <jarcher@nvidia.com> | 2025-08-04 12:26:30 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-04 19:26:30 +0000 |
| commit | 3f12964b24f8829a4548f634463492f02b7de913 (patch) | |
| tree | 4ebb45c9f4b61ecce73293828e0aef6213641748 /tests | |
| parent | 34840bb69fd6b124e772535ffb3f223743870467 (diff) | |
Add support for pointer literals in metal (#8040)
Add support for kIROp_PtrLit types in metal and add a test for null pointer
values, which is the only valid value.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/metal/pointer-literals.slang | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/metal/pointer-literals.slang b/tests/metal/pointer-literals.slang new file mode 100644 index 000000000..327d488d2 --- /dev/null +++ b/tests/metal/pointer-literals.slang @@ -0,0 +1,30 @@ +//TEST:SIMPLE(filecheck=METAL): -target metal -stage compute -entry computeMain
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage compute -entry computeMain
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<uint> outputBuffer;
+
+//METAL: {{\[\[}}kernel{{\]\]}} void computeMain
+//METALLIB: define void @computeMain
+
+// Test that pointer literals are handled correctly in Metal.
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ // Test pointer literals in some contexts that might generate kIROp_PtrLit.
+
+ // Test 1: Basic pointer literal assignment
+ void* ptr1 = nullptr;
+ outputBuffer[0] = (ptr1 == nullptr) ? 1 : 0;
+
+ // Test 2: Pointer literal in struct
+ struct TestStruct
+ {
+ void* ptr;
+ int value;
+ };
+
+ TestStruct test = { nullptr, 42 };
+ outputBuffer[1] = (test.ptr == nullptr) ? 1 : 0;
+}
\ No newline at end of file |
