@@ -152,17 +152,11 @@ void free_arch(t_arch* arch) {
152152 return ;
153153 }
154154
155- delete[] arch->Switches ;
156- arch->Switches = nullptr ;
157-
158155 free_arch_models (arch->models );
159156
160- for (int i = 0 ; i < arch->num_directs ; ++i) {
161- vtr::free (arch->Directs [i].name );
162- vtr::free (arch->Directs [i].from_pin );
163- vtr::free (arch->Directs [i].to_pin );
164- }
165- vtr::free (arch->Directs );
157+ vtr::release_memory (arch->switches );
158+
159+ vtr::release_memory (arch->directs );
166160
167161 vtr::free (arch->architecture_id );
168162
@@ -235,7 +229,7 @@ t_model* free_arch_model(t_model* model) {
235229 return next_model;
236230}
237231
238- // Frees all the model portss in a linked list
232+ // Frees all the model ports in a linked list
239233void free_arch_model_ports (t_model_ports* model_ports) {
240234 t_model_ports* model_port = model_ports;
241235 while (model_port) {
@@ -256,16 +250,17 @@ t_model_ports* free_arch_model_port(t_model_ports* model_port) {
256250}
257251
258252void free_type_descriptors (std::vector<t_physical_tile_type>& type_descriptors) {
259- for (auto & type : type_descriptors) {
260- vtr::free (type.name );
253+ for (t_physical_tile_type& type : type_descriptors) {
254+ vtr::release_memory (type.name );
255+
261256 if (type.index == EMPTY_TYPE_INDEX) {
262257 continue ;
263258 }
264259
265- for (auto & sub_tile : type.sub_tiles ) {
266- vtr::free (sub_tile.name );
260+ for (t_sub_tile & sub_tile : type.sub_tiles ) {
261+ vtr::release_memory (sub_tile.name );
267262
268- for (auto port : sub_tile.ports ) {
263+ for (t_physical_tile_port& port : sub_tile.ports ) {
269264 vtr::free (port.name );
270265 }
271266 }
@@ -276,8 +271,8 @@ void free_type_descriptors(std::vector<t_physical_tile_type>& type_descriptors)
276271void free_type_descriptors (std::vector<t_logical_block_type>& type_descriptors) {
277272 free_all_pb_graph_nodes (type_descriptors);
278273
279- for (auto & type : type_descriptors) {
280- vtr::free (type.name );
274+ for (t_logical_block_type & type : type_descriptors) {
275+ vtr::release_memory (type.name );
281276 if (type.index == EMPTY_TYPE_INDEX) {
282277 continue ;
283278 }
@@ -522,7 +517,7 @@ t_port* findPortByName(const char* name, t_pb_type* pb_type, int* high_index, in
522517
523518t_physical_tile_type get_empty_physical_type (const char * name /* = EMPTY_BLOCK_NAME*/ ) {
524519 t_physical_tile_type type;
525- type.name = vtr::strdup ( name) ;
520+ type.name = name;
526521 type.num_pins = 0 ;
527522 type.width = 1 ;
528523 type.height = 1 ;
@@ -540,7 +535,7 @@ t_physical_tile_type get_empty_physical_type(const char* name /*= EMPTY_BLOCK_NA
540535
541536t_logical_block_type get_empty_logical_type (const char * name /* =EMPTY_BLOCK_NAME*/ ) {
542537 t_logical_block_type type;
543- type.name = vtr::strdup ( name) ;
538+ type.name = name;
544539 type.pb_type = nullptr ;
545540
546541 return type;
@@ -1104,7 +1099,6 @@ void SyncModelsPbTypes(t_arch* arch,
11041099
11051100void SyncModelsPbTypes_rec (t_arch* arch,
11061101 t_pb_type* pb_type) {
1107- int i, j, p;
11081102 t_model *model_match_prim, *cur_model;
11091103 t_model_ports* model_port;
11101104 vtr::t_linked_vptr* old;
@@ -1143,7 +1137,7 @@ void SyncModelsPbTypes_rec(t_arch* arch,
11431137 }
11441138 cur_model = cur_model->next ;
11451139 }
1146- if (found != true ) {
1140+ if (!found ) {
11471141 archfpga_throw (get_arch_file_name (), 0 ,
11481142 " No matching model for pb_type %s\n " , pb_type->blif_model );
11491143 }
@@ -1154,7 +1148,7 @@ void SyncModelsPbTypes_rec(t_arch* arch,
11541148 model_match_prim->pb_types ->next = old;
11551149 model_match_prim->pb_types ->data_vptr = pb_type;
11561150
1157- for (p = 0 ; p < pb_type->num_ports ; p++) {
1151+ for (int p = 0 ; p < pb_type->num_ports ; p++) {
11581152 found = false ;
11591153 /* TODO: Parse error checking - check if INPUT matches INPUT and OUTPUT matches OUTPUT (not yet done) */
11601154 model_port = model_match_prim->inputs ;
@@ -1203,17 +1197,16 @@ void SyncModelsPbTypes_rec(t_arch* arch,
12031197 }
12041198 model_port = model_port->next ;
12051199 }
1206- if (found != true ) {
1200+ if (!found ) {
12071201 archfpga_throw (get_arch_file_name (), 0 ,
12081202 " No matching model port for port %s in pb_type %s\n " ,
12091203 pb_type->ports [p].name , pb_type->name );
12101204 }
12111205 }
12121206 } else {
1213- for (i = 0 ; i < pb_type->num_modes ; i++) {
1214- for (j = 0 ; j < pb_type->modes [i].num_pb_type_children ; j++) {
1215- SyncModelsPbTypes_rec (arch,
1216- &(pb_type->modes [i].pb_type_children [j]));
1207+ for (int i = 0 ; i < pb_type->num_modes ; i++) {
1208+ for (int j = 0 ; j < pb_type->modes [i].num_pb_type_children ; j++) {
1209+ SyncModelsPbTypes_rec (arch, &(pb_type->modes [i].pb_type_children [j]));
12171210 }
12181211 }
12191212 }
@@ -1229,11 +1222,11 @@ void SyncModelsPbTypes_rec(t_arch* arch,
12291222void primitives_annotation_clock_match (t_pin_to_pin_annotation* annotation,
12301223 t_pb_type* parent_pb_type) {
12311224 int i_port;
1232- bool clock_valid = false ; // Determine if annotation's clock is same as primtive 's clock
1225+ bool clock_valid = false ; // Determine if annotation's clock is same as primitive 's clock
12331226
12341227 if (!parent_pb_type || !annotation) {
12351228 archfpga_throw (__FILE__, __LINE__,
1236- " Annotation_clock check encouters invalid annotation or primitive.\n " );
1229+ " Annotation_clock check encounters invalid annotation or primitive.\n " );
12371230 }
12381231
12391232 for (i_port = 0 ; i_port < parent_pb_type->num_ports ; i_port++) {
@@ -1253,18 +1246,17 @@ void primitives_annotation_clock_match(t_pin_to_pin_annotation* annotation,
12531246 }
12541247}
12551248
1256- const t_segment_inf* find_segment (const t_arch* arch, std::string name) {
1257- for (size_t i = 0 ; i < (arch->Segments ).size (); ++i) {
1258- const t_segment_inf* seg = &arch->Segments [i];
1259- if (seg->name == name) {
1260- return seg;
1249+ const t_segment_inf* find_segment (const t_arch* arch, std::string_view name) {
1250+ for (const auto & segment : arch->Segments ) {
1251+ if (segment.name == name) {
1252+ return &segment;
12611253 }
12621254 }
12631255
12641256 return nullptr ;
12651257}
12661258
1267- bool segment_exists (const t_arch* arch, std::string name) {
1259+ bool segment_exists (const t_arch* arch, std::string_view name) {
12681260 return find_segment (arch, name) != nullptr ;
12691261}
12701262
@@ -1342,7 +1334,7 @@ const t_pin_to_pin_annotation* find_sequential_annotation(const t_pb_type* pb_ty
13421334 return nullptr ;
13431335}
13441336
1345- const t_pin_to_pin_annotation* find_combinational_annotation (const t_pb_type* pb_type, std::string in_port, std::string out_port) {
1337+ const t_pin_to_pin_annotation* find_combinational_annotation (const t_pb_type* pb_type, std::string_view in_port, std::string_view out_port) {
13461338 for (int iannot = 0 ; iannot < pb_type->num_annotations ; ++iannot) {
13471339 const t_pin_to_pin_annotation* annot = &pb_type->annotations [iannot];
13481340 for (const auto & annot_in_str : vtr::split (annot->input_pins )) {
@@ -1386,24 +1378,24 @@ void link_physical_logical_types(std::vector<t_physical_tile_type>& PhysicalTile
13861378
13871379 std::sort (equivalent_sites.begin (), equivalent_sites.end (), criteria);
13881380
1389- for (auto & logical_block : LogicalBlockTypes) {
1381+ for (t_logical_block_type & logical_block : LogicalBlockTypes) {
13901382 for (auto site : equivalent_sites) {
1391- if (0 == strcmp ( logical_block.name , site->pb_type ->name ) ) {
1383+ if (logical_block.name == site->pb_type ->name ) {
13921384 logical_block.equivalent_tiles .push_back (&physical_tile);
13931385 break ;
13941386 }
13951387 }
13961388 }
13971389 }
13981390
1399- for (auto & logical_block : LogicalBlockTypes) {
1391+ for (t_logical_block_type & logical_block : LogicalBlockTypes) {
14001392 if (logical_block.index == EMPTY_TYPE_INDEX) continue ;
14011393
14021394 auto & equivalent_tiles = logical_block.equivalent_tiles ;
14031395
14041396 if ((int )equivalent_tiles.size () <= 0 ) {
14051397 archfpga_throw (__FILE__, __LINE__,
1406- " Logical Block %s does not have any equivalent tiles.\n " , logical_block.name );
1398+ " Logical Block %s does not have any equivalent tiles.\n " , logical_block.name . c_str () );
14071399 }
14081400
14091401 std::unordered_map<int , bool > ignored_pins_check_map;
@@ -1439,7 +1431,7 @@ void link_physical_logical_types(std::vector<t_physical_tile_type>& PhysicalTile
14391431 if (result == direct_map.end ()) {
14401432 archfpga_throw (__FILE__, __LINE__,
14411433 " Logical pin %d not present in pin mapping between Tile %s and Block %s.\n " ,
1442- pin, tile->name , logical_block.name );
1434+ pin, tile->name . c_str () , logical_block.name . c_str () );
14431435 }
14441436
14451437 int sub_tile_pin_index = result->second .pin ;
@@ -1453,15 +1445,15 @@ void link_physical_logical_types(std::vector<t_physical_tile_type>& PhysicalTile
14531445 archfpga_throw (__FILE__, __LINE__,
14541446 " Physical Tile %s has a different value for the ignored pin (physical pin: %d, logical pin: %d) "
14551447 " different from the corresponding pins of the other equivalent site %s\n ." ,
1456- tile->name , phy_index, pin, logical_block.name );
1448+ tile->name . c_str () , phy_index, pin, logical_block.name . c_str () );
14571449 }
14581450
14591451 auto global_result = global_pins_check_map.insert (std::pair<int , bool >(pin, is_global));
14601452 if (!global_result.second && global_result.first ->second != is_global) {
14611453 archfpga_throw (__FILE__, __LINE__,
14621454 " Physical Tile %s has a different value for the global pin (physical pin: %d, logical pin: %d) "
14631455 " different from the corresponding pins of the other equivalent sites\n ." ,
1464- tile->name , phy_index, pin);
1456+ tile->name . c_str () , phy_index, pin);
14651457 }
14661458 }
14671459 }
@@ -1471,27 +1463,25 @@ void link_physical_logical_types(std::vector<t_physical_tile_type>& PhysicalTile
14711463
14721464/* Sets up the pin classes for the type. */
14731465void setup_pin_classes (t_physical_tile_type* type) {
1474- int i, k;
1475- int pin_count;
14761466 int num_class;
14771467
1478- for (i = 0 ; i < type->num_pins ; i++) {
1468+ for (int i = 0 ; i < type->num_pins ; i++) {
14791469 type->pin_class .push_back (OPEN);
14801470 type->is_ignored_pin .push_back (true );
14811471 type->is_pin_global .push_back (true );
14821472 }
14831473
1484- pin_count = 0 ;
1474+ int pin_count = 0 ;
14851475
14861476 t_class_range class_range;
14871477
14881478 /* Equivalent pins share the same class, non-equivalent pins belong to different pin classes */
1489- for (auto & sub_tile : type->sub_tiles ) {
1479+ for (const t_sub_tile & sub_tile : type->sub_tiles ) {
14901480 int capacity = sub_tile.capacity .total ();
14911481 class_range.low = type->class_inf .size ();
14921482 class_range.high = class_range.low - 1 ;
1493- for (i = 0 ; i < capacity; ++i) {
1494- for (const auto & port : sub_tile.ports ) {
1483+ for (int i = 0 ; i < capacity; ++i) {
1484+ for (const t_physical_tile_port & port : sub_tile.ports ) {
14951485 if (port.equivalent != PortEquivalence::NONE) {
14961486 t_class class_inf;
14971487 num_class = (int )type->class_inf .size ();
@@ -1505,7 +1495,7 @@ void setup_pin_classes(t_physical_tile_type* type) {
15051495 class_inf.type = DRIVER;
15061496 }
15071497
1508- for (k = 0 ; k < port.num_pins ; ++k) {
1498+ for (int k = 0 ; k < port.num_pins ; ++k) {
15091499 class_inf.pinlist .push_back (pin_count);
15101500 type->pin_class [pin_count] = num_class;
15111501 // clock pins and other specified global ports are initially specified
@@ -1525,7 +1515,7 @@ void setup_pin_classes(t_physical_tile_type* type) {
15251515 type->class_inf .push_back (class_inf);
15261516 class_range.high ++;
15271517 } else if (port.equivalent == PortEquivalence::NONE) {
1528- for (k = 0 ; k < port.num_pins ; ++k) {
1518+ for (int k = 0 ; k < port.num_pins ; ++k) {
15291519 t_class class_inf;
15301520 num_class = (int )type->class_inf .size ();
15311521 class_inf.num_pins = 1 ;
@@ -1544,7 +1534,7 @@ void setup_pin_classes(t_physical_tile_type* type) {
15441534 // as ignored pins (i.e. connections are not created in the rr_graph and
15451535 // nets connected to the port are ignored as well).
15461536 type->is_ignored_pin [pin_count] = port.is_clock || port.is_non_clock_global ;
1547- // clock pins and other specified global ports are flaged as global
1537+ // clock pins and other specified global ports are flagged as global
15481538 type->is_pin_global [pin_count] = port.is_clock || port.is_non_clock_global ;
15491539
15501540 if (port.is_clock ) {
0 commit comments