-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for ASSOCIATE blocks #2165
Comments
I think this should just be a matter of identifying references to an associate-name and replacing it with the equivalent PSyIR fragment which we can construct when we encounter the ASSOCIATE. |
I thought about this some more last night and decided it wouldn't actually be that easy - as illustrated by the last two examples above, the associate-name can be a reference to a structure access. This is then effectively the same problem that we've already solved in the in-lining support. That might need some refactoring to support this case. |
I now have a first working version that simply creates an instance of
|
I started implementing functionality to assign the associate-expressions to local temporaries and immediately hit (yet) another problem: associate-names can appear on the LHS of assignments (as in the examples in the description of this Issue). Obviously it then makes no sense to have a local temporary :-( |
Unfortunately, if an associate-name is passed to a Call then we don't know whether or not it is written to. |
Our normal approach to this sort of problem is to give the user the nuclear option (i.e. tell us that it is safe). However, this functionality is in the PSyIR front end and so we have no current mechanism for exposing such an option (and then it would have to be on a per-file basis anyway). An alternative approach would be to leave the front end as is and supply a Transformation that attempts to convert a CodeBlock containing an ASSOCIATE block into code. That could then be given a |
Why does it matter if the associate name appears on the LHS of an expression if the associate name is translated to a local variable? |
We've just discussed this at length and have concluded that the only general solution is to either declare a pointer if the expression corresponds to an address in memory OR evaluate it and store the result if it has a value. The question is, how easy is it going to be to modify the declaration of the thing we need to point to (i.e. give it the TARGET attribute) so that Fortran is happy? |
Fortran 2003 has the ASSOCIATE block:
and this is used quite heavily in NEMOVAR.
Essentially, it boils down to syntactic sugar in order to simplify the use of complex expressions, e.g.:
The text was updated successfully, but these errors were encountered: