Skip to content

Commit f0e8378

Browse files
call c_str() on name member variable when necessary
1 parent 8ef3b02 commit f0e8378

17 files changed

+43
-43
lines changed

libs/libarchfpga/src/arch_util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ t_port* findPortByName(const char* name, t_pb_type* pb_type, int* high_index, in
517517

518518
t_physical_tile_type get_empty_physical_type(const char* name /*= EMPTY_BLOCK_NAME*/) {
519519
t_physical_tile_type type;
520-
type.name = vtr::strdup(name);
520+
type.name = name;
521521
type.num_pins = 0;
522522
type.width = 1;
523523
type.height = 1;

libs/libarchfpga/src/physical_types.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ int t_physical_tile_type::get_sub_tile_loc_from_pin(int pin_num) const {
133133
}
134134

135135
bool t_physical_tile_type::is_empty() const {
136-
return std::string(name) == std::string(EMPTY_BLOCK_NAME);
136+
return name == std::string(EMPTY_BLOCK_NAME);
137137
}
138138

139139
/*

libs/libarchfpga/src/read_fpga_interchange_arch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,7 +1969,7 @@ struct ArchReader {
19691969
if (!has_valid_sites)
19701970
continue;
19711971

1972-
ptype.name = vtr::strdup(name.c_str());
1972+
ptype.name = name;
19731973
ptype.index = ++index;
19741974
ptype.width = ptype.height = ptype.area = 1;
19751975
ptype.capacity = 0;
@@ -2199,7 +2199,7 @@ struct ArchReader {
21992199
std::vector<std::pair<std::string, std::string>> const_cells{arch_->gnd_cell, arch_->vcc_cell};
22002200
// Create constant tile
22012201
t_physical_tile_type constant;
2202-
constant.name = vtr::strdup(const_block_.c_str());
2202+
constant.name = const_block_;
22032203
constant.index = ptypes_.size();
22042204
constant.width = constant.height = constant.area = 1;
22052205
constant.capacity = 1;

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2999,7 +2999,7 @@ static void ProcessTileProps(pugi::xml_node Node,
29992999

30003000
/* Load type name */
30013001
auto Prop = get_attribute(Node, "name", loc_data).value();
3002-
PhysicalTileType->name = vtr::strdup(Prop);
3002+
PhysicalTileType->name = Prop;
30033003

30043004
/* Load properties */
30053005
PhysicalTileType->width = get_attribute(Node, "width", loc_data, ReqOpt::OPTIONAL).as_uint(1);

libs/librrgraph/src/base/check_rr_graph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ void check_rr_graph(const RRGraphView& rr_graph,
285285
continue;
286286
}
287287
VTR_LOG_ERROR("in check_rr_graph: node %d (%s) at (%d,%d) block=%s side=%s pin=%s has no fanin.\n",
288-
inode, rr_graph.node_type_string(rr_node), rr_graph.node_xlow(rr_node), rr_graph.node_ylow(rr_node), block_type->name, TOTAL_2D_SIDE_STRINGS[node_side], pin_name.c_str());
288+
inode, rr_graph.node_type_string(rr_node), rr_graph.node_xlow(rr_node), rr_graph.node_ylow(rr_node), block_type->name.c_str(), TOTAL_2D_SIDE_STRINGS[node_side], pin_name.c_str());
289289
}
290290
}
291291
} else {

libs/librrgraph/src/utils/alloc_and_load_rr_indexed_data.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,9 +748,9 @@ static void print_rr_index_info(const vtr::vector<RRIndexedDataId, t_rr_indexed_
748748
} else if (cost_index == IPIN_COST_INDEX) {
749749
string_stream << cost_index << " IPIN";
750750
} else if (cost_index <= IPIN_COST_INDEX + y_chan_cost_offset) {
751-
string_stream << cost_index << " CHANX " << segment_inf[index_data.seg_index].name.c_str();
751+
string_stream << cost_index << " CHANX " << segment_inf[index_data.seg_index].name;
752752
} else {
753-
string_stream << cost_index << " CHANY " << segment_inf[index_data.seg_index].name.c_str();
753+
string_stream << cost_index << " CHANY " << segment_inf[index_data.seg_index].name;
754754
}
755755

756756
std::string cost_index_str = string_stream.str();

utils/fasm/src/fasm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void FasmWriterVisitor::visit_clb_impl(ClusterBlockId blk_id, const t_pb* clb) {
9898
vpr_throw(VPR_ERROR_OTHER,
9999
__FILE__, __LINE__,
100100
"number of fasm_prefix (%s) options (%d) for block (%s) must match capacity(%d)",
101-
prefix_unsplit.c_str(), fasm_prefixes.size(), physical_tile_->name, physical_tile_->capacity);
101+
prefix_unsplit.c_str(), fasm_prefixes.size(), physical_tile_->name.c_str(), physical_tile_->capacity);
102102
}
103103
grid_prefix = fasm_prefixes[sub_tile];
104104
blk_prefix_ = grid_prefix + ".";

