Mercurial > hg > Members > kono > Cerium
annotate example/get_segment/spe/fixpic.pl @ 466:4fa8760e18c2
prohibit global variable in Task....
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 01 Oct 2009 17:33:58 +0900 |
parents | 40af9fc1d428 |
children | 7777761e8e02 |
rev | line source |
---|---|
425 | 1 #!/usr/bin/perl |
2 # | |
3 # Author: Shinji KONO <kono@ie.u-ryukyu.ac.jp> | |
4 # v.0.1 Sat May 30 04:41:18 JST 2009 | |
5 # | |
6 # fix spu-gcc assembler soruce for DMA loadable PIC code | |
7 # | |
8 #$(OVLOBJS): %.o : %.cc | |
9 # $(SPECC) $(SPECFLAGS) -c $< -S -o $(<:.cc=.s) | |
10 # perl spe/fixpic.pl $(<:.cc=.s) | $(SPECC) $(SPECFLAGS) -x assembler -c -o $@ - | |
11 | |
12 use strict; | |
13 | |
14 my %global; | |
15 my %local; | |
16 my %weak; | |
17 my @line; | |
18 | |
19 # Basically SPU code is PIC. But linked library is in the fixed | |
20 # address space. | |
21 # | |
22 # rewrite relative to absolute for global branch address | |
23 # | |
24 # Target instruction | |
25 # hbrr -> hbra | |
26 # br -> bra | |
27 # brsl -> brasl | |
28 # brnz cannot be global | |
29 | |
465 | 30 # lqr -> li (for global) |
31 # ila global -> a $0,.LC0-.,$1 | |
32 | |
425 | 33 while(<>) { |
34 push(@line,$_); | |
35 if(/\.global\s+([^\s]+)/) { | |
36 $global{$1} = 1; | |
37 } | |
38 if(/\.weak\s+([^\s]+)/) { | |
39 $weak{$1} = 1; | |
40 next; | |
41 } | |
42 if(/^([^\s]+):/) { | |
43 $local{$1} = 1; | |
44 } | |
45 } | |
46 | |
47 for(@line) { | |
48 if (! /^#/) { | |
465 | 49 next if (/\.section\s+\.rodata/); |
425 | 50 if(/\s(br)\s+([^\s]+)/||/\s(brsl|hbrr)\s+[^\s]+,\s*([^\s]+)/) { |
51 my $name = $2; | |
52 if (! defined $local{$name} || defined $weak{$name} ) { | |
53 s/hbrr/hbra/ || | |
54 s/brsl/brasl/ || | |
55 s/br/bra/ ; | |
56 } | |
466
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
465
diff
changeset
|
57 # } elsif(/\s(lqr)\s+(\$\d+),([^\s]+)/) { |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
465
diff
changeset
|
58 # my $name = $2; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
465
diff
changeset
|
59 # if (! defined $local{$name} || defined $weak{$name} ) { |
465 | 60 # s/lqr/lqd/; |
466
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
465
diff
changeset
|
61 # } |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
465
diff
changeset
|
62 # } elsif(/\s(ila)\s+(\$\d+),([^\s]+)/) { |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
465
diff
changeset
|
63 # my $name = $3; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
465
diff
changeset
|
64 # if (! defined $local{$name} || defined $weak{$name} ) { |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
465
diff
changeset
|
65 # $_ = $_; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
465
diff
changeset
|
66 # } else { |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
465
diff
changeset
|
67 # $_ = "\tai\t$2,\$0,$3-.\n"; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
465
diff
changeset
|
68 # } |
425 | 69 } |
70 } | |
71 print ; | |
72 } | |
73 | |
74 # end |