GenCmm(..), Cmm,
GenCmmTop(..), CmmTop,
GenBasicBlock(..), CmmBasicBlock, blockId, blockStmts,
- CmmStmt(..),
+ CmmStmt(..), CmmActuals, CmmFormal, CmmFormals, CmmHintFormals,
CmmCallTarget(..),
CmmStatic(..), Section(..),
CmmExpr(..), cmmExprRep,
CmmReg(..), cmmRegRep,
CmmLit(..), cmmLitRep,
- LocalReg(..), localRegRep,
- BlockId(..),
+ LocalReg(..), localRegRep, Kind(..),
+ BlockId(..), BlockEnv,
GlobalReg(..), globalRegRep,
- node, nodeReg, spReg, hpReg,
+ node, nodeReg, spReg, hpReg, spLimReg
) where
#include "HsVersions.h"
import CLabel
import ForeignCall
import Unique
+import UniqFM
import FastString
import Data.Word
= CmmProc
[d] -- Info table, may be empty
CLabel -- Used to generate both info & entry labels
- [LocalReg] -- Argument locals live on entry (C-- procedure params)
+ CmmFormals -- Argument locals live on entry (C-- procedure params)
[GenBasicBlock i] -- Code, may be empty. The first block is
-- the entry point. The order is otherwise initially
-- unimportant, but at some point the code gen will
| CmmCall -- A foreign call, with
CmmCallTarget
- [(CmmReg,MachHint)] -- zero or more results
- [(CmmExpr,MachHint)] -- zero or more arguments
- (Maybe [GlobalReg]) -- Global regs that may need to be saved
- -- if they will be clobbered by the call.
- -- Nothing <=> save *all* globals that
- -- might be clobbered.
+ CmmHintFormals -- zero or more results
+ CmmActuals -- zero or more arguments
| CmmBranch BlockId -- branch to another BB in this fn
-- Undefined outside range, and when there's a Nothing
| CmmJump CmmExpr -- Jump to another function,
- [(CmmExpr, MachHint)] -- with these parameters.
+ CmmActuals -- with these parameters.
| CmmReturn -- Return from a function,
- [(CmmExpr, MachHint)] -- with these return values.
+ CmmActuals -- with these return values.
+
+type CmmActual = CmmExpr
+type CmmActuals = [(CmmActual,MachHint)]
+type CmmFormal = LocalReg
+type CmmHintFormals = [(CmmFormal,MachHint)]
+type CmmFormals = [CmmFormal]
{-
Discussion
cmmRegRep (CmmLocal reg) = localRegRep reg
cmmRegRep (CmmGlobal reg) = globalRegRep reg
+-- | Whether a 'LocalReg' is a GC followable pointer
+data Kind = KindPtr | KindNonPtr deriving (Eq)
+
data LocalReg
- = LocalReg !Unique MachRep
+ = LocalReg
+ !Unique -- ^ Identifier
+ MachRep -- ^ Type
+ Kind -- ^ Should the GC follow as a pointer
instance Eq LocalReg where
- (LocalReg u1 _) == (LocalReg u2 _) = u1 == u2
+ (LocalReg u1 _ _) == (LocalReg u2 _ _) = u1 == u2
instance Uniquable LocalReg where
- getUnique (LocalReg uniq _) = uniq
+ getUnique (LocalReg uniq _ _) = uniq
localRegRep :: LocalReg -> MachRep
-localRegRep (LocalReg _ rep) = rep
+localRegRep (LocalReg _ rep _) = rep
+
+localRegGCFollow (LocalReg _ _ p) = p
data CmmLit
= CmmInt Integer MachRep
instance Uniquable BlockId where
getUnique (BlockId u) = u
+type BlockEnv a = UniqFM {- BlockId -} a
+
-----------------------------------------------------------------------------
-- Static Data
-----------------------------------------------------------------------------
)
-- convenient aliases
-spReg, hpReg, nodeReg :: CmmReg
+spReg, hpReg, spLimReg, nodeReg :: CmmReg
spReg = CmmGlobal Sp
hpReg = CmmGlobal Hp
+spLimReg = CmmGlobal SpLim
nodeReg = CmmGlobal node
node :: GlobalReg