utils/fasm/test/test_fasm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static std::string get_pin_feature (size_t inode) {
228228

229229
if (sub_tile_pin >= pin_lo && sub_tile_pin < pin_hi) {
230230
int port_pin = sub_tile_pin - pin_lo;
231-
return vtr::string_fmt("PIN_%d_%d_%s_%s_%d", ilow, jlow, sub_tile_type->name, port.name, port_pin);
231+
return vtr::string_fmt("PIN_%d_%d_%s_%s_%d", ilow, jlow, sub_tile_type->name.c_str(), port.name, port_pin);
232232
}
233233
}
234234

vpr/src/base/SetupGrid.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -424,15 +424,15 @@ static DeviceGrid build_device_grid(const t_grid_def& grid_def, size_t grid_widt
424424
if (startx > grid_width - 1) {
425425
if (warn_out_of_range) {
426426
VTR_LOG_WARN("Block type '%s' grid location specification startx (%s = %d) falls outside device horizontal range [%d,%d]\n",
427-
type->name, xspec.start_expr.c_str(), startx, 0, grid_width - 1);
427+
type->name.c_str(), xspec.start_expr.c_str(), startx, 0, grid_width - 1);
428428
}
429429
continue; //No instances will be created
430430
}
431431

432432
if (starty > grid_height - 1) {
433433
if (warn_out_of_range) {
434434
VTR_LOG_WARN("Block type '%s' grid location specification starty (%s = %d) falls outside device vertical range [%d,%d]\n",
435-
type->name, yspec.start_expr.c_str(), starty, 0, grid_height - 1);
435+
type->name.c_str(), yspec.start_expr.c_str(), starty, 0, grid_height - 1);
436436
}
437437
continue; //No instances will be created
438438
}
@@ -441,28 +441,28 @@ static DeviceGrid build_device_grid(const t_grid_def& grid_def, size_t grid_widt
441441
if (endx > grid_width - 1) {
442442
if (warn_out_of_range) {
443443
VTR_LOG_WARN("Block type '%s' grid location specification endx (%s = %d) falls outside device horizontal range [%d,%d]\n",
444-
type->name, xspec.end_expr.c_str(), endx, 0, grid_width - 1);
444+
type->name.c_str(), xspec.end_expr.c_str(), endx, 0, grid_width - 1);
445445
}
446446
}
447447

448448
if (endy > grid_height - 1) {
449449
if (warn_out_of_range) {
450450
VTR_LOG_WARN("Block type '%s' grid location specification endy (%s = %d) falls outside device vertical range [%d,%d]\n",
451-
type->name, yspec.end_expr.c_str(), endy, 0, grid_height - 1);
451+
type->name.c_str(), yspec.end_expr.c_str(), endy, 0, grid_height - 1);
452452
}
453453
}
454454

455455
//The end must fall after (or equal) to the start
456456
if (endx < startx) {
457457
VPR_FATAL_ERROR(VPR_ERROR_ARCH,
458458
"Grid location specification endx (%s = %d) can not come before startx (%s = %d) for block type '%s'",
459-
xspec.end_expr.c_str(), endx, xspec.start_expr.c_str(), startx, type->name);
459+
xspec.end_expr.c_str(), endx, xspec.start_expr.c_str(), startx, type->name.c_str());
460460
}
461461

462462
if (endy < starty) {
463463
VPR_FATAL_ERROR(VPR_ERROR_ARCH,
464464
"Grid location specification endy (%s = %d) can not come before starty (%s = %d) for block type '%s'",
465-
yspec.end_expr.c_str(), endy, yspec.start_expr.c_str(), starty, type->name);
465+
yspec.end_expr.c_str(), endy, yspec.start_expr.c_str(), starty, type->name.c_str());
466466
}
467467

