OLD | NEW |
1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python2 |
2 | 2 |
3 import argparse | 3 import argparse |
4 import itertools | 4 import itertools |
5 import os | 5 import os |
6 import re | 6 import re |
7 import subprocess | 7 import subprocess |
8 import sys | 8 import sys |
9 import tempfile | 9 import tempfile |
10 | 10 |
11 from utils import FindBaseNaCl, shellcmd | 11 from utils import FindBaseNaCl, shellcmd |
12 | 12 |
13 | 13 |
14 def TargetAssemblerFlags(target, sandboxed): | 14 def TargetAssemblerFlags(target, sandboxed): |
15 # TODO(reed kotler). Need to find out exactly we need to | 15 # TODO(reed kotler). Need to find out exactly we need to |
16 # add here for Mips32. | 16 # add here for Mips32. |
17 flags = { 'x8632': ['-triple=%s' % ('i686-nacl' if sandboxed else 'i686')], | 17 flags = { 'x8632': ['-triple=%s' % ('i686-nacl' if sandboxed else 'i686')], |
| 18 'x8664': ['-triple=%s' % ( |
| 19 'x86_64-nacl' if sandboxed else 'x86_64')], |
18 'arm32': ['-triple=%s' % ( | 20 'arm32': ['-triple=%s' % ( |
19 'armv7a-nacl' if sandboxed else 'armv7a'), | 21 'armv7a-nacl' if sandboxed else 'armv7a'), |
20 '-mcpu=cortex-a9', '-mattr=+neon'], | 22 '-mcpu=cortex-a9', '-mattr=+neon'], |
21 'mips32': ['-triple=mipsel' ] } | 23 'mips32': ['-triple=mipsel' ] } |
22 return flags[target] | 24 return flags[target] |
23 | 25 |
24 | 26 |
25 def TargetDisassemblerFlags(target): | 27 def TargetDisassemblerFlags(target): |
26 flags = { 'x8632': ['-Mintel'], | 28 flags = { 'x8632': ['-Mintel'], |
| 29 'x8664': ['-Mintel'], |
27 'arm32': [], | 30 'arm32': [], |
28 'mips32':[] } | 31 'mips32':[] } |
29 return flags[target] | 32 return flags[target] |
30 | 33 |
31 | 34 |
32 def main(): | 35 def main(): |
33 """Run the pnacl-sz compiler on an llvm file. | 36 """Run the pnacl-sz compiler on an llvm file. |
34 | 37 |
35 Takes an llvm input file, freezes it into a pexe file, converts | 38 Takes an llvm input file, freezes it into a pexe file, converts |
36 it to a Subzero program, and finally compiles it. | 39 it to a Subzero program, and finally compiles it. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 help='Disassemble the assembled output') | 79 help='Disassemble the assembled output') |
77 argparser.add_argument('--dis-flags', required=False, | 80 argparser.add_argument('--dis-flags', required=False, |
78 action='append', default=[], | 81 action='append', default=[], |
79 help='Add a disassembler flag') | 82 help='Add a disassembler flag') |
80 argparser.add_argument('--filetype', default='iasm', dest='filetype', | 83 argparser.add_argument('--filetype', default='iasm', dest='filetype', |
81 choices=['obj', 'asm', 'iasm'], | 84 choices=['obj', 'asm', 'iasm'], |
82 help='Output file type. Default %(default)s') | 85 help='Output file type. Default %(default)s') |
83 argparser.add_argument('--forceasm', required=False, action='store_true', | 86 argparser.add_argument('--forceasm', required=False, action='store_true', |
84 help='Force --filetype=asm') | 87 help='Force --filetype=asm') |
85 argparser.add_argument('--target', default='x8632', dest='target', | 88 argparser.add_argument('--target', default='x8632', dest='target', |
86 choices=['x8632','arm32','mips32'], | 89 choices=['x8632','x8664','arm32','mips32'], |
87 help='Target architecture. Default %(default)s') | 90 help='Target architecture. Default %(default)s') |
88 argparser.add_argument('--echo-cmd', required=False, | 91 argparser.add_argument('--echo-cmd', required=False, |
89 action='store_true', | 92 action='store_true', |
90 help='Trace command that generates ICE instructions') | 93 help='Trace command that generates ICE instructions') |
91 argparser.add_argument('--tbc', required=False, action='store_true', | 94 argparser.add_argument('--tbc', required=False, action='store_true', |
92 help='Input is textual bitcode (not .ll)') | 95 help='Input is textual bitcode (not .ll)') |
93 argparser.add_argument('--expect-fail', required=False, action='store_true', | 96 argparser.add_argument('--expect-fail', required=False, action='store_true', |
94 help='Negate success of run by using LLVM not') | 97 help='Negate success of run by using LLVM not') |
95 argparser.add_argument('--args', '-a', nargs=argparse.REMAINDER, | 98 argparser.add_argument('--args', '-a', nargs=argparse.REMAINDER, |
96 default=[], | 99 default=[], |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 [output_file_name]) | 202 [output_file_name]) |
200 | 203 |
201 stdout_result = shellcmd(cmd, echo=args.echo_cmd) | 204 stdout_result = shellcmd(cmd, echo=args.echo_cmd) |
202 if not args.echo_cmd: | 205 if not args.echo_cmd: |
203 sys.stdout.write(stdout_result) | 206 sys.stdout.write(stdout_result) |
204 if asm_temp and not keep_output_file: | 207 if asm_temp and not keep_output_file: |
205 os.remove(output_file_name) | 208 os.remove(output_file_name) |
206 | 209 |
207 if __name__ == '__main__': | 210 if __name__ == '__main__': |
208 main() | 211 main() |
OLD | NEW |