![]() |
User Guide
|
Visitor to transform global variable usage to local More...
Visitor to transform global variable usage to local
Motivation: As NMODL doesn't support returning multiple values, procedures are often written with use of range variables that can be made local. For example:
In above example we are only interested in variable alpha computed in DERIVATIVE block. If rates() is inlined into DERIVATIVE block then we get:
Now tau and beta could become local variables provided that their values are not used in any other global blocks.
Implementation Notes:
Definition at line 84 of file localize_visitor.hpp.
#include <localize_visitor.hpp>
Private Member Functions | |
std::vector< std::string > | variables_to_optimize () const |
bool | node_for_def_use_analysis (const ast::Node &node) const |
bool | is_solve_procedure (const ast::Node &node) const |
Private Attributes | |
bool | ignore_verbatim = false |
ignore verbatim blocks while localizing More... | |
symtab::SymbolTable * | program_symtab = nullptr |
|
default |
|
inlineexplicit |
Definition at line 100 of file localize_visitor.hpp.
|
private |
Definition at line 59 of file localize_visitor.cpp.
|
private |
Blocks where we should compute def-use chains. We are excluding procedures and functions because we expect those to be "inlined". If procedure/function is not inlined then DefUse pass returns result as "Use". So it's safe.
Definition at line 23 of file localize_visitor.cpp.
|
private |
Definition at line 69 of file localize_visitor.cpp.
|
overridevirtual |
visit node of type ast::Program
symtab visitor pass need to be run before
compute def use chains
as we are doing global analysis, if any global block is "using" variable then we can't localize the variable
all blocks that are have either definition or conditional definition need local variable
mark variable as localized in global symbol table
insert new symbol in the symbol table of current block
Implements nmodl::visitor::ConstVisitor.
Definition at line 103 of file localize_visitor.cpp.
|
private |
ignore verbatim blocks while localizing
Definition at line 87 of file localize_visitor.hpp.
|
private |
Definition at line 89 of file localize_visitor.hpp.