add comp-call-optim pass
This commit is contained in:
parent
47b22e5514
commit
a317620a52
1 changed files with 26 additions and 0 deletions
|
@ -56,6 +56,7 @@
|
|||
comp-limplify
|
||||
comp-ssa
|
||||
comp-propagate
|
||||
comp-call-optim
|
||||
comp-final)
|
||||
"Passes to be executed in order.")
|
||||
|
||||
|
@ -1320,6 +1321,31 @@ This can run just once."
|
|||
(comp-log-func comp-func)))
|
||||
funcs)
|
||||
|
||||
|
||||
;;; Call optimizer pass specific code.
|
||||
;; Try to avoid funcall trampoline use when possible.
|
||||
|
||||
(defun comp-call-optim (funcs)
|
||||
(cl-loop
|
||||
for comp-func in funcs
|
||||
for self = (comp-func-symbol-name comp-func)
|
||||
for self-callref = (comp-nargs-p (comp-func-args comp-func))
|
||||
when (and (>= comp-speed 2)
|
||||
(not self-callref) ;; Could improve this
|
||||
)
|
||||
do (cl-loop
|
||||
for b being each hash-value of (comp-func-blocks comp-func)
|
||||
do (cl-loop
|
||||
for insn-cell on (comp-block-insns b)
|
||||
for insn = (car insn-cell)
|
||||
do (pcase insn
|
||||
(`(set ,lval (callref funcall ,f . ,rest))
|
||||
(when (eq self (comp-mvar-constant f))
|
||||
(setcar insn-cell
|
||||
`(set ,lval (call ,(comp-mvar-constant f) ,@rest))))))))
|
||||
(comp-log-func comp-func))
|
||||
funcs)
|
||||
|
||||
|
||||
;;; Final pass specific code.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue