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 re | 5 import re |
6 | 6 |
7 if __name__ == '__main__': | 7 if __name__ == '__main__': |
8 """Compares a LLVM file with a subzero file for differences. | 8 """Compares a LLVM file with a subzero file for differences. |
9 | 9 |
10 Before comparing, the LLVM file is massaged to remove comments, | 10 Before comparing, the LLVM file is massaged to remove comments, |
(...skipping 24 matching lines...) Expand all Loading... | |
35 help='Subzero bitcode file [default stdin]') | 35 help='Subzero bitcode file [default stdin]') |
36 args = argparser.parse_args() | 36 args = argparser.parse_args() |
37 bitcode = args.llfile[0].readlines() | 37 bitcode = args.llfile[0].readlines() |
38 sz_out = [ line.rstrip() for line in args.szfile.readlines()] | 38 sz_out = [ line.rstrip() for line in args.szfile.readlines()] |
39 | 39 |
40 # Filter certain lines and patterns from the input, and collect | 40 # Filter certain lines and patterns from the input, and collect |
41 # the remainder into llc_out. | 41 # the remainder into llc_out. |
42 llc_out = [] | 42 llc_out = [] |
43 tail_call = re.compile(' tail call '); | 43 tail_call = re.compile(' tail call '); |
44 trailing_comment = re.compile(';.*') | 44 trailing_comment = re.compile(';.*') |
45 ignore_pattern = re.compile('^ *$|^declare|^@') | 45 #ignore_pattern = re.compile('^ *$|^declare|^@.*\]$') |
jvoung (off chromium)
2014/06/28 17:00:33
could remove the old copy now
Jim Stichnoth
2014/06/29 14:33:46
Done.
| |
46 ignore_pattern = re.compile('|'.join([ | |
47 '^ *$', # all-whitespace lines | |
48 '^declare', # declarations without definitions | |
49 '^@.*\]$' # PNaCl global declarations like: | |
50 # @v = external global [4 x i8] | |
51 ])) | |
46 prev_line = None | 52 prev_line = None |
47 for line in bitcode: | 53 for line in bitcode: |
48 if prev_line: | 54 if prev_line: |
49 line = prev_line + line | 55 line = prev_line + line |
50 prev_line = None | 56 prev_line = None |
51 # Convert tail call into regular (non-tail) call. | 57 # Convert tail call into regular (non-tail) call. |
52 line = tail_call.sub(' call ', line) | 58 line = tail_call.sub(' call ', line) |
53 # Remove trailing comments and spaces. | 59 # Remove trailing comments and spaces. |
54 line = trailing_comment.sub('', line).rstrip() | 60 line = trailing_comment.sub('', line).rstrip() |
55 # Ignore blanks lines, forward declarations, and variable definitions. | 61 # Ignore blanks lines, forward declarations, and variable definitions. |
(...skipping 28 matching lines...) Expand all Loading... | |
84 lines_diff += 1 | 90 lines_diff += 1 |
85 continue | 91 continue |
86 if sz_line: print 'SZ (%d)> %s' % (lines_total, sz_line) | 92 if sz_line: print 'SZ (%d)> %s' % (lines_total, sz_line) |
87 if llc_line: print 'LL (%d)> %s' % (lines_total, llc_line) | 93 if llc_line: print 'LL (%d)> %s' % (lines_total, llc_line) |
88 return_code = 1 | 94 return_code = 1 |
89 | 95 |
90 if return_code == 0: | 96 if return_code == 0: |
91 message = 'Success (ignored %d diffs out of %d lines)' | 97 message = 'Success (ignored %d diffs out of %d lines)' |
92 print message % (lines_diff, lines_total) | 98 print message % (lines_diff, lines_total) |
93 exit(return_code) | 99 exit(return_code) |
OLD | NEW |