[Libclc-dev] [PATCH 1/3] amdgcn-amdhsa: Add get_global_size() implementation
Tom Stellard via Libclc-dev
libclc-dev at lists.llvm.org
Wed Sep 14 04:22:55 PDT 2016
---
amdgcn-amdhsa/lib/SOURCES | 1 +
amdgcn-amdhsa/lib/workitem/get_global_size.ll | 39 +++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
create mode 100644 amdgcn-amdhsa/lib/workitem/get_global_size.ll
diff --git a/amdgcn-amdhsa/lib/SOURCES b/amdgcn-amdhsa/lib/SOURCES
index b33368d..257942c 100644
--- a/amdgcn-amdhsa/lib/SOURCES
+++ b/amdgcn-amdhsa/lib/SOURCES
@@ -1 +1,2 @@
+workitem/get_global_size.ll
workitem/get_local_size.ll
diff --git a/amdgcn-amdhsa/lib/workitem/get_global_size.ll b/amdgcn-amdhsa/lib/workitem/get_global_size.ll
new file mode 100644
index 0000000..10f9901
--- /dev/null
+++ b/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) #1 {
+ %dispatch_ptr = call noalias nonnull dereferenceable(64) i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr()
+ switch i32 %0, label %14 [
+ i32 0, label %2
+ i32 1, label %6
+ i32 2, label %10
+ ]
+
+; <label>:2: ; preds = %1
+ %3 = getelementptr inbounds i8, i8 addrspace(2)* %dispatch_ptr, i64 12
+ %4 = bitcast i8 addrspace(2)* %3 to i32 addrspace(2)*
+ %5 = load i32, i32 addrspace(2)* %4, align 4, !invariant.load !0
+ %size_x = zext i32 %5 to i64
+ ret i64 %size_x
+
+; <label>:6: ; preds = %1
+ %7 = getelementptr inbounds i8, i8 addrspace(2)* %dispatch_ptr, i64 16
+ %8 = bitcast i8 addrspace(2)* %7 to i32 addrspace(2)*
+ %9 = load i32, i32 addrspace(2)* %8, align 4, !invariant.load !0
+ %size_y = zext i32 %9 to i64
+ ret i64 %size_y
+
+; <label>:10: ; preds = %1
+ %11 = getelementptr inbounds i8, i8 addrspace(2)* %dispatch_ptr, i64 20
+ %12 = bitcast i8 addrspace(2)* %11 to i32 addrspace(2)*
+ %13 = load i32, i32 addrspace(2)* %12, align 4, !invariant.load !0
+ %size_z = zext i32 %13 to i64
+ ret i64 %size_z
+
+; <label>:14: ; preds = %1
+ ret i64 1
+}
+
+attributes #0 = { nounwind readnone }
+attributes #1 = { alwaysinline norecurse nounwind readonly }
+
+!0 = !{}
--
2.7.4
More information about the Libclc-dev
mailing list