mirror of
https://github.com/qemu/qemu.git
synced 2026-02-03 21:29:17 +00:00
[PR #270] Suggestion for an Instruction Mapping between QEMU RVI32/64 Translation and Sail Language #356
Closed
opened 2026-01-31 21:30:55 +00:00 by claunia
·
0 comments
No Branch/Tag Specified
master
staging
staging-10.0
staging-10.1
staging-10.2
stable-10.2
stable-7.2
staging-7.2
stable-10.0
stable-10.1
10.1-testing
tracing
99888-virtio-zero-init-c9s
stable-9.2
staging-9.2
staging-8.2
stable-8.2
stable-9.1
staging-9.1
stable-9.0
staging-9.0
coverity
stable-8.1
staging-8.1
stable-8.0
staging-8.0
block
staging-0.0
staging-mjt-test
stable-7.2-staging
stable-8.0-staging
stsquad-hotfix
stable-6.1
stable-6.0
stable-6.0-staging
stable-5.0
stable-4.2
stable-4.1
stable-4.0
stable-3.1
stable-3.0
stable-2.12
stable-2.11
stable-2.10
stable-2.9
stable-2.8
stable-2.7
stable-2.6
stable-2.5
stable-2.4
stable-2.3
stable-2.2
stable-2.1
stable-2.0
stable-1.7
stable-1.6
stable-1.5
stable-1.4
stable-1.3
stable-1.2
stable-1.1
stable-1.0
stable-0.15
stable-0.14
stable-0.13
stable-0.12
stable-0.11
stable-0.10
v10.2.0
v10.2.0-rc4
v10.2.0-rc3
v7.2.22
v10.0.7
v10.1.3
v10.2.0-rc2
v10.2.0-rc1
v10.0.6
v10.1.2
v7.2.21
v10.1.1
v10.0.5
v7.2.20
v10.0.4
v10.1.0
v10.1.0-rc4
v10.1.0-rc3
v10.1.0-rc2
v10.1.0-rc1
v10.1.0-rc0
v7.2.19
v10.0.3
v10.0.2
v10.0.1
v9.2.4
v7.2.18
v10.0.0
v10.0.0-rc4
v10.0.0-rc3
v10.0.0-rc2
v7.2.17
v8.2.10
v9.2.3
v10.0.0-rc1
v10.0.0-rc0
v9.2.2
v8.2.9
v7.2.16
v9.2.1
v9.1.3
v9.2.0
v9.2.0-rc3
v9.2.0-rc2
v9.1.2
v9.0.4
v8.2.8
v7.2.15
v9.2.0-rc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0.15.1
v0.15.0
v0.15.0-rc2
v0.15.0-rc1
v0.15.0-rc0
v0.14.1
v0.14.0
v0.14.0-rc2
v0.14.0-rc1
v0.14.0-rc0
v0.13.0
v0.13.0-rc3
v0.13.0-rc2
v0.13.0-rc1
v0.13.0-rc0
v0.12.5
v0.12.4
v0.12.3
v0.12.2
v0.12.1
v0.12.0
v0.12.0-rc2
v0.12.0-rc1
v0.12.0-rc0
v0.11.1
v0.11.0
v0.11.0-rc2
v0.11.0-rc1
v0.10.6
v0.11.0-rc0
v0.10.5
v0.10.4
v0.10.3
release_0_10_2
v0.10.2
release_0_10_1
v0.10.1
release_0_10_0
v0.10.0
v0.9.1
release_0_9_1
v0.9.0
release_0_9_0
release_0_8_2
v0.8.2
v0.8.1
release_0_8_1
v0.7.1
release_0_7_1
v0.7.0
release_0_7_0
v0.6.1
release_0_6_1
v0.6.0
release_0_6_0
release_0_5_1
v0.5.1
v0.5.0
v0.4.4
v0.4.3
v0.4.2
v0.4.1
v0.4.0
v0.3.0
v0.2.0
v0.1.6
v0.1.5
v0.1.4
v0.1.3
v0.1.1
v0.1.0
initial
Milestone
No items
No Milestone
Projects
Clear projects
No project
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/qemu#356
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/qemu/qemu/pull/270
State: closed
Merged: No
Project Proposal: Sail to QEMU Target Downstream Task Issue
The goal of this project is to perhaps create a generated RVI-32/64 translation for QEMU, we hope to utilize Sail as the source for conversion.
The following files are involved:
/model/riscv_insts_base.sailLink to file
target/riscv/insn_trans/trans_rvi.c.incLink to file
Below is the following representation/translation in both the files of importance:
Load Upper Immediate instruction
Sail code (
model/riscv_insts_base.sail):QEMU code (target/riscv/insn_trans/trans_rvi.c.inc):
OR, it could come from the JSON, which includes the mnemonic and the Sail function clause execute for the mnemonic.
(DisasContext *ctx, arg_: standard template
lui: mnemonic
*a: standard template
gen_set_gpri(ctx, a->[register], a->[immediate]): map from Sail construct X(register) = immediate pattern
Need to understand conventions for names of structure fields, like rd and imm in both the Sail code and the QEMU code.
Standard Template
A standard template would look like:
And the pattern matching database would include, to start:
Translating from the Sail code
Translating from the Sail code involves just working with the code that specifies actions:
Note that for Load Upper Immediate, only the code associated with RISCV_LUI is executed. This will have to be understood also through parsing the mapping clause assembly and finding that RISCV_LUI is associated exclusively with the lui mnemonic.
In QEMU, this shift and sign extend is done before trans_lui is called, presumably as a normal part of decoding a “U Format” instruction.
So, this line can be ignored in translation from Sail to QEMU.
Add Upper Immediate to PC
Looking to another, similar instruction, Add Upper Immediate to PC, Sail code is above (same as Load Upper Immediate).
QEMU code:
Initial Patch Example
An initial local patch (Link to commit) was created to demonstrate the mapping of the form:
This is another pattern to be added to the translation database:
variable = get_arch_pc() + offsettarget_pc = dest_gpr(ctx, a->rd)gen_pc_plus_diff(target_pc, ctx, a->imm)Where the format of the map is:
Map<String, pair<Sail_Instruction_Representation, QEMU_Instruction_Representation>>
The template is consistent, so only the code needs to be translated.
We were hoping to get suggestions and feedback from the community and maintainers based on this task, using the output of the example files used to create a base mapping.
We hope to create a webpage representing the instruction mappings, that the community itself could refer to. We are in the process of constructing a universal page dedicated to these translations across several downstream projects, so it could be referred to and reviewed by those interested in generation/translation of instruction representation across several projects compared against each other.