summaryrefslogtreecommitdiffstats
path: root/libclc/r600/lib
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2015-09-21 14:59:56 +0000
committerTom Stellard <thomas.stellard@amd.com>2015-09-21 14:59:56 +0000
commita59fd49ba4cfe71a088d1d0aff8a80d29939c237 (patch)
tree6ae2a41e4359a6c2e29b723a8cbfe26ceb4c3126 /libclc/r600/lib
parent9a7d4a940f86ed62da0b2ce82ee51f86d94d4735 (diff)
downloadbcm5719-llvm-a59fd49ba4cfe71a088d1d0aff8a80d29939c237.tar.gz
bcm5719-llvm-a59fd49ba4cfe71a088d1d0aff8a80d29939c237.zip
r600: Add image writing builtins.
Patch by: Zoltan Gilian llvm-svn: 248161
Diffstat (limited to 'libclc/r600/lib')
-rw-r--r--libclc/r600/lib/SOURCES4
-rw-r--r--libclc/r600/lib/image/write_image_impl.ll52
-rw-r--r--libclc/r600/lib/image/write_imagef.cl9
-rw-r--r--libclc/r600/lib/image/write_imagei.cl9
-rw-r--r--libclc/r600/lib/image/write_imageui.cl9
5 files changed, 83 insertions, 0 deletions
diff --git a/libclc/r600/lib/SOURCES b/libclc/r600/lib/SOURCES
index 706c879954d..029b22c1049 100644
--- a/libclc/r600/lib/SOURCES
+++ b/libclc/r600/lib/SOURCES
@@ -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
diff --git a/libclc/r600/lib/image/write_image_impl.ll b/libclc/r600/lib/image/write_image_impl.ll
new file mode 100644
index 00000000000..265f5d6045e
--- /dev/null
+++ b/libclc/r600/lib/image/write_image_impl.ll
@@ -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 }
diff --git a/libclc/r600/lib/image/write_imagef.cl b/libclc/r600/lib/image/write_imagef.cl
new file mode 100644
index 00000000000..4483fcf68db
--- /dev/null
+++ b/libclc/r600/lib/image/write_imagef.cl
@@ -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);
+}
diff --git a/libclc/r600/lib/image/write_imagei.cl b/libclc/r600/lib/image/write_imagei.cl
new file mode 100644
index 00000000000..394a223d0a8
--- /dev/null
+++ b/libclc/r600/lib/image/write_imagei.cl
@@ -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);
+}
diff --git a/libclc/r600/lib/image/write_imageui.cl b/libclc/r600/lib/image/write_imageui.cl
new file mode 100644
index 00000000000..91344de8a1d
--- /dev/null
+++ b/libclc/r600/lib/image/write_imageui.cl
@@ -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);
+}
OpenPOWER on IntegriCloud