[libclc] r248161 - r600: Add image writing builtins.
Tom Stellard via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 21 07:59:56 PDT 2015
Author: tstellar
Date: Mon Sep 21 09:59:56 2015
New Revision: 248161
URL: http://llvm.org/viewvc/llvm-project?rev=248161&view=rev
Log:
r600: Add image writing builtins.
Patch by: Zoltan Gilian
Added:
libclc/trunk/r600/lib/image/write_image_impl.ll
libclc/trunk/r600/lib/image/write_imagef.cl
libclc/trunk/r600/lib/image/write_imagei.cl
libclc/trunk/r600/lib/image/write_imageui.cl
Modified:
libclc/trunk/generic/include/clc/image/image.h
libclc/trunk/r600/lib/SOURCES
Modified: libclc/trunk/generic/include/clc/image/image.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/image/image.h?rev=248161&r1=248160&r2=248161&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/image/image.h (original)
+++ libclc/trunk/generic/include/clc/image/image.h Mon Sep 21 09:59:56 2015
@@ -15,6 +15,13 @@ _CLC_OVERLOAD _CLC_DECL int get_image_ch
_CLC_OVERLOAD _CLC_DECL int2 get_image_dim (image2d_t image);
_CLC_OVERLOAD _CLC_DECL int4 get_image_dim (image3d_t image);
+_CLC_OVERLOAD _CLC_DECL void
+write_imagef(image2d_t image, int2 coord, float4 color);
+_CLC_OVERLOAD _CLC_DECL void
+write_imagei(image2d_t image, int2 coord, int4 color);
+_CLC_OVERLOAD _CLC_DECL void
+write_imageui(image2d_t image, int2 coord, uint4 color);
+
_CLC_OVERLOAD _CLC_DECL float4
read_imagef(image2d_t image, sampler_t sampler, int2 coord);
_CLC_OVERLOAD _CLC_DECL float4
Modified: libclc/trunk/r600/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/SOURCES?rev=248161&r1=248160&r2=248161&view=diff
==============================================================================
--- libclc/trunk/r600/lib/SOURCES (original)
+++ libclc/trunk/r600/lib/SOURCES Mon Sep 21 09:59:56 2015
@@ -20,3 +20,7 @@ image/read_imagef.cl
image/read_imagei.cl
image/read_imageui.cl
image/read_image_impl.ll
+image/write_imagef.cl
+image/write_imagei.cl
+image/write_imageui.cl
+image/write_image_impl.ll
Added: libclc/trunk/r600/lib/image/write_image_impl.ll
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/image/write_image_impl.ll?rev=248161&view=auto
==============================================================================
--- libclc/trunk/r600/lib/image/write_image_impl.ll (added)
+++ libclc/trunk/r600/lib/image/write_image_impl.ll Mon Sep 21 09:59:56 2015
@@ -0,0 +1,52 @@
+%opencl.image2d_t = type opaque
+%opencl.image3d_t = type opaque
+
+declare i32 @llvm.OpenCL.image.get.resource.id.2d(
+ %opencl.image2d_t addrspace(1)*) nounwind readnone
+declare i32 @llvm.OpenCL.image.get.resource.id.3d(
+ %opencl.image3d_t addrspace(1)*) nounwind readnone
+
+declare void @llvm.r600.rat.store.typed(<4 x i32> %color, <4 x i32> %coord, i32 %rat_id)
+
+define void @__clc_write_imageui_2d(
+ %opencl.image2d_t addrspace(1)* nocapture %img,
+ <2 x i32> %coord, <4 x i32> %color) #0 {
+
+ ; Coordinate int2 -> int4.
+ %e0 = extractelement <2 x i32> %coord, i32 0
+ %e1 = extractelement <2 x i32> %coord, i32 1
+ %coord.0 = insertelement <4 x i32> undef, i32 %e0, i32 0
+ %coord.1 = insertelement <4 x i32> %coord.0, i32 %e1, i32 1
+ %coord.2 = insertelement <4 x i32> %coord.1, i32 0, i32 2
+ %coord.3 = insertelement <4 x i32> %coord.2, i32 0, i32 3
+
+ ; Get RAT ID.
+ %img_id = call i32 @llvm.OpenCL.image.get.resource.id.2d(
+ %opencl.image2d_t addrspace(1)* %img)
+ %rat_id = add i32 %img_id, 1
+
+ ; Call store intrinsic.
+ call void @llvm.r600.rat.store.typed(<4 x i32> %color, <4 x i32> %coord.3, i32 %rat_id)
+ ret void
+}
+
+define void @__clc_write_imagei_2d(
+ %opencl.image2d_t addrspace(1)* nocapture %img,
+ <2 x i32> %coord, <4 x i32> %color) #0 {
+ call void @__clc_write_imageui_2d(
+ %opencl.image2d_t addrspace(1)* nocapture %img,
+ <2 x i32> %coord, <4 x i32> %color)
+ ret void
+}
+
+define void @__clc_write_imagef_2d(
+ %opencl.image2d_t addrspace(1)* nocapture %img,
+ <2 x i32> %coord, <4 x float> %color) #0 {
+ %color.i32 = bitcast <4 x float> %color to <4 x i32>
+ call void @__clc_write_imageui_2d(
+ %opencl.image2d_t addrspace(1)* nocapture %img,
+ <2 x i32> %coord, <4 x i32> %color.i32)
+ ret void
+}
+
+attributes #0 = { alwaysinline }
Added: libclc/trunk/r600/lib/image/write_imagef.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/image/write_imagef.cl?rev=248161&view=auto
==============================================================================
--- libclc/trunk/r600/lib/image/write_imagef.cl (added)
+++ libclc/trunk/r600/lib/image/write_imagef.cl Mon Sep 21 09:59:56 2015
@@ -0,0 +1,9 @@
+#include <clc/clc.h>
+
+_CLC_DECL void __clc_write_imagef_2d(image2d_t image, int2 coord, float4 color);
+
+_CLC_OVERLOAD _CLC_DEF void
+write_imagef(image2d_t image, int2 coord, float4 color)
+{
+ __clc_write_imagef_2d(image, coord, color);
+}
Added: libclc/trunk/r600/lib/image/write_imagei.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/image/write_imagei.cl?rev=248161&view=auto
==============================================================================
--- libclc/trunk/r600/lib/image/write_imagei.cl (added)
+++ libclc/trunk/r600/lib/image/write_imagei.cl Mon Sep 21 09:59:56 2015
@@ -0,0 +1,9 @@
+#include <clc/clc.h>
+
+_CLC_DECL void __clc_write_imagei_2d(image2d_t image, int2 coord, int4 color);
+
+_CLC_OVERLOAD _CLC_DEF void
+write_imagei(image2d_t image, int2 coord, int4 color)
+{
+ __clc_write_imagei_2d(image, coord, color);
+}
Added: libclc/trunk/r600/lib/image/write_imageui.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/image/write_imageui.cl?rev=248161&view=auto
==============================================================================
--- libclc/trunk/r600/lib/image/write_imageui.cl (added)
+++ libclc/trunk/r600/lib/image/write_imageui.cl Mon Sep 21 09:59:56 2015
@@ -0,0 +1,9 @@
+#include <clc/clc.h>
+
+_CLC_DECL void __clc_write_imageui_2d(image2d_t image, int2 coord, uint4 color);
+
+_CLC_OVERLOAD _CLC_DEF void
+write_imageui(image2d_t image, int2 coord, uint4 color)
+{
+ __clc_write_imageui_2d(image, coord, color);
+}
More information about the cfe-commits
mailing list