Dear all,
GNU binutils defines a de facto standard unimplemented instruction, unimp. The binary form of that instruction depends on whether compressed instructions are enabled or not (e.g., directly by using .option norvc, or indirectly by setting the -march switch). Here's the current support matrix:
unimp | .option norvc | c0001073
unimp | .option rvc | 0000
c.unimp | .option norvc | error
c.unimp | .option rvc | error
A few comments:
1) Since all compressed instructions are in the form c.op, I believe it would make sense to support an explicit c.unimp.
2) One advantage of the current unimp design is that it's possible to distinguish between 16-bit and 32-bit unimp forms. A few other design would be possible, but that's probably something that we would want to preserve. If that were unimportant, we could simply use 0000_0000 as a 32-bit unimp, which also has its advantages.
3) The ISA spec doesn't specify 0000 as a canonical unimplemented instruction, but it does specify it as an invalid instruction. Therefore, if an implementation traps on invalid instructions, then it's guaranteed to trap. So keeping 0000 as a 16-bit unimp seems perfect. It would probably be worth documenting its use as a canonical 16-bit unimp in the spec, though.
4) The ISA spec doesn't have anything to say about the instruction c0001073. This is basically a variant of the ECALL/EBREAK/etc. family of instructions. The RISC-V specs also don't seem to guarantee that an implementation traps on unimplemented instructions. Even ignoring that, theoretically there's no guarantee that c0001073 isn't implemented, since it's not reserved for that purpose. Ideally we would use something like an all ones instruction as a 32-bit unimp, but the ISA spec pretty much rejects that possibility:
"Defining a 32-bit word of all ones as illegal was also considered, as all machines must support a 32-bit instruction size, but this requires the instruction-fetch unit on machines with ILEN>32 report an illegal instruction exception rather than access fault when such an instruction borders a protection boundary, complicating variable-instruction-length fetch and decode."
So, if we really have to reserve a legal instruction pattern for a 32-bit unimplemented instruction, we might as well choose the current c000107. I would just recommend that the ISA spec documents this. Preferably as a something actually determined by the spec, but if that's not possible or agreed upon then, IMO, the spec should at least mention that it's a de facto standard practice.
Assuming we want to keep the current 0000 / c0001073 design, and an explicit c.unimp is accepted, then this would be the result:
unimp | .option norvc | c0001073
unimp | .option rvc | 0000
c.unimp | .option norvc | error
c.unimp | .option rvc | 0000
I have an LLVM patch that adds support for unimp (c0001073) and c.unimp (0000), pending discussion of this issue.
Do you agree on keeping (and documenting) the current unimp design, plus support for an explicit c.unimp?
--
Best,
Luís
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAPhv3np5TOijeWDhYqrBZsH-f-zHAo5EzMDKjNK5ohfYM%2BN5Yw%40mail.gmail.com.
On Thu, 29 Nov 2018 at 12:19, Andrew Waterman
<wate...@eecs.berkeley.edu> wrote:
> On Thu, Nov 29, 2018 at 3:49 AM Luís Marques <luism...@lowrisc.org> wrote:
>> 4) The ISA spec doesn't have anything to say about the instruction c0001073. This is basically a variant of the ECALL/EBREAK/etc. family of instructions. The RISC-V specs also don't seem to guarantee that an implementation traps on unimplemented instructions. Even ignoring that, theoretically there's no guarantee that c0001073 isn't implemented, since it's not reserved for that purpose. Ideally we would use something like an all ones instruction as a 32-bit unimp, but the ISA spec pretty much rejects that possibility:
>
>
> This is the instruction CSRRW x0, cycle, x0. As the specification states, cycle is a read-only CSR; so, whether or not the implementation provides the cycle CSR, this instruction is guaranteed to trap.
Though instructions such as CSRRW are optional in the specification
proposed for ratification. By my understanding that means an
implementation that doesn't provide Zicsr may either:
1) Re-use that encoding space for something else, or
2) Fail to trap on unimplemented instructions
If the implementation fails to trap on unimplemented instructions, then it doesn't matter which opcode we pick for this purpose...
--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAPhv3nquL6k1HOi4C1-vj2wFNvup3xodsKyzNJ%2BYoa7KsarS8Q%40mail.gmail.com.
I think I don't quite understand why 0x00000000 is a bad value for a 32 bit unimp.If C is implemented then it hits c.unimp.If C is not implemented then it's an invalid encoding, which will trap.
regards,
Liviu