Skip to content

Commit d687349

Browse files
committed
[lib] fixed the bug in I/O of rrgraph. Seems that the ostream require std:string after to_string conversion
1 parent f8ed27a commit d687349

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

libs/librrgraph/src/base/rr_graph_builder.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,18 @@ void RRGraphBuilder::set_node_ptc_nums(RRNodeId node, const std::string& ptc_str
255255
std::string RRGraphBuilder::node_ptc_nums_to_string(RRNodeId node) const {
256256
std::string ret;
257257
if (node_ptc_nums_.empty()) {
258-
ret = std::to_string(node_storage_.node_ptc_num(node));
258+
return std::to_string(node_storage_.node_ptc_num(node));
259259
// VTR_LOG("Node ptc single: %d -> string %s\n", node_storage_.node_ptc_num(node), ret.c_str());
260-
} else {
261-
VTR_ASSERT(size_t(node) < node_ptc_nums_.size());
262-
for (size_t iptc = 0; iptc < node_ptc_nums_[node].size(); iptc++) {
263-
ret += std::to_string(node_ptc_nums_[node][iptc]) + ",";
264-
}
265-
/* Remove the last comma */
266-
ret.pop_back();
267260
}
261+
VTR_ASSERT(size_t(node) < node_ptc_nums_.size());
262+
if (node_ptc_nums_[node].empty()) {
263+
return std::to_string(node_storage_.node_ptc_num(node));
264+
}
265+
for (size_t iptc = 0; iptc < node_ptc_nums_[node].size(); iptc++) {
266+
ret += std::to_string(node_ptc_nums_[node][iptc]) + ",";
267+
}
268+
/* Remove the last comma */
269+
ret.pop_back();
268270
return ret;
269271
}
270272

libs/librrgraph/src/io/gen/rr_graph_uxsdcxx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4020,7 +4020,7 @@ inline void write_node(T &in, std::ostream &os, Context &context){
40204020
auto child_context = in.get_node_loc(context);
40214021
os << "<loc";
40224022
os << " layer=\"" << in.get_node_loc_layer(child_context) << "\"";
4023-
os << " ptc=\"" << in.get_node_loc_ptc(child_context) << "\"";
4023+
os << " ptc=\"" << std::string(in.get_node_loc_ptc(child_context)) << "\"";
40244024
if((bool)in.get_node_loc_side(child_context))
40254025
os << " side=\"" << lookup_loc_side[(int)in.get_node_loc_side(child_context)] << "\"";
40264026
if((bool)in.get_node_loc_twist(child_context))

libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
713713
}
714714

715715
inline const char* get_node_loc_ptc(const t_rr_node& node) final {
716-
std::string ret = rr_graph_builder_->node_ptc_nums_to_string(node.id());
717-
return ret.c_str();
716+
return rr_graph_builder_->node_ptc_nums_to_string(node.id()).c_str();
718717
}
719718
inline int get_node_loc_layer(const t_rr_node& node) final {
720719
return rr_graph_->node_layer(node.id());

0 commit comments

Comments
 (0)