From 02bd9340e2d81dcdc991c4cc47888b2404e56110 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Mon, 8 Jul 2019 07:17:28 +0200 Subject: [PATCH] some code for const propagation --- lisp/emacs-lisp/comp.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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)) -- 2.39.5