Implementing custom risc-v extensions

In risc-v world, it is common that cores implement vendor-specific custom instructions (or CSRs, or other tweaks to the basic architecture).

Is it possible for end-users to extend ida’s existing risc-v support such that the decompiler is also aware of the new instructions?

Specifically I’m currently interested in andes v5 extensions, however this is a general question as the functionality would be better to have as end-user implementable, since there are a huge number of possible extensions/configurations, and it grows rapidly.

I used to be more active ida user - afaik this functionality does not exist. however maybe that changed recently-ish?

Hi @shawn,

The good news is that we have a way to do that. The decompiler SDK includes a filter microcode_filter_t, which allows you to teach the decompiler unsupported instructions of an otherwise supported architecture.

As a great real-world example, you may take a look at this project made by the CTF team: GitHub - 0rganizers/nmips: nanoMIPS IDA plugin
which extended our MIPS decompiler to nanoMIPS back when we didn’t support it natively.

Hope it helps with your implementation!

1 Like