Implement decoder for compressed RISC-V instructions
pavelkryukov opened this issue · 5 comments
RISC-V ISA specifies 'C' (compressed) subset of 16-bit encoded instructions: https://content.riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf, chapter 12.
Your goal is extended RISCV_Instr_Decoder class to support the compressed instructions, and add these instructions to our RISCV ISA table:
- C.LWSP
- C.LDSP
- C.LQSP
- C.SWSP
- C.SDSP
- C.SQSP
- C.LW
- C.LD
- C.LQ
- C.J
- C.JAL
- C.JR
- C.JALR
- C.BEQZ
- C.BNEZ
- C.LI
- C.LUI
- C.ADDI
- C.ADDIW
- C.ADDI16SP
- C.ADDI4SPN
- C.SLLI
- C.SRLI
- C.SRAI
- C.ANDI
- C.MV
- C.ADD
- C.AND
- C.OR
- C.XOR
- C.SUB
- C.ADDW
- C.SUBW
- C.EBREAK
I tried to add some code. Could you please tell me if I am in the right way or not?
I propose to start with unit tests first.
We have some tests for RISC-V decoder here:
mipt-mips/simulator/risc_v/t/unit_test.cpp
Lines 11 to 22 in 3357feb
You can write new tests by your own, following the ISA paper, or you can use these from LLVM: https://github.com/llvm/llvm-project/blob/master/llvm/test/MC/RISCV/rv32c-valid.s
I have implemented C_LWSP, C_SW, C_LW instructions on my 'Compressed-ISA' github branch. Could you please have a look at it?
Please open a pull request to initialize code review tool