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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pydir/utils.py » ('j') | szdiff.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: llvm2iceinsts.py
diff --git a/llvm2iceinsts.py b/llvm2iceinsts.py
new file mode 100755
index 0000000000000000000000000000000000000000..15f593400c1d1c24e7970e2296f05b07165afc33
--- /dev/null
+++ b/llvm2iceinsts.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python2
+
+import argparse
+import os, sys
+import itertools
+import subprocess
+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.
+
+for p in sys.path:
+ if p.endswith('/toolchain_build/src/pnacl-subzero'):
+ sys.path.insert(0, p + '/pydir')
+ break
+
+from utils import shellcmd
+
+if __name__ == '__main__':
+ """Runs commands"""
Jim Stichnoth 2014/05/14 21:45:18 More descriptive description.
Karl 2014/05/14 21:56:57 Done.
+ 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.
+ argparser = argparse.ArgumentParser(description=desc)
+ argparser.add_argument(
+ '--llvm2ice', required=False, default='./llvm2ice', metavar='LLVM2ICE',
+ help='Path to llvm2ice driver program [default ./llvm2ice]')
+ argparser.add_argument('--llvm-bin-path', required=False,
+ default=None, metavar='LLVM_BIN_PATH',
+ help='Path to LLVM executables ' +
+ '(for to building PNaCl files)')
Jim Stichnoth 2014/05/14 21:45:18 for to --> for
Karl 2014/05/14 21:56:57 Done.
+ argparser.add_argument('--pnacl', required=False,
+ action='store_true',
+ help='Convert llvm source to PNaCl bitcode ' +
+ 'file first')
+ argparser.add_argument('--echo-cmd', required=False,
+ action='store_true',
+ 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.
+ argparser.add_argument('llfile', nargs=1,
+ metavar='LLVM_FILE',
+ help='Llvm source file')
+ args = argparser.parse_args()
+ llvm_bin_path = args.llvm_bin_path
+ llfile = args.llfile[0]
+
+ cmd = []
+ if args.pnacl:
+ cmd = [os.path.join(llvm_bin_path, 'llvm-as'), llfile, '-o', '-', '|',
+ os.path.join(llvm_bin_path, 'pnacl-freeze'),
+ '--allow-local-symbol-tables', '|']
+ cmd += [args.llvm2ice, '-verbose', 'inst', '-notranslate']
+ if args.pnacl:
+ cmd += ['--allow-local-symbol-tables', '--bitcode-format=pnacl']
+ else:
+ cmd.append(llfile)
+
+ stdout_result = shellcmd(cmd, echo=args.echo_cmd)
+ if not args.echo_cmd:
+ sys.stdout.write(stdout_result)
« no previous file with comments | « no previous file | pydir/utils.py » ('j') | szdiff.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698