From 9a9a53eada042ce6867c32fdb8431632bb87cc15 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Sat, 18 May 2013 13:50:06 +0100 Subject: [PATCH] New function: dominate-p --- experimental/compiler.lisp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/experimental/compiler.lisp b/experimental/compiler.lisp index 9122f3c..49ed56e 100644 --- a/experimental/compiler.lisp +++ b/experimental/compiler.lisp @@ -156,6 +156,8 @@ entry exit ;; The component where the basic block belongs to. component + ;; The order in the reverse post ordering of the blocks. + order ;; A bit-vector representing the set of dominators. See the function ;; `compute-dominators' to know how to use it properly. dominators% @@ -765,9 +767,11 @@ ;;;; abstractions to use this information. (defun compute-reverse-post-order (component) - (let ((output nil)) + (let ((output nil) + (count 0)) (flet ((add-block-to-list (block) - (push block output))) + (push block output) + (setf (block-order block) (incf count)))) (map-postorder-blocks #'add-block-to-list component)) (setf (component-reverse-post-order-p component) t) (setf (component-blocks component) output))) @@ -819,6 +823,11 @@ (setf changes (or changes (not (equal (block-dominators% block) (block-dominators% block))))) (incf i))))) +;;; Return T if BLOCK1 dominates BLOCK2, else return NIL. +(defun dominate-p (block1 block2) + (let ((order (block-order block1))) + (= 1 (aref (block-dominators% block2) order)))) + ;;;; IR Debugging ;;;; -- 1.7.10.4