-sub build_inout_idx_class {
- my $n = shift;
- my $op = shift;
- my $inout = shift;
- my @idx_class;
-
- if (exists($n->{"reg_req"}{"$inout"})) {
- my @reqs = @{ $n->{"reg_req"}{"$inout"} };
-
- for (my $idx = 0; $idx <= $#reqs; $idx++) {
- my $class = undef;
-
- if ($reqs[$idx] eq "none") {
- $class = "none";
- }
- elsif (is_reg_class($reqs[$idx])) {
- $class = $reqs[$idx];
- }
- else {
- my @regs = split(/ /, $reqs[$idx]);
-GET_CLASS: foreach my $reg (@regs) {
- if ($reg =~ /!?(in|out)\_r\d+/ || $reg =~ /!in/) {
- $class = "UNKNOWN_CLASS";
- }
- else {
- $class = get_reg_class($reg);
- if (!defined $class) {
- die("Could not get ".uc($inout)." register class for '$op' pos $idx (reg $reg) ... exiting.\n");
- }
- else {
- last GET_CLASS;
- } # !defined class
- } # if (reg =~ ...
- } # foreach
- } # if
-
- push(@idx_class, $class);
- } # for
- } # if
-
- return @idx_class;
-}
-
-###
-# Generates the requirements for the given description
-###
-sub generate_requirements {
- my $n = shift;
- my $op = shift;
- my $inout = shift;
-
- # get classes for the complementary direction
- my $outin = ($inout eq "in") ? "out" : "in";
-
- my @reqs = @{ $n->{"reg_req"}{"$inout"} };
-
- for (my $idx = 0; $idx <= $#reqs; $idx++) {
- my $class = undef;
-
- my $tmp2 = "const $arch\_register_req_t _".$op."_reg_req_$inout\_$idx = ";
- my $tmp = "#define ".$op."_reg_req_$inout\_$idx ";
-
- if ($reqs[$idx] eq "none") {
- $tmp .= "&$arch\_default_req_none\n";
- }
- elsif ($reqs[$idx] =~ /^new_reg_(.*)$/) {
- if (is_reg_class($1)) {
- $tmp .= "&_".$op."_reg_req_$inout\_$idx\n";
- $tmp2 .= "{\n";
- $tmp2 .= " {\n";
- $tmp2 .= " arch_register_req_type_should_be_different_from_all,\n";
- $tmp2 .= " &$arch\_reg_classes[CLASS_$arch\_".$1."],\n";
- $tmp2 .= " NULL, /* limit function */\n";
- $tmp2 .= " NULL, /* limit environment */\n";
- $tmp2 .= " NULL, /* same node */\n";
- $tmp2 .= " NULL /* different node */\n";
- $tmp2 .= " },\n";
- $tmp2 .= " 0,\n";
- $tmp2 .= " 0\n";
- $tmp2 .= "};\n";
-
- push(@obst_req, $tmp2."\n");
- push(@obst_header_all, "extern const $arch\_register_req_t _".$op."_reg_req_$inout\_$idx;\n");
- }
- else {
- print STDERR "Invalid register class '$1' given in OUT requirement $idx for '$op'.\n";
- }
- }
- elsif (is_reg_class($reqs[$idx])) {
- $tmp .= "&$arch\_default_req_".$arch."_".$reqs[$idx]."\n";
- }
- else {
- my @req_type_mask;
- my ($class, $has_limit, $same_pos, $different_pos) = build_subset_class_func($n, $op, $idx, (($inout eq "in") ? 1 : 0), $reqs[$idx]);
-
- if (!defined($class)) {
- die("Could not build subset for ".uc($inout)." requirements '$op' pos $idx ... exiting.\n");
- }
-
- if ($has_limit) {
- push(@req_type_mask, "arch_register_req_type_limited");
- }
- if (defined($same_pos)) {
- push(@req_type_mask, "arch_register_req_type_should_be_same");
- }
- if (defined($different_pos)) {
- if ($different_pos == 666) {
- push(@req_type_mask, "arch_register_req_type_should_be_different_from_all");
- undef $different_pos;