x64: Migrate trapif and trapff to ISLE (#4545)
https://github.com/bytecodealliance/wasmtime/pull/4545
This commit is contained in:
@@ -147,6 +147,10 @@
|
||||
(decl valid_reg () Reg)
|
||||
(extern extractor valid_reg valid_reg)
|
||||
|
||||
;; Mark this value as used, to ensure that it gets lowered.
|
||||
(decl mark_value_used (Value) Unit)
|
||||
(extern constructor mark_value_used mark_value_used)
|
||||
|
||||
;; Put the given value into a register.
|
||||
;;
|
||||
;; Asserts that the value fits into a single register, and doesn't require
|
||||
@@ -563,6 +567,11 @@
|
||||
;; Variant determines how result is given when combined with a
|
||||
;; ConsumesFlags. See `with_flags` below for more.
|
||||
(type ProducesFlags (enum
|
||||
;; For cases where the flags have been produced by another
|
||||
;; instruction, and we have out-of-band reasons to know
|
||||
;; that they won't be clobbered by the time we depend on
|
||||
;; them.
|
||||
(AlreadyExistingFlags)
|
||||
(ProducesFlagsSideEffect (inst MInst))
|
||||
;; Not directly combinable with a ConsumesFlags;
|
||||
;; used in s390x and unwrapped directly by `trapif`.
|
||||
@@ -574,6 +583,7 @@
|
||||
;; Variant determines how result is given when combined with a
|
||||
;; ProducesFlags. See `with_flags` below for more.
|
||||
(type ConsumesFlags (enum
|
||||
(ConsumesFlagsSideEffect (inst MInst))
|
||||
(ConsumesFlagsReturnsResultWithProducer (inst MInst) (result Reg))
|
||||
(ConsumesFlagsReturnsReg (inst MInst) (result Reg))
|
||||
(ConsumesFlagsTwiceReturnsValueRegs (inst1 MInst)
|
||||
@@ -667,6 +677,30 @@
|
||||
(let ((v ValueRegs (with_flags p c)))
|
||||
(value_regs_get v 0)))
|
||||
|
||||
;; Indicate that the current state of the flags register from the instruction
|
||||
;; that produces this Value is relied on.
|
||||
(decl flags_to_producesflags (Value) ProducesFlags)
|
||||
(rule (flags_to_producesflags val)
|
||||
(let ((_ Unit (mark_value_used val)))
|
||||
(ProducesFlags.AlreadyExistingFlags)))
|
||||
|
||||
;; Combine a flags-producing instruction and a flags-consuming instruction that
|
||||
;; produces no results.
|
||||
;;
|
||||
;; This function handles the following case only:
|
||||
;; - ProducesFlagsSideEffect + ConsumesFlagsSideEffect
|
||||
(decl with_flags_side_effect (ProducesFlags ConsumesFlags) SideEffectNoResult)
|
||||
|
||||
(rule (with_flags_side_effect
|
||||
(ProducesFlags.AlreadyExistingFlags)
|
||||
(ConsumesFlags.ConsumesFlagsSideEffect c))
|
||||
(SideEffectNoResult.Inst c))
|
||||
|
||||
(rule (with_flags_side_effect
|
||||
(ProducesFlags.ProducesFlagsSideEffect p)
|
||||
(ConsumesFlags.ConsumesFlagsSideEffect c))
|
||||
(SideEffectNoResult.Inst2 p c))
|
||||
|
||||
;;;; Helpers for Working with TrapCode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(decl trap_code_division_by_zero () TrapCode)
|
||||
|
||||
Reference in New Issue
Block a user