From dd9966de376b6a9666f9b2e82e73d2164cbcbb27 Mon Sep 17 00:00:00 2001 From: bernardo Date: Sun, 8 Dec 2024 22:20:18 +0000 Subject: [PATCH] drt: elimination of drt::frInst dbTransform Signed-off-by: bernardo --- src/drt/src/DesignCallBack.cpp | 2 -- src/drt/src/db/obj/frInst.cpp | 6 ++---- src/drt/src/db/obj/frInst.h | 19 +++++++------------ src/drt/src/db/obj/frInstTerm.cpp | 15 ++++++++------- src/drt/src/db/obj/frRPin.cpp | 2 +- src/drt/src/db/obj/frRef.h | 4 ---- src/drt/src/db/obj/frVia.h | 6 +++--- src/drt/src/dr/FlexDR_init.cpp | 10 +++------- src/drt/src/dr/FlexDR_maze.cpp | 2 +- src/drt/src/frRegionQuery.cpp | 12 ++++++------ src/drt/src/gr/FlexGR.cpp | 2 +- src/drt/src/io/GuideProcessor.cpp | 4 ++-- src/drt/src/io/io.cpp | 4 ---- src/drt/src/io/io_parser_helper.cpp | 2 +- src/drt/src/pa/FlexPA_prep.cpp | 12 ++++++------ src/drt/src/ta/FlexTA_init.cpp | 4 ++-- 16 files changed, 43 insertions(+), 63 deletions(-) diff --git a/src/drt/src/DesignCallBack.cpp b/src/drt/src/DesignCallBack.cpp index 955aa28ff69..722319a7d38 100644 --- a/src/drt/src/DesignCallBack.cpp +++ b/src/drt/src/DesignCallBack.cpp @@ -66,8 +66,6 @@ void DesignCallBack::inDbPostMoveInst(odb::dbInst* db_inst) auto block = db_inst->getBlock(); x = defdist(block, x); y = defdist(block, y); - inst->setOrigin({x, y}); - inst->setOrient(db_inst->getOrient()); if (design->getRegionQuery() != nullptr) { design->getRegionQuery()->addBlockObj(inst); } diff --git a/src/drt/src/db/obj/frInst.cpp b/src/drt/src/db/obj/frInst.cpp index 1b31c60dd66..fc9d67632d2 100644 --- a/src/drt/src/db/obj/frInst.cpp +++ b/src/drt/src/db/obj/frInst.cpp @@ -35,16 +35,14 @@ namespace drt { Rect frInst::getBBox() const { Rect box = getMaster()->getBBox(); - dbTransform xform = getDBTransform(); - xform.apply(box); + getTransform().apply(box); return box; } Rect frInst::getBoundaryBBox() const { Rect box = getMaster()->getDieBox(); - dbTransform xform = getDBTransform(); - xform.apply(box); + getTransform().apply(box); return box; } diff --git a/src/drt/src/db/obj/frInst.h b/src/drt/src/db/obj/frInst.h index 1b8f37ab9c9..d5829ed734f 100644 --- a/src/drt/src/db/obj/frInst.h +++ b/src/drt/src/db/obj/frInst.h @@ -83,24 +83,20 @@ class frInst : public frRef /* from frRef * getOrient - * setOrient * getOrigin - * setOrigin * getTransform - * setTransform */ - dbOrientType getOrient() const override { return xform_.getOrient(); } - void setOrient(const dbOrientType& tmpOrient) override + dbOrientType getOrient() const override { - xform_.setOrient(tmpOrient); + return db_inst_->getTransform().getOrient(); + } + Point getOrigin() const override + { + return db_inst_->getTransform().getOffset(); } - Point getOrigin() const override { return xform_.getOffset(); } - void setOrigin(const Point& tmpPoint) override { xform_.setOffset(tmpPoint); } - dbTransform getTransform() const override { return xform_; } - void setTransform(const dbTransform& xformIn) override { xform_ = xformIn; } odb::dbInst* getDBInst() const { return db_inst_; } - dbTransform getDBTransform() const { return db_inst_->getTransform(); } + dbTransform getTransform() const { return db_inst_->getTransform(); } /* from frPinFig * hasPin @@ -148,7 +144,6 @@ class frInst : public frRef std::vector> instTerms_; std::vector> instBlockages_; odb::dbInst* db_inst_; - dbTransform xform_; int pinAccessIdx_; bool toBeDeleted_; }; diff --git a/src/drt/src/db/obj/frInstTerm.cpp b/src/drt/src/db/obj/frInstTerm.cpp index 7f96389998a..e9940f3313d 100644 --- a/src/drt/src/db/obj/frInstTerm.cpp +++ b/src/drt/src/db/obj/frInstTerm.cpp @@ -40,11 +40,12 @@ frString frInstTerm::getName() const frAccessPoint* frInstTerm::getAccessPoint(frCoord x, frCoord y, frLayerNum lNum) { auto inst = getInst(); - dbTransform shiftXform = inst->getTransform(); - Point offset(shiftXform.getOffset()); - x = x - offset.getX(); - y = y - offset.getY(); - return term_->getAccessPoint(x, y, lNum, inst->getPinAccessIdx()); + dbTransform shiftXform; + inst->getTransform().invert(shiftXform); + Point pt(x, y); + shiftXform.apply(pt); + return term_->getAccessPoint( + pt.getX(), pt.getY(), lNum, inst->getPinAccessIdx()); } bool frInstTerm::hasAccessPoint(frCoord x, frCoord y, frLayerNum lNum) @@ -56,7 +57,7 @@ void frInstTerm::getShapes(std::vector& outShapes) const { term_->getShapes(outShapes); for (auto& shape : outShapes) { - dbTransform trans = getInst()->getDBTransform(); + dbTransform trans = getInst()->getTransform(); shape.move(trans); } } @@ -64,7 +65,7 @@ void frInstTerm::getShapes(std::vector& outShapes) const Rect frInstTerm::getBBox() const { Rect bbox(term_->getBBox()); - dbTransform trans = getInst()->getDBTransform(); + dbTransform trans = getInst()->getTransform(); trans.apply(bbox); return bbox; } diff --git a/src/drt/src/db/obj/frRPin.cpp b/src/drt/src/db/obj/frRPin.cpp index 62065776ab3..a9d4c0858a9 100644 --- a/src/drt/src/db/obj/frRPin.cpp +++ b/src/drt/src/db/obj/frRPin.cpp @@ -40,7 +40,7 @@ Rect frRPin::getBBox() switch (term->typeId()) { case frcInstTerm: { auto inst = static_cast(term)->getInst(); - dbTransform shiftXform = inst->getDBTransform(); + dbTransform shiftXform = inst->getTransform(); pt = accessPoint->getPoint(); shiftXform.apply(pt); diff --git a/src/drt/src/db/obj/frRef.h b/src/drt/src/db/obj/frRef.h index 583babb546a..6358214b413 100644 --- a/src/drt/src/db/obj/frRef.h +++ b/src/drt/src/db/obj/frRef.h @@ -39,10 +39,6 @@ class frRef : public frPinFig virtual dbOrientType getOrient() const = 0; virtual Point getOrigin() const = 0; virtual dbTransform getTransform() const = 0; - // setters - virtual void setOrient(const dbOrientType& tmpOrient) = 0; - virtual void setOrigin(const Point& tmpPoint) = 0; - virtual void setTransform(const dbTransform& xform) = 0; protected: // constructors diff --git a/src/drt/src/db/obj/frVia.h b/src/drt/src/db/obj/frVia.h index 498564a301c..668feb4a8d8 100644 --- a/src/drt/src/db/obj/frVia.h +++ b/src/drt/src/db/obj/frVia.h @@ -102,11 +102,11 @@ class frVia : public frRef */ dbOrientType getOrient() const override { return dbOrientType(); } - void setOrient(const dbOrientType& tmpOrient) override { ; } + void setOrient(const dbOrientType& tmpOrient) { ; } Point getOrigin() const override { return origin_; } - void setOrigin(const Point& tmpPoint) override { origin_ = tmpPoint; } + void setOrigin(const Point& tmpPoint) { origin_ = tmpPoint; } dbTransform getTransform() const override { return origin_; } - void setTransform(const dbTransform& xformIn) override {} + void setTransform(const dbTransform& xformIn) {} /* from frPinFig * hasPin diff --git a/src/drt/src/dr/FlexDR_init.cpp b/src/drt/src/dr/FlexDR_init.cpp index b4e0b0ff0f5..ed97850da43 100644 --- a/src/drt/src/dr/FlexDR_init.cpp +++ b/src/drt/src/dr/FlexDR_init.cpp @@ -1177,15 +1177,12 @@ void FlexDRWorker::initNet_term(const frDesign* design, { for (auto term : terms) { // ap - // TODO is instXform used properly here? - dbTransform instXform; // (0,0), R0 dbTransform shiftXform; switch (term->typeId()) { case frcInstTerm: { auto instTerm = static_cast(term); frInst* inst = instTerm->getInst(); - shiftXform = inst->getDBTransform(); - instXform = inst->getDBTransform(); + shiftXform = inst->getTransform(); auto trueTerm = instTerm->getTerm(); const std::string name = inst->getName() + "/" + trueTerm->getName(); initNet_term_helper( @@ -2900,8 +2897,7 @@ void FlexDRWorker::initMazeCost_terms(const std::set& objs, } else if (obj->typeId() == frcInstTerm) { auto instTerm = static_cast(obj); auto inst = instTerm->getInst(); - const dbTransform xform = inst->getDBTransform(); - const dbTransform shiftXform = inst->getDBTransform(); + const dbTransform xform = inst->getTransform(); const dbMasterType masterType = inst->getMaster()->getMasterType(); bool accessHorz = false; bool accessVert = false; @@ -2970,7 +2966,7 @@ void FlexDRWorker::initMazeCost_terms(const std::set& objs, if (masterType.isBlock()) { modCornerToCornerSpacing( box, zIdx, type); // temp solution for ISPD19 benchmarks - modBlockedEdgesForMacroPin(instTerm, shiftXform, isAddPathCost); + modBlockedEdgesForMacroPin(instTerm, xform, isAddPathCost); if (isAddPathCost) { type = ModCostType::setFixedShape; } else { diff --git a/src/drt/src/dr/FlexDR_maze.cpp b/src/drt/src/dr/FlexDR_maze.cpp index 81e15c04079..00ddf6a2ffb 100644 --- a/src/drt/src/dr/FlexDR_maze.cpp +++ b/src/drt/src/dr/FlexDR_maze.cpp @@ -2779,7 +2779,7 @@ bool FlexDRWorker::addApPathSegs(const FlexMazeIdx& apIdx, drNet* net) connecting = &end; } if (inst) { - dbTransform trans = inst->getDBTransform(); + dbTransform trans = inst->getTransform(); trans.apply(begin); trans.apply(end); if (end < begin) { // if rotation swapped order, correct it diff --git a/src/drt/src/frRegionQuery.cpp b/src/drt/src/frRegionQuery.cpp index 2f720435e31..c9a35d22fd4 100644 --- a/src/drt/src/frRegionQuery.cpp +++ b/src/drt/src/frRegionQuery.cpp @@ -187,7 +187,7 @@ void frRegionQuery::addBlockObj(frBlockObject* obj) switch (obj->typeId()) { case frcInstTerm: { auto instTerm = static_cast(obj); - dbTransform xform = instTerm->getInst()->getDBTransform(); + dbTransform xform = instTerm->getInst()->getTransform(); for (auto& pin : instTerm->getTerm()->getPins()) { for (auto& uFig : pin->getFigs()) { auto shape = uFig.get(); @@ -201,7 +201,7 @@ void frRegionQuery::addBlockObj(frBlockObject* obj) } case frcInstBlockage: { auto instBlk = static_cast(obj); - dbTransform xform = instBlk->getInst()->getDBTransform(); + dbTransform xform = instBlk->getInst()->getTransform(); auto blk = instBlk->getBlockage(); auto pin = blk->getPin(); for (auto& uFig : pin->getFigs()) { @@ -260,7 +260,7 @@ void frRegionQuery::removeBlockObj(frBlockObject* obj) switch (obj->typeId()) { case frcInstTerm: { auto instTerm = static_cast(obj); - dbTransform xform = instTerm->getInst()->getDBTransform(); + dbTransform xform = instTerm->getInst()->getTransform(); for (auto& pin : instTerm->getTerm()->getPins()) { for (auto& uFig : pin->getFigs()) { auto shape = uFig.get(); @@ -274,7 +274,7 @@ void frRegionQuery::removeBlockObj(frBlockObject* obj) } case frcInstBlockage: { auto instBlk = static_cast(obj); - dbTransform xform = instBlk->getInst()->getDBTransform(); + dbTransform xform = instBlk->getInst()->getTransform(); auto blk = instBlk->getBlockage(); auto pin = blk->getPin(); for (auto& uFig : pin->getFigs()) { @@ -458,7 +458,7 @@ void frRegionQuery::addGRObj(grVia* via) void frRegionQuery::Impl::add(frInstTerm* instTerm, ObjectsByLayer& allShapes) { - dbTransform xform = instTerm->getInst()->getDBTransform(); + dbTransform xform = instTerm->getInst()->getTransform(); for (auto& pin : instTerm->getTerm()->getPins()) { for (auto& uFig : pin->getFigs()) { @@ -495,7 +495,7 @@ void frRegionQuery::Impl::add(frBTerm* term, void frRegionQuery::Impl::add(frInstBlockage* instBlk, ObjectsByLayer& allShapes) { - dbTransform xform = instBlk->getInst()->getDBTransform(); + dbTransform xform = instBlk->getInst()->getTransform(); auto blk = instBlk->getBlockage(); auto pin = blk->getPin(); for (auto& uFig : pin->getFigs()) { diff --git a/src/drt/src/gr/FlexGR.cpp b/src/drt/src/gr/FlexGR.cpp index 85de4c07f73..764389b9a02 100644 --- a/src/drt/src/gr/FlexGR.cpp +++ b/src/drt/src/gr/FlexGR.cpp @@ -1642,7 +1642,7 @@ void FlexGR::initGR_genTopology_net(frNet* net) Point pt; if (rpin->getFrTerm()->typeId() == frcInstTerm) { auto inst = static_cast(rpin->getFrTerm())->getInst(); - dbTransform shiftXform = inst->getDBTransform(); + dbTransform shiftXform = inst->getTransform(); pt = rpin->getAccessPoint()->getPoint(); shiftXform.apply(pt); } else { diff --git a/src/drt/src/io/GuideProcessor.cpp b/src/drt/src/io/GuideProcessor.cpp index ebf52a69534..83e41252750 100644 --- a/src/drt/src/io/GuideProcessor.cpp +++ b/src/drt/src/io/GuideProcessor.cpp @@ -112,7 +112,7 @@ std::vector getAccessPoints(const frBlockObject* pin) std::vector result; if (pin->typeId() == frcInstTerm) { auto iterm = static_cast(pin); - auto transform = iterm->getInst()->getDBTransform(); + auto transform = iterm->getInst()->getTransform(); const int pin_access_idx = iterm->getInst()->getPinAccessIdx(); for (const auto& mpin : iterm->getTerm()->getPins()) { if (!mpin->hasPinAccess()) { @@ -1327,7 +1327,7 @@ void GuideProcessor::genGuides_addCoverGuide_helper(frInstTerm* iterm, { const frInst* inst = iterm->getInst(); const size_t num_pins = iterm->getTerm()->getPins().size(); - dbTransform transform = inst->getDBTransform(); + dbTransform transform = inst->getTransform(); for (int pin_idx = 0; pin_idx < num_pins; pin_idx++) { const frAccessPoint* pref_ap = getPrefAp(iterm, pin_idx); if (pref_ap) { diff --git a/src/drt/src/io/io.cpp b/src/drt/src/io/io.cpp index d2efa2d8d62..ed9cf3e0e2a 100644 --- a/src/drt/src/io/io.cpp +++ b/src/drt/src/io/io.cpp @@ -128,10 +128,6 @@ void io::Parser::setInst(odb::dbInst* inst) auto uInst = std::make_unique(inst->getName(), master, inst); auto tmpInst = uInst.get(); - int x, y; - inst->getLocation(x, y); - tmpInst->setOrigin(Point(x, y)); - tmpInst->setOrient(inst->getOrient()); int numInstTerms = 0; tmpInst->setPinAccessIdx(inst->getPinAccessIdx()); for (auto& uTerm : tmpInst->getMaster()->getTerms()) { diff --git a/src/drt/src/io/io_parser_helper.cpp b/src/drt/src/io/io_parser_helper.cpp index 4cd2ff0a7e8..e7965b22b69 100644 --- a/src/drt/src/io/io_parser_helper.cpp +++ b/src/drt/src/io/io_parser_helper.cpp @@ -878,7 +878,7 @@ void io::Parser::checkPins() if (!inst->getMaster()->getMasterType().isBlock()) { continue; } - dbTransform xform = inst->getDBTransform(); + dbTransform xform = inst->getTransform(); for (auto& iTerm : inst->getInstTerms()) { if (!iTerm->hasNet() || iTerm->getNet()->isSpecial()) { continue; diff --git a/src/drt/src/pa/FlexPA_prep.cpp b/src/drt/src/pa/FlexPA_prep.cpp index f9197ece799..319475bb260 100644 --- a/src/drt/src/pa/FlexPA_prep.cpp +++ b/src/drt/src/pa/FlexPA_prep.cpp @@ -74,7 +74,7 @@ FlexPA::mergePinShapes(T* pin, frInstTerm* inst_term, const bool is_shrink) dbTransform xform; if (inst) { - xform = inst->getDBTransform(); + xform = inst->getTransform(); } frTechObject* tech = getDesign()->getTech(); @@ -1790,7 +1790,7 @@ void FlexPA::revertAccessPoints() const auto& unique = unique_insts_.getUnique(); for (auto& inst : unique) { dbTransform revertXform; - inst->getDBTransform().invert(revertXform); + inst->getTransform().invert(revertXform); const auto pin_access_idx = unique_insts_.getPAIndex(inst); for (auto& inst_term : inst->getInstTerms()) { @@ -2091,7 +2091,7 @@ void FlexPA::addAccessPatternObj( std::vector>& vias, const bool isPrev) { - const dbTransform xform = inst->getDBTransform(); + const dbTransform xform = inst->getTransform(); int access_point_idx = 0; auto& access_points = access_pattern->getPattern(); @@ -2541,7 +2541,7 @@ int FlexPA::getEdgeCost( has_vio = (vio_edges[edge_idx] == 1); } else { auto curr_unique_inst = unique_insts_.getUnique(curr_unique_inst_idx); - dbTransform xform = curr_unique_inst->getDBTransform(); + dbTransform xform = curr_unique_inst->getTransform(); // check DRC std::vector> objs; const auto& [pin_1, inst_term_1] = pins[prev_pin_idx]; @@ -2710,7 +2710,7 @@ bool FlexPA::genPatterns_commit( auto rvia = via.get(); temp_vias.push_back(std::move(via)); - dbTransform xform = inst->getDBTransform(); + dbTransform xform = inst->getTransform(); Point pt(access_point->getPoint()); xform.apply(pt); rvia->setOrigin(pt); @@ -2802,7 +2802,7 @@ void FlexPA::genPatternsPrintDebug( auto& [pin, inst_term] = pins[0]; if (inst_term) { frInst* inst = inst_term->getInst(); - xform = inst->getDBTransform(); + xform = inst->getTransform(); } std::cout << "failed pattern:"; diff --git a/src/drt/src/ta/FlexTA_init.cpp b/src/drt/src/ta/FlexTA_init.cpp index 1bc90376e48..e35bb572be6 100644 --- a/src/drt/src/ta/FlexTA_init.cpp +++ b/src/drt/src/ta/FlexTA_init.cpp @@ -137,7 +137,7 @@ bool FlexTAWorker::initIroute_helper_pin(frGuide* guide, continue; } frInst* inst = iterm->getInst(); - dbTransform shiftXform = inst->getDBTransform(); + dbTransform shiftXform = inst->getTransform(); frMTerm* mterm = iterm->getTerm(); int pinIdx = 0; for (auto& pin : mterm->getPins()) { @@ -258,7 +258,7 @@ void FlexTAWorker::initIroute_helper_generic_helper(frGuide* guide, continue; } frInst* inst = iterm->getInst(); - dbTransform shiftXform = inst->getDBTransform(); + dbTransform shiftXform = inst->getTransform(); frMTerm* mterm = iterm->getTerm(); int pinIdx = 0; for (auto& pin : mterm->getPins()) {