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

Side by Side Diff: llvm2iceinsts.py

Issue 554013002: Subzero: Move python scripts into a common pydir. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « crosstest/runtests.sh ('k') | pydir/crosstest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'pydir'))
11
12 from utils import shellcmd
13
14 if __name__ == '__main__':
15 desc = 'Run llvm2ice on llvm file to produce ICE instructions.'
16 argparser = argparse.ArgumentParser(
17 description=desc,
18 formatter_class=argparse.ArgumentDefaultsHelpFormatter,
19 epilog='''
20 Runs in two modes, depending on whether the flag '--pnacl' is specified.
21
22 If flag '--pnacl' is omitted, it runs llvm2ice to (directly) generate
23 the corresponding ICE instructions.
24
25 If flag '--pnacl' is given, it first assembles and freezes the
26 llvm source file generating the corresponding PNaCl bitcode
27 file. The PNaCl bitcode file is then piped into llvm2ice to
28 generate the corresponding ICE instructions.
29 ''')
30 argparser.add_argument(
31 '--llvm2ice', required=False, default='./llvm2ice', metavar='LLVM2ICE',
32 help='Path to llvm2ice driver program')
33 argparser.add_argument('--llvm-bin-path', required=False,
34 default=None, metavar='LLVM_BIN_PATH',
35 help='Path to LLVM executables ' +
36 '(for building PNaCl files)')
37 argparser.add_argument('--pnacl', required=False,
38 action='store_true',
39 help='Convert llvm source to PNaCl bitcode ' +
40 'file first')
41 argparser.add_argument('--echo-cmd', required=False,
42 action='store_true',
43 help='Trace command that generates ICE instructions')
44 argparser.add_argument('llfile', nargs=1,
45 metavar='LLVM_FILE',
46 help='Llvm source file')
47
48 args = argparser.parse_args()
49 llvm_bin_path = args.llvm_bin_path
50 llfile = args.llfile[0]
51
52 cmd = []
53 if args.pnacl:
54 cmd = [os.path.join(llvm_bin_path, 'llvm-as'), llfile, '-o', '-', '|',
55 os.path.join(llvm_bin_path, 'pnacl-freeze'),
56 '--allow-local-symbol-tables', '|']
57 cmd += [args.llvm2ice, '-verbose', 'inst', '-notranslate']
58 if args.pnacl:
59 cmd += ['--allow-local-symbol-tables', '--bitcode-format=pnacl']
60 else:
61 cmd.append(llfile)
62
63 stdout_result = shellcmd(cmd, echo=args.echo_cmd)
64 if not args.echo_cmd:
65 sys.stdout.write(stdout_result)
OLDNEW
« no previous file with comments | « crosstest/runtests.sh ('k') | pydir/crosstest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698