[libclc] r248159 - Add image attribute getter builtins

Tom Stellard via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 21 07:47:53 PDT 2015


Author: tstellar
Date: Mon Sep 21 09:47:53 2015
New Revision: 248159

URL: http://llvm.org/viewvc/llvm-project?rev=248159&view=rev
Log:
Add image attribute getter builtins

Added get_image_* OpenCL builtins to the headers.
Added implementation to the r600 target.

Patch by: Zoltan Gilian

Added:
    libclc/trunk/generic/include/clc/image/
    libclc/trunk/generic/include/clc/image/image.h
    libclc/trunk/generic/lib/image/
    libclc/trunk/generic/lib/image/get_image_dim.cl
    libclc/trunk/r600/lib/image/
    libclc/trunk/r600/lib/image/get_image_attributes_impl.ll
    libclc/trunk/r600/lib/image/get_image_channel_data_type.cl
    libclc/trunk/r600/lib/image/get_image_channel_order.cl
    libclc/trunk/r600/lib/image/get_image_depth.cl
    libclc/trunk/r600/lib/image/get_image_height.cl
    libclc/trunk/r600/lib/image/get_image_width.cl
Modified:
    libclc/trunk/generic/include/clc/clc.h
    libclc/trunk/generic/lib/SOURCES
    libclc/trunk/r600/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=248159&r1=248158&r2=248159&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Mon Sep 21 09:47:53 2015
@@ -210,6 +210,10 @@
 #include <clc/cl_khr_local_int32_extended_atomics/atom_or.h>
 #include <clc/cl_khr_local_int32_extended_atomics/atom_xor.h>
 
+/* 6.11.13 Image Read and Write Functions */
+
+#include <clc/image/image.h>
+
 /* libclc internal defintions */
 #ifdef __CLC_INTERNAL
 #include <math/clc_nextafter.h>

Added: libclc/trunk/generic/include/clc/image/image.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/image/image.h?rev=248159&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/image/image.h (added)
+++ libclc/trunk/generic/include/clc/image/image.h Mon Sep 21 09:47:53 2015
@@ -0,0 +1,16 @@
+_CLC_OVERLOAD _CLC_DECL int get_image_width (image2d_t image);
+_CLC_OVERLOAD _CLC_DECL int get_image_width (image3d_t image);
+
+_CLC_OVERLOAD _CLC_DECL int get_image_height (image2d_t image);
+_CLC_OVERLOAD _CLC_DECL int get_image_height (image3d_t image);
+
+_CLC_OVERLOAD _CLC_DECL int get_image_depth (image3d_t image);
+
+_CLC_OVERLOAD _CLC_DECL int get_image_channel_data_type (image2d_t image);
+_CLC_OVERLOAD _CLC_DECL int get_image_channel_data_type (image3d_t image);
+
+_CLC_OVERLOAD _CLC_DECL int get_image_channel_order (image2d_t image);
+_CLC_OVERLOAD _CLC_DECL int get_image_channel_order (image3d_t image);
+
+_CLC_OVERLOAD _CLC_DECL int2 get_image_dim (image2d_t image);
+_CLC_OVERLOAD _CLC_DECL int4 get_image_dim (image3d_t image);

Modified: libclc/trunk/generic/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=248159&r1=248158&r2=248159&view=diff
==============================================================================
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Mon Sep 21 09:47:53 2015
@@ -133,3 +133,4 @@ shared/vload.cl
 shared/vstore.cl
 workitem/get_global_id.cl
 workitem/get_global_size.cl
+image/get_image_dim.cl

Added: libclc/trunk/generic/lib/image/get_image_dim.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/image/get_image_dim.cl?rev=248159&view=auto
==============================================================================
--- libclc/trunk/generic/lib/image/get_image_dim.cl (added)
+++ libclc/trunk/generic/lib/image/get_image_dim.cl Mon Sep 21 09:47:53 2015
@@ -0,0 +1,9 @@
+#include <clc/clc.h>
+
+_CLC_OVERLOAD _CLC_DEF int2 get_image_dim (image2d_t image) {
+  return (int2)(get_image_width(image), get_image_height(image));
+}
+_CLC_OVERLOAD _CLC_DEF int4 get_image_dim (image3d_t image) {
+  return (int4)(get_image_width(image), get_image_height(image),
+                get_image_depth(image), 0);
+}

Modified: libclc/trunk/r600/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/SOURCES?rev=248159&r1=248158&r2=248159&view=diff
==============================================================================
--- libclc/trunk/r600/lib/SOURCES (original)
+++ libclc/trunk/r600/lib/SOURCES Mon Sep 21 09:47:53 2015
@@ -10,3 +10,9 @@ workitem/get_global_size.ll
 workitem/get_work_dim.ll
 synchronization/barrier.cl
 synchronization/barrier_impl.ll
