@@ -601,9 +601,23 @@ fn expand(
601601 Ok ( ercs_expanded)
602602}
603603
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].
606607fn 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 (
607621 info : & ClusterInfo ,
608622 defs : & RegisterProperties ,
609623 config : & Config ,
@@ -641,7 +655,7 @@ fn expand_cluster(
641655
642656 let defs = cluster. default_register_properties . derive_from ( defs) ;
643657
644- let cluster_size = cluster_size_in_bits ( cluster, & defs, config)
658+ let cluster_size = cluster_info_size_in_bits ( cluster, & defs, config)
645659 . with_context ( || format ! ( "Cluster {} has no determinable `size` field" , cluster. name) ) ?;
646660
647661 match cluster {
0 commit comments