pharaun / rspace

The rusty space game, in which you program various ships to do battle in risc-v assembly. This contains the collection of libraries+code for this project.
3 stars 0 forks source link

A possible approach to handle the match table for the risc-v instructionset #4

Open pharaun opened 6 years ago

pharaun commented 6 years ago
  1. Since some instruction have data where func7 and func3 are, we can't just do a single 'mask' we need to identify the type of instruction it is, perform a mask (in the right shape to only allow through ie opcode, func3, and func7 as needed)
  2. a macro that creates a single linear match table, perhaps in a format like such:
    macro!([
    (<func7>, <func3>, <opcode>, function/code for that instruction),
    (0x0, 0x0, LUI, <function>)
    ]);
  3. This should now allow me to have a nice single linear match of u32 against u32, the question i guess is will this be easier to maintain and be faster than ie 3 u32 in a tuple against 3 u32 in a tuple matches, (cos there a small over head (i think) of detecting the instruction type to employ the correct mask.
pharaun commented 6 years ago
  1. Consider, we have the match list that build.rs is already building, should be able to reuse this in the vm, ie we use the macro to pull out the relevant out of the pnf table that is being code generated instead of re-hardcoding these values in a second location.