Week2 - Continuing COMMON Blocks

Continuation of COMMON block

Date: May 29, 2023.

Hello! May 28, 2023 marked the end of second week of GSoC'23. In this week I continued working on the implementation of COMMON block. Majorly I focused on getting common block variables replaced with StructAccessMember in the body of the program.

To start simple I decided to work on getting common block variables in assignments replaced with StructAccessMember. On observation, we found that we have to do it every time we "resolve" a variable / array. I used `replace_with_common_block_variables` function to replace common block variables with StructAccessMember. This function takes `ASR::expr_t*` as input and returns replaced `ASR::expr_t*` as output. For example:

The above code snippet translates to the following fortran code:

Initially a COMMON module was created and populated with StructType_t, which contains all variables of COMMON blocks. Then in `ast_body_visitor` I used `replace_with_common_block_variables` to replace Variable_t and ArrayItem_t with StructAccessMember_t. This was done by checking if the variable is present in the hash table or not. If it is present then we replace it with StructAccessMember_t. With this ASR implementation of COMMON block was completed.

ASR to LLVM

The first issue for ASR to LLVM conversion was Issue: 1703 that was because of wrong addition of `ASR::StructType_t.m_name` to dependencies of `ASR::Module_t` created. Second was Issue: 1684 which was because of not adding variable names to dependencies of `ASR::StructType_t` created. Both of these issues were fixed throught PR: 1706.

Later on we realised that LFortran is unable to compile the translated code to LLVM (Issue: 1723) which needs to be fixed for successfull compilation of ASR to LLVM code. We are still working on it and will be fixed soon.

In short, I worked for 13 hours this week and was able to complete ASR implementaiton of COMMON block. I also worked on ASR to LLVM conversion but was unable to complete it. All the Issues and PRs can be found below:

  • PR: 1665
  • Issue: 1684
  • Issue: 1694
  • PR: 1695
  • Issue: 1703
  • Issue: 1713
  • Issue: 1714
  • Issue: 1715
  • Issue: 1723
  • I would to thank Ondřej Čertík for helping me out during this week and guiding me through the whole process.