|
| 1 | +; REQUIRES: spirv-as |
| 2 | +; RUN: spirv-as --target-env spv1.4 -o %t.spv %s |
| 3 | +; RUN: spirv-val %t.spv |
| 4 | +; RUN: llvm-spirv -r --spirv-target-env=CL2.0 %t.spv -o - | llvm-dis | FileCheck --check-prefix=CHECK-OCL %s |
| 5 | +; RUN: llvm-spirv -r --spirv-target-env=SPV-IR %t.spv -o - | llvm-dis | FileCheck --check-prefix=CHECK-SPV-IR %s |
| 6 | + |
| 7 | +; Ensure that UserSemantic decorations on BuiltIn variables do not prevent successful translation. |
| 8 | + |
| 9 | +; CHECK-OCL: call spir_func i64 @_Z13get_global_idj(i32 0) |
| 10 | +; CHECK-SPV-IR: call spir_func i64 @_Z33__spirv_BuiltInGlobalInvocationIdi(i32 0) |
| 11 | + |
| 12 | + OpCapability Addresses |
| 13 | + OpCapability Linkage |
| 14 | + OpCapability Kernel |
| 15 | + OpCapability Int64 |
| 16 | + OpMemoryModel Physical64 OpenCL |
| 17 | + OpEntryPoint Kernel %usersemantic_test "usersemantic_test" %global_id |
| 18 | + OpDecorate %global_id LinkageAttributes "global_id" Import |
| 19 | + OpDecorate %global_id Constant |
| 20 | + OpDecorate %global_id BuiltIn GlobalInvocationId |
| 21 | + ; Basic decoration: |
| 22 | + OpDecorateString %global_id UserSemantic "FOO" |
| 23 | + ; Duplicate decorations are allowed as long as the string is different. |
| 24 | + OpDecorateString %global_id UserSemantic "BAR" |
| 25 | + ; Try one more string with punctuation. |
| 26 | + OpDecorateString %global_id UserSemantic "FOO? BAR. BAZ!" |
| 27 | + %ulong = OpTypeInt 64 0 |
| 28 | + %uint = OpTypeInt 32 0 |
| 29 | + %v3ulong = OpTypeVector %ulong 3 |
| 30 | +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong |
| 31 | + %void = OpTypeVoid |
| 32 | +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint |
| 33 | + %9 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint |
| 34 | +%global_id = OpVariable %_ptr_Input_v3ulong Input |
| 35 | +%usersemantic_test = OpFunction %void None %9 |
| 36 | + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_uint |
| 37 | + %entry = OpLabel |
| 38 | + %index = OpLoad %v3ulong %global_id Aligned 32 |
| 39 | + %call = OpCompositeExtract %ulong %index 0 |
| 40 | + %conv = OpUConvert %uint %call |
| 41 | + %idxprom = OpSConvert %ulong %conv |
| 42 | + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %dst %idxprom |
| 43 | + OpStore %arrayidx %conv Aligned 4 |
| 44 | + OpReturn |
| 45 | + OpFunctionEnd |
0 commit comments