468468
//The minimum increment is the block dimension
@@ -471,15 +471,15 @@ static DeviceGrid build_device_grid(const t_grid_def& grid_def, size_t grid_widt
471471
VPR_FATAL_ERROR(VPR_ERROR_ARCH,
472472
"Grid location specification incrx for block type '%s' must be at least"
473473
" block width (%d) to avoid overlapping instances (was %s = %d)",
474-
type->name, type->width, xspec.incr_expr.c_str(), incrx);
474+
type->name.c_str(), type->width, xspec.incr_expr.c_str(), incrx);
475475
}
476476

477477
VTR_ASSERT(type->height > 0);
478478
if (incry < size_t(type->height)) {
479479
VPR_FATAL_ERROR(VPR_ERROR_ARCH,
480480
"Grid location specification incry for block type '%s' must be at least"
481481
" block height (%d) to avoid overlapping instances (was %s = %d)",
482-
type->name, type->height, yspec.incr_expr.c_str(), incry);
482+
type->name.c_str(), type->height, yspec.incr_expr.c_str(), incry);
483483
}
484484

485485
//The minimum repeat is the region dimension
@@ -488,15 +488,15 @@ static DeviceGrid build_device_grid(const t_grid_def& grid_def, size_t grid_widt
488488
VPR_FATAL_ERROR(VPR_ERROR_ARCH,
489489
"Grid location specification repeatx for block type '%s' must be at least"
490490
" the region width (%d) to avoid overlapping instances (was %s = %d)",
491-
type->name, region_width, xspec.repeat_expr.c_str(), repeatx);
491+
type->name.c_str(), region_width, xspec.repeat_expr.c_str(), repeatx);
492492
}
493493

494494
size_t region_height = endy - starty + 1; //+1 since start/end are both inclusive
495495
if (repeaty < region_height) {
496496
VPR_FATAL_ERROR(VPR_ERROR_ARCH,
497497
"Grid location specification repeaty for block type '%s' must be at least"
498498
" the region height (%d) to avoid overlapping instances (was %s = %d)",
499-
type->name, region_height, xspec.repeat_expr.c_str(), repeaty);
499+
type->name.c_str(), region_height, xspec.repeat_expr.c_str(), repeaty);
500500
}
501501

502502
//VTR_LOG("Applying grid_loc_def for '%s' priority %d startx=%s=%zu, endx=%s=%zu, starty=%s=%zu, endx=%s=%zu,\n",
@@ -538,7 +538,7 @@ static DeviceGrid build_device_grid(const t_grid_def& grid_def, size_t grid_widt
538538

539539
if (!seen_types.count(&type)) {
540540
VTR_LOG_WARN("Block type '%s' was not specified in device grid layout\n",
541-
type.name);
541+
type.name.c_str());
542542
}
543543
}
544544

@@ -610,8 +610,8 @@ static void set_grid_block_type(int priority,
610610
" Existing block type '%s' at (%zu,%zu) has the same priority (%d) as new overlapping type '%s'."
611611
" The last specification will apply.\n",
612612
x_root, y_root,
613-
max_priority_type_loc.type->name, max_priority_type_loc.x, max_priority_type_loc.y,
614-
priority, type->name);
613+
max_priority_type_loc.type->name.c_str(), max_priority_type_loc.x, max_priority_type_loc.y,
614+
priority, type->name.c_str());
615615
}
616616

617617
//Mark all the grid tiles 'covered' by this block with the appropriate type
@@ -733,19 +733,19 @@ static void CheckGrid(const DeviceGrid& grid) {
733733
if (tile_type != type) {
734734
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
735735
"Grid Location (%d,%d,%d) should have type '%s' (based on root location) but has type '%s'\n",
736-
i, j, layer_num, type->name, type->name);
736+
i, j, layer_num, type->name.c_str(), type->name.c_str());
737737
}
738738

739739
if (tile_width_offset != x_offset) {
740740
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
741741
"Grid Location (%d,%d,%d) of type '%s' should have width offset '%d' (based on root location) but has '%d'\n",
742-
i, j, layer_num, type->name, x_offset, tile_width_offset);
742+
i, j, layer_num, type->name.c_str(), x_offset, tile_width_offset);
743743
}
744744

