1 target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
3 %opencl.image2d_t = type opaque
5 declare <4 x float> @llvm.R600.tex(<4 x float>, i32, i32, i32, i32, i32, i32,
6 i32, i32, i32) readnone
7 declare i32 @llvm.OpenCL.image.get.resource.id.2d(
8 %opencl.image2d_t addrspace(1)*) nounwind readnone
9 declare i32 @llvm.OpenCL.sampler.get.resource.id(i32) readnone
11 define <4 x float> @__clc_v4f_from_v2f(<2 x float> %v) alwaysinline {
12 %e0 = extractelement <2 x float> %v, i32 0
13 %e1 = extractelement <2 x float> %v, i32 1
14 %res.0 = insertelement <4 x float> undef, float %e0, i32 0
15 %res.1 = insertelement <4 x float> %res.0, float %e1, i32 1
16 %res.2 = insertelement <4 x float> %res.1, float 0.0, i32 2
17 %res.3 = insertelement <4 x float> %res.2, float 0.0, i32 3
18 ret <4 x float> %res.3
21 define <4 x float> @__clc_read_imagef_tex(
22 %opencl.image2d_t addrspace(1)* nocapture %img,
23 i32 %sampler, <2 x float> %coord) alwaysinline {
25 %coord_v4 = call <4 x float> @__clc_v4f_from_v2f(<2 x float> %coord)
26 %smp_id = call i32 @llvm.OpenCL.sampler.get.resource.id(i32 %sampler)
27 %img_id = call i32 @llvm.OpenCL.image.get.resource.id.2d(
28 %opencl.image2d_t addrspace(1)* %img)
29 %tex_id = add i32 %img_id, 2 ; First 2 IDs are reserved.
31 %coord_norm = and i32 %sampler, 1
32 %is_norm = icmp eq i32 %coord_norm, 1
33 br i1 %is_norm, label %NormCoord, label %UnnormCoord
35 %data.norm = call <4 x float> @llvm.R600.tex(
36 <4 x float> %coord_v4,
37 i32 0, i32 0, i32 0, ; Offset.
39 i32 1, i32 1, i32 1, i32 1) ; Normalized coords.
40 ret <4 x float> %data.norm
42 %data.unnorm = call <4 x float> @llvm.R600.tex(
43 <4 x float> %coord_v4,
44 i32 0, i32 0, i32 0, ; Offset.
45 i32 %tex_id, i32 %smp_id,
46 i32 0, i32 0, i32 0, i32 0) ; Unnormalized coords.
47 ret <4 x float> %data.unnorm