mirror of
https://github.com/holub/mame
synced 2025-07-04 09:28:51 +03:00
Some pedantic netlist changes. (nw)
This commit is contained in:
parent
12d07f9174
commit
bce5387096
@ -1233,6 +1233,7 @@ namespace netlist
|
|||||||
pnamedlist_t<core_device_t *> m_started_devices;
|
pnamedlist_t<core_device_t *> m_started_devices;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ATTR_COLD plog_base<NL_DEBUG> &log() { return m_log; }
|
||||||
ATTR_COLD const plog_base<NL_DEBUG> &log() const { return m_log; }
|
ATTR_COLD const plog_base<NL_DEBUG> &log() const { return m_log; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -198,6 +198,7 @@ namespace netlist
|
|||||||
|
|
||||||
void model_parse(const pstring &model, model_map_t &map);
|
void model_parse(const pstring &model, model_map_t &map);
|
||||||
|
|
||||||
|
plog_base<NL_DEBUG> &log() { return netlist().log(); }
|
||||||
const plog_base<NL_DEBUG> &log() const { return netlist().log(); }
|
const plog_base<NL_DEBUG> &log() const { return netlist().log(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "pstring.h"
|
#include "pstring.h"
|
||||||
#include "palloc.h"
|
#include "palloc.h"
|
||||||
|
#include "plists.h"
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
pstr_t pstring_t<putf8_traits>::m_zero = pstr_t(0);
|
pstr_t pstring_t<putf8_traits>::m_zero = pstr_t(0);
|
||||||
@ -305,6 +306,106 @@ long pstring_t<F>::as_long(bool *error) const
|
|||||||
// static stuff ...
|
// static stuff ...
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Cached allocation of string memory
|
||||||
|
*
|
||||||
|
* This improves startup performance by 30%.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
static pstack_t<pstr_t *> *stk = NULL;
|
||||||
|
|
||||||
|
static inline unsigned countleadbits(unsigned x)
|
||||||
|
{
|
||||||
|
#ifndef count_leading_zeros
|
||||||
|
unsigned msk;
|
||||||
|
unsigned ret;
|
||||||
|
if (x < 0x100)
|
||||||
|
{
|
||||||
|
msk = 0x80;
|
||||||
|
ret = 24;
|
||||||
|
}
|
||||||
|
else if (x < 0x10000)
|
||||||
|
{
|
||||||
|
msk = 0x8000;
|
||||||
|
ret = 16;
|
||||||
|
}
|
||||||
|
else if (x < 0x1000000)
|
||||||
|
{
|
||||||
|
msk = 0x800000;
|
||||||
|
ret = 8;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msk = 0x80000000;
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
while ((msk & x) == 0 && ret < 31)
|
||||||
|
{
|
||||||
|
msk = msk >> 1;
|
||||||
|
ret++;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
#else
|
||||||
|
return count_leading_zeros(x);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename F>
|
||||||
|
void pstring_t<F>::sfree(pstr_t *s)
|
||||||
|
{
|
||||||
|
s->m_ref_count--;
|
||||||
|
if (s->m_ref_count == 0 && s != &m_zero)
|
||||||
|
{
|
||||||
|
if (stk != NULL)
|
||||||
|
{
|
||||||
|
unsigned sn= ((32 - countleadbits(s->len())) + 1) / 2;
|
||||||
|
stk[sn].push(s);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pfree_array(((char *)s));
|
||||||
|
//_mm_free(((char *)s));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename F>
|
||||||
|
pstr_t *pstring_t<F>::salloc(int n)
|
||||||
|
{
|
||||||
|
if (stk == NULL)
|
||||||
|
stk = palloc_array(pstack_t<pstr_t *>, 17);
|
||||||
|
pstr_t *p;
|
||||||
|
unsigned sn= ((32 - countleadbits(n)) + 1) / 2;
|
||||||
|
unsigned size = sizeof(pstr_t) + (1<<(sn * 2)) + 1;
|
||||||
|
if (stk[sn].empty())
|
||||||
|
p = (pstr_t *) palloc_array(char, size);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//printf("%u %u\n", sn, (unsigned) stk[sn].count());
|
||||||
|
p = stk[sn].pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// str_t *p = (str_t *) _mm_malloc(size, 8);
|
||||||
|
p->init(n);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
template<typename F>
|
||||||
|
void pstring_t<F>::resetmem()
|
||||||
|
{
|
||||||
|
if (stk != NULL)
|
||||||
|
{
|
||||||
|
for (unsigned i=0; i<=16; i++)
|
||||||
|
{
|
||||||
|
for (; stk[i].count() > 0; )
|
||||||
|
pfree_array(stk[i].pop());
|
||||||
|
}
|
||||||
|
pfree_array(stk);
|
||||||
|
stk = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
template<typename F>
|
template<typename F>
|
||||||
void pstring_t<F>::sfree(pstr_t *s)
|
void pstring_t<F>::sfree(pstr_t *s)
|
||||||
{
|
{
|
||||||
@ -331,6 +432,8 @@ void pstring_t<F>::resetmem()
|
|||||||
{
|
{
|
||||||
// Release the 0 string
|
// Release the 0 string
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
// pstring ...
|
// pstring ...
|
||||||
|
@ -22,21 +22,21 @@
|
|||||||
struct pstr_t
|
struct pstr_t
|
||||||
{
|
{
|
||||||
//str_t() : m_ref_count(1), m_len(0) { m_str[0] = 0; }
|
//str_t() : m_ref_count(1), m_len(0) { m_str[0] = 0; }
|
||||||
pstr_t(const int alen)
|
pstr_t(const unsigned alen)
|
||||||
{
|
{
|
||||||
init(alen);
|
init(alen);
|
||||||
}
|
}
|
||||||
void init(const int alen)
|
void init(const unsigned alen)
|
||||||
{
|
{
|
||||||
m_ref_count = 1;
|
m_ref_count = 1;
|
||||||
m_len = alen;
|
m_len = alen;
|
||||||
m_str[0] = 0;
|
m_str[0] = 0;
|
||||||
}
|
}
|
||||||
char *str() { return &m_str[0]; }
|
char *str() { return &m_str[0]; }
|
||||||
int len() const { return m_len; }
|
unsigned len() const { return m_len; }
|
||||||
int m_ref_count;
|
int m_ref_count;
|
||||||
private:
|
private:
|
||||||
int m_len;
|
unsigned m_len;
|
||||||
char m_str[1];
|
char m_str[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -548,47 +548,57 @@ template <bool build_enabled = true>
|
|||||||
class pfmt_writer_t
|
class pfmt_writer_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
pfmt_writer_t() { }
|
pfmt_writer_t() : m_enabled(true) { }
|
||||||
virtual ~pfmt_writer_t() { }
|
virtual ~pfmt_writer_t() { }
|
||||||
|
|
||||||
ATTR_COLD void operator ()(const char *fmt) const
|
ATTR_COLD void operator ()(const char *fmt) const
|
||||||
{
|
{
|
||||||
if (build_enabled) vdowrite(fmt);
|
if (build_enabled && m_enabled) vdowrite(fmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T1>
|
template<typename T1>
|
||||||
ATTR_COLD void operator ()(const char *fmt, const T1 &v1) const
|
ATTR_COLD void operator ()(const char *fmt, const T1 &v1) const
|
||||||
{
|
{
|
||||||
if (build_enabled) vdowrite(pfmt(fmt)(v1));
|
if (build_enabled && m_enabled) vdowrite(pfmt(fmt)(v1));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
ATTR_COLD void operator ()(const char *fmt, const T1 &v1, const T2 &v2) const
|
ATTR_COLD void operator ()(const char *fmt, const T1 &v1, const T2 &v2) const
|
||||||
{
|
{
|
||||||
if (build_enabled) vdowrite(pfmt(fmt)(v1)(v2));
|
if (build_enabled && m_enabled) vdowrite(pfmt(fmt)(v1)(v2));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T1, typename T2, typename T3>
|
template<typename T1, typename T2, typename T3>
|
||||||
ATTR_COLD void operator ()(const char *fmt, const T1 &v1, const T2 &v2, const T3 &v3) const
|
ATTR_COLD void operator ()(const char *fmt, const T1 &v1, const T2 &v2, const T3 &v3) const
|
||||||
{
|
{
|
||||||
if (build_enabled) vdowrite(pfmt(fmt)(v1)(v2)(v3));
|
if (build_enabled && m_enabled) vdowrite(pfmt(fmt)(v1)(v2)(v3));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T1, typename T2, typename T3, typename T4>
|
template<typename T1, typename T2, typename T3, typename T4>
|
||||||
ATTR_COLD void operator ()(const char *fmt, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4) const
|
ATTR_COLD void operator ()(const char *fmt, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4) const
|
||||||
{
|
{
|
||||||
if (build_enabled) vdowrite(pfmt(fmt)(v1)(v2)(v3)(v4));
|
if (build_enabled && m_enabled) vdowrite(pfmt(fmt)(v1)(v2)(v3)(v4));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T1, typename T2, typename T3, typename T4, typename T5>
|
template<typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||||
ATTR_COLD void operator ()(const char *fmt, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5) const
|
ATTR_COLD void operator ()(const char *fmt, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5) const
|
||||||
{
|
{
|
||||||
if (build_enabled) vdowrite(pfmt(fmt)(v1)(v2)(v3)(v4)(v5));
|
if (build_enabled && m_enabled) vdowrite(pfmt(fmt)(v1)(v2)(v3)(v4)(v5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_enabled(const bool v)
|
||||||
|
{
|
||||||
|
m_enabled = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_enabled() const { return m_enabled; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void vdowrite(const pstring &ls) const {}
|
virtual void vdowrite(const pstring &ls) const {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_enabled;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <plog_level L, bool build_enabled = true>
|
template <plog_level L, bool build_enabled = true>
|
||||||
|
@ -135,7 +135,7 @@ public:
|
|||||||
ATTR_COLD int get_net_idx(net_t *net);
|
ATTR_COLD int get_net_idx(net_t *net);
|
||||||
|
|
||||||
inline eSolverType type() const { return m_type; }
|
inline eSolverType type() const { return m_type; }
|
||||||
const plog_base<NL_DEBUG> &log() const { return netlist().log(); }
|
plog_base<NL_DEBUG> &log() { return netlist().log(); }
|
||||||
|
|
||||||
virtual void log_stats();
|
virtual void log_stats();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user