745745
if (tile_height_offset != y_offset) {
746746
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
747747
"Grid Location (%d,%d,%d) of type '%s' should have height offset '%d' (based on root location) but has '%d'\n",
748-
i, j, layer_num, type->name, y_offset, tile_height_offset);
748+
i, j, layer_num, type->name.c_str(), y_offset, tile_height_offset);
749749
}
750750
}
751751
}

vpr/src/base/vpr_api.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ void vpr_create_device_grid(const t_vpr_setup& vpr_setup, const t_arch& Arch) {
494494
if (is_empty_type(&type)) continue;
495495

496496
VTR_LOG("\tNetlist\n\t\t%d\tblocks of type: %s\n",
497-
num_type_instances[&type], type.name);
497+
num_type_instances[&type], type.name.c_str());
498498

499499
VTR_LOG("\tArchitecture\n");
500500
for (const auto equivalent_tile : type.equivalent_tiles) {
@@ -503,7 +503,7 @@ void vpr_create_device_grid(const t_vpr_setup& vpr_setup, const t_arch& Arch) {
503503
num_instances = (int)device_ctx.grid.num_instances(equivalent_tile, -1);
504504

505505
VTR_LOG("\t\t%d\tblocks of type: %s\n",
506-
num_instances, equivalent_tile->name);
506+
num_instances, equivalent_tile->name.c_str());
507507
}
508508
}
509509
VTR_LOG("\n");
@@ -516,7 +516,7 @@ void vpr_create_device_grid(const t_vpr_setup& vpr_setup, const t_arch& Arch) {
516516
}
517517

518518
if (device_ctx.grid.num_instances(&type, -1) != 0) {
519-
VTR_LOG("\tPhysical Tile %s:\n", type.name);
519+
VTR_LOG("\tPhysical Tile %s:\n", type.name.c_str());
520520

521521
auto equivalent_sites = get_equivalent_sites_set(&type);
522522

@@ -526,7 +526,7 @@ void vpr_create_device_grid(const t_vpr_setup& vpr_setup, const t_arch& Arch) {
526526
if (num_inst != 0) {
527527
util = float(num_type_instances[logical_block]) / num_inst;
528528
}
529-
VTR_LOG("\tBlock Utilization: %.2f Logical Block: %s\n", util, logical_block->name);
529+
VTR_LOG("\tBlock Utilization: %.2f Logical Block: %s\n", util, logical_block->name.c_str());
530530
}
531531
}
532532
}

