diff --git a/liberty/LibertyParser.cc b/liberty/LibertyParser.cc index d85911b7..2049bec3 100644 --- a/liberty/LibertyParser.cc +++ b/liberty/LibertyParser.cc @@ -324,6 +324,24 @@ LibertyGroup::clear() deleteContents(variables_); } +bool +LibertyGroup::empty() const +{ + return subgroups_.empty() + && simple_attr_map_.empty() + && complex_attr_map_.empty() + && define_map_.empty(); +} + +bool +LibertyGroup::oneGroupOnly() const +{ + return subgroups_.size() == 1 + && simple_attr_map_.empty() + && complex_attr_map_.empty() + && define_map_.empty(); +} + void LibertyGroup::addSubgroup(LibertyGroup *subgroup) { diff --git a/liberty/LibertyParser.hh b/liberty/LibertyParser.hh index 2f533c36..7f426f71 100644 --- a/liberty/LibertyParser.hh +++ b/liberty/LibertyParser.hh @@ -127,6 +127,8 @@ public: int line); ~LibertyGroup(); void clear(); + bool empty() const; + bool oneGroupOnly() const; const std::string &type() const { return type_; } const LibertyAttrValueSeq ¶ms() const { return params_; } // First param as a string. diff --git a/liberty/LibertyReader.cc b/liberty/LibertyReader.cc index 5d99d1f1..9f8a696e 100644 --- a/liberty/LibertyReader.cc +++ b/liberty/LibertyReader.cc @@ -151,7 +151,8 @@ LibertyReader::endLibrary(const LibertyGroup *library_group, LibertyGroup *) { // If a library has no cells endCell is not called. - readLibraryAttributes(library_group); + if (!library_group->empty()) + readLibraryAttributes(library_group); checkThresholds(library_group); delete library_group; } @@ -166,7 +167,8 @@ LibertyReader::endCell(const LibertyGroup *cell_group, // Normally they are all defined by the first cell, but there // are libraries that define table templates and bus tyupes // between cells. - readLibraryAttributes(library_group); + if (!library_group->oneGroupOnly()) + readLibraryAttributes(library_group); const char *name = cell_group->firstName(); if (name) {