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

Side by Side Diff: pydir/run-pnacl-sz.py

Issue 1136793002: Handle ARM "ret void" and function alignment with proper padding. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: note moved to cpp Created 5 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 unified diff | Download patch
« no previous file with comments | « Makefile.standalone ('k') | src/IceCfg.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
14 def TargetAssemblerFlags(target):
15 # TODO(stichnot): -triple=i686-nacl should be used for a
16 # sandboxing test. This means there should be an args.sandbox
17 # argument that also gets passed through to pnacl-sz.
18 flags = { 'x8632': ['-triple=i686'],
19 'arm32': ['-triple=armv7a', '-mcpu=cortex-a9', '-mattr=+neon'] }
20 return flags[target]
21
22
23 def TargetDisassemblerFlags(target):
24 flags = { 'x8632': ['-Mintel'],
25 'arm32': [] }
26 return flags[target]
27
28
13 def main(): 29 def main():
14 """Run the pnacl-sz compiler on an llvm file. 30 """Run the pnacl-sz compiler on an llvm file.
15 31
16 Takes an llvm input file, freezes it into a pexe file, converts 32 Takes an llvm input file, freezes it into a pexe file, converts
17 it to a Subzero program, and finally compiles it. 33 it to a Subzero program, and finally compiles it.
18 """ 34 """
19 argparser = argparse.ArgumentParser( 35 argparser = argparse.ArgumentParser(
20 description=' ' + main.__doc__, 36 description=' ' + main.__doc__,
21 formatter_class=argparse.ArgumentDefaultsHelpFormatter) 37 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
22 argparser.add_argument('--input', '-i', required=True, 38 argparser.add_argument('--input', '-i', required=True,
(...skipping 26 matching lines...) Expand all
49 help='Assemble the output') 65 help='Assemble the output')
50 argparser.add_argument('--disassemble', required=False, 66 argparser.add_argument('--disassemble', required=False,
51 action='store_true', 67 action='store_true',
52 help='Disassemble the assembled output') 68 help='Disassemble the assembled output')
53 argparser.add_argument('--dis-flags', required=False, 69 argparser.add_argument('--dis-flags', required=False,
54 action='append', default=[], 70 action='append', default=[],
55 help='Add a disassembler flag') 71 help='Add a disassembler flag')
56 argparser.add_argument('--filetype', default='iasm', dest='filetype', 72 argparser.add_argument('--filetype', default='iasm', dest='filetype',
57 choices=['obj', 'asm', 'iasm'], 73 choices=['obj', 'asm', 'iasm'],
58 help='Output file type. Default %(default)s.') 74 help='Output file type. Default %(default)s.')
75 argparser.add_argument('--target', default='x8632', dest='target',
76 choices=['x8632','arm32'],
77 help='Target architecture. Default %(default)s.')
59 argparser.add_argument('--echo-cmd', required=False, 78 argparser.add_argument('--echo-cmd', required=False,
60 action='store_true', 79 action='store_true',
61 help='Trace command that generates ICE instructions') 80 help='Trace command that generates ICE instructions')
62 argparser.add_argument('--args', '-a', nargs=argparse.REMAINDER, 81 argparser.add_argument('--args', '-a', nargs=argparse.REMAINDER,
63 default=[], 82 default=[],
64 help='Remaining arguments are passed to pnacl-sz') 83 help='Remaining arguments are passed to pnacl-sz')
65 84
66 args = argparser.parse_args() 85 args = argparser.parse_args()
67 pnacl_bin_path = args.pnacl_bin_path 86 pnacl_bin_path = args.pnacl_bin_path
68 llfile = args.input 87 llfile = args.input
69 88
70 if args.llvm and args.llvm_source: 89 if args.llvm and args.llvm_source:
71 raise RuntimeError("Can't specify both '--llvm' and '--llvm-source'") 90 raise RuntimeError("Can't specify both '--llvm' and '--llvm-source'")
72 91
73 if args.llvm_source and args.no_local_syms: 92 if args.llvm_source and args.no_local_syms:
74 raise RuntimeError("Can't specify both '--llvm-source' and " + 93 raise RuntimeError("Can't specify both '--llvm-source' and " +
75 "'--no-local-syms'") 94 "'--no-local-syms'")
76 95
77 cmd = [] 96 cmd = []
78 if not args.llvm_source: 97 if not args.llvm_source:
79 cmd = [os.path.join(pnacl_bin_path, 'llvm-as'), llfile, '-o', '-', '|', 98 cmd = [os.path.join(pnacl_bin_path, 'llvm-as'), llfile, '-o', '-', '|',
80 os.path.join(pnacl_bin_path, 'pnacl-freeze')] 99 os.path.join(pnacl_bin_path, 'pnacl-freeze')]
81 if not args.no_local_syms: 100 if not args.no_local_syms:
82 cmd += ['--allow-local-symbol-tables'] 101 cmd += ['--allow-local-symbol-tables']
83 cmd += ['|'] 102 cmd += ['|']
84 cmd += [args.pnacl_sz] 103 cmd += [args.pnacl_sz]
104 cmd += ['--target', args.target]
85 if args.insts: 105 if args.insts:
86 # If the tests are based on '-verbose inst' output, force 106 # If the tests are based on '-verbose inst' output, force
87 # single-threaded translation because dump output does not get 107 # single-threaded translation because dump output does not get
88 # reassembled into order. 108 # reassembled into order.
89 cmd += ['-verbose', 'inst', '-notranslate', '-threads=0'] 109 cmd += ['-verbose', 'inst', '-notranslate', '-threads=0']
90 if not args.llvm_source: 110 if not args.llvm_source:
91 cmd += ['--bitcode-format=pnacl'] 111 cmd += ['--bitcode-format=pnacl']
92 if not args.no_local_syms: 112 if not args.no_local_syms:
93 cmd += ['--allow-local-symbol-tables'] 113 cmd += ['--allow-local-symbol-tables']
94 if args.llvm or args.llvm_source: 114 if args.llvm or args.llvm_source:
95 cmd += ['--build-on-read=0'] 115 cmd += ['--build-on-read=0']
96 else: 116 else:
97 cmd += ['--build-on-read=1'] 117 cmd += ['--build-on-read=1']
98 cmd += ['--filetype=' + args.filetype] 118 cmd += ['--filetype=' + args.filetype]
99 cmd += args.args 119 cmd += args.args
100 if args.llvm_source: 120 if args.llvm_source:
101 cmd += [llfile] 121 cmd += [llfile]
102 asm_temp = None 122 asm_temp = None
103 if args.assemble or args.disassemble: 123 if args.assemble or args.disassemble:
104 # On windows we may need to close the file first before it can be 124 # On windows we may need to close the file first before it can be
105 # re-opened by the other tools, so don't do delete-on-close, 125 # re-opened by the other tools, so don't do delete-on-close,
106 # and instead manually delete. 126 # and instead manually delete.
107 asm_temp = tempfile.NamedTemporaryFile(delete=False) 127 asm_temp = tempfile.NamedTemporaryFile(delete=False)
108 asm_temp.close() 128 asm_temp.close()
109 if args.assemble and args.filetype != 'obj': 129 if args.assemble and args.filetype != 'obj':
110 cmd += ['|', os.path.join(pnacl_bin_path, 'llvm-mc'), 130 cmd += (['|', os.path.join(pnacl_bin_path, 'llvm-mc')] +
111 # TODO(stichnot): -triple=i686-nacl should be used for a 131 TargetAssemblerFlags(args.target) +
112 # sandboxing test. This means there should be an args.sandbox 132 ['-filetype=obj', '-o', asm_temp.name])
113 # argument that also gets passed through to pnacl-sz.
114 '-triple=i686',
115 '-filetype=obj', '-o', asm_temp.name]
116 elif asm_temp: 133 elif asm_temp:
117 cmd += ['-o', asm_temp.name] 134 cmd += ['-o', asm_temp.name]
118 if args.disassemble: 135 if args.disassemble:
119 # Show wide instruction encodings, diassemble, and show relocs. 136 # Show wide instruction encodings, diassemble, and show relocs.
120 cmd += (['&&', os.path.join(pnacl_bin_path, 'le32-nacl-objdump')] + 137 cmd += (['&&', os.path.join(pnacl_bin_path, 'le32-nacl-objdump')] +
121 args.dis_flags + 138 args.dis_flags +
122 ['-w', '-d', '-r', '-Mintel', asm_temp.name]) 139 ['-w', '-d', '-r'] + TargetDisassemblerFlags(args.target) +
140 [asm_temp.name])
123 141
124 stdout_result = shellcmd(cmd, echo=args.echo_cmd) 142 stdout_result = shellcmd(cmd, echo=args.echo_cmd)
125 if not args.echo_cmd: 143 if not args.echo_cmd:
126 sys.stdout.write(stdout_result) 144 sys.stdout.write(stdout_result)
127 if asm_temp: 145 if asm_temp:
128 os.remove(asm_temp.name) 146 os.remove(asm_temp.name)
129 147
130 if __name__ == '__main__': 148 if __name__ == '__main__':
131 main() 149 main()
OLDNEW
« no previous file with comments | « Makefile.standalone ('k') | src/IceCfg.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698