Skip to content

How to add a custom non-standard instruction type format #795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MauSilvestrini opened this issue Dec 4, 2020 · 5 comments
Closed

How to add a custom non-standard instruction type format #795

MauSilvestrini opened this issue Dec 4, 2020 · 5 comments

Comments

@MauSilvestrini
Copy link

Good morning to everyone, I want to add a custom non-standard instruction that should have the following type format:

image

This field format is not new for the RISC-V ISA, it resembles the R4-type format that is used for the encoding of some instructions in the standard extension RV32F for single precision floating point calculation. In that specific case the rs3 source register field has been replaced with the destination register called RD1, in which I want to write something.

I already find out how to encode this new instruction extension, but I’d like to know, as far as possible, the procedure on how to add this new instruction type format to the current RISCV toolchain ISA, in particular which files I have to modify in order to write a piece of code that allows to write onto the RD1 field.

Many thanks for your help.

@jim-wilson
Copy link
Collaborator

Binutils doesn't use instruction formats, except for the .insn pseudo op. If you want .insn support for your new instruction you might need to change that if the existing r4 instruction format support doesn't work.

Otherwise, instruction formats are irrrelevant, and all that matters are the MASK/MATCH bit masks, and the 'd' 's' 't' etc letters to specify operands. But if your format is close enough to r4 then you probably don't need a new operand letter.

@Nelson1225
Copy link

FYI, I suppose all instructions can be derived from the existing instruction formats, although some of them might look weird.

@Nelson1225
Copy link

This should help, riscvarchive/riscv-binutils-gdb#184

@MauSilvestrini
Copy link
Author

Binutils doesn't use instruction formats, except for the .insn pseudo op. If you want .insn support for your new instruction you might need to change that if the existing r4 instruction format support doesn't work.

Otherwise, instruction formats are irrrelevant, and all that matters are the MASK/MATCH bit masks, and the 'd' 's' 't' etc letters to specify operands. But if your format is close enough to r4 then you probably don't need a new operand letter.

Many thanks for your help Mr Wilson, with this I fixed the problem releted to the riscv-toolchain. Best Regards.

@TommyMurphyTM1234
Copy link
Collaborator

This is a list of all issues logged that I can find that relate to adding new instructions to the toolchain:

At this stage in the evolution of RISC-V,the majority of instruction addition will be done under the auspices of the relevant groups working on standardising, prototyping, and implementing/enhancing RISC-V extensions and their corresponding instructions. As such, there should be less of a demand for others to do so.

However, where somebody still wants to implement a non stadard custom extension/instruction here are some useful resources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants