summaryrefslogtreecommitdiff
path: root/compiler/cmm/BlockId.hs
diff options
context:
space:
mode:
authordias@eecs.harvard.edu <unknown>2008-05-29 16:05:45 +0000
committerdias@eecs.harvard.edu <unknown>2008-05-29 16:05:45 +0000
commit0d80489c9b9f2421f65d8dd86c1e50c6bb429715 (patch)
tree68fbebbb771f95252e847cd91180c614b405f14c /compiler/cmm/BlockId.hs
parent724a9e83f9498382e3580d26a7dd7cd6b108408c (diff)
downloadhaskell-0d80489c9b9f2421f65d8dd86c1e50c6bb429715.tar.gz
Replacing copyins and copyouts with data-movement instructions
o Moved BlockId stuff to a new file to avoid module recursion o Defined stack areas for parameter-passing locations and spill slots o Part way through replacing copy in and copy out nodes - added movement instructions for stack pointer - added movement instructions for call and return parameters (but not with the proper calling conventions) o Inserting spills and reloads for proc points is now procpoint-aware (it was relying on the presence of a CopyIn node as a proxy for procpoint knowledge) o Changed ZipDataflow to expect AGraphs (instead of being polymorphic in the type of graph)
Diffstat (limited to 'compiler/cmm/BlockId.hs')
-rw-r--r--compiler/cmm/BlockId.hs60
1 files changed, 60 insertions, 0 deletions
diff --git a/compiler/cmm/BlockId.hs b/compiler/cmm/BlockId.hs
new file mode 100644
index 0000000000..fb9b7cab8f
--- /dev/null
+++ b/compiler/cmm/BlockId.hs
@@ -0,0 +1,60 @@
+module BlockId
+ ( BlockId(..), mkBlockId -- ToDo: BlockId should be abstract, but it isn't yet
+ , BlockEnv, emptyBlockEnv, lookupBlockEnv, extendBlockEnv, mkBlockEnv
+ , BlockSet, emptyBlockSet, elemBlockSet, extendBlockSet, sizeBlockSet, mkBlockSet
+ ) where
+
+import Outputable
+import UniqFM
+import Unique
+import UniqSet
+
+----------------------------------------------------------------
+--- Block Ids, their environments, and their sets
+
+{- Note [Unique BlockId]
+~~~~~~~~~~~~~~~~~~~~~~~~
+Although a 'BlockId' is a local label, for reasons of implementation,
+'BlockId's must be unique within an entire compilation unit. The reason
+is that each local label is mapped to an assembly-language label, and in
+most assembly languages allow, a label is visible throughout the enitre
+compilation unit in which it appears.
+-}
+
+newtype BlockId = BlockId Unique
+ deriving (Eq,Ord)
+
+instance Uniquable BlockId where
+ getUnique (BlockId u) = u
+
+mkBlockId :: Unique -> BlockId
+mkBlockId uniq = BlockId uniq
+
+instance Show BlockId where
+ show (BlockId u) = show u
+
+instance Outputable BlockId where
+ ppr = ppr . getUnique
+
+
+type BlockEnv a = UniqFM {- BlockId -} a
+emptyBlockEnv :: BlockEnv a
+emptyBlockEnv = emptyUFM
+mkBlockEnv :: [(BlockId,a)] -> BlockEnv a
+mkBlockEnv = listToUFM
+lookupBlockEnv :: BlockEnv a -> BlockId -> Maybe a
+lookupBlockEnv = lookupUFM
+extendBlockEnv :: BlockEnv a -> BlockId -> a -> BlockEnv a
+extendBlockEnv = addToUFM
+
+type BlockSet = UniqSet BlockId
+emptyBlockSet :: BlockSet
+emptyBlockSet = emptyUniqSet
+elemBlockSet :: BlockId -> BlockSet -> Bool
+elemBlockSet = elementOfUniqSet
+extendBlockSet :: BlockSet -> BlockId -> BlockSet
+extendBlockSet = addOneToUniqSet
+mkBlockSet :: [BlockId] -> BlockSet
+mkBlockSet = mkUniqSet
+sizeBlockSet :: BlockSet -> Int
+sizeBlockSet = sizeUniqSet