mirror of https://github.com/YosysHQ/yosys.git
internal_stats: astnode (sizeof)
This commit is contained in:
parent
17ee367c7b
commit
1372c47036
|
@ -41,6 +41,8 @@ namespace AST {
|
||||||
std::string current_filename;
|
std::string current_filename;
|
||||||
void (*set_line_num)(int) = NULL;
|
void (*set_line_num)(int) = NULL;
|
||||||
int (*get_line_num)() = NULL;
|
int (*get_line_num)() = NULL;
|
||||||
|
unsigned long long astnodes = 0;
|
||||||
|
unsigned long long astnode_count() { return astnodes; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// instantiate global variables (private API)
|
// instantiate global variables (private API)
|
||||||
|
@ -204,6 +206,7 @@ AstNode::AstNode(AstNodeType type, AstNode *child1, AstNode *child2, AstNode *ch
|
||||||
static unsigned int hashidx_count = 123456789;
|
static unsigned int hashidx_count = 123456789;
|
||||||
hashidx_count = mkhash_xorshift(hashidx_count);
|
hashidx_count = mkhash_xorshift(hashidx_count);
|
||||||
hashidx_ = hashidx_count;
|
hashidx_ = hashidx_count;
|
||||||
|
astnodes++;
|
||||||
|
|
||||||
this->type = type;
|
this->type = type;
|
||||||
filename = current_filename;
|
filename = current_filename;
|
||||||
|
@ -292,6 +295,7 @@ void AstNode::delete_children()
|
||||||
// AstNode destructor
|
// AstNode destructor
|
||||||
AstNode::~AstNode()
|
AstNode::~AstNode()
|
||||||
{
|
{
|
||||||
|
astnodes--;
|
||||||
delete_children();
|
delete_children();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -410,6 +410,9 @@ namespace AST
|
||||||
extern void (*set_line_num)(int);
|
extern void (*set_line_num)(int);
|
||||||
extern int (*get_line_num)();
|
extern int (*get_line_num)();
|
||||||
|
|
||||||
|
// for stats
|
||||||
|
unsigned long long astnode_count();
|
||||||
|
|
||||||
// set set_line_num and get_line_num to internal dummy functions (done by simplify() and AstModule::derive
|
// set set_line_num and get_line_num to internal dummy functions (done by simplify() and AstModule::derive
|
||||||
// to control the filename and linenum properties of new nodes not generated by a frontend parser)
|
// to control the filename and linenum properties of new nodes not generated by a frontend parser)
|
||||||
void use_internal_line_num();
|
void use_internal_line_num();
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "kernel/celltypes.h"
|
#include "kernel/celltypes.h"
|
||||||
#include "passes/techmap/libparse.h"
|
#include "passes/techmap/libparse.h"
|
||||||
#include "kernel/cost.h"
|
#include "kernel/cost.h"
|
||||||
|
#include "frontends/ast/ast.h"
|
||||||
#include "libs/json11/json11.hpp"
|
#include "libs/json11/json11.hpp"
|
||||||
|
|
||||||
#if defined(__APPLE__) && defined(__MACH__)
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
@ -105,6 +106,8 @@ struct InternalStatsPass : public Pass {
|
||||||
if (auto mem = current_mem_bytes()) {
|
if (auto mem = current_mem_bytes()) {
|
||||||
log(" \"memory_now\": %s,\n", std::to_string(*mem).c_str());
|
log(" \"memory_now\": %s,\n", std::to_string(*mem).c_str());
|
||||||
}
|
}
|
||||||
|
auto ast_bytes = AST::astnode_count() * (unsigned long long) sizeof(AST::AstNode);
|
||||||
|
log(" \"memory_ast\": %s,\n", std::to_string(ast_bytes).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// stats go here
|
// stats go here
|
||||||
|
|
Loading…
Reference in New Issue