@@ -320,11 +320,6 @@ static void free_pb_type(t_pb_type* pb_type) {
320320 vtr::free (pb_type->modes [i].interconnect [j].output_string );
321321 vtr::free (pb_type->modes [i].interconnect [j].name );
322322
323- for (t_pin_to_pin_annotation& annotation : pb_type->modes [i].interconnect [j].annotations ) {
324- vtr::free (annotation.clock );
325- vtr::free (annotation.input_pins );
326- vtr::free (annotation.output_pins );
327- }
328323 pb_type->modes [i].interconnect [j].annotations .clear ();
329324 delete pb_type->modes [i].interconnect [j].interconnect_power ;
330325 }
@@ -333,12 +328,6 @@ static void free_pb_type(t_pb_type* pb_type) {
333328 }
334329
335330 delete[] pb_type->modes ;
336-
337- for (t_pin_to_pin_annotation& annotation : pb_type->annotations ) {
338- vtr::free (annotation.input_pins );
339- vtr::free (annotation.output_pins );
340- vtr::free (annotation.clock );
341- }
342331 pb_type->annotations .clear ();
343332
344333 delete pb_type->pb_type_power ;
@@ -439,13 +428,11 @@ std::unordered_set<t_logical_block_type_ptr> get_equivalent_sites_set(t_physical
439428}
440429
441430void alloc_and_load_default_child_for_pb_type (t_pb_type* pb_type,
442- char * new_name,
431+ std::string_view new_name,
443432 t_pb_type* copy) {
444- char * dot;
445-
446433 VTR_ASSERT (pb_type->blif_model != nullptr );
447434
448- copy->name = vtr::strdup (new_name);
435+ copy->name = vtr::strdup (new_name. data () );
449436 copy->blif_model = vtr::strdup (pb_type->blif_model );
450437 copy->class_type = pb_type->class_type ;
451438 copy->depth = pb_type->depth ;
@@ -482,8 +469,7 @@ void alloc_and_load_default_child_for_pb_type(t_pb_type* pb_type,
482469 if (copy->pb_type_power ->estimation_method == POWER_METHOD_AUTO_SIZES) {
483470 copy->ports [i].port_power ->wire_type = POWER_WIRE_TYPE_AUTO;
484471 copy->ports [i].port_power ->buffer_type = POWER_BUFFER_TYPE_AUTO;
485- } else if (copy->pb_type_power ->estimation_method
486- == POWER_METHOD_SPECIFY_SIZES) {
472+ } else if (copy->pb_type_power ->estimation_method == POWER_METHOD_SPECIFY_SIZES) {
487473 copy->ports [i].port_power ->wire_type = POWER_WIRE_TYPE_IGNORED;
488474 copy->ports [i].port_power ->buffer_type = POWER_BUFFER_TYPE_NONE;
489475 }
@@ -492,20 +478,18 @@ void alloc_and_load_default_child_for_pb_type(t_pb_type* pb_type,
492478 size_t num_annotations = pb_type->annotations .size ();
493479 copy->annotations .resize (num_annotations);
494480 for (size_t i = 0 ; i < num_annotations; i++) {
495- copy->annotations [i].clock = vtr::strdup (pb_type->annotations [i].clock );
496- dot = strstr (pb_type->annotations [i].input_pins , " ." );
497- copy->annotations [i].input_pins = (char *)vtr::malloc (sizeof (char ) * (strlen (new_name) + strlen (dot) + 1 ));
498- copy->annotations [i].input_pins [0 ] = ' \0 ' ;
499- strcat (copy->annotations [i].input_pins , new_name);
500- strcat (copy->annotations [i].input_pins , dot);
501- if (pb_type->annotations [i].output_pins != nullptr ) {
502- dot = strstr (pb_type->annotations [i].output_pins , " ." );
503- copy->annotations [i].output_pins = (char *)vtr::malloc (sizeof (char ) * (strlen (new_name) + strlen (dot) + 1 ));
504- copy->annotations [i].output_pins [0 ] = ' \0 ' ;
505- strcat (copy->annotations [i].output_pins , new_name);
506- strcat (copy->annotations [i].output_pins , dot);
481+ copy->annotations [i].clock = pb_type->annotations [i].clock ;
482+
483+ auto dot_pos = pb_type->annotations [i].input_pins .find (' .' );
484+ VTR_ASSERT_MSG (dot_pos != std::string::npos, " Expected '.' in input_pins" );
485+ copy->annotations [i].input_pins = std::string (new_name) + pb_type->annotations [i].input_pins .substr (dot_pos);
486+
487+ if (!pb_type->annotations [i].output_pins .empty ()) {
488+ dot_pos = pb_type->annotations [i].output_pins .find (' .' );
489+ VTR_ASSERT_MSG (dot_pos != std::string::npos, " Expected '.' in output_pins" );
490+ copy->annotations [i].output_pins = std::string (new_name) + pb_type->annotations [i].output_pins .substr (dot_pos);
507491 } else {
508- copy->annotations [i].output_pins = nullptr ;
492+ copy->annotations [i].output_pins . clear () ;
509493 }
510494 copy->annotations [i].line_num = pb_type->annotations [i].line_num ;
511495 copy->annotations [i].format = pb_type->annotations [i].format ;
@@ -572,9 +556,9 @@ void ProcessLutClass(t_pb_type* lut_pb_type) {
572556 size_t num_annotations = lut_pb_type->annotations .size ();
573557 lut_pb_type->modes [0 ].interconnect [0 ].annotations .resize (num_annotations);
574558 for (size_t i = 0 ; i < num_annotations; i++) {
575- lut_pb_type->modes [0 ].interconnect [0 ].annotations [i].clock = vtr::strdup ( lut_pb_type->annotations [i].clock ) ;
576- lut_pb_type->modes [0 ].interconnect [0 ].annotations [i].input_pins = vtr::strdup ( lut_pb_type->annotations [i].input_pins ) ;
577- lut_pb_type->modes [0 ].interconnect [0 ].annotations [i].output_pins = vtr::strdup ( lut_pb_type->annotations [i].output_pins ) ;
559+ lut_pb_type->modes [0 ].interconnect [0 ].annotations [i].clock = lut_pb_type->annotations [i].clock ;
560+ lut_pb_type->modes [0 ].interconnect [0 ].annotations [i].input_pins = lut_pb_type->annotations [i].input_pins ;
561+ lut_pb_type->modes [0 ].interconnect [0 ].annotations [i].output_pins =lut_pb_type->annotations [i].output_pins ;
578562 lut_pb_type->modes [0 ].interconnect [0 ].annotations [i].line_num = lut_pb_type->annotations [i].line_num ;
579563 lut_pb_type->modes [0 ].interconnect [0 ].annotations [i].format = lut_pb_type->annotations [i].format ;
580564 lut_pb_type->modes [0 ].interconnect [0 ].annotations [i].type = lut_pb_type->annotations [i].type ;
@@ -592,12 +576,6 @@ void ProcessLutClass(t_pb_type* lut_pb_type) {
592576 lut_pb_type->modes [1 ].pb_type_children = new t_pb_type[1 ];
593577 alloc_and_load_default_child_for_pb_type (lut_pb_type, default_name,
594578 lut_pb_type->modes [1 ].pb_type_children );
595- /* moved annotations to child so delete old annotations */
596- for (size_t i = 0 ; i < num_annotations; i++) {
597- vtr::free (lut_pb_type->annotations [i].input_pins );
598- vtr::free (lut_pb_type->annotations [i].output_pins );
599- vtr::free (lut_pb_type->annotations [i].clock );
600- }
601579 lut_pb_type->annotations .clear ();
602580 lut_pb_type->modes [1 ].pb_type_children [0 ].depth = lut_pb_type->depth + 1 ;
603581 lut_pb_type->modes [1 ].pb_type_children [0 ].parent_mode = &lut_pb_type->modes [1 ];
@@ -962,8 +940,7 @@ void primitives_annotation_clock_match(t_pin_to_pin_annotation* annotation,
962940
963941 for (i_port = 0 ; i_port < parent_pb_type->num_ports ; i_port++) {
964942 if (parent_pb_type->ports [i_port].is_clock ) {
965- if (strcmp (parent_pb_type->ports [i_port].name , annotation->clock )
966- == 0 ) {
943+ if (parent_pb_type->ports [i_port].name == annotation->clock ) {
967944 clock_valid = true ;
968945 break ;
969946 }
0 commit comments