Tom Stellard | a59fd49 | 2015-09-21 14:59:56 +0000 | [diff] [blame] | 1 | %opencl.image2d_t = type opaque |
| 2 | %opencl.image3d_t = type opaque |
| 3 | |
| 4 | declare i32 @llvm.OpenCL.image.get.resource.id.2d( |
| 5 | %opencl.image2d_t addrspace(1)*) nounwind readnone |
| 6 | declare i32 @llvm.OpenCL.image.get.resource.id.3d( |
| 7 | %opencl.image3d_t addrspace(1)*) nounwind readnone |
| 8 | |
| 9 | declare void @llvm.r600.rat.store.typed(<4 x i32> %color, <4 x i32> %coord, i32 %rat_id) |
| 10 | |
| 11 | define void @__clc_write_imageui_2d( |
| 12 | %opencl.image2d_t addrspace(1)* nocapture %img, |
| 13 | <2 x i32> %coord, <4 x i32> %color) #0 { |
| 14 | |
| 15 | ; Coordinate int2 -> int4. |
| 16 | %e0 = extractelement <2 x i32> %coord, i32 0 |
| 17 | %e1 = extractelement <2 x i32> %coord, i32 1 |
| 18 | %coord.0 = insertelement <4 x i32> undef, i32 %e0, i32 0 |
| 19 | %coord.1 = insertelement <4 x i32> %coord.0, i32 %e1, i32 1 |
| 20 | %coord.2 = insertelement <4 x i32> %coord.1, i32 0, i32 2 |
| 21 | %coord.3 = insertelement <4 x i32> %coord.2, i32 0, i32 3 |
| 22 | |
| 23 | ; Get RAT ID. |
| 24 | %img_id = call i32 @llvm.OpenCL.image.get.resource.id.2d( |
| 25 | %opencl.image2d_t addrspace(1)* %img) |
| 26 | %rat_id = add i32 %img_id, 1 |
| 27 | |
| 28 | ; Call store intrinsic. |
| 29 | call void @llvm.r600.rat.store.typed(<4 x i32> %color, <4 x i32> %coord.3, i32 %rat_id) |
| 30 | ret void |
| 31 | } |
| 32 | |
| 33 | define void @__clc_write_imagei_2d( |
| 34 | %opencl.image2d_t addrspace(1)* nocapture %img, |
| 35 | <2 x i32> %coord, <4 x i32> %color) #0 { |
| 36 | call void @__clc_write_imageui_2d( |
| 37 | %opencl.image2d_t addrspace(1)* nocapture %img, |
| 38 | <2 x i32> %coord, <4 x i32> %color) |
| 39 | ret void |
| 40 | } |
| 41 | |
| 42 | define void @__clc_write_imagef_2d( |
| 43 | %opencl.image2d_t addrspace(1)* nocapture %img, |
| 44 | <2 x i32> %coord, <4 x float> %color) #0 { |
| 45 | %color.i32 = bitcast <4 x float> %color to <4 x i32> |
| 46 | call void @__clc_write_imageui_2d( |
| 47 | %opencl.image2d_t addrspace(1)* nocapture %img, |
| 48 | <2 x i32> %coord, <4 x i32> %color.i32) |
| 49 | ret void |
| 50 | } |
| 51 | |
| 52 | attributes #0 = { alwaysinline } |