@@ -86,6 +86,10 @@ fn derived_str(dname: &Option<String>) -> String {
86
86
}
87
87
}
88
88
89
+ fn replace_idx ( name : & str , idx : & str ) -> String {
90
+ name. replace ( "[%s]" , idx) . replace ( "%s" , idx)
91
+ }
92
+
89
93
fn get_registers (
90
94
base_address : u64 ,
91
95
registers : Option < & Vec < RegisterCluster > > ,
@@ -116,8 +120,8 @@ fn get_registers(
116
120
let addr = str_utils:: format_address (
117
121
first_addr + ( i as u64 ) * ( d. dim_increment as u64 ) ,
118
122
) ;
119
- let rname = r. name . replace ( "%s" , & idx) ;
120
- let description = description . replace ( "%s" , & idx) ;
123
+ let rname = replace_idx ( & r. name , & idx) ;
124
+ let description = replace_idx ( & description , & idx) ;
121
125
let text = format ! (
122
126
"{addr} B REGISTER {rname}{derived}{access}: {description}"
123
127
) ;
@@ -144,8 +148,8 @@ fn get_registers(
144
148
for ( i, idx) in d. indexes ( ) . enumerate ( ) {
145
149
let caddr = first_addr + ( i as u64 ) * ( d. dim_increment as u64 ) ;
146
150
let addr = str_utils:: format_address ( caddr) ;
147
- let cname = c. name . replace ( "%s" , & idx) ;
148
- let description = description . replace ( "%s" , & idx) ;
151
+ let cname = replace_idx ( & c. name , & idx) ;
152
+ let description = replace_idx ( & description , & idx) ;
149
153
let text =
150
154
format ! ( "{addr} B CLUSTER {cname}{derived}: {description}" ) ;
151
155
mmap. push ( text) ;
@@ -180,7 +184,8 @@ fn get_fields(register: &RegisterInfo, addr: &str, mmap: &mut Vec<String>) {
180
184
for ( i, idx) in d. indexes ( ) . enumerate ( ) {
181
185
let bit_offset = f. bit_range . offset + ( i as u32 ) * d. dim_increment ;
182
186
let bit_width = f. bit_range . width ;
183
- let fname = f. name . replace ( "%s" , & idx) ;
187
+ let fname = replace_idx ( & f. name , & idx) ;
188
+ let description = replace_idx ( & description, & idx) ;
184
189
let text = format ! (
185
190
"{addr} C FIELD {bit_offset:02}w{bit_width:02} {fname}{derived}{access}: {description}"
186
191
) ;
0 commit comments