OLD | NEW |
1 # Taken from utils/lit/tests in the LLVM tree and hacked together to support | 1 # Taken from utils/lit/tests in the LLVM tree and hacked together to support |
2 # our tests. | 2 # our tests. |
3 | 3 |
4 # -*- Python -*- | 4 # -*- Python -*- |
5 | 5 |
6 import os | 6 import os |
7 import re | 7 import re |
8 import sys | 8 import sys |
9 | 9 |
10 import lit.formats | 10 import lit.formats |
(...skipping 21 matching lines...) Expand all Loading... |
32 config.substitutions.append(('%{python}', sys.executable)) | 32 config.substitutions.append(('%{python}', sys.executable)) |
33 | 33 |
34 pydir = os.path.join(bin_root, 'pydir') | 34 pydir = os.path.join(bin_root, 'pydir') |
35 | 35 |
36 # Finding LLVM binary tools. All tools used in the tests must be listed in | 36 # Finding LLVM binary tools. All tools used in the tests must be listed in |
37 # the llvmbintools list. | 37 # the llvmbintools list. |
38 llvmbinpath = os.path.abspath(os.environ.get('LLVM_BIN_PATH')) | 38 llvmbinpath = os.path.abspath(os.environ.get('LLVM_BIN_PATH')) |
39 | 39 |
40 # Finding Subzero tools | 40 # Finding Subzero tools |
41 llvm2icetool = os.path.join(bin_root, 'llvm2ice') | 41 llvm2icetool = os.path.join(bin_root, 'llvm2ice') |
| 42 |
| 43 # Convert LLVM source to PNaCl bitcode, read using the |
| 44 # Subzero bitcode reader, and then translate. |
42 config.substitutions.append( | 45 config.substitutions.append( |
43 ('%llvm2iceinsts', ' '.join([os.path.join(pydir, 'llvm2iceinsts.py'), | 46 ('%p2i', ' '.join([os.path.join(pydir, 'run-llvm2ice.py'), |
44 '--llvm2ice', llvm2icetool, | 47 '--llvm2ice', llvm2icetool, |
45 '--llvm-bin-path', llvmbinpath | 48 '--llvm-bin-path', llvmbinpath |
46 ]))) | 49 ]))) |
| 50 |
| 51 # Convert LLVM source to PNaCl bitcode, read using the PNaCl bitcode reader, |
| 52 # convert to ICE using the ICE Converter, and then translate. |
| 53 # TODO(kschimpf) Deprecated, remove once p2i working. |
| 54 config.substitutions.append( |
| 55 ('%l2i', ' '.join([os.path.join(pydir, 'run-llvm2ice.py'), |
| 56 '--llvm', '--llvm2ice', llvm2icetool, |
| 57 '--llvm-bin-path', llvmbinpath |
| 58 ]))) |
| 59 |
| 60 # Read LLVM source, convert to ICE using the ICE converter, and then translate. |
| 61 # Note: l2i is preferred over lc2i, since it uses PNaCl bitcode. |
| 62 # TODO(kschimpf) Deprecated, remove once p2i working. |
| 63 config.substitutions.append( |
| 64 ('%lc2i', ' '.join([os.path.join(pydir, 'run-llvm2ice.py'), |
| 65 '--llvm-source', '--llvm2ice', llvm2icetool, |
| 66 '--llvm-bin-path', llvmbinpath |
| 67 ]))) |
| 68 |
47 config.substitutions.append(('%llvm2ice', llvm2icetool)) | 69 config.substitutions.append(('%llvm2ice', llvm2icetool)) |
48 config.substitutions.append(('%szdiff', os.path.join(pydir, 'szdiff.py'))) | 70 config.substitutions.append(('%szdiff', os.path.join(pydir, 'szdiff.py'))) |
49 | 71 |
50 llvmbintools = [r"\bFileCheck\b", r"\bllvm-as\b", r"\bllvm-mc\b", | 72 llvmbintools = [r"\bFileCheck\b", r"\bllvm-as\b", r"\bllvm-mc\b", |
51 r"\bllvm-objdump\b", r"\bnot\b", r"\bpnacl-freeze\b", | 73 r"\bllvm-objdump\b", r"\bnot\b", r"\bpnacl-freeze\b", |
52 r"\bpnacl-bcdis\b"] | 74 r"\bpnacl-bcdis\b"] |
53 | 75 |
54 for tool in llvmbintools: | 76 for tool in llvmbintools: |
55 # The re.sub() line is adapted from one of LLVM's lit.cfg files. | 77 # The re.sub() line is adapted from one of LLVM's lit.cfg files. |
56 # Extract the tool name from the pattern. This relies on the tool | 78 # Extract the tool name from the pattern. This relies on the tool |
57 # name being surrounded by \b word match operators. If the | 79 # name being surrounded by \b word match operators. If the |
58 # pattern starts with "| ", include it in the string to be | 80 # pattern starts with "| ", include it in the string to be |
59 # substituted. | 81 # substituted. |
60 substitution = re.sub(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$", | 82 substitution = re.sub(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$", |
61 r"\2" + llvmbinpath + "/" + r"\4", | 83 r"\2" + llvmbinpath + "/" + r"\4", |
62 tool) | 84 tool) |
63 config.substitutions.append((tool, substitution)) | 85 config.substitutions.append((tool, substitution)) |
64 | 86 |
65 # Add a feature to detect the Python version. | 87 # Add a feature to detect the Python version. |
66 config.available_features.add("python%d.%d" % (sys.version_info[0], | 88 config.available_features.add("python%d.%d" % (sys.version_info[0], |
67 sys.version_info[1])) | 89 sys.version_info[1])) |
68 | 90 |
69 # Debugging output | 91 # Debugging output |
70 def dbg(s): | 92 def dbg(s): |
71 print '[DBG] %s' % s | 93 print '[DBG] %s' % s |
72 | 94 |
73 dbg('bin_root = %s' % bin_root) | 95 dbg('bin_root = %s' % bin_root) |
74 dbg('llvmbinpath = %s' % llvmbinpath) | 96 dbg('llvmbinpath = %s' % llvmbinpath) |
OLD | NEW |