Week 8 - Implicit Deallocate & Abstracting Descriptor Access

This week, I worked on two things. First one is ImplicitDeallocate node. After our meeting, Ondrej and I decided to directly add ImplicitDeallocate in the main ASR i.e., the one available just before applying all the passes and handing over to the backend. The reason being that we are always going to add the above nodes irrespective of what the program contains. In other words, instead of sweeping over the ASR twice we can just simply add these nodes in relevant visitor methods. Say, for example we need to add this node just before every return statement, then we can easily do this in, visit_Return (or something like that, this is just an example). No need to go over the ASR again and keep doing type checking on every node we encounter. Another thing we discovered in our meeting is that array descriptor members were being directly accessed in asr_to_llvm.cpp. So, any change to the descriptor would require a lot of changes in the above file, which is obviously wasteful hardwork. So we decided to abstract out the calls in such a manner that if the descriptor changes then we don’t have to modify the calls to access the new descriptor’s members, just change the implementation and everything will fall into place. Well, virtual functions comes to the rescue in such a case. We created a base class (with default implementations) and then inherited it in subclasses where we provided concrete implementations for playing around with a descriptor. This way if we need some new subclass, we won’t be required to touch asr_to_llvm.cpp. Just new implementations will be used instead of older ones. Following are the links to MRs, in case you are interested. Bye!

MR - !1018

MR - !1026

Address

Jodhpur, Rajasthan, India