| 1 |
;;===----------------------------------------------------------------------===;; |
| 2 |
; |
| 3 |
; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
; See https://llvm.org/LICENSE.txt for license information. |
| 5 |
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
; |
| 7 |
;;===----------------------------------------------------------------------===;; |
| 8 |
|
| 9 |
%opencl.image2d_t = type opaque |
| 10 |
|
| 11 |
declare <4 x float> @llvm.R600.tex(<4 x float>, i32, i32, i32, i32, i32, i32, |
| 12 |
i32, i32, i32) readnone |
| 13 |
declare i32 @llvm.OpenCL.image.get.resource.id.2d( |
| 14 |
%opencl.image2d_t addrspace(1)*) nounwind readnone |
| 15 |
declare i32 @llvm.OpenCL.sampler.get.resource.id(i32) readnone |
| 16 |
|
| 17 |
define <4 x float> @__clc_v4f_from_v2f(<2 x float> %v) alwaysinline { |
| 18 |
%e0 = extractelement <2 x float> %v, i32 0 |
| 19 |
%e1 = extractelement <2 x float> %v, i32 1 |
| 20 |
%res.0 = insertelement <4 x float> poison, float %e0, i32 0 |
| 21 |
%res.1 = insertelement <4 x float> %res.0, float %e1, i32 1 |
| 22 |
%res.2 = insertelement <4 x float> %res.1, float 0.0, i32 2 |
| 23 |
%res.3 = insertelement <4 x float> %res.2, float 0.0, i32 3 |
| 24 |
ret <4 x float> %res.3 |
| 25 |
} |
| 26 |
|
| 27 |
define <4 x float> @__clc_read_imagef_tex( |
| 28 |
%opencl.image2d_t addrspace(1)* nocapture %img, |
| 29 |
i32 %sampler, <2 x float> %coord) alwaysinline { |
| 30 |
entry: |
| 31 |
%coord_v4 = call <4 x float> @__clc_v4f_from_v2f(<2 x float> %coord) |
| 32 |
%smp_id = call i32 @llvm.OpenCL.sampler.get.resource.id(i32 %sampler) |
| 33 |
%img_id = call i32 @llvm.OpenCL.image.get.resource.id.2d( |
| 34 |
%opencl.image2d_t addrspace(1)* %img) |
| 35 |
%tex_id = add i32 %img_id, 2 ; First 2 IDs are reserved. |
| 36 |
|
| 37 |
%coord_norm = and i32 %sampler, 1 |
| 38 |
%is_norm = icmp eq i32 %coord_norm, 1 |
| 39 |
br i1 %is_norm, label %NormCoord, label %UnnormCoord |
| 40 |
NormCoord: |
| 41 |
%data.norm = call <4 x float> @llvm.R600.tex( |
| 42 |
<4 x float> %coord_v4, |
| 43 |
i32 0, i32 0, i32 0, ; Offset. |
| 44 |
i32 2, i32 %smp_id, |
| 45 |
i32 1, i32 1, i32 1, i32 1) ; Normalized coords. |
| 46 |
ret <4 x float> %data.norm |
| 47 |
UnnormCoord: |
| 48 |
%data.unnorm = call <4 x float> @llvm.R600.tex( |
| 49 |
<4 x float> %coord_v4, |
| 50 |
i32 0, i32 0, i32 0, ; Offset. |
| 51 |
i32 %tex_id, i32 %smp_id, |
| 52 |
i32 0, i32 0, i32 0, i32 0) ; Unnormalized coords. |
| 53 |
ret <4 x float> %data.unnorm |
| 54 |
} |