GenCmm(..), Cmm,
GenCmmTop(..), CmmTop,
GenBasicBlock(..), CmmBasicBlock, blockId, blockStmts,
- CmmStmt(..),
+ CmmStmt(..), CmmActuals, CmmFormals,
CmmCallTarget(..),
CmmStatic(..), Section(..),
CmmExpr(..), cmmExprRep,
CmmReg(..), cmmRegRep,
CmmLit(..), cmmLitRep,
LocalReg(..), localRegRep,
- BlockId(..),
+ 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.
+ CmmFormals -- zero or more results
+ CmmActuals -- zero or more arguments
| CmmBranch BlockId -- branch to another BB in this fn
-- one -> second block etc
-- Undefined outside range, and when there's a Nothing
- | CmmJump CmmExpr [LocalReg] -- Jump to another function, with these
- -- parameters.
+ | CmmJump CmmExpr -- Jump to another function,
+ CmmActuals -- with these parameters.
+
+ | CmmReturn -- Return from a function,
+ CmmActuals -- with these return values.
+
+type CmmActuals = [(CmmExpr,MachHint)]
+type CmmFormals = [(CmmReg,MachHint)]
{-
Discussion
-- ** is shorthand only, meaning **
-- CmmMachOp (MO_S_Add rep (CmmReg reg) (CmmLit (CmmInt i rep)))
-- where rep = cmmRegRep reg
+ deriving Eq
cmmExprRep :: CmmExpr -> MachRep
cmmExprRep (CmmLit lit) = cmmLitRep lit
-- It is also used inside the NCG during when generating
-- position-independent code.
| CmmLabelDiffOff CLabel CLabel Int -- label1 - label2 + offset
+ deriving Eq
cmmLitRep :: CmmLit -> MachRep
cmmLitRep (CmmInt _ rep) = rep
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