Skip to content

Commit

Permalink
cranelift/riscv64: Fix mv instruction pretty-printing (#8494)
Browse files Browse the repository at this point in the history
The operand collector and the instruction emitter for Inst::Mov both
placed the `rm` register before `rd`, so the emitted code was correct,
but the pretty-printer used the opposite order and so printed the
operands backwards. Note that the VCode disassembly disagreed with
Capstone's disassembly of the emitted machine code.
  • Loading branch information
jameysharp committed Apr 27, 2024
1 parent 6232904 commit 1cf3a9d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cranelift/codegen/src/isa/riscv64/inst/mod.rs
Expand Up @@ -1552,8 +1552,8 @@ impl Inst {
format!("virtual_sp_offset_adj {:+}", amount)
}
&MInst::Mov { rd, rm, ty } => {
let rd = format_reg(rd.to_reg(), allocs);
let rm = format_reg(rm, allocs);
let rd = format_reg(rd.to_reg(), allocs);

let op = match ty {
F32 => "fmv.s",
Expand Down
2 changes: 1 addition & 1 deletion cranelift/filetests/filetests/isa/riscv64/reftypes.clif
Expand Up @@ -97,7 +97,7 @@ block3(v7: r64, v8: r64):
; mv a3,a0
; mv s5,a2
; sd a1,16(nominal_sp)
; mv a3,a0
; mv a0,a3
; mv s9,a3
; load_sym a5,%f+0
; sd s9,8(nominal_sp)
Expand Down

0 comments on commit 1cf3a9d

Please sign in to comment.