From: Andrea Corallo Date: Mon, 8 Jul 2019 05:17:28 +0000 (+0200) Subject: some code for const propagation X-Git-Tag: emacs-28.0.90~2727^2~1390 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=02bd9340e2d81dcdc991c4cc47888b2404e56110;p=emacs.git some code for const propagation --- diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 42533759424..8ed75e0a4b3 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -37,6 +37,15 @@ (defconst comp-known-ret-types '((Fcons . cons))) +(defconst comp-mostly-pure-funcs + '(% * + - / /= 1+ 1- < <= = > >= cons list % concat logand logcount logior + lognot logxor regexp-opt regexp-quote string-to-char string-to-syntax + symbol-name) + "Functions on witch we do constant propagation." + ;; Is it acceptable to move into the compile time functions that are + ;; allocating memory? (these are technically not side effect free) +) + (cl-defstruct comp-args mandatory nonrest rest) @@ -105,6 +114,13 @@ "Slot into the meta-stack pointed by sp + 1." '(comp-slot-n (1+ (comp-sp)))) +;; (defun comp-opt-call (inst) +;; "Optimize if possible a side-effect-free call in INST." +;; (cl-destructuring-bind (_ f &rest args) inst +;; (when (and (member f comp-mostly-pure-funcs) +;; (cl-every #'identity (mapcar #'comp-mvar-const-vld args))) +;; (apply f (mapcar #'comp-mvar-constant args))))) + (defmacro comp-push-call (x) "Push call X into frame." `(let ((src-slot ,x))