Remove trapif and trapff (#5162)
This branch removes the trapif and trapff instructions, in favor of using an explicit comparison and trapnz. This moves us closer to removing iflags and fflags, but introduces the need to implement instructions like iadd_cout in the x64 and aarch64 backends.
This commit is contained in:
@@ -3851,27 +3851,9 @@
|
||||
(rule (lower (debugtrap))
|
||||
(side_effect (debugtrap_impl)))
|
||||
|
||||
;;;; Rules for `uadd_overflow_trap` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;;;; Rules for `trapif` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; Similarly to `selectif_spectre_guard`, we only recognize specific patterns
|
||||
;; generated by common code here. Others will fail to lower.
|
||||
|
||||
;; Recognize the case of `ifcmp` feeding into `trapif`. Directly generate
|
||||
;; the desired comparison here; there is no separate `ifcmp` lowering.
|
||||
|
||||
(rule (lower (trapif int_cc (ifcmp x y) trap_code))
|
||||
(side_effect (trap_if_bool (icmp_val $false int_cc x y) trap_code)))
|
||||
|
||||
;; Recognize the case of `iadd_ifcout` feeding into `trapif`. Note that
|
||||
;; in the case, the `iadd_ifcout` is generated by a separate lowering
|
||||
;; (in order to properly handle the register output of that instruction.)
|
||||
;;
|
||||
;; The flags must not have been clobbered by any other instruction between the
|
||||
;; iadd_ifcout and this instruction, as verified by the CLIF validator; so we
|
||||
;; can simply rely on the condition code here.
|
||||
;;
|
||||
;; IaddIfcout is implemented via a ADD LOGICAL instruction, which sets the
|
||||
;; UaddOverflowTrap is implemented via a ADD LOGICAL instruction, which sets the
|
||||
;; the condition code as follows:
|
||||
;; 0 Result zero; no carry
|
||||
;; 1 Result not zero; no carry
|
||||
@@ -3885,14 +3867,6 @@
|
||||
;; remap the IntCC::UnsignedGreaterThan value that we have here as result
|
||||
;; of the unsigned_add_overflow_condition call to the correct mask.
|
||||
|
||||
(rule (lower (trapif (IntCC.UnsignedGreaterThan)
|
||||
flags @ (iadd_ifcout _ _) trap_code))
|
||||
(side_effect
|
||||
(trap_if_bool (bool (flags_to_producesflags flags) (mask_as_cond 3))
|
||||
trap_code)))
|
||||
|
||||
;;;; Rules for `uadd_overflow_trap` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule 0 (lower (has_type (fits_in_64 ty) (uadd_overflow_trap x y tc)))
|
||||
(with_flags
|
||||
(add_logical_reg_with_flags_paired ty x y)
|
||||
|
||||
@@ -176,7 +176,6 @@ impl LowerBackend for S390xBackend {
|
||||
| Opcode::Trapz
|
||||
| Opcode::Trapnz
|
||||
| Opcode::ResumableTrapnz
|
||||
| Opcode::Trapif
|
||||
| Opcode::Debugtrap
|
||||
| Opcode::Call
|
||||
| Opcode::CallIndirect
|
||||
@@ -222,7 +221,7 @@ impl LowerBackend for S390xBackend {
|
||||
Opcode::GlobalValue => {
|
||||
panic!("global_value should have been removed by legalization!");
|
||||
}
|
||||
Opcode::Ifcmp | Opcode::Ffcmp | Opcode::Trapff => {
|
||||
Opcode::Ifcmp | Opcode::Ffcmp => {
|
||||
panic!("Flags opcode should not be encountered.");
|
||||
}
|
||||
Opcode::Jump | Opcode::Brz | Opcode::Brnz | Opcode::BrTable => {
|
||||
|
||||
Reference in New Issue
Block a user