Skip to content

Commit 9a0d0c7

Browse files
authored
Merge pull request #8621 from hzeller/feature-20251012-using-dbinst
Remove 'using odb::dbInst;' in header files to not pollute namespace.
2 parents 78af416 + 22678f4 commit 9a0d0c7

File tree

19 files changed

+85
-84
lines changed

19 files changed

+85
-84
lines changed

src/dpl/include/dpl/Opendp.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ using utl::Logger;
3131

3232
using odb::dbBlock;
3333
using odb::dbDatabase;
34-
using odb::dbInst;
3534
using odb::dbMaster;
3635
using odb::dbMasterType;
3736
using odb::dbTechLayer;
@@ -92,8 +91,8 @@ class Opendp
9291
Opendp(const Opendp&) = delete;
9392
Opendp& operator=(const Opendp&) = delete;
9493

95-
void legalCellPos(dbInst* db_inst); // call from rsz
96-
void initMacrosAndGrid(); // call from rsz
94+
void legalCellPos(odb::dbInst* db_inst); // call from rsz
95+
void initMacrosAndGrid(); // call from rsz
9796

9897
// legalize/report
9998
// max_displacment is in sites. use zero for defaults.
@@ -104,15 +103,15 @@ class Opendp
104103

105104
void setPaddingGlobal(int left, int right);
106105
void setPadding(dbMaster* master, int left, int right);
107-
void setPadding(dbInst* inst, int left, int right);
106+
void setPadding(odb::dbInst* inst, int left, int right);
108107
void setDebug(std::unique_ptr<dpl::DplObserver>& observer);
109108

110109
// Global padding.
111110
int padGlobalLeft() const;
112111
int padGlobalRight() const;
113112
// Find instance/master/global padding value for an instance.
114-
int padLeft(dbInst* inst) const;
115-
int padRight(dbInst* inst) const;
113+
int padLeft(odb::dbInst* inst) const;
114+
int padRight(odb::dbInst* inst) const;
116115

