@@ -601,9 +601,23 @@ fn expand(
601
601
Ok ( ercs_expanded)
602
602
}
603
603
604
- /// Recursively calculate the size of a cluster. A cluster's size is the maximum
605
- /// end position of its recursive children.
604
+ /// Calculate the size of a Cluster. If it is an array, then the dimensions
605
+ /// tell us the size of the array. Otherwise, inspect the contents using
606
+ /// [cluster_info_size_in_bits].
606
607
fn cluster_size_in_bits (
608
+ cluster : & Cluster ,
609
+ defs : & RegisterProperties ,
610
+ config : & Config ,
611
+ ) -> Result < u32 > {
612
+ match cluster {
613
+ Cluster :: Single ( info) => cluster_info_size_in_bits ( info, defs, config) ,
614
+ Cluster :: Array ( _info, dim) => Ok ( dim. dim * dim. dim_increment * BITS_PER_BYTE ) ,
615
+ }
616
+ }
617
+
618
+ /// Recursively calculate the size of a ClusterInfo. A cluster's size is the
619
+ /// maximum end position of its recursive children.
620
+ fn cluster_info_size_in_bits (
607
621
info : & ClusterInfo ,
608
622
defs : & RegisterProperties ,
609
623
config : & Config ,
@@ -641,7 +655,7 @@ fn expand_cluster(
641
655
642
656
let defs = cluster. default_register_properties . derive_from ( defs) ;
643
657
644
- let cluster_size = cluster_size_in_bits ( cluster, & defs, config)
658
+ let cluster_size = cluster_info_size_in_bits ( cluster, & defs, config)
645
659
. with_context ( || format ! ( "Cluster {} has no determinable `size` field" , cluster. name) ) ?;
646
660
647
661
match cluster {
0 commit comments