|
| 1 | +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=+SPV_EXT_relaxed_printf_string_address_space %s -o - | FileCheck %s |
| 2 | +; RUN: not llc -O0 -mtriple=spirv32-unknown-unknown %s -o %t.spvt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR |
| 3 | + |
| 4 | +; CHECK: OpExtension "SPV_EXT_relaxed_printf_string_address_space" |
| 5 | +; CHECK: %[[#ExtInstSetId:]] = OpExtInstImport "OpenCL.std" |
| 6 | +; CHECK-DAG: %[[#TypeInt32Id:]] = OpTypeInt 32 0 |
| 7 | +; CHECK-DAG: %[[#TypeInt8Id:]] = OpTypeInt 8 0 |
| 8 | +; CHECK-DAG: %[[#TypeInt64Id:]] = OpTypeInt 64 0 |
| 9 | +; CHECK-DAG: %[[#TypeArrayId:]] = OpTypeArray %[[#TypeInt8Id]] %[[#]] |
| 10 | +; CHECK-DAG: %[[#ConstantStorClassGlobalPtrTy:]] = OpTypePointer UniformConstant %[[#TypeArrayId]] |
| 11 | +; CHECK-DAG: %[[#WGStorClassGlobalPtrTy:]] = OpTypePointer Workgroup %[[#TypeArrayId]] |
| 12 | +; CHECK-DAG: %[[#CrossWFStorClassGlobalPtrTy:]] = OpTypePointer CrossWorkgroup %[[#TypeArrayId]] |
| 13 | +; CHECK-DAG: %[[#FunctionStorClassPtrTy:]] = OpTypePointer Function %[[#TypeInt8Id]] |
| 14 | +; CHECK-DAG: %[[#WGStorClassPtrTy:]] = OpTypePointer Workgroup %[[#TypeInt8Id]] |
| 15 | +; CHECK-DAG: %[[#CrossWFStorClassPtrTy:]] = OpTypePointer CrossWorkgroup %[[#TypeInt8Id]] |
| 16 | +; CHECK: %[[#ConstantCompositeId:]] = OpConstantComposite %[[#TypeArrayId]] %[[#]] %[[#]] %[[#]] %[[#]] %[[#]] %[[#]] |
| 17 | +; CHECK: %[[#]] = OpVariable %[[#ConstantStorClassGlobalPtrTy]] UniformConstant %[[#ConstantCompositeId]] |
| 18 | +; CHECK: %[[#]] = OpVariable %[[#CrossWFStorClassGlobalPtrTy]] CrossWorkgroup %[[#ConstantCompositeId]] |
| 19 | +; CHECK: %[[#]] = OpVariable %[[#WGStorClassGlobalPtrTy]] Workgroup %[[#ConstantCompositeId]] |
| 20 | +; CHECK: %[[#GEP1:]] = OpInBoundsPtrAccessChain %[[#FunctionStorClassPtrTy]] %[[#]] %[[#]] %[[#]] |
| 21 | +; CHECK: %[[#]] = OpExtInst %[[#TypeInt32Id]] %[[#ExtInstSetId:]] printf %[[#GEP1]] |
| 22 | +; CHECK: %[[#GEP2:]] = OpInBoundsPtrAccessChain %[[#CrossWFStorClassPtrTy]] %[[#]] %[[#]] %[[#]] |
| 23 | +; CHECK: %[[#]] = OpExtInst %[[#TypeInt32Id]] %[[#ExtInstSetId:]] printf %[[#GEP2]] |
| 24 | +; CHECK: %[[#GEP3:]] = OpInBoundsPtrAccessChain %[[#WGStorClassPtrTy]] %[[#]] %[[#]] %[[#]] |
| 25 | +; CHECK: %[[#]] = OpExtInst %[[#TypeInt32Id]] %[[#ExtInstSetId:]] printf %[[#GEP3]] |
| 26 | + |
| 27 | +; CHECK-ERROR: LLVM ERROR: SPV_EXT_relaxed_printf_string_address_space is required because printf uses a format string not in constant address space. |
| 28 | + |
| 29 | +@0 = internal unnamed_addr addrspace(2) constant [6 x i8] c"Test\0A\00", align 1 |
| 30 | +@1 = internal unnamed_addr addrspace(1) constant [6 x i8] c"Test\0A\00", align 1 |
| 31 | +@2 = internal unnamed_addr addrspace(3) constant [6 x i8] c"Test\0A\00", align 1 |
| 32 | + |
| 33 | +define spir_kernel void @test() { |
| 34 | + %tmp1 = alloca [6 x i8], align 1 |
| 35 | + call void @llvm.memcpy.p0.p2.i64(ptr align 1 %tmp1, ptr addrspace(2) align 1 @0, i64 6, i1 false) |
| 36 | + %1 = getelementptr inbounds [6 x i8], ptr %tmp1, i32 0, i32 0 |
| 37 | + %2 = call spir_func i32 @_Z18__spirv_ocl_printfPc(ptr %1) |
| 38 | + %3 = getelementptr inbounds [6 x i8], ptr addrspace(1) @1, i32 0, i32 0 |
| 39 | + %4 = call spir_func i32 @_Z18__spirv_ocl_printfPU3AS1c(ptr addrspace(1) %3) |
| 40 | + %5 = getelementptr inbounds [6 x i8], ptr addrspace(3) @2, i32 0, i32 0 |
| 41 | + %6 = call spir_func i32 @_Z18__spirv_ocl_printfPU3AS3c(ptr addrspace(3) %5) |
| 42 | + ret void |
| 43 | +} |
| 44 | + |
| 45 | +declare spir_func i32 @_Z18__spirv_ocl_printfPc(ptr) |
| 46 | +declare spir_func i32 @_Z18__spirv_ocl_printfPU3AS1c(ptr addrspace(1)) |
| 47 | +declare spir_func i32 @_Z18__spirv_ocl_printfPU3AS3c(ptr addrspace(3)) |
| 48 | +declare void @llvm.memcpy.p0.p2.i64(ptr captures(none), ptr addrspace(2) captures(none) readonly, i64, i1) |
0 commit comments