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

Side by Side Diff: szdiff.py

Issue 205613002: Initial skeleton of Subzero. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 9 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
(Empty)
1 #!/usr/bin/env python2
2
3 # Runs llvm2ice on an input .ll file, and compares the output against
4 # the input.
5 #
6 # Before comparing, the input file is massaged to remove comments,
7 # blank lines, global variable definitions, external function
8 # declarations, and possibly other patterns that llvm2ice does not
9 # handle.
10 #
11 # The output file and the massaged input file are compared line by
12 # line for differences. However, there is a regex defined such that
13 # if the regex matches a line in the input file, that line and the
14 # corresponding line in the output file are ignored. This lets us
15 # ignore minor differences such as inttoptr and ptrtoint, and printing
16 # of floating-point constants.
17 #
18 # On success, no output is produced. On failure, each mismatch is
19 # printed as two lines, one starting with "SZ" and one starting with
20 # "LL".
21
22 import argparse
23 import subprocess
24 import re
25
26 if __name__ == '__main__':
27 argparser = argparse.ArgumentParser()
28 argparser.add_argument('llfile')
29 argparser.add_argument('--llvm2ice')
30 args = argparser.parse_args()
31
32 infile = args.llfile
33 llvm2ice = args.llvm2ice if args.llvm2ice else './llvm2ice'
34 command = [llvm2ice, '-verbose', 'inst', '-notranslate', infile]
35 p = subprocess.Popen(command, stdout=subprocess.PIPE)
36 sz_out, stderr = p.communicate()
37 sed_command = ['sed', '-e', 's/;.*//', '-e', 's/ *$//', infile]
38 grep1_command = ['grep', '-v', '^ *$']
39 grep2_command = ['grep', '-v', '^declare']
40 grep3_command = ['grep', '-v', '^@']
41 sed = subprocess.Popen(sed_command, stdout=subprocess.PIPE)
42 grep1 = subprocess.Popen(grep1_command, stdin=sed.stdout,
43 stdout=subprocess.PIPE)
44 grep2 = subprocess.Popen(grep2_command, stdin=grep1.stdout,
45 stdout=subprocess.PIPE)
46 grep3 = subprocess.Popen(grep3_command, stdin=grep2.stdout,
47 stdout=subprocess.PIPE)
48 llc_out = grep3.communicate()[0]
49 match = re.compile('|'.join([' -[0-9]+', # negative constants
50 'float [-0-9]', # FP constants
51 'inttoptr', # inttoptr pointer types
52 'ptrtoint' # ptrtoint pointer types
53 ]))
54 return_code = 0
55 for (sz_line, llc_line) in zip(sz_out.splitlines(), llc_out.splitlines()):
56 if not match.search(llc_line) and sz_line != llc_line:
57 print 'SZ>' + sz_line
58 print 'LL>' + llc_line
59 return_code = 1
60 if return_code == 0: print 'Success'
61 exit(return_code)
OLDNEW
« IceCfg.h ('K') | « llvm2ice.cpp ('k') | tests_lit/.gitignore » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698