-
Notifications
You must be signed in to change notification settings - Fork 53
/
ispc-disp
executable file
·64 lines (55 loc) · 1.9 KB
/
ispc-disp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/python3
###############################################################################
#
# Copyright (c) 2020, Intel Corporation
# Copyright (c) 2020, University of Utah
# SPDX-License-Identifier: Apache-2.0
#
###############################################################################
# This script modifies passed arguments to provide a common interface for ispc
# and clang.
# It is a terrible work-around and we need to change it in the future.
###############################################################################
import re
import sys
ispc_replacements = [('-c', ''), ('-std=c++11', '')]
clang_replacements = [('-woff', '-w'), ('--pic', '-fPIC'), ('--mcmodel=large', '-mcmodel=large')]
targ_replacements = [('sse\d', 'westmere'),
('avx1', 'sandybridge'),
('avx2', 'haswell'),
('avx512knl', 'knl'),
('avx512skx', '')]
def replace_arg(arg, replacements):
for repl in replacements:
sig, new_arg = repl
if arg == sig:
return new_arg
return arg
def replace_targ(arg):
march_arg, arch = arg.split('=')
new_arg = "-march="
arch = arch.split('-')[0]
for i in targ_replacements:
arch = re.sub(i[0], i[1], arch)
new_arg += arch
return new_arg
def process(args):
is_clang = False
if 'func.ispc' not in args:
is_clang = True
new_args = []
if not is_clang:
new_args.append("ispc")
for arg in args[1:]:
new_args.append(replace_arg(arg, ispc_replacements))
else:
new_args.append("clang++")
for arg in args[1:]:
if arg.startswith("--target"):
new_args.append(replace_targ(arg))
else:
new_args.append(replace_arg(arg, clang_replacements))
new_args = " ".join(new_args)
print(new_args)
if __name__ == '__main__':
process(sys.argv)