Compare commits
No commits in common. "bdb2a901cab7ee79480632903b13ec901d778241" and "c1846e35bdf536a3533cbbd706db729035308692" have entirely different histories.
bdb2a901ca
...
c1846e35bd
3 changed files with 1 additions and 36 deletions
|
@ -1,8 +1,7 @@
|
||||||
(in-package #:user-side-compiler)
|
(in-package #:user-side-compiler)
|
||||||
|
|
||||||
(defclass ir-data ()
|
(defclass ir-data ()
|
||||||
((%definition :accessor definition :initarg :definition)
|
((%definition :accessor definition :initarg :definition)))
|
||||||
(%last-use :accessor last-use)))
|
|
||||||
|
|
||||||
(defclass ir-result (ir-data)
|
(defclass ir-result (ir-data)
|
||||||
((%user :accessor user :initarg :user :initform nil)))
|
((%user :accessor user :initarg :user :initform nil)))
|
||||||
|
|
|
@ -80,8 +80,6 @@ end")
|
||||||
(compile-node (match-syntax program) builder)
|
(compile-node (match-syntax program) builder)
|
||||||
root-block)))
|
root-block)))
|
||||||
(do-iblocks (ib rb)
|
(do-iblocks (ib rb)
|
||||||
(optim-reorder-arguments ib)
|
|
||||||
(optim-direct-variable-use ib)
|
|
||||||
(optim-call-duplicate-args ib)
|
(optim-call-duplicate-args ib)
|
||||||
(optim-remove-unused ib))
|
(optim-remove-unused ib))
|
||||||
(print-iblocks rb)
|
(print-iblocks rb)
|
||||||
|
|
|
@ -168,35 +168,3 @@ though I'm pretty sure it can't anyway.")
|
||||||
(push input arguments))))
|
(push input arguments))))
|
||||||
(loop :for (new . old) :in replacements
|
(loop :for (new . old) :in replacements
|
||||||
:do (setf (inputs call) (substitute new old (inputs call)))))))))
|
:do (setf (inputs call) (substitute new old (inputs call)))))))))
|
||||||
|
|
||||||
(defun optim-direct-variable-use (iblock)
|
|
||||||
"Removes unnecessary uses of IR-FETCHVAR.
|
|
||||||
Some operations do not require their operands to be copied before use. CPU
|
|
||||||
instructions, for example. This optimization pass goes through and removes
|
|
||||||
IR-FETCHVAR instructions that would serve no purpose in compiled code."
|
|
||||||
;; TODO: Add more instructions to the candidates
|
|
||||||
(let ((candidates-type '(or ir-test-equal ir-plus ir-minus))
|
|
||||||
(to-remove '()))
|
|
||||||
(do-instructions (inst iblock)
|
|
||||||
#+(or)
|
|
||||||
(when (equalp (name iblock) "else")
|
|
||||||
(break "~A ~A" inst
|
|
||||||
(if (typep inst 'ir-fetchvar)
|
|
||||||
(format nil "~A ~A ~A" (input inst) (output inst) (users (output inst)))
|
|
||||||
"")))
|
|
||||||
(when (typep inst 'ir-fetchvar)
|
|
||||||
(let ((result (output inst))
|
|
||||||
(src (input inst)))
|
|
||||||
(when (and (not (typep (output inst) 'ir-reusable))
|
|
||||||
(typep (user result) candidates-type))
|
|
||||||
(let ((user (user (output inst))))
|
|
||||||
(setf (inputs user) (substitute src result (inputs user)))
|
|
||||||
(push inst to-remove))))))
|
|
||||||
(mapc #'delete-instruction to-remove)))
|
|
||||||
|
|
||||||
(defun compute-lifetime-knowledge (start-iblock)
|
|
||||||
(do-iblocks (iblock start-iblock)
|
|
||||||
(do-instructions (inst iblock)
|
|
||||||
(loop :for data :in (inputs inst)
|
|
||||||
:when (typep data 'ir-data)
|
|
||||||
:do (setf (last-use data) inst)))))
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue