From 217e0437deba2b76e11ebd35cc19c8e5ffc920aa Mon Sep 17 00:00:00 2001 From: Yihong Zhang Date: Fri, 26 Jan 2024 18:18:12 -0800 Subject: [PATCH] WIP --- tree_unique_args/src/let_inline.egg | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tree_unique_args/src/let_inline.egg b/tree_unique_args/src/let_inline.egg index ddd24eed0..f99fe2e0d 100644 --- a/tree_unique_args/src/let_inline.egg +++ b/tree_unique_args/src/let_inline.egg @@ -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