From a296abc15cdd10beb3616ab000fc80c2af47d47e Mon Sep 17 00:00:00 2001 From: James Cherry Date: Tue, 16 Sep 2025 14:49:01 -0700 Subject: [PATCH] Tag use static cmp functions Signed-off-by: James Cherry --- search/CheckMinPulseWidths.cc | 2 +- search/Crpr.cc | 2 +- search/Path.cc | 2 +- search/PathEnum.cc | 2 +- search/PathGroup.cc | 2 +- search/Search.cc | 4 +- search/Tag.cc | 146 ++++++++++--------------------- search/Tag.hh | 70 +++++++-------- search/VisitPathGroupVertices.cc | 2 +- 9 files changed, 84 insertions(+), 148 deletions(-) diff --git a/search/CheckMinPulseWidths.cc b/search/CheckMinPulseWidths.cc index 85fcb071..d732c01f 100644 --- a/search/CheckMinPulseWidths.cc +++ b/search/CheckMinPulseWidths.cc @@ -350,7 +350,7 @@ MinPulseWidthCheck::closePath(const StaState *sta) const close_ap, sta); while (close_iter.hasNext()) { Path *close_path = close_iter.next(); - if (tagMatchNoPathAp(close_path->tag(sta), &close_tag)) { + if (Tag::matchNoPathAp(close_path->tag(sta), &close_tag)) { debugPrint(sta->debug(), "mpw", 3, " match %s", close_path->tag(sta)->to_string(sta).c_str()); return close_path; diff --git a/search/Crpr.cc b/search/Crpr.cc index 62d6d94f..6d227bb8 100644 --- a/search/Crpr.cc +++ b/search/Crpr.cc @@ -81,7 +81,7 @@ CheckCrpr::otherMinMaxArrival(const Path *path) other_ap, this); while (other_iter.hasNext()) { Path *other = other_iter.next(); - if (tagMatchCrpr(other->tag(this), tag)) + if (Tag::matchCrpr(other->tag(this), tag)) return other->arrival(); } // No corresponding path found. diff --git a/search/Path.cc b/search/Path.cc index 21640562..b3436613 100644 --- a/search/Path.cc +++ b/search/Path.cc @@ -642,7 +642,7 @@ Path::cmpNoCrpr(const Path *path1, VertexId vertex_id1 = path1->vertexId(sta); VertexId vertex_id2 = path2->vertexId(sta); if (vertex_id1 == vertex_id2) - return tagMatchCmp(path1->tag(sta), path2->tag(sta), false, sta); + return Tag::matchCmp(path1->tag(sta), path2->tag(sta), false, sta); else if (vertex_id1 < vertex_id2) return -1; else diff --git a/search/PathEnum.cc b/search/PathEnum.cc index a63f76e9..7a8d15b6 100644 --- a/search/PathEnum.cc +++ b/search/PathEnum.cc @@ -393,7 +393,7 @@ PathEnumFaninVisitor::visitFromToPath(const Pin *, // These paths fanin to before_div_ so we know to_vertex matches. if ((!unique_pins_ || from_vertex != prev_vertex_) && arc != prev_arc_ - && tagMatchNoCrpr(to_tag, before_div_tag_)) { + && Tag::matchNoCrpr(to_tag, before_div_tag_)) { debugPrint(debug_, "path_enum", 3, "visit fanin %s -> %s %s %s", from_path->to_string(this).c_str(), to_vertex->to_string(this).c_str(), diff --git a/search/PathGroup.cc b/search/PathGroup.cc index 7b24f642..4da88579 100644 --- a/search/PathGroup.cc +++ b/search/PathGroup.cc @@ -149,7 +149,7 @@ PathGroup::enumMinSlackUnderMin(PathEnd *path_end) other_ap, sta_); while (other_iter.hasNext()) { Path *other = other_iter.next(); - if (tagMatchCrpr(other->tag(sta_), tag)) { + if (Tag::matchCrpr(other->tag(sta_), tag)) { PathEnd *end_min = path_end->copy(); end_min->setPath(other); float slack = delayAsFloat(end_min->slackNoCrpr(sta_)); diff --git a/search/Search.cc b/search/Search.cc index 5a9452c3..a138267b 100644 --- a/search/Search.cc +++ b/search/Search.cc @@ -2826,7 +2826,7 @@ bool ReportPathLess::operator()(const Path *path1, const Path *path2) const { - return tagCmp(path1->tag(sta_), path2->tag(sta_), sta_) < 0; + return Tag::cmp(path1->tag(sta_), path2->tag(sta_), sta_) < 0; } void @@ -3610,7 +3610,7 @@ RequiredVisitor::visitFromToPath(const Pin *, while (to_iter.hasNext()) { Path *to_path = to_iter.next(); Tag *to_path_tag = to_path->tag(this); - if (tagMatchNoCrpr(to_path_tag, to_tag)) { + if (Tag::matchNoCrpr(to_path_tag, to_tag)) { Required to_required = to_path->required(); Required from_required = to_required - arc_delay; debugPrint(debug_, "search", 3, " to tag %2u: %s", diff --git a/search/Tag.cc b/search/Tag.cc index 3c3fe930..a95b5122 100644 --- a/search/Tag.cc +++ b/search/Tag.cc @@ -38,16 +38,6 @@ namespace sta { -static int -tagStateCmp(const Tag *tag1, - const Tag *tag2); -static bool -tagStateEqual(ExceptionStateSet *states1, - ExceptionStateSet *states2); -static bool -tagStateEqualCrpr(const Tag *tag1, - const Tag *tag2); - Tag::Tag(TagIndex index, int rf_index, PathAPIndex path_ap_index, @@ -304,13 +294,13 @@ bool TagLess::operator()(const Tag *tag1, const Tag *tag2) const { - return tagCmp(tag1, tag2, sta_) < 0; + return Tag::cmp(tag1, tag2, sta_) < 0; } int -tagCmp(const Tag *tag1, - const Tag *tag2, - const StaState *sta) +Tag::cmp(const Tag *tag1, + const Tag *tag2, + const StaState *sta) { if (tag1 == tag2) return 0; @@ -358,22 +348,15 @@ tagCmp(const Tag *tag1, if (is_segment_start1 && !is_segment_start2) return 1; - return tagStateCmp(tag1, tag2); + return stateCmp(tag1, tag2); } bool -tagEqual(const Tag *tag1, - const Tag *tag2, - const StaState *sta) +Tag::equal(const Tag *tag1, + const Tag *tag2, + const StaState *sta) { - return tag1 == tag2 - || (tag1->rfIndex() == tag2->rfIndex() - && tag1->pathAPIndex() == tag2->pathAPIndex() - && ClkInfo::equal(tag1->clkInfo(), tag2->clkInfo(), sta) - && tag1->isClock() == tag2->isClock() - && tag1->inputDelay() == tag2->inputDelay() - && tag1->isSegmentStart() == tag2->isSegmentStart() - && tagStateEqual(tag1, tag2)); + return cmp(tag1, tag2, sta) == 0; } //////////////////////////////////////////////////////////////// @@ -398,45 +381,33 @@ bool TagMatchLess::operator()(const Tag *tag1, const Tag *tag2) const { - return tagMatchCmp(tag1, tag2, match_crpr_clk_pin_, sta_) < 0; + return Tag::matchCmp(tag1, tag2, match_crpr_clk_pin_, sta_) < 0; } //////////////////////////////////////////////////////////////// bool -tagMatch(const Tag *tag1, - const Tag *tag2, - const StaState *sta) +Tag::match(const Tag *tag1, + const Tag *tag2, + const StaState *sta) { - return tagMatch(tag1, tag2, true, sta); + return Tag::matchCmp(tag1, tag2, true, sta) == 0; } bool -tagMatch(const Tag *tag1, - const Tag *tag2, - bool match_crpr_clk_pin, - const StaState *sta) +Tag::match(const Tag *tag1, + const Tag *tag2, + bool match_crpr_clk_pin, + const StaState *sta) { - const ClkInfo *clk_info1 = tag1->clkInfo(); - const ClkInfo *clk_info2 = tag2->clkInfo(); - return tag1 == tag2 - || (clk_info1->clkEdge() == clk_info2->clkEdge() - && tag1->rfIndex() == tag2->rfIndex() - && tag1->pathAPIndex() == tag2->pathAPIndex() - && tag1->isClock() == tag2->isClock() - && tag1->isSegmentStart() == tag2->isSegmentStart() - && clk_info1->isGenClkSrcPath() == clk_info2->isGenClkSrcPath() - && (!match_crpr_clk_pin - || !sta->crprActive() - || clk_info1->crprClkVertexId(sta) == clk_info2->crprClkVertexId(sta)) - && tagStateEqual(tag1, tag2)); + return Tag::matchCmp(tag1, tag2, match_crpr_clk_pin, sta) == 0; } int -tagMatchCmp(const Tag *tag1, - const Tag *tag2, - bool match_crpr_clk_pin, - const StaState *sta) +Tag::matchCmp(const Tag *tag1, + const Tag *tag2, + bool match_crpr_clk_pin, + const StaState *sta) { if (tag1 == tag2) return 0; @@ -497,12 +468,12 @@ tagMatchCmp(const Tag *tag1, return 1; } - return tagStateCmp(tag1, tag2); + return stateCmp(tag1, tag2); } bool -tagMatchNoCrpr(const Tag *tag1, - const Tag *tag2) +Tag::matchNoCrpr(const Tag *tag1, + const Tag *tag2) { const ClkInfo *clk_info1 = tag1->clkInfo(); const ClkInfo *clk_info2 = tag2->clkInfo(); @@ -512,12 +483,12 @@ tagMatchNoCrpr(const Tag *tag1, && tag1->pathAPIndex() == tag2->pathAPIndex() && tag1->isClock() == tag2->isClock() && clk_info1->isGenClkSrcPath() == clk_info2->isGenClkSrcPath() - && tagStateEqual(tag1, tag2)); + && Tag::stateEqual(tag1, tag2)); } bool -tagMatchNoPathAp(const Tag *tag1, - const Tag *tag2) +Tag::matchNoPathAp(const Tag *tag1, + const Tag *tag2) { const ClkInfo *clk_info1 = tag1->clkInfo(); const ClkInfo *clk_info2 = tag2->clkInfo(); @@ -527,12 +498,12 @@ tagMatchNoPathAp(const Tag *tag1, && tag1->isClock() == tag2->isClock() && tag1->isSegmentStart() == tag2->isSegmentStart() && clk_info1->isGenClkSrcPath() == clk_info2->isGenClkSrcPath() - && tagStateEqual(tag1, tag2)); + && Tag::stateEqual(tag1, tag2)); } bool -tagMatchCrpr(const Tag *tag1, - const Tag *tag2) +Tag::matchCrpr(const Tag *tag1, + const Tag *tag2) { const ClkInfo *clk_info1 = tag1->clkInfo(); const ClkInfo *clk_info2 = tag2->clkInfo(); @@ -542,14 +513,14 @@ tagMatchCrpr(const Tag *tag1, && tag1->isClock() == tag2->isClock() && tag1->isSegmentStart() == tag2->isSegmentStart() && clk_info1->isGenClkSrcPath() == clk_info2->isGenClkSrcPath() - && tagStateEqualCrpr(tag1, tag2)); + && stateEqualCrpr(tag1, tag2)); } //////////////////////////////////////////////////////////////// -static int -tagStateCmp(const Tag *tag1, - const Tag *tag2) +int +Tag::stateCmp(const Tag *tag1, + const Tag *tag2) { ExceptionStateSet *states1 = tag1->states(); ExceptionStateSet *states2 = tag2->states(); @@ -587,45 +558,16 @@ tagStateCmp(const Tag *tag1, } bool -tagStateEqual(const Tag *tag1, - const Tag *tag2) +Tag::stateEqual(const Tag *tag1, + const Tag *tag2) { - return tagStateEqual(tag1->states(), tag2->states()); -} - -static bool -tagStateEqual(ExceptionStateSet *states1, - ExceptionStateSet *states2) -{ - bool states_null1 = (states1 == nullptr || states1->empty()); - bool states_null2 = (states2 == nullptr || states2->empty()); - if (states_null1 && states_null2) - return true; - else if (states_null1 != states_null2) - return false; - - size_t state_size1 = states1->size(); - size_t state_size2 = states2->size(); - if (state_size1 == state_size2) { - ExceptionStateSet::Iterator state_iter1(states1); - ExceptionStateSet::Iterator state_iter2(states2); - while (state_iter1.hasNext() - && state_iter2.hasNext()) { - ExceptionState *state1 = state_iter1.next(); - ExceptionState *state2 = state_iter2.next(); - if (state1 != state2) - return false; - } - return true; - } - else - return false; + return stateCmp(tag1, tag2) == 0; } // Match loop exception states only for crpr min/max paths. -static bool -tagStateEqualCrpr(const Tag *tag1, - const Tag *tag2) +bool +Tag::stateEqualCrpr(const Tag *tag1, + const Tag *tag2) { ExceptionStateSet *states1 = tag1->states(); ExceptionStateSet *states2 = tag2->states(); @@ -681,7 +623,7 @@ bool TagEqual::operator()(const Tag *tag1, const Tag *tag2) const { - return tagEqual(tag1, tag2, sta_); + return Tag::equal(tag1, tag2, sta_); } TagMatchHash::TagMatchHash(bool match_crpr_clk_pin, @@ -708,7 +650,7 @@ bool TagMatchEqual::operator()(const Tag *tag1, const Tag *tag2) const { - return tagMatch(tag1, tag2, match_crpr_clk_pin_, sta_); + return Tag::match(tag1, tag2, match_crpr_clk_pin_, sta_); } } // namespace diff --git a/search/Tag.hh b/search/Tag.hh index 6f9cccbd..7e6369f7 100644 --- a/search/Tag.hh +++ b/search/Tag.hh @@ -90,9 +90,41 @@ public: size_t matchHash(bool match_crpr_clk_pin, const StaState *sta) const; + static int cmp(const Tag *tag1, + const Tag *tag2, + const StaState *sta); + static int matchCmp(const Tag *tag1, + const Tag *tag2, + bool match_clk_clk_pin, + const StaState *sta); + static bool match(const Tag *tag1, + const Tag *tag2, + bool match_crpr_clk_pin, + const StaState *sta); + static bool equal(const Tag *tag1, + const Tag *tag2, + const StaState *sta); + static bool matchNoPathAp(const Tag *tag1, + const Tag *tag2); + static bool matchCrpr(const Tag *tag1, + const Tag *tag2); + static bool matchNoCrpr(const Tag *tag1, + const Tag *tag2); + protected: void findHash(); + // Match tag clock edge, clock driver and exception states but not clk info. + static bool match(const Tag *tag1, + const Tag *tag2, + const StaState *sta); + static bool stateEqual(const Tag *tag1, + const Tag *tag2); + static int stateCmp(const Tag *tag1, + const Tag *tag2); + static bool stateEqualCrpr(const Tag *tag1, + const Tag *tag2); + private: ClkInfo *clk_info_; InputDelay *input_delay_; @@ -149,42 +181,4 @@ private: const StaState *sta_; }; -bool -tagEqual(const Tag *tag1, - const Tag *tag2, - const StaState *sta); -int -tagCmp(const Tag *tag1, - const Tag *tag2, - const StaState *sta); - -// Match tag clock edge, clock driver and exception states but not clk info. -bool -tagMatch(const Tag *tag1, - const Tag *tag2, - const StaState *sta); -bool -tagMatch(const Tag *tag1, - const Tag *tag2, - bool match_crpr_clk_pin, - const StaState *sta); -bool -tagStateEqual(const Tag *tag1, - const Tag *tag2); -bool -tagMatchNoCrpr(const Tag *tag1, - const Tag *tag2); -int -tagMatchCmp(const Tag *tag1, - const Tag *tag2, - bool match_clk_clk_pin, - const StaState *sta); - -bool -tagMatchNoPathAp(const Tag *tag1, - const Tag *tag2); -bool -tagMatchCrpr(const Tag *tag1, - const Tag *tag2); - } // namespace diff --git a/search/VisitPathGroupVertices.cc b/search/VisitPathGroupVertices.cc index b20ef395..4e77577a 100644 --- a/search/VisitPathGroupVertices.cc +++ b/search/VisitPathGroupVertices.cc @@ -283,7 +283,7 @@ PathGroupPathVisitor::visitFromToPath(const Pin *, VertexPathIterator to_iter(to_vertex, to_rf, path_ap, this); while (to_iter.hasNext()) { Path *to_path = to_iter.next(); - if (tagMatchNoCrpr(to_path->tag(this), to_tag) + if (Tag::matchNoCrpr(to_path->tag(this), to_tag) && matching_paths->hasKey(to_path)) { debugPrint(debug_, "visit_path_group", 2, "match crpr %s %s -> %s %s",