From d53b883e87bccf9d163d3447c0c20ca3cd544bed Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Sun, 19 Apr 2026 22:50:58 +0000 Subject: [PATCH] rmp: adjust naming to Google-style (excluding method names) Signed-off-by: Matt Liberty --- src/rmp/include/rmp/Restructure.h | 16 ++-- src/rmp/src/Restructure.cpp | 87 ++++++++++----------- src/rmp/src/delay_optimization_strategy.cpp | 2 + src/rmp/src/genetic_strategy.cpp | 14 ++-- src/rmp/src/gia.cpp | 2 + src/rmp/src/slack_tuning_strategy.cpp | 14 ++-- src/rmp/test/cpp/TestAbc.cc | 12 +-- 7 files changed, 75 insertions(+), 72 deletions(-) diff --git a/src/rmp/include/rmp/Restructure.h b/src/rmp/include/rmp/Restructure.h index 83a794685db..cb697371725 100644 --- a/src/rmp/include/rmp/Restructure.h +++ b/src/rmp/include/rmp/Restructure.h @@ -44,13 +44,13 @@ namespace rmp { enum class Mode { - AREA_1 = 0, - AREA_2, - AREA_3, - DELAY_1, - DELAY_2, - DELAY_3, - DELAY_4 + kArea1 = 0, + kArea2, + kArea3, + kDelay1, + kDelay2, + kDelay3, + kDelay4 }; class Restructure @@ -165,7 +165,7 @@ class Restructure std::vector lib_file_names_; std::set path_insts_; - Mode opt_mode_{Mode::DELAY_1}; + Mode opt_mode_{Mode::kDelay1}; bool is_area_mode_{false}; int blif_call_id_{0}; }; diff --git a/src/rmp/src/Restructure.cpp b/src/rmp/src/Restructure.cpp index 9fe9fa0c1bf..69ad28b0f8a 100644 --- a/src/rmp/src/Restructure.cpp +++ b/src/rmp/src/Restructure.cpp @@ -192,10 +192,10 @@ void Restructure::runABC() "Constants before remap {}", countConsts(block_)); - Blif blif_( + Blif blif( logger_, open_sta_, locell_, loport_, hicell_, hiport_, ++blif_call_id_); - blif_.setReplaceableInstances(path_insts_); - blif_.writeBlif(input_blif_file_name_.c_str(), !is_area_mode_); + blif.setReplaceableInstances(path_insts_); + blif.writeBlif(input_blif_file_name_.c_str(), !is_area_mode_); debugPrint( logger_, RMP, "remap", 1, "Writing blif file {}", input_blif_file_name_); files_to_remove.emplace_back(input_blif_file_name_); @@ -206,10 +206,10 @@ void Restructure::runABC() if (is_area_mode_) { // Area Mode - modes = {Mode::AREA_1, Mode::AREA_2, Mode::AREA_3}; + modes = {Mode::kArea1, Mode::kArea2, Mode::kArea3}; } else { // Delay Mode - modes = {Mode::DELAY_1, Mode::DELAY_2, Mode::DELAY_3, Mode::DELAY_4}; + modes = {Mode::kDelay1, Mode::kDelay2, Mode::kDelay3, Mode::kDelay4}; } child_proc.resize(modes.size(), 0); @@ -274,8 +274,7 @@ void Restructure::runABC() int num_instances = 0; bool success = readAbcLog(abc_log_name, level_gain, delay); if (success) { - success - = blif_.inspectBlif(output_blif_file_name_.c_str(), num_instances); + success = blif.inspectBlif(output_blif_file_name_.c_str(), num_instances); logger_->report( "Optimized to {} instances in iteration {} with max path depth " "decrease of {}, delay of {}.", @@ -293,7 +292,7 @@ void Restructure::runABC() } else { // Using only DELAY_4 for delay based gain since other modes not // showing good gains - if (modes[curr_mode_idx] == Mode::DELAY_4) { + if (modes[curr_mode_idx] == Mode::kDelay4) { best_delay_gain = delay; best_blif = output_blif_file_name_; } @@ -307,7 +306,7 @@ void Restructure::runABC() || best_delay_gain < std::numeric_limits::max()) { // read back netlist debugPrint(logger_, RMP, "remap", 1, "Reading blif file {}.", best_blif); - blif_.readBlif(best_blif.c_str(), block_); + blif.readBlif(best_blif.c_str(), block_); debugPrint(logger_, utl::RMP, "remap", @@ -373,10 +372,10 @@ void Restructure::getEndPoints(sta::PinSet& ends, if (!errors.empty() && errors[0]->size() > 1) { sta::CheckError* error = errors[0]; bool first = true; - for (auto pinName : *error) { - debugPrint(logger_, RMP, "remap", 1, "Unconstrained pin: {}", pinName); - if (!first && open_sta_->getDbNetwork()->findPin(pinName.c_str())) { - ends.insert(open_sta_->getDbNetwork()->findPin(pinName.c_str())); + for (auto pin_name : *error) { + debugPrint(logger_, RMP, "remap", 1, "Unconstrained pin: {}", pin_name); + if (!first && open_sta_->getDbNetwork()->findPin(pin_name.c_str())) { + ends.insert(open_sta_->getDbNetwork()->findPin(pin_name.c_str())); } first = false; } @@ -384,10 +383,10 @@ void Restructure::getEndPoints(sta::PinSet& ends, if (errors.size() > 1 && errors[1]->size() > 1) { sta::CheckError* error = errors[1]; bool first = true; - for (auto pinName : *error) { - debugPrint(logger_, RMP, "remap", 1, "Unclocked pin: {}", pinName); - if (!first && open_sta_->getDbNetwork()->findPin(pinName.c_str())) { - ends.insert(open_sta_->getDbNetwork()->findPin(pinName.c_str())); + for (auto pin_name : *error) { + debugPrint(logger_, RMP, "remap", 1, "Unclocked pin: {}", pin_name); + if (!first && open_sta_->getDbNetwork()->findPin(pin_name.c_str())) { + ends.insert(open_sta_->getDbNetwork()->findPin(pin_name.c_str())); } first = false; } @@ -439,7 +438,7 @@ void Restructure::removeConstCells() open_sta_->clearLogicConstants(); open_sta_->findLogicConstants(); - std::set constInsts; + std::set const_insts; int const_cnt = 1; for (auto inst : block_->getInsts()) { int outputs = 0; @@ -462,16 +461,16 @@ void Restructure::removeConstCells() } outputs++; auto pin = open_sta_->getDbNetwork()->dbToSta(iterm); - sta::LogicValue pinVal + sta::LogicValue pin_val = open_sta_->simLogicValue(pin, open_sta_->cmdMode()); - if (pinVal == sta::LogicValue::one || pinVal == sta::LogicValue::zero) { + if (pin_val == sta::LogicValue::one || pin_val == sta::LogicValue::zero) { odb::dbNet* net = iterm->getNet(); if (net) { - odb::dbMaster* const_master = (pinVal == sta::LogicValue::one) + odb::dbMaster* const_master = (pin_val == sta::LogicValue::one) ? hicell_master : locell_master; odb::dbMTerm* const_port - = (pinVal == sta::LogicValue::one) ? hiterm : loterm; + = (pin_val == sta::LogicValue::one) ? hiterm : loterm; std::string inst_name = "rmp_const_" + std::to_string(const_cnt); debugPrint(logger_, RMP, @@ -495,19 +494,19 @@ void Restructure::removeConstCells() } } if (outputs > 0 && outputs == const_outputs) { - constInsts.insert(inst); + const_insts.insert(inst); } } open_sta_->clearLogicConstants(); debugPrint( - logger_, RMP, "remap", 2, "Removing {} instances...", constInsts.size()); + logger_, RMP, "remap", 2, "Removing {} instances...", const_insts.size()); - for (auto inst : constInsts) { + for (auto inst : const_insts) { removeConstCell(inst); } logger_->report("Removed {} instances with constant outputs.", - constInsts.size()); + const_insts.size()); } void Restructure::removeConstCell(odb::dbInst* inst) @@ -572,19 +571,19 @@ void Restructure::writeOptCommands(std::ofstream& script) script << choice << '\n'; script << choice2 << '\n'; - if (opt_mode_ == Mode::AREA_3) { + if (opt_mode_ == Mode::kArea3) { script << "choice2\n"; // << "scleanup" << std::endl; } else { script << "resyn2\n"; // << "scleanup" << std::endl; } switch (opt_mode_) { - case Mode::DELAY_1: { + case Mode::kDelay1: { script << "map -D 0.01 -A 0.9 -B 0.2 -M 0 -p\n"; script << "buffer -p -c\n"; break; } - case Mode::DELAY_2: { + case Mode::kDelay2: { script << "choice\n"; script << "map -D 0.01 -A 0.9 -B 0.2 -M 0 -p\n"; script << "choice\n"; @@ -593,7 +592,7 @@ void Restructure::writeOptCommands(std::ofstream& script) << "topo\n"; break; } - case Mode::DELAY_3: { + case Mode::kDelay3: { script << "choice2\n"; script << "map -D 0.01 -A 0.9 -B 0.2 -M 0 -p\n"; script << "choice2\n"; @@ -602,7 +601,7 @@ void Restructure::writeOptCommands(std::ofstream& script) << "topo\n"; break; } - case Mode::DELAY_4: { + case Mode::kDelay4: { script << "choice2\n"; script << "amap -F 20 -A 20 -C 5000 -Q 0.1 -m\n"; script << "choice2\n"; @@ -610,15 +609,15 @@ void Restructure::writeOptCommands(std::ofstream& script) script << "buffer -p -c\n"; break; } - case Mode::AREA_2: - case Mode::AREA_3: { + case Mode::kArea2: + case Mode::kArea3: { script << "choice2\n"; script << "amap -m -Q 0.1 -F 20 -A 20 -C 5000\n"; script << "choice2\n"; script << "amap -m -Q 0.1 -F 20 -A 20 -C 5000\n"; break; } - case Mode::AREA_1: + case Mode::kArea1: default: { script << "choice2\n"; script << "amap -m -Q 0.1 -F 20 -A 20 -C 5000\n"; @@ -633,27 +632,27 @@ void Restructure::setMode(const char* mode_name) if (!strcmp(mode_name, "timing")) { is_area_mode_ = false; - opt_mode_ = Mode::DELAY_1; + opt_mode_ = Mode::kDelay1; } else if (!strcmp(mode_name, "area")) { - opt_mode_ = Mode::AREA_1; + opt_mode_ = Mode::kArea1; } else { logger_->warn(RMP, 10, "Mode {} not recognized.", mode_name); } } -void Restructure::setTieHiPort(sta::LibertyPort* tieHiPort) +void Restructure::setTieHiPort(sta::LibertyPort* tie_hi_port) { - if (tieHiPort) { - hicell_ = tieHiPort->libertyCell()->name(); - hiport_ = tieHiPort->name(); + if (tie_hi_port) { + hicell_ = tie_hi_port->libertyCell()->name(); + hiport_ = tie_hi_port->name(); } } -void Restructure::setTieLoPort(sta::LibertyPort* tieLoPort) +void Restructure::setTieLoPort(sta::LibertyPort* tie_lo_port) { - if (tieLoPort) { - locell_ = tieLoPort->libertyCell()->name(); - loport_ = tieLoPort->name(); + if (tie_lo_port) { + locell_ = tie_lo_port->libertyCell()->name(); + loport_ = tie_lo_port->name(); } } diff --git a/src/rmp/src/delay_optimization_strategy.cpp b/src/rmp/src/delay_optimization_strategy.cpp index 016858c750c..188bb61ca2f 100644 --- a/src/rmp/src/delay_optimization_strategy.cpp +++ b/src/rmp/src/delay_optimization_strategy.cpp @@ -20,6 +20,7 @@ #include "utl/deleter.h" namespace abc { +// NOLINTBEGIN(readability-identifier-naming) extern Abc_Ntk_t* Abc_NtkMap(Abc_Ntk_t* pNtk, Mio_Library_t* userLib, double DelayTarget, @@ -37,6 +38,7 @@ extern Abc_Ntk_t* Abc_NtkMap(Abc_Ntk_t* pNtk, int fVerbose); extern void Abc_FrameSetLibGen(void* pLib); extern void Abc_FrameSetDrivingCell(char* pName); +// NOLINTEND(readability-identifier-naming) } // namespace abc namespace rmp { diff --git a/src/rmp/src/genetic_strategy.cpp b/src/rmp/src/genetic_strategy.cpp index 97fcf1fb468..2707315eefa 100644 --- a/src/rmp/src/genetic_strategy.cpp +++ b/src/rmp/src/genetic_strategy.cpp @@ -126,8 +126,8 @@ std::vector GeneticStrategy::RunStrategy( // Selection std::ranges::stable_sort( population, std::ranges::greater{}, &SolutionSlack::WorstSlack); - std::vector newPopulation; - newPopulation.reserve(population_size_); + std::vector new_population; + new_population.reserve(population_size_); for (int j = 0; j < population_size_; j++) { std::vector tournament(tournament_size_); std::generate_n(tournament.begin(), tournament_size_, [&]() { @@ -141,17 +141,17 @@ std::vector GeneticStrategy::RunStrategy( static_cast(tournament_probability_)); }); if (winner != tournament.end()) { - newPopulation.emplace_back(population[*winner]); + new_population.emplace_back(population[*winner]); } } - removeDuplicates(newPopulation, logger); + removeDuplicates(new_population, logger); // No winners from tournament, use first candidate - if (newPopulation.empty()) { - newPopulation.emplace_back(population.front()); + if (new_population.empty()) { + new_population.emplace_back(population.front()); } - population = std::move(newPopulation); + population = std::move(new_population); for (const auto& candidate : population) { debugPrint(logger, RMP, "genetic", 1, candidate.toString()); diff --git a/src/rmp/src/gia.cpp b/src/rmp/src/gia.cpp index b33d34f4dba..8123b5ecaad 100644 --- a/src/rmp/src/gia.cpp +++ b/src/rmp/src/gia.cpp @@ -43,6 +43,7 @@ #include "utl/unique_name.h" namespace abc { +// NOLINTBEGIN(readability-identifier-naming) extern Abc_Ntk_t* Abc_NtkFromAigPhase(Aig_Man_t* pMan); extern Abc_Ntk_t* Abc_NtkFromCellMappedGia(Gia_Man_t* p, int fUseBuffs); extern Abc_Ntk_t* Abc_NtkFromDarChoices(Abc_Ntk_t* pNtkOld, Aig_Man_t* pMan); @@ -79,6 +80,7 @@ extern Vec_Ptr_t* Abc_NtkCollectCiNames(Abc_Ntk_t* pNtk); extern Vec_Ptr_t* Abc_NtkCollectCoNames(Abc_Ntk_t* pNtk); extern void Abc_NtkRedirectCiCo(Abc_Ntk_t* pNtk); extern void Abc_FrameSetLibGen(void* pLib); +// NOLINTEND(readability-identifier-naming) } // namespace abc namespace rmp { diff --git a/src/rmp/src/slack_tuning_strategy.cpp b/src/rmp/src/slack_tuning_strategy.cpp index ab93488f1fa..ea153e8f0fe 100644 --- a/src/rmp/src/slack_tuning_strategy.cpp +++ b/src/rmp/src/slack_tuning_strategy.cpp @@ -39,19 +39,19 @@ std::string SolutionSlack::toString() const return "[]"; } - std::ostringstream resStream; - resStream << '[' << std::to_string(solution_.front().id); + std::ostringstream res_stream; + res_stream << '[' << std::to_string(solution_.front().id); for (int i = 1; i < solution_.size(); i++) { - resStream << ", " << std::to_string(solution_[i].id); + res_stream << ", " << std::to_string(solution_[i].id); } - resStream << "], worst slack: "; + res_stream << "], worst slack: "; if (worst_slack_) { - resStream << *worst_slack_; + res_stream << *worst_slack_; } else { - resStream << "not computed"; + res_stream << "not computed"; } - return resStream.str(); + return res_stream.str(); } SolutionSlack::ResultOps SolutionSlack::RandomNeighbor( diff --git a/src/rmp/test/cpp/TestAbc.cc b/src/rmp/test/cpp/TestAbc.cc index 4885e51d7a2..d881ae0638c 100644 --- a/src/rmp/test/cpp/TestAbc.cc +++ b/src/rmp/test/cpp/TestAbc.cc @@ -51,7 +51,7 @@ using cut::AbcLibraryFactory; using cut::LogicCut; using cut::LogicExtractorFactory; -static const std::string prefix("_main/src/rmp/test/"); +static const std::string kPrefix("_main/src/rmp/test/"); std::once_flag init_abc_flag; @@ -62,12 +62,12 @@ class AbcTest : public tst::Fixture { std::call_once(init_abc_flag, []() { abc::Abc_Start(); }); - library_ = readLiberty(prefix + "Nangate45/Nangate45_typ.lib"); + library_ = readLiberty(kPrefix + "Nangate45/Nangate45_typ.lib"); odb::dbTech* tech - = loadTechLef("nangate45", prefix + "Nangate45/Nangate45_tech.lef"); + = loadTechLef("nangate45", kPrefix + "Nangate45/Nangate45_tech.lef"); loadLibaryLef( - tech, "nangate45", prefix + "Nangate45/Nangate45_stdcell.lef"); + tech, "nangate45", kPrefix + "Nangate45/Nangate45_stdcell.lef"); } void LoadVerilog(const std::string& file_name, const std::string& top = "top") @@ -133,7 +133,7 @@ TEST_F(AbcTest, InsertingMappedLogicAfterOptimizationCutDoesNotThrow) factory.AddDbSta(sta_.get()); AbcLibrary abc_library = factory.Build(); - LoadVerilog(prefix + "aes_nangate45.v", /*top=*/"aes_cipher_top"); + LoadVerilog(kPrefix + "aes_nangate45.v", /*top=*/"aes_cipher_top"); sta::dbNetwork* network = sta_->getDbNetwork(); sta::Vertex* flop_input_vertex = nullptr; @@ -162,7 +162,7 @@ TEST_F(AbcTest, InsertingMappedLogicAfterOptimizationCutDoesNotThrow) TEST_F(AbcTest, ResynthesisStrategyDoesNotThrow) { - LoadVerilog(prefix + "aes_nangate45.v", /*top=*/"aes_cipher_top"); + LoadVerilog(kPrefix + "aes_nangate45.v", /*top=*/"aes_cipher_top"); utl::UniqueName name_generator; ZeroSlackStrategy zero_slack;