]> git.eshelyaron.com Git - emacs.git/commitdiff
some code for const propagation
authorAndrea Corallo <andrea_corallo@yahoo.it>
Mon, 8 Jul 2019 05:17:28 +0000 (07:17 +0200)
committerAndrea Corallo <akrl@sdf.org>
Wed, 1 Jan 2020 10:33:50 +0000 (11:33 +0100)
lisp/emacs-lisp/comp.el

index 425337594243e7b2ede3b5323e73044c8d305a51..8ed75e0a4b33bdd80a492546c5137d42daaae3fb 100644 (file)
 
 (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)
 
   "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))