Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python2 | |
| 2 | |
| 3 import argparse | |
| 4 import os, sys | |
| 5 import itertools | |
| 6 import subprocess | |
| 7 import re | |
|
Jim Stichnoth
2014/05/14 21:45:18
Sort imports alphabetically. (I know some or all
Karl
2014/05/14 21:56:57
Done.
| |
| 8 | |
| 9 for p in sys.path: | |
| 10 if p.endswith('/toolchain_build/src/pnacl-subzero'): | |
| 11 sys.path.insert(0, p + '/pydir') | |
| 12 break | |
| 13 | |
| 14 from utils import shellcmd | |
| 15 | |
| 16 if __name__ == '__main__': | |
| 17 """Runs commands""" | |
|
Jim Stichnoth
2014/05/14 21:45:18
More descriptive description.
Karl
2014/05/14 21:56:57
Done.
| |
| 18 desc = 'Run llvm2ice on llvm file to produce ice instructions.' | |
|
Jim Stichnoth
2014/05/14 21:45:18
I've been trying to use all-capitalized ICE in tex
Karl
2014/05/14 21:56:57
Done.
| |
| 19 argparser = argparse.ArgumentParser(description=desc) | |
| 20 argparser.add_argument( | |
| 21 '--llvm2ice', required=False, default='./llvm2ice', metavar='LLVM2ICE', | |
| 22 help='Path to llvm2ice driver program [default ./llvm2ice]') | |
| 23 argparser.add_argument('--llvm-bin-path', required=False, | |
| 24 default=None, metavar='LLVM_BIN_PATH', | |
| 25 help='Path to LLVM executables ' + | |
| 26 '(for to building PNaCl files)') | |
|
Jim Stichnoth
2014/05/14 21:45:18
for to --> for
Karl
2014/05/14 21:56:57
Done.
| |
| 27 argparser.add_argument('--pnacl', required=False, | |
| 28 action='store_true', | |
| 29 help='Convert llvm source to PNaCl bitcode ' + | |
| 30 'file first') | |
| 31 argparser.add_argument('--echo-cmd', required=False, | |
| 32 action='store_true', | |
| 33 help='Trace command that generates ice instructions') | |
|
Jim Stichnoth
2014/05/14 21:45:18
ice --> ICE
Karl
2014/05/14 21:56:57
Done.
| |
| 34 argparser.add_argument('llfile', nargs=1, | |
| 35 metavar='LLVM_FILE', | |
| 36 help='Llvm source file') | |
| 37 args = argparser.parse_args() | |
| 38 llvm_bin_path = args.llvm_bin_path | |
| 39 llfile = args.llfile[0] | |
| 40 | |
| 41 cmd = [] | |
| 42 if args.pnacl: | |
| 43 cmd = [os.path.join(llvm_bin_path, 'llvm-as'), llfile, '-o', '-', '|', | |
| 44 os.path.join(llvm_bin_path, 'pnacl-freeze'), | |
| 45 '--allow-local-symbol-tables', '|'] | |
| 46 cmd += [args.llvm2ice, '-verbose', 'inst', '-notranslate'] | |
| 47 if args.pnacl: | |
| 48 cmd += ['--allow-local-symbol-tables', '--bitcode-format=pnacl'] | |
| 49 else: | |
| 50 cmd.append(llfile) | |
| 51 | |
| 52 stdout_result = shellcmd(cmd, echo=args.echo_cmd) | |
| 53 if not args.echo_cmd: | |
| 54 sys.stdout.write(stdout_result) | |
| OLD | NEW |