Skip to content

Commit 9035e52

Browse files
authored
Compilation fixes for C++20. (#5278)
Signed-off-by: fruffy <[email protected]>
1 parent 9613369 commit 9035e52

22 files changed

+60
-39
lines changed

backends/tofino/bf-asm/asm-types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ class MapIterChecked {
410410
iter(MapIterChecked *s, pair_t *p_) : self(s), p(p_) { check(); }
411411
pair_t &operator*() const { return *p; }
412412
pair_t *operator->() const { return p; }
413-
bool operator==(iter &a) const { return p == a.p; }
413+
bool operator==(const iter &a) const { return p == a.p; }
414414
iter &operator++() {
415415
p++;
416416
check();

backends/tofino/bf-asm/atcam_match.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ void AlgTcamMatchTable::write_regs_vt(REGS &regs) {
365365
}
366366
}
367367

368-
std::unique_ptr<json::vector> AlgTcamMatchTable::gen_memory_resource_allocation_tbl_cfg() const {
368+
std::unique_ptr<json::vector> AlgTcamMatchTable::gen_memory_resource_allocation_tbl_cfg_no_input()
369+
const {
369370
if (col_priority_way.size() == 0)
370371
error(lineno, "No column priority determined for table %s", name());
371372
unsigned fmt_width = format ? (format->size + 127) / 128 : 0;
@@ -427,7 +428,7 @@ void AlgTcamMatchTable::gen_unit_cfg(json::vector &units, int size) const {
427428
// Assuming atcam next hit table cannot be multiple tables
428429
stage_tbl["default_next_table"] =
429430
!hit_next.empty() ? hit_next[0].next_table_id() : Target::END_OF_PIPE();
430-
stage_tbl["memory_resource_allocation"] = gen_memory_resource_allocation_tbl_cfg();
431+
stage_tbl["memory_resource_allocation"] = gen_memory_resource_allocation_tbl_cfg_no_input();
431432
// Hash functions not necessary currently for ATCAM matches, as the result comes from
432433
// the partition_field_name
433434
stage_tbl["hash_functions"] = json::vector();

backends/tofino/bf-asm/deparser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
unsigned Deparser::unique_field_list_handle;
3131
Deparser Deparser::singleton_object;
3232

33-
Deparser::Deparser() : Section("deparser") {}
34-
Deparser::~Deparser() {}
35-
3633
struct Deparser::FDEntry {
3734
struct Base {
3835
virtual ~Base() {}
@@ -202,6 +199,9 @@ struct Deparser::FDEntry {
202199
void check(bitvec &phv_use) { what->check(phv_use); }
203200
};
204201

202+
Deparser::Deparser() : Section("deparser") {}
203+
Deparser::~Deparser() = default;
204+
205205
struct Deparser::Intrinsic::Type {
206206
target_t target;
207207
gress_t gress;

backends/tofino/bf-asm/exact_match.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,8 @@ void ExactMatchTable::gen_tbl_cfg(json::vector &out) const {
471471
unsigned ram_depth = way.rams.at(0).isLamb() ? LAMB_DEPTH : SRAM_DEPTH;
472472
way_tbl["size"] = way.rams.size() / fmt_width * format->groups() * ram_depth;
473473
add_pack_format(way_tbl, format.get(), false);
474-
way_tbl["memory_resource_allocation"] = gen_memory_resource_allocation_tbl_cfg(way);
474+
way_tbl["memory_resource_allocation"] =
475+
gen_memory_resource_allocation_tbl_cfg_with_way(way);
475476
way_stage_tables.push_back(std::move(way_tbl));
476477
}
477478
}

backends/tofino/bf-asm/gtest/gtestasm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class GTestOptions : public Util::Options {
5959
},
6060
"[Compiler debugging] Adjust logging level per file (see below)");
6161
}
62-
std::vector<const char *> *process(int argc, char *const argv[]) {
62+
std::vector<const char *> *process(int argc, char *const argv[]) override {
6363
auto remainingOptions = Util::Options::process(argc, argv);
6464
return remainingOptions;
6565
}

backends/tofino/bf-asm/input_xbar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ class InputXbar {
280280
: outer(o), outer_end(oend), inner_valid(false) {
281281
mk_inner_valid();
282282
}
283-
bool operator==(const all_iter &a) {
283+
bool operator==(const all_iter &a) const {
284284
if (outer != a.outer) return false;
285285
if (inner_valid != a.inner_valid) return false;
286286
return inner_valid ? inner == a.inner : true;

backends/tofino/bf-asm/json.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ class vector : public obj, public vector_base {
296296
}
297297
};
298298

299-
typedef ordered_map<obj *, std::unique_ptr<obj>, obj::ptrless> map_base;
299+
using map_base = ordered_map<obj *, std::unique_ptr<obj>, obj::ptrless>;
300300
class map : public obj, public map_base {
301301
public:
302302
map() {}

backends/tofino/bf-asm/proxy_hash.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ void ProxyHashMatchTable::gen_tbl_cfg(json::vector &out) const {
172172
BUG_CHECK(fmt_width, "width of format is 0");
173173
way_tbl["size"] = way.rams.size() / fmt_width * format->groups() * 1024;
174174
add_pack_format(way_tbl, format.get(), false);
175-
way_tbl["memory_resource_allocation"] = gen_memory_resource_allocation_tbl_cfg(way);
175+
way_tbl["memory_resource_allocation"] =
176+
gen_memory_resource_allocation_tbl_cfg_with_way(way);
176177
way_stage_tables.push_back(std::move(way_tbl));
177178
}
178179
}

backends/tofino/bf-asm/sram_match.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ bool SRamMatchTable::verify_match_key() {
338338
return error_count == 0;
339339
}
340340

341-
std::unique_ptr<json::map> SRamMatchTable::gen_memory_resource_allocation_tbl_cfg(
341+
std::unique_ptr<json::map> SRamMatchTable::gen_memory_resource_allocation_tbl_cfg_with_way(
342342
const Way &way) const {
343343
json::map mra;
344344
unsigned vpn_ctr = 0;

backends/tofino/bf-asm/tables.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "action_bus.h"
2424
#include "backends/tofino/bf-asm/config.h"
25+
#include "backends/tofino/bf-asm/json.h"
2526
#include "backends/tofino/bf-asm/stage.h"
2627
#include "input_xbar.h"
2728
#include "instruction.h"
@@ -2304,7 +2305,7 @@ void Table::Actions::Action::check_and_add_resource(json::vector &resources,
23042305
// present in the resource array
23052306
bool found = false;
23062307
for (auto &r : resources) {
2307-
if (resource == r->to<json::map>()) {
2308+
if (resource == r->to<json::obj>()) {
23082309
found = true;
23092310
break;
23102311
}
@@ -2556,7 +2557,7 @@ void Table::Actions::add_action_format(const Table *table, json::map &tbl) const
25562557
json::string name = a.first;
25572558
int lo = remove_name_tail_range(name);
25582559
json::string immed_name = a.second.name;
2559-
if (immed_name != "immediate") continue; // output only immediate fields
2560+
if (immed_name != json::string("immediate")) continue; // output only immediate fields
25602561
if (!(act.has_param(name) || a.second.is_constant))
25612562
continue; // and fields that are parameters or constants
25622563
json::map action_format_per_action_imm_field;

0 commit comments

Comments
 (0)