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
'H'-extension ordering #837
Comments
|
binutils, GCC and LLVM are all treat As a RISC-V GCC maintainer, I really hope this could be fixed in spec soon. |
|
Thanks @a4lg for the detailed analysis. Can you send a patch for the unpriv spec naming section (chapter 28) as well ? |
|
We'll discuss it at the next architecture review meeting. |
|
@atishp04 Give me two days. |
|
Sorry, I’m not willing to establish the precedent of giving a timeline for this kind of AR. We’ll do our best to be prompt. |
|
@aswaterman It's alright. I just wanted to know whether we have some time to discuss based on "proof-of-concept" changes. |
|
Draft Changes: #839 |
|
This is temporarily resolved via db7a4a0, but the ordering aspect will soon be made moot; see #831 (comment) |
Based on current consensus made in: <riscv/riscv-isa-manual#837>, this commit changes the canonical order of 'H'. Of course, making --isa string more permissive can be a solution to possible incompatibility caused by this.
Related to: #781
My Proposal
Update extension category list:
(assuming #831 is applied)
This is incompatible with Spike but required changes to the software ecosystem will be minimal.
IMPORTANT
This is about making consensus for software adoption.
Halready)So we can close this issue once consensus is made (not when documentation is changed).
Background
There is a ongoing work on QEMU to generate long ISA string (for DeviceTree) from enabled extensions.
The problem is, this includes following extensions:
H(Hypervisor extension)Zhinx(IEEE754 binary16 arithmetic in GPR)Zhinxmin(IEEE754 binary16 arithmetic in GPR; conversion only)Because extension category order of
His not yet determined, we cannot make sure that generated ISA string is valid on long-term.Some other software (including Spike, Linux and LLVM) also began using
Has hypervisor extension and/orZhinx*as IEEE754 binary16 support extensions and some ordering is incompatible with another.I request to define category order of
Hin the extension category list (version 20191213:IMAFDQLCBJTPVN, latest draft:IMAFDQLCBKJTPV) to minimize confusion (as fast as possible; even before official documentation changes) and enable preliminary support for hypervisor extension.Software List and Compatibility Issues So Far
Ordering Table
Z*extensions)Kmust be fixed (out of scope from this issue)His missingNis removed (but is it okay? >#831),His missingN(#831), addHhere forcompatibility with Linux/QEMU/LLVM
Software 1: Spike (PARSER / GENERATOR)
Spike parses ISA string given by
--isacommand line argument. The parser is relatively strict on single-letter extensions (not that strict on multi-letter ones). It also expandsGtoIMAFDso it's also a generator.Source:
riscv/isa_parser.cc(on master)Note that this is incompatible with Linux and QEMU.
Software 2: Linux (PARSER / GENERATOR)
Version (PARSER): 4.15 or later (parser is changed multiple times)
Version (GENERATOR): 5.18 or later (before 5.18, it printed DeviceTree entry as-is)
Scope (GENERATOR): Output of
/proc/cpuinfoThe ISA string parser is very permissive, accepting ISA strings with invalid order. So, the effect of changing the rule is minimal, unless user-mode software tries to parse ISA string given by the kernel strictly.
ISA string generator is used on 5.18 or later to print support ISA and extensions from feature bitmap (before 5.18, original DeviceTree value is directly printed out).
Source:
arch/riscv/kernel/cpu.c(on master)This is used by the GENERATOR to generate ISA string when printing
/proc/cpuinfo.This is incompatible with Spike but mostly compatible with QEMU (except
Kbut it's harmless becauseKwill not be a single extension).Software 3: QEMU (GENERATOR)
QEMU generates ISA string from enabled extensions (specified by QEMU-style extension-enabling options). So, it's a generator.
Version: Past (possibly before 7.1)
Source:
target/riscv/cpu.c(on master)ISA string is generated from this variable and target
misaCSR. It has a few problems as follows:CandLhave wrong order (harmless sinceLis actually never supported)KandJhave wrong order (harmless since bothJandKare not going to be a single extension)This is incompatible with Spike but mostly compatible with Linux (except
Kbut it's harmless becauseKwill not be a single extension).Version: Future (possibly 7.1 or later)
Version: merged to QEMU RISC-V branch for the next version (possibly 7.1 release or later)
On this branch, it supports adding multi-letter extensions to the ISA string (stored as a part of DeviceTree).
Source:
target/riscv/cpu.c(onriscv-to-apply.nextbranch)ISA string (short portion) is generated from this variable and target
misaCSR.This is chosen for compatibility with past QEMU (
riscv_single_letter_extsis a strict subset ofriscv_extsbefore, preserving order).Source:
target/riscv/cpu.c(onriscv-to-apply.nextbranch)This array is used to generate long portion of the ISA string by enabled extensions and must be sorted by canonical order.
Note that, despite that
His afterD,ZhinxandZhinxminare placed beforeZdinx. This is not good and I'll fix or removeZhinx*tentatively (independently to this discussion).This is incompatible with Spike but compatible with Linux (except
Zhinx*).Software 4: GNU Binutils (not implemented yet; PARSER / GENERATOR)
Not implemented yet (but requires handling once
Hextension is introduced). The parser is relatively strict.It also need to emit RISC-V attributes (containing required ISA and extensions) so it's not only a parser but a generator.
Source:
bfd/elfxx-riscv.c(on master)His not included yet. Note thatJandKhave wrong order and I already sent a patch to fix it.Software 5: GNU Compiler Collection (not implemented yet; PARSER / GENERATOR)
Not implemented yet (but requires handling once
Hextension is introduced). The parser is relatively strict.It can also emit RISC-V attributes (containing required ISA and extensions) so it's not only a parser but a generator.
Source:
gcc/common/config/riscv/riscv-common.cc(on master)His not included yet. Note thatJandKhave wrong order and I will send a patch to fix it.Software 6: LLVM (not implemented yet; PARSER / GENERATOR)
Not implemented yet (but requires handling once
Hextension is introduced). The parser is relatively strict.It also need to emit RISC-V attributes (containing required ISA and extensions) so it's not only a parser but a generator.
Source:
llvm/lib/Support/RISCVISAInfo.cpp(on main)His not included yet. Maybe I should addKto the list, though.The most notable thing in LLVM is, it already supports both
Zk*andZhinx*extensions. LLVM handles all single-letters not listed inAllStdExts(exceptiande) are ordered by its alphabetical order, after all supported single-letter extensions (listed inAllStdExts). This rule takes effect onZ*extensions.That means, current LLVM effectively has extension order
mafdqlcbjtpvnhk. If we moveK(by addingktoAllStdExts),His located at the end (making almost compatible with others).The text was updated successfully, but these errors were encountered: