- 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+/) {
- $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)) {
- push(@req_type_mask, "arch_register_req_type_should_be_different");
- }
-
- $tmp .= "&_".$op."_reg_req_$inout\_$idx\n";
- $tmp2 .= "{\n";
- $tmp2 .= " {\n";
- $tmp2 .= " ".join(" | ", @req_type_mask).",\n";
- $tmp2 .= " &$arch\_reg_classes[CLASS_$arch\_".$class."],\n";
- $tmp2 .= " ".($has_limit ? "limit_reg_".$op."_$inout\_".$idx : "NULL").",\n";
- $tmp2 .= " NULL, /* limit environment */\n";
- $tmp2 .= " NULL, /* same node */\n";
- $tmp2 .= " NULL /* different node */\n";
- $tmp2 .= " },\n";
- $tmp2 .= " ".(defined($same_pos) ? $same_pos : "0").",\n";
- $tmp2 .= " ".(defined($different_pos) ? $different_pos : "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");
- }
-
- push(@obst_requirement_def, $tmp);
- }
-
-}