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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 config.test_exec_root = config.test_source_root | 55 config.test_exec_root = config.test_source_root |
56 config.target_triple = '(unused)' | 56 config.target_triple = '(unused)' |
57 | 57 |
58 src_root = os.path.join(FindBaseNaCl(), 'toolchain_build/src/subzero') | 58 src_root = os.path.join(FindBaseNaCl(), 'toolchain_build/src/subzero') |
59 bin_root = src_root | 59 bin_root = src_root |
60 config.substitutions.append(('%{src_root}', src_root)) | 60 config.substitutions.append(('%{src_root}', src_root)) |
61 config.substitutions.append(('%{python}', sys.executable)) | 61 config.substitutions.append(('%{python}', sys.executable)) |
62 | 62 |
63 pydir = os.path.join(bin_root, 'pydir') | 63 pydir = os.path.join(bin_root, 'pydir') |
64 | 64 |
65 # Finding LLVM binary tools. All tools used in the tests must be listed in | 65 # Finding LLVM binary tools. Tools used in the tests must be listed in |
66 # the llvmbintools list. | 66 # the llvmbintools list or binutilsbintools. |
67 llvmbinpath = os.path.abspath(os.environ.get('LLVM_BIN_PATH')) | 67 llvmbinpath = os.path.abspath(os.environ.get('LLVM_BIN_PATH')) |
68 | 68 |
| 69 # Find binutils tools. This is used for objdump. |
| 70 binutilsbinpath = os.path.abspath(os.environ.get('BINUTILS_BIN_PATH')) |
| 71 |
69 # Define the location of the llvm2ice tool. | 72 # Define the location of the llvm2ice tool. |
70 llvm2icetool = os.path.join(bin_root, 'llvm2ice') | 73 llvm2icetool = os.path.join(bin_root, 'llvm2ice') |
71 llvm2iceatts = shellcmd(' '.join([llvm2icetool, '--build-atts']), | 74 llvm2iceatts = shellcmd(' '.join([llvm2icetool, '--build-atts']), |
72 echo=False).split() | 75 echo=False).split() |
73 | 76 |
74 # Add build attributes of llvm2ice tool to the set of available features. | 77 # Add build attributes of llvm2ice tool to the set of available features. |
75 config.available_features.update(llvm2iceatts) | 78 config.available_features.update(llvm2iceatts) |
76 | 79 |
77 def if_cond_flag(Value): | 80 def if_cond_flag(Value): |
78 return '--cond=true' if Value else '--cond=false' | 81 return '--cond=true' if Value else '--cond=false' |
79 | 82 |
80 # shell conditional commands. | 83 # shell conditional commands. |
81 if_atts = [os.path.join(pydir, 'if.py')] | 84 if_atts = [os.path.join(pydir, 'if.py')] |
82 if_atts_cmd = if_atts + ['--have=' + att for att in llvm2iceatts] | 85 if_atts_cmd = if_atts + ['--have=' + att for att in llvm2iceatts] |
83 ifl2i_atts_cmd = if_atts + [if_cond_flag('allow_llvm_ir' in llvm2iceatts), | 86 ifl2i_atts_cmd = if_atts + [if_cond_flag('allow_llvm_ir' in llvm2iceatts), |
84 '--command'] | 87 '--command'] |
85 iflc2i_atts_cmd = if_atts + [if_cond_flag('allow_llvm_ir_as_input' | 88 iflc2i_atts_cmd = if_atts + [if_cond_flag('allow_llvm_ir_as_input' |
86 in llvm2iceatts), '--command'] | 89 in llvm2iceatts), '--command'] |
87 | 90 |
88 # Base command for running llvm2ice | 91 # Base command for running llvm2ice |
89 llvm2ice_cmd = [os.path.join(pydir, 'run-llvm2ice.py'), | 92 llvm2ice_cmd = [os.path.join(pydir, 'run-llvm2ice.py'), |
90 '--llvm2ice', llvm2icetool, | 93 '--llvm2ice', llvm2icetool, |
91 '--llvm-bin-path', llvmbinpath] | 94 '--llvm-bin-path', llvmbinpath, |
| 95 '--binutils-bin-path', binutilsbinpath] |
92 | 96 |
93 # Run commands only if corresponding build attributes apply, including | 97 # Run commands only if corresponding build attributes apply, including |
94 # for each compiler setup. | 98 # for each compiler setup. |
95 config.substitutions.append(('%ifp', ' ')) | 99 config.substitutions.append(('%ifp', ' ')) |
96 config.substitutions.append(('%iflc', ' '.join(iflc2i_atts_cmd))) | 100 config.substitutions.append(('%iflc', ' '.join(iflc2i_atts_cmd))) |
97 config.substitutions.append(('%ifl', ' '.join(ifl2i_atts_cmd))) | 101 config.substitutions.append(('%ifl', ' '.join(ifl2i_atts_cmd))) |
98 config.substitutions.append(('%if', ' '.join(if_atts_cmd))) | 102 config.substitutions.append(('%if', ' '.join(if_atts_cmd))) |
99 | 103 |
100 # Translate LLVM source for each compiler setup. | 104 # Translate LLVM source for each compiler setup. |
101 config.substitutions.append(('%p2i', ' '.join(llvm2ice_cmd))) | 105 config.substitutions.append(('%p2i', ' '.join(llvm2ice_cmd))) |
102 config.substitutions.append(('%l2i', ' '.join(ifl2i_atts_cmd + llvm2ice_cmd | 106 config.substitutions.append(('%l2i', ' '.join(ifl2i_atts_cmd + llvm2ice_cmd |
103 + ['--llvm']))) | 107 + ['--llvm']))) |
104 config.substitutions.append(('%lc2i', ' '.join(iflc2i_atts_cmd + llvm2ice_cmd | 108 config.substitutions.append(('%lc2i', ' '.join(iflc2i_atts_cmd + llvm2ice_cmd |
105 + ['--llvm-source']))) | 109 + ['--llvm-source']))) |
106 | 110 |
107 config.substitutions.append(('%llvm2ice', llvm2icetool)) | 111 config.substitutions.append(('%llvm2ice', llvm2icetool)) |
108 | 112 |
109 llvmbintools = [r"\bFileCheck\b", | 113 llvmbintools = [r"\bFileCheck\b", |
110 r"\bllvm-as\b", | 114 r"\bllvm-as\b", |
111 r"\bllvm-mc\b", | 115 r"\bllvm-mc\b", |
112 r"\bllvm-objdump\b", | |
113 r"\bllvm-readobj\b", | 116 r"\bllvm-readobj\b", |
114 r"\bnot\b", | 117 r"\bnot\b", |
115 r"\bpnacl-freeze\b", | 118 r"\bpnacl-freeze\b", |
116 r"\bpnacl-bcdis\b"] | 119 r"\bpnacl-bcdis\b"] |
117 | 120 |
118 for tool in llvmbintools: | 121 for tool in llvmbintools: |
119 # The re.sub() line is adapted from one of LLVM's lit.cfg files. | 122 # The re.sub() line is adapted from one of LLVM's lit.cfg files. |
120 # Extract the tool name from the pattern. This relies on the tool | 123 # Extract the tool name from the pattern. This relies on the tool |
121 # name being surrounded by \b word match operators. If the | 124 # name being surrounded by \b word match operators. If the |
122 # pattern starts with "| ", include it in the string to be | 125 # pattern starts with "| ", include it in the string to be |
123 # substituted. | 126 # substituted. |
124 substitution = re.sub(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$", | 127 substitution = re.sub(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$", |
125 r"\2" + llvmbinpath + "/" + r"\4", | 128 r"\2" + llvmbinpath + "/" + r"\4", |
126 tool) | 129 tool) |
127 config.substitutions.append((tool, substitution)) | 130 config.substitutions.append((tool, substitution)) |
128 | 131 |
| 132 binutilsbintools = [r"\bobjdump\b",] |
| 133 |
| 134 for tool in binutilsbintools: |
| 135 # The re.sub() line is adapted from one of LLVM's lit.cfg files. |
| 136 # Similar to the llvmbintools. |
| 137 substitution = re.sub(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$", |
| 138 r"\2" + binutilsbinpath + "/" + r"\4", |
| 139 tool) |
| 140 config.substitutions.append((tool, substitution)) |
| 141 |
129 # Add a feature to detect the Python version. | 142 # Add a feature to detect the Python version. |
130 config.available_features.add("python%d.%d" % (sys.version_info[0], | 143 config.available_features.add("python%d.%d" % (sys.version_info[0], |
131 sys.version_info[1])) | 144 sys.version_info[1])) |
132 | 145 |
133 # Debugging output | 146 # Debugging output |
134 def dbg(s): | 147 def dbg(s): |
135 print '[DBG] %s' % s | 148 print '[DBG] %s' % s |
136 | 149 |
137 dbg('bin_root = %s' % bin_root) | 150 dbg('bin_root = %s' % bin_root) |
138 dbg('llvmbinpath = %s' % llvmbinpath) | 151 dbg('llvmbinpath = %s' % llvmbinpath) |
| 152 dbg('binutilsbinpath = %s' % binutilsbinpath) |
139 dbg("Build attributes = %s" % llvm2iceatts) | 153 dbg("Build attributes = %s" % llvm2iceatts) |
OLD | NEW |