Skip to content

Commit 07f6318

Browse files
author
Nathan Shreve
committed
Created operator int() for vtr::StrongId
1 parent 355f0cb commit 07f6318

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

libs/librrgraph/src/base/rr_spatial_lookup.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,11 @@ void RRSpatialLookup::add_node(RRNodeId node,
272272

273273
if (size_t(ptc) >= rr_node_indices_[type][layer][x][y][side].size()) {
274274
/* Deposit invalid ids to newly allocated elements while original elements are untouched */
275-
rr_node_indices_[type][layer][x][y][side].resize(ptc + 1, int(size_t(RRNodeId::INVALID())));
275+
rr_node_indices_[type][layer][x][y][side].resize(ptc + 1, int(RRNodeId::INVALID()));
276276
}
277277

278278
/* Resize on demand finished; Register the node */
279-
rr_node_indices_[type][layer][x][y][side][ptc] = int(size_t(node));
279+
rr_node_indices_[type][layer][x][y][side][ptc] = int(node);
280280
}
281281

282282
bool RRSpatialLookup::remove_node(RRNodeId node,
@@ -302,7 +302,7 @@ bool RRSpatialLookup::remove_node(RRNodeId node,
302302
if ((size_t)y >= rr_node_indices_[type].dim_size(2)) return false;
303303
if (side >= rr_node_indices_[type].dim_size(3)) return false;
304304
if ((size_t)ptc >= rr_node_indices_[type][layer][x][y][side].size()) return false;
305-
if (rr_node_indices_[type][layer][x][y][side][ptc] != int(size_t(node))) return false;
305+
if (rr_node_indices_[type][layer][x][y][side][ptc] != int(node)) return false;
306306

307307
// The node was in the spatial lookup; remove it. -1 corresponds to an invalid node id,
308308
// and so is treated as absent in the spatial lookup

libs/libvtrutil/src/vtr_strong_id.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ class StrongId {
200200
/// @brief Allow explicit conversion to size_t (e.g. my_vector[size_t(strong_id)])
201201
explicit constexpr operator std::size_t() const { return static_cast<std::size_t>(id_); }
202202

203+
/// @brief Allow explicit conversion to int
204+
explicit constexpr operator int() const { return static_cast<int>(size_t(id_)); }
205+
203206
/// @brief To enable hashing Ids
204207
friend std::hash<StrongId<tag, T, sentinel>>;
205208

vpr/src/place/place.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ std::unique_ptr<FILE, decltype(&vtr::fclose)> f_move_stats_file(nullptr,
212212
"%s,%s," \
213213
"%d,", \
214214
t, \
215-
int(size_t(b_from)), int(size_t(b_to)), \
215+
int(b_from), int(b_to), \
216216
from_type->name, (to_type ? to_type->name : "EMPTY"), \
217217
affected_blocks.num_moved_blocks); \
218218
} \

vpr/src/route/route_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ load_net_terminal_groups(const RRGraphView& rr_graph,
532532
/* TODO: net_terminal_groups cannot be fully RRNodeId - ified, because this code calls libarchfpga which
533533
* I think should not be aware of RRNodeIds. Fixing this requires some refactoring to lift the offending functions
534534
* into VPR. */
535-
std::vector<int> new_group = {int(size_t(rr_node_num))};
535+
std::vector<int> new_group = {int(rr_node_num)};
536536
int new_group_num = net_terminal_groups[net_id].size();
537537
net_terminal_groups[net_id].push_back(new_group);
538538
net_terminal_group_num[net_id][pin_count] = new_group_num;

vpr/src/route/route_debug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void enable_router_debug(
1313
bool active_iteration_debug = (router_opts.router_debug_iteration >= 0);
1414

1515
bool match_net = (ParentNetId(router_opts.router_debug_net) == net || router_opts.router_debug_net == -1);
16-
bool match_sink = (router_opts.router_debug_sink_rr == int(size_t((sink_rr))) || router_opts.router_debug_sink_rr < 0);
16+
bool match_sink = (router_opts.router_debug_sink_rr == int(sink_rr) || router_opts.router_debug_sink_rr < 0);
1717
bool match_iteration = (router_opts.router_debug_iteration == router_iteration || router_opts.router_debug_iteration < 0);
1818

1919
f_router_debug = active_net_debug || active_sink_debug || active_iteration_debug;

0 commit comments

Comments
 (0)