Home | History | Annotate | Download | only in transcoding
      1 ;;__kernel void testAtomicCompareExchangeExplicit_cl20(
      2 ;;    volatile global atomic_int* object,
      3 ;;    global int* expected,
      4 ;;    int desired)
      5 ;;{
      6 ;;  // Values of memory order and memory scope arguments correspond to SPIR-2.0 spec.
      7 ;;  atomic_compare_exchange_strong_explicit(object, expected, desired,
      8 ;;                                          memory_order_release, // 2
      9 ;;                                          memory_order_relaxed  // 0
     10 ;;                                         ); // by default, assume device scope = 2
     11 ;;  atomic_compare_exchange_strong_explicit(object, expected, desired,
     12 ;;                                          memory_order_acq_rel,   // 3
     13 ;;                                          memory_order_relaxed,   // 0
     14 ;;                                          memory_scope_work_group // 1
     15 ;;                                         );
     16 ;;  atomic_compare_exchange_weak_explicit(object, expected, desired,
     17 ;;                                        memory_order_release, // 2
     18 ;;                                        memory_order_relaxed  // 0
     19 ;;                                         ); // by default, assume device scope = 2
     20 ;;  atomic_compare_exchange_weak_explicit(object, expected, desired,
     21 ;;                                        memory_order_acq_rel,   // 3
     22 ;;                                        memory_order_relaxed,   // 0
     23 ;;                                        memory_scope_work_group // 1
     24 ;;                                       );
     25 ;;}
     26 
     27 ; RUN: llvm-as %s -o %t.bc
     28 ; RUN: llvm-spirv %t.bc -spirv-text -o %t.txt
     29 ; RUN: FileCheck < %t.txt %s --check-prefix=CHECK-SPIRV
     30 ; RUN: llvm-spirv %t.bc -o %t.spv
     31 ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
     32 ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
     33 
     34 ;CHECK-SPIRV: TypeInt [[int:[0-9]+]] 32 0
     35 ;; Constants below correspond to the SPIR-V spec
     36 ;CHECK-SPIRV-DAG: Constant [[int]] [[DeviceScope:[0-9]+]] 1
     37 ;CHECK-SPIRV-DAG: Constant [[int]] [[WorkgroupScope:[0-9]+]] 2
     38 ;CHECK-SPIRV-DAG: Constant [[int]] [[ReleaseMemSem:[0-9]+]] 4
     39 ;CHECK-SPIRV-DAG: Constant [[int]] [[RelaxedMemSem:[0-9]+]] 0
     40 ;CHECK-SPIRV-DAG: Constant [[int]] [[AcqRelMemSem:[0-9]+]] 8
     41 
     42 ;CHECK-SPIRV: AtomicCompareExchange {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} [[DeviceScope]] [[ReleaseMemSem]] [[RelaxedMemSem]]
     43 ;CHECK-SPIRV: AtomicCompareExchange {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} [[WorkgroupScope]] [[AcqRelMemSem]] [[RelaxedMemSem]]
     44 ;CHECK-SPIRV: AtomicCompareExchangeWeak {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} [[DeviceScope]] [[ReleaseMemSem]] [[RelaxedMemSem]]
     45 ;CHECK-SPIRV: AtomicCompareExchangeWeak {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} [[WorkgroupScope]] [[AcqRelMemSem]] [[RelaxedMemSem]]
     46 
     47 ;CHECK-LLVM: call spir_func i1 @_Z39atomic_compare_exchange_strong_explicitPVU3AS4U7_AtomiciPiiiii(i32 addrspace(4)* %0, i32* %expected1, i32 %desired, i32 2, i32 0, i32 2)
     48 ;CHECK-LLVM: call spir_func i1 @_Z39atomic_compare_exchange_strong_explicitPVU3AS4U7_AtomiciPiiiii(i32 addrspace(4)* %0, i32* %expected2, i32 %desired, i32 3, i32 0, i32 1)
     49 ;CHECK-LLVM: call spir_func i1 @_Z37atomic_compare_exchange_weak_explicitPVU3AS4U7_AtomiciPiiiii(i32 addrspace(4)* %0, i32* %expected3, i32 %desired, i32 2, i32 0, i32 2)
     50 ;CHECK-LLVM: call spir_func i1 @_Z37atomic_compare_exchange_weak_explicitPVU3AS4U7_AtomiciPiiiii(i32 addrspace(4)* %0, i32* %expected4, i32 %desired, i32 3, i32 0, i32 1)
     51 
     52 target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
     53 target triple = "spir"
     54 
     55 ; Function Attrs: nounwind
     56 define spir_kernel void @testAtomicCompareExchangeExplicit_cl20(i32 addrspace(1)* %object, i32 addrspace(1)* %expected, i32 %desired) #0 {
     57 entry:
     58   %0 = addrspacecast i32 addrspace(1)* %object to i32 addrspace(4)*
     59   %1 = addrspacecast i32 addrspace(1)* %expected to i32 addrspace(4)*
     60   %call = tail call spir_func zeroext i1 @_Z39atomic_compare_exchange_strong_explicitPVU3AS4U7_AtomiciPU3AS4ii12memory_orderS4_(i32 addrspace(4)* %0, i32 addrspace(4)* %1, i32 %desired, i32 2, i32 0) #2
     61   %call1 = tail call spir_func zeroext i1 @_Z39atomic_compare_exchange_strong_explicitPVU3AS4U7_AtomiciPU3AS4ii12memory_orderS4_12memory_scope(i32 addrspace(4)* %0, i32 addrspace(4)* %1, i32 %desired, i32 3, i32 0, i32 1) #2
     62   %call2 = tail call spir_func zeroext i1 @_Z37atomic_compare_exchange_weak_explicitPVU3AS4U7_AtomiciPU3AS4ii12memory_orderS4_(i32 addrspace(4)* %0, i32 addrspace(4)* %1, i32 %desired, i32 2, i32 0) #2
     63   %call3 = tail call spir_func zeroext i1 @_Z37atomic_compare_exchange_weak_explicitPVU3AS4U7_AtomiciPU3AS4ii12memory_orderS4_12memory_scope(i32 addrspace(4)* %0, i32 addrspace(4)* %1, i32 %desired, i32 3, i32 0, i32 1) #2
     64   ret void
     65 }
     66 
     67 declare spir_func zeroext i1 @_Z39atomic_compare_exchange_strong_explicitPVU3AS4U7_AtomiciPU3AS4ii12memory_orderS4_(i32 addrspace(4)*, i32 addrspace(4)*, i32, i32, i32) #1
     68 
     69 declare spir_func zeroext i1 @_Z39atomic_compare_exchange_strong_explicitPVU3AS4U7_AtomiciPU3AS4ii12memory_orderS4_12memory_scope(i32 addrspace(4)*, i32 addrspace(4)*, i32, i32, i32, i32) #1
     70 
     71 declare spir_func zeroext i1 @_Z37atomic_compare_exchange_weak_explicitPVU3AS4U7_AtomiciPU3AS4ii12memory_orderS4_(i32 addrspace(4)*, i32 addrspace(4)*, i32, i32, i32) #1
     72 
     73 declare spir_func zeroext i1 @_Z37atomic_compare_exchange_weak_explicitPVU3AS4U7_AtomiciPU3AS4ii12memory_orderS4_12memory_scope(i32 addrspace(4)*, i32 addrspace(4)*, i32, i32, i32, i32) #1
     74 
     75 attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
     76 attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
     77 attributes #2 = { nounwind }
     78 
     79 !opencl.kernels = !{!0}
     80 !opencl.enable.FP_CONTRACT = !{}
     81 !opencl.spir.version = !{!6}
     82 !opencl.ocl.version = !{!7}
     83 !opencl.used.extensions = !{!8}
     84 !opencl.used.optional.core.features = !{!8}
     85 !opencl.compiler.options = !{!8}
     86 
     87 !0 = !{void (i32 addrspace(1)*, i32 addrspace(1)*, i32)* @testAtomicCompareExchangeExplicit_cl20, !1, !2, !3, !4, !5}
     88 !1 = !{!"kernel_arg_addr_space", i32 1, i32 1, i32 0}
     89 !2 = !{!"kernel_arg_access_qual", !"none", !"none", !"none"}
     90 !3 = !{!"kernel_arg_type", !"atomic_int*", !"int*", !"int"}
     91 !4 = !{!"kernel_arg_base_type", !"_Atomic(int)*", !"int*", !"int"}
     92 !5 = !{!"kernel_arg_type_qual", !"volatile", !"", !""}
     93 !6 = !{i32 1, i32 2}
     94 !7 = !{i32 2, i32 0}
     95 !8 = !{}
     96