-
Notifications
You must be signed in to change notification settings - Fork 138
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
[RFC]Add align pragma for derived type and fix shape array/character type #1360
Conversation
Gentle Ping... |
Thanks @JiaweiHawk for this RFC and patch. We would like to support directives in commonly used formats. Is this based on some other compiler's directives? The only one I could find was Intel's which has the syntax Also think having a hex number is probably not good for readability. |
Thank @kiranchandramohan for reviewing.
I chose this format only because I found the keyword "SW_ALIGN" in the source code, so I reused that part of the code, which resulted in this format.
Here I did not specify a particular format for the numbers, I just use By the way, there seems to be some errors in the test cases added in this patch, I will try to fix them later. |
f161447
to
5863814
Compare
IMO if the cost of sticking to Intel's syntax is too high and requires major refactor, then we'd rather use the simpler syntax proposed by the author (as it is simpler and straightforward). I do agree though about use of hex, it's uncommon in the Fortran world. |
b3a5219
to
05667b8
Compare
Yes, changing to the Intel's syntax does require some refactor on the In fact, there is already If possible, I'd like to keep my original syntax, which allows me to do less work. As for the use of hex, this patch supports both hexadecimal and decimal formats. And I have changed the test case to decimal formats and it works fine. |
05667b8
to
72de48c
Compare
It's ok for me. |
If it is possible, can I still keep my original syntax? It appears that Flang originally intended to implement So I think we can reuse this interface, and this can allow me to do less work. |
If we are using a non-standard format then we will have to define the syntax, meaning, restrictions (which values can be provided, which types apply). Also, we will be setting a precedent and if the format is not available in Having said that, we do not want to spend too much time adding the feature to Classic Flang. So I am OK if @bryanpkc and @shivaramaarao are OK. @pawosm-arm has already given his go ahead. |
The syntax looks fine to me. I will find time to review the PR. |
Hi all, It seems like there are some issues with the CI.
|
@bryanpkc I think we need to make decisions here
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that adding a palign
field to symbols in the ILM output necessitates bumping up the ILM version number in tools/flang2/flang2exe/upper.h
.
Thanks @bryanpkc for the review. I've identified the similar issue in Additionally, I would like to inquire how to generate the numeric values on the left side of the comments, it seems that there isn't much information on how these numbers should be generated. /*
* 20.1 -- 1.55
* All of 1.54 +
* pass elemental field for subprogram when emitting ST_ENTRY.
*
* For ST_PROC, receive IS_PROC_PTR_IFACE flag.
*
* ${how to generate this number} -- 1.56
* All of 1.55 + PALIGN
*/
#include "gbldefs.h"
#include "semant.h"
#define VersionMajor 1
#define VersionMinor 56 |
@JiaweiHawk I think those numbers are nvfortran version numbers, and are no longer relevant in open-source Classic Flang. You could use something like |
Thank you for explanation. I will update this patchset according to your suggestions. |
This patch adds the `palign` field in `struct SYM` to record the symbol's alignment passed by `!DIR$ ALIGN alignment`.
flang should store the alignment from `!DIR$ ALIGN alignment` pragma to the symbol when decalring a variable's symbol, so later flang can align the variable by ALIGNG(sptr).
flang1 uses export_symbol() to export symbols to .mod files, and uses import() to import symbols from .mod files. This patch exports `palign` field from `SYM` to .mod files, and imports `palign` field from .mod files to `ps->sym.palign`.
flang1 uses lower_symbol() to lower symbols to .stb file, and flang2 uses read_symbol() to upper symbols from .stb file. This patch exports `palign` field from `SYM` to .stb files, and imports `palign` field from .stb files to `SYM`. What's more, this patch also refactors a test case to pass regression tests.
To align the symbol set by `!DIR$ ALIGN alignment` pragma in flang1, flang should align both its symbol's offset in AG and AG's alignment in memory. This patch ensures that the BSS is aligned in memory to the maximum alignment among all symbols in the BSS.
To align the symbol set by `!DIR$ ALIGN alignment` pragma in flang1, flang should align both its symbol's offset in AG and AG's alignment in memory. This patch ensures that the statics is aligned in memory to the maximum alignment among all symbols in the statics.
To align the symbol set by `!DIR$ ALIGN alignment` pragma in flang1, flang should align both its symbol's offset in AG and AG's alignment in memory. This patch ensures that the cmn is aligned in memory to the maximum alignment among all symbols in the cmn.
To align the symbol set by `!DIR$ ALIGN alignment` pragma in flang1, flang should align both its symbol's offset in AG and AG's alignment in memory. This patch ensures the alignment of the symbol's offset in AG.
flang uses alignment_of_var()/alignment_var()/align_of_var() to get the symbol alignment. This patch fixes symbol alignment with `PALIGNG(s)` passed from pragma `!DIR$ ALIGN alignment` in flang1.
Add test case to validate the effectiveness of the pragma `!DIR$ ALIGN alignment` for derived types.
Add test case to validate the effectiveness of the pragma `!DIR$ ALIGN alignment` for array.
Add test case to validate the effectiveness of the pragma `!DIR$ ALIGN alignment` for character.
46ab29c
to
7e38f91
Compare
Hi all, It seems like CI does not find the clang binary. build_flang (AArch64, release_15x) CI encountered an error during the "Check tools" step, the complete log is provided below:
|
Yep, I became aware of the CI failures yesterday and have been trying to fix them. The cause is that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. (Sorry I had re-requested a review from you by mistake, @pawosm-arm.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggested squashing the commits on merge
Thank you very much for your contribution, @JiaweiHawk! |
Thanks @bryanpkc and all the other reviewers for their help in getting this patchset finally merged! |
Add support for aligning the first address of some type with configurable alignment.
The overall idea for this patch set is as follows:
do_sw()
STG_MEMBERS(dt)
to save the pragma alignment value corresponding to the dtypealignment()
andlower_put_datatype()
in flang1read_datatype()
alignment()
in flang2gen_acon_expr()
gen_acon_expr()
Finally, the following effects can be achieved:
I test locally through
make check-flang
, and also pass some custom tests and add them to the test folder in patch.Please correct me if I am wrong, and I am looking forward to feedback for this patch set.