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

Side by Side Diff: llvm2iceinsts.py

Issue 277033003: Modify pnacl subzero to be able to read pnacl bitcode files. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Fix test files to also test PNaCl bitcode files. Created 6 years, 7 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 | « no previous file | pydir/utils.py » ('j') | szdiff.py » ('J')
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 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)
OLDNEW
« no previous file with comments | « no previous file | pydir/utils.py » ('j') | szdiff.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698