[Libclc-dev] [PATCH] amdgcn-amdhsa: Add get_global_size() implementation
Tom Stellard via Libclc-dev
libclc-dev at lists.llvm.org
Wed Jul 20 17:23:43 PDT 2016
---
amdgcn-amdhsa/lib/SOURCES | 1 +
amdgcn-amdhsa/lib/workitem/get_global_size.ll | 36 +++++++++++++++++++++++++++
2 files changed, 37 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..91e419d
--- /dev/null
+++ b/amdgcn-amdhsa/lib/workitem/get_global_size.ll
@@ -0,0 +1,36 @@
+declare i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr() #0
+
+define i32 @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
+ ret i32 %5
+
+; <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
+ ret i32 %9
+
+; <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
+ ret i32 %13
+
+; <label>:14: ; preds = %1
+ ret i32 1
+}
+
+attributes #0 = { nounwind readnone }
+attributes #1 = { alwaysinline norecurse nounwind readonly }
+
+!0 = !{}
--
2.7.4
More information about the Libclc-dev
mailing list