| 1 |
; RUN: llvm-as %s -o %t.bc |
| 2 |
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_INTEL_16bit_atomics |
| 3 |
; RUN: llvm-spirv -to-text %t.spv -o %t.spt |
| 4 |
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV |
| 5 |
|
| 6 |
; RUN: llvm-spirv -r --spirv-target-env=CL2.0 %t.spv -o %t.rev.bc |
| 7 |
; RUN: llvm-dis %t.rev.bc |
| 8 |
; RUN: FileCheck < %t.rev.ll %s --check-prefixes=CHECK-LLVM |
| 9 |
|
| 10 |
; Check that without extension we don't use its capabilities - there is no |
| 11 |
; limitation on using i16 with atomic instruction in the core specification. |
| 12 |
; RUN: llvm-spirv %t.bc -o %t.noext.spv |
| 13 |
; RUN: spirv-val %t.noext.spv |
| 14 |
; RUN: llvm-spirv -to-text %t.noext.spv -o %t.noext.spt |
| 15 |
; RUN: FileCheck < %t.noext.spt %s --check-prefix=CHECK-SPIRV-NOEXT |
| 16 |
|
| 17 |
; CHECK-SPIRV: Capability Int16 |
| 18 |
; CHECK-SPIRV: Capability AtomicInt16CompareExchangeINTEL |
| 19 |
; CHECK-SPIRV-NOT: Capability Int16AtomicsINTEL |
| 20 |
; CHECK-SPIRV: Extension "SPV_INTEL_16bit_atomics" |
| 21 |
|
| 22 |
; CHECK-SPIRV-NOEXT: Capability Int16 |
| 23 |
; CHECK-SPIRV-NOEXT-NOT: Capability AtomicInt16CompareExchangeINTEL |
| 24 |
; CHECK-SPIRV-NOEXT-NOT: Capability Int16AtomicsINTEL |
| 25 |
; CHECK-SPIRV-NOEXT-NOT: Extension "SPV_INTEL_16bit_atomics" |
| 26 |
|
| 27 |
; CHECK-SPIRV-DAG: Constant [[#]] [[#DeviceScope:]] 1 |
| 28 |
; CHECK-SPIRV-DAG: Constant [[#]] [[#Release:]] 4 |
| 29 |
; CHECK-SPIRV-DAG: Constant [[#]] [[#SequentiallyConsistent:]] 16 |
| 30 |
; CHECK-SPIRV-DAG: Constant [[#]] [[#Acquire:]] 2 |
| 31 |
|
| 32 |
; CHECK-LLVM: call spir_func void @_Z21atomic_store_explicitPU3AS4VU7_Atomicss12memory_order12memory_scope |
| 33 |
; CHECK-LLVM: call spir_func i16 @_Z20atomic_load_explicitPU3AS4VU7_Atomics12memory_order12memory_scope |
| 34 |
; CHECK-LLVM: call spir_func i16 @_Z24atomic_exchange_explicitPU3AS4VU7_Atomicss12memory_order12memory_scope |
| 35 |
; CHECK-LLVM: call spir_func i1 @_Z39atomic_compare_exchange_strong_explicitPU3AS4VU7_AtomicsPU3AS4ss12memory_orderS4_12memory_scope |
| 36 |
|
| 37 |
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" |
| 38 |
target triple = "spir64" |
| 39 |
|
| 40 |
@ui = common dso_local addrspace(1) global i16 0, align 4 |
| 41 |
; Function Attrs: nounwind |
| 42 |
define dso_local spir_func void @test() { |
| 43 |
entry: |
| 44 |
; CHECK-SPIRV: Variable [[#]] [[#PTR:]] 7 |
| 45 |
%0 = alloca i16 |
| 46 |
; CHECK-SPIRV: AtomicStore [[#PTR]] [[#DeviceScope]] [[#Release]] [[#]] |
| 47 |
store atomic i16 0, ptr %0 release, align 4 |
| 48 |
; CHECK-SPIRV: AtomicLoad [[#]] [[#]] [[#PTR]] [[#DeviceScope]] [[#Acquire]] |
| 49 |
%1 = load atomic i16, ptr %0 acquire, align 4 |
| 50 |
; CHECK-SPIRV: AtomicExchange [[#]] [[#]] [[#]] [[#DeviceScope]] [[#]] {{.+}} |
| 51 |
%2 = atomicrmw xchg ptr addrspace(1) @ui, i16 42 acq_rel |
| 52 |
; CHECK-SPIRV: AtomicCompareExchange [[#]] [[#]] [[#]] [[#DeviceScope]] [[#SequentiallyConsistent]] [[#Acquire]] {{.+}} |
| 53 |
%3 = cmpxchg ptr %0, i16 128, i16 456 seq_cst acquire |
| 54 |
ret void |
| 55 |
} |