From fc1e9b53ee8521c5ce26908929af1d702e31b93b Mon Sep 17 00:00:00 2001
From: sof <unknown>
Date: Tue, 25 Nov 1997 18:01:00 +0000
Subject: [PATCH] [project @ 1997-11-25 18:00:56 by sof] Move StableLoc (and
 assoc. access functions) from CgBindery to CgMonad. Done to avoid having to
 give the home of Maybe in CgBindery.hi-boot.

---
 ghc/compiler/codeGen/CgBindery.hi-boot |  7 ++----
 ghc/compiler/codeGen/CgBindery.lhs     | 19 ++-------------
 ghc/compiler/codeGen/CgLoop1.lhi       |  6 ++---
 ghc/compiler/codeGen/CgMonad.lhs       | 32 +++++++++++++++++++++++++-
 4 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/ghc/compiler/codeGen/CgBindery.hi-boot b/ghc/compiler/codeGen/CgBindery.hi-boot
index f9a119b22fba..e2c06aa4f739 100644
--- a/ghc/compiler/codeGen/CgBindery.hi-boot
+++ b/ghc/compiler/codeGen/CgBindery.hi-boot
@@ -1,11 +1,8 @@
 _interface_ CgBindery 1
 _exports_
-CgBindery CgBindings CgIdInfo(MkCgIdInfo) VolatileLoc StableLoc nukeVolatileBinds maybeAStkLoc maybeBStkLoc;
+CgBindery CgBindings CgIdInfo(MkCgIdInfo) VolatileLoc nukeVolatileBinds;
 _declarations_
 1 type CgBindings = Id.IdEnv CgIdInfo;
-1 data CgIdInfo = MkCgIdInfo Id.Id CgBindery.VolatileLoc CgBindery.StableLoc ClosureInfo!LambdaFormInfo;
+1 data CgIdInfo = MkCgIdInfo Id.Id CgBindery.VolatileLoc CgMonad.StableLoc ClosureInfo!LambdaFormInfo;
 1 data VolatileLoc;
-1 data StableLoc;
 1 nukeVolatileBinds _:_ CgBindery.CgBindings -> CgBindery.CgBindings ;;
