Improve RISC-V pseudo-instructions #137
Replies: 11 comments
-
There is a field for adding pseudo instructions to an instruction definition. For example, in riscv-unified-db/arch/inst/B/add.uw.yaml Lines 25 to 27 in 1ad462f It's not super thought-out, though, and could probably use some tweaking. Getting some more examples of pseudo instructions we want to define would help. |
Beta Was this translation helpful? Give feedback.
-
Maybe we can get a full list from someone with experience with the RISC-V toolchains (like Ana)? |
Beta Was this translation helpful? Give feedback.
-
Here's an interesting case: RDCYCLE is a pseudo instruction defined by Zicntr, but it's an alias of A few possibilities:
I'm inclined to prefer 1. since it matches what we're doing for CSRs/CSR fields, but that's not a strong preference. |
Beta Was this translation helpful? Give feedback.
-
Either solution looks good to me. |
Beta Was this translation helpful? Give feedback.
-
Please correct me if I misunderstood all of this, but doesn't this mean that the riscv-opcodes is so far wrong in defining this pseudo-instruction(and many more from what I have checked)? Since the instruction is defined as
inside the rv_zicsr file. It seems even a bit more tricky than this since there isn't even a rv_zicntr file, while the spec definitely has them as two different extensions: |
Beta Was this translation helpful? Give feedback.
-
Yes, I believe riscv-opcodes is incorrect in this case. In general, I've found that there is quite a bit related to Zicsr/Zicntr/Zihpm that is not correct in the spec/riscv-opcodes, etc. Presumably, this is because those extensions were bolted on as an afterthought; originally, everything was defined in the base architecture. |
Beta Was this translation helpful? Give feedback.
-
Maybe I am missing something obvious, but it seems like another wrinkle with the current format is that it's not clear what to do with pseudoinstructions that correspond to a sequence of two real instructions. For example, Perhaps this is an argument for pseudoinstructions getting their own, independent files? |
Beta Was this translation helpful? Give feedback.
-
@sampsyo On top of that , Maybe there is no need for that and back-ends could do that if pseudoinstructions mention those parameters, but @dhower-qc or @james-ball-qualcomm should have a better understanding of whether or not that's possible. Those parameters could be: pseudoinstruction: Obviously my naming is awful :) , but I think the point remains. |
Beta Was this translation helpful? Give feedback.
-
This is also complicated by the fact that some multi-instruction pseduo-instructions don't have a single mapping (e.g., To sum up complications we've uncovered so far:
Given this list, I agree with @sampsyo -- we should start to specify pseudo-instructions in their own file. The question now is how to structure it to capture these complications. |
Beta Was this translation helpful? Give feedback.
-
Maybe a simple way would be to use the same logic we're using now, but to specify 'original_instructions:' in pseudo-instructions files. |
Beta Was this translation helpful? Give feedback.
-
As discussed on last meeting, this is the format for pseudoinstruction I got:
I already have all the pseudo-instructions from riscv-opcodes ready, so if you guys agree wih this, I can PR anytime |
Beta Was this translation helpful? Give feedback.
-
Can we add defined pseudo-instructions to riscv-unified-db?
Here's a port of a post by Ved (link):
"ARC discussed a question about the location of pseudo- instructions with respect to the ISA manual and concluded that a list of pseudo-instructions should be included in the ISA manual. A PR is planned."
Beta Was this translation helpful? Give feedback.
All reactions