Add uadd_overflow_trap (#5123)
Add a new instruction uadd_overflow_trap, which is a fused version of iadd_ifcout and trapif. Adding this instruction removes a dependency on the iflags type, and would allow us to move closer to removing it entirely. The instruction is defined for the i32 and i64 types only, and is currently only used in the legalization of heap_addr.
This commit is contained in:
@@ -1352,6 +1352,41 @@
|
||||
(rule (lower (trap code))
|
||||
(side_effect (x64_ud2 code)))
|
||||
|
||||
;;;; Rules for `uadd_overflow_trap` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower (has_type (fits_in_64 ty) (uadd_overflow_trap a b tc)))
|
||||
(with_flags
|
||||
(x64_add_with_flags_paired ty a b)
|
||||
(trap_if (CC.B) tc)))
|
||||
|
||||
;; Add a register and an immediate.
|
||||
|
||||
(rule 1 (lower (has_type (fits_in_64 ty)
|
||||
(uadd_overflow_trap a (simm32_from_value b) tc)))
|
||||
(with_flags
|
||||
(x64_add_with_flags_paired ty a b)
|
||||
(trap_if (CC.B) tc)))
|
||||
|
||||
(rule 2 (lower (has_type (fits_in_64 ty)
|
||||
(uadd_overflow_trap (simm32_from_value a) b tc)))
|
||||
(with_flags
|
||||
(x64_add_with_flags_paired ty b a)
|
||||
(trap_if (CC.B) tc)))
|
||||
|
||||
;; Add a register and memory.
|
||||
|
||||
(rule 3 (lower (has_type (fits_in_64 ty)
|
||||
(uadd_overflow_trap a (sinkable_load b) tc)))
|
||||
(with_flags
|
||||
(x64_add_with_flags_paired ty a (sink_load_to_gpr_mem_imm b))
|
||||
(trap_if (CC.B) tc)))
|
||||
|
||||
(rule 4 (lower (has_type (fits_in_64 ty)
|
||||
(uadd_overflow_trap (sinkable_load a) b tc)))
|
||||
(with_flags
|
||||
(x64_add_with_flags_paired ty b (sink_load_to_gpr_mem_imm a))
|
||||
(trap_if (CC.B) tc)))
|
||||
|
||||
;;;; Rules for `trapif` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; The flags must not have been clobbered by any other instruction between the
|
||||
|
||||
@@ -527,6 +527,7 @@ fn lower_insn_to_regs(
|
||||
| Opcode::IsubIfbout
|
||||
| Opcode::IsubBorrow
|
||||
| Opcode::IsubIfborrow
|
||||
| Opcode::UaddOverflowTrap
|
||||
| Opcode::BandImm
|
||||
| Opcode::BorImm
|
||||
| Opcode::BxorImm
|
||||
|
||||
Reference in New Issue
Block a user