-1 maybeAStkLoc _:_ CgBindery.StableLoc  -> PrelBase.Maybe HeapOffs.VirtualSpAOffset ;;
-1 maybeBStkLoc _:_ CgBindery.StableLoc  -> PrelBase.Maybe HeapOffs.VirtualSpBOffset ;;
diff --git a/ghc/compiler/codeGen/CgBindery.lhs b/ghc/compiler/codeGen/CgBindery.lhs
index 37937d06b9c6..d43313392b84 100644
--- a/ghc/compiler/codeGen/CgBindery.lhs
+++ b/ghc/compiler/codeGen/CgBindery.lhs
@@ -8,9 +8,9 @@
 
 module CgBindery (
 	SYN_IE(CgBindings), CgIdInfo(..){-dubiously concrete-},
-	StableLoc, VolatileLoc,
+	VolatileLoc, StableLoc, -- (the latter is defined in CgMonad)
 
-	maybeAStkLoc, maybeBStkLoc,
+--	maybeAStkLoc, maybeBStkLoc,
 
 	stableAmodeIdInfo, heapIdInfo, newTempAmodeAndIdInfo,
 	letNoEscapeIdInfo, idInfoToAmode,
@@ -42,7 +42,6 @@ import Id		( idPrimRep, toplevelishId,
 			  idSetToList,
 			  GenId{-instance NamedThing-}, SYN_IE(Id)
 			)
-import Literal          ( Literal )
 import Maybes		( catMaybes )
 import Name		( isLocallyDefined, isWiredInName,
 			  Name{-instance NamedThing-}, NamedThing(..) )
@@ -93,20 +92,6 @@ data VolatileLoc
   | VirNodeLoc	VirtualHeapOffset	-- Cts of offset indirect from Node
 					-- ie *(Node+offset)
 
-data StableLoc
-  = NoStableLoc
-  | VirAStkLoc		VirtualSpAOffset
-  | VirBStkLoc		VirtualSpBOffset
-  | LitLoc		Literal
-  | StableAmodeLoc	CAddrMode
-
--- these are so StableLoc can be abstract:
-
-maybeAStkLoc (VirAStkLoc offset) = Just offset
-maybeAStkLoc _			 = Nothing
-
-maybeBStkLoc (VirBStkLoc offset) = Just offset
-maybeBStkLoc _			 = Nothing
 \end{code}
 
 %************************************************************************
diff --git a/ghc/compiler/codeGen/CgLoop1.lhi b/ghc/compiler/codeGen/CgLoop1.lhi
index ef8dd2d66948..985529ba8402 100644
--- a/ghc/compiler/codeGen/CgLoop1.lhi
+++ b/ghc/compiler/codeGen/CgLoop1.lhi
@@ -3,14 +3,12 @@ interface CgLoop1 where
 import PreludeStdIO	( Maybe )
 
 import CgBindery	( CgBindings(..), CgIdInfo(..),
-			  VolatileLoc, StableLoc,
-			  nukeVolatileBinds,
-			  maybeAStkLoc, maybeBStkLoc
+			  VolatileLoc, nukeVolatileBinds
 		 	)
 import CgUsages		( getSpBRelOffset )
 
 import AbsCSyn		( RegRelative )
-import CgMonad		( FCode(..) )
+import CgMonad		( FCode(..), StableLoc, maybeAStkLoc, maybeBStkLoc )
 import ClosureInfo	( LambdaFormInfo )
 import HeapOffs		( VirtualSpAOffset(..), VirtualSpBOffset(..) )
 import Id		( IdEnv(..), Id(..) )
diff --git a/ghc/compiler/codeGen/CgMonad.lhs b/ghc/compiler/codeGen/CgMonad.lhs
index 902774bd2d0a..6c9e31f83f01 100644
--- a/ghc/compiler/codeGen/CgMonad.lhs
+++ b/ghc/compiler/codeGen/CgMonad.lhs
@@ -42,6 +42,8 @@ module CgMonad (
 	Sequel(..), -- ToDo: unabstract?
 	sequelToAmode,
 
+	StableLoc(..), maybeAStkLoc, maybeBStkLoc,
+
 	-- out of general friendliness, we also export ...
 	CgInfoDownwards(..), CgState(..),	-- non-abstract
 	CompilationInfo(..)
@@ -73,6 +75,7 @@ import Id		( idType,
 			  SYN_IE(ConTag), GenId{-instance Outputable-},
 			  SYN_IE(Id)
 			)
+import Literal          ( Literal )
 import Maybes		( maybeToBool )
 import Outputable	( PprStyle(..), Outputable(..) )
 import PprType		( GenType{-instance Outputable-} )
@@ -218,6 +221,33 @@ sequelToAmode (UpdateCode amode) = returnFC (CReg StdUpdRetVecReg)
 sequelToAmode (CaseAlts amode _) = returnFC amode
 \end{code}
 
+@StableLoc@ encodes where an Id can be found, used by
+the @CgBindings@ environment in @CgBindery@.
+
+The natural home for @StableLoc@ is @CgBindery@, but it is
+stuck out here to avoid giving the type for @maybeBStkLoc@
+and @maybeAStkLoc@ in the @.hi-boot@ file for @CgBindery@.
+This is problematic since they're both returning @Maybe@ types,
+which lives in @PrelBase@ (< ghc-2.09) or @PrelMaybe@ (> 2.09).
+ToDo: after the next major release, move it back.
+
+\begin{code}
+data StableLoc
+  = NoStableLoc
+  | VirAStkLoc		VirtualSpAOffset
+  | VirBStkLoc		VirtualSpBOffset
+  | LitLoc		Literal
+  | StableAmodeLoc	CAddrMode
+
+-- these are so StableLoc can be abstract:
+
+maybeAStkLoc (VirAStkLoc offset) = Just offset
+maybeAStkLoc _			 = Nothing
+
+maybeBStkLoc (VirBStkLoc offset) = Just offset
+maybeBStkLoc _			 = Nothing
+\end{code}
+
 See the NOTES about the details of stack/heap usage tracking.
 
 \begin{code}
@@ -709,7 +739,7 @@ lookupBindC name info_down@(MkCgInfoDown _ static_binds _)
 
 %************************************************************************
 %*									*
-\subsection[CgStackery-deadslots]{Finding dead stack slots}
+\subsection[CgMonad-deadslots]{Finding dead stack slots}
 %*									*
 %************************************************************************
 
-- 
GitLab