mortbopet / Ripes

A graphical processor simulator and assembly editor for the RISC-V ISA
https://ripes.me/
MIT License
2.52k stars 270 forks source link

Make ISA definitions compile-time defined. #306

Closed mortbopet closed 10 months ago

mortbopet commented 11 months ago

From https://github.com/mortbopet/Ripes/issues/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:

mortbopet commented 10 months ago

fixed in 2a042c9