Internals: Smaller AstNode to save space/time
This commit is contained in:
parent
30ad20be52
commit
5563c9666c
|
|
@ -39,17 +39,15 @@ vluint64_t AstNode::s_editCntLast=0;
|
||||||
// along with each userp, and thus by bumping this count we can make it look
|
// along with each userp, and thus by bumping this count we can make it look
|
||||||
// as if we iterated across the entire tree to set all the userp's to null.
|
// as if we iterated across the entire tree to set all the userp's to null.
|
||||||
int AstNode::s_cloneCntGbl=0;
|
int AstNode::s_cloneCntGbl=0;
|
||||||
int AstUserInUse::s_userCntGbl=0; // Hot cache line, leave adjacent
|
uint32_t AstUserInUse::s_userCntGbl=0; // Hot cache line, leave adjacent
|
||||||
int AstUser2InUse::s_userCntGbl=0; // Hot cache line, leave adjacent
|
uint32_t AstUser2InUse::s_userCntGbl=0; // Hot cache line, leave adjacent
|
||||||
int AstUser3InUse::s_userCntGbl=0; // Hot cache line, leave adjacent
|
uint32_t AstUser3InUse::s_userCntGbl=0; // Hot cache line, leave adjacent
|
||||||
int AstUser4InUse::s_userCntGbl=0; // Hot cache line, leave adjacent
|
uint32_t AstUser4InUse::s_userCntGbl=0; // Hot cache line, leave adjacent
|
||||||
int AstUser5InUse::s_userCntGbl=0; // Hot cache line, leave adjacent
|
|
||||||
|
|
||||||
bool AstUserInUse::s_userBusy=false;
|
bool AstUserInUse::s_userBusy=false;
|
||||||
bool AstUser2InUse::s_userBusy=false;
|
bool AstUser2InUse::s_userBusy=false;
|
||||||
bool AstUser3InUse::s_userBusy=false;
|
bool AstUser3InUse::s_userBusy=false;
|
||||||
bool AstUser4InUse::s_userBusy=false;
|
bool AstUser4InUse::s_userBusy=false;
|
||||||
bool AstUser5InUse::s_userBusy=false;
|
|
||||||
|
|
||||||
//######################################################################
|
//######################################################################
|
||||||
// V3AstType
|
// V3AstType
|
||||||
|
|
@ -885,7 +883,7 @@ void AstNode::dumpTreeFile(const string& filename, bool append) {
|
||||||
if (logsp->fail()) v3fatalSrc("Can't write "<<filename);
|
if (logsp->fail()) v3fatalSrc("Can't write "<<filename);
|
||||||
*logsp<<"Tree Dump from <e"<<dec<<editCountLast()<<">";
|
*logsp<<"Tree Dump from <e"<<dec<<editCountLast()<<">";
|
||||||
*logsp<<" to <e"<<dec<<editCountGbl()<<">"<<endl;
|
*logsp<<" to <e"<<dec<<editCountGbl()<<">"<<endl;
|
||||||
if (editCountGbl()==editCountLast() && 1) { // Off, as messes up tree diffing
|
if (editCountGbl()==editCountLast()) {
|
||||||
*logsp<<endl;
|
*logsp<<endl;
|
||||||
*logsp<<"No changes since last dump!\n";
|
*logsp<<"No changes since last dump!\n";
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
49
src/V3Ast.h
49
src/V3Ast.h
|
|
@ -375,18 +375,18 @@ struct AstNUser {
|
||||||
|
|
||||||
class AstUserInUseBase {
|
class AstUserInUseBase {
|
||||||
protected:
|
protected:
|
||||||
static void allocate(int& cntGblRef, bool& userBusyRef) {
|
static void allocate(uint32_t& cntGblRef, bool& userBusyRef) {
|
||||||
// Perhaps there's still a AstUserInUse in scope for this?
|
// Perhaps there's still a AstUserInUse in scope for this?
|
||||||
UASSERT_STATIC(!userBusyRef, "Conflicting user use; AstUser*InUse request when under another AstUserInUse");
|
UASSERT_STATIC(!userBusyRef, "Conflicting user use; AstUser*InUse request when under another AstUserInUse");
|
||||||
userBusyRef = true;
|
userBusyRef = true;
|
||||||
clearcnt(cntGblRef, userBusyRef);
|
clearcnt(cntGblRef, userBusyRef);
|
||||||
}
|
}
|
||||||
static void free(int& cntGblRef, bool& userBusyRef) {
|
static void free(uint32_t& cntGblRef, bool& userBusyRef) {
|
||||||
UASSERT_STATIC(userBusyRef, "Free of User*() not under AstUserInUse");
|
UASSERT_STATIC(userBusyRef, "Free of User*() not under AstUserInUse");
|
||||||
clearcnt(cntGblRef, userBusyRef); // Includes a checkUse for us
|
clearcnt(cntGblRef, userBusyRef); // Includes a checkUse for us
|
||||||
userBusyRef = false;
|
userBusyRef = false;
|
||||||
}
|
}
|
||||||
static void clearcnt(int& cntGblRef, bool& userBusyRef) {
|
static void clearcnt(uint32_t& cntGblRef, bool& userBusyRef) {
|
||||||
UASSERT_STATIC(userBusyRef, "Clear of User*() not under AstUserInUse");
|
UASSERT_STATIC(userBusyRef, "Clear of User*() not under AstUserInUse");
|
||||||
// If this really fires and is real (after 2^32 edits???)
|
// If this really fires and is real (after 2^32 edits???)
|
||||||
// we could just walk the tree and clear manually
|
// we could just walk the tree and clear manually
|
||||||
|
|
@ -401,8 +401,8 @@ protected:
|
||||||
class AstUserInUse : AstUserInUseBase {
|
class AstUserInUse : AstUserInUseBase {
|
||||||
protected:
|
protected:
|
||||||
friend class AstNode;
|
friend class AstNode;
|
||||||
static int s_userCntGbl; // Count of which usage of userp() this is
|
static uint32_t s_userCntGbl; // Count of which usage of userp() this is
|
||||||
static bool s_userBusy; // Count is in use
|
static bool s_userBusy; // Count is in use
|
||||||
public:
|
public:
|
||||||
AstUserInUse() { allocate(s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
AstUserInUse() { allocate(s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
||||||
~AstUserInUse() { free (s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
~AstUserInUse() { free (s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
||||||
|
|
@ -411,8 +411,8 @@ public:
|
||||||
class AstUser2InUse : AstUserInUseBase {
|
class AstUser2InUse : AstUserInUseBase {
|
||||||
protected:
|
protected:
|
||||||
friend class AstNode;
|
friend class AstNode;
|
||||||
static int s_userCntGbl; // Count of which usage of userp() this is
|
static uint32_t s_userCntGbl; // Count of which usage of userp() this is
|
||||||
static bool s_userBusy; // Count is in use
|
static bool s_userBusy; // Count is in use
|
||||||
public:
|
public:
|
||||||
AstUser2InUse() { allocate(s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
AstUser2InUse() { allocate(s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
||||||
~AstUser2InUse() { free (s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
~AstUser2InUse() { free (s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
||||||
|
|
@ -421,8 +421,8 @@ public:
|
||||||
class AstUser3InUse : AstUserInUseBase {
|
class AstUser3InUse : AstUserInUseBase {
|
||||||
protected:
|
protected:
|
||||||
friend class AstNode;
|
friend class AstNode;
|
||||||
static int s_userCntGbl; // Count of which usage of userp() this is
|
static uint32_t s_userCntGbl; // Count of which usage of userp() this is
|
||||||
static bool s_userBusy; // Count is in use
|
static bool s_userBusy; // Count is in use
|
||||||
public:
|
public:
|
||||||
AstUser3InUse() { allocate(s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
AstUser3InUse() { allocate(s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
||||||
~AstUser3InUse() { free (s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
~AstUser3InUse() { free (s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
||||||
|
|
@ -431,23 +431,13 @@ public:
|
||||||
class AstUser4InUse : AstUserInUseBase {
|
class AstUser4InUse : AstUserInUseBase {
|
||||||
protected:
|
protected:
|
||||||
friend class AstNode;
|
friend class AstNode;
|
||||||
static int s_userCntGbl; // Count of which usage of userp() this is
|
static uint32_t s_userCntGbl; // Count of which usage of userp() this is
|
||||||
static bool s_userBusy; // Count is in use
|
static bool s_userBusy; // Count is in use
|
||||||
public:
|
public:
|
||||||
AstUser4InUse() { allocate(s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
AstUser4InUse() { allocate(s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
||||||
~AstUser4InUse() { free (s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
~AstUser4InUse() { free (s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
||||||
static void clear() { clearcnt(s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
static void clear() { clearcnt(s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
||||||
};
|
};
|
||||||
class AstUser5InUse : AstUserInUseBase {
|
|
||||||
protected:
|
|
||||||
friend class AstNode;
|
|
||||||
static int s_userCntGbl; // Count of which usage of userp() this is
|
|
||||||
static bool s_userBusy; // Count is in use
|
|
||||||
public:
|
|
||||||
AstUser5InUse() { allocate(s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
|
||||||
~AstUser5InUse() { free (s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
|
||||||
static void clear() { clearcnt(s_userCntGbl/*ref*/, s_userBusy/*ref*/); }
|
|
||||||
};
|
|
||||||
|
|
||||||
//######################################################################
|
//######################################################################
|
||||||
// AstNVisitor -- Allows new functions to be called on each node
|
// AstNVisitor -- Allows new functions to be called on each node
|
||||||
|
|
@ -559,27 +549,28 @@ class AstNode {
|
||||||
|
|
||||||
AstNode* m_headtailp; // When at begin/end of list, the opposite end of the list
|
AstNode* m_headtailp; // When at begin/end of list, the opposite end of the list
|
||||||
|
|
||||||
AstNode* m_clonep; // Pointer to clone of/ source of this module (for *LAST* cloneTree() ONLY)
|
|
||||||
int m_cloneCnt; // Mark of when userp was set
|
|
||||||
static int s_cloneCntGbl; // Count of which userp is set
|
|
||||||
|
|
||||||
FileLine* m_fileline; // Where it was declared
|
FileLine* m_fileline; // Where it was declared
|
||||||
vluint64_t m_editCount; // When it was last edited
|
vluint64_t m_editCount; // When it was last edited
|
||||||
static vluint64_t s_editCntGbl; // Global edit counter
|
static vluint64_t s_editCntGbl; // Global edit counter
|
||||||
static vluint64_t s_editCntLast;// Global edit counter, last value for printing * near node #s
|
static vluint64_t s_editCntLast;// Global edit counter, last value for printing * near node #s
|
||||||
|
|
||||||
|
AstNode* m_clonep; // Pointer to clone of/ source of this module (for *LAST* cloneTree() ONLY)
|
||||||
|
int m_cloneCnt; // Mark of when userp was set
|
||||||
|
static int s_cloneCntGbl; // Count of which userp is set
|
||||||
|
|
||||||
// Attributes
|
// Attributes
|
||||||
bool m_signed; // Node is signed
|
bool m_signed; // Node is signed
|
||||||
int m_width; // Bit width of operation
|
int m_width; // Bit width of operation
|
||||||
int m_widthMin; // If unsized, bitwidth of minimum implementation
|
int m_widthMin; // If unsized, bitwidth of minimum implementation
|
||||||
|
// This member ordering both allows 64 bit alignment and puts associated data together
|
||||||
AstNUser* m_userp; // Pointer to any information the user iteration routine wants
|
AstNUser* m_userp; // Pointer to any information the user iteration routine wants
|
||||||
int m_userCnt; // Mark of when userp was set
|
uint32_t m_userCnt; // Mark of when userp was set
|
||||||
|
uint32_t m_user2Cnt; // Mark of when userp was set
|
||||||
AstNUser* m_user2p; // Pointer to any information the user iteration routine wants
|
AstNUser* m_user2p; // Pointer to any information the user iteration routine wants
|
||||||
int m_user2Cnt; // Mark of when userp was set
|
|
||||||
AstNUser* m_user3p; // Pointer to any information the user iteration routine wants
|
AstNUser* m_user3p; // Pointer to any information the user iteration routine wants
|
||||||
int m_user3Cnt; // Mark of when userp was set
|
uint32_t m_user3Cnt; // Mark of when userp was set
|
||||||
|
uint32_t m_user4Cnt; // Mark of when userp was set
|
||||||
AstNUser* m_user4p; // Pointer to any information the user iteration routine wants
|
AstNUser* m_user4p; // Pointer to any information the user iteration routine wants
|
||||||
int m_user4Cnt; // Mark of when userp was set
|
|
||||||
|
|
||||||
// METHODS
|
// METHODS
|
||||||
void op1p(AstNode* nodep) { m_op1p = nodep; if (nodep) nodep->m_backp = this; }
|
void op1p(AstNode* nodep) { m_op1p = nodep; if (nodep) nodep->m_backp = this; }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue