| 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, GetObjdumpCmd, 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' % ( | 18 'x8664': ['-triple=%s' % ( |
| 19 'x86_64-nacl' if sandboxed else 'x86_64')], | 19 'x86_64-nacl' if sandboxed else 'x86_64')], |
| 20 'arm32': ['-triple=%s' % ( | 20 'arm32': ['-triple=%s' % ( |
| 21 'armv7a-nacl' if sandboxed else 'armv7a'), | 21 'armv7a-nacl' if sandboxed else 'armv7a'), |
| 22 '-mcpu=cortex-a9', '-mattr=+neon'], | 22 '-mcpu=cortex-a9', '-mattr=+neon'], |
| 23 'mips32': ['-triple=mipsel' ] } | 23 'mips32': ['-triple=mipsel' ] } |
| 24 return flags[target] | 24 return flags[target] |
| 25 | 25 |
| 26 | 26 |
| 27 def TargetDisassemblerFlags(target): | 27 def TargetDisassemblerFlags(target): |
| 28 flags = { 'x8632': ['-Mintel'], | 28 flags = { 'x8632': ['-Mintel'], |
| 29 'x8664': ['-Mintel'], | 29 'x8664': ['-Mintel'], |
| 30 'arm32': [], | 30 'arm32': [], |
| 31 'mips32':[] } | 31 'mips32':[] } |
| 32 return flags[target] | 32 return flags[target] |
| 33 | 33 |
| 34 def GetObjdumpCmd(): | |
| 35 """Return a suitable objdump command.""" | |
| 36 return 'arm-nacl-objdump' | |
| 37 | |
| 38 def main(): | 34 def main(): |
| 39 """Run the pnacl-sz compiler on an llvm file. | 35 """Run the pnacl-sz compiler on an llvm file. |
| 40 | 36 |
| 41 Takes an llvm input file, freezes it into a pexe file, converts | 37 Takes an llvm input file, freezes it into a pexe file, converts |
| 42 it to a Subzero program, and finally compiles it. | 38 it to a Subzero program, and finally compiles it. |
| 43 """ | 39 """ |
| 44 argparser = argparse.ArgumentParser( | 40 argparser = argparse.ArgumentParser( |
| 45 description=' ' + main.__doc__, | 41 description=' ' + main.__doc__, |
| 46 formatter_class=argparse.ArgumentDefaultsHelpFormatter) | 42 formatter_class=argparse.ArgumentDefaultsHelpFormatter) |
| 47 argparser.add_argument('--input', '-i', required=True, | 43 argparser.add_argument('--input', '-i', required=True, |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 [output_file_name]) | 201 [output_file_name]) |
| 206 | 202 |
| 207 stdout_result = shellcmd(cmd, echo=args.echo_cmd) | 203 stdout_result = shellcmd(cmd, echo=args.echo_cmd) |
| 208 if not args.echo_cmd: | 204 if not args.echo_cmd: |
| 209 sys.stdout.write(stdout_result) | 205 sys.stdout.write(stdout_result) |
| 210 if asm_temp and not keep_output_file: | 206 if asm_temp and not keep_output_file: |
| 211 os.remove(output_file_name) | 207 os.remove(output_file_name) |
| 212 | 208 |
| 213 if __name__ == '__main__': | 209 if __name__ == '__main__': |
| 214 main() | 210 main() |
| OLD | NEW |