Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: pydir/run-llvm2ice.py

Issue 600043002: Clean up run script to use for testing Subzero. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python2
2
3 import argparse
4 import itertools
5 import os
6 import re
7 import subprocess
8 import sys
9
10 from utils import shellcmd
11
12 if __name__ == '__main__':
13 desc = 'Run the llvm2ice compiler on a llvm file.'
Jim Stichnoth 2014/09/24 20:37:36 You should probably use a docstring here, like in
Karl 2014/09/24 21:01:22 Done.
14 argparser = argparse.ArgumentParser(
15 description=desc,
16 formatter_class=argparse.ArgumentDefaultsHelpFormatter,
17 epilog='''
18 This driver program assembles the input llvm file,
19 freezes it into a pexe file,
20 converts it to a Subzero program, and finally compiles it.
21 ''')
22 argparser.add_argument('--input', '-i', required=True,
23 help='LLVM source file to compile')
24 argparser.add_argument('--insts', required=False,
25 action='store_true',
26 help='Stop afer translating to Subzero instructions')
jvoung (off chromium) 2014/09/24 20:35:19 after
Karl 2014/09/24 21:01:22 Done.
27 argparser.add_argument('--no-local-syms', required=False,
28 action='store_true',
29 help="Don't keep local symbols in the PEXE file")
Jim Stichnoth 2014/09/24 20:37:36 Maybe lowercase 'pexe' for consistency with pexe a
Karl 2014/09/24 21:01:22 Done.
30 argparser.add_argument('--llvm', required=False,
31 action='store_true',
32 help='Parse pexe into llvm IR first, then ' +
33 'convert to Subzero')
34 argparser.add_argument('--llvm-source', required=False,
35 action='store_true',
36 help='Parse source directly into llvm IR ' +
37 '(without generating a pexe), then ' +
38 'convert to Subzero')
39 argparser.add_argument(
40 '--llvm2ice', required=False, default='./llvm2ice', metavar='LLVM2ICE',
41 help="Subzero translator 'llvm2ice'")
42 argparser.add_argument('--llvm-bin-path', required=False,
43 default=None, metavar='LLVM_BIN_PATH',
44 help='Path to LLVM executables ' +
45 '(for building PEXE files)')
46 argparser.add_argument('--echo-cmd', required=False,
47 action='store_true',
48 help='Trace command that generates ICE instructions')
49 argparser.add_argument('--args', '-a', nargs=argparse.REMAINDER,
50 help='Remaining arguments are passed to llvm2ice')
51
52 args = argparser.parse_args()
53 llvm_bin_path = args.llvm_bin_path
54 llfile = args.input
55
56 if args.llvm and args.llvm_source:
57 raise RuntimeError("Can't specify both '--llvm' and '--llvm-source'")
58
59 if args.llvm_source and args.no_local_syms:
60 raise RuntimeError("Can't specify both '--llvm-source' and " +
61 "'--no-local-syms'")
62
63 cmd = []
64 if not args.llvm_source:
65 cmd = [os.path.join(llvm_bin_path, 'llvm-as'), llfile, '-o', '-', '|',
66 os.path.join(llvm_bin_path, 'pnacl-freeze')]
67 if not args.no_local_syms:
68 cmd += ['--allow-local-symbol-tables']
69 cmd += ['|']
70 cmd += [args.llvm2ice]
71 if args.insts:
72 cmd += ['-verbose', 'inst', '-notranslate']
73 if not args.llvm_source:
74 cmd += ['--bitcode-format=pnacl']
75 if not args.no_local_syms:
76 cmd += ['--allow-local-symbol-tables']
77 if not (args.llvm or args.llvm_source):
78 cmd += ['--build-on-read']
79 if args.args:
80 cmd += args.args
81 if args.llvm_source:
82 cmd.append(llfile)
Jim Stichnoth 2014/09/24 20:37:36 Maybe use cmd += [llfile] for consistency?
83
84 stdout_result = shellcmd(cmd, echo=args.echo_cmd)
85 if not args.echo_cmd:
86 sys.stdout.write(stdout_result)
OLDNEW
« no previous file with comments | « pydir/llvm2iceinsts.py ('k') | tests_lit/lit.cfg » ('j') | tests_lit/lit.cfg » ('J')

Powered by Google App Engine
This is Rietveld 408576698