From 15898ab691c2bd1750d992bf0dc08c0f52e42a42 Mon Sep 17 00:00:00 2001 From: John Lorentzson Date: Thu, 31 Jul 2025 13:07:46 +0200 Subject: [PATCH] Add function for replacing IR-TERMINATOR in IBLOCK --- user-side-compiler/middle/graph-manipulation.lisp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/user-side-compiler/middle/graph-manipulation.lisp b/user-side-compiler/middle/graph-manipulation.lisp index 6652fca..b961616 100644 --- a/user-side-compiler/middle/graph-manipulation.lisp +++ b/user-side-compiler/middle/graph-manipulation.lisp @@ -24,6 +24,17 @@ (setf (start ib) new) (setf (next prev-inst) new)))) +(defun replace-terminator (old new) + (check-type old ir-terminator) + (check-type new ir-terminator) + (let ((iblock (iblock old)) + (before (previous old))) + (setf (destinations old) '() + (next before) new + (end iblock) new + (iblock new) iblock + (previous new) before))) + (defun yank-instruction (instruction) "Removes INSTRUCTIONS without cleaning up, allowing it to be put back in." (check-type instruction (and ir-inst (not ir-terminator)))