Tom Stellard | 9a7d4a9 | 2015-09-21 14:59:54 +0000 | [diff] [blame] | 1 | %opencl.image2d_t = type opaque |
| 2 | |
| 3 | declare <4 x float> @llvm.R600.tex(<4 x float>, i32, i32, i32, i32, i32, i32, |
| 4 | i32, i32, i32) readnone |
| 5 | declare i32 @llvm.OpenCL.image.get.resource.id.2d( |
| 6 | %opencl.image2d_t addrspace(1)*) nounwind readnone |
| 7 | declare i32 @llvm.OpenCL.sampler.get.resource.id(i32) readnone |
| 8 | |
| 9 | define <4 x float> @__clc_v4f_from_v2f(<2 x float> %v) alwaysinline { |
| 10 | %e0 = extractelement <2 x float> %v, i32 0 |
| 11 | %e1 = extractelement <2 x float> %v, i32 1 |
| 12 | %res.0 = insertelement <4 x float> undef, float %e0, i32 0 |
| 13 | %res.1 = insertelement <4 x float> %res.0, float %e1, i32 1 |
| 14 | %res.2 = insertelement <4 x float> %res.1, float 0.0, i32 2 |
| 15 | %res.3 = insertelement <4 x float> %res.2, float 0.0, i32 3 |
| 16 | ret <4 x float> %res.3 |
| 17 | } |
| 18 | |
| 19 | define <4 x float> @__clc_read_imagef_tex( |
| 20 | %opencl.image2d_t addrspace(1)* nocapture %img, |
| 21 | i32 %sampler, <2 x float> %coord) alwaysinline { |
| 22 | entry: |
| 23 | %coord_v4 = call <4 x float> @__clc_v4f_from_v2f(<2 x float> %coord) |
| 24 | %smp_id = call i32 @llvm.OpenCL.sampler.get.resource.id(i32 %sampler) |
| 25 | %img_id = call i32 @llvm.OpenCL.image.get.resource.id.2d( |
| 26 | %opencl.image2d_t addrspace(1)* %img) |
| 27 | %tex_id = add i32 %img_id, 2 ; First 2 IDs are reserved. |
| 28 | |
| 29 | %coord_norm = and i32 %sampler, 1 |
| 30 | %is_norm = icmp eq i32 %coord_norm, 1 |
| 31 | br i1 %is_norm, label %NormCoord, label %UnnormCoord |
| 32 | NormCoord: |
| 33 | %data.norm = call <4 x float> @llvm.R600.tex( |
| 34 | <4 x float> %coord_v4, |
| 35 | i32 0, i32 0, i32 0, ; Offset. |
| 36 | i32 2, i32 %smp_id, |
| 37 | i32 1, i32 1, i32 1, i32 1) ; Normalized coords. |
| 38 | ret <4 x float> %data.norm |
| 39 | UnnormCoord: |
| 40 | %data.unnorm = call <4 x float> @llvm.R600.tex( |
| 41 | <4 x float> %coord_v4, |
| 42 | i32 0, i32 0, i32 0, ; Offset. |
| 43 | i32 %tex_id, i32 %smp_id, |
| 44 | i32 0, i32 0, i32 0, i32 0) ; Unnormalized coords. |
| 45 | ret <4 x float> %data.unnorm |
| 46 | } |