Skip to content

Commit addabb5

Browse files
committed
address gemini
Signed-off-by: PrecisEDAnon <PrecisEDAnon@proton.me>
1 parent 8685a33 commit addabb5

File tree

6 files changed

+264
-339
lines changed

6 files changed

+264
-339
lines changed

src/gpl/src/replace.cpp

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -26,56 +26,14 @@
2626
#include "routeBase.h"
2727
#include "rsz/Resizer.hh"
2828
#include "timingBase.h"
29+
#include "utl/Environment.h"
2930
#include "utl/Logger.h"
3031
#include "utl/validation.h"
3132

3233
namespace gpl {
3334

3435
using utl::GPL;
3536

36-
namespace {
37-
bool envVarTruthy(const char* name)
38-
{
39-
const char* raw = std::getenv(name);
40-
if (raw == nullptr || *raw == '\0') {
41-
return false;
42-
}
43-
44-
std::string value(raw);
45-
const size_t start = value.find_first_not_of(" \t\n\r");
46-
if (start == std::string::npos) {
47-
return false;
48-
}
49-
const size_t end = value.find_last_not_of(" \t\n\r");
50-
value = value.substr(start, end - start + 1);
51-
std::transform(
52-
value.begin(), value.end(), value.begin(), [](unsigned char c) {
53-
return static_cast<char>(std::tolower(c));
54-
});
55-
return value == "1" || value == "true" || value == "yes" || value == "on";
56-
}
57-
58-
bool useOrfsNewOpenroad()
59-
{
60-
return envVarTruthy("ORFS_ENABLE_NEW_OPENROAD");
61-
}
62-
63-
std::optional<float> getEnvFloat(const char* name)
64-
{
65-
const char* raw = std::getenv(name);
66-
if (raw == nullptr || *raw == '\0') {
67-
return std::nullopt;
68-
}
69-
70-
char* end = nullptr;
71-
const float value = std::strtof(raw, &end);
72-
if (end == raw || (end != nullptr && *end != '\0')) {
73-
return std::nullopt;
74-
}
75-
return value;
76-
}
77-
} // namespace
78-
7937
Replace::Replace(odb::dbDatabase* odb,
8038
sta::dbSta* sta,
8139
rsz::Resizer* resizer,
@@ -304,8 +262,9 @@ bool Replace::initNesterovPlace(const PlaceOptions& options, const int threads)
304262
tb_ = std::make_shared<TimingBase>(nbc_, rs_, log_);
305263
tb_->setTimingNetWeightOverflows(options.timingNetWeightOverflows);
306264
float timing_net_weight_max = options.timingNetWeightMax;
307-
if (useOrfsNewOpenroad() && !options.timingNetWeightMaxUserSet) {
308-
if (auto env_max = getEnvFloat("GPL_WEIGHT_MAX")) {
265+
if (utl::envVarTruthy("ORFS_ENABLE_NEW_OPENROAD")
266+
&& !options.timingNetWeightMaxUserSet) {
267+
if (auto env_max = utl::getEnvFloat("GPL_WEIGHT_MAX")) {
309268
if (*env_max > 0.0f) {
310269
timing_net_weight_max = *env_max;
311270
} else {

0 commit comments

Comments
 (0)