[llvm] [SPIRV] Added opencl Pipe builtins (PR #135335)

via llvm-commits llvm-commits at lists.llvm.org
Tue May 27 23:50:03 PDT 2025


================
@@ -0,0 +1,446 @@
+; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
+
+; Test generated from the opencl test in the SPIRV-LLVM Translator (pipe_builtins.cl)
+
+; CHECK: OpCapability Kernel
+; CHECK: OpCapability Addresses
+; CHECK: OpCapability Pipes
+; CHECK: OpCapability Int64
+
+; --- Check common types ---
+; CHECK-DAG: %[[#PipeWriteTy:]] = OpTypePipe WriteOnly
+; CHECK-DAG: %[[#PipeReadTy:]] = OpTypePipe ReadOnly
+; CHECK-DAG: %[[#ReserveIdTy:]] = OpTypeReserveId
+; CHECK-DAG: %[[#BoolTy:]] = OpTypeBool
+; CHECK-DAG: %[[#Int32Ty:]] = OpTypeInt 32 0
+; CHECK-DAG: %[[#CONST:]] = OpConstant %[[#Int32Ty]] 4
+; CHECK-DAG: %[[#CONST2:]] = OpConstant %[[#Int32Ty]] 2
+; CHECK-DAG: %[[#CONST3:]] = OpConstant %[[#Int32Ty]] 3
+; CHECK-DAG: %[[#CONST4:]] = OpConstant %[[#Int32Ty]] 1
+
+; --- Function: test_pipe_convenience_write_uint ---
+; CHECK: %[[#ReadWriteInst1:]] = OpWritePipe %[[#Int32Ty]] %[[#]] %[[#]] %[[#CONST]] %[[#CONST]]
+  
+; --- Function: test_pipe_convenience_read_uint ---
+; CHECK: %[[#ReadPipeInst2:]] = OpReadPipe %[[#Int32Ty]] %[[#]] %[[#]] %[[#CONST]] %[[#CONST]]
+  
+; --- Function: test_pipe_write ---
+; CHECK: %[[#ReserveWrite1:]] = OpReserveWritePipePackets %[[#ReserveIdTy]] %[[#]] %[[#]] %[[#CONST]] %[[#CONST]]
+; CHECK: %[[#IsValidWrite1:]] = OpIsValidReserveId %[[#BoolTy]] %[[#]]
+; CHECK: %[[#ReservedWrite1:]] = OpReservedWritePipe %[[#Int32Ty]] %[[#]] %[[#]] %[[#]] %[[#]] %[[#CONST]] %[[#CONST]]
+; CHECK: OpCommitWritePipe %[[#]] %[[#]] %[[#CONST]] %[[#CONST]]
+  
+; --- Function: test_pipe_query_functions ---
+; CHECK: %[[#]] = OpGetMaxPipePackets %[[#Int32Ty]] %[[#]] %[[#CONST]] %[[#CONST]]
+; CHECK: %[[#]] = OpGetNumPipePackets %[[#Int32Ty]] %[[#]] %[[#CONST]] %[[#CONST]]
+  
+; --- Function: test_pipe_read ---
+; CHECK: %[[#ReserveRead1:]] = OpReserveReadPipePackets %[[#ReserveIdTy]] %[[#]] %[[#]] %[[#CONST]] %[[#CONST]]
+; CHECK: %[[#IsValidRead1:]] = OpIsValidReserveId %[[#BoolTy]] %[[#]]
+; CHECK: %[[#ReservedRead1:]] = OpReservedReadPipe %[[#Int32Ty]] %[[#]] %[[#]] %[[#]] %[[#]] %[[#CONST]] %[[#CONST]]
+; CHECK: OpCommitReadPipe %[[#]] %[[#]] %[[#CONST]] %[[#CONST]]
+  
+; --- Function: test_pipe_workgroup_write_char ---
+; CHECK: %[[#GRW1:]] = OpGroupReserveWritePipePackets %[[#ReserveIdTy]] %[[#CONST2]] %[[#]] %[[#]] %[[#CONST4]] %[[#CONST4]]
+; CHECK: %[[#IsValidGRW1:]] = OpIsValidReserveId %[[#BoolTy]] %[[#]]
+; CHECK: %[[#ReservedGWWrite:]] = OpReservedWritePipe %[[#Int32Ty]] %[[#]] %[[#]] %[[#]] %[[#]] %[[#CONST4]] %[[#CONST4]]
+; CHECK: OpGroupCommitWritePipe %[[#CONST2]] %[[#]] %[[#]] %[[#CONST4]] %[[#CONST4]]
+  
+; --- Function: test_pipe_workgroup_read_char ---
+; CHECK: %[[#GRR1:]] = OpGroupReserveReadPipePackets %[[#ReserveIdTy]] %[[#CONST2]] %[[#]] %[[#]] %[[#CONST4]] %[[#CONST4]]
+; CHECK: %[[#IsValidGRR1:]] = OpIsValidReserveId %[[#BoolTy]] %[[#]]
+; CHECK: %[[#ReservedGWRead:]] = OpReservedReadPipe %[[#Int32Ty]] %[[#]] %[[#]] %[[#]] %[[#]] %[[#CONST4]] %[[#CONST4]]
+; CHECK: OpGroupCommitReadPipe %[[#CONST2]] %[[#]] %[[#]] %[[#CONST4]] %[[#CONST4]]
+  
+; --- Function: test_pipe_subgroup_write_uint ---
+; CHECK: %[[#SRW1:]] = OpGroupReserveWritePipePackets %[[#ReserveIdTy]] %[[#CONST3]] %[[#]] %[[#]] %[[#CONST]] %[[#CONST]]
+; CHECK: %[[#IsValidSRW1:]] = OpIsValidReserveId %[[#BoolTy]] %[[#]]
+; CHECK: %[[#ReservedSWWrite:]] = OpReservedWritePipe %[[#Int32Ty]] %[[#]] %[[#]] %[[#]] %[[#]] %[[#CONST]] %[[#CONST]]
+; CHECK: OpGroupCommitWritePipe %[[#CONST3]] %[[#]] %[[#]] %[[#CONST]] %[[#CONST]]
+  
+; --- Function: test_pipe_subgroup_read_uint ---
+; CHECK: %[[#SRR1:]] = OpGroupReserveReadPipePackets %[[#ReserveIdTy]] %[[#CONST3]] %[[#]] %[[#]] %[[#CONST]] %[[#CONST]]
+; CHECK: %[[#IsValidSRR1:]] = OpIsValidReserveId %[[#BoolTy]] %[[#]]
+; CHECK: %[[#ReservedSWRead:]] = OpReservedReadPipe %[[#Int32Ty]] %[[#]] %[[#]] %[[#]] %[[#]] %[[#CONST]] %[[#CONST]]
+; CHECK: OpGroupCommitReadPipe %[[#CONST3]] %[[#]] %[[#]] %[[#CONST]] %[[#CONST]]
+
+ at test_pipe_workgroup_write_char.res_id = internal addrspace(3) global target("spirv.ReserveId") undef, align 8
+ at test_pipe_workgroup_read_char.res_id = internal addrspace(3) global target("spirv.ReserveId") undef, align 8
+
+; Function Attrs: convergent noinline norecurse nounwind optnone
+define dso_local spir_kernel void @test_pipe_convenience_write_uint(ptr addrspace(1) noundef align 4 %src, target("spirv.Pipe", 1) %out_pipe) #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !5 !kernel_arg_base_type !5 !kernel_arg_type_qual !6 {
----------------
EbinJose2002 wrote:

> Lets remove the unnecessary IR from the test to simply its maintenance.

I have modified the test and made it smaller.

https://github.com/llvm/llvm-project/pull/135335


More information about the llvm-commits mailing list