OLD | NEW |
1 # -*- Python -*- | 1 # -*- Python -*- |
2 # Taken from utils/lit/tests in the LLVM tree and hacked together to support | 2 # Taken from utils/lit/tests in the LLVM tree and hacked together to support |
3 # our tests. | 3 # our tests. |
4 # | 4 # |
5 # Note: This configuration has simple commands to run Subzero's translator. | 5 # Note: This configuration has simple commands to run Subzero's translator. |
6 # They have the form %X2i (i.e. %p2i, %l2i, and %lc2i) where X is defined | 6 # They have the form %X2i (i.e. %p2i, %l2i, and %lc2i) where X is defined |
7 # as follows: | 7 # as follows: |
8 # | 8 # |
9 # p : Run Subzero's translator, building ICE from PNaCl bitcode directly. | 9 # p : Run Subzero's translator, building ICE from PNaCl bitcode directly. |
10 # l : Run Subzero's translator, converting the .ll file to a PNaCl bitcode | 10 # l : Run Subzero's translator, converting the .ll file to a PNaCl bitcode |
(...skipping 21 matching lines...) Expand all Loading... |
32 # existence of %l2i and %lc2i), you can use the %if command (which is | 32 # existence of %l2i and %lc2i), you can use the %if command (which is |
33 # a short hand for using pydir/ifatts.py). | 33 # a short hand for using pydir/ifatts.py). |
34 | 34 |
35 import os | 35 import os |
36 import re | 36 import re |
37 import sys | 37 import sys |
38 | 38 |
39 import lit.formats | 39 import lit.formats |
40 | 40 |
41 sys.path.insert(0, 'pydir') | 41 sys.path.insert(0, 'pydir') |
42 from utils import FindBaseNaCl | 42 from utils import FindBaseNaCl, shellcmd |
43 from ifatts import GetFileAttributes | 43 from ifatts import GetFileAttributes |
44 | 44 |
45 # name: The name of this test suite. | 45 # name: The name of this test suite. |
46 config.name = 'subzero' | 46 config.name = 'subzero' |
47 | 47 |
48 # testFormat: The test format to use to interpret tests. | 48 # testFormat: The test format to use to interpret tests. |
49 config.test_format = lit.formats.ShTest() | 49 config.test_format = lit.formats.ShTest() |
50 | 50 |
51 # suffixes: A list of file extensions to treat as test files. | 51 # suffixes: A list of file extensions to treat as test files. |
52 config.suffixes = ['.ll'] | 52 config.suffixes = ['.ll'] |
53 | 53 |
54 # test_source_root: The root path where tests are located. | 54 # test_source_root: The root path where tests are located. |
55 config.test_source_root = os.path.dirname(__file__) | 55 config.test_source_root = os.path.dirname(__file__) |
56 config.test_exec_root = config.test_source_root | 56 config.test_exec_root = config.test_source_root |
57 config.target_triple = '(unused)' | 57 config.target_triple = '(unused)' |
58 | 58 |
59 src_root = os.path.join(FindBaseNaCl(), 'toolchain_build/src/subzero') | 59 src_root = os.path.join(FindBaseNaCl(), 'toolchain_build/src/subzero') |
60 bin_root = src_root | 60 bin_root = src_root |
61 config.substitutions.append(('%{src_root}', src_root)) | 61 config.substitutions.append(('%{src_root}', src_root)) |
62 config.substitutions.append(('%{python}', sys.executable)) | 62 config.substitutions.append(('%{python}', sys.executable)) |
63 | 63 |
64 pydir = os.path.join(bin_root, 'pydir') | 64 pydir = os.path.join(bin_root, 'pydir') |
65 | 65 |
66 # Finding LLVM binary tools. All tools used in the tests must be listed in | 66 # Finding LLVM binary tools. All tools used in the tests must be listed in |
67 # the llvmbintools list. | 67 # the llvmbintools list. |
68 llvmbinpath = os.path.abspath(os.environ.get('LLVM_BIN_PATH')) | 68 llvmbinpath = os.path.abspath(os.environ.get('LLVM_BIN_PATH')) |
69 | 69 |
70 # Define the location of the llvm2ice tool. | 70 # Define the location of the llvm2ice tool. |
71 llvm2icetool = os.path.join(bin_root, 'llvm2ice') | 71 llvm2icetool = os.path.join(bin_root, 'llvm2ice') |
72 llvm2icetoolatts = os.path.join(bin_root, 'llvm2ice.build_atts') | 72 llvm2iceatts = shellcmd(' '.join([llvm2icetool, '--build-atts']), |
| 73 echo=False).split() |
73 | 74 |
74 # Add build attributes of llvm2ice tool to the set of available features. | 75 # Add build attributes of llvm2ice tool to the set of available features. |
75 config.available_features.update(GetFileAttributes(llvm2icetoolatts)) | 76 config.available_features.update(llvm2iceatts) |
76 | 77 |
77 # Base command for testing build attributes | 78 def if_cond_flag(Value): |
78 if_atts_base = [os.path.join(pydir, 'ifatts.py'), llvm2icetoolatts] | 79 return '--cond=true' if Value else '--cond=false' |
79 if_atts_cmd = if_atts_base + ['--command'] | 80 |
80 ifl2i_atts_cmd = if_atts_base + ['--att=allow_llvm_ir', '--command'] | 81 # shell conditional commands. |
81 iflc2i_atts_cmd = if_atts_base + ['--att=allow_llvm_ir', | 82 if_atts = [os.path.join(pydir, 'if.py')] |
82 '--att=allow_llvm_ir_as_input', | 83 if_atts_cmd = if_atts + ['--have=' + att |
83 '--command'] | 84 for att in llvm2iceatts] + ['--command'] |
| 85 ifl2i_atts_cmd = if_atts + [if_cond_flag('allow_llvm_ir' in llvm2iceatts), |
| 86 '--command'] |
| 87 iflc2i_atts_cmd = if_atts + [if_cond_flag('allow_llvm_ir_as_input' |
| 88 in llvm2iceatts), '--command'] |
84 | 89 |
85 # Base command for running llvm2ice | 90 # Base command for running llvm2ice |
86 llvm2ice_cmd = [os.path.join(pydir, 'run-llvm2ice.py'), | 91 llvm2ice_cmd = [os.path.join(pydir, 'run-llvm2ice.py'), |
87 '--llvm2ice', llvm2icetool, | 92 '--llvm2ice', llvm2icetool, |
88 '--llvm-bin-path', llvmbinpath] | 93 '--llvm-bin-path', llvmbinpath] |
89 | 94 |
90 # Run commands only if corresponding build attributes apply, including | 95 # Run commands only if corresponding build attributes apply, including |
91 # for each compiler setup. | 96 # for each compiler setup. |
92 config.substitutions.append(('%ifp', ' ')) | 97 config.substitutions.append(('%ifp', ' ')) |
93 config.substitutions.append(('%iflc', ' '.join(iflc2i_atts_cmd))) | 98 config.substitutions.append(('%iflc', ' '.join(iflc2i_atts_cmd))) |
(...skipping 28 matching lines...) Expand all Loading... |
122 # Add a feature to detect the Python version. | 127 # Add a feature to detect the Python version. |
123 config.available_features.add("python%d.%d" % (sys.version_info[0], | 128 config.available_features.add("python%d.%d" % (sys.version_info[0], |
124 sys.version_info[1])) | 129 sys.version_info[1])) |
125 | 130 |
126 # Debugging output | 131 # Debugging output |
127 def dbg(s): | 132 def dbg(s): |
128 print '[DBG] %s' % s | 133 print '[DBG] %s' % s |
129 | 134 |
130 dbg('bin_root = %s' % bin_root) | 135 dbg('bin_root = %s' % bin_root) |
131 dbg('llvmbinpath = %s' % llvmbinpath) | 136 dbg('llvmbinpath = %s' % llvmbinpath) |
| 137 dbg("Build attributes = %s" % llvm2iceatts) |
OLD | NEW |