OLD | NEW |
1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python2 |
2 | 2 |
3 import argparse | 3 import argparse |
4 import itertools | 4 import itertools |
5 import os | 5 import os |
6 import re | 6 import re |
7 import subprocess | 7 import subprocess |
8 import sys | 8 import sys |
9 | 9 |
10 from utils import shellcmd | 10 from utils import shellcmd |
(...skipping 29 matching lines...) Expand all Loading... |
40 '--llvm2ice', required=False, default='./llvm2ice', metavar='LLVM2ICE', | 40 '--llvm2ice', required=False, default='./llvm2ice', metavar='LLVM2ICE', |
41 help="Subzero translator 'llvm2ice'") | 41 help="Subzero translator 'llvm2ice'") |
42 argparser.add_argument('--llvm-bin-path', required=False, | 42 argparser.add_argument('--llvm-bin-path', required=False, |
43 default=None, metavar='LLVM_BIN_PATH', | 43 default=None, metavar='LLVM_BIN_PATH', |
44 help='Path to LLVM executables ' + | 44 help='Path to LLVM executables ' + |
45 '(for building PEXE files)') | 45 '(for building PEXE files)') |
46 argparser.add_argument('--echo-cmd', required=False, | 46 argparser.add_argument('--echo-cmd', required=False, |
47 action='store_true', | 47 action='store_true', |
48 help='Trace command that generates ICE instructions') | 48 help='Trace command that generates ICE instructions') |
49 argparser.add_argument('--args', '-a', nargs=argparse.REMAINDER, | 49 argparser.add_argument('--args', '-a', nargs=argparse.REMAINDER, |
| 50 default=[], |
50 help='Remaining arguments are passed to llvm2ice') | 51 help='Remaining arguments are passed to llvm2ice') |
51 | 52 |
52 args = argparser.parse_args() | 53 args = argparser.parse_args() |
53 llvm_bin_path = args.llvm_bin_path | 54 llvm_bin_path = args.llvm_bin_path |
54 llfile = args.input | 55 llfile = args.input |
55 | 56 |
56 if args.llvm and args.llvm_source: | 57 if args.llvm and args.llvm_source: |
57 raise RuntimeError("Can't specify both '--llvm' and '--llvm-source'") | 58 raise RuntimeError("Can't specify both '--llvm' and '--llvm-source'") |
58 | 59 |
59 if args.llvm_source and args.no_local_syms: | 60 if args.llvm_source and args.no_local_syms: |
(...skipping 11 matching lines...) Expand all Loading... |
71 if args.insts: | 72 if args.insts: |
72 cmd += ['-verbose', 'inst', '-notranslate'] | 73 cmd += ['-verbose', 'inst', '-notranslate'] |
73 if not args.llvm_source: | 74 if not args.llvm_source: |
74 cmd += ['--bitcode-format=pnacl'] | 75 cmd += ['--bitcode-format=pnacl'] |
75 if not args.no_local_syms: | 76 if not args.no_local_syms: |
76 cmd += ['--allow-local-symbol-tables'] | 77 cmd += ['--allow-local-symbol-tables'] |
77 if args.llvm or args.llvm_source: | 78 if args.llvm or args.llvm_source: |
78 cmd += ['--build-on-read=0'] | 79 cmd += ['--build-on-read=0'] |
79 else: | 80 else: |
80 cmd += ['--build-on-read=1'] | 81 cmd += ['--build-on-read=1'] |
81 if args.args: | 82 cmd += args.args |
82 cmd += args.args | |
83 if args.llvm_source: | 83 if args.llvm_source: |
84 cmd += [llfile] | 84 cmd += [llfile] |
85 | 85 |
86 stdout_result = shellcmd(cmd, echo=args.echo_cmd) | 86 stdout_result = shellcmd(cmd, echo=args.echo_cmd) |
87 if not args.echo_cmd: | 87 if not args.echo_cmd: |
88 sys.stdout.write(stdout_result) | 88 sys.stdout.write(stdout_result) |
89 | 89 |
90 if __name__ == '__main__': | 90 if __name__ == '__main__': |
91 main() | 91 main() |
OLD | NEW |