-
Notifications
You must be signed in to change notification settings - Fork 647
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
Is Zmmul a subset of M? #869
Comments
It's not quite a proper subset because of Quoting myself:
But the toolchain probably doesn't care about that. |
Moreover, RISC-V doesn't have the concept of "subset" as a special type of extension. There are just base ISAs and extensions, and extensions might happen to overlap, as they do in this case. The sentence you quoted is using the word "subset" in the standard English sense; it's not implicitly defining a special kind of extension. If people are finding it confusing, we can rephrase it to avoid the word "subset", but I think informal use of the word "subset" is going to crop up again as more overlapping extensions are defined over time. |
As a separate matter, it is the case that RV32IM_Zmmul is a legal ISA string (and it is equivalent to RV32IM, modulo the detail Scott mentioned that probably isn't important in the this context). It would then seem to follow logically that |
I guess I more care about what is the canonical form of -march=rv64im_zmmul and -march=rv64im, toolchain need that to manage multi-lib, that might not super important from the ISA spec view, but I really want preventing from define toolchain's own canonical form to resolve this issue or make bunch of special rule in toolchain. Having a complete canonical rule for those stuffs would be easier I think. |
If I'm understanding this correctly, for systems with writable and implemented misa:
|
RV64IM is canonical even though both are legal. No one wants to write Zmmul just for redundancy... (Canonical for the purposes of privilege-agnostic software, I mean, since the |
I suppose that's correct, with the subtle qualifier that "writable and implemented misa" does not necessarily imply that every bit of misa is modifiable, e.g. an rv32im system might have misa.M hardwired to 1 even when other bits are writable. But does the toolchain really care about what bits of misa are writable, and/or what features those bits control? If I tell the compiler to target rv32im then it should assume that mul/div are both valid. If I'm planning to run on a system where I've written misa.M to 0, then I should compile with rv32i, not rv32im. |
No, it’s a distraction. If you tell the toolchain you have M, you better have M enabled, and at that point M_Zmmul == M. |
Whether misa.M is writable is a separate M-mode option that should not affect software, and certainly not <M-mode software. |
I don't think anyone was planning on having compiler flags for the presence of CSR bits (aside from those that filter in via ISA extensions), the real goal here was to figure out if Zmmul was implied by M. It sounds like the answer to that is no, at least in the general case, as there's this difference in behavior between the two related to misa.M. I agree that behavior doesn't have any impact on code generation, but it does impact things like what built-in defines get provided, how we merge the ISA string attributes, multilib paths, simulators, etc. |
Zmmul is implied by M - it is a proper subset of the instructions in M. Here the ISA string is being used to tell the compiler what instructions the compiler can use. I really don't think you want to encode possible ISA-related EE differences beyond what the instructions do. The dependence is the other way around - the binary tells the EE what instructions it uses, and the EE has to be set up to support that. As for #defines/paths etc. - what software is going to want to do different things based on whether misa.M is writable? |
Sorry, now I'm confused again. You're saying '"Zmmul is implied by M", but Scott's saying in #869 (comment) that there's a behavioral difference between |
That behavior difference is not anything that the toolchain would care about. We're telling the toolchain what instructions are available -- not what instructions might possibly be dynamically disabled. In this context, it's fair to say that Zmmul is implied by M. |
Note that if you implement an RV32IM, and misa.M is read/write, and you
set misa.M to 0
- that doesn't necessarily mean that a MUL instruction won't multiple two
source registers and put it into a destination register.
It might trap, it might multiply, it might do something custom (e.g. a
custom scaled multiply)?
Zmmul doesn't have that subtlety; if it is present, then executing a MUL op
better perform the multiply.
The case with a RV32IM_Zmmul with misa.m begin RW does effectively allow
the Divide instructions to be... undefined.
It would be pretty weird to do that and not have those opcodes do something
custom in that case, but it is totally implementation dependent.
…On Thu, Jul 14, 2022 at 4:38 PM Scott Johnson ***@***.***> wrote:
That behavior difference is not anything that the toolchain would care
about. We're telling the toolchain what instructions are available -- not
what instructions might possibly be dynamically disabled.
In this context, it's fair to say that Zmmul is implied by M.
—
Reply to this email directly, view it on GitHub
<#869 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHPXVJXVYOSISVVBNOKRKCDVUCQHPANCNFSM53SX5OTQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
And I would not say that Zmmul is implied by M; I would say that Zmmul ops
are implied by M to be a bit more precise.
And pedantic, which is my new middle name.
On Fri, Jul 15, 2022 at 7:45 AM Allen Baum ***@***.***>
wrote:
… Note that if you implement an RV32IM, and misa.M is read/write, and you
set misa.M to 0
- that doesn't necessarily mean that a MUL instruction won't multiple two
source registers and put it into a destination register.
It might trap, it might multiply, it might do something custom (e.g. a
custom scaled multiply)?
Zmmul doesn't have that subtlety; if it is present, then executing a MUL
op better perform the multiply.
The case with a RV32IM_Zmmul with misa.m begin RW does effectively allow
the Divide instructions to be... undefined.
It would be pretty weird to do that and not have those opcodes do
something custom in that case, but it is totally implementation dependent.
On Thu, Jul 14, 2022 at 4:38 PM Scott Johnson ***@***.***>
wrote:
> That behavior difference is not anything that the toolchain would care
> about. We're telling the toolchain what instructions are available -- not
> what instructions might possibly be dynamically disabled.
>
> In this context, it's fair to say that Zmmul is implied by M.
>
> —
> Reply to this email directly, view it on GitHub
> <#869 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AHPXVJXVYOSISVVBNOKRKCDVUCQHPANCNFSM53SX5OTQ>
> .
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
>
|
Zmmul unprivileged ISA string should not imply anything about privileged support for disabling/enabling features. |
We got to talking about how Zmmul and M interact with each other riscv/riscv-isa-manual#869 , and it turns out that QEMU's behavior is slightly wrong: having Zmmul and M is a legal combination, it just means that the multiplication instructions are supported even when M is disabled at runtime via misa. This just stops overriding M from Zmmul, with that the other checks for the multiplication instructions work as per the ISA. Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20220714180033.22385-1-palmer@rivosinc.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
We got to talking about how Zmmul and M interact with each other riscv/riscv-isa-manual#869 , and it turns out that QEMU's behavior is slightly wrong: having Zmmul and M is a legal combination, it just means that the multiplication instructions are supported even when M is disabled at runtime via misa. This just stops overriding M from Zmmul, with that the other checks for the multiplication instructions work as per the ISA. Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20220714180033.22385-1-palmer@rivosinc.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
We got to talking about how Zmmul and M interact with each other riscv/riscv-isa-manual#869 , and it turns out that QEMU's behavior is slightly wrong: having Zmmul and M is a legal combination, it just means that the multiplication instructions are supported even when M is disabled at runtime via misa. This just stops overriding M from Zmmul, with that the other checks for the multiplication instructions work as per the ISA. Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20220714180033.22385-1-palmer@rivosinc.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
We got to talking about how Zmmul and M interact with each other riscv/riscv-isa-manual#869 , and it turns out that QEMU's behavior is slightly wrong: having Zmmul and M is a legal combination, it just means that the multiplication instructions are supported even when M is disabled at runtime via misa. This just stops overriding M from Zmmul, with that the other checks for the multiplication instructions work as per the ISA. Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20220714180033.22385-1-palmer@rivosinc.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This came up during the GNU tools meeting earlier today, we couldn't quite figure out how M and Zmmul are related to each other. It's not entirely clear whether Zmmul is a subset of the M extension, or a different extension that implements a subset of the functionality of the M extension. The wording is slightly different here, "The Zmmul extension implements the multiplication subset of the M extension." vs "he Zfhmin extension is a subset of the Zfh extension, ...". I'm not sure if those different wordings are meant to imply a different relationship between the extensions.
It seems like folks are leaning towards Zmmul being a subset of M, which means
-march=rv32im
will define__riscv_zmmul
and-march=rv32imzmmul
will be legal. That seems fine to me, just wanted to check it's what the spec is trying to say.The text was updated successfully, but these errors were encountered: