@@ -592,9 +592,24 @@ 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) =>
606
+ Ok ( dim. dim * dim. dim_increment * BITS_PER_BYTE ) ,
607
+ }
608
+ }
609
+
610
+ /// Recursively calculate the size of a ClusterInfo. A cluster's size is the
611
+ /// maximum end position of its recursive children.
612
+ fn cluster_info_size_in_bits (
598
613
info : & ClusterInfo ,
599
614
defs : & RegisterProperties ,
600
615
config : & Config ,
@@ -632,7 +647,7 @@ fn expand_cluster(
632
647
633
648
let defs = cluster. default_register_properties . derive_from ( defs) ;
634
649
635
- let cluster_size = cluster_size_in_bits ( cluster, & defs, config)
650
+ let cluster_size = cluster_info_size_in_bits ( cluster, & defs, config)
636
651
. with_context ( || format ! ( "Cluster {} has no determinable `size` field" , cluster. name) ) ?;
637
652
638
653
match cluster {
0 commit comments