Skip to content

Commit 3a69da0

Browse files
fix fasm build warnings
1 parent 44e7f02 commit 3a69da0

File tree

2 files changed

+21
-30
lines changed

2 files changed

+21
-30
lines changed

utils/fasm/src/fasm.cpp

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
#include "fasm.h"
22

33
#include <algorithm>
4-
#include <fstream>
5-
#include <iomanip>
64
#include <iostream>
7-
#include <iterator>
85
#include <set>
96
#include <sstream>
107
#include <string>
11-
#include <unordered_map>
128

139
#include "globals.h"
1410

1511
#include "rr_metadata.h"
1612

1713
#include "vtr_assert.h"
1814
#include "vtr_logic.h"
19-
#include "vtr_version.h"
2015
#include "vpr_error.h"
2116

2217
#include "atom_netlist_utils.h"
23-
#include "netlist_writer.h"
24-
#include "vpr_utils.h"
2518

2619
#include "fasm_utils.h"
2720

@@ -77,7 +70,7 @@ void FasmWriterVisitor::visit_clb_impl(ClusterBlockId blk_id, const t_pb* clb) {
7770
std::vector<std::string> tag_defs = vtr::split(value->front().as_string().get(strings_), "\n");
7871
for (auto& tag_def: tag_defs) {
7972
auto parts = split_fasm_entry(tag_def, "=:", "\t ");
80-
if (parts.size() == 0) {
73+
if (parts.empty()) {
8174
continue;
8275
}
8376

@@ -86,7 +79,7 @@ void FasmWriterVisitor::visit_clb_impl(ClusterBlockId blk_id, const t_pb* clb) {
8679
VTR_ASSERT(tags_.count(parts.at(0)) == 0);
8780

8881
// When the value is "NULL" then substitute empty string
89-
if (!parts.at(1).compare("NULL")) {
82+
if (parts.at(1) == "NULL") {
9083
tags_[parts.at(0)] = "";
9184
}
9285
else {
@@ -179,7 +172,7 @@ std::string FasmWriterVisitor::handle_fasm_prefix(const t_metadata_dict *meta,
179172
}
180173

181174
std::string FasmWriterVisitor::build_clb_prefix(const t_pb *pb, const t_pb_graph_node* pb_graph_node, bool* is_parent_pb_null) const {
182-
std::string clb_prefix = "";
175+
std::string clb_prefix;
183176

184177
const t_pb *pb_for_graph_node = nullptr;
185178

@@ -272,7 +265,7 @@ void FasmWriterVisitor::visit_all_impl(const t_pb_routes &pb_routes, const t_pb*
272265
std::string clb_prefix = build_clb_prefix(pb, pb_graph_node, &is_parent_pb_null);
273266
clb_prefix_map_.insert(std::make_pair(pb_graph_node, clb_prefix));
274267
clb_prefix_ = clb_prefix;
275-
if (is_parent_pb_null == true) {
268+
if (is_parent_pb_null) {
276269
return;
277270
}
278271

@@ -365,7 +358,7 @@ static LogicVec lut_outputs(const t_pb* atom_pb, size_t num_inputs, const t_pb_r
365358
if(truth_table.size() == 1) {
366359
VTR_ASSERT(truth_table[0].size() == 1);
367360
lut.SetConstant(truth_table[0][0]);
368-
} else if(truth_table.size() == 0) {
361+
} else if(truth_table.empty()) {
369362
lut.SetConstant(vtr::LogicValue::FALSE);
370363
} else {
371364
vpr_throw(VPR_ERROR_OTHER, __FILE__, __LINE__, "LUT truth table unexpected size is %d", truth_table.size());
@@ -420,7 +413,7 @@ static LogicVec lut_outputs(const t_pb* atom_pb, size_t num_inputs, const t_pb_r
420413
return lut.table();
421414
}
422415

423-
const t_metadata_dict *FasmWriterVisitor::get_fasm_type(const t_pb_graph_node* pb_graph_node, std::string target_type) const {
416+
const t_metadata_dict *FasmWriterVisitor::get_fasm_type(const t_pb_graph_node* pb_graph_node, const std::string& target_type) const {
424417
if(pb_graph_node == nullptr) {
425418
return nullptr;
426419
}
@@ -470,9 +463,8 @@ const LutOutputDefinition* FasmWriterVisitor::find_lut(const t_pb_graph_node* pb
470463
VTR_ASSERT(value != nullptr);
471464

472465
std::vector<std::pair<std::string, LutOutputDefinition>> luts;
473-
luts.push_back(std::make_pair(
474-
vtr::string_fmt("%s[0]", pb_graph_node->pb_type->name),
475-
LutOutputDefinition(value->as_string().get(strings_))));
466+
luts.emplace_back(vtr::string_fmt("%s[0]", pb_graph_node->pb_type->name),
467+
LutOutputDefinition(value->as_string().get(strings_)));
476468

477469
auto insert_result = lut_definitions_.insert(
478470
std::make_pair(pb_graph_node->pb_type, luts));
@@ -505,8 +497,7 @@ const LutOutputDefinition* FasmWriterVisitor::find_lut(const t_pb_graph_node* pb
505497
fasm_lut_str.c_str());
506498
}
507499

508-
luts.push_back(std::make_pair(
509-
parts[1], LutOutputDefinition(parts[0])));
500+
luts.emplace_back(parts[1], LutOutputDefinition(parts[0]));
510501
}
511502

512503
auto insert_result = lut_definitions_.insert(
@@ -569,9 +560,9 @@ void FasmWriterVisitor::check_for_param(const t_pb *atom) {
569560
VTR_ASSERT(value != nullptr);
570561

571562
std::string fasm_params_str = value->as_string().get(strings_);
572-
for(const auto param : vtr::split(fasm_params_str, "\n")) {
563+
for(const auto& param : vtr::split(fasm_params_str, "\n")) {
573564
auto param_parts = split_fasm_entry(param, "=", "\t ");
574-
if(param_parts.size() == 0) {
565+
if(param_parts.empty()) {
575566
continue;
576567
}
577568
VTR_ASSERT(param_parts.size() == 2);
@@ -589,10 +580,10 @@ void FasmWriterVisitor::check_for_param(const t_pb *atom) {
589580

590581
auto &params = iter->second;
591582

592-
for(auto param : atom_ctx.nlist.block_params(atom_blk_id)) {
583+
for(const auto& param : atom_ctx.nlist.block_params(atom_blk_id)) {
593584
auto feature = params.EmitFasmFeature(param.first, param.second);
594585

595-
if(feature.size() > 0) {
586+
if(!feature.empty()) {
596587
output_fasm_features(feature);
597588
}
598589
}
@@ -668,7 +659,7 @@ void FasmWriterVisitor::find_clb_prefix(const t_pb_graph_node *node,
668659
}
669660
}
670661

671-
void FasmWriterVisitor::output_fasm_mux(std::string fasm_mux_str,
662+
void FasmWriterVisitor::output_fasm_mux(const std::string& fasm_mux_str,
672663
t_interconnect *interconnect,
673664
const t_pb_graph_pin *mux_input_pin) {
674665
auto *pb_name = mux_input_pin->parent_node->pb_type->name;
@@ -697,7 +688,7 @@ void FasmWriterVisitor::output_fasm_mux(std::string fasm_mux_str,
697688
for(const auto &mux_input : mux_inputs) {
698689
auto mux_parts = split_fasm_entry(mux_input, "=:", "\t ");
699690

700-
if(mux_parts.size() == 0) {
691+
if(mux_parts.empty()) {
701692
// Swallow whitespace.
702693
continue;
703694
}
@@ -753,11 +744,11 @@ void FasmWriterVisitor::output_fasm_mux(std::string fasm_mux_str,
753744
pb_name, pb_index, port_name, pin_index, fasm_mux_str.c_str());
754745
}
755746

756-
void FasmWriterVisitor::output_fasm_features(const std::string features) const {
747+
void FasmWriterVisitor::output_fasm_features(const std::string& features) const {
757748
output_fasm_features(features, clb_prefix_, blk_prefix_);
758749
}
759750

760-
void FasmWriterVisitor::output_fasm_features(const std::string features, const std::string clb_prefix, const std::string blk_prefix) const {
751+
void FasmWriterVisitor::output_fasm_features(const std::string& features, const std::string& clb_prefix, const std::string& blk_prefix) const {
761752
std::stringstream os(features);
762753

763754
while(os) {

utils/fasm/src/fasm.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ class FasmWriterVisitor : public NetlistVisitor {
6666
void finish_impl() override;
6767

6868
private:
69-
void output_fasm_features(const std::string features) const;
70-
void output_fasm_features(const std::string features, const std::string clb_prefix, const std::string blk_prefix) const;
69+
void output_fasm_features(const std::string& features) const;
70+
void output_fasm_features(const std::string& features, const std::string& clb_prefix, const std::string& blk_prefix) const;
7171
void check_features(const t_metadata_dict *meta) const;
7272
void check_interconnect(const t_pb_routes &pb_route, int inode);
7373
void check_for_lut(const t_pb* atom);
74-
void output_fasm_mux(std::string fasm_mux, t_interconnect *interconnect, const t_pb_graph_pin *mux_input_pin);
74+
void output_fasm_mux(const std::string& fasm_mux, t_interconnect *interconnect, const t_pb_graph_pin *mux_input_pin);
7575
void walk_routing();
7676
void walk_route_tree(const RRGraphBuilder& rr_graph_builder, const RouteTreeNode& root);
7777
std::string build_clb_prefix(const t_pb *pb, const t_pb_graph_node* pb_graph_node, bool* is_parent_pb_null) const;
@@ -83,7 +83,7 @@ class FasmWriterVisitor : public NetlistVisitor {
8383
bool *have_prefix, std::string *clb_prefix) const;
8484
std::string handle_fasm_prefix(const t_metadata_dict *meta,
8585
const t_pb_graph_node *pb_graph_node, const t_pb_type *pb_type) const;
86-
const t_metadata_dict *get_fasm_type(const t_pb_graph_node* pb_graph_node, std::string target_type) const;
86+
const t_metadata_dict *get_fasm_type(const t_pb_graph_node* pb_graph_node, const std::string& target_type) const;
8787

8888
vtr::string_internment *strings_;
8989
std::ostream& os_;

0 commit comments

Comments
 (0)