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