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:
@@ -2772,6 +2772,14 @@
|
||||
)
|
||||
x))
|
||||
|
||||
;; Check for unsigned overflow.
|
||||
(decl trap_if_overflow (ProducesFlags TrapCode) Reg)
|
||||
(rule (trap_if_overflow producer tc)
|
||||
(with_flags_reg
|
||||
producer
|
||||
(ConsumesFlags.ConsumesFlagsSideEffect
|
||||
(MInst.TrapIf (cond_br_cond (Cond.Hs)) tc))))
|
||||
|
||||
(decl sink_atomic_load (Inst) Reg)
|
||||
(rule (sink_atomic_load x @ (atomic_load _ addr))
|
||||
(let ((_ Unit (sink_inst x)))
|
||||
|
||||
@@ -2373,6 +2373,11 @@
|
||||
(add_with_flags ty a b)
|
||||
(invalid_reg)))
|
||||
|
||||
;;; Rules for `uadd_overflow_trap` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower (has_type (fits_in_64 ty) (uadd_overflow_trap a b tc)))
|
||||
(trap_if_overflow (add_with_flags_paired ty a b) tc))
|
||||
|
||||
;;; Rules for `tls_value` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower (tls_value (symbol_value_data name _ _)))
|
||||
|
||||
@@ -257,6 +257,8 @@ pub(crate) fn lower_insn_to_regs(
|
||||
|
||||
Opcode::IaddIfcout => implemented_in_isle(ctx),
|
||||
|
||||
Opcode::UaddOverflowTrap => implemented_in_isle(ctx),
|
||||
|
||||
Opcode::IaddImm
|
||||
| Opcode::ImulImm
|
||||
| Opcode::UdivImm
|
||||
|
||||
Reference in New Issue
Block a user