Hi, continuing with the GSoC blog series, I would be sharing my progress in the second week of the programme. I would say it was a challenging one since I had to brainstorm a lot about how to include intrinsic functions (like,
ubound) at the ASR level. But thanks to Ondrej the problem got resolved once we met on Tuesday. Let’s dive into details without further delay.
Intrinsic Function Support For Arrays
As I said, the challenging part for this feature was to find an easy method to include calls and declarations of intrinsic functions for arrays at the ASR level. There were two approaches, one was to add such functions manually to the ASR tree and the other one was to define an empty function as an interface and let
lfortran do the job of adding that interface to the ASR tree automatically. The second approach sounds easier and more efficient. However, it treats an intrinsic function as something defined by the user and the backend doesn’t get a signal to write its own definition for it. So, we decided to reset the
abiType of these functions as
Intrinsic which can be used by any backend as a signal and add their own definition for it. Thanks to Ondrej for the ideas and suggestions which lead to this beautiful solution.
Well, this is an easy one once we figure out a way to generate nested do loops automatically and add that to the ASR. In simple terms, an operation like,
c = a + b gets converted to,
c(i, j, k, . . .) = a(i, j, k, . . .) + b(i, j, k, . . .). Moreover, we will add optimisations (extend to be specific) to evaluate the RHS if both the array references are found to be constants or
parameters in Fortran terms.
MRs - !939
Well, again I will be converting the slicing operation to a nested do loop. Though the tricky part is to decide where the result of slicing should go. I have planned to store it in a new array variable (having a number or a symbol like
@ in the prefix) and replace the occurrences of similar slices with that new variable. Let me know if you have any other ideas to deal with it in the MR below.
MR - !943
So that’s all for this week. Will update you in the next week. Take care and stay safe until then.