46 lines
1.9 KiB
Common Lisp
46 lines
1.9 KiB
Common Lisp
;; Prelude definitions specific to the mid-end.
|
|
|
|
;;;;; eclass and enode access ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Extract any node(s) for the given eclass ID.
|
|
(decl multi inst_data (Type InstructionData) Value)
|
|
(extern extractor inst_data inst_data_etor)
|
|
|
|
;; Construct a pure node, returning a new (or deduplicated
|
|
;; already-existing) eclass ID.
|
|
(decl make_inst (Type InstructionData) Value)
|
|
(extern constructor make_inst make_inst_ctor)
|
|
|
|
;; Constructors for value arrays.
|
|
(decl value_array_2_ctor (Value Value) ValueArray2)
|
|
(extern constructor value_array_2_ctor value_array_2_ctor)
|
|
(decl value_array_3_ctor (Value Value Value) ValueArray3)
|
|
(extern constructor value_array_3_ctor value_array_3_ctor)
|
|
|
|
(rule (eq ty x y) (icmp ty (IntCC.Equal) x y))
|
|
(rule (ne ty x y) (icmp ty (IntCC.NotEqual) x y))
|
|
(rule (ult ty x y) (icmp ty (IntCC.UnsignedLessThan) x y))
|
|
(rule (ule ty x y) (icmp ty (IntCC.UnsignedLessThanOrEqual) x y))
|
|
(rule (ugt ty x y) (icmp ty (IntCC.UnsignedGreaterThan) x y))
|
|
(rule (uge ty x y) (icmp ty (IntCC.UnsignedGreaterThanOrEqual) x y))
|
|
(rule (slt ty x y) (icmp ty (IntCC.SignedLessThan) x y))
|
|
(rule (sle ty x y) (icmp ty (IntCC.SignedLessThanOrEqual) x y))
|
|
(rule (sgt ty x y) (icmp ty (IntCC.SignedGreaterThan) x y))
|
|
(rule (sge ty x y) (icmp ty (IntCC.SignedGreaterThanOrEqual) x y))
|
|
|
|
;;;;; optimization toplevel ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; The main matcher rule invoked by the toplevel driver.
|
|
(decl multi simplify (Value) Value)
|
|
|
|
;; Mark a node as requiring remat when used in a different block.
|
|
(decl remat (Value) Value)
|
|
(extern constructor remat remat)
|
|
|
|
;; Mark a node as subsuming whatever else it's rewritten from -- this
|
|
;; is definitely preferable, not just a possible option. Useful for,
|
|
;; e.g., constant propagation where we arrive at a definite "final
|
|
;; answer".
|
|
(decl subsume (Value) Value)
|
|
(extern constructor subsume subsume)
|