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 shellcmd | 11 from utils import shellcmd |
12 | 12 |
13 | 13 |
14 def TargetAssemblerFlags(target): | 14 def TargetAssemblerFlags(target): |
15 # TODO(stichnot): -triple=i686-nacl should be used for a | 15 # TODO(stichnot): -triple=i686-nacl should be used for a |
16 # sandboxing test. This means there should be an args.sandbox | 16 # sandboxing test. This means there should be an args.sandbox |
17 # argument that also gets passed through to pnacl-sz. | 17 # argument that also gets passed through to pnacl-sz. |
| 18 # TODO(reed kotler). Need to find out exactly we need to |
| 19 # add here for Mips32. |
18 flags = { 'x8632': ['-triple=i686'], | 20 flags = { 'x8632': ['-triple=i686'], |
19 'arm32': ['-triple=armv7a', '-mcpu=cortex-a9', '-mattr=+neon'] } | 21 'arm32': ['-triple=armv7a', '-mcpu=cortex-a9', '-mattr=+neon'], |
| 22 'mips32': ['-triple=mipsel-none-nacl' ] } |
20 return flags[target] | 23 return flags[target] |
21 | 24 |
22 | 25 |
23 def TargetDisassemblerFlags(target): | 26 def TargetDisassemblerFlags(target): |
24 flags = { 'x8632': ['-Mintel'], | 27 flags = { 'x8632': ['-Mintel'], |
25 'arm32': [] } | 28 'arm32': [], |
| 29 'mips32':[] } |
26 return flags[target] | 30 return flags[target] |
27 | 31 |
28 | 32 |
29 def main(): | 33 def main(): |
30 """Run the pnacl-sz compiler on an llvm file. | 34 """Run the pnacl-sz compiler on an llvm file. |
31 | 35 |
32 Takes an llvm input file, freezes it into a pexe file, converts | 36 Takes an llvm input file, freezes it into a pexe file, converts |
33 it to a Subzero program, and finally compiles it. | 37 it to a Subzero program, and finally compiles it. |
34 """ | 38 """ |
35 argparser = argparse.ArgumentParser( | 39 argparser = argparse.ArgumentParser( |
(...skipping 30 matching lines...) Expand all Loading... |
66 argparser.add_argument('--disassemble', required=False, | 70 argparser.add_argument('--disassemble', required=False, |
67 action='store_true', | 71 action='store_true', |
68 help='Disassemble the assembled output') | 72 help='Disassemble the assembled output') |
69 argparser.add_argument('--dis-flags', required=False, | 73 argparser.add_argument('--dis-flags', required=False, |
70 action='append', default=[], | 74 action='append', default=[], |
71 help='Add a disassembler flag') | 75 help='Add a disassembler flag') |
72 argparser.add_argument('--filetype', default='iasm', dest='filetype', | 76 argparser.add_argument('--filetype', default='iasm', dest='filetype', |
73 choices=['obj', 'asm', 'iasm'], | 77 choices=['obj', 'asm', 'iasm'], |
74 help='Output file type. Default %(default)s.') | 78 help='Output file type. Default %(default)s.') |
75 argparser.add_argument('--target', default='x8632', dest='target', | 79 argparser.add_argument('--target', default='x8632', dest='target', |
76 choices=['x8632','arm32'], | 80 choices=['x8632','arm32','mips32'], |
77 help='Target architecture. Default %(default)s.') | 81 help='Target architecture. Default %(default)s.') |
78 argparser.add_argument('--echo-cmd', required=False, | 82 argparser.add_argument('--echo-cmd', required=False, |
79 action='store_true', | 83 action='store_true', |
80 help='Trace command that generates ICE instructions') | 84 help='Trace command that generates ICE instructions') |
81 argparser.add_argument('--tbc', required=False, action='store_true', | 85 argparser.add_argument('--tbc', required=False, action='store_true', |
82 help='Input is textual bitcode (not .ll)') | 86 help='Input is textual bitcode (not .ll)') |
83 argparser.add_argument('--expect-fail', required=False, action='store_true', | 87 argparser.add_argument('--expect-fail', required=False, action='store_true', |
84 help='Negate success of run by using LLVM not') | 88 help='Negate success of run by using LLVM not') |
85 argparser.add_argument('--args', '-a', nargs=argparse.REMAINDER, | 89 argparser.add_argument('--args', '-a', nargs=argparse.REMAINDER, |
86 default=[], | 90 default=[], |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 [asm_temp.name]) | 159 [asm_temp.name]) |
156 | 160 |
157 stdout_result = shellcmd(cmd, echo=args.echo_cmd) | 161 stdout_result = shellcmd(cmd, echo=args.echo_cmd) |
158 if not args.echo_cmd: | 162 if not args.echo_cmd: |
159 sys.stdout.write(stdout_result) | 163 sys.stdout.write(stdout_result) |
160 if asm_temp: | 164 if asm_temp: |
161 os.remove(asm_temp.name) | 165 os.remove(asm_temp.name) |
162 | 166 |
163 if __name__ == '__main__': | 167 if __name__ == '__main__': |
164 main() | 168 main() |
OLD | NEW |