![]() |
User Guide
|
Represent use of a variable in the statement. More...
Represent use of a variable in the statement.
For a given variable, say tau, when we have statement like a = tau + c + tau
then def-use is simply [DUState::U, DUState::U]
. But if we have if-else block like:
Then to know the effective result, we have to analyze def-use in IF
and ELSE
blocks i.e. if variable is used in any of the if-elseif-else block then it needs to mark as DUState::U
. Hence we keep the track of all children in case of statements like if-else.
Definition at line 85 of file defuse_analyze_visitor.hpp.
#include <defuse_analyze_visitor.hpp>
Public Member Functions | |
DUInstance (DUState state, const std::shared_ptr< const ast::BinaryExpression > binary_expression) | |
DUState | eval (DUVariableType variable_type) const |
analyze all children and return "effective" usage More... | |
DUState | sub_block_eval (DUVariableType variable_type) const |
if, elseif and else evaluation More... | |
DUState | conditional_block_eval (DUVariableType variable_type) const |
evaluate global usage i.e. with [D,U] states of children More... | |
void | print (printer::JSONPrinter &printer) const |
DUInstance to JSON string. More... | |
Public Attributes | |
DUState | state |
state of the usage More... | |
std::vector< DUInstance > | children |
usage of variable in case of if like statements More... | |
std::shared_ptr< const ast::BinaryExpression > | binary_expression |
binary expression in which the variable is used/defined More... | |
|
inlineexplicit |
Definition at line 93 of file defuse_analyze_visitor.hpp.
DUState nmodl::visitor::DUInstance::conditional_block_eval | ( | DUVariableType | variable_type = DUVariableType::Global | ) | const |
evaluate global usage i.e. with [D,U] states of children
Evaluate conditional block containing sub-blocks like if, elseif and else.
Note that sub-blocks are already evaluated by sub_block_eval() and has only leaf nodes. In order to find effective defuse, following rules are used:
Definition at line 133 of file defuse_analyze_visitor.cpp.
DUState nmodl::visitor::DUInstance::eval | ( | DUVariableType | variable_type = DUVariableType::Global | ) | const |
analyze all children and return "effective" usage
Find "effective" usage of variable from def-use chain.
Note that we are interested in "global" variable usage and hence we consider only [U,D] states and not [LU, LD]
Definition at line 165 of file defuse_analyze_visitor.cpp.
void nmodl::visitor::DUInstance::print | ( | printer::JSONPrinter & | printer | ) | const |
DUInstance to JSON string.
Definition at line 57 of file defuse_analyze_visitor.cpp.
DUState nmodl::visitor::DUInstance::sub_block_eval | ( | DUVariableType | variable_type = DUVariableType::Global | ) | const |
if, elseif and else evaluation
Evaluate sub-blocks like if, elseif and else As these are innermost blocks, we have to just check first use of variable in this block and that's the result of this block.
Definition at line 89 of file defuse_analyze_visitor.cpp.
std::shared_ptr<const ast::BinaryExpression> nmodl::visitor::DUInstance::binary_expression |
binary expression in which the variable is used/defined
We use the binary expression because it is used in both:
We also want the outermost binary expression. Thus, we do not keep track of the interior ones. For example:
\( tau = tau + 1 \)
we want to return the full statement, not only \( tau + 1 \)
Definition at line 123 of file defuse_analyze_visitor.hpp.
std::vector<DUInstance> nmodl::visitor::DUInstance::children |
usage of variable in case of if like statements
Definition at line 91 of file defuse_analyze_visitor.hpp.
DUState nmodl::visitor::DUInstance::state |
state of the usage
Definition at line 88 of file defuse_analyze_visitor.hpp.