+image/get_image_width.cl
+image/get_image_height.cl
+image/get_image_depth.cl
+image/get_image_channel_data_type.cl
+image/get_image_channel_order.cl
+image/get_image_attributes_impl.ll

Added: libclc/trunk/r600/lib/image/get_image_attributes_impl.ll
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/image/get_image_attributes_impl.ll?rev=248159&view=auto
==============================================================================
--- libclc/trunk/r600/lib/image/get_image_attributes_impl.ll (added)
+++ libclc/trunk/r600/lib/image/get_image_attributes_impl.ll Mon Sep 21 09:47:53 2015
@@ -0,0 +1,87 @@
+%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 [3 x i32] @llvm.OpenCL.image.get.size.2d(
+  %opencl.image2d_t addrspace(1)*) nounwind readnone
+declare [3 x i32] @llvm.OpenCL.image.get.size.3d(
+  %opencl.image3d_t addrspace(1)*) nounwind readnone
+
+declare [2 x i32] @llvm.OpenCL.image.get.format.2d(
+  %opencl.image2d_t addrspace(1)*) nounwind readnone
+declare [2 x i32] @llvm.OpenCL.image.get.format.3d(
+  %opencl.image3d_t addrspace(1)*) nounwind readnone
+
+define i32 @__clc_get_image_width_2d(
+                          %opencl.image2d_t addrspace(1)* nocapture %img) #0 {
+  %1 = tail call [3 x i32] @llvm.OpenCL.image.get.size.2d(
+    %opencl.image2d_t addrspace(1)* %img)
+  %2 = extractvalue [3 x i32] %1, 0
+  ret i32 %2
+}
+define i32 @__clc_get_image_width_3d(
+                          %opencl.image3d_t addrspace(1)* nocapture %img) #0 {
+  %1 = tail call [3 x i32] @llvm.OpenCL.image.get.size.3d(
+    %opencl.image3d_t addrspace(1)* %img)
+  %2 = extractvalue [3 x i32] %1, 0
+  ret i32 %2
+}
+
+define i32 @__clc_get_image_height_2d(
+                          %opencl.image2d_t addrspace(1)* nocapture %img) #0 {
+  %1 = tail call [3 x i32] @llvm.OpenCL.image.get.size.2d(
+    %opencl.image2d_t addrspace(1)* %img)
+  %2 = extractvalue [3 x i32] %1, 1
+  ret i32 %2
+}
+define i32 @__clc_get_image_height_3d(
+                          %opencl.image3d_t addrspace(1)* nocapture %img) #0 {
+  %1 = tail call [3 x i32] @llvm.OpenCL.image.get.size.3d(
+    %opencl.image3d_t addrspace(1)* %img)
+  %2 = extractvalue [3 x i32] %1, 1
+  ret i32 %2
+}
+
+define i32 @__clc_get_image_depth_3d(
+                          %opencl.image3d_t addrspace(1)* nocapture %img) #0 {
+  %1 = tail call [3 x i32] @llvm.OpenCL.image.get.size.3d(
+    %opencl.image3d_t addrspace(1)* %img)
+  %2 = extractvalue [3 x i32] %1, 2
+  ret i32 %2
+}
+
+define i32 @__clc_get_image_channel_data_type_2d(
+                          %opencl.image2d_t addrspace(1)* nocapture %img) #0 {
+  %1 = tail call [2 x i32] @llvm.OpenCL.image.get.format.2d(
+    %opencl.image2d_t addrspace(1)* %img)
+  %2 = extractvalue [2 x i32] %1, 0
+  ret i32 %2
+}
+define i32 @__clc_get_image_channel_data_type_3d(
+                          %opencl.image3d_t addrspace(1)* nocapture %img) #0 {
+  %1 = tail call [2 x i32] @llvm.OpenCL.image.get.format.3d(
+    %opencl.image3d_t addrspace(1)* %img)
+  %2 = extractvalue [2 x i32] %1, 0
+  ret i32 %2
+}
+
+define i32 @__clc_get_image_channel_order_2d(
+                          %opencl.image2d_t addrspace(1)* nocapture %img) #0 {
+  %1 = tail call [2 x i32] @llvm.OpenCL.image.get.format.2d(
+    %opencl.image2d_t addrspace(1)* %img)
+  %2 = extractvalue [2 x i32] %1, 1
+  ret i32 %2
+}
+define i32 @__clc_get_image_channel_order_3d(
+                          %opencl.image3d_t addrspace(1)* nocapture %img) #0 {
+  %1 = tail call [2 x i32] @llvm.OpenCL.image.get.format.3d(
+    %opencl.image3d_t addrspace(1)* %img)
+  %2 = extractvalue [2 x i32] %1, 1
+  ret i32 %2
+}
+
+attributes #0 = { nounwind readnone alwaysinline }