vpr/src/base/vpr_types.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ std::string t_ext_pin_util_targets::to_string() const {
139139
for (unsigned int itype = 0; itype < device_ctx.physical_tile_types.size(); ++itype) {
140140
if (is_empty_type(&device_ctx.physical_tile_types[itype])) continue;
141141

142-
auto blk_name = device_ctx.physical_tile_types[itype].name;
142+
const std::string& blk_name = device_ctx.physical_tile_types[itype].name;
143143

144144
ss << blk_name << ":";
145145

@@ -264,7 +264,7 @@ std::string t_pack_high_fanout_thresholds::to_string() const {
264264
for (unsigned int itype = 0; itype < device_ctx.physical_tile_types.size(); ++itype) {
265265
if (is_empty_type(&device_ctx.physical_tile_types[itype])) continue;
266266

267-
auto blk_name = device_ctx.physical_tile_types[itype].name;
267+
const std::string& blk_name = device_ctx.physical_tile_types[itype].name;
268268

269269
ss << blk_name << ":";
270270

vpr/src/place/place_macro.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ static void mark_direct_of_ports(int idirect,
468468
for (int itype = 1; itype < (int)device_ctx.physical_tile_types.size(); itype++) {
469469
auto& physical_tile = device_ctx.physical_tile_types[itype];
470470
// Find blocks with the same pb_type_name
471-
if (pb_type_name == physical_tile.name ) {
471+
if (pb_type_name == physical_tile.name) {
472472
int num_sub_tiles = physical_tile.sub_tiles.size();
473473
for (int isub_tile = 0; isub_tile < num_sub_tiles; isub_tile++) {
474474
auto& ports = physical_tile.sub_tiles[isub_tile].ports;

vpr/src/place/timing_place_lookup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ static vtr::NdMatrix<float, 4> compute_delta_delays(
735735
auto type = grid.get_physical_type({x, y, from_layer_num});
736736

737737
if (type != device_ctx.EMPTY_PHYSICAL_TILE_TYPE) {
738-
if (!allowed_types.empty() && allowed_types.find(std::string(type->name)) == allowed_types.end()) {
738+
if (!allowed_types.empty() && allowed_types.find(type->name) == allowed_types.end()) {
739739
continue;
740740
}
741741
src_type = type;
@@ -779,7 +779,7 @@ static vtr::NdMatrix<float, 4> compute_delta_delays(
779779
auto type = grid.get_physical_type({x, y, from_layer_num});
780780

781781
if (type != device_ctx.EMPTY_PHYSICAL_TILE_TYPE) {
782-
if (!allowed_types.empty() && allowed_types.find(std::string(type->name)) == allowed_types.end()) {
782+
if (!allowed_types.empty() && allowed_types.find(type->name) == allowed_types.end()) {
783783
continue;
784784
}
785785
src_type = type;

vpr/src/route/overuse_report.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ static void log_single_overused_node_status(int overuse_index, RRNodeId node_id)
418418
VTR_LOG(" %7d", rr_graph.node_ptc_num(node_id));
419419

420420
// Block Name
421-
VTR_LOG(" %7s", physical_blk->name);
421+
VTR_LOG(" %7s", physical_blk->name.c_str());
422422

423423
//X_low
424424
VTR_LOG(" %7d", x);

vpr/src/route/router_lookahead_map_utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ t_src_opin_delays compute_router_src_opin_lookahead(bool is_flat) {
412412
VTR_LOG_WARN("Found no %ssample locations for %s in %s\n",
413413
(num_sampled_locs == 0) ? "" : "more ",
414414
rr_node_typename[rr_type],
415-
device_ctx.physical_tile_types[itile].name);
415+
device_ctx.physical_tile_types[itile].name.c_str());
416416
break;
417417
}
418418

@@ -491,7 +491,7 @@ t_chan_ipins_delays compute_router_chan_ipin_lookahead() {
491491
if (sample_loc.x == OPEN && sample_loc.y == OPEN && sample_loc.layer_num == OPEN) {
492492
//No untried instances of the current tile type left
493493
VTR_LOG_WARN("Found no sample locations for %s\n",
494-
tile_type.name);
494+
tile_type.name.c_str());
495495
continue;
496496
}
497497

vpr/src/util/vpr_utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ void sync_grid_to_blocks() {
136136
if (type != device_ctx.grid.get_physical_type({blk_x, blk_y, blk_layer})) {
137137
VPR_FATAL_ERROR(VPR_ERROR_PLACE, "A block is in a grid location (%d x %d) layer (%d) with a conflicting types '%s' and '%s' .\n",
138138
blk_x, blk_y, blk_layer,
139-
type->name,
140-
device_ctx.grid.get_physical_type({blk_x, blk_y, blk_layer})->name);
139+
type->name.c_str(),
140+
device_ctx.grid.get_physical_type({blk_x, blk_y, blk_layer})->name.c_str());
141141
}
142142

143143
/* Check already in use */
@@ -1810,7 +1810,7 @@ t_physical_tile_port find_tile_port_by_name(t_physical_tile_type_ptr type, std::
18101810
}
18111811

18121812
// Port has not been found, throw an error.
1813-
VPR_THROW(VPR_ERROR_ARCH, "Unable to find port %s (on block %s).\n", port_name, type->name);
1813+
VPR_THROW(VPR_ERROR_ARCH, "Unable to find port %s (on block %s).\n", port_name, type->name.c_str());
18141814
}
18151815

18161816
void pretty_print_uint(const char* prefix, size_t value, int num_digits, int scientific_precision) {

vpr/test/test_interchange_device.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ TEST_CASE("read_interchange_tiles", "[vpr]") {
113113
std::unordered_set<std::string> ptypes = {"EMPTY", "IOB", "IB", "OB", "CLB", "constant_block"};
114114

115115
// Check that there are exactly the expected models
116-
for (auto ptype : physical_tile_types) {
117-
std::string name = ptype.name;
116+
for (const t_physical_tile_type& ptype : physical_tile_types) {
117+
const std::string& name = ptype.name;
118118
REQUIRE(ptypes.find(name) != ptypes.end());
119119
ptypes.erase(name);
120120

0 commit comments

Comments
 (0)