Mercurial > hg > Members > anatofuz > MoarVM
annotate tools/graph_spesh.p6 @ 42:dc42e7eb1adf
delte '-fno-optimize-sibling-calls' optin to use use clang in compilation
author | Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 29 Nov 2018 19:43:32 +0900 |
parents | 2cf249471370 |
children |
rev | line source |
---|---|
0
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 #!/usr/bin/env perl6 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 =begin pod |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 The Speshlog Excerpt Grapher |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 This little script will eat a piece of speshlog (it expects to be fed an |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 excerpt that contains only a single Frame with all its BBs, but it'll get |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 only slightly confused if BBs are missing) and outputs Graphviz' C<DOT> |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 Language to stdout. |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 Ideally, you'd use C<dot> to generate an image file from the result or have |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 it display the result "interactively" in a window: |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 =code |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 perl6 graph_spesh.p6 a_nice_excerpt.txt | dot -Tsvg > helpful_graph.svg |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 perl6 graph_spesh.p6 a_nice_excerpt.txt | dot -Tpng > huge_image.png |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 perl6 graph_spesh.p6 a_nice_excerpt.txt | dot -Tx11 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 The -T flag for dot selects the output format. Using K<-Tx11> will open a |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 window in which you can pan and zoom around in. |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 If you get an error that MAST::Ops could not be found, please run |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 C<tools/update_ops.p6> to generate that module. |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 =end pod |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
28 use lib ~$?FILE.path.parent.child("lib"); |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 use MAST::Ops; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32 my $current_bb; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
34 my %lit_real_serial; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
35 my %lit_str_serial; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
36 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 say 'digraph G {'; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 say ' graph [rankdir="TB"];'; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 say ' node [shape=record,style=filled,fillcolor=white];'; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
41 say " \"Control Flow Graph\";"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 say " \"Dominance Tree\";"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
44 my $insnum = 0; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
45 my $in_subgraph = 0; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
46 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
47 my $ann_num = 0; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
48 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
49 # if instruction-carrying lines appear before the first BB, we |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 # shall gracefully invent a starting point. |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
51 my $last_ins = "\"out of nowhere\""; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
52 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
53 my %bb_map; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
54 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
55 my @connections; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
56 my %bb_connections; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
57 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
58 my @dominance_conns; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
59 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
60 my @callsite_args; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
61 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
62 my %reg_writers; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
63 my @delayed_writer_connections; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
64 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
65 my @bb_overview; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
66 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
67 constant @bb_colors = ((((1 .. *) X* 0.618033988749895) X% 1.0) .map(*.fmt("%.5f ")) |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
68 Z~ (((0, -1 ... *) X* 0.0618033988749895) X% 0.05 + 0.95) .map(*.fmt("%.5f "))) |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
69 X~ "0.9900"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
70 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
71 for lines() -> $_ is copy { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
72 when / ^ ' ' <!before '['> $<opname>=[<[a..z I 0..9 _]>+] \s+ |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
73 [ $<argument>=[ |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
74 | r \s* $<regnum>=[<.digit>+] \s* '(' \s* $<regver>=[<.digit>+] \s* ')' |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
75 | liti <.digit>+ '(' ~ ')' <-[)]>+ |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
76 | litn <.digit>+ '(' ~ ')' <-[)]>+ |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
77 | lits '(' .*? ')' |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
78 | lex '(' .*? ')' |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
79 | sslot '(' <digit>+ ')' |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
80 | BB '(' <digit>+ ')' |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
81 | coderef '(' ~ ')' <-[)]>+ |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
82 | callsite '(' ~ ')' <-[)]>+ |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
83 | '<nyi>' |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
84 | '<nyi(lit)>' |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
85 ] ]* % [',' \s*] [\s* '(' <-[)]>+ ')']? \s* $ / { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
86 say ""; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
87 say " \"{$<opname>}_{$insnum}\" "; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
88 print " ["; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
89 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
90 if $<opname> eq "set" | "decont" { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
91 print "shape=Mrecord "; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
92 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
93 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
94 my $previous_ins = $last_ins; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
95 my $current_ins = "\"{$<opname>}_{$insnum}\""; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
96 $last_ins = $current_ins ~ ":op"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
97 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
98 my @back_connections; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
99 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
100 my @labelparts = qq[ <op> $<opname> ]; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
101 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
102 #note "---------------"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
103 #note @<argument>.gist; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
104 #note "---------------"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
105 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
106 my @props; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
107 my $opcode; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
108 my $arity; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
109 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
110 if %MAST::Ops::codes{$<opname>}:exists { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
111 $opcode = %MAST::Ops::codes{$<opname>}; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
112 $arity = @MAST::Ops::counts[$opcode]; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
113 my $offset = @MAST::Ops::offsets[$opcode]; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
114 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
115 @props = do for ^$arity { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
116 $%( |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
117 flags => (my $flags = @MAST::Ops::values[$offset + $_]), |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
118 rwmasked => (my $rwmasked = $flags +& %MAST::Ops::flags<MVM_operand_rw_mask>), |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
119 type => ($flags +& %MAST::Ops::flags<MVM_operand_type_mask>), |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
120 is_sslot => ($flags +& %MAST::Ops::flags<MVM_operand_spesh_slot>), |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
121 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
122 targets_reg => ($rwmasked +& (%MAST::Ops::flags<MVM_operand_write_reg> |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
123 +| %MAST::Ops::flags<MVM_operand_read_reg>)), |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
124 writes_tgt => ($rwmasked +& (%MAST::Ops::flags<MVM_operand_write_reg> |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
125 +| %MAST::Ops::flags<MVM_operand_write_lex>)), |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
126 ) |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
127 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
128 } else { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
129 # we have an extop here. assume it writes to its first register and |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
130 # has exactly as many arguments as it says in the spesh log. |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
131 $arity = @<argument>.elems; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
132 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
133 @props = $%( |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
134 flags => 0, |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
135 rwmasked => (my $type = %MAST::Ops::flags<MVM_operand_write_reg>), |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
136 type => $type, |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
137 targets_reg => 1, |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
138 writes_tgt => 1 ), |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
139 slip do for 1..^$arity { $%( |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
140 flags => 0, |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
141 rwmasked => (my $boringtype = %MAST::Ops::flags<MVM_operand_read_reg>), |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
142 type => $boringtype, |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
143 targets_reg => @<argument>[$_].match(/r<digit>+'('<digit>+')'/) ?? 1 !! 0, |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
144 writes_tgt => 0 ) }; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
145 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
146 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
147 my @argument_names = @<argument>>>.Str>>.trans( "<" => "«", ">" => "»" ); |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
148 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
149 if $arity && @props[0]<writes_tgt> { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
150 if @props[0]<targets_reg> { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
151 %reg_writers{@argument_names[0]} = $current_ins ~ ":0"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
152 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
153 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
154 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
155 my $first_read = @props[0]<writes_tgt> ?? 1 !! 0; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
156 for @argument_names.kv -> $k, $v { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
157 if $k >= $first_read and @props[$k]<targets_reg> { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
158 if %reg_writers{$v}:exists { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
159 @back_connections.push: %reg_writers{$v} => $current_ins ~ ":$k"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
160 } else { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
161 @delayed_writer_connections.push: $v => $current_ins ~ ":$k"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
162 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
163 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
164 @labelparts.push: "<$k> $v"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
165 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
166 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
167 if $arity && @props[0]<writes_tgt> { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
168 @labelparts = flat @labelparts[1, 0], @labelparts[2..*]; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
169 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
170 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
171 # find outgoing connections |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
172 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
173 for @argument_names.kv -> $k, $_ { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
174 if m/ BB '(' $<target>=[<digit>+] ')' / -> $/ { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
175 @connections.push: $%( |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
176 source_block => $current_bb, |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
177 target_block => $<target>, |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
178 source_ins => $current_ins ~ ":<$k>" |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
179 ); |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
180 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
181 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
182 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
183 print " label=\"{ @labelparts.join(" | ") }\" rank=$insnum"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
184 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
185 $insnum++; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
186 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
187 say " ];"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
188 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
189 say ""; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
190 if $previous_ins ~~ / entry / { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
191 say " $previous_ins -> $last_ins [style=dotted];"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
192 } else { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
193 say " $previous_ins -> $last_ins [color=\"#999999\"];"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
194 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
195 say ""; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
196 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
197 for @back_connections { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
198 say " $_.key() -> $_.value();"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
199 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
200 say ""; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
201 say ""; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
202 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
203 when / ^ ' BB ' $<bbnum>=[<.digit>+] ' (' ~ ')' $<addr>=<[0..9 a..f x]>+ ':' $ / { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
204 %bb_map{~$<bbnum>} = ~$<addr>; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
205 %bb_map{~$<addr>} = ~$<bbnum>; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
206 if $in_subgraph { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
207 say " \"exit_$current_bb\";"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
208 say " $last_ins -> \"exit_$current_bb\" [style=dotted];"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
209 say " }" if $in_subgraph; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
210 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
211 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
212 say " subgraph "; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
213 say "\"cluster_{~$<addr>}\" \{"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
214 say " style=filled;"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
215 say " color=\"@bb_colors[+$<bbnum>]\";"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
216 say " rankdir = TB;"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
217 #say " label = \"$<bbnum>\";"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
218 say " \"entry_$<addr>\" [label=\"<op> entry of block $<bbnum>\"];"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
219 $in_subgraph = True; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
220 $current_bb = ~$<addr>; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
221 $last_ins = "\"entry_$<addr>\""; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
222 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
223 @bb_overview.push: " \"bb_ov_$<addr>\" [fillcolor=\"@bb_colors[+$<bbnum>]\",color=black,style=filled,label=\"$<bbnum>\"];"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
224 @bb_overview.push: " \"bb_ov_d_$<addr>\" [fillcolor=\"@bb_colors[+$<bbnum>]\",color=black,style=filled,label=\"$<bbnum>\"];"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
225 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
226 when / ^ ' ' 'Successors: ' [$<succ>=[<.digit>+]]* % ', ' $ / { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
227 %bb_connections{$current_bb} = @<succ>>>.Str; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
228 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
229 when / ^ ' ' '[Annotation: ' $<annotation>=[<[a..z A..Z 0..9 \ ]>+] $<rest>=<-[\]]>+ / { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
230 my $previous_ins = $last_ins; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
231 $last_ins = "\"annotation_{$current_bb}_{$<annotation>}_{$ann_num++}\""; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
232 say " $last_ins [label=\"{$<annotation>} {$<rest>}\" shape=cds];"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
233 if $last_ins ~~ / entry / { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
234 say " $previous_ins -> $last_ins [style=dotted];"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
235 } else { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
236 say " $previous_ins -> $last_ins [color=lightgrey];"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
237 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
238 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
239 when / ^ 'Finished specialization of ' / { } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
240 when / ^ ' ' \s* r $<regnum>=[<.digit>+] '(' $<regver>=[<.digit>+] ')' ':' / { } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
241 when / ^ ' ' 'Dominance children: ' [$<child>=[<.digit>+]]* % [',' <.ws>] / { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
242 for $<child>.list -> $child { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
243 @dominance_conns.push($current_bb => $child.Int); |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
244 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
245 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
246 when / ^ ' ' [ 'Instructions' | 'Predecessors' ] / { } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
247 when /^ [ 'Facts' | '='+ ] / { } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
248 when /^ 'Spesh of \'' $<methname>=[<[a..z 0..9 _ ' -]>*] |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
249 '\' (cuid: ' $<cuid>=[<[a..z A..Z 0..9 _ . -]>+] |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
250 ', file: ' $<filename>=[<-[:]>*] ':' $<lineno>=[<digit>+] ')' $ / { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
251 say " file [shape=record label=\"\{ {$<methname>} | {$<filename>}:{$<lineno>} | {$<cuid>} \}\"];"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
252 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
253 when / ^ \s* $ / { } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
254 when /^ 'Callsite ' $<uniqid>=[<[a..f A..F 0..9 x]>+] ' (' $<argc>=[<digit>+] ' args, ' $<posc>=[<digit>+] ' pos)' $/ { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
255 say " callsite [shape=record label=\"\{ Callsite | {$<argc>} arguments, {$<posc>} of them positionals | {$<uniqid>} \}\"];"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
256 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
257 when / ^ ' - ' $<argument_name>=[<[a..z A..B 0..9 _ ' -]>+] $ / { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
258 @callsite_args.push: ~$<argument_name>; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
259 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
260 when / ^ ' PHI' / { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
261 # we don't have a nice way to show PHI nodes yet, sadly. |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
262 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
263 when / ^ ['Stats:' | 'Logged values:'] / { } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
264 when / ^ ' ' \d+ [ 'spesh slots' | 'log values'] / { } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
265 when / ^ ' ' \s* [\d+]+ %% \s+ / { } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
266 default { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
267 say " unparsed_line_$((state $)++) [label=\"{$_}\"];"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
268 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
269 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
270 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
271 say " }" if $in_subgraph; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
272 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
273 if @callsite_args { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
274 say @callsite_args.map({ "\"arg_$((state $)++)\" [label=\"$_\"]" }).join(';'); |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
275 say "callsite -> " ~ (^@callsite_args).map({"\"arg_$_\""}).join(" -> ") ~ ";"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
276 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
277 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
278 for @connections { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
279 say "$_.<source_ins> -> \"entry_{ %bb_map{.<target_block>} }\" [style=dotted];"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
280 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
281 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
282 for @dominance_conns { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
283 say "\"exit_$_.key()\" -> \"entry_%bb_map{$_.value}\" [style=tapered;penwidth=10;arrowhead=none;color=grey];"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
284 say "\"bb_ov_d_$_.key()\" -> \"bb_ov_d_%bb_map{$_.value}\" [style=tapered;penwidth=10;arrowhead=none;color=grey];"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
285 once say "\"Dominance Tree\" -> \"bb_ov_d_$_.key()\";"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
286 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
287 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
288 for @delayed_writer_connections -> $conn { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
289 my $from = $conn.key; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
290 my $to = $conn.value; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
291 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
292 if %reg_writers{$from}:exists { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
293 say " %reg_writers{$from} -> $to;"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
294 note "found a connection for $from even after reading the whole file ..."; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
295 } else { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
296 note "Couldn't find a writer for $from anywhere! (harmless error)"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
297 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
298 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
299 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
300 for %bb_connections.kv -> $k, $v { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
301 # bb 0 is special and has successors that it won't jump to. |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
302 #note "marking successors for block $k"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
303 #note $v.perl; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
304 #note ""; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
305 next unless @$v; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
306 my @candidates = do %bb_map{$k} == "0" |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
307 ?? %bb_map{@$v} |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
308 !! %bb_map{$v[*-1]}; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
309 for @candidates -> $cand { |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
310 say " \"exit_$k\" -> \"entry_$cand\" [style=dotted];"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
311 say " \"bb_ov_$k\" -> \"bb_ov_$cand\";"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
312 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
313 once say "\"Control Flow Graph\" -> \"bb_ov_$k\";"; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
314 } |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
315 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
316 .say for @bb_overview; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
317 |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
318 say '}'; |
2cf249471370
convert mercurial for git
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
319 |