Assert that we only use virtual registers with moves (#5440)
Assert that we never see real registers as arguments to move instructions in VCodeBuilder::collect_operands. Also fix a bug in the riscv64 backend that was discovered by these assertions: the lowerings of get_stack_pointer and get_frame_pointer were using physical registers 8 and 2 directly. The solution was similar to other backends: add a move instruction specifically for moving out of physical registers, whose source operand is opaque to regalloc2.
This commit is contained in:
@@ -148,6 +148,13 @@
|
||||
(rm Reg)
|
||||
(ty Type))
|
||||
|
||||
;; A MOV instruction, but where the source register is a non-allocatable
|
||||
;; PReg. It's important that the register be non-allocatable, as regalloc2
|
||||
;; will not see it as used.
|
||||
(MovFromPReg
|
||||
(rd WritableReg)
|
||||
(rm PReg))
|
||||
|
||||
(Fence
|
||||
(pred FenceReq)
|
||||
(succ FenceReq))
|
||||
@@ -1958,9 +1965,6 @@
|
||||
(lower_branch (br_table index _ _) targets)
|
||||
(lower_br_table index targets))
|
||||
|
||||
(decl x_reg (u8) Reg)
|
||||
(extern constructor x_reg x_reg)
|
||||
|
||||
(decl load_ra () Reg)
|
||||
(extern constructor load_ra load_ra)
|
||||
|
||||
@@ -2142,3 +2146,20 @@
|
||||
(lower_bmask $I128 $I128 val)
|
||||
(let ((res ValueRegs (lower_bmask $I64 $I128 val)))
|
||||
(value_regs (value_regs_get res 0) (value_regs_get res 0))))
|
||||
|
||||
|
||||
;;;; Helpers for physical registers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(decl gen_mov_from_preg (PReg) Reg)
|
||||
|
||||
(rule
|
||||
(gen_mov_from_preg rm)
|
||||
(let ((rd WritableReg (temp_writable_reg $I64))
|
||||
(_ Unit (emit (MInst.MovFromPReg rd rm))))
|
||||
rd))
|
||||
|
||||
(decl fp_reg () PReg)
|
||||
(extern constructor fp_reg fp_reg)
|
||||
|
||||
(decl sp_reg () PReg)
|
||||
(extern constructor sp_reg sp_reg)
|
||||
|
||||
Reference in New Issue
Block a user