Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
yihozhang committed Jan 27, 2024
1 parent b21ad84 commit 217e043
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions tree_unique_args/src/let_inline.egg
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
(ruleset let-inline)

;; To implement
;; ExprIsNontrivial
;; arg-used-Expr-count
;; arg-used-Expr
;; arg-used-Expr <== easy
;; MapArgOverVec
;; set->vec
;; BuildSubstMapFrom
;; SubsetOperandMap

(relation ExprUsesArgs-demand (Expr))
(rule (
(= expr (Let id (All inp-ord inp-exprs) out))
(= inp (ListExpr-ith inp-exprs ith))
(ExprIsValid inp)
(ExprIsPure inp)
) (
(arg-used-Expr-demand inp)
))

(function ExprUsesArgs (Expr) I64Set :merge (set-union old new))
(rule (
(BodyContainsExpr body (Get (Arg id) i))
) (
(set (arg-used-Expr e) (set-of i))
))

(rule (
(= expr (Let id (All inp-ord inp-exprs) out))
(= inp (ListExpr-ith inp-exprs ith))
(= (ExprIsNontrivial inp) true)
(>= (Expr-size inp) 3) ;; so that `inp` involves at least some binary operation
(ExprIsPure inp)

;; NB: arg-used-count might undercount
Expand Down

0 comments on commit 217e043

Please sign in to comment.