fixed comments
[libfirm] / ir / be / scripts / generate_regalloc_if.pl
1 #!/usr/bin/perl -w
2
3 # This script generates C code which creates ands sets up functions and
4 # data structures for the register allocator.
5 # Creation: 2005/11/14
6 # $Id$
7
8 use strict;
9 use Data::Dumper;
10
11 my $specfile   = $ARGV[0];
12 my $target_dir = $ARGV[1];
13
14 our $arch;
15 our %reg_classes;
16 our %nodes;
17
18 # include spec file
19
20 my $return;
21
22 no strict "subs";
23 unless ($return = do $specfile) {
24         warn "couldn't parse $specfile: $@" if $@;
25         warn "couldn't do $specfile: $!"    unless defined $return;
26         warn "couldn't run $specfile"       unless $return;
27 }
28 use strict "subs";
29
30 my $target_c   = $target_dir."/gen_".$arch."_regalloc_if.c";
31 my $target_h   = $target_dir."/gen_".$arch."_regalloc_if.h";
32 my $target_h_t = $target_dir."/gen_".$arch."_regalloc_if_t.h";
33
34 # helper function
35 sub translate_reg_type {
36         my $t = shift;
37
38         if ($t == 0) {
39                 return "arch_register_type_none";
40         }
41         else {
42                 my @types;
43
44                 if ($t & 1) {
45                         push(@types, "arch_register_type_caller_save");
46                 }
47
48                 if ($t & 2) {
49                         push(@types, "arch_register_type_callee_save");
50                 }
51
52                 if ($t & 4) {
53                         push(@types, "arch_register_type_ignore");
54                 }
55
56                 if ($t & 8) {
57                         push(@types, "arch_register_type_joker");
58                 }
59
60                 if ($t & 16) {
61                         push(@types, "arch_register_type_virtual");
62                 }
63
64                 return join(" | ", @types);
65         }
66 }
67
68 # stacks for output
69 my @obst_regtypes_def; # stack for the register type variables definitions
70 my @obst_regtypes_decl;# stack for the register type variables declarations
71 my @obst_regclasses;   # stack for the register class variables
72 my @obst_classdef;     # stack to define a name for a class index
73 my @obst_regdef;       # stack to define a name for a register index
74 my @obst_reginit;      # stack for the register type inits
75 my @obst_req;          # stack for the register requirements
76 my @obst_limit_func;   # stack for functions to return a subset of a register class
77 my @obst_defreq_head;  # stack for prototypes of default requirement function
78 my @obst_header_all;   # stack for some extern struct defs needed for bearch_$arch include
79 my @obst_requirement_def;  # stack for requirement name defines
80
81 my $numregs;
82 my $class_ptr;
83 my $class_idx = 0;
84
85 my $tmp;
86
87 my %reg2class;
88
89 # there is a default NONE requirement
90 $tmp = "/* Default NONE register requirements */\n";
91 $tmp .= "const $arch\_register_req_t $arch\_default_req_none = {\n";
92 $tmp .= "  {\n";
93 $tmp .= "    arch_register_req_type_none,  /* register type  */\n";
94 $tmp .= "    NULL,                         /* register class */\n";
95 $tmp .= "    NULL,                         /* limit function */\n";
96 $tmp .= "    NULL,                         /* limit environment */\n";
97 $tmp .= "    NULL,                         /* node for same */\n";
98 $tmp .= "    NULL                          /* node for different */\n";
99 $tmp .= "  },\n";
100 $tmp .= "  0,                              /* same pos */\n";
101 $tmp .= "  0                               /* different pos */\n";
102 $tmp .= "};\n\n";
103 push(@obst_req, $tmp);
104 push(@obst_header_all, "extern const $arch\_register_req_t $arch\_default_req_none;\n");
105
106 push(@obst_classdef, "enum reg_classes {\n");
107
108 my $class_mode;
109
110 # generate register type and class variable, init function and default requirements
111 foreach my $class_name (keys(%reg_classes)) {
112         my @class         = @{ $reg_classes{"$class_name"} };
113         my $old_classname = $class_name;
114
115         $class_name = $arch."_".$class_name;
116         $numregs    = "N_".$class_name."_REGS";
117         $class_ptr  = "&".$arch."_reg_classes[CLASS_".$class_name."]";
118         $class_mode = pop(@class)->{"mode"};
119
120         push(@obst_regtypes_decl, "extern arch_register_t ".$class_name."_regs[$numregs];\n");
121         push(@obst_regtypes_def, "arch_register_t ".$class_name."_regs[$numregs];\n");
122
123         push(@obst_classdef, "  CLASS_$class_name = $class_idx,\n");
124         push(@obst_regclasses, "{ \"$class_name\", $numregs, NULL, ".$class_name."_regs }");
125
126         # there is a default NORMAL requirement for each class
127         $tmp  = "/* Default NORMAL register requirements for class $class_name */\n";
128         $tmp .= "const $arch\_register_req_t $arch\_default_req_$class_name = {\n";
129         $tmp .= "  {\n";
130         $tmp .= "    arch_register_req_type_normal,\n";
131         $tmp .= "    $class_ptr,\n";
132         $tmp .= "    NULL,                    /* limit function */ \n";
133         $tmp .= "    NULL,                    /* limit environment */\n";
134         $tmp .= "    NULL,                    /* node for same */\n";
135         $tmp .= "    NULL                     /* node for different */\n";
136         $tmp .= "  },\n";
137         $tmp .= "  0,                         /* same pos */\n";
138         $tmp .= "  0                          /* different pos */\n";
139         $tmp .= "};\n\n";
140         push(@obst_req, $tmp);
141         push(@obst_header_all, "extern const $arch\_register_req_t $arch\_default_req_$class_name;\n");
142
143         my $idx = 0;
144         push(@obst_reginit, "  /* Init of all registers in class '$class_name' */\n\n");
145         push(@obst_reginit, "  /* set largest possible mode for '$class_name' */\n");
146         push(@obst_reginit, "  $arch\_reg_classes[CLASS_".$class_name."].mode = $class_mode;\n\n");
147         push(@obst_regdef, "enum reg_".$class_name."_values {\n");
148         foreach (@class) {
149                 # For each class we build for each of it's member registers a limit function
150                 # which limits the class to this particular register. We also build the
151                 # corresponding requirement structs.
152                 # We need those functions to set register requirements on demand in transformation
153                 # esp. for Call and RegParams where we can mix int and float parameters.
154
155                 my $limit_func_name = $arch."_limit_".$class_name."_".$_->{"name"};
156
157                 # push the function prototype
158                 $tmp = "void $limit_func_name(void *_unused, bitset_t *bs)";
159                 push(@obst_defreq_head, $tmp.";\n");
160
161                 # push the function definition
162                 $tmp .= " {\n";
163                 $tmp .= "    bs = bitset_clear_all(bs);\n";
164                 $tmp .= "    bitset_set(bs, REG_".uc($_->{"name"}).");\n";  # REGISTER to index assignment is done some lines down
165                 $tmp .= "}\n\n";
166                 push(@obst_limit_func, $tmp);
167
168                 # push the default requirement struct
169                 $tmp  = "const $arch\_register_req_t $arch\_default_req_$class_name\_".$_->{"name"}." = {\n";
170                 $tmp .= "  {\n";
171                 $tmp .= "    arch_register_req_type_limited,\n";
172                 $tmp .= "    $class_ptr,\n";
173                 $tmp .= "    $limit_func_name,\n";
174                 $tmp .= "    NULL,                     /* limit environment */\n";
175                 $tmp .= "    NULL,                     /* node for same */\n";
176                 $tmp .= "    NULL                      /* node for different */\n";
177                 $tmp .= "  },\n";
178                 $tmp .= "  0,                          /* same pos */\n";
179                 $tmp .= "  0                           /* different pos */\n";
180                 $tmp .= "};\n\n";
181                 push(@obst_req, $tmp);
182                 push(@obst_header_all,"extern const $arch\_register_req_t $arch\_default_req_$class_name\_".$_->{"name"}.";\n");
183
184                 $reg2class{$_->{"name"}} = { "class" => $old_classname, "index" => $idx }; # remember reg to class for later use
185                 push(@obst_regdef, "  REG_".uc($_->{"name"})." = $idx,\n");
186                 push(@obst_reginit, "  ".$class_name."_regs[$idx].name      = \"".$_->{"name"}."\";\n");
187                 push(@obst_reginit, "  ".$class_name."_regs[$idx].reg_class = $class_ptr;\n");
188                 push(@obst_reginit, "  ".$class_name."_regs[$idx].index     = $idx;\n");
189                 push(@obst_reginit, "  ".$class_name."_regs[$idx].type      = ".translate_reg_type($_->{"type"}).";\n");
190                 push(@obst_reginit, "\n");
191                 $idx++;
192         }
193         push(@obst_regdef, "  $numregs = $idx\n");
194         push(@obst_regdef, "};\n\n");
195
196         $class_idx++;
197 }
198
199 push(@obst_classdef, "  N_CLASSES = ".scalar(keys(%reg_classes))."\n");
200 push(@obst_classdef, "};\n\n");
201
202 # generate node-register constraints
203 foreach my $op (keys(%nodes)) {
204         my %n = %{ $nodes{"$op"} };
205
206         next if (!exists($n{"reg_req"}));
207
208         $op = $arch."_".$op;
209
210         push(@obst_req, "/* IN requirements for '$op' */\n");
211         # check for argument requirements
212         if (exists($n{"reg_req"}{"in"})) {
213                 generate_requirements(\%n, $op, "in");
214         }
215
216         push(@obst_req, "/* OUT requirements for '$op' */\n");
217         # check for result requirements
218         if (exists($n{"reg_req"}{"out"})) {
219                 generate_requirements(\%n, $op, "out");
220         }
221 }
222
223
224
225 # generate header _t (internal usage) file
226 open(OUT, ">$target_h_t") || die("Could not open $target_h_t, reason: $!\n");
227
228 my $creation_time = localtime(time());
229
230 $tmp = uc($arch);
231
232 print OUT<<EOF;
233 #ifndef _GEN_$tmp\_REGALLOC_IF_T_H_
234 #define _GEN_$tmp\_REGALLOC_IF_T_H_
235
236 /**
237  * Generated register classes from spec.
238  *
239  * DO NOT EDIT THIS FILE, your changes will be lost.
240  * Edit $specfile instead.
241  * created by: $0 $specfile $target_dir
242  * date:       $creation_time
243  */
244
245 EOF
246
247 print OUT @obst_requirement_def;
248
249 print OUT "\n#endif /* _GEN_$tmp\_REGALLOC_IF_T_H_ */\n";
250
251
252
253 # generate header (external usage) file
254 open(OUT, ">$target_h") || die("Could not open $target_h, reason: $!\n");
255
256 $creation_time = localtime(time());
257
258 print OUT<<EOF;
259 #ifndef _GEN_$tmp\_REGALLOC_IF_H_
260 #define _GEN_$tmp\_REGALLOC_IF_H_
261
262 /**
263  * Contains additional external requirements defs for external includes.
264  *
265  * DO NOT EDIT THIS FILE, your changes will be lost.
266  * Edit $specfile instead.
267  * created by: $0 $specfile $target_dir
268  * date:       $creation_time
269  */
270
271 #include "../bearch.h"
272 #include "$arch\_nodes_attr.h"
273
274 EOF
275
276 print OUT @obst_regdef, "\n";
277
278 print OUT @obst_classdef, "\n";
279
280 print OUT @obst_regtypes_decl, "\n";
281
282 print OUT "extern arch_register_class_t $arch\_reg_classes[N_CLASSES];\n\n";
283
284 print OUT "void ".$arch."_register_init(void *isa_ptr);\n\n";
285
286 print OUT @obst_header_all, "\n";
287
288 print OUT @obst_defreq_head, "\n";
289
290 print OUT "\n#endif /* _GEN_$tmp\_REGALLOC_IF_H_ */\n";
291
292 close(OUT);
293
294
295
296 # generate c file
297 open(OUT, ">$target_c") || die("Could not open $target_c, reason: $!\n");
298
299 $creation_time = localtime(time());
300
301 print OUT<<EOF;
302 /**
303  * The generated interface for the register allocator.
304  * Contains register classes and types and register constraints
305  * for all nodes where constraints were given in spec.
306  *
307  * DO NOT EDIT THIS FILE, your changes will be lost.
308  * Edit $specfile instead.
309  * created by: $0 $specfile $target_dir
310  * date:       $creation_time
311  */
312
313 #include "gen_$arch\_regalloc_if.h"
314 #include "bearch_$arch\_t.h"   /* we need this to put the caller saved registers into the isa set */
315 #include "$arch\_map_regs.h"
316 #include "irmode.h"
317
318 EOF
319
320 print OUT "arch_register_class_t $arch\_reg_classes[] = {\n  ".join(",\n  ", @obst_regclasses)."\n};\n\n";
321
322 print OUT @obst_regtypes_def, "\n";
323
324 print OUT "void ".$arch."_register_init(void *isa_ptr) {\n";
325 print OUT @obst_reginit;
326 print OUT "}\n\n";
327
328 print OUT @obst_limit_func;
329
330 print OUT @obst_req;
331
332 close(OUT);
333
334 ###
335 # Remember the register class for each index in the given requirements.
336 # We need this information for requirements like "in_sX" or "out_dX"
337 # @return array of classes corresponding to the requirement for each index
338 ###
339 sub build_inout_idx_class {
340         my $n     = shift;
341         my $op    = shift;
342         my $inout = shift;
343         my @idx_class;
344
345         if (exists($n->{"reg_req"}{"$inout"})) {
346                 my @reqs = @{ $n->{"reg_req"}{"$inout"} };
347
348                 for (my $idx = 0; $idx <= $#reqs; $idx++) {
349                         my $class = undef;
350
351                         if ($reqs[$idx] eq "none") {
352                                 $class = "none";
353                         }
354                         elsif (is_reg_class($reqs[$idx])) {
355                                 $class = $reqs[$idx];
356                         }
357                         else {
358                                 my @regs = split(/ /, $reqs[$idx]);
359 GET_CLASS:              foreach my $reg (@regs) {
360                                         if ($reg =~ /!?(in|out)\_r\d+/ || $reg =~ /!in/) {
361                                                 $class = "UNKNOWN_CLASS";
362                                         }
363                                         else {
364                                                 $class = get_reg_class($reg);
365                                                 if (!defined $class) {
366                                                         die("Could not get ".uc($inout)." register class for '$op' pos $idx (reg $reg) ... exiting.\n");
367                                                 }
368                                                 else {
369                                                         last GET_CLASS;
370                                                 } # !defined class
371                                         } # if (reg =~ ...
372                                 } # foreach
373                         } # if
374
375                         push(@idx_class, $class);
376                 } # for
377         } # if
378
379         return @idx_class;
380 }
381
382 ###
383 # Generates the requirements for the given description
384 ###
385 sub generate_requirements {
386         my $n     = shift;
387         my $op    = shift;
388         my $inout = shift;
389
390         # get classes for the complementary direction
391         my $outin     = ($inout eq "in") ? "out" : "in";
392
393         my @reqs = @{ $n->{"reg_req"}{"$inout"} };
394
395         for (my $idx = 0; $idx <= $#reqs; $idx++) {
396                 my $class = undef;
397
398                 my $tmp2 = "const $arch\_register_req_t _".$op."_reg_req_$inout\_$idx = ";
399                 my $tmp  = "#define ".$op."_reg_req_$inout\_$idx ";
400
401                 if ($reqs[$idx] eq "none") {
402                         $tmp .= "&$arch\_default_req_none\n";
403                 }
404                 elsif ($reqs[$idx] =~ /^new_reg_(.*)$/) {
405                         if (is_reg_class($1)) {
406                                 $tmp  .=  "&_".$op."_reg_req_$inout\_$idx\n";
407                                 $tmp2 .= "{\n";
408                                 $tmp2 .= "  {\n";
409                                 $tmp2 .= "    arch_register_req_type_should_be_different_from_all,\n";
410                                 $tmp2 .= "    &$arch\_reg_classes[CLASS_$arch\_".$1."],\n";
411                                 $tmp2 .= "    NULL,        /* limit function */\n";
412                                 $tmp2 .= "    NULL,        /* limit environment */\n";
413                                 $tmp2 .= "    NULL,        /* same node */\n";
414                                 $tmp2 .= "    NULL         /* different node */\n";
415                                 $tmp2 .= "  },\n";
416                                 $tmp2 .= "  0,\n";
417                                 $tmp2 .= "  0\n";
418                                 $tmp2 .= "};\n";
419
420                                 push(@obst_req, $tmp2."\n");
421                                 push(@obst_header_all, "extern const $arch\_register_req_t _".$op."_reg_req_$inout\_$idx;\n");
422                         }
423                         else {
424                                 print STDERR "Invalid register class '$1' given in OUT requirement $idx for '$op'.\n";
425                         }
426                 }
427                 elsif (is_reg_class($reqs[$idx])) {
428                         $tmp .= "&$arch\_default_req_".$arch."_".$reqs[$idx]."\n";
429                 }
430                 else {
431                         my @req_type_mask;
432                         my ($class, $has_limit, $same_pos, $different_pos) = build_subset_class_func($n, $op, $idx, (($inout eq "in") ? 1 : 0), $reqs[$idx]);
433
434                         if (!defined($class)) {
435                                 die("Could not build subset for ".uc($inout)." requirements '$op' pos $idx ... exiting.\n");
436                         }
437
438                         if ($has_limit) {
439                                 push(@req_type_mask, "arch_register_req_type_limited");
440                         }
441                         if (defined($same_pos)) {
442                                 push(@req_type_mask, "arch_register_req_type_should_be_same");
443                         }
444                         if (defined($different_pos)) {
445                                 if ($different_pos == 666) {
446                                         push(@req_type_mask, "arch_register_req_type_should_be_different_from_all");
447                                         undef $different_pos;
448                                 }
449                                 else {
450                                         push(@req_type_mask, "arch_register_req_type_should_be_different");
451                                 }
452                         }
453
454                         $tmp  .= "&_".$op."_reg_req_$inout\_$idx\n";
455                         $tmp2 .= "{\n";
456                         $tmp2 .= "  {\n";
457                         $tmp2 .= "    ".join(" | ", @req_type_mask).",\n";
458                         $tmp2 .= "    &$arch\_reg_classes[CLASS_$arch\_".$class."],\n";
459                         $tmp2 .= "    ".($has_limit ? "limit_reg_".$op."_$inout\_".$idx : "NULL").",\n";
460                         $tmp2 .= "    NULL,        /* limit environment */\n";
461                         $tmp2 .= "    NULL,        /* same node */\n";
462                         $tmp2 .= "    NULL         /* different node */\n";
463                         $tmp2 .= "  },\n";
464                         $tmp2 .= "  ".(defined($same_pos) ? $same_pos : "0").",\n";
465                         $tmp2 .= "  ".(defined($different_pos) ? $different_pos : "0")."\n";
466                         $tmp2 .= "};\n";
467
468                         push(@obst_req, $tmp2."\n");
469                         push(@obst_header_all, "extern const $arch\_register_req_t _".$op."_reg_req_$inout\_$idx;\n");
470                 }
471
472                 push(@obst_requirement_def, $tmp);
473         }
474
475 }
476
477 ###
478 # Determines whether $name is a specified register class or not.
479 # @return 1 if name is register class, 0 otherwise
480 ###
481 sub is_reg_class {
482         my $name = shift;
483         return 1 if exists($reg_classes{"$name"});
484         return 0;
485 }
486
487 ###
488 # Returns the register class for a given register.
489 # @return class or undef
490 ###
491 sub get_reg_class {
492         my $reg = shift;
493         $reg = substr($reg, 1) if ($reg =~ /!.*/);
494         return $reg2class{"$reg"}{"class"} if (exists($reg2class{"$reg"}));
495         return undef;
496 }
497
498 ###
499 # Returns the index of a given register within it's register class.
500 # @return index or undef
501 ###
502 sub get_reg_index {
503         my $reg = shift;
504         return $reg2class{"$reg"}{"index"} if (exists($reg2class{"$reg"}));
505         return undef;
506 }
507
508 ###
509 # Generates the function for a given $op and a given IN-index
510 # which returns a subset of possible register from a register class
511 # @return classname from which the subset is derived or undef and
512 #         pos which corresponds to in/out reference position or undef
513 ###
514 sub build_subset_class_func {
515         my $neg           = undef;
516         my $class         = undef;
517         my $has_limit     = 0;
518         my $same_pos      = undef;
519         my $different_pos = undef;
520         my $temp;
521         my @obst_init;
522         my @obst_limits;
523         my @obst_ignore;
524
525
526         # build function header
527         my $n   = shift;
528         my $op  = shift;
529         my $idx = shift;
530         my $in  = shift;
531
532         my $outin = $in ? "out" : "in";
533         my @regs  = split(/ /, shift);
534
535         my @idx_class = build_inout_idx_class($n, $op, $outin);
536
537         # set/unset registers
538 CHECK_REQS: foreach (@regs) {
539                 if (/(!)?$outin\_r(\d+)/) {
540                         if (($1 && defined($different_pos)) || (!$1 && defined($same_pos))) {
541                                 print STDERR "Multiple in/out references of same type in one requirement not allowed.\n";
542                                 return (undef, undef, undef, undef);
543                         }
544
545                         if ($1) {
546                                 $different_pos = $in ? -$2 : $2 - 1;
547                         }
548                         else {
549                                 $same_pos = $in ? -$2 : $2 - 1;
550                         }
551
552                         $class = $idx_class[$2 - 1];
553                         next CHECK_REQS;
554                 }
555                 elsif (/!in/) {
556                         $class = $idx_class[0];
557                         return ($class, 0, undef, 666);
558                 }
559
560                 # check for negate
561                 if (substr($_, 0, 1) eq "!") {
562                         if (defined($neg) && $neg == 0) {
563                                 # we have seen a positiv constraint as first one but this one is negative
564                                 # this doesn't make sense
565                                 print STDERR "Mixed positive and negative constraints for the same slot are not allowed.\n";
566                                 return (undef, undef, undef, undef);
567                         }
568
569                         if (!defined($neg)) {
570                                 $has_limit = 1;
571                                 push(@obst_init, "  bs = bitset_set_all(bs);     /* allow all register (negative constraints given) */\n");
572                         }
573
574                         $_   = substr($_, 1); # skip '!'
575                         $neg = 1;
576                 }
577                 else {
578                         if (defined($neg) && $neg == 1) {
579                                 # we have seen a negative constraint as first one but this one is positive
580                                 # this doesn't make sense
581                                 print STDERR "Mixed positive and negative constraints for the same slot are not allowed.\n";
582                                 return (undef, undef, undef, undef);
583                         }
584
585                         if (!defined($neg)) {
586                                 $has_limit = 1;
587                                 push(@obst_init, "  bs = bitset_clear_all(bs);   /* disallow all register (positive constraints given) */\n");
588                         }
589                         $neg = 0;
590                 }
591
592                 # check if register belongs to one of the given classes
593                 $temp = get_reg_class($_);
594                 if (!defined($temp)) {
595                         print STDERR "Unknown register '$_'!\n";
596                         return (undef, undef, undef, undef);
597                 }
598
599                 # set class
600                 if (!defined($class)) {
601                         $class = $temp;
602                 }
603                 elsif ($class ne $temp) {
604                         # all registers must belong to the same class
605                         print STDERR "Registerclass mismatch. '$_' is not member of class '$class'.\n";
606                         return (undef, undef, undef, undef);
607                 }
608
609                 if ($neg == 1) {
610                         $has_limit = 1;
611                         push(@obst_limits, "  bitset_clear(bs, ".get_reg_index($_).");         /* disallow $_ */\n");
612                 }
613                 else {
614                         $has_limit = 1;
615                         push(@obst_limits, "  bitset_set(bs, ".get_reg_index($_).");           /* allow $_ */\n");
616                 }
617         }
618
619         my @cur_class = @{ $reg_classes{"$class"} };
620         for (my $idx = 0; $idx <= $#cur_class; $idx++) {
621                 if (defined($cur_class[$idx]{"type"}) && ($cur_class[$idx]{"type"} & 4)) {
622                         push(@obst_ignore, "  bitset_clear(bs, ".get_reg_index($cur_class[$idx]{"name"}).");");
623                         push(@obst_ignore, "         /* disallow ignore reg ".$cur_class[$idx]{"name"}." */\n");
624                 }
625         }
626
627         if ($has_limit == 1) {
628                 push(@obst_header_all, "void limit_reg_".$op."_".($in ? "in" : "out")."_".$idx."(void *_unused, bitset_t *bs);\n");
629
630                 push(@obst_limit_func, "/* limit the possible registers for ".($in ? "IN" : "OUT")." $idx at op $op */\n");
631                 push(@obst_limit_func, "void limit_reg_".$op."_".($in ? "in" : "out")."_".$idx."(void *_unused, bitset_t *bs) {\n");
632                 push(@obst_limit_func, @obst_init);
633                 push(@obst_limit_func, @obst_ignore);
634                 push(@obst_limit_func, @obst_limits);
635                 push(@obst_limit_func, "}\n\n");
636         }
637
638         return ($class, $has_limit, $same_pos, $different_pos);
639 }