| 1 |
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s |
| 2 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 3 |
|
| 4 |
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s |
| 5 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 6 |
|
| 7 |
; CHECK-DAG: %[[#TyEvent:]] = OpTypeEvent |
| 8 |
; CHECK-DAG: %[[#TyStruct:]] = OpTypeStruct %[[#TyEvent]] |
| 9 |
; CHECK-DAG: %[[#ConstEvent:]] = OpConstantNull %[[#TyEvent]] |
| 10 |
; CHECK-DAG: %[[#TyEventPtr:]] = OpTypePointer Function %[[#TyEvent]] |
| 11 |
; CHECK-DAG: %[[#TyEventPtrGen:]] = OpTypePointer Generic %[[#TyEvent]] |
| 12 |
; CHECK-DAG: %[[#TyStructPtr:]] = OpTypePointer Function %[[#TyStruct]] |
| 13 |
; CHECK-DAG: %[[#TyChar:]] = OpTypeInt 8 0 |
| 14 |
; CHECK-DAG: %[[#TyV4:]] = OpTypeVector %[[#TyChar]] 4 |
| 15 |
; CHECK-DAG: %[[#TyStructV4:]] = OpTypeStruct %[[#TyV4]] |
| 16 |
; CHECK-DAG: %[[#TyPtrSV4_CW:]] = OpTypePointer CrossWorkgroup %[[#TyStructV4]] |
| 17 |
; CHECK-DAG: %[[#TyPtrV4_W:]] = OpTypePointer Workgroup %[[#TyV4]] |
| 18 |
; CHECK-DAG: %[[#TyPtrV4_CW:]] = OpTypePointer CrossWorkgroup %[[#TyV4]] |
| 19 |
; CHECK-DAG: %[[#TyHalf:]] = OpTypeFloat 16 |
| 20 |
; CHECK-DAG: %[[#TyHalfV2:]] = OpTypeVector %[[#TyHalf]] 2 |
| 21 |
; CHECK-DAG: %[[#TyHalfV2_W:]] = OpTypePointer Workgroup %[[#TyHalfV2]] |
| 22 |
; CHECK-DAG: %[[#TyHalfV2_CW:]] = OpTypePointer CrossWorkgroup %[[#TyHalfV2]] |
| 23 |
|
| 24 |
; Check correct translation of __spirv_GroupAsyncCopy and target("spirv.Event") zeroinitializer |
| 25 |
|
| 26 |
; CHECK: OpFunction |
| 27 |
; CHECK: %[[#HalfA1:]] = OpFunctionParameter %[[#TyHalfV2_W:]] |
| 28 |
; CHECK: %[[#HalfA2:]] = OpFunctionParameter %[[#TyHalfV2_CW:]] |
| 29 |
; CHECK: OpGroupAsyncCopy %[[#TyEvent]] %[[#]] %[[#HalfA1]] %[[#HalfA2]] %[[#]] %[[#]] %[[#ConstEvent]] |
| 30 |
; CHECK: OpFunctionEnd |
| 31 |
|
| 32 |
%StructEvent = type { target("spirv.Event") } |
| 33 |
|
| 34 |
@G_r = global target("spirv.Event") poison |
| 35 |
|
| 36 |
define spir_kernel void @test_half(ptr addrspace(3) %_arg1, ptr addrspace(1) %_arg2) { |
| 37 |
entry: |
| 38 |
%r = tail call spir_func target("spirv.Event") @_Z22__spirv_GroupAsyncCopyjPU3AS3Dv2_DF16_PU3AS1KS_mm9ocl_event(i32 2, ptr addrspace(3) %_arg1, ptr addrspace(1) %_arg2, i64 16, i64 10, target("spirv.Event") zeroinitializer) |
| 39 |
store target("spirv.Event") %r, ptr @G_r |
| 40 |
ret void |
| 41 |
} |
| 42 |
|
| 43 |
declare dso_local spir_func target("spirv.Event") @_Z22__spirv_GroupAsyncCopyjPU3AS3Dv2_DF16_PU3AS1KS_mm9ocl_event(i32 noundef, ptr addrspace(3) noundef, ptr addrspace(1) noundef, i64 noundef, i64 noundef, target("spirv.Event")) |
| 44 |
|
| 45 |
; CHECK: OpFunction |
| 46 |
; CHECK: OpFunctionParameter |
| 47 |
; CHECK: %[[#Src:]] = OpFunctionParameter |
| 48 |
; CHECK: %[[#EventVar:]] = OpVariable %[[#TyEventPtr]] Function |
| 49 |
; CHECK: %[[#Dest:]] = OpInBoundsPtrAccessChain |
| 50 |
; CHECK: %[[#CopyRes:]] = OpGroupAsyncCopy %[[#TyEvent]] %[[#]] %[[#Dest]] %[[#Src]] %[[#]] %[[#]] %[[#ConstEvent]] |
| 51 |
; CHECK: OpStore %[[#EventVar]] %[[#CopyRes]] |
| 52 |
; CHECK: OpFunctionEnd |
| 53 |
|
| 54 |
define spir_kernel void @foo(ptr addrspace(1) %_arg_out_ptr, ptr addrspace(3) %_arg_local_acc) { |
| 55 |
entry: |
| 56 |
%var = alloca %StructEvent |
| 57 |
%dev_event.i.sroa.0 = alloca target("spirv.Event") |
| 58 |
%add.ptr.i26 = getelementptr inbounds i32, ptr addrspace(1) %_arg_out_ptr, i64 0 |
| 59 |
%call3.i = tail call spir_func target("spirv.Event") @_Z22__spirv_GroupAsyncCopyjPU3AS1iPU3AS3Kimm9ocl_event(i32 2, ptr addrspace(1) %add.ptr.i26, ptr addrspace(3) %_arg_local_acc, i64 16, i64 10, target("spirv.Event") zeroinitializer) |
| 60 |
store target("spirv.Event") %call3.i, ptr %dev_event.i.sroa.0 |
| 61 |
ret void |
| 62 |
} |
| 63 |
|
| 64 |
declare dso_local spir_func target("spirv.Event") @_Z22__spirv_GroupAsyncCopyjPU3AS1iPU3AS3Kimm9ocl_event(i32, ptr addrspace(1), ptr addrspace(3), i64, i64, target("spirv.Event")) |
| 65 |
|
| 66 |
; Check correct type inference when calling __spirv_GroupAsyncCopy: |
| 67 |
; we expect that the Backend is able to deduce a type of the %_arg_Local |
| 68 |
; given facts that it's possible to deduce a type of the %_arg |
| 69 |
; and %_arg_Local and %_arg are source/destination arguments in OpGroupAsyncCopy |
| 70 |
|
| 71 |
; CHECK: OpFunction |
| 72 |
; CHECK: %[[#BarArg1:]] = OpFunctionParameter %[[#TyPtrV4_W]] |
| 73 |
; CHECK: %[[#BarArg2:]] = OpFunctionParameter %[[#TyPtrSV4_CW]] |
| 74 |
; CHECK: %[[#EventVarBar:]] = OpVariable %[[#TyStructPtr]] Function |
| 75 |
; CHECK: %[[#EventVarBarCasted2:]] = OpBitcast %[[#TyEventPtr]] %[[#EventVarBar]] |
| 76 |
; CHECK: %[[#ResBar:]] = OpGroupAsyncCopy %[[#TyEvent]] %[[#]] %[[#BarArg1]] %[[#]] %[[#]] %[[#]] %[[#ConstEvent]] |
| 77 |
; CHECK: %[[#EventVarBarCasted:]] = OpBitcast %[[#TyEventPtr]] %[[#EventVarBar]] |
| 78 |
; CHECK: OpStore %[[#EventVarBarCasted]] %[[#ResBar]] |
| 79 |
; CHECK: %[[#EventVarBarGen:]] = OpPtrCastToGeneric %[[#TyEventPtrGen]] %[[#EventVarBarCasted2]] |
| 80 |
; CHECK: OpGroupWaitEvents %[[#]] %[[#]] %[[#EventVarBarGen]] |
| 81 |
; CHECK: OpFunctionEnd |
| 82 |
|
| 83 |
%Vec4 = type { <4 x i8> } |
| 84 |
|
| 85 |
define spir_kernel void @bar(ptr addrspace(3) %_arg_Local, ptr addrspace(1) readonly %_arg) { |
| 86 |
entry: |
| 87 |
%E1 = alloca %StructEvent |
| 88 |
%srcptr = getelementptr inbounds %Vec4, ptr addrspace(1) %_arg, i64 0 |
| 89 |
%r1 = tail call spir_func target("spirv.Event") @_Z22__spirv_GroupAsyncCopyjPU3AS3Dv4_aPU3AS1KS_mm9ocl_event(i32 2, ptr addrspace(3) %_arg_Local, ptr addrspace(1) %srcptr, i64 16, i64 10, target("spirv.Event") zeroinitializer) |
| 90 |
store target("spirv.Event") %r1, ptr %E1 |
| 91 |
%E.ascast.i = addrspacecast ptr %E1 to ptr addrspace(4) |
| 92 |
call spir_func void @_Z23__spirv_GroupWaitEventsjiP9ocl_event(i32 2, i32 1, ptr addrspace(4) %E.ascast.i) |
| 93 |
ret void |
| 94 |
} |
| 95 |
|
| 96 |
declare dso_local spir_func target("spirv.Event") @_Z22__spirv_GroupAsyncCopyjPU3AS3Dv4_aPU3AS1KS_mm9ocl_event(i32, ptr addrspace(3), ptr addrspace(1), i64, i64, target("spirv.Event")) |
| 97 |
declare dso_local spir_func void @_Z23__spirv_GroupWaitEventsjiP9ocl_event(i32, i32, ptr addrspace(4)) |