Skip to content

Commit cf2cd45

Browse files
committed
Have AbcLibrary own the mio_library_ member
Release if a user requests it. Then make a new one for future requests. Supress stdout of abc for future constructions. Signed-off-by: Drew Lewis <[email protected]>
1 parent 3daea17 commit cf2cd45

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

src/cut/include/cut/abc_library_factory.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ namespace cut {
2626
class AbcLibrary
2727
{
2828
public:
29-
AbcLibrary(utl::UniquePtrWithDeleter<abc::SC_Lib> abc_library);
29+
AbcLibrary(utl::UniquePtrWithDeleter<abc::SC_Lib> abc_library,
30+
utl::Logger* logger);
3031
AbcLibrary(AbcLibrary&&) = default;
3132
~AbcLibrary() = default;
3233
abc::SC_Lib* abc_library() { return abc_library_.get(); }
33-
abc::Mio_Library_t* mio_library() { return mio_library_; }
34+
abc::Mio_Library_t* mio_library();
3435
bool IsSupportedCell(const std::string& cell_name);
3536
bool IsConst0Cell(const std::string& cell_name);
3637
bool IsConst1Cell(const std::string& cell_name);
@@ -42,7 +43,8 @@ class AbcLibrary
4243
void InitializeConstGates();
4344

4445
utl::UniquePtrWithDeleter<abc::SC_Lib> abc_library_;
45-
abc::Mio_Library_t* mio_library_;
46+
utl::UniquePtrWithDeleter<abc::Mio_Library_t> mio_library_ = nullptr;
47+
utl::Logger* logger_ = nullptr;
4648
std::set<std::string> supported_cells_;
4749
std::unordered_set<std::string> const1_gates_;
4850
std::unordered_set<std::string> const0_gates_;

src/cut/src/abc_library_factory.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "sta/TableModel.hh"
3434
#include "sta/TimingArc.hh"
3535
#include "sta/Units.hh"
36+
#include "utl/SuppressStdout.h"
3637
#include "utl/deleter.h"
3738

3839
namespace abc {
@@ -43,10 +44,24 @@ void Abc_Stop();
4344

4445
namespace cut {
4546

46-
AbcLibrary::AbcLibrary(utl::UniquePtrWithDeleter<abc::SC_Lib> abc_library)
47-
: abc_library_(std::move(abc_library))
47+
AbcLibrary::AbcLibrary(utl::UniquePtrWithDeleter<abc::SC_Lib> abc_library,
48+
utl::Logger* logger)
49+
: abc_library_(std::move(abc_library)), logger_(logger)
4850
{
49-
mio_library_ = abc::Abc_SclDeriveGenlibSimple(abc_library_.get());
51+
mio_library_ = utl::UniquePtrWithDeleter<abc::Mio_Library_t>(
52+
abc::Abc_SclDeriveGenlibSimple(abc_library_.get()),
53+
[](abc::Mio_Library_t* lib) { abc::Mio_LibraryDelete(lib); });
54+
}
55+
56+
abc::Mio_Library_t* AbcLibrary::mio_library()
57+
{
58+
if (mio_library_ == nullptr) {
59+
utl::SuppressStdout nostdout(logger_);
60+
mio_library_ = utl::UniquePtrWithDeleter<abc::Mio_Library_t>(
61+
abc::Abc_SclDeriveGenlibSimple(abc_library_.get()),
62+
[](abc::Mio_Library_t* lib) { abc::Mio_LibraryDelete(lib); });
63+
}
64+
return mio_library_.release();
5065
}
5166

5267
static bool IsCombinational(sta::LibertyCell* cell)
@@ -382,8 +397,10 @@ AbcLibrary AbcLibraryFactory::Build()
382397
abc::Abc_SclHashCells(abc_library);
383398
abc::Abc_SclLinkCells(abc_library);
384399

385-
return AbcLibrary(utl::UniquePtrWithDeleter<abc::SC_Lib>(
386-
abc_library, [](abc::SC_Lib* lib) { abc::Abc_SclLibFree(lib); }));
400+
return AbcLibrary(
401+
utl::UniquePtrWithDeleter<abc::SC_Lib>(
402+
abc_library, [](abc::SC_Lib* lib) { abc::Abc_SclLibFree(lib); }),
403+
logger_);
387404
}
388405

389406
std::vector<sta::LibertyCell*> AbcLibraryFactory::GetLibertyCellsFromCorner(

0 commit comments

Comments
 (0)