Search code examples
qemuriscvinstruction-encoding

What's the difference between the '-' and '.' in the decode of RISCV instructions in QEMU?


The instructions of RISCV are decoded into 32 bits. When some part of the decoded instruction is required from the input, dot '.' is used to server as the placeholder for each bit. However, there're are some instructions that contain '-' in their decoded versions. So what does the '-' actually mean?

Take the following instruciton as an example: vlxei8_v ... 0-1 . ..... ..... 000 ..... 0000111 @r_nfvm, counting from left to right, the fifth bit is '-', what does this mean?


Solution

  • The decodetree file format is documented in the developer-information section of QEMU's documentation: https://www.qemu.org/docs/master/devel/decodetree.html

    That says:

    The difference between ‘.’ and ‘-’ is that ‘.’ means that the bit will be covered with a field or a final 0 or 1 from the pattern, and ‘-’ means that the bit is really ignored by the cpu and will not be specified.

    Basically the codegenerator will complain if you mark a bit as '.' and then don't use it (by either specifying elsewhere that it is always 0 or 1 or by specifying that it is part of a named field). '-' exists for the occasional case where the value of the bit truly does not matter.

    For any specific case, if you wanted to know exactly why that bit was "doesn't matter" you'd need to look at the architecture specification: sometimes this is because architecturally it is "doesn't matter", and sometimes because the architectural meaning is irrelevant to QEMU's implementation.