Added: libclc/trunk/r600/lib/image/get_image_channel_data_type.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/image/get_image_channel_data_type.cl?rev=248159&view=auto
==============================================================================
--- libclc/trunk/r600/lib/image/get_image_channel_data_type.cl (added)
+++ libclc/trunk/r600/lib/image/get_image_channel_data_type.cl Mon Sep 21 09:47:53 2015
@@ -0,0 +1,13 @@
+#include <clc/clc.h>
+
+_CLC_DECL int __clc_get_image_channel_data_type_2d(image2d_t);
+_CLC_DECL int __clc_get_image_channel_data_type_3d(image3d_t);
+
+_CLC_OVERLOAD _CLC_DEF int
+get_image_channel_data_type(image2d_t image) {
+  return __clc_get_image_channel_data_type_2d(image);
+}
+_CLC_OVERLOAD _CLC_DEF int
+get_image_channel_data_type(image3d_t image) {
+  return __clc_get_image_channel_data_type_3d(image);
+}

Added: libclc/trunk/r600/lib/image/get_image_channel_order.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/image/get_image_channel_order.cl?rev=248159&view=auto
==============================================================================
--- libclc/trunk/r600/lib/image/get_image_channel_order.cl (added)
+++ libclc/trunk/r600/lib/image/get_image_channel_order.cl Mon Sep 21 09:47:53 2015
@@ -0,0 +1,13 @@
+#include <clc/clc.h>
+
+_CLC_DECL int __clc_get_image_channel_order_2d(image2d_t);
+_CLC_DECL int __clc_get_image_channel_order_3d(image3d_t);
+
+_CLC_OVERLOAD _CLC_DEF int
+get_image_channel_order(image2d_t image) {
+  return __clc_get_image_channel_order_2d(image);
+}
+_CLC_OVERLOAD _CLC_DEF int
+get_image_channel_order(image3d_t image) {
+  return __clc_get_image_channel_order_3d(image);
+}

Added: libclc/trunk/r600/lib/image/get_image_depth.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/image/get_image_depth.cl?rev=248159&view=auto
==============================================================================
--- libclc/trunk/r600/lib/image/get_image_depth.cl (added)
+++ libclc/trunk/r600/lib/image/get_image_depth.cl Mon Sep 21 09:47:53 2015
@@ -0,0 +1,8 @@
+#include <clc/clc.h>
+
+_CLC_DECL int __clc_get_image_depth_3d(image3d_t);
+
+_CLC_OVERLOAD _CLC_DEF int
+get_image_depth(image3d_t image) {
+	return __clc_get_image_depth_3d(image);
+}

Added: libclc/trunk/r600/lib/image/get_image_height.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/image/get_image_height.cl?rev=248159&view=auto
==============================================================================
--- libclc/trunk/r600/lib/image/get_image_height.cl (added)
+++ libclc/trunk/r600/lib/image/get_image_height.cl Mon Sep 21 09:47:53 2015
@@ -0,0 +1,13 @@
+#include <clc/clc.h>
+
+_CLC_DECL int __clc_get_image_height_2d(image2d_t);
+_CLC_DECL int __clc_get_image_height_3d(image3d_t);
+
+_CLC_OVERLOAD _CLC_DEF int
+get_image_height(image2d_t image) {
+  return __clc_get_image_height_2d(image);
+}
+_CLC_OVERLOAD _CLC_DEF int
+get_image_height(image3d_t image) {
+  return __clc_get_image_height_3d(image);
+}

Added: libclc/trunk/r600/lib/image/get_image_width.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/image/get_image_width.cl?rev=248159&view=auto
==============================================================================
--- libclc/trunk/r600/lib/image/get_image_width.cl (added)
+++ libclc/trunk/r600/lib/image/get_image_width.cl Mon Sep 21 09:47:53 2015
@@ -0,0 +1,13 @@
+#include <clc/clc.h>
+
+_CLC_DECL int __clc_get_image_width_2d(image2d_t);
+_CLC_DECL int __clc_get_image_width_3d(image3d_t);
+
+_CLC_OVERLOAD _CLC_DEF int
+get_image_width(image2d_t image) {
+  return __clc_get_image_width_2d(image);
+}
+_CLC_OVERLOAD _CLC_DEF int
+get_image_width(image3d_t image) {
+  return __clc_get_image_width_3d(image);
+}




More information about the cfe-commits mailing list