annotate python/ppci/report.py @ 345:b4882ff0ed06

Added more arm isa tests
author Windel Bouwman
date Sun, 02 Mar 2014 17:12:08 +0100
parents 86b02c98a717
children
rev   line source
331
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
1
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
2 import logging
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
3 import io
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
4
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 331
diff changeset
5 from . import outstream
331
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
6 from .c3 import AstPrinter
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
7 from . import logformat
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
8 from .irutils import Writer
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
9
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
10 class RstFormatter(logging.Formatter):
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
11 """ Formatter that tries to create an rst document """
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
12 def __init__(self):
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
13 super().__init__(fmt=logformat)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
14
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
15 def format(self, record):
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
16 s = super().format(record)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
17 s += '\n'
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
18 if hasattr(record, 'c3_ast'):
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
19 f = io.StringIO()
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
20 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
21 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
22 print('.. code::', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
23 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
24 AstPrinter().printAst(record.c3_ast, f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
25 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
26 s += '\n' + f.getvalue()
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
27 if hasattr(record, 'ircode'):
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
28 f = io.StringIO()
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
29 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
30 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
31 print('.. code::', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
32 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
33 Writer(' ').write(record.ircode, f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
34 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
35 s += '\n' + f.getvalue()
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
36 if hasattr(record, 'irfunc'):
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
37 f = io.StringIO()
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
38 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
39 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
40 print('.. code::', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
41 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
42 Writer(' ').write_function(record.irfunc, f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
43 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
44 s += '\n' + f.getvalue()
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
45 if hasattr(record, 'ppci_frame'):
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
46 f = io.StringIO()
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
47 frame = record.ppci_frame
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
48 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
49 print('.. code::', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
50 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
51 print(' {}'.format(frame.name), file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
52 for i in frame.instructions:
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
53 print(' {}'.format(i),file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
54 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
55 s += '\n' + f.getvalue()
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
56 if hasattr(record, 'ra_cfg'):
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
57 f = io.StringIO()
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
58 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
59 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
60 print('.. graphviz::', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
61 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
62 print(' digraph G {', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
63 print(' size="8,80";', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
64 cfg = record.ra_cfg
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
65 cfg.to_dot(f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
66 print(' }', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
67 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
68 s += '\n' + f.getvalue()
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
69 if hasattr(record, 'ra_ig'):
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
70 f = io.StringIO()
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
71 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
72 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
73 print('.. graphviz::', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
74 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
75 print(' digraph G {', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
76 print(' ratio="compress";', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
77 print(' size="8,80";', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
78 ig = record.ra_ig
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
79 ig.to_dot(f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
80 print(' }', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
81 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
82 s += '\n' + f.getvalue()
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
83 if hasattr(record, 'zcc_outs'):
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
84 f = io.StringIO()
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
85 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
86 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
87 print('.. code::', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
88 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
89 outstream.OutputStreamWriter(' ').dump(record.zcc_outs, f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
90 print('', file=f)
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
91 s += '\n' + f.getvalue()
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
92 return s
a78b41ff6ad2 Added better recipe files
Windel Bouwman
parents:
diff changeset
93