Skip to content

Commit ce29e8c

Browse files
committed
Restore support for llvm-3.9
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu> Acked-by: Aaron Watry <awatry@gmail.com> llvm-svn: 314543
1 parent f4bb480 commit ce29e8c

File tree

9 files changed

+90
-4
lines changed

9 files changed

+90
-4
lines changed

libclc/amdgcn-amdhsa/lib/OVERRIDES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
workitem/get_num_groups.ll
2+
workitem/get_global_size.39.ll
3+
workitem/get_local_size.39.ll
4+
workitem/get_num_groups.39.ll

libclc/amdgcn/lib/OVERRIDES_3.9

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
workitem/get_global_size.ll
2+
workitem/get_local_size.ll
3+
workitem/get_num_groups.ll

libclc/amdgcn/lib/SOURCES_3.9

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
workitem/get_global_size.39.ll
2+
workitem/get_local_size.39.ll
3+
workitem/get_num_groups.39.ll
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
declare i32 @llvm.r600.read.global.size.x() nounwind readnone
2+
declare i32 @llvm.r600.read.global.size.y() nounwind readnone
3+
declare i32 @llvm.r600.read.global.size.z() nounwind readnone
4+
5+
define i32 @get_global_size(i32 %dim) nounwind readnone alwaysinline {
6+
switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 2, label %z_dim]
7+
x_dim:
8+
%x = call i32 @llvm.r600.read.global.size.x()
9+
ret i32 %x
10+
y_dim:
11+
%y = call i32 @llvm.r600.read.global.size.y()
12+
ret i32 %y
13+
z_dim:
14+
%z = call i32 @llvm.r600.read.global.size.z()
15+
ret i32 %z
16+
default:
17+
ret i32 1
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
declare i32 @llvm.r600.read.local.size.x() nounwind readnone
2+
declare i32 @llvm.r600.read.local.size.y() nounwind readnone
3+
declare i32 @llvm.r600.read.local.size.z() nounwind readnone
4+
5+
define i32 @get_local_size(i32 %dim) nounwind readnone alwaysinline {
6+
switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 2, label %z_dim]
7+
x_dim:
8+
%x = call i32 @llvm.r600.read.local.size.x()
9+
ret i32 %x
10+
y_dim:
11+
%y = call i32 @llvm.r600.read.local.size.y()
12+
ret i32 %y
13+
z_dim:
14+
%z = call i32 @llvm.r600.read.local.size.z()
15+
ret i32 %z
16+
default:
17+
ret i32 1
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
declare i32 @llvm.r600.read.ngroups.x() nounwind readnone
2+
declare i32 @llvm.r600.read.ngroups.y() nounwind readnone
3+
declare i32 @llvm.r600.read.ngroups.z() nounwind readnone
4+
5+
define i32 @get_num_groups(i32 %dim) nounwind readnone alwaysinline {
6+
switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 2, label %z_dim]
7+
x_dim:
8+
%x = call i32 @llvm.r600.read.ngroups.x()
9+
ret i32 %x
10+
y_dim:
11+
%y = call i32 @llvm.r600.read.ngroups.y()
12+
ret i32 %y
13+
z_dim:
14+
%z = call i32 @llvm.r600.read.ngroups.z()
15+
ret i32 %z
16+
default:
17+
ret i32 1
18+
}

libclc/amdgpu/lib/SOURCES_3.9

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
shared/vload_half_helpers.ll
2+
shared/vstore_half_helpers.ll

libclc/configure.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ def llvm_config(args):
7272
llvm_int_version = int(llvm_version[0]) * 100 + int(llvm_version[1]) * 10
7373
llvm_string_version = llvm_version[0] + '.' + llvm_version[1]
7474

75-
if llvm_int_version < 400:
76-
print("libclc requires LLVM >= 4.0")
75+
if llvm_int_version < 390:
76+
print("libclc requires LLVM >= 3.9")
7777
sys.exit(1)
7878

7979
llvm_system_libs = llvm_config(['--system-libs'])
@@ -109,9 +109,13 @@ def llvm_config(args):
109109
'nvptx64--nvidiacl' : { 'devices' : [{'gpu' : '', 'aliases' : []} ]},
110110
}
111111

112-
available_targets['amdgcn-mesa-mesa3d'] = available_targets['amdgcn--']
113112

114-
default_targets = ['nvptx--nvidiacl', 'nvptx64--nvidiacl', 'r600--', 'amdgcn--', 'amdgcn--amdhsa', 'amdgcn-mesa-mesa3d']
113+
default_targets = ['nvptx--nvidiacl', 'nvptx64--nvidiacl', 'r600--', 'amdgcn--', 'amdgcn--amdhsa']
114+
115+
#mesa is using amdgcn-mesa-mesa3d since llvm-4.0
116+
if llvm_int_version > 390:
117+
available_targets['amdgcn-mesa-mesa3d'] = available_targets['amdgcn--']
118+
default_targets.append('amdgcn-mesa-mesa3d')
115119

116120
targets = args
117121
if not targets:
@@ -218,13 +222,21 @@ def llvm_config(args):
218222
override_list_file = os.path.join(libdir, 'OVERRIDES')
219223
compat_list_file = os.path.join(libdir,
220224
'SOURCES_' + llvm_string_version)
225+
compat_list_override = os.path.join(libdir,
226+
'OVERRIDES_' + llvm_string_version)
221227

222228
# Build compat list
223229
if os.path.exists(compat_list_file):
224230
for compat in open(compat_list_file).readlines():
225231
compat = compat.rstrip()
226232
compats.append(compat)
227233

234+
# Add target compat overrides
235+
if os.path.exists(compat_list_override):
236+
for override in open(compat_list_override).readlines():
237+
override = override.rstrip()
238+
sources_seen.add(override)
239+
228240
# Add target overrides
229241
if os.path.exists(override_list_file):
230242
for override in open(override_list_file).readlines():

libclc/utils/prepare-builtins.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
#if HAVE_LLVM > 0x0390
12
#include "llvm/Bitcode/BitcodeReader.h"
23
#include "llvm/Bitcode/BitcodeWriter.h"
4+
#else
5+
#include "llvm/Bitcode/ReaderWriter.h"
6+
#endif
7+
38
#include "llvm/IR/Function.h"
49
#include "llvm/IR/GlobalVariable.h"
510
#include "llvm/IR/LLVMContext.h"
@@ -41,8 +46,12 @@ int main(int argc, char **argv) {
4146
} else {
4247
std::unique_ptr<MemoryBuffer> &BufferPtr = BufferOrErr.get();
4348
ErrorOr<std::unique_ptr<Module>> ModuleOrErr =
49+
#if HAVE_LLVM > 0x0390
4450
expectedToErrorOrAndEmitErrors(Context,
4551
parseBitcodeFile(BufferPtr.get()->getMemBufferRef(), Context));
52+
#else
53+
parseBitcodeFile(BufferPtr.get()->getMemBufferRef(), Context);
54+
#endif
4655
if (std::error_code ec = ModuleOrErr.getError())
4756
ErrorMessage = ec.message();
4857

0 commit comments

Comments
 (0)