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

Unified Diff: pydir/build-pnacl-ir.py

Issue 265703002: Add Om1 lowering with no optimizations (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Merge changed from Karl's committed CL 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 | « crosstest/test_icmp_main.cpp ('k') | src/IceCfg.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pydir/build-pnacl-ir.py
diff --git a/pydir/build-pnacl-ir.py b/pydir/build-pnacl-ir.py
new file mode 100755
index 0000000000000000000000000000000000000000..67dbefdbb71d950c8d3efb3d0726337875d062cb
--- /dev/null
+++ b/pydir/build-pnacl-ir.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python2
+
+import argparse
+import os
+import sys
+import tempfile
+from utils import shellcmd
+
+if __name__ == '__main__':
+ argparser = argparse.ArgumentParser()
+ argparser.add_argument('cfile', nargs='+', type=str,
+ help='C file(s) to convert')
+ argparser.add_argument('--nacl_sdk_root', nargs='?', type=str,
+ help='Path to NACL_SDK_ROOT')
+ argparser.add_argument('--dir', nargs='?', type=str, default='.',
+ help='Output directory')
+ argparser.add_argument('--disable-verify', action='store_true')
+ args = argparser.parse_args()
+
+ nacl_sdk_root = os.environ.get('NACL_SDK_ROOT', None)
+ if args.nacl_sdk_root:
+ nacl_sdk_root = os.path.expanduser(args.nacl_sdk_root)
+
+ if not nacl_sdk_root or not os.path.exists(nacl_sdk_root):
+ print '''\
+Please set the NACL_SDK_ROOT environment variable or pass the path through
+--nacl_sdk_root to point to a valid Native Client SDK installation.'''
+ sys.exit(1)
+
+ includes_path = os.path.join(nacl_sdk_root, 'include')
+ toolchain_path = os.path.join(nacl_sdk_root, 'toolchain', 'linux_pnacl')
+ clang_path = os.path.join(toolchain_path, 'bin64', 'pnacl-clang')
+ opt_path = os.path.join(toolchain_path, 'host_x86_64', 'bin', 'opt')
+
+ tempdir = tempfile.mkdtemp()
+
+ for cname in args.cfile:
+ basename = os.path.splitext(cname)[0]
+ llname = os.path.join(tempdir, basename + '.ll')
+ pnaclname = basename + '.pnacl.ll'
+ pnaclname = os.path.join(args.dir, pnaclname)
+
+ shellcmd(clang_path + ' -I{0} -c {1} -o {2}'.format(
+ includes_path, cname, llname))
+ shellcmd(opt_path +
+ ' -O2 -pnacl-abi-simplify-preopt -pnacl-abi-simplify-postopt' +
+ ('' if args.disable_verify else
+ ' -verify-pnaclabi-module -verify-pnaclabi-functions') +
+ ' -pnaclabi-allow-debug-metadata -disable-simplify-libcalls'
+ ' {0} -S -o {1}'.format(llname, pnaclname))
« no previous file with comments | « crosstest/test_icmp_main.cpp ('k') | src/IceCfg.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698