+----------------------------------------------------------------------
+----- Instance declarations for register use
+
+instance UserOfLocalRegs Middle where
+ foldRegsUsed f z m = middle m
+ where middle (MidComment {}) = z
+ middle (MidAssign _lhs expr) = fold f z expr
+ middle (MidStore addr rval) = fold f (fold f z addr) rval
+ middle (MidUnsafeCall tgt _ress args) = fold f (fold f z tgt) args
+ middle (MidAddToContext ra args) = fold f (fold f z ra) args
+ middle (CopyIn _ _formals _) = z
+ middle (CopyOut _ actuals) = fold f z actuals
+ fold f z m = foldRegsUsed f z m -- avoid monomorphism restriction
+
+instance UserOfLocalRegs Last where
+ foldRegsUsed f z m = last m
+ where last (LastReturn) = z
+ last (LastJump e) = foldRegsUsed f z e
+ last (LastBranch _id) = z
+ last (LastCall tgt _) = foldRegsUsed f z tgt
+ last (LastCondBranch e _ _) = foldRegsUsed f z e
+ last (LastSwitch e _tbl) = foldRegsUsed f z e
+
+
+----------------------------------------------------------------------
+----- Instance declarations for prettyprinting (avoids recursive imports)