aboutsummaryrefslogtreecommitdiff
path: root/libclc
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2016-09-16 22:43:29 +0000
committerTom Stellard <thomas.stellard@amd.com>2016-09-16 22:43:29 +0000
commite7ad23bad32014b579fbc07ef9bf0a52bd070ec0 (patch)
treeb0a64b858f302eeb06e60037c0363237f98506a8 /libclc
parent0a3ede0a14226b4b74335b81be466e045697ff80 (diff)
downloadllvm-e7ad23bad32014b579fbc07ef9bf0a52bd070ec0.zip
llvm-e7ad23bad32014b579fbc07ef9bf0a52bd070ec0.tar.gz
llvm-e7ad23bad32014b579fbc07ef9bf0a52bd070ec0.tar.bz2
amdgcn-amdhsa: Add get_global_size() implementation
llvm-svn: 281791
Diffstat (limited to 'libclc')
-rw-r--r--libclc/amdgcn-amdhsa/lib/SOURCES1
-rw-r--r--libclc/amdgcn-amdhsa/lib/workitem/get_global_size.ll39
2 files changed, 40 insertions, 0 deletions
diff --git a/libclc/amdgcn-amdhsa/lib/SOURCES b/libclc/amdgcn-amdhsa/lib/SOURCES
index b33368d..257942c0 100644
--- a/libclc/amdgcn-amdhsa/lib/SOURCES
+++ b/libclc/amdgcn-amdhsa/lib/SOURCES
@@ -1 +1,2 @@
+workitem/get_global_size.ll
workitem/get_local_size.ll
diff --git a/libclc/amdgcn-amdhsa/lib/workitem/get_global_size.ll b/libclc/amdgcn-amdhsa/lib/workitem/get_global_size.ll
new file mode 100644
index 0000000..af0f2ea
--- /dev/null
+++ b/libclc/amdgcn-amdhsa/lib/workitem/get_global_size.ll
@@ -0,0 +1,39 @@
+declare i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr() #0
+
+define i64 @get_global_size(i32 %dim) #1 {
+ %dispatch_ptr = call noalias nonnull dereferenceable(64) i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr()
+ switch i32 %dim, label %default [
+ i32 0, label %x
+ i32 1, label %y
+ i32 2, label %z
+ ]
+
+x:
+ %ptr_x = getelementptr inbounds i8, i8 addrspace(2)* %dispatch_ptr, i64 12
+ %ptr_x32 = bitcast i8 addrspace(2)* %ptr_x to i32 addrspace(2)*
+ %x32 = load i32, i32 addrspace(2)* %ptr_x32, align 4, !invariant.load !0
+ %size_x = zext i32 %x32 to i64
+ ret i64 %size_x
+
+y:
+ %ptr_y = getelementptr inbounds i8, i8 addrspace(2)* %dispatch_ptr, i64 16
+ %ptr_y32 = bitcast i8 addrspace(2)* %ptr_y to i32 addrspace(2)*
+ %y32 = load i32, i32 addrspace(2)* %ptr_y32, align 4, !invariant.load !0
+ %size_y = zext i32 %y32 to i64
+ ret i64 %size_y
+
+z:
+ %ptr_z = getelementptr inbounds i8, i8 addrspace(2)* %dispatch_ptr, i64 20
+ %ptr_z32 = bitcast i8 addrspace(2)* %ptr_z to i32 addrspace(2)*
+ %z32 = load i32, i32 addrspace(2)* %ptr_z32, align 4, !invariant.load !0
+ %size_z = zext i32 %z32 to i64
+ ret i64 %size_z
+
+default:
+ ret i64 1
+}
+
+attributes #0 = { nounwind readnone }
+attributes #1 = { alwaysinline norecurse nounwind readonly }
+
+!0 = !{}