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

Side by Side Diff: pydir/run-llvm2ice.py

Issue 914263005: Subzero: switch from llvm-objdump to objdump for lit tests (for LLVM merge) (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: backup... 9 to go Created 5 years, 10 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
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 10
10 from utils import shellcmd 11 from utils import shellcmd
11 12
12 def main(): 13 def main():
13 """Run the llvm2ice compiler on an llvm file. 14 """Run the llvm2ice compiler on an llvm file.
14 15
15 Takes an llvm input file, freezes it into a pexe file, converts 16 Takes an llvm input file, freezes it into a pexe file, converts
16 it to a Subzero program, and finally compiles it. 17 it to a Subzero program, and finally compiles it.
17 """ 18 """
18 argparser = argparse.ArgumentParser( 19 argparser = argparse.ArgumentParser(
(...skipping 17 matching lines...) Expand all
36 help='Parse source directly into llvm IR ' + 37 help='Parse source directly into llvm IR ' +
37 '(without generating a pexe), then ' + 38 '(without generating a pexe), then ' +
38 'convert to Subzero') 39 'convert to Subzero')
39 argparser.add_argument( 40 argparser.add_argument(
40 '--llvm2ice', required=False, default='./llvm2ice', metavar='LLVM2ICE', 41 '--llvm2ice', required=False, default='./llvm2ice', metavar='LLVM2ICE',
41 help="Subzero translator 'llvm2ice'") 42 help="Subzero translator 'llvm2ice'")
42 argparser.add_argument('--llvm-bin-path', required=False, 43 argparser.add_argument('--llvm-bin-path', required=False,
43 default=None, metavar='LLVM_BIN_PATH', 44 default=None, metavar='LLVM_BIN_PATH',
44 help='Path to LLVM executables ' + 45 help='Path to LLVM executables ' +
45 '(for building PEXE files)') 46 '(for building PEXE files)')
47 argparser.add_argument('--binutils-bin-path', required=False,
48 default=None, metavar='BINUTILS_BIN_PATH',
49 help='Path to Binutils executables')
50 argparser.add_argument('--assemble', required=False,
51 action='store_true',
52 help='Assemble the output')
53 argparser.add_argument('--disassemble', required=False,
54 action='store_true',
55 help='Disassemble the assembled output')
46 argparser.add_argument('--echo-cmd', required=False, 56 argparser.add_argument('--echo-cmd', required=False,
47 action='store_true', 57 action='store_true',
48 help='Trace command that generates ICE instructions') 58 help='Trace command that generates ICE instructions')
49 argparser.add_argument('--args', '-a', nargs=argparse.REMAINDER, 59 argparser.add_argument('--args', '-a', nargs=argparse.REMAINDER,
50 default=[], 60 default=[],
51 help='Remaining arguments are passed to llvm2ice') 61 help='Remaining arguments are passed to llvm2ice')
52 62
53 args = argparser.parse_args() 63 args = argparser.parse_args()
54 llvm_bin_path = args.llvm_bin_path 64 llvm_bin_path = args.llvm_bin_path
65 binutils_bin_path = args.binutils_bin_path
55 llfile = args.input 66 llfile = args.input
56 67
57 if args.llvm and args.llvm_source: 68 if args.llvm and args.llvm_source:
58 raise RuntimeError("Can't specify both '--llvm' and '--llvm-source'") 69 raise RuntimeError("Can't specify both '--llvm' and '--llvm-source'")
59 70
60 if args.llvm_source and args.no_local_syms: 71 if args.llvm_source and args.no_local_syms:
61 raise RuntimeError("Can't specify both '--llvm-source' and " + 72 raise RuntimeError("Can't specify both '--llvm-source' and " +
62 "'--no-local-syms'") 73 "'--no-local-syms'")
63 74
64 cmd = [] 75 cmd = []
(...skipping 13 matching lines...) Expand all
78 cmd += ['--bitcode-format=pnacl'] 89 cmd += ['--bitcode-format=pnacl']
79 if not args.no_local_syms: 90 if not args.no_local_syms:
80 cmd += ['--allow-local-symbol-tables'] 91 cmd += ['--allow-local-symbol-tables']
81 if args.llvm or args.llvm_source: 92 if args.llvm or args.llvm_source:
82 cmd += ['--build-on-read=0'] 93 cmd += ['--build-on-read=0']
83 else: 94 else:
84 cmd += ['--build-on-read=1'] 95 cmd += ['--build-on-read=1']
85 cmd += args.args 96 cmd += args.args
86 if args.llvm_source: 97 if args.llvm_source:
87 cmd += [llfile] 98 cmd += [llfile]
99 asm_temp = None
100 if args.assemble or args.disassemble:
101 # On windows we may need to close the file first before it can be
102 # re-opened by the other tools, so don't do delete-on-close,
103 # and instead manually delete.
104 asm_temp = tempfile.NamedTemporaryFile(delete=False)
105 asm_temp.close()
106 if args.assemble:
107 cmd += ['|', os.path.join(llvm_bin_path, 'llvm-mc'),
108 '-triple=i686-none-nacl',
109 '-filetype=obj', '-o', asm_temp.name]
110 if args.disassemble:
111 # Show wide instruction encodings, diassemble, and show relocs.
112 cmd += ['&&', os.path.join(binutils_bin_path, 'le32-nacl-objdump'),
113 '-w', '-d', '-r', '-Mintel', asm_temp.name]
88 114
89 stdout_result = shellcmd(cmd, echo=args.echo_cmd) 115 stdout_result = shellcmd(cmd, echo=args.echo_cmd)
90 if not args.echo_cmd: 116 if not args.echo_cmd:
91 sys.stdout.write(stdout_result) 117 sys.stdout.write(stdout_result)
118 if asm_temp:
119 os.remove(asm_temp.name)
92 120
93 if __name__ == '__main__': 121 if __name__ == '__main__':
94 main() 122 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698