Commit | Line | Data |
36bb303b |
1 | BEGIN { |
2 | # Get function prototypes |
9ad884cb |
3 | require 'regen_lib.pl'; |
36bb303b |
4 | } |
d09b2d29 |
5 | #use Fatal qw(open close rename chmod unlink); |
6 | open DESC, 'regcomp.sym'; |
7 | $ind = 0; |
8 | |
9 | while (<DESC>) { |
10 | next if /^\s*($|\#)/; |
11 | $ind++; |
12 | chomp; |
13 | ($name[$ind], $desc, $rest[$ind]) = split /\t+/, $_, 3; |
14 | ($type[$ind], $code[$ind], $args[$ind], $longj[$ind]) |
15 | = split /[,\s]\s*/, $desc, 4; |
16 | } |
17 | close DESC; |
18 | $tot = $ind; |
19 | |
20 | $tmp_h = 'tmp_reg.h'; |
21 | |
22 | unlink $tmp_h if -f $tmp_h; |
23 | |
24 | open OUT, ">$tmp_h"; |
dfb1454f |
25 | binmode OUT; |
d09b2d29 |
26 | |
27 | print OUT <<EOP; |
28 | /* !!!!!!! DO NOT EDIT THIS FILE !!!!!!! |
9b155405 |
29 | This file is built by regcomp.pl from regcomp.sym. |
d09b2d29 |
30 | Any changes made here will be lost! |
31 | */ |
32 | |
33 | EOP |
34 | |
35 | $ind = 0; |
36 | while (++$ind <= $tot) { |
37 | $oind = $ind - 1; |
38 | $hind = sprintf "%#4x", $oind; |
39 | print OUT <<EOP; |
40 | #define $name[$ind] $oind /* $hind $rest[$ind] */ |
41 | EOP |
42 | } |
43 | |
44 | print OUT <<EOP; |
45 | |
46 | #ifndef DOINIT |
22c35a8c |
47 | EXTCONST U8 PL_regkind[]; |
d09b2d29 |
48 | #else |
22c35a8c |
49 | EXTCONST U8 PL_regkind[] = { |
d09b2d29 |
50 | EOP |
51 | |
52 | $ind = 0; |
53 | while (++$ind <= $tot) { |
54 | print OUT <<EOP; |
55 | $type[$ind], /* $name[$ind] */ |
56 | EOP |
57 | } |
58 | |
59 | print OUT <<EOP; |
60 | }; |
61 | #endif |
62 | |
63 | |
64 | #ifdef REG_COMP_C |
29de9391 |
65 | static const U8 regarglen[] = { |
d09b2d29 |
66 | EOP |
67 | |
68 | $ind = 0; |
69 | while (++$ind <= $tot) { |
70 | $size = 0; |
71 | $size = "EXTRA_SIZE(struct regnode_$args[$ind])" if $args[$ind]; |
72 | |
73 | print OUT <<EOP; |
74 | $size, /* $name[$ind] */ |
75 | EOP |
76 | } |
77 | |
78 | print OUT <<EOP; |
79 | }; |
80 | |
29de9391 |
81 | static const char reg_off_by_arg[] = { |
d09b2d29 |
82 | EOP |
83 | |
84 | $ind = 0; |
85 | while (++$ind <= $tot) { |
86 | $size = $longj[$ind] || 0; |
9b155405 |
87 | |
d09b2d29 |
88 | print OUT <<EOP; |
89 | $size, /* $name[$ind] */ |
90 | EOP |
91 | } |
92 | |
93 | print OUT <<EOP; |
94 | }; |
9b155405 |
95 | |
96 | #ifdef DEBUGGING |
29de9391 |
97 | static const char * const reg_name[] = { |
9b155405 |
98 | EOP |
99 | |
100 | $ind = 0; |
101 | while (++$ind <= $tot) { |
102 | $hind = sprintf "%#4x", $ind-1; |
103 | $size = $longj[$ind] || 0; |
104 | |
105 | print OUT <<EOP; |
106 | "$name[$ind]", /* $hind */ |
107 | EOP |
108 | } |
109 | |
110 | print OUT <<EOP; |
111 | }; |
112 | |
29de9391 |
113 | static const int reg_num = $tot; |
9b155405 |
114 | |
115 | #endif /* DEBUGGING */ |
d09b2d29 |
116 | #endif /* REG_COMP_C */ |
117 | |
118 | EOP |
119 | |
36bb303b |
120 | close OUT or die "close $tmp_h: $!"; |
d09b2d29 |
121 | |
36bb303b |
122 | safer_rename $tmp_h, 'regnodes.h'; |