117116
void checkPlacement(bool verbose, const std::string& report_file_name = "");
118117
void fillerPlacement(const dbMasterSeq& filler_masters,
@@ -126,10 +125,11 @@ class Opendp
126125
void insertDecapCells(double target, IRDropByPoint& psm_ir_drops);
127126

128127
// Get the instance adjacent to the left or right of a given instance
129-
dbInst* getAdjacentInstance(dbInst* inst, bool left) const;
128+
odb::dbInst* getAdjacentInstance(odb::dbInst* inst, bool left) const;
130129

131130
// Find a cluster of instances that are touching each other
132-
std::vector<dbInst*> getAdjacentInstancesCluster(dbInst* inst) const;
131+
std::vector<odb::dbInst*> getAdjacentInstancesCluster(
132+
odb::dbInst* inst) const;
133133
Padding* getPadding() { return padding_.get(); }
134134
void improvePlacement(int seed,
135135
int max_displacement_x,
@@ -159,14 +159,14 @@ class Opendp
159159
friend class Graphics;
160160
void findDisplacementStats();
161161
DbuPt pointOffMacro(const Node& cell);
162-
void convertDbToCell(dbInst* db_inst, Node& cell);
162+
void convertDbToCell(odb::dbInst* db_inst, Node& cell);
163163
// Return error count.
164164
void saveViolations(const std::vector<Node*>& failures,
165165
odb::dbMarkerCategory* category,
166166
const std::string& violation_type = "") const;
167167
void importDb();
168168
void importClear();
169-
odb::Rect getBbox(dbInst* inst);
169+
odb::Rect getBbox(odb::dbInst* inst);
170170
void createNetwork();
171171
void createArchitecture();
172172
void setUpPlacementGroups();

src/dpl/include/dpl/OptMirror.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class Logger;
1616

1717
namespace dpl {
1818

19-
using odb::dbInst;
2019
using odb::dbNet;
2120

2221
using utl::Logger;
@@ -53,15 +52,15 @@ class OptimizeMirroring
5352
void run();
5453

5554
private:
56-
int mirrorCandidates(std::vector<dbInst*>& mirror_candidates);
55+
int mirrorCandidates(std::vector<odb::dbInst*>& mirror_candidates);
5756
void findNetBoxes();
58-
std::vector<dbInst*> findMirrorCandidates(NetBoxes& net_boxes);
57+
std::vector<odb::dbInst*> findMirrorCandidates(NetBoxes& net_boxes);
5958

60-
void updateNetBoxes(dbInst* inst);
61-
void saveNetBoxes(dbInst* inst);
62-
void restoreNetBoxes(dbInst* inst);
59+
void updateNetBoxes(odb::dbInst* inst);
60+
void saveNetBoxes(odb::dbInst* inst);
61+
void restoreNetBoxes(odb::dbInst* inst);
6362

64-
int64_t hpwl(dbInst* inst); // Sum of ITerm hpwl's.
63+
int64_t hpwl(odb::dbInst* inst); // Sum of ITerm hpwl's.
6564

6665
Logger* logger_ = nullptr;
6766
odb::dbDatabase* db_ = nullptr;

src/dpl/src/DecapPlacement.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ void Opendp::insertDecapInPos(dbMaster* master,
205205
{
206206
// insert decap inst
207207
std::string inst_name = "DECAP_" + to_string(decap_count_);
208-
dbInst* inst = dbInst::create(block_,
209-
master,
210-
inst_name.c_str(),
211-
/* physical_only */ true);
208+
odb::dbInst* inst = odb::dbInst::create(block_,
209+
master,
210+
inst_name.c_str(),
211+
/* physical_only */ true);
212212
const GridX grid_x = grid_->gridX(pos_x - core_.xMin());
213213
const GridY grid_y = grid_->gridSnapDownY(pos_y - core_.yMin());
214214
const odb::dbOrientType orient

src/dpl/src/FillerPlacement.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ void Opendp::placeRowFillers(GridY row,
216216
for (dbMaster* master : fillers) {
217217
std::string inst_name
218218
= prefix + to_string(row.v) + "_" + to_string(k.v);
219-
dbInst* inst = dbInst::create(block_,
220-
master,
221-
inst_name.c_str(),
222-
/* physical_only */ true);
219+
odb::dbInst* inst = odb::dbInst::create(block_,
220+
master,
221+
inst_name.c_str(),
222+
/* physical_only */ true);
223223
DbuX x{core_.xMin() + gridToDbu(k, site_width)};
224224
DbuY y{core_.yMin() + grid_->gridYToDbu(row)};
225225
inst->setOrient(orient);
@@ -292,15 +292,15 @@ dbMasterSeq& Opendp::gapFillers(
292292
void Opendp::removeFillers()
293293
{
294294
block_ = db_->getChip()->getBlock();
295-
for (dbInst* db_inst : block_->getInsts()) {
295+
for (odb::dbInst* db_inst : block_->getInsts()) {
296296
if (isFiller(db_inst)) {
297297
odb::dbInst::destroy(db_inst);
298298
}
299299
}
300300
}
301301

302302
/* static */
303-
bool Opendp::isFiller(dbInst* db_inst)
303+
bool Opendp::isFiller(odb::dbInst* db_inst)
304304
{
305305
dbMaster* db_master = db_inst->getMaster();
306306
return db_master->getType() == odb::dbMasterType::CORE_SPACER

src/dpl/src/Opendp.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ using std::string;
3333

3434
using utl::DPL;
3535

36+
using odb::dbInst;
3637
using odb::Rect;
3738

3839
////////////////////////////////////////////////////////////////
@@ -62,7 +63,7 @@ void Opendp::setPaddingGlobal(const int left, const int right)
6263
padding_->setPaddingGlobal(GridX{left}, GridX{right});
6364
}
6465

65-
void Opendp::setPadding(dbInst* inst, const int left, const int right)
66+
void Opendp::setPadding(odb::dbInst* inst, const int left, const int right)
6667
{
6768
padding_->setPadding(inst, GridX{left}, GridX{right});
6869
}
@@ -139,7 +140,7 @@ void Opendp::updateDbInstLocations()
139140
{
140141
for (auto& cell : network_->getNodes()) {
141142
if (!cell->isFixed() && cell->isStdCell()) {
142-
dbInst* db_inst_ = cell->getDbInst();
143+
odb::dbInst* db_inst_ = cell->getDbInst();
143144
// Only move the instance if necessary to avoid triggering callbacks.
144145
if (db_inst_->getOrient() != cell->getOrient()) {
145146
db_inst_->setOrient(cell->getOrient());
@@ -235,12 +236,12 @@ int Opendp::padGlobalRight() const
235236
return padding_->padGlobalRight().v;
236237
}
237238

238-
int Opendp::padLeft(dbInst* inst) const
239+
int Opendp::padLeft(odb::dbInst* inst) const
239240
{
240241
return padding_->padLeft(inst).v;
241242
}
242243

243-
int Opendp::padRight(dbInst* inst) const
244+
int Opendp::padRight(odb::dbInst* inst) const
244245
{
245246
return padding_->padRight(inst).v;
246247
}
@@ -354,7 +355,7 @@ void Opendp::groupInitPixels2()
354355
}
355356
}
356357

357-
dbInst* Opendp::getAdjacentInstance(dbInst* inst, bool left) const
358+
odb::dbInst* Opendp::getAdjacentInstance(odb::dbInst* inst, bool left) const
358359
{
359360
const Rect inst_rect = inst->getBBox()->getBox();
360361
DbuX x_dbu = left ? DbuX{inst_rect.xMin() - 1} : DbuX{inst_rect.xMax() + 1};
@@ -365,7 +366,7 @@ dbInst* Opendp::getAdjacentInstance(dbInst* inst, bool left) const
365366

366367
Pixel* pixel = grid_->gridPixel(x, y);
367368

368-
dbInst* adjacent_inst = nullptr;
369+
odb::dbInst* adjacent_inst = nullptr;
369370

370371
// do not return macros, endcaps and tapcells
371372
if (pixel != nullptr && pixel->cell && pixel->cell->getDbInst()->isCore()) {
@@ -379,9 +380,9 @@ std::vector<dbInst*> Opendp::getAdjacentInstancesCluster(dbInst* inst) const
379380
{
380381
const bool left = true;
381382
const bool right = false;
382-
std::vector<dbInst*> adj_inst_cluster;
383+
std::vector<odb::dbInst*> adj_inst_cluster;
383384

384-
dbInst* left_inst = getAdjacentInstance(inst, left);
385+
odb::dbInst* left_inst = getAdjacentInstance(inst, left);
385386
while (left_inst != nullptr) {
386387
adj_inst_cluster.push_back(left_inst);
387388
// the right instance can be ignored, since it was added in the line above
@@ -391,7 +392,7 @@ std::vector<dbInst*> Opendp::getAdjacentInstancesCluster(dbInst* inst) const
391392
std::reverse(adj_inst_cluster.begin(), adj_inst_cluster.end());
392393
adj_inst_cluster.push_back(inst);
393394

394-
dbInst* right_inst = getAdjacentInstance(inst, right);
395+
odb::dbInst* right_inst = getAdjacentInstance(inst, right);
395396
while (right_inst != nullptr) {
396397
adj_inst_cluster.push_back(right_inst);
397398
// the left instance can be ignored, since it was added in the line above

src/dpl/src/OptMirror.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ void OptimizeMirroring::run()
6969
return net_box1->hpwl() > net_box2->hpwl();
7070
});
7171

72-
std::vector<dbInst*> mirror_candidates = findMirrorCandidates(sorted_boxes);
72+
std::vector<odb::dbInst*> mirror_candidates
73+
= findMirrorCandidates(sorted_boxes);
7374
odb::WireLengthEvaluator eval(block_);
7475
int64_t hpwl_before = eval.hpwl();
7576
int mirror_count = mirrorCandidates(mirror_candidates);
@@ -113,23 +114,23 @@ void OptimizeMirroring::findNetBoxes()
113114
}
114115
}
115116

116-
std::vector<dbInst*> OptimizeMirroring::findMirrorCandidates(
117+
std::vector<odb::dbInst*> OptimizeMirroring::findMirrorCandidates(
117118
NetBoxes& net_boxes)
118119
{
119-
std::vector<dbInst*> mirror_candidates;
120-
unordered_set<dbInst*> existing;
120+
std::vector<odb::dbInst*> mirror_candidates;
121+
unordered_set<odb::dbInst*> existing;
121122
// Find inst terms on the boundary of the net boxes.
122123
for (NetBox* net_box : net_boxes) {
123124
if (!net_box->isIgnore()) {
124125
dbNet* net = net_box->getNet();
125126
const odb::Rect& box = net_box->getBox();
126127
for (dbITerm* iterm : net->getITerms()) {
127-
dbInst* inst = iterm->getInst();
128+
odb::dbInst* inst = iterm->getInst();
128129
int x, y;
129130
if (inst->isCore() && !inst->isFixed() && iterm->getAvgXY(&x, &y)
130131
&& (x == box.xMin() || x == box.xMax() || y == box.yMin()
131132
|| y == box.yMax())) {
132-
dbInst* inst = iterm->getInst();
133+
odb::dbInst* inst = iterm->getInst();
133134
if (existing.find(inst) == existing.end()) {
134135
mirror_candidates.push_back(inst);
135136
existing.insert(inst);
@@ -147,10 +148,11 @@ std::vector<dbInst*> OptimizeMirroring::findMirrorCandidates(
147148
return mirror_candidates;
148149
}
149150

150-
int OptimizeMirroring::mirrorCandidates(std::vector<dbInst*>& mirror_candidates)
151+
int OptimizeMirroring::mirrorCandidates(
152+
std::vector<odb::dbInst*>& mirror_candidates)
151153
{
152154
int mirror_count = 0;
153-
for (dbInst* inst : mirror_candidates) {
155+
for (odb::dbInst* inst : mirror_candidates) {
154156
// Use hpwl of all nets connected to the instance terms
155157
// before/after to determine incremental change to total hpwl.
156158
int64_t hpwl_before = hpwl(inst);
@@ -199,7 +201,7 @@ static dbOrientType orientMirrorY(const dbOrientType& orient)
199201
return dbOrientType::R0;
200202
}
201203

202-
int64_t OptimizeMirroring::hpwl(dbInst* inst)
204+
int64_t OptimizeMirroring::hpwl(odb::dbInst* inst)
203205
{
204206
int64_t inst_hpwl = 0;
205207
for (dbITerm* iterm : inst->getITerms()) {
@@ -214,7 +216,7 @@ int64_t OptimizeMirroring::hpwl(dbInst* inst)
214216
return inst_hpwl;
215217
}
216218

217-
void OptimizeMirroring::updateNetBoxes(dbInst* inst)
219+
void OptimizeMirroring::updateNetBoxes(odb::dbInst* inst)
218220
{
219221
for (dbITerm* iterm : inst->getITerms()) {
220222
dbNet* net = iterm->getNet();
@@ -227,7 +229,7 @@ void OptimizeMirroring::updateNetBoxes(dbInst* inst)
227229
}
228230
}
229231

230-
void OptimizeMirroring::saveNetBoxes(dbInst* inst)
232+
void OptimizeMirroring::saveNetBoxes(odb::dbInst* inst)
231233
{
232234
for (dbITerm* iterm : inst->getITerms()) {
233235
dbNet* net = iterm->getNet();
@@ -237,7 +239,7 @@ void OptimizeMirroring::saveNetBoxes(dbInst* inst)
237239
}
238240
}
239241

240-
void OptimizeMirroring::restoreNetBoxes(dbInst* inst)
242+
void OptimizeMirroring::restoreNetBoxes(odb::dbInst* inst)
241243
{
242244
for (dbITerm* iterm : inst->getITerms()) {
243245
dbNet* net = iterm->getNet();

src/dpl/src/Place.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ void Opendp::initMacrosAndGrid()
10541054
setFixedGridCells();
10551055
}
10561056

1057-
void Opendp::convertDbToCell(dbInst* db_inst, Node& cell)
1057+
void Opendp::convertDbToCell(odb::dbInst* db_inst, Node& cell)
10581058
{
10591059
cell.setType(Node::CELL);
10601060
cell.setDbInst(db_inst);
@@ -1104,7 +1104,7 @@ DbuPt Opendp::pointOffMacro(const Node& cell)
11041104
return init;
11051105
}
11061106

1107-
void Opendp::legalCellPos(dbInst* db_inst)
1107+
void Opendp::legalCellPos(odb::dbInst* db_inst)
11081108
{
11091109
Node cell;
11101110
convertDbToCell(db_inst, cell);

src/dpl/src/dbToOpendp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static bool swapWidthHeight(const dbOrientType& orient)
8181
return false;
8282
}
8383

84-
Rect Opendp::getBbox(dbInst* inst)
84+
Rect Opendp::getBbox(odb::dbInst* inst)
8585
{
8686
dbMaster* master = inst->getMaster();
8787

@@ -109,6 +109,7 @@ void Opendp::createNetwork()
109109
min_row_height = std::min(min_row_height, row->getSite()->getHeight());
110110
}
111111
///////////////////////////////////
112+
using odb::dbInst;
112113
auto block_insts = block->getInsts();
113114
std::vector<dbInst*> insts(block_insts.begin(), block_insts.end());
114115
std::stable_sort(insts.begin(), insts.end(), [](dbInst* a, dbInst* b) {

src/dpl/src/graphics/Graphics.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ using odb::dbBox;
1616

1717
Graphics::Graphics(Opendp* dp,
1818
float min_displacement,
19-
const dbInst* debug_instance)
19+
const odb::dbInst* debug_instance)
2020
: dp_(dp),
2121
debug_instance_(debug_instance),
2222
min_displacement_(min_displacement)
@@ -29,7 +29,7 @@ void Graphics::startPlacement(dbBlock* block)
2929
block_ = block;
3030
}
3131

32-
void Graphics::placeInstance(dbInst* instance)
32+
void Graphics::placeInstance(odb::dbInst* instance)
3333
{
3434
if (!instance || instance != debug_instance_) {
3535
return;

0 commit comments

Comments
 (0)