| 1 |
; RUN: llc -verify-machineinstrs -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 |
; CHECK: OpCapability Kernel |
| 5 |
; CHECK: OpCapability Addresses |
| 6 |
; CHECK: OpCapability Pipes |
| 7 |
; CHECK: OpCapability Int8 |
| 8 |
; CHECK: OpCapability GenericPointer |
| 9 |
|
| 10 |
; CHECK-DAG: %[[#PipeWriteTy:]] = OpTypePipe WriteOnly |
| 11 |
; CHECK-DAG: %[[#PipeReadTy:]] = OpTypePipe ReadOnly |
| 12 |
; CHECK-DAG: %[[#ReserveIdTy:]] = OpTypeReserveId |
| 13 |
; CHECK-DAG: %[[#BoolTy:]] = OpTypeBool |
| 14 |
; CHECK-DAG: %[[#Int32Ty:]] = OpTypeInt 32 0 |
| 15 |
; CHECK-DAG: %[[#Uint1:]] = OpConstant %[[#Int32Ty]] 1 |
| 16 |
; CHECK-DAG: %[[#Uint2:]] = OpConstant %[[#Int32Ty]] 2 |
| 17 |
; CHECK-DAG: %[[#Uint3:]] = OpConstant %[[#Int32Ty]] 3 |
| 18 |
; CHECK-DAG: %[[#Uint4:]] = OpConstant %[[#Int32Ty]] 4 |
| 19 |
; CHECK-DAG: %[[#NullUint:]] = OpConstantNull %[[#Int32Ty]] |
| 20 |
|
| 21 |
; CHECK: OpFunction |
| 22 |
; CHECK: %[[#FuncParam1:]] = OpFunctionParameter %[[#PipeWriteTy]] |
| 23 |
; CHECK: %[[#FuncParam2:]] = OpFunctionParameter %[[#PipeReadTy]] |
| 24 |
|
| 25 |
; CHECK: %[[#BasicWriteReserve:]] = OpReserveWritePipePackets %[[#ReserveIdTy]] %[[#FuncParam1]] %[[#Uint1]] %[[#Uint4]] %[[#Uint4]] |
| 26 |
; CHECK: OpWritePipe %[[#Int32Ty]] %[[#FuncParam1]] %[[#]] %[[#Uint4]] %[[#Uint4]] |
| 27 |
; CHECK: OpCommitWritePipe %[[#FuncParam1]] %[[#BasicWriteReserve]] %[[#Uint4]] %[[#Uint4]] |
| 28 |
; CHECK: %[[#BasicReadReserve:]] = OpReserveReadPipePackets %[[#ReserveIdTy]] %[[#FuncParam2]] %[[#Uint1]] %[[#Uint4]] %[[#Uint4]] |
| 29 |
; CHECK: OpReadPipe %[[#Int32Ty]] %[[#FuncParam2]] %[[#]] %[[#Uint4]] %[[#Uint4]] |
| 30 |
; CHECK: OpCommitReadPipe %[[#FuncParam2]] %[[#BasicReadReserve]] %[[#Uint4]] %[[#Uint4]] |
| 31 |
|
| 32 |
; --- Reserved pipe operations --- |
| 33 |
; CHECK: %[[#ReservedWriteReserve:]] = OpReserveWritePipePackets %[[#ReserveIdTy]] %[[#FuncParam1]] %[[#Uint1]] %[[#Uint4]] %[[#Uint4]] |
| 34 |
; CHECK: %[[#ReservedWrite:]] = OpReservedWritePipe %[[#Int32Ty]] %[[#FuncParam1]] %[[#ReservedWriteReserve]] %[[#NullUint]] %[[#]] %[[#Uint4]] %[[#Uint4]] |
| 35 |
; CHECK: %[[#IsValidWrite:]] = OpIsValidReserveId %[[#BoolTy]] %[[#ReservedWriteReserve]] |
| 36 |
; CHECK: OpCommitWritePipe %[[#FuncParam1]] %[[#ReservedWriteReserve]] %[[#Uint4]] %[[#Uint4]] |
| 37 |
; CHECK: %[[#ReservedReadReserve:]] = OpReserveReadPipePackets %[[#ReserveIdTy]] %[[#FuncParam2]] %[[#Uint1]] %[[#Uint4]] %[[#Uint4]] |
| 38 |
; CHECK: %[[#ReservedRead:]] = OpReservedReadPipe %[[#Int32Ty]] %[[#FuncParam2]] %[[#ReservedReadReserve]] %[[#NullUint]] %[[#]] %[[#Uint4]] %[[#Uint4]] |
| 39 |
; CHECK: %[[#IsValidRead:]] = OpIsValidReserveId %[[#BoolTy]] %[[#ReservedReadReserve]] |
| 40 |
; CHECK: OpCommitReadPipe %[[#FuncParam2]] %[[#ReservedReadReserve]] %[[#Uint4]] %[[#Uint4]] |
| 41 |
|
| 42 |
; --- Pipe packet queries --- |
| 43 |
; CHECK: %[[#MaxPacketsWO:]] = OpGetMaxPipePackets %[[#Int32Ty]] %[[#FuncParam1]] %[[#Uint4]] %[[#Uint4]] |
| 44 |
; CHECK: OpStore %[[#]] %[[#MaxPacketsWO]] Aligned 4 |
| 45 |
; CHECK: %[[#NumPacketsWO:]] = OpGetNumPipePackets %[[#Int32Ty]] %[[#FuncParam1]] %[[#Uint4]] %[[#Uint4]] |
| 46 |
; CHECK: OpStore %[[#]] %[[#NumPacketsWO]] Aligned 4 |
| 47 |
; CHECK: %[[#MaxPacketsRO:]] = OpGetMaxPipePackets %[[#Int32Ty]] %[[#FuncParam2]] %[[#Uint4]] %[[#Uint4]] |
| 48 |
; CHECK: OpStore %[[#]] %[[#MaxPacketsRO]] Aligned 4 |
| 49 |
; CHECK: %[[#NumPacketsRO:]] = OpGetNumPipePackets %[[#Int32Ty]] %[[#FuncParam2]] %[[#Uint4]] %[[#Uint4]] |
| 50 |
; CHECK: OpStore %[[#]] %[[#NumPacketsRO]] Aligned 4 |
| 51 |
|
| 52 |
; --- Workgroup operations --- |
| 53 |
; CHECK: %[[#WorkgroupWriteReserve:]] = OpGroupReserveWritePipePackets %[[#ReserveIdTy]] %[[#Uint2]] %[[#FuncParam1]] %[[#Uint1]] %[[#Uint1]] %[[#Uint1]] |
| 54 |
; CHECK: OpGroupCommitWritePipe %[[#Uint2]] %[[#FuncParam1]] %[[#WorkgroupWriteReserve]] %[[#Uint1]] %[[#Uint1]] |
| 55 |
; CHECK: %[[#WorkgroupReadReserve:]] = OpGroupReserveReadPipePackets %[[#ReserveIdTy]] %[[#Uint2]] %[[#FuncParam2]] %[[#Uint1]] %[[#Uint1]] %[[#Uint1]] |
| 56 |
; CHECK: OpGroupCommitReadPipe %[[#Uint2]] %[[#FuncParam2]] %[[#WorkgroupReadReserve]] %[[#Uint1]] %[[#Uint1]] |
| 57 |
|
| 58 |
; --- Subgroup operations --- |
| 59 |
; CHECK: %[[#SubgroupWriteReserve:]] = OpGroupReserveWritePipePackets %[[#ReserveIdTy]] %[[#Uint3]] %[[#FuncParam1]] %[[#Uint1]] %[[#Uint4]] %[[#Uint4]] |
| 60 |
; CHECK: OpGroupCommitWritePipe %[[#Uint3]] %[[#FuncParam1]] %[[#SubgroupWriteReserve]] %[[#Uint4]] %[[#Uint4]] |
| 61 |
; CHECK: %[[#SubgroupReadReserve:]] = OpGroupReserveReadPipePackets %[[#ReserveIdTy]] %[[#Uint3]] %[[#FuncParam2]] %[[#Uint1]] %[[#Uint4]] %[[#Uint4]] |
| 62 |
; CHECK: OpGroupCommitReadPipe %[[#Uint3]] %[[#FuncParam2]] %[[#SubgroupReadReserve]] %[[#Uint4]] %[[#Uint4]] |
| 63 |
|
| 64 |
define spir_kernel void @test_pipe_builtins( |
| 65 |
target("spirv.Pipe", 1) %out_pipe, |
| 66 |
target("spirv.Pipe", 0) %in_pipe, |
| 67 |
ptr addrspace(4) %src, |
| 68 |
ptr addrspace(4) %dst, |
| 69 |
ptr addrspace(1) %max_packets_wo, |
| 70 |
ptr addrspace(1) %num_packets_wo, |
| 71 |
ptr addrspace(1) %max_packets_ro, |
| 72 |
ptr addrspace(1) %num_packets_ro |
| 73 |
) { |
| 74 |
entry: |
| 75 |
; Basic pipe operations |
| 76 |
%0 = call spir_func target("spirv.ReserveId") @__reserve_write_pipe(target("spirv.Pipe", 1) %out_pipe, i32 1, i32 4, i32 4) |
| 77 |
%1 = call spir_func i32 @__write_pipe_2(target("spirv.Pipe", 1) %out_pipe, ptr addrspace(4) %src, i32 4, i32 4) |
| 78 |
call spir_func void @__commit_write_pipe(target("spirv.Pipe", 1) %out_pipe, target("spirv.ReserveId") %0, i32 4, i32 4) |
| 79 |
|
| 80 |
%2 = call spir_func target("spirv.ReserveId") @__reserve_read_pipe(target("spirv.Pipe", 0) %in_pipe, i32 1, i32 4, i32 4) |
| 81 |
%3 = call spir_func i32 @__read_pipe_2(target("spirv.Pipe", 0) %in_pipe, ptr addrspace(4) %dst, i32 4, i32 4) |
| 82 |
call spir_func void @__commit_read_pipe(target("spirv.Pipe", 0) %in_pipe, target("spirv.ReserveId") %2, i32 4, i32 4) |
| 83 |
|
| 84 |
; Reserved pipe operations |
| 85 |
%4 = call spir_func target("spirv.ReserveId") @__reserve_write_pipe(target("spirv.Pipe", 1) %out_pipe, i32 1, i32 4, i32 4) |
| 86 |
%5 = call spir_func i32 @__write_pipe_4(target("spirv.Pipe", 1) %out_pipe, target("spirv.ReserveId") %4, i32 0, ptr addrspace(4) %src, i32 4, i32 4) |
| 87 |
%6 = call spir_func i1 @_Z19is_valid_reserve_id13ocl_reserveid(target("spirv.ReserveId") %4) |
| 88 |
call spir_func void @__commit_write_pipe(target("spirv.Pipe", 1) %out_pipe, target("spirv.ReserveId") %4, i32 4, i32 4) |
| 89 |
|
| 90 |
%7 = call spir_func target("spirv.ReserveId") @__reserve_read_pipe(target("spirv.Pipe", 0) %in_pipe, i32 1, i32 4, i32 4) |
| 91 |
%8 = call spir_func i32 @__read_pipe_4(target("spirv.Pipe", 0) %in_pipe, target("spirv.ReserveId") %7, i32 0, ptr addrspace(4) %dst, i32 4, i32 4) |
| 92 |
%9 = call spir_func i1 @_Z19is_valid_reserve_id13ocl_reserveid(target("spirv.ReserveId") %7) |
| 93 |
call spir_func void @__commit_read_pipe(target("spirv.Pipe", 0) %in_pipe, target("spirv.ReserveId") %7, i32 4, i32 4) |
| 94 |
|
| 95 |
; Pipe packet queries |
| 96 |
%10 = call spir_func i32 @__get_pipe_max_packets_wo(target("spirv.Pipe", 1) %out_pipe, i32 4, i32 4) |
| 97 |
store i32 %10, ptr addrspace(1) %max_packets_wo, align 4 |
| 98 |
%11 = call spir_func i32 @__get_pipe_num_packets_wo(target("spirv.Pipe", 1) %out_pipe, i32 4, i32 4) |
| 99 |
store i32 %11, ptr addrspace(1) %num_packets_wo, align 4 |
| 100 |
%12 = call spir_func i32 @__get_pipe_max_packets_ro(target("spirv.Pipe", 0) %in_pipe, i32 4, i32 4) |
| 101 |
store i32 %12, ptr addrspace(1) %max_packets_ro, align 4 |
| 102 |
%13 = call spir_func i32 @__get_pipe_num_packets_ro(target("spirv.Pipe", 0) %in_pipe, i32 4, i32 4) |
| 103 |
store i32 %13, ptr addrspace(1) %num_packets_ro, align 4 |
| 104 |
|
| 105 |
; Workgroup operations |
| 106 |
%14 = call spir_func target("spirv.ReserveId") @__work_group_reserve_write_pipe(target("spirv.Pipe", 1) %out_pipe, i32 1, i32 1, i32 1) |
| 107 |
call spir_func void @__work_group_commit_write_pipe(target("spirv.Pipe", 1) %out_pipe, target("spirv.ReserveId") %14, i32 1, i32 1) |
| 108 |
%15 = call spir_func target("spirv.ReserveId") @__work_group_reserve_read_pipe(target("spirv.Pipe", 0) %in_pipe, i32 1, i32 1, i32 1) |
| 109 |
call spir_func void @__work_group_commit_read_pipe(target("spirv.Pipe", 0) %in_pipe, target("spirv.ReserveId") %15, i32 1, i32 1) |
| 110 |
|
| 111 |
; Subgroup operations |
| 112 |
%16 = call spir_func target("spirv.ReserveId") @__sub_group_reserve_write_pipe(target("spirv.Pipe", 1) %out_pipe, i32 1, i32 4, i32 4) |
| 113 |
call spir_func void @__sub_group_commit_write_pipe(target("spirv.Pipe", 1) %out_pipe, target("spirv.ReserveId") %16, i32 4, i32 4) |
| 114 |
%17 = call spir_func target("spirv.ReserveId") @__sub_group_reserve_read_pipe(target("spirv.Pipe", 0) %in_pipe, i32 1, i32 4, i32 4) |
| 115 |
call spir_func void @__sub_group_commit_read_pipe(target("spirv.Pipe", 0) %in_pipe, target("spirv.ReserveId") %17, i32 4, i32 4) |
| 116 |
|
| 117 |
ret void |
| 118 |
} |
| 119 |
|
| 120 |
declare spir_func target("spirv.ReserveId") @__reserve_write_pipe(target("spirv.Pipe", 1), i32, i32, i32) |
| 121 |
declare spir_func target("spirv.ReserveId") @__reserve_read_pipe(target("spirv.Pipe", 0), i32, i32, i32) |
| 122 |
declare spir_func i32 @__write_pipe_2(target("spirv.Pipe", 1), ptr addrspace(4), i32, i32) |
| 123 |
declare spir_func i32 @__read_pipe_2(target("spirv.Pipe", 0), ptr addrspace(4), i32, i32) |
| 124 |
declare spir_func i32 @__write_pipe_4(target("spirv.Pipe", 1), target("spirv.ReserveId"), i32, ptr addrspace(4), i32, i32) |
| 125 |
declare spir_func i32 @__read_pipe_4(target("spirv.Pipe", 0), target("spirv.ReserveId"), i32, ptr addrspace(4), i32, i32) |
| 126 |
declare spir_func void @__commit_write_pipe(target("spirv.Pipe", 1), target("spirv.ReserveId"), i32, i32) |
| 127 |
declare spir_func void @__commit_read_pipe(target("spirv.Pipe", 0), target("spirv.ReserveId"), i32, i32) |
| 128 |
declare spir_func i1 @_Z19is_valid_reserve_id13ocl_reserveid(target("spirv.ReserveId")) |
| 129 |
declare spir_func i32 @__get_pipe_max_packets_wo(target("spirv.Pipe", 1), i32, i32) |
| 130 |
declare spir_func i32 @__get_pipe_num_packets_wo(target("spirv.Pipe", 1), i32, i32) |
| 131 |
declare spir_func i32 @__get_pipe_max_packets_ro(target("spirv.Pipe", 0), i32, i32) |
| 132 |
declare spir_func i32 @__get_pipe_num_packets_ro(target("spirv.Pipe", 0), i32, i32) |
| 133 |
declare spir_func target("spirv.ReserveId") @__work_group_reserve_write_pipe(target("spirv.Pipe", 1), i32, i32, i32) |
| 134 |
declare spir_func void @__work_group_commit_write_pipe(target("spirv.Pipe", 1), target("spirv.ReserveId"), i32, i32) |
| 135 |
declare spir_func target("spirv.ReserveId") @__work_group_reserve_read_pipe(target("spirv.Pipe", 0), i32, i32, i32) |
| 136 |
declare spir_func void @__work_group_commit_read_pipe(target("spirv.Pipe", 0), target("spirv.ReserveId"), i32, i32) |
| 137 |
declare spir_func target("spirv.ReserveId") @__sub_group_reserve_write_pipe(target("spirv.Pipe", 1), i32, i32, i32) |
| 138 |
declare spir_func void @__sub_group_commit_write_pipe(target("spirv.Pipe", 1), target("spirv.ReserveId"), i32, i32) |
| 139 |
declare spir_func target("spirv.ReserveId") @__sub_group_reserve_read_pipe(target("spirv.Pipe", 0), i32, i32, i32) |
| 140 |
declare spir_func void @__sub_group_commit_read_pipe(target("spirv.Pipe", 0), target("spirv.ReserveId"), i32, i32) |