Skip to content

Commit

Permalink
drt: elimination of drt::frInst dbTransform
Browse files Browse the repository at this point in the history
Signed-off-by: bernardo <[email protected]>
  • Loading branch information
bnmfw committed Dec 8, 2024
1 parent 06732f5 commit dd9966d
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 63 deletions.
2 changes: 0 additions & 2 deletions src/drt/src/DesignCallBack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 2 additions & 4 deletions src/drt/src/db/obj/frInst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
19 changes: 7 additions & 12 deletions src/drt/src/db/obj/frInst.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -148,7 +144,6 @@ class frInst : public frRef
std::vector<std::unique_ptr<frInstTerm>> instTerms_;
std::vector<std::unique_ptr<frInstBlockage>> instBlockages_;
odb::dbInst* db_inst_;
dbTransform xform_;
int pinAccessIdx_;
bool toBeDeleted_;
};
Expand Down
15 changes: 8 additions & 7 deletions src/drt/src/db/obj/frInstTerm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -56,15 +57,15 @@ void frInstTerm::getShapes(std::vector<frRect>& outShapes) const
{
term_->getShapes(outShapes);
for (auto& shape : outShapes) {
dbTransform trans = getInst()->getDBTransform();
dbTransform trans = getInst()->getTransform();
shape.move(trans);
}
}

Rect frInstTerm::getBBox() const
{
Rect bbox(term_->getBBox());
dbTransform trans = getInst()->getDBTransform();
dbTransform trans = getInst()->getTransform();
trans.apply(bbox);
return bbox;
}
Expand Down
2 changes: 1 addition & 1 deletion src/drt/src/db/obj/frRPin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Rect frRPin::getBBox()
switch (term->typeId()) {
case frcInstTerm: {
auto inst = static_cast<frInstTerm*>(term)->getInst();
dbTransform shiftXform = inst->getDBTransform();
dbTransform shiftXform = inst->getTransform();

pt = accessPoint->getPoint();
shiftXform.apply(pt);
Expand Down
4 changes: 0 additions & 4 deletions src/drt/src/db/obj/frRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/drt/src/db/obj/frVia.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions src/drt/src/dr/FlexDR_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<frInstTerm*>(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(
Expand Down Expand Up @@ -2900,8 +2897,7 @@ void FlexDRWorker::initMazeCost_terms(const std::set<frBlockObject*>& objs,
} else if (obj->typeId() == frcInstTerm) {
auto instTerm = static_cast<frInstTerm*>(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;
Expand Down Expand Up @@ -2970,7 +2966,7 @@ void FlexDRWorker::initMazeCost_terms(const std::set<frBlockObject*>& 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 {
Expand Down
2 changes: 1 addition & 1 deletion src/drt/src/dr/FlexDR_maze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/drt/src/frRegionQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void frRegionQuery::addBlockObj(frBlockObject* obj)
switch (obj->typeId()) {
case frcInstTerm: {
auto instTerm = static_cast<frInstTerm*>(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();
Expand All @@ -201,7 +201,7 @@ void frRegionQuery::addBlockObj(frBlockObject* obj)
}
case frcInstBlockage: {
auto instBlk = static_cast<frInstBlockage*>(obj);
dbTransform xform = instBlk->getInst()->getDBTransform();
dbTransform xform = instBlk->getInst()->getTransform();
auto blk = instBlk->getBlockage();
auto pin = blk->getPin();
for (auto& uFig : pin->getFigs()) {
Expand Down Expand Up @@ -260,7 +260,7 @@ void frRegionQuery::removeBlockObj(frBlockObject* obj)
switch (obj->typeId()) {
case frcInstTerm: {
auto instTerm = static_cast<frInstTerm*>(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();
Expand All @@ -274,7 +274,7 @@ void frRegionQuery::removeBlockObj(frBlockObject* obj)
}
case frcInstBlockage: {
auto instBlk = static_cast<frInstBlockage*>(obj);
dbTransform xform = instBlk->getInst()->getDBTransform();
dbTransform xform = instBlk->getInst()->getTransform();
auto blk = instBlk->getBlockage();
auto pin = blk->getPin();
for (auto& uFig : pin->getFigs()) {
Expand Down Expand Up @@ -458,7 +458,7 @@ void frRegionQuery::addGRObj(grVia* via)
void frRegionQuery::Impl::add(frInstTerm* instTerm,
ObjectsByLayer<frBlockObject>& allShapes)
{
dbTransform xform = instTerm->getInst()->getDBTransform();
dbTransform xform = instTerm->getInst()->getTransform();

for (auto& pin : instTerm->getTerm()->getPins()) {
for (auto& uFig : pin->getFigs()) {
Expand Down Expand Up @@ -495,7 +495,7 @@ void frRegionQuery::Impl::add(frBTerm* term,
void frRegionQuery::Impl::add(frInstBlockage* instBlk,
ObjectsByLayer<frBlockObject>& allShapes)
{
dbTransform xform = instBlk->getInst()->getDBTransform();
dbTransform xform = instBlk->getInst()->getTransform();
auto blk = instBlk->getBlockage();
auto pin = blk->getPin();
for (auto& uFig : pin->getFigs()) {
Expand Down
2 changes: 1 addition & 1 deletion src/drt/src/gr/FlexGR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ void FlexGR::initGR_genTopology_net(frNet* net)
Point pt;
if (rpin->getFrTerm()->typeId() == frcInstTerm) {
auto inst = static_cast<frInstTerm*>(rpin->getFrTerm())->getInst();
dbTransform shiftXform = inst->getDBTransform();
dbTransform shiftXform = inst->getTransform();
pt = rpin->getAccessPoint()->getPoint();
shiftXform.apply(pt);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/drt/src/io/GuideProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ std::vector<Point3D> getAccessPoints(const frBlockObject* pin)
std::vector<Point3D> result;
if (pin->typeId() == frcInstTerm) {
auto iterm = static_cast<const frInstTerm*>(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()) {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions src/drt/src/io/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ void io::Parser::setInst(odb::dbInst* inst)
auto uInst = std::make_unique<frInst>(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()) {
Expand Down
2 changes: 1 addition & 1 deletion src/drt/src/io/io_parser_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/drt/src/pa/FlexPA_prep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -2091,7 +2091,7 @@ void FlexPA::addAccessPatternObj(
std::vector<std::unique_ptr<frVia>>& 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();

Expand Down Expand Up @@ -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<std::pair<frConnFig*, frBlockObject*>> objs;
const auto& [pin_1, inst_term_1] = pins[prev_pin_idx];
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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:";
Expand Down
4 changes: 2 additions & 2 deletions src/drt/src/ta/FlexTA_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit dd9966d

Please sign in to comment.