diff options
| author | Jan Vesely <jan.vesely@rutgers.edu> | 2016-07-22 17:24:20 +0000 |
|---|---|---|
| committer | Jan Vesely <jan.vesely@rutgers.edu> | 2016-07-22 17:24:20 +0000 |
| commit | 74f02db922b4609095da4218fd3016c2c51d056b (patch) | |
| tree | 63edc54fa54dfa66fbce3a716c068d3d029ded20 /libclc/amdgcn/lib | |
| parent | 3c89bb09d55c089dced548401e023b30b4c72206 (diff) | |
| download | bcm5719-llvm-74f02db922b4609095da4218fd3016c2c51d056b.tar.gz bcm5719-llvm-74f02db922b4609095da4218fd3016c2c51d056b.zip | |
AMDGPU: Use clang intrinsics for workitem builtins
v2: split into 2 patches
use clang builtins for other intrinsics as well
v3: Fix warnings
Switch r600 to use implictarg.ptr
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 276442
Diffstat (limited to 'libclc/amdgcn/lib')
| -rw-r--r-- | libclc/amdgcn/lib/SOURCES | 5 | ||||
| -rw-r--r-- | libclc/amdgcn/lib/workitem/get_group_id.cl | 11 | ||||
| -rw-r--r-- | libclc/amdgcn/lib/workitem/get_group_id.ll | 29 | ||||
| -rw-r--r-- | libclc/amdgcn/lib/workitem/get_local_id.cl | 11 | ||||
| -rw-r--r-- | libclc/amdgcn/lib/workitem/get_local_id.ll | 31 | ||||
| -rw-r--r-- | libclc/amdgcn/lib/workitem/get_work_dim.cl | 9 |
6 files changed, 34 insertions, 62 deletions
diff --git a/libclc/amdgcn/lib/SOURCES b/libclc/amdgcn/lib/SOURCES index ada06d2a296..49d9b531408 100644 --- a/libclc/amdgcn/lib/SOURCES +++ b/libclc/amdgcn/lib/SOURCES @@ -1,4 +1,5 @@ math/ldexp.cl synchronization/barrier_impl.ll -workitem/get_group_id.ll -workitem/get_local_id.ll +workitem/get_group_id.cl +workitem/get_local_id.cl +workitem/get_work_dim.cl diff --git a/libclc/amdgcn/lib/workitem/get_group_id.cl b/libclc/amdgcn/lib/workitem/get_group_id.cl new file mode 100644 index 00000000000..4b4e7a7bed3 --- /dev/null +++ b/libclc/amdgcn/lib/workitem/get_group_id.cl @@ -0,0 +1,11 @@ +#include <clc/clc.h> + +_CLC_DEF uint get_group_id(uint dim) +{ + switch(dim) { + case 0: return __builtin_amdgcn_workgroup_id_x(); + case 1: return __builtin_amdgcn_workgroup_id_y(); + case 2: return __builtin_amdgcn_workgroup_id_z(); + default: return 1; + } +} diff --git a/libclc/amdgcn/lib/workitem/get_group_id.ll b/libclc/amdgcn/lib/workitem/get_group_id.ll deleted file mode 100644 index 9d820e0b3e4..00000000000 --- a/libclc/amdgcn/lib/workitem/get_group_id.ll +++ /dev/null @@ -1,29 +0,0 @@ -declare i32 @llvm.amdgcn.workgroup.id.x() #0 -declare i32 @llvm.amdgcn.workgroup.id.y() #0 -declare i32 @llvm.amdgcn.workgroup.id.z() #0 - -define i32 @get_group_id(i32 %dim) #1 { - switch i32 %dim, label %default [ - i32 0, label %x_dim - i32 1, label %y_dim - i32 2, label %z_dim - ] - -x_dim: - %x = tail call i32 @llvm.amdgcn.workgroup.id.x() - ret i32 %x - -y_dim: - %y = tail call i32 @llvm.amdgcn.workgroup.id.y() - ret i32 %y - -z_dim: - %z = tail call i32 @llvm.amdgcn.workgroup.id.z() - ret i32 %z - -default: - ret i32 0 -} - -attributes #0 = { nounwind readnone } -attributes #1 = { alwaysinline norecurse nounwind readnone } diff --git a/libclc/amdgcn/lib/workitem/get_local_id.cl b/libclc/amdgcn/lib/workitem/get_local_id.cl new file mode 100644 index 00000000000..257c30f723b --- /dev/null +++ b/libclc/amdgcn/lib/workitem/get_local_id.cl @@ -0,0 +1,11 @@ +#include <clc/clc.h> + +_CLC_DEF uint get_local_id(uint dim) +{ + switch(dim) { + case 0: return __builtin_amdgcn_workitem_id_x(); + case 1: return __builtin_amdgcn_workitem_id_y(); + case 2: return __builtin_amdgcn_workitem_id_z(); + default: return 1; + } +} diff --git a/libclc/amdgcn/lib/workitem/get_local_id.ll b/libclc/amdgcn/lib/workitem/get_local_id.ll deleted file mode 100644 index c54291c0b8f..00000000000 --- a/libclc/amdgcn/lib/workitem/get_local_id.ll +++ /dev/null @@ -1,31 +0,0 @@ -declare i32 @llvm.amdgcn.workitem.id.x() #0 -declare i32 @llvm.amdgcn.workitem.id.y() #0 -declare i32 @llvm.amdgcn.workitem.id.z() #0 - -define i32 @get_local_id(i32 %dim) #1 { - switch i32 %dim, label %default [ - i32 0, label %x_dim - i32 1, label %y_dim - i32 2, label %z_dim - ] - -x_dim: - %x = tail call i32 @llvm.amdgcn.workitem.id.x(), !range !0 - ret i32 %x - -y_dim: - %y = tail call i32 @llvm.amdgcn.workitem.id.y(), !range !0 - ret i32 %y - -z_dim: - %z = tail call i32 @llvm.amdgcn.workitem.id.z(), !range !0 - ret i32 %z - -default: - ret i32 0 -} - -attributes #0 = { nounwind readnone } -attributes #1 = { alwaysinline norecurse nounwind readnone } - -!0 = !{ i32 0, i32 2048 } diff --git a/libclc/amdgcn/lib/workitem/get_work_dim.cl b/libclc/amdgcn/lib/workitem/get_work_dim.cl new file mode 100644 index 00000000000..dd2c64fc230 --- /dev/null +++ b/libclc/amdgcn/lib/workitem/get_work_dim.cl @@ -0,0 +1,9 @@ +#include <clc/clc.h> + +_CLC_DEF uint get_work_dim() +{ + __attribute__((address_space(2))) uint * ptr = + (__attribute__((address_space(2))) uint *) + __builtin_amdgcn_implicitarg_ptr(); + return ptr[0]; +} |

