WIP: Implementing Symbolic ASR pass#2200
WIP: Implementing Symbolic ASR pass#2200anutosh491 wants to merge 12 commits intolcompilers:mainfrom
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.
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.
You can access the Function scope using current_scope and the Module scope using current_scope->parent.
There was a problem hiding this comment.
Store all the statements in pass_result.
There was a problem hiding this comment.
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.
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.
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.
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