Skip to content

Commit

Permalink
Merge pull request #1713 from KLayout/feature/issue-1701
Browse files Browse the repository at this point in the history
Implementing solution for issue #1701 (Feature request: strm2oas shou…
  • Loading branch information
klayoutmatthias authored May 31, 2024
2 parents f2b7bc6 + b5e2eb2 commit f8d5c1c
Show file tree
Hide file tree
Showing 13 changed files with 182 additions and 200 deletions.
24 changes: 3 additions & 21 deletions src/buddies/src/bd/bdReaderOptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -805,29 +805,11 @@ GenericReaderOptions::configure (db::LoadLayoutOptions &load_options)
load_options.set_option_by_name ("lefdef_config.macro_resolution_mode", m_lefdef_macro_resolution_mode);
load_options.set_option_by_name ("lefdef_config.paths_relative_to_cwd", true);

m_lef_layouts.clear ();
tl::Variant lef_layout_ptrs = tl::Variant::empty_list ();
tl::Variant lef_layout_files = tl::Variant::empty_list ();
for (std::vector<std::string>::const_iterator l = m_lefdef_lef_layout_files.begin (); l != m_lefdef_lef_layout_files.end (); ++l) {

try {

std::unique_ptr<db::Layout> ly (new db::Layout ());

tl::InputStream stream (*l);
db::Reader reader (stream);
db::LoadLayoutOptions load_options;
reader.read (*ly, load_options);

lef_layout_ptrs.push (tl::Variant::make_variant_ref (ly.get ()));
m_lef_layouts.push_back (ly.release ());

} catch (tl::Exception &ex) {
tl::warn << ex.msg ();
}

lef_layout_files.push (*l);
}

load_options.set_option_by_name ("lefdef_config.macro_layouts", lef_layout_ptrs);
load_options.set_option_by_name ("lefdef_config.macro_layout_files", lef_layout_files);
}

static std::string::size_type find_file_sep (const std::string &s, std::string::size_type from)
Expand Down
2 changes: 0 additions & 2 deletions src/buddies/src/bd/bdReaderOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ class BD_PUBLIC GenericReaderOptions
std::string m_lefdef_map_file;
int m_lefdef_macro_resolution_mode;
std::vector<std::string> m_lefdef_lef_layout_files;

tl::shared_collection<db::Layout> m_lef_layouts;
};

/**
Expand Down
1 change: 0 additions & 1 deletion src/db/db/dbLayout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,6 @@ Layout::mem_stat (MemStatistics *stat, MemStatistics::purpose_t purpose, int cat
db::mem_stat (stat, purpose, cat, m_pcell_ids, true, (void *) this);
db::mem_stat (stat, purpose, cat, m_lib_proxy_map, true, (void *) this);
db::mem_stat (stat, purpose, cat, m_meta_info, true, (void *) this);
db::mem_stat (stat, purpose, cat, m_string_repository, true, (void *) this);
db::mem_stat (stat, purpose, cat, m_shape_repository, true, (void *) this);
db::mem_stat (stat, purpose, cat, m_properties_repository, true, (void *) this);
db::mem_stat (stat, purpose, cat, m_array_repository, true, (void *) this);
Expand Down
17 changes: 0 additions & 17 deletions src/db/db/dbLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -588,22 +588,6 @@ class DB_PUBLIC Layout
return m_array_repository;
}

/**
* @brief Accessor to the string repository
*/
StringRepository &string_repository ()
{
return m_string_repository;
}

/**
* @brief Accessor to the string repository (const version)
*/
const StringRepository &string_repository () const
{
return m_string_repository;
}

/**
* @brief Accessor to the shape repository
*/
Expand Down Expand Up @@ -2170,7 +2154,6 @@ class DB_PUBLIC Layout
cell_map_type m_cell_map;
double m_dbu;
db::properties_id_type m_prop_id;
StringRepository m_string_repository;
GenericRepository m_shape_repository;
PropertiesRepository m_properties_repository;
ArrayRepository m_array_repository;
Expand Down
72 changes: 70 additions & 2 deletions src/db/db/dbText.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@


#include "dbText.h"
#include "tlThreads.h"

namespace db
{


static char halign2code (db::HAlign ha)
{
if (ha == db::HAlignCenter) {
Expand Down Expand Up @@ -78,13 +80,79 @@ static db::VAlign extract_valign (tl::Extractor &ex)
}
}

// ----------------------------------------------------------------------------
// StringRepository implementation

static StringRepository s_repository;
static StringRepository *sp_repository = 0;
static tl::Mutex s_repository_lock;

StringRepository *
StringRepository::instance ()
{
return sp_repository;
}

StringRepository::StringRepository ()
{
sp_repository = this;
}

StringRepository::~StringRepository ()
{
if (sp_repository == this) {
sp_repository = 0;
}

for (std::set<StringRef *>::const_iterator s = m_string_refs.begin (); s != m_string_refs.end (); ++s) {
delete *s;
}
}

const StringRef *
StringRepository::create_string_ref ()
{
tl::MutexLocker locker (&s_repository_lock);
StringRef *ref = new StringRef ();
m_string_refs.insert (ref);
return ref;
}

void
StringRepository::unregister_ref (StringRef *ref)
{
tl::MutexLocker locker (&s_repository_lock);
if (! m_string_refs.empty ()) {
m_string_refs.erase (ref);
}
}

// ----------------------------------------------------------------------------
// StringRef implementation

static tl::Mutex s_ref_lock;

StringRef::~StringRef ()
{
if (mp_rep) {
mp_rep->unregister_ref (this);
if (StringRepository::instance ()) {
StringRepository::instance ()->unregister_ref (this);
}
}

void
StringRef::add_ref ()
{
tl::MutexLocker locker (&s_ref_lock);
++m_ref_count;
}

void
StringRef::remove_ref ()
{
tl::MutexLocker locker (&s_ref_lock);
--m_ref_count;
if (m_ref_count == 0) {
delete this;
}
}

Expand Down
Loading

0 comments on commit f8d5c1c

Please sign in to comment.