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