@@ -592,9 +592,23 @@ fn expand(
592
592
Ok ( ercs_expanded)
593
593
}
594
594
595
- /// Recursively calculate the size of a cluster. A cluster's size is the maximum
596
- /// end position of its recursive children.
595
+ /// Calculate the size of a Cluster. If it is an array, then the dimensions
596
+ /// tell us the size of the array. Otherwise, inspect the contents using
597
+ /// [cluster_info_size_in_bits].
597
598
fn cluster_size_in_bits (
599
+ cluster : & Cluster ,
600
+ defs : & RegisterProperties ,
601
+ config : & Config ,
602
+ ) -> Result < u32 > {
603
+ match cluster {
604
+ Cluster :: Single ( info) => cluster_info_size_in_bits ( info, defs, config) ,
605
+ Cluster :: Array ( _info, dim) => Ok ( dim. dim * dim. dim_increment * BITS_PER_BYTE ) ,
606
+ }
607
+ }
608
+
609
+ /// Recursively calculate the size of a ClusterInfo. A cluster's size is the
610
+ /// maximum end position of its recursive children.
611
+ fn cluster_info_size_in_bits (
598
612
info : & ClusterInfo ,
599
613
defs : & RegisterProperties ,
600
614
config : & Config ,
@@ -632,7 +646,7 @@ fn expand_cluster(
632
646
633
647
let defs = cluster. default_register_properties . derive_from ( defs) ;
634
648
635
- let cluster_size = cluster_size_in_bits ( cluster, & defs, config)
649
+ let cluster_size = cluster_info_size_in_bits ( cluster, & defs, config)
636
650
. with_context ( || format ! ( "Cluster {} has no determinable `size` field" , cluster. name) ) ?;
637
651
638
652
match cluster {
0 commit comments