[Flang-dev] RFC: lowering Fortran AST to an IR

Roger Ferrer Ibáñez rofirrim at gmail.com
Thu Oct 25 02:09:54 EDT 2018


Hi,

I see. Thanks for the clarification Eric!

Regards,

Missatge de Eric Schweitz (PGI) <eric.schweitz at pgroup.com> del dia dj., 25
d’oct. 2018 a les 1:14:

> Hi Roger,
>
>
>
> Thank you for your questions.  First, I should clarify that I am not the
> author of this document.
>
>
>
> My understanding is the intent is for scope transitions to be encoded as
> action pairs, each of which correspond to an LLVM Instruction. To borrow
> your example, it could look something like the following. Blue would be the
> outer (PROGRAM) scope and red the inner (BLOCK construct) scope.
>
>
>
> +-----------
>
> ENTRY_BLOCK:
>
> program main
>
> SCOPE_ENTRY
>     implicit none
>     integer :: x, i
>     integer, external :: fun
>
> BR BLOCK1
> +-----------
>
> +-----------
>
> BLOCK1:
>     do i = 1, 10
>       block
>
> SCOPE_ENTRY
>           integer :: y
>           y = i + 1
>           print *, y
>           if (i < fun()) &
>
> BCC _ BLOCK2 BLOCK3
>
> +-----------
>
> +-----------
>
> BLOCK2:
>
>               & exit
>
> SCOPE_EXIT
>
> BR EXIT_BLOCK
> +-----------
>
> +-----------
>
> BLOCK3:
>
>       end block
>
> SCOPE_EXIT
>    end do
>
> GOTO BLOCK1
> +-----------
>
> +-----------
>
> EXIT_BLOCK:
>
>    print *, "end"
> SCOPE_EXIT
>
> end program main
>
> +-----------
>
>
>
> The proposal might be seen as (speaking imprecisely) analogous to
> requiring the use of @llvm.stacksave and @llvm.stackrestore intrinsics, and
> the maintenance of the invariants is more complicated than these
> @llvm.stack* calls (as a SCOPE EXIT cannot be omitted).
>
>
>
> --
>
> Eric
>
>
>
> *From:* Roger Ferrer Ibáñez <rofirrim at gmail.com>
> *Sent:* Wednesday, October 24, 2018 2:27 PM
> *To:* Eric Schweitz (PGI) <eric.schweitz at pgroup.com>
> *Cc:* flang-dev at lists.flang-compiler.org
> *Subject:* Re: [Flang-dev] RFC: lowering Fortran AST to an IR
>
>
>
> Hi Eric,
>
>
>
> thanks a lot for sharing pointers to these documents.
>
>
>
> I was curious about the scope transitions. If I'm reading it right, it
> means that the control flow graph encodes the active scope of the current
> basic block. Is my understanding correct?
>
>
>
> If so, doesn't it become a bit complicated to maintain in the presence of
> transfers of control flow that cross the boundary of a scope?
>
>
>
> I was thinking of an example like this
>
>
>
> program main
>     implicit none
>     integer :: x, i
>     integer, external :: fun
>
>     do i = 1, 10
>       block
>           integer :: y
>           y = i + 1
>           print *, y
>           if (i < fun()) exit
>       end block
>    end do
>    print *, "end"
> end program main
>
>
>
> Would the exit have to cross first a SCOPE_EXIT (I presume there would be
> one for the 'end block') before jumping to the 'print *, "end"'?
>
>
>
> Kind regards,
>
> Roger
>
>
>
> Missatge de Eric Schweitz (PGI) <eric.schweitz at pgroup.com> del dia dc.,
> 24 d’oct. 2018 a les 21:42:
>
> The f18 project has a high-level design document out for several months on
> an intermediate representation for lowering and optimizing Fortran ASTs.
> The document can be found here: https://bit.ly/2q9IRaQ
>
>
>
> Some context for this document can be found in the github documentation
> at: https://github.com/flang-compiler/f18/tree/master/documentation
>
> Of particular note:
>
> * Parsing: https://bit.ly/2ERlXyO
>
> * Semantics: https://bit.ly/2CAybcB
>
> * Label Resolution: https://bit.ly/2PlXQfP
>
>
>
> The purpose of the f18 CFG will be to lower Fortran surface syntax into an
> semantically clean operational structure amenable to high-level
> transformations and further lowering into LLVM-IR.
>
>
>
> As the project continues to move forward, we would like to know of if
> there are any relevant thoughts, concerns, or questions.
>
>
>
> --
>
> Eric
>
>
> ------------------------------
>
> This email message is for the sole use of the intended recipient(s) and
> may contain confidential information.  Any unauthorized review, use,
> disclosure or distribution is prohibited.  If you are not the intended
> recipient, please contact the sender by reply email and destroy all copies
> of the original message.
> ------------------------------
>
> _______________________________________________
> flang-dev mailing list
> flang-dev at lists.flang-compiler.org
>
> http://lists.flang-compiler.org/mailman/listinfo/flang-dev_lists.flang-compiler.org
>
>
>
> --
>
> Roger Ferrer Ibáñez
>


-- 
Roger Ferrer Ibáñez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.flang-compiler.org/pipermail/flang-dev_lists.flang-compiler.org/attachments/20181025/12bad446/attachment.html>


More information about the flang-dev mailing list