User Guide
nmodl::visitor::DefUseAnalyzeVisitor Class Reference

Visitor to return Def-Use chain for a given variable in the block/node More...

Detailed Description

Visitor to return Def-Use chain for a given variable in the block/node

Motivation: For global to local variable transformation aka localizer pass, we need to compute Def-Use chains for all global variables. For example, if we have variable usage like:

NEURON {
RANGE tau, beta
}
DERIVATIVE states() {
...
x = alpha
beta = x + y
....
z = beta
}
INITIAL {
...
beta = x + y
z = beta * 0.1
alpha = x * y
}

In the above example if we look at variable beta then it's defined before it's usage and hence it can be safely made local. But variable alpha is used in first block and defined in second block. Hence it can't be made local. A variable can be made local if it is defined before it's usage (in all global blocks). We exclude procedures/functions because we expect inlining to be done prior to this pass.

The analysis of if-elseif-else needs special attention because the def-use chain needs re-cursive evaluation in order to find end-result. For example:

IF(...) {
beta = y
} ELSE {
IF(...) {
beta = x
} ELSE {
x = beta
}
}

For if-else statements, in the above example, if the variable is used in any of the if-elseif-else part then it is considered as "used". And this is done recursively from innermost level to the top.

Definition at line 214 of file defuse_analyze_visitor.hpp.

#include <defuse_analyze_visitor.hpp>

Inheritance diagram for nmodl::visitor::DefUseAnalyzeVisitor:
nmodl::visitor::ConstAstVisitor nmodl::visitor::ConstVisitor

Public Member Functions

 DefUseAnalyzeVisitor ()=delete
 
 DefUseAnalyzeVisitor (symtab::SymbolTable &symtab)
 
 DefUseAnalyzeVisitor (symtab::SymbolTable &symtab, bool ignore_verbatim)
 
void visit_binary_expression (const ast::BinaryExpression &node) override
 Nmodl grammar doesn't allow assignment operator on rhs (e.g. More...
 
void visit_if_statement (const ast::IfStatement &node) override
 visit node of type ast::IfStatement More...
 
void visit_function_call (const ast::FunctionCall &node) override
 Nothing to do if called function is not defined or it's external but if there is a function call for internal function that means there is no inlining happened. More...
 
void visit_statement_block (const ast::StatementBlock &node) override
 visit node of type ast::StatementBlock More...
 
void visit_verbatim (const ast::Verbatim &node) override
 We are not analyzing verbatim blocks yet and hence if there is a verbatim block we assume there is variable usage. More...
 
DUChain analyze (const ast::Ast &node, const std::string &name)
 compute def-use chain for a variable within the node More...
 
unsupported statements

/ we aren't sure how to handle this "yet" and hence variables used in any of the below statements are handled separately

void visit_reaction_statement (const ast::ReactionStatement &node) override
 unsupported statements : we aren't sure how to handle this "yet" and hence variables used in any of the below statements are handled separately More...
 
void visit_non_lin_equation (const ast::NonLinEquation &node) override
 visit node of type ast::NonLinEquation More...
 
void visit_lin_equation (const ast::LinEquation &node) override
 visit node of type ast::LinEquation More...
 
void visit_from_statement (const ast::FromStatement &node) override
 visit node of type ast::FromStatement More...
 
void visit_conserve (const ast::Conserve &node) override
 visit node of type ast::Conserve More...
 
void visit_var_name (const ast::VarName &node) override
 visit node of type ast::VarName More...
 
void visit_name (const ast::Name &node) override
 visit node of type ast::Name More...
 
void visit_indexed_name (const ast::IndexedName &node) override
 visit node of type ast::IndexedName More...
 
statements

/ nodes that should not be used for def-use chain analysis

void visit_conductance_hint (const ast::ConductanceHint &node) override
 statements / nodes that should not be used for def-use chain analysis More...
 
void visit_local_list_statement (const ast::LocalListStatement &node) override
 visit node of type ast::LocalListStatement More...
 
void visit_argument (const ast::Argument &node) override
 visit node of type ast::Argument More...
 

Private Member Functions

void process_variable (const std::string &name)
 
