Werner's Miscellanea
Sign in or create your account | Project List | Help
Werner's Miscellanea Git Source Tree
Root/
Source at commit a6136bd02799bcab8d2e48fd21dc91f0fee0df41 created 12 years 5 months ago. By Werner Almesberger, m1rc3/norruption/2/dumplock: use correct offset; fixed block number counting | |
---|---|
1 | #!/usr/bin/perl |
2 | |
3 | |
4 | sub flush |
5 | { |
6 | if ($nregs) { |
7 | print 0+keys %reg, "/", (sort { $b cmp $a } keys %reg)[0], |
8 | "\n"; |
9 | return; |
10 | } |
11 | for (sort keys %use) { |
12 | print "$_ = ".$reg{$_}."\n"; |
13 | } |
14 | print $res; |
15 | } |
16 | |
17 | |
18 | if ($ARGV[0] eq "-r") { |
19 | shift @ARGV; |
20 | $nregs = 1; |
21 | } |
22 | |
23 | |
24 | while (<>) { |
25 | if (/FPVM fragment:/) { |
26 | &flush if $i; |
27 | undef %tmp; |
28 | undef $i; |
29 | } |
30 | if (/PFPU fragment:/) { |
31 | undef $res; |
32 | undef %reg; |
33 | undef @val; |
34 | %use = %tmp; |
35 | $i = 0; |
36 | } |
37 | |
38 | $tmp{"R$1"} = 1 if /^\d+:.*-> R0(\d+)/; |
39 | next unless defined $i; |
40 | |
41 | next unless |
42 | /^(\d+):\s+(\S+)\s+(R\d+)?(,(R\d+))?.*?(->\s+(R\d+))?\s*$/; |
43 | # 1 2 3 4 5 6 7 |
44 | ($c, $op, $a, $b, $d) = ($1, $2, $3, $5, $7); |
45 | undef $e; |
46 | $e = $1 if /E=(\d+)>/; |
47 | die "($i) $_" if $c != $i; |
48 | |
49 | $reg{$a} = 1 if $nregs && defined $a; |
50 | $reg{$b} = 1 if $nregs && defined $b; |
51 | |
52 | print STDERR "$i: concurrent read/write on $a (A)\n" |
53 | if defined $d && $a eq $d; |
54 | print STDERR "$i: concurrent read/write on $b (B)\n" |
55 | if defined $d && $b eq $d; |
56 | |
57 | $a = $reg{$a} if defined $reg{$a}; |
58 | $b = $reg{$b} if defined $reg{$b}; |
59 | |
60 | if ($op eq "IF<R2>") { |
61 | $expr = "(IF ".$reg{"R002"}." $a $b)"; |
62 | $reg{"R002"} = 1 if $nregs; |
63 | } elsif ($op eq "VECTOUT") { |
64 | $res = "A = $a\nB = $b\n"; |
65 | } elsif (defined $b) { |
66 | $expr = "($op $a $b)"; |
67 | } elsif (defined $a) { |
68 | $expr = "($op $a)"; |
69 | } else { |
70 | $expr = "($op)"; |
71 | } |
72 | |
73 | $val[$e] = $expr if defined $e; |
74 | $reg{$d} = $val[$i] if defined $d; |
75 | $i++; |
76 | } |
77 | &flush; |
78 |
Branches:
master