Tag use static cmp functions

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2025-09-16 14:49:01 -07:00
parent 7c6a473bbc
commit a296abc15c
9 changed files with 84 additions and 148 deletions

View File

@ -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;

View File

@ -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.

View File

@ -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

View File

@ -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(),

View File

@ -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_));

View File

@ -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",

View File

@ -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

View File

@ -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

View File

@ -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",