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:
@@ -48,6 +48,13 @@
|
||||
(lower (has_type (fits_in_64 ty) (iadd_ifcout x y)))
|
||||
(output_ifcout (alu_add x y)))
|
||||
|
||||
;;; Rules for `uadd_overflow_trap` ;;;;;;;;;;;;;
|
||||
(rule
|
||||
(lower (has_type (fits_in_64 ty) (uadd_overflow_trap x y tc)))
|
||||
(let ((res ValueRegs (lower_uadd_overflow x y ty))
|
||||
(_ InstOutput (gen_trapif (value_regs_get res 1) tc)))
|
||||
(value_regs_get res 0)))
|
||||
|
||||
|
||||
;;;; Rules for `isub` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Base case, simply subtracting things in registers.
|
||||
@@ -853,8 +860,8 @@
|
||||
(rule
|
||||
(lower (trapif _ (iadd_ifcout a @ (value_type ty) b) trap_code))
|
||||
(let
|
||||
((test Reg (lower_uadd_overflow a b ty)))
|
||||
(gen_trapif test trap_code)))
|
||||
((res ValueRegs (lower_uadd_overflow a b ty)))
|
||||
(gen_trapif (value_regs_get res 1) trap_code)))
|
||||
|
||||
|
||||
;;;;; Rules for `trapff`;;;;;;;;;
|
||||
|
||||
Reference in New Issue
Block a user