void process_variable (const std::string &name, int index)
 
void update_defuse_chain (const std::string &name)
 Update the Def-Use chain for given variable. More...
 
void visit_unsupported_node (const ast::Node &node)
 
void visit_with_new_chain (const ast::Node &node, DUState state)
 
void start_new_chain (DUState state)
 

Private Attributes

symtab::SymbolTableglobal_symtab = nullptr
 symbol table containing global variables More...
 
std::vector< DUInstance > * current_chain = nullptr
 def-use chain currently being constructed More...
 
symtab::SymbolTablecurrent_symtab = nullptr
 symbol table for current statement block (or of parent block if doesn't have) should be initialized by caller somehow More...
 
std::stack< symtab::SymbolTable * > symtab_stack
 symbol tables in call hierarchy More...
 
std::string variable_name
 variable for which to construct def-use chain More...
 
DUVariableType variable_type
 variable type (Local or Global) More...
 
bool unsupported_node = false
 indicate that there is unsupported construct encountered More...
 
bool ignore_verbatim = false
 ignore verbatim blocks More...
 
bool visiting_lhs = false
 starting visiting lhs of assignment statement More...
 
std::shared_ptr< const ast::BinaryExpressioncurrent_binary_expression = nullptr
 

Additional Inherited Members

- Protected Member Functions inherited from nmodl::visitor::ConstAstVisitor
void visit_node (const ast::Node &node) override
 visit node of type ast::Node More...
 
void visit_statement (const ast::Statement &node) override
 visit node of type ast::Statement More...
 
void visit_expression (const ast::Expression &node) override
 visit node of type ast::Expression More...
 
void visit_block (const ast::Block &node) override
 visit node of type ast::Block More...
 
void visit_identifier (const ast::Identifier &node) override
 visit node of type ast::Identifier More...
 
void visit_number (const ast::Number &node) override
 visit node of type ast::Number More...
 
void visit_string (const ast::String &node) override
 visit node of type ast::String More...
 
void visit_integer (const ast::Integer &node) override
 visit node of type ast::Integer More...
 
void visit_float (const ast::Float &node) override
 visit node of type ast::Float More...
 
void visit_double (const ast::Double &node) override
 visit node of type ast::Double More...
 
void visit_boolean (const ast::Boolean &node) override
 visit node of type ast::Boolean More...
 
void visit_name (const ast::Name &node) override
 visit node of type ast::Name More...
 
void visit_prime_name (const ast::PrimeName &node) override
 visit node of type ast::PrimeName More...
 
void visit_indexed_name (const ast::IndexedName &node) override
 visit node of type ast::IndexedName More...
 
void visit_var_name (const ast::VarName &node) override
 visit node of type ast::VarName More...
 
void visit_argument (const ast::Argument &node) override
 visit node of type ast::Argument More...
 
void visit_react_var_name (const ast::ReactVarName &node) override
 visit node of type ast::ReactVarName More...
 
void visit_read_ion_var (const ast::ReadIonVar &node) override
 visit node of type ast::ReadIonVar More...
 
void visit_write_ion_var (const ast::WriteIonVar &node) override
 visit node of type ast::WriteIonVar More...
 
void visit_nonspecific_cur_var (const ast::NonspecificCurVar &node) override
 visit node of type ast::NonspecificCurVar More...
 
void visit_electrode_cur_var (const ast::ElectrodeCurVar &node) override
 visit node of type ast::ElectrodeCurVar More...
 
void visit_range_var (const ast::RangeVar &node) override
 visit node of type ast::RangeVar More...
 
void visit_global_var (const ast::GlobalVar &node) override
 visit node of type ast::GlobalVar More...
 
void visit_pointer_var (const ast::PointerVar &node) override
 visit node of type ast::PointerVar More...
 
void visit_random_var (const ast::RandomVar &node) override
 visit node of type ast::RandomVar More...
 
void visit_bbcore_pointer_var (const ast::BbcorePointerVar &node) override
 visit node of type ast::BbcorePointerVar More...
 
void visit_extern_var (const ast::ExternVar &node) override
 visit node of type ast::ExternVar More...
 
void visit_param_block (const ast::ParamBlock &node) override
 visit node of type ast::ParamBlock More...
 
void visit_independent_block (const ast::IndependentBlock &node) override
 visit node of type ast::IndependentBlock More...
 
void visit_assigned_block (const ast::AssignedBlock &node) override
 visit node of type ast::AssignedBlock More...
 
void visit_state_block (const ast::StateBlock &node) override
 visit node of type ast::StateBlock More...
 
void visit_initial_block (const ast::InitialBlock &node) override
 visit node of type ast::InitialBlock More...
 
void visit_constructor_block (const ast::ConstructorBlock &node) override
 visit node of type ast::ConstructorBlock More...
 
void visit_destructor_block (const ast::DestructorBlock &node) override
 visit node of type ast::DestructorBlock More...
 
void visit_statement_block (const ast::StatementBlock &node) override
 visit node of type ast::StatementBlock More...
 
void visit_derivative_block (const ast::DerivativeBlock &node) override
 visit node of type ast::DerivativeBlock More...
 
void visit_linear_block (const ast::LinearBlock &node) override
 visit node of type ast::LinearBlock More...
 
void visit_non_linear_block (const ast::NonLinearBlock &node) override
 visit node of type ast::NonLinearBlock More...
 
void visit_discrete_block (const ast::DiscreteBlock &node) override
 visit node of type ast::DiscreteBlock More...
 
void visit_function_table_block (const ast::FunctionTableBlock &node) override
 visit node of type ast::FunctionTableBlock More...
 
void visit_function_block (const ast::FunctionBlock &node) override
 visit node of type ast::FunctionBlock More...
 
void visit_procedure_block (const ast::ProcedureBlock &node) override
 visit node of type ast::ProcedureBlock More...
 
void visit_net_receive_block (const ast::NetReceiveBlock &node) override
 visit node of type ast::NetReceiveBlock More...
 
void visit_solve_block (const ast::SolveBlock &node) override
 visit node of type ast::SolveBlock More...
 
void visit_breakpoint_block (const ast::BreakpointBlock &node) override
 visit node of type ast::BreakpointBlock More...
 
void visit_before_block (const ast::BeforeBlock &node) override
 visit node of type ast::BeforeBlock More...
 
void visit_after_block (const ast::AfterBlock &node) override
 visit node of type ast::AfterBlock More...
 
void visit_ba_block (const ast::BABlock &node) override
 visit node of type ast::BABlock More...
 
void visit_for_netcon (const ast::ForNetcon &node) override
 visit node of type ast::ForNetcon More...
 
void visit_kinetic_block (const ast::KineticBlock &node) override
 visit node of type ast::KineticBlock More...
 
void visit_unit_block (const ast::UnitBlock &node) override
 visit node of type ast::UnitBlock More...
 
void visit_constant_block (const ast::ConstantBlock &node) override
 visit node of type ast::ConstantBlock More...
 
void visit_neuron_block (const ast::NeuronBlock &node) override
 visit node of type ast::NeuronBlock More...
 
void visit_unit (const ast::Unit &node) override
 visit node of type ast::Unit More...
 
void visit_double_unit (const ast::DoubleUnit &node) override
 visit node of type ast::DoubleUnit More...
 
void visit_local_var (const ast::LocalVar &node) override
 visit node of type ast::LocalVar More...
 
void visit_limits (const ast::Limits &node) override
 visit node of type ast::Limits More...
 
void visit_number_range (const ast::NumberRange &node) override
 visit node of type ast::NumberRange More...
 
void visit_constant_var (const ast::ConstantVar &node) override
 visit node of type ast::ConstantVar More...
 
void visit_binary_operator (const ast::BinaryOperator &node) override
 visit node of type ast::BinaryOperator More...
 
void visit_unary_operator (const ast::UnaryOperator &node) override
 visit node of type ast::UnaryOperator More...
 
void visit_reaction_operator (const ast::ReactionOperator &node) override
 visit node of type ast::ReactionOperator More...
 
void visit_paren_expression (const ast::ParenExpression &node) override
 visit node of type ast::ParenExpression More...
 
void visit_binary_expression (const ast::BinaryExpression &node) override
 visit node of type ast::BinaryExpression More...
 
void visit_diff_eq_expression (const ast::DiffEqExpression &node) override
 visit node of type ast::DiffEqExpression More...
 
void visit_unary_expression (const ast::UnaryExpression &node) override
 visit node of type ast::UnaryExpression More...
 
void visit_non_lin_equation (const ast::NonLinEquation &node) override
 visit node of type ast::NonLinEquation More...
 
void visit_lin_equation (const ast::LinEquation &node) override
 visit node of type ast::LinEquation More...
 
void visit_function_call (const ast::FunctionCall &node) override
 visit node of type ast::FunctionCall More...
 
void visit_watch (const ast::Watch &node) override
 visit node of type ast::Watch More...
 
void visit_ba_block_type (const ast::BABlockType &node) override
 visit node of type ast::BABlockType More...
 
void visit_unit_def (const ast::UnitDef &node) override
 visit node of type ast::UnitDef More...
 
void visit_factor_def (const ast::FactorDef &node) override
 visit node of type ast::FactorDef More...
 
void visit_valence (const ast::Valence &node) override
 visit node of type ast::Valence More...
 
void visit_unit_state (const ast::UnitState &node) override
 visit node of type ast::UnitState More...
 
void visit_local_list_statement (const ast::LocalListStatement &node) override
 visit node of type ast::LocalListStatement More...
 
void visit_model (const ast::Model &node) override
 visit node of type ast::Model More...
 
void visit_define (const ast::Define &node) override
 visit node of type ast::Define More...
 
void visit_include (const ast::Include &node) override
 visit node of type ast::Include More...
 
void visit_param_assign (const ast::ParamAssign &node) override
 visit node of type ast::ParamAssign More...
 
void visit_assigned_definition (const ast::AssignedDefinition &node) override
 visit node of type ast::AssignedDefinition More...
 
void visit_conductance_hint (const ast::ConductanceHint &node) override
 visit node of type ast::ConductanceHint More...
 
void visit_expression_statement (const ast::ExpressionStatement &node) override
 visit node of type ast::ExpressionStatement More...
 
void visit_protect_statement (const ast::ProtectStatement &node) override
 visit node of type ast::ProtectStatement More...
 
void visit_from_statement (const ast::FromStatement &node) override
 visit node of type ast::FromStatement More...
 
void visit_while_statement (const ast::WhileStatement &node) override
 visit node of type ast::WhileStatement More...
 
void visit_if_statement (const ast::IfStatement &node) override
 visit node of type ast::IfStatement More...
 
void visit_else_if_statement (const ast::ElseIfStatement &node) override
 visit node of type ast::ElseIfStatement More...
 
void visit_else_statement (const ast::ElseStatement &node) override
 visit node of type ast::ElseStatement More...
 
void visit_watch_statement (const ast::WatchStatement &node) override
 visit node of type ast::WatchStatement More...
 
void visit_mutex_lock (const ast::MutexLock &node) override
 visit node of type ast::MutexLock More...
 
void visit_mutex_unlock (const ast::MutexUnlock &node) override
 visit node of type ast::MutexUnlock More...
 
void visit_conserve (const ast::Conserve &node) override
 visit node of type ast::Conserve More...
 
void visit_compartment (const ast::Compartment &node) override
 visit node of type ast::Compartment More...
 
void visit_lon_difuse (const ast::LonDifuse &node) override
 visit node of type ast::LonDifuse More...
 
void visit_reaction_statement (const ast::ReactionStatement &node) override
 visit node of type ast::ReactionStatement More...
 
void visit_lag_statement (const ast::LagStatement &node) override
 visit node of type ast::LagStatement More...
 
void visit_constant_statement (const ast::ConstantStatement &node) override
 visit node of type ast::ConstantStatement More...
 
void visit_table_statement (const ast::TableStatement &node) override
 visit node of type ast::TableStatement More...
 
void visit_suffix (const ast::Suffix &node) override
 visit node of type ast::Suffix More...
 
void visit_useion (const ast::Useion &node) override
 visit node of type ast::Useion More...
 
void visit_nonspecific (const ast::Nonspecific &node) override
 visit node of type ast::Nonspecific More...
 
void visit_electrode_current (const ast::ElectrodeCurrent &node) override
 visit node of type ast::ElectrodeCurrent More...
 
void visit_range (const ast::Range &node) override
 visit node of type ast::Range More...
 
void visit_global (const ast::Global &node) override
 visit node of type ast::Global More...
 
void visit_random_var_list (const ast::RandomVarList &node) override
 visit node of type ast::RandomVarList More...
 
void visit_pointer (const ast::Pointer &node) override
 visit node of type ast::Pointer More...
 
void visit_bbcore_pointer (const ast::BbcorePointer &node) override
 visit node of type ast::BbcorePointer More...
 
void visit_external (const ast::External &node) override
 visit node of type ast::External More...
 
void visit_thread_safe (const ast::ThreadSafe &node) override
 visit node of type ast::ThreadSafe More...
 
void visit_verbatim (const ast::Verbatim &node) override
 visit node of type ast::Verbatim More...
 
void visit_line_comment (const ast::LineComment &node) override
 visit node of type ast::LineComment More...
 
void visit_block_comment (const ast::BlockComment &node) override
 visit node of type ast::BlockComment More...
 
void visit_ontology_statement (const ast::OntologyStatement &node) override
 visit node of type ast::OntologyStatement More...
 
void visit_program (const ast::Program &node) override
 visit node of type ast::Program More...
 
void visit_nrn_state_block (const ast::NrnStateBlock &node) override
 visit node of type ast::NrnStateBlock More...
 
void visit_eigen_newton_solver_block (const ast::EigenNewtonSolverBlock &node) override
 visit node of type ast::EigenNewtonSolverBlock More...
 
void visit_eigen_linear_solver_block (const ast::EigenLinearSolverBlock &node) override
 visit node of type ast::EigenLinearSolverBlock More...
 
void visit_wrapped_expression (const ast::WrappedExpression &node) override
 visit node of type ast::WrappedExpression More...
 
void visit_derivimplicit_callback (const ast::DerivimplicitCallback &node) override
 visit node of type ast::DerivimplicitCallback More...
 
void visit_solution_expression (const ast::SolutionExpression &node) override
 visit node of type ast::SolutionExpression More...
 
void visit_update_dt (const ast::UpdateDt &node) override
 visit node of type ast::UpdateDt More...
 
- Protected Member Functions inherited from nmodl::visitor::ConstVisitor
virtual ~ConstVisitor ()=default
 

Constructor & Destructor Documentation

◆ DefUseAnalyzeVisitor() [1/3]

nmodl::visitor::DefUseAnalyzeVisitor::DefUseAnalyzeVisitor ( )
delete

◆ DefUseAnalyzeVisitor() [2/3]

nmodl::visitor::DefUseAnalyzeVisitor::DefUseAnalyzeVisitor ( symtab::SymbolTable symtab)
inlineexplicit

Definition at line 257 of file defuse_analyze_visitor.hpp.

◆ DefUseAnalyzeVisitor() [3/3]

nmodl::visitor::DefUseAnalyzeVisitor::DefUseAnalyzeVisitor ( symtab::SymbolTable symtab,
bool  ignore_verbatim 
)
inline

Definition at line 260 of file defuse_analyze_visitor.hpp.

Member Function Documentation

◆ analyze()

DUChain nmodl::visitor::DefUseAnalyzeVisitor::analyze ( const ast::Ast node,
const std::string &  name 
)

compute def-use chain for a variable within the node

re-initialize state

new chain

analyze given node

Definition at line 419 of file defuse_analyze_visitor.cpp.

◆ process_variable() [1/2]

void nmodl::visitor::DefUseAnalyzeVisitor::process_variable ( const std::string &  name)
private

Definition at line 393 of file defuse_analyze_visitor.cpp.

◆ process_variable() [2/2]

void nmodl::visitor::DefUseAnalyzeVisitor::process_variable ( const std::string &  name,
int  index 
)
private

Definition at line 399 of file defuse_analyze_visitor.cpp.

◆ start_new_chain()

void nmodl::visitor::DefUseAnalyzeVisitor::start_new_chain ( DUState  state)
private

Definition at line 414 of file defuse_analyze_visitor.cpp.

◆ update_defuse_chain()

void nmodl::visitor::DefUseAnalyzeVisitor::update_defuse_chain ( const std::string &  name)
private

Update the Def-Use chain for given variable.

Parameters
nameName of the variable excluding index or dimension

Update def-use chain if we encounter a variable that we are looking for. If we encounter non-supported construct then we mark that variable as "use" because we haven't completely analyzed the usage. Marking that variable "U" make sures that won't get optimized. Then we distinguish between local and non-local variables. All variables that appear on lhs are marked as "definitions" whereas the one on rhs are marked as "usages".

Definition at line 369 of file defuse_analyze_visitor.cpp.

◆ visit_argument()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_argument ( const ast::Argument node)
overridevirtual

visit node of type ast::Argument

Implements nmodl::visitor::ConstVisitor.

Definition at line 354 of file defuse_analyze_visitor.cpp.

◆ visit_binary_expression()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_binary_expression ( const ast::BinaryExpression node)
overridevirtual

Nmodl grammar doesn't allow assignment operator on rhs (e.g.

a = b + (b=c) and hence not necessary to keep track of assignment operator using stack.

Implements nmodl::visitor::ConstVisitor.

Definition at line 229 of file defuse_analyze_visitor.cpp.

◆ visit_conductance_hint()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_conductance_hint ( const ast::ConductanceHint node)
overridevirtual

statements / nodes that should not be used for def-use chain analysis

Implements nmodl::visitor::ConstVisitor.

Definition at line 350 of file defuse_analyze_visitor.cpp.

◆ visit_conserve()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_conserve ( const ast::Conserve node)
overridevirtual

visit node of type ast::Conserve

Implements nmodl::visitor::ConstVisitor.

Definition at line 313 of file defuse_analyze_visitor.cpp.

◆ visit_from_statement()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_from_statement ( const ast::FromStatement node)
overridevirtual

visit node of type ast::FromStatement

Implements nmodl::visitor::ConstVisitor.

Definition at line 309 of file defuse_analyze_visitor.cpp.

◆ visit_function_call()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_function_call ( const ast::FunctionCall node)
overridevirtual

Nothing to do if called function is not defined or it's external but if there is a function call for internal function that means there is no inlining happened.

In this case we mark the call as unsupported.

Implements nmodl::visitor::ConstVisitor.

Definition at line 204 of file defuse_analyze_visitor.cpp.

◆ visit_if_statement()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_if_statement ( const ast::IfStatement node)
overridevirtual

visit node of type ast::IfStatement

store previous chain

starting new if block

visiting if sub-block

visiting else if sub-blocks

visiting else sub-block

restore to previous chain

Implements nmodl::visitor::ConstVisitor.

Definition at line 249 of file defuse_analyze_visitor.cpp.

◆ visit_indexed_name()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_indexed_name ( const ast::IndexedName node)
overridevirtual

visit node of type ast::IndexedName

index should be an integer (e.g. after constant folding) if this is not the case and then we can't determine exact def-use chain

check if variable name without index part is same

Implements nmodl::visitor::ConstVisitor.

Definition at line 327 of file defuse_analyze_visitor.cpp.

◆ visit_lin_equation()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_lin_equation ( const ast::LinEquation node)
overridevirtual

visit node of type ast::LinEquation

Implements nmodl::visitor::ConstVisitor.

Definition at line 305 of file defuse_analyze_visitor.cpp.

◆ visit_local_list_statement()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_local_list_statement ( const ast::LocalListStatement node)
overridevirtual

visit node of type ast::LocalListStatement

Implements nmodl::visitor::ConstVisitor.

Definition at line 352 of file defuse_analyze_visitor.cpp.

◆ visit_name()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_name ( const ast::Name node)
overridevirtual

visit node of type ast::Name

Implements nmodl::visitor::ConstVisitor.

Definition at line 322 of file defuse_analyze_visitor.cpp.

◆ visit_non_lin_equation()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_non_lin_equation ( const ast::NonLinEquation node)
overridevirtual

visit node of type ast::NonLinEquation

Implements nmodl::visitor::ConstVisitor.

Definition at line 301 of file defuse_analyze_visitor.cpp.

◆ visit_reaction_statement()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_reaction_statement ( const ast::ReactionStatement node)
overridevirtual

unsupported statements : we aren't sure how to handle this "yet" and hence variables used in any of the below statements are handled separately

Implements nmodl::visitor::ConstVisitor.

Definition at line 297 of file defuse_analyze_visitor.cpp.

◆ visit_statement_block()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_statement_block ( const ast::StatementBlock node)
overridevirtual

visit node of type ast::StatementBlock

Implements nmodl::visitor::ConstVisitor.

Definition at line 214 of file defuse_analyze_visitor.cpp.

◆ visit_unsupported_node()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_unsupported_node ( const ast::Node node)
private

Definition at line 193 of file defuse_analyze_visitor.cpp.

◆ visit_var_name()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_var_name ( const ast::VarName node)
overridevirtual

visit node of type ast::VarName

Implements nmodl::visitor::ConstVisitor.

Definition at line 317 of file defuse_analyze_visitor.cpp.

◆ visit_verbatim()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_verbatim ( const ast::Verbatim node)
overridevirtual

We are not analyzing verbatim blocks yet and hence if there is a verbatim block we assume there is variable usage.

Todo:
One simple way would be to look for p_name in the string of verbatim block to find the variable usage.

Implements nmodl::visitor::ConstVisitor.

Definition at line 287 of file defuse_analyze_visitor.cpp.

◆ visit_with_new_chain()

void nmodl::visitor::DefUseAnalyzeVisitor::visit_with_new_chain ( const ast::Node node,
DUState  state 
)
private

Definition at line 407 of file defuse_analyze_visitor.cpp.

Member Data Documentation

◆ current_binary_expression

std::shared_ptr<const ast::BinaryExpression> nmodl::visitor::DefUseAnalyzeVisitor::current_binary_expression = nullptr
private

Definition at line 244 of file defuse_analyze_visitor.hpp.

◆ current_chain

std::vector<DUInstance>* nmodl::visitor::DefUseAnalyzeVisitor::current_chain = nullptr
private

def-use chain currently being constructed

Definition at line 220 of file defuse_analyze_visitor.hpp.

◆ current_symtab

symtab::SymbolTable* nmodl::visitor::DefUseAnalyzeVisitor::current_symtab = nullptr
private

symbol table for current statement block (or of parent block if doesn't have) should be initialized by caller somehow

Definition at line 224 of file defuse_analyze_visitor.hpp.

◆ global_symtab

symtab::SymbolTable* nmodl::visitor::DefUseAnalyzeVisitor::global_symtab = nullptr
private

symbol table containing global variables

Definition at line 217 of file defuse_analyze_visitor.hpp.

◆ ignore_verbatim

bool nmodl::visitor::DefUseAnalyzeVisitor::ignore_verbatim = false
private

ignore verbatim blocks

Definition at line 239 of file defuse_analyze_visitor.hpp.

◆ symtab_stack

std::stack<symtab::SymbolTable*> nmodl::visitor::DefUseAnalyzeVisitor::symtab_stack
private

symbol tables in call hierarchy

Definition at line 227 of file defuse_analyze_visitor.hpp.

◆ unsupported_node

bool nmodl::visitor::DefUseAnalyzeVisitor::unsupported_node = false
private

indicate that there is unsupported construct encountered

Definition at line 236 of file defuse_analyze_visitor.hpp.

◆ variable_name

std::string nmodl::visitor::DefUseAnalyzeVisitor::variable_name
private

variable for which to construct def-use chain

Definition at line 230 of file defuse_analyze_visitor.hpp.

◆ variable_type

DUVariableType nmodl::visitor::DefUseAnalyzeVisitor::variable_type
private

variable type (Local or Global)

Definition at line 233 of file defuse_analyze_visitor.hpp.

◆ visiting_lhs

bool nmodl::visitor::DefUseAnalyzeVisitor::visiting_lhs = false
private

starting visiting lhs of assignment statement

Definition at line 242 of file defuse_analyze_visitor.hpp.


The documentation for this class was generated from the following files: