+foreach my $class_name (keys(%reg_classes)) {
+ my @class = @{ $reg_classes{"$class_name"} };
+
+ my $idx = 0;
+ foreach (@class) {
+ if (defined($_->{name})) {
+ $reg2class{$_->{name}} = {
+ "class" => $class_name,
+ "index" => $idx
+ };
+ }
+ $idx++;
+ }
+ $regclass2len{$class_name} = $idx;
+}
+
+sub get_limited_array {
+ my $reg = shift;
+ my $regclass = $reg2class{"$reg"}{"class"};
+ my $ucname = uc($reg);
+ my $result = "{ ";
+
+ my $limitedbitsetlen = $regclass2len{$regclass};
+ my $arraylen = ($limitedbitsetlen+31) / 32;
+ my $firstreg = uc($reg_classes{$regclass}[0]->{"name"});
+ my $classuc = uc($regclass);
+ my $first = 1;
+ for (my $i = 0; $i < $arraylen; ++$i) {
+ if ($first) {
+ $first = 0;
+ } else {
+ $result .= ", ";
+ }
+
+ my $index = $reg2class{"$reg"}{"index"};
+ if ($index >= $i*32 && $index < ($i+1)*32) {
+ if ($i > 0) {
+ $result .= "(1 << (REG_${classuc}_${ucname} % 32))";
+ } else {
+ $result .= "(1 << REG_${classuc}_${ucname})";
+ }
+ } else {
+ $result .= "0";
+ }
+ }
+ $result .= " }";
+}
+