-
Notifications
You must be signed in to change notification settings - Fork 36
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
Define -march string #26
base: main
Are you sure you want to change the base?
Conversation
@palmer-dabbelt commented the following on the GCC mailing list:
As I wrote in my reply message, I think Also, I don't think a common |
README.mkd
Outdated
* The next part consists of single-letter ISA extensions, which may be in | ||
non-canonical order. | ||
* The next part consists of multi-letter ISA extensions, which may be in | ||
non-canonical order. |
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 would like to relax the order between single-letter
/ multi-letter
ext, see #14
Changes:
2021/08/16: Remove order constraint between single-letter and multi-letter, also add 2 more NOTE.
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.
Will do.
README.mkd
Outdated
* `rv64gc_xtheadba`: Valid `-march` string. | ||
* `rv64gc_Zicsr`: Invalid because of the uppercase character. | ||
* `rv32mai`: Invalid because base ISA does not follow `rv32`. | ||
* `rv32i_zicsr_m`: Invalid because `m` after multi-letter extension. |
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.
So this will become valid.
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.
Will do.
README.mkd
Outdated
|
||
The following interpretation differences exist: | ||
|
||
* The expansion of `g` with versions before `20190609` is `imafd`. |
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.
typo (here and below): 20190609 -> 20190608
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.
Thx!
* `rv32i_zicsrzifencei`: Invalid because multi-letter extensions need to be | ||
separated by an underscore (`zicsr` and `zifencei` are existing individual | ||
extensions). | ||
|
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.
Last specification defines "dependency" notion for extensions. We need to either mention that -march=
respects this convention, or state that -march=
doesn't follow it.
See 29.3 of 20191213: Some ISA extensions depend on the presence of other extensions, e.g., "D" depends on "F" and "F" depends on "Zicsr". These dependences may be implicit in the ISA name: for example, RV32IF is equivalent to RV32IFZicsr, and RV32ID is equivalent to RV32IFD and RV32IFDZicsr.
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.
Thanks for highlighting this.
I think it is expected by users that the march string follows this implicit enablement of extensions.
I will add a sentence to clarify this.
Thank you for the work. Trying to understand how the interpretation works so maybe I can help on the LLVM side. Is there an existing table for interpretation(s) to the ISA? If so this will help me clarify the confusion that I have to both "dates" and "version number" coexists (based on this PR - |
e8d5a82
to
5570a72
Compare
I tried to cover exactly this by the amount of examples included in the PR. Regarding the ISA versions: we will just have to support all existing versioning schemes: so versions are well-ordered, but not lexicographic sortable, strings. |
I've updated the PR according to the provided feedback. |
5570a72
to
82ac13d
Compare
This is essentially a collection of all recent change requests for the -march string: * Relax the ISA string order ([1]) * Add custom extensions ([2]) * Add profiles support ([3]) Most of this patch is based on proposals from Kito Cheng <kito.cheng@gmail.com> (see linked resources below). [1] riscv-non-isa#14 [2] riscv-non-isa#1 [3] https://lists.riscv.org/g/sig-toolchains/message/379 [4] riscv-non-isa#11 Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
82ac13d
to
252f1c3
Compare
Kito mentioned that there should be more details regarding the versioning of extensions. I've added some details about that to the PR. |
We should have -march=isa+ext for completeness (yes, _ works in that case, but then you have to care about whether it’s an ISA or profile as your “base”). We also need -march=+foo so you can add to whatever the default is (whether that’s from a flag in user-provided CFLAGS or the system default when not specified). Maybe also -march=-foo, though that gets a bit weird (but that already needs to work in the assembler due to .option arch, so give it the same semantics). |
I also worry about what happens if a user gives CFLAGS=“-march=isa -misa-spec=…” and a build system then adds -march=profile given you’ve said it’s an error to combine those. |
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 support this effort. But I think it is worth calling out explicitly where it breaks compatibility with the ISA string as defined in Vol. I Ch. 29, since existing software and build systems are following those conventions already for march
. I give two examples below of compatibility breaks. These are just the first two that immediately jumped out at me (I didn't go through the whole PR carefully).
which may be in non-canonical order. | ||
* Single-letter ISA extensions may be separated from other single-letter extensions | ||
by an underscore (`_`). | ||
* Multi-letter ISA extensions must be separated from other extensions |
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.
Vol. I Ch. 29 says:
Extensions with the "Z" prefix must be separated from other multi-letter extensions by an under-
score, e.g., "RV32IMACZicsr_Zifencei".
Note there is no underscore between C
and Zicsr
.
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 properly described what I wanted to express, but I was not aware that -march=rv64imafdczbb
is valid in GCC and clang. I will update this to match the currently implemented behavior to reduce the differences to the ISA strings.
Fun fact: GCC currently accepts -march=rv64imafdczbbzba
and clang does not.
But I don't think that's an issue.
|
||
A valid `-march` string in the ISA-string-based format must follow these rules: | ||
|
||
* All characters of the string must be lowercase. |
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.
Vol. I Ch. 29 says:
The ISA naming strings are case insensitive.
Indeed, the examples given therein use mixed case.
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.
This is listed as the first bullet "All characters of the string must be lowercase".
So I think this is already properly documented.
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 realize now that this is already enforced by existing toolchains, so in this case I was wrong to say that
existing software and build systems are following those conventions already for
march
.
I still think it is worth a remark about incompatibilities with the ISA spec, but such nonnormative text can always be added later.
I do worry that profile strings might be rather cryptic and easily confusable (by humans) with ISA naming strings. If it's agreed this is problematic, it's not clear if it's best handled in the profiles spec or in how the profile names are represented in
|
As mentioned in the profiles ticket, would it be ok, to mention in a note that tools/compilers may impose restrictions about which march string format is accepted (e.g. via prefix or cmdln flag) and that users may look in to the compiler manual for details? So we would just define the formats here and leave some room for further restrictions for tools/compilers (if any). |
I'm not sure if we should define this here (unless enough people want this). The idea is good, but it feels a bit like an added-value feature of a tool/compiler.
Same for this. I would let this behavior be defined by the tool as I fear that different tools prefer different behavior (e.g. accepting the last provided flag vs. throwing an error vs. ./configure flag to define the policy...). I would prefer to restrict the description to a minimum that's usable by a user. Compilers and tools can then derive from here and extend more features. Would this be ok? |
If GCC and LLVM do different things for any of these it will be a pain point, so no, I think they really do need to be documented conventions. Otherwise either nobody will use them or they'll use them and be locked into one compiler for no good reason. |
Following content has send in another private mail thread, but I think it could be also post here: I agree the naming of profile can be improved to prevent the confusion, but actually I am less concern about the confusion on the Consider the following two cases (and use the most confused possible
So based on the above two situations I think that should not be |
In today's Toolchain SIG call, we agreed to split this PR into multiple ones not to mix different issues and to move this forward:
|
This is essentially a collection of all recent change requests for the -march string:
-march
string, as it is not exactly the RISC-V ISA naming string, and highlight the lower-case requirement (https://gcc.gnu.org/pipermail/gcc-patches/2022-November/605249.html)Most of this patch is based on proposals and inputs from Kito and Palmer (see linked resources above).
It might not be perfect, but it could serve as a reasonable initial draft for further discussions.
Comments are welcome!
CC: @palmer-dabbelt @kito-cheng @asb @jrtc27