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