Index: crosstest/crosstest.py |
diff --git a/crosstest/crosstest.py b/crosstest/crosstest.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..ab241cf5c94f5f7a2e2e3e6988f0d1e033d01703 |
--- /dev/null |
+++ b/crosstest/crosstest.py |
@@ -0,0 +1,66 @@ |
+#!/usr/bin/env python2 |
+ |
+import argparse |
+import os, sys |
+import subprocess |
+import tempfile |
+ |
+sys.path.insert(0, '../pydir') |
+from utils import shellcmd |
+ |
+if __name__ == '__main__': |
+ argparser = argparse.ArgumentParser() |
+ argparser.add_argument('--test', required=True, action='append', |
+ help='List of C/C++/.ll files with test functions') |
+ argparser.add_argument('--driver', required=True, |
+ help='Driver program') |
+ argparser.add_argument('--target', required=False, default='X8632', |
JF
2014/05/01 00:16:55
X8632 isn't the naming you followed in the previou
Jim Stichnoth
2014/05/05 07:03:55
Looks like I was inconsistent in the previous CL.
|
+ help='Translation target string') |
+ argparser.add_argument('-O', required=False, default='2', dest='optlevel', |
+ choices=['m1', '-1', '0', '1', '2'], |
JF
2014/05/01 00:16:55
Are m1 and -1 the same?
Jim Stichnoth
2014/05/05 07:03:55
Yes. Added to the help string.
|
+ help='Optimization level'); |
+ argparser.add_argument('--prefix', required=True, |
+ help='String prepended to Subzero symbol names') |
+ argparser.add_argument('--output', '-o', required=True, |
+ help='Executable to produce') |
+ argparser.add_argument('--dir', required=False, default='.', |
+ help='Output directory for all files') |
+ args = argparser.parse_args() |
+ |
+ objs = [] |
+ for arg in args.test: |
+ base, ext = os.path.splitext(arg) |
+ if ext == '.ll': |
+ bitcode = arg |
+ else: |
+ bitcode = os.path.join(args.dir, base + '.pnacl.ll') |
+ shellcmd(['../pydir/build-pnacl-ir.py', '--dir', args.dir, arg]) |
+ shellcmd('sed -i "s/^define internal /define /" ' + bitcode) |
+ shellcmd('sed -i "s/le32-unknown-nacl/i686-pc-linux-gnu/" ' + bitcode) |
JF
2014/05/01 00:16:55
sed?
Jim Stichnoth
2014/05/05 07:03:55
okok, I redid this with python regex.
|
+ |
+ asm_sz = os.path.join(args.dir, base + '.sz.s') |
+ obj_sz = os.path.join(args.dir, base + '.sz.o') |
+ obj_llc = os.path.join(args.dir, base + '.llc.o') |
+ shellcmd(['../llvm2ice', |
+ '-O' + args.optlevel, |
+ '--target=' + args.target, |
+ '--prefix=' + args.prefix, |
+ '-o=' + asm_sz, |
+ bitcode]) |
+ shellcmd(['$LLVM_BIN_PATH/llvm-mc', |
JF
2014/05/01 00:16:55
Shouldn't LLVM_BIN_PATH be an argument instead?
Jim Stichnoth
2014/05/05 07:03:55
Done. Added --llvm-bin-path arg, and changed runte
|
+ '-arch=x86', |
JF
2014/05/01 00:16:55
x86 always?
Jim Stichnoth
2014/05/05 07:03:55
Added the arch_map dictionary to map Subzero --tar
|
+ '-x86-asm-syntax=intel', |
+ '-filetype=obj', |
+ '-o=' + obj_sz, |
+ asm_sz]) |
+ shellcmd(['$LLVM_BIN_PATH/llc', |
+ '-filetype=obj', |
+ '-o=' + obj_llc, |
+ bitcode]) |
+ objs.append(obj_sz) |
+ objs.append(bitcode) |
+ #objs.append(obj_llc) |
JF
2014/05/01 00:16:55
Commented out.
Jim Stichnoth
2014/05/05 07:03:55
This was left in intentionally, but I cleaned it u
|
+ |
+ shellcmd(['$LLVM_BIN_PATH/clang', '-g', '-m32', args.driver] + |
+ objs + |
+ ['-lm', '-o', os.path.join(args.dir, args.output)]) |
JF
2014/05/01 00:16:55
Doesn't this sometimes need to be clang++ to find
Jim Stichnoth
2014/05/05 07:03:55
You are right. 'clang' doesn't work as the linker
|