mortbopet / Ripes

A graphical processor simulator and assembly editor for the RISC-V ISA

Home Page:https://ripes.me/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make ISA definitions compile-time defined.

mortbopet opened this issue · comments

From #303:

Currrently, instructions are defined dynamically (e.g. https://github.com/mortbopet/Ripes/blob/master/src/assembler/rv_c_ext.h#L319C11-L323), meaning that all information that we specify when defining an instruction must lookup some runtime object to acquire the values of interest (opcode bitfields etc..). However, from the point of view of writing e.g. the RISC-V decoder model, we only need static information - hence there would be quite a bit of overhead in performing a bunch of dynamic, runtime lookups. As such, solving this issue should also consider whether there is a way to make instruction information (specifically bitfields) available at compile time.

So as suggested above, it could be neat if we would have a way to statically define an instruction set, rather than the current dynamic, runtime-defined method.

Some prototyping work to show the feasability: https://godbolt.org/z/zjhr9nTfq

Cool things that such a compile-time defined approach would allow for:

  • Deduplicating information and increasing performance - we can, at compile time, lookup any field of any instruction and perform computations with said fields
  • Compile-time check that instructions are sanely defined
    • e.g. all bit fields must be accounted for
    • and there must be no bit-fields that overlap