-
Notifications
You must be signed in to change notification settings - Fork 171
WIP: Implementing Symbolic ASR pass #2200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Very good, great plan. |
src/libasr/pass/replace_symbolic.cpp
Outdated
for (auto &item : current_scope->get_scope()) { | ||
if (is_a<ASR::Variable_t>(*item.second)) { | ||
this->visit_symbol(*item.second); | ||
if(symbolic_replaces_with_CPtr_Function){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do this operation in the visit_variable itself.
And remove both visit_Module and visit_Function.
I think PassVisitor handles everything, Even transform_stmts
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can access the Function scope using current_scope
and the Module scope using current_scope->parent
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Store all the statements in pass_result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so if we get rid of visit_Module
and visit_Function
,
the scope for function is x.m_parent_symtab
and that of module is x.m_parent_symtab->parent
right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, that would work, but let's use current_scope
instead.
PassVisitor would have assigned current_scope
with x.m_symtab
in visit_Function
(in asr.h
: ASRPassBaseWalkVisitor
).
So you can use current_scope
to access the Function scope and current_scope-> parent
to access the Module scope.
ReplaceSymbolicVisitor(Allocator &al_) : | ||
PassVisitor(al_, nullptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this: #2200 (comment) doesn't work, pass m_global_scope
as an argument to ReplaceSymbolicVisitor
and pass that symtab
to PassVisitor
instead of nullptr
.
99c3295
to
e8c173a
Compare
e8c173a
to
e77ac83
Compare
Thanks @Thirumalai-Shaktivel for the review! |
That's it! |
SymbolTable* current_scope_copy = current_scope; | ||
current_scope = xx.m_parent_symtab; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this, as we already assign it in the Function visitor!
Great job, @anutosh491! |
The pass should be responsible for converting the ASR of Program 1 to Prorgam 2
Program 1
Program 2