Skip to content

Commit 55f1490

Browse files
authored
Merge pull request #2862 from verilog-to-routing/increase_cpp_ver_20
Increase C++ version from 17 to 20
2 parents bb0005c + f7c8c2d commit 55f1490

23 files changed

+53
-49
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,6 @@ jobs:
439439
- { name: 'GCC 11 (Ubuntu Noble - 24.04)', eval: 'CC=gcc-11 && CXX=g++-11', }
440440
- { name: 'GCC 12 (Ubuntu Noble - 24.04)', eval: 'CC=gcc-12 && CXX=g++-12', }
441441
- { name: 'GCC 14 (Ubuntu Noble - 24.04)', eval: 'CC=gcc-14 && CXX=g++-14', }
442-
- { name: 'Clang 15 (Ubuntu Noble - 24.04)', eval: 'CC=clang-15 && CXX=clang++-15', }
443442
- { name: 'Clang 16 (Ubuntu Noble - 24.04)', eval: 'CC=clang-16 && CXX=clang++-16', }
444443
- { name: 'Clang 17 (Ubuntu Noble - 24.04)', eval: 'CC=clang-17 && CXX=clang++-17', }
445444
- { name: 'Clang 18 (Ubuntu Noble - 24.04)', eval: 'CC=clang-18 && CXX=clang++-18', }

CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ add_definitions("-DVTR_ASSERT_LEVEL=${VTR_ASSERT_LEVEL}")
9393
include(CheckCXXCompilerFlag)
9494

9595
#
96-
# We require c++17 support
96+
# We require c++20 support
9797
#
98-
set(CMAKE_CXX_STANDARD 17)
98+
set(CMAKE_CXX_STANDARD 20)
9999
set(CMAKE_CXX_STANDARD_REQUIRED ON)
100100
set(CMAKE_CXX_EXTENSIONS OFF) #No compiler specific extensions
101101

@@ -160,7 +160,7 @@ else()
160160
"-Wcast-align" #Warn if a cast causes memory alignment changes
161161
"-Wshadow" #Warn if local variable shadows another variable
162162
"-Wformat=2" #Sanity checks for printf-like formatting
163-
"-Wno-format-nonliteral" # But don't worry about non-literal formtting (i.e. run-time printf format strings)
163+
"-Wno-format-nonliteral" # But don't worry about non-literal formatting (i.e. run-time printf format strings)
164164
"-Wlogical-op" #Checks for logical op when bit-wise expected
165165
"-Wmissing-declarations" #Warn if a global function is defined with no declaration
166166
"-Wmissing-include-dirs" #Warn if a user include directory is missing
@@ -178,10 +178,10 @@ else()
178178
"-Wduplicated-cond" #Warn about identical conditions in if-else chains
179179
"-Wduplicated-branches" #Warn when different branches of an if-else chain are equivalent
180180
"-Wnull-dereference" #Warn about null pointer dereference execution paths
181-
"-Wuninitialized" #Warn about unitialized values
181+
"-Wuninitialized" #Warn about uninitialized values
182182
"-Winit-self" #Warn about self-initialization
183183
"-Wcatch-value=3" #Warn when catch statements don't catch by reference
184-
"-Wextra-semi" #Warn about redudnant semicolons
184+
"-Wextra-semi" #Warn about redundant semicolons
185185
"-Wimplicit-fallthrough=3" #Warn about case fallthroughs, but allow 'fallthrough' comments to suppress warnings
186186
#GCC-like optional
187187
#"-Wsuggest-final-types" #Suggest where 'final' would help if specified on a type methods

libs/EXTERNAL/libezgl/include/ezgl/point.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class point2d {
3636
/**
3737
* Create a point at the given x and y position.
3838
*/
39-
point2d(double x_coord, double y_coord) : x(x_coord), y(y_coord)
39+
point2d(double x_coord, double y_coord) noexcept : x(x_coord), y(y_coord)
4040
{
4141
}
4242

libs/EXTERNAL/libezgl/include/ezgl/rectangle.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class rectangle {
3333
/**
3434
* Default constructor: Create a zero-sized rectangle at {0,0}.
3535
*/
36-
rectangle() : m_first({0, 0}), m_second({0, 0})
36+
rectangle() noexcept : m_first({0, 0}), m_second({0, 0})
3737
{
3838
}
3939

libs/EXTERNAL/libtatum/libtatum/tatum/util/tatum_strong_id.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ template<typename tag, typename T, T sentinel>
161161
bool operator!=(const StrongId<tag,T,sentinel>& lhs, const StrongId<tag,T,sentinel>& rhs);
162162

163163
template<typename tag, typename T, T sentinel>
164-
bool operator<(const StrongId<tag,T,sentinel>& lhs, const StrongId<tag,T,sentinel>& rhs);
164+
bool operator<(const StrongId<tag,T,sentinel>& lhs, const StrongId<tag,T,sentinel>& rhs) noexcept;
165165

166166

167167
//Class template definition with default template parameters
@@ -198,7 +198,7 @@ class StrongId {
198198
// after the function name (i.e. <>)
199199
friend bool operator== <>(const StrongId<tag,T,sentinel>& lhs, const StrongId<tag,T,sentinel>& rhs);
200200
friend bool operator!= <>(const StrongId<tag,T,sentinel>& lhs, const StrongId<tag,T,sentinel>& rhs);
201-
friend bool operator< <>(const StrongId<tag,T,sentinel>& lhs, const StrongId<tag,T,sentinel>& rhs);
201+
friend bool operator< <>(const StrongId<tag,T,sentinel>& lhs, const StrongId<tag,T,sentinel>& rhs) noexcept;
202202
private:
203203
T id_;
204204
};
@@ -215,7 +215,7 @@ bool operator!=(const StrongId<tag,T,sentinel>& lhs, const StrongId<tag,T,sentin
215215

216216
//Needed for std::map-like containers
217217
template<typename tag, typename T, T sentinel>
218-
bool operator<(const StrongId<tag,T,sentinel>& lhs, const StrongId<tag,T,sentinel>& rhs) {
218+
bool operator<(const StrongId<tag,T,sentinel>& lhs, const StrongId<tag,T,sentinel>& rhs) noexcept {
219219
return lhs.id_ < rhs.id_;
220220
}
221221

libs/libarchfpga/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ target_link_libraries(libarchfpga
2626

2727
if(${VTR_ENABLE_CAPNPROTO})
2828
target_link_libraries(libarchfpga libvtrcapnproto)
29+
find_package(ZLIB REQUIRED)
30+
target_link_libraries(libarchfpga ZLIB::ZLIB)
2931
target_compile_definitions(libarchfpga PRIVATE VTR_ENABLE_CAPNPROTO)
3032
endif()
3133

libs/libarchfpga/src/cad_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ struct t_pack_patterns {
104104
std::vector<std::vector<t_pb_graph_pin*>> chain_root_pins;
105105

106106
// default constructor initializing to an invalid pack pattern
107-
t_pack_patterns() {
107+
t_pack_patterns() noexcept {
108108
name = nullptr;
109109
index = -1;
110110
root_block = nullptr;

libs/libarchfpga/src/parse_switchblocks.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@
44
*
55
*
66
* A large chunk of this file is dedicated to helping parse the initial switchblock
7-
* specificaiton in the XML arch file, providing error checking, etc.
7+
* specification in the XML arch file, providing error checking, etc.
88
*
99
* Another large chunk of this file is dedicated to parsing the actual formulas
1010
* specified by the switch block permutation functions into their numeric counterparts.
1111
*/
1212

13-
#include <string.h>
13+
#include <cstring>
1414
#include <string>
15-
#include <sstream>
1615
#include <vector>
17-
#include <stack>
18-
#include <utility>
19-
#include <algorithm>
2016

2117
#include "vtr_assert.h"
2218
#include "vtr_util.h"
@@ -26,9 +22,7 @@
2622

2723
#include "arch_error.h"
2824

29-
#include "read_xml_util.h"
3025
#include "arch_util.h"
31-
#include "arch_types.h"
3226
#include "physical_types.h"
3327
#include "parse_switchblocks.h"
3428

libs/libarchfpga/src/physical_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ enum class e_sb_type;
9595
// Metadata value storage.
9696
class t_metadata_value {
9797
public:
98-
explicit t_metadata_value(vtr::interned_string v)
98+
explicit t_metadata_value(vtr::interned_string v) noexcept
9999
: value_(v) {}
100100
explicit t_metadata_value(const t_metadata_value& o) noexcept
101101
: value_(o.value_) {}

libs/librrgraph/src/base/rr_graph_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct t_pin_chain_node {
2121
int nxt_node_idx = OPEN;
2222

2323
t_pin_chain_node() = default;
24-
t_pin_chain_node(int pin_num, int nxt_idx)
24+
t_pin_chain_node(int pin_num, int nxt_idx) noexcept
2525
: pin_physical_num(pin_num)
2626
, nxt_node_idx(nxt_idx) {}
2727
};

libs/libvtrutil/src/vtr_flat_map.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class flat_map2;
2121
* @brief A function to create a flat map
2222
*
2323
* Helper function to create a flat map from a vector of pairs
24-
* without haveing to explicity specify the key and value types
24+
* without having to explicitly specify the key and value types
2525
*/
2626
template<class K, class V>
2727
flat_map<K, V> make_flat_map(std::vector<std::pair<K, V>>&& vec) {
@@ -435,7 +435,7 @@ template<class K, class T, class Compare, class Storage>
435435
class flat_map2 : public flat_map<K, T, Compare, Storage> {
436436
public:
437437
///@brief Constructor
438-
flat_map2() {}
438+
flat_map2() noexcept {}
439439
explicit flat_map2(std::vector<typename flat_map2<K, T, Compare, Storage>::value_type>&& values)
440440
: flat_map<K, T, Compare>(std::move(values)) {}
441441

libs/libvtrutil/src/vtr_geometry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ template<class T>
119119
class Rect {
120120
public: //Constructors
121121
///@brief default constructor
122-
Rect();
122+
Rect() noexcept;
123123

124124
///@brief construct using 4 vertex
125125
Rect(T left_val, T bottom_val, T right_val, T top_val);

libs/libvtrutil/src/vtr_geometry.tpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Point<T>& Point<T>::operator-=(const Point<T>& rhs) {
8686
* Rect
8787
*/
8888
template<class T>
89-
Rect<T>::Rect()
89+
Rect<T>::Rect() noexcept
9090
: Rect<T>(Point<T>(0, 0), Point<T>(0, 0)) {
9191
//pass
9292
}

libs/libvtrutil/src/vtr_ndoffsetmatrix.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class NdOffsetMatrixProxy {
6363
* dim_stride: The stride of this dimension (i.e. how many element in memory between indicies of this dimension)
6464
* start: Pointer to the start of the sub-matrix this proxy represents
6565
*/
66-
NdOffsetMatrixProxy<T, N>(const DimRange* dim_ranges, size_t idim, size_t dim_stride, T* start)
66+
NdOffsetMatrixProxy(const DimRange* dim_ranges, size_t idim, size_t dim_stride, T* start)
6767
: dim_ranges_(dim_ranges)
6868
, idim_(idim)
6969
, dim_stride_(dim_stride)
@@ -116,7 +116,7 @@ class NdOffsetMatrixProxy<T, 1> {
116116
* - dim_stride: The stride of this dimension (i.e. how many element in memory between indicies of this dimension)
117117
* - start: Pointer to the start of the sub-matrix this proxy represents
118118
*/
119-
NdOffsetMatrixProxy<T, 1>(const DimRange* dim_ranges, size_t idim, size_t dim_stride, T* start)
119+
NdOffsetMatrixProxy(const DimRange* dim_ranges, size_t idim, size_t dim_stride, T* start)
120120
: dim_ranges_(dim_ranges)
121121
, idim_(idim)
122122
, dim_stride_(dim_stride)

libs/libvtrutil/src/vtr_strong_id.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ template<typename tag, typename T, T sentinel>
167167
constexpr bool operator!=(const StrongId<tag, T, sentinel>& lhs, const StrongId<tag, T, sentinel>& rhs);
168168

169169
template<typename tag, typename T, T sentinel>
170-
constexpr bool operator<(const StrongId<tag, T, sentinel>& lhs, const StrongId<tag, T, sentinel>& rhs);
170+
constexpr bool operator<(const StrongId<tag, T, sentinel>& lhs, const StrongId<tag, T, sentinel>& rhs) noexcept;
171171

172172
template<typename tag, typename T, T sentinel>
173173
std::ostream& operator<<(std::ostream& out, const StrongId<tag, T, sentinel>& rhs);
@@ -182,11 +182,11 @@ class StrongId {
182182
static constexpr StrongId INVALID() noexcept { return StrongId(); }
183183

184184
///@brief Default to the sentinel value
185-
constexpr StrongId()
185+
constexpr StrongId() noexcept
186186
: id_(sentinel) {}
187187

188188
///@brief Only allow explicit constructions from a raw Id (no automatic conversions)
189-
explicit constexpr StrongId(T id)
189+
explicit constexpr StrongId(T id) noexcept
190190
: id_(id) {}
191191

192192
// Allow some explicit conversion to useful types:
@@ -216,7 +216,7 @@ class StrongId {
216216
///@brief != operator
217217
friend constexpr bool operator!= <>(const StrongId<tag, T, sentinel>& lhs, const StrongId<tag, T, sentinel>& rhs);
218218
///@brief < operator
219-
friend constexpr bool operator< <>(const StrongId<tag, T, sentinel>& lhs, const StrongId<tag, T, sentinel>& rhs);
219+
friend constexpr bool operator< <>(const StrongId<tag, T, sentinel>& lhs, const StrongId<tag, T, sentinel>& rhs) noexcept;
220220

221221
/**
222222
* @brief to be able to print them out
@@ -241,7 +241,7 @@ constexpr bool operator!=(const StrongId<tag, T, sentinel>& lhs, const StrongId<
241241

242242
///@brief operator < Needed for std::map-like containers
243243
template<typename tag, typename T, T sentinel>
244-
constexpr bool operator<(const StrongId<tag, T, sentinel>& lhs, const StrongId<tag, T, sentinel>& rhs) {
244+
constexpr bool operator<(const StrongId<tag, T, sentinel>& lhs, const StrongId<tag, T, sentinel>& rhs) noexcept {
245245
return lhs.id_ < rhs.id_;
246246
}
247247

libs/libvtrutil/src/vtr_strong_id_range.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ class StrongIdIterator {
4646
using difference_type = ssize_t;
4747

4848
///@brief Dereference operator (*)
49-
StrongId& operator*() {
49+
StrongId operator*() const {
5050
VTR_ASSERT_SAFE(bool(id_));
51-
return this->id_;
51+
return id_;
5252
}
5353

5454
///@brief += operator
@@ -75,6 +75,14 @@ class StrongIdIterator {
7575
return *this;
7676
}
7777

78+
///@brief Post-increment operator
79+
StrongIdIterator operator++(int) {
80+
VTR_ASSERT_SAFE(bool(id_));
81+
StrongIdIterator temp = *this; // Create a copy of the current object
82+
++(*this); // Use the pre-increment operator to increment
83+
return temp; // Return the copy
84+
}
85+
7886
///@brief Decremment operator
7987
StrongIdIterator& operator--() {
8088
VTR_ASSERT_SAFE(bool(id_));

vpr/src/base/setup_noc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
// a data structure to store the position information of a noc router in the FPGA device
4141
struct t_noc_router_tile_position {
42-
t_noc_router_tile_position(int x, int y, int layer_num, float centroid_x, float centroid_y)
42+
t_noc_router_tile_position(int x, int y, int layer_num, float centroid_x, float centroid_y) noexcept
4343
: grid_width_position(x)
4444
, grid_height_position(y)
4545
, layer_position(layer_num)

vpr/src/noc/noc_traffic_flows.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ struct t_noc_traffic_flow {
6868
int traffic_flow_priority;
6969

7070
/** Constructor initializes all variables*/
71-
t_noc_traffic_flow(std::string source_router_name, std::string sink_router_name, ClusterBlockId source_router_id, ClusterBlockId sink_router_id, double flow_bandwidth, double max_flow_latency, int flow_priority)
71+
t_noc_traffic_flow(std::string source_router_name,
72+
std::string sink_router_name,
73+
ClusterBlockId source_router_id,
74+
ClusterBlockId sink_router_id,
75+
double flow_bandwidth,
76+
double max_flow_latency,
77+
int flow_priority) noexcept
7278
: source_router_module_name(std::move(source_router_name))
7379
, sink_router_module_name(std::move(sink_router_name))
7480
, source_router_cluster_id(source_router_id)

vpr/src/pack/pack_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct t_lb_type_rr_node {
6969
t_pb_graph_pin* pb_graph_pin; /* pb_graph_pin associated with this lb_rr_node if exists, NULL otherwise */
7070
float intrinsic_cost; /* cost of this node */
7171

72-
t_lb_type_rr_node() {
72+
t_lb_type_rr_node() noexcept {
7373
capacity = 0;
7474
num_modes = 0;
7575
num_fanout = nullptr;
@@ -130,7 +130,7 @@ struct t_intra_lb_net {
130130
std::vector<bool> fixed_terminals; /* Marks a terminal as having a fixed target (i.e. a pin not a sink) */
131131
t_lb_trace* rt_tree; /* Route tree head */
132132

133-
t_intra_lb_net() {
133+
t_intra_lb_net() noexcept {
134134
atom_net_id = AtomNetId::INVALID();
135135
rt_tree = nullptr;
136136
}

vpr/src/place/grid_tile_lookup.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#include "grid_tile_lookup.h"
22

3-
GridTileLookup::GridTileLookup() {
3+
GridTileLookup::GridTileLookup()
4+
: max_placement_locations(g_vpr_ctx.device().logical_block_types.size()) {
45
const auto& device_ctx = g_vpr_ctx.device();
56
const int num_layers = device_ctx.grid.get_num_layers();
67

7-
//Will store the max number of tile locations for each logical block type
8-
max_placement_locations.resize(device_ctx.logical_block_types.size());
9-
108
for (const auto& type : device_ctx.logical_block_types) {
119
vtr::NdMatrix<int, 3> type_count({static_cast<unsigned long>(num_layers), device_ctx.grid.width(), device_ctx.grid.height()});
1210
fill_type_matrix(&type, type_count);

vpr/src/route/route_common.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,12 +601,11 @@ static vtr::vector<ParentBlockId, std::vector<RRNodeId>> load_rr_clb_sources(con
601601

602602
static vtr::vector<ParentNetId, uint8_t> load_is_clock_net(const Netlist<>& net_list,
603603
bool is_flat) {
604-
vtr::vector<ParentNetId, uint8_t> is_clock_net;
604+
vtr::vector<ParentNetId, uint8_t> is_clock_net(net_list.nets().size());
605605

606606
auto& atom_ctx = g_vpr_ctx.atom();
607607
std::set<AtomNetId> clock_nets = find_netlist_physical_clock_nets(atom_ctx.nlist);
608608

609-
is_clock_net.resize(net_list.nets().size());
610609
for (auto net_id : net_list.nets()) {
611610
std::size_t net_id_num = std::size_t(net_id);
612611
if (is_flat) {

vpr/src/route/router_lookahead_map_utils.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,9 +1219,7 @@ static void run_intra_tile_dijkstra(const RRGraphView& rr_graph,
12191219
node_expanded.resize(rr_graph.num_nodes());
12201220
std::fill(node_expanded.begin(), node_expanded.end(), false);
12211221

1222-
vtr::vector<RRNodeId, float> node_seen_cost;
1223-
node_seen_cost.resize(rr_graph.num_nodes());
1224-
std::fill(node_seen_cost.begin(), node_seen_cost.end(), -1.);
1222+
vtr::vector<RRNodeId, float> node_seen_cost(rr_graph.num_nodes(), -1.f);
12251223

12261224
struct t_pq_entry {
12271225
float delay;

vpr/src/timing/PreClusterDelayCalculator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class PreClusterDelayCalculator : public tatum::DelayCalculator {
1919
PreClusterDelayCalculator(const AtomNetlist& netlist,
2020
const AtomLookup& netlist_lookup,
2121
float intercluster_net_delay,
22-
const Prepacker& prepacker)
22+
const Prepacker& prepacker) noexcept
2323
: netlist_(netlist)
2424
, netlist_lookup_(netlist_lookup)
2525
, inter_cluster_net_delay_(intercluster_net_delay)

0 commit comments

Comments
 (0)