CgUtils

ghc-7.6.3: The GHC API

Safe Haskell | None

CgUtils

Synopsis

- addIdReps :: [Id] -> [(CgRep, Id)]
- cgLit :: Literal -> FCode CmmLit
- emitDataLits :: CLabel -> [CmmLit] -> Code
- mkDataLits :: Section -> CLabel -> [CmmLit] -> GenCmmDecl CmmStatics info stmt
- emitRODataLits :: String -> CLabel -> [CmmLit] -> Code
- mkRODataLits :: CLabel -> [CmmLit] -> GenCmmDecl CmmStatics info stmt
- emitIf :: CmmExpr -> Code -> Code
- emitIfThenElse :: CmmExpr -> Code -> Code -> Code
- emitRtsCall :: PackageId -> FastString -> [CmmHinted CmmExpr] -> Code
- emitRtsCallWithVols :: PackageId -> FastString -> [CmmHinted CmmExpr] -> [GlobalReg] -> Code
- emitRtsCallWithResult :: LocalReg -> ForeignHint -> PackageId -> FastString -> [CmmHinted CmmExpr] -> Code
- emitRtsCallGen :: [CmmHinted LocalReg] -> PackageId -> FastString -> [CmmHinted CmmExpr] -> Maybe [GlobalReg] -> Code
- assignTemp :: CmmExpr -> FCode CmmExpr
- assignTemp_ :: CmmExpr -> FCode CmmExpr
- newTemp :: CmmType -> FCode LocalReg
- emitSimultaneously :: CmmStmts -> Code
- emitSwitch :: CmmExpr -> [(ConTagZ, CgStmts)] -> Maybe CgStmts -> ConTagZ -> ConTagZ -> Code
- emitLitSwitch :: CmmExpr -> [(Literal, CgStmts)] -> CgStmts -> Code
- tagToClosure :: TyCon -> CmmExpr -> CmmExpr
- callerSaves :: GlobalReg -> Bool
- callerSaveVolatileRegs :: Maybe [GlobalReg] -> ([CmmStmt], [CmmStmt])
- get_GlobalReg_addr :: GlobalReg -> CmmExpr
- activeStgRegs :: [GlobalReg]
- fixStgRegisters :: RawCmmDecl -> RawCmmDecl
- cmmAndWord :: CmmExpr -> CmmExpr -> CmmExpr
- cmmOrWord :: CmmExpr -> CmmExpr -> CmmExpr
- cmmNegate :: CmmExpr -> CmmExpr
- cmmEqWord :: CmmExpr -> CmmExpr -> CmmExpr
- cmmNeWord :: CmmExpr -> CmmExpr -> CmmExpr
- cmmUGtWord :: CmmExpr -> CmmExpr -> CmmExpr
- cmmSubWord :: CmmExpr -> CmmExpr -> CmmExpr
- cmmMulWord :: CmmExpr -> CmmExpr -> CmmExpr
- cmmAddWord :: CmmExpr -> CmmExpr -> CmmExpr
- cmmUShrWord :: CmmExpr -> CmmExpr -> CmmExpr
- cmmOffsetExprW :: CmmExpr -> CmmExpr -> CmmExpr
- cmmOffsetExprB :: CmmExpr -> CmmExpr -> CmmExpr
- cmmRegOffW :: CmmReg -> WordOff -> CmmExpr
- cmmRegOffB :: CmmReg -> ByteOff -> CmmExpr
- cmmLabelOffW :: CLabel -> WordOff -> CmmLit
- cmmLabelOffB :: CLabel -> ByteOff -> CmmLit
- cmmOffsetW :: CmmExpr -> WordOff -> CmmExpr
- cmmOffsetB :: CmmExpr -> ByteOff -> CmmExpr
- cmmOffsetLitW :: CmmLit -> WordOff -> CmmLit
- cmmOffsetLitB :: CmmLit -> ByteOff -> CmmLit
- cmmLoadIndexW :: CmmExpr -> Int -> CmmType -> CmmExpr
- cmmConstrTag :: CmmExpr -> CmmExpr
- cmmConstrTag1 :: CmmExpr -> CmmExpr
- tagForCon :: DataCon -> ConTagZ
- tagCons :: DataCon -> CmmExpr -> CmmExpr
- isSmallFamily :: Int -> Bool
- cmmUntag :: CmmExpr -> CmmExpr
- cmmIsTagged :: CmmExpr -> CmmExpr
- cmmGetTag :: CmmExpr -> CmmExpr
- addToMem :: Width -> CmmExpr -> Int -> CmmStmt
- addToMemE :: Width -> CmmExpr -> CmmExpr -> CmmStmt
- mkWordCLit :: StgWord -> CmmLit
- newStringCLit :: String -> FCode CmmLit
- newByteStringCLit :: [Word8] -> FCode CmmLit
- packHalfWordsCLit :: (Integral a, Integral b) => a -> b -> CmmLit
- blankWord :: CmmStatic
- getSRTInfo :: FCode C_SRT

# Documentation

addIdReps :: [Id] -> [(CgRep, Id)]

cgLit :: Literal -> FCode CmmLit

emitDataLits :: CLabel -> [CmmLit] -> Code

mkDataLits :: Section -> CLabel -> [CmmLit] -> GenCmmDecl CmmStatics info stmt

emitRODataLits :: String -> CLabel -> [CmmLit] -> Code

mkRODataLits :: CLabel -> [CmmLit] -> GenCmmDecl CmmStatics info stmt

emitIf :: CmmExpr -> Code -> Code

emitIfThenElse :: CmmExpr -> Code -> Code -> Code

emitRtsCall

Arguments

:: PackageId | package the function is in
-> FastString | name of function
-> [CmmHinted CmmExpr] | function args
-> Code | cmm code

Emit code to call a Cmm function.

emitRtsCallWithVols :: PackageId -> FastString -> [CmmHinted CmmExpr] -> [GlobalReg] -> Code

emitRtsCallWithResult :: LocalReg -> ForeignHint -> PackageId -> FastString -> [CmmHinted CmmExpr] -> Code

emitRtsCallGen :: [CmmHinted LocalReg] -> PackageId -> FastString -> [CmmHinted CmmExpr] -> Maybe [GlobalReg] -> Code

assignTemp :: CmmExpr -> FCode CmmExpr

If the expression is trivial, return it. Otherwise, assign the expression to a temporary register and return an expression referring to this register.

assignTemp_ :: CmmExpr -> FCode CmmExpr

If the expression is trivial and doesn't refer to a global register, return it. Otherwise, assign the expression to a temporary register and return an expression referring to this register.

newTemp :: CmmType -> FCode LocalReg

emitSimultaneously :: CmmStmts -> Code

emitSwitch :: CmmExpr -> [(ConTagZ, CgStmts)] -> Maybe CgStmts -> ConTagZ -> ConTagZ -> Code

emitLitSwitch :: CmmExpr -> [(Literal, CgStmts)] -> CgStmts -> Code

tagToClosure :: TyCon -> CmmExpr -> CmmExpr

callerSaves :: GlobalReg -> Bool

Returns `True` if this global register is stored in a caller-saves machine register.

callerSaveVolatileRegs :: Maybe [GlobalReg] -> ([CmmStmt], [CmmStmt])

get_GlobalReg_addr :: GlobalReg -> CmmExpr

We map STG registers onto appropriate CmmExprs. Either they map to real machine registers or stored as offsets from BaseReg. Given a GlobalReg, get_GlobalReg_addr always produces the register table address for it.

activeStgRegs :: [GlobalReg]

Here is where the STG register map is defined for each target arch. The order matters (for the llvm backend anyway)! We must make sure to maintain the order here with the order used in the LLVM calling conventions. Note that also, this isn't all registers, just the ones that are currently possbily mapped to real registers.

fixStgRegisters :: RawCmmDecl -> RawCmmDecl

Fixup global registers so that they assign to locations within the RegTable if they aren't pinned for the current target.

cmmAndWord :: CmmExpr -> CmmExpr -> CmmExpr

cmmOrWord :: CmmExpr -> CmmExpr -> CmmExpr

cmmNegate :: CmmExpr -> CmmExpr

cmmEqWord :: CmmExpr -> CmmExpr -> CmmExpr

cmmNeWord :: CmmExpr -> CmmExpr -> CmmExpr

cmmUGtWord :: CmmExpr -> CmmExpr -> CmmExpr

cmmSubWord :: CmmExpr -> CmmExpr -> CmmExpr

cmmMulWord :: CmmExpr -> CmmExpr -> CmmExpr

cmmAddWord :: CmmExpr -> CmmExpr -> CmmExpr

cmmUShrWord :: CmmExpr -> CmmExpr -> CmmExpr

cmmOffsetExprW :: CmmExpr -> CmmExpr -> CmmExpr

cmmOffsetExprB :: CmmExpr -> CmmExpr -> CmmExpr

cmmRegOffW :: CmmReg -> WordOff -> CmmExpr

cmmRegOffB :: CmmReg -> ByteOff -> CmmExpr

cmmLabelOffW :: CLabel -> WordOff -> CmmLit

cmmLabelOffB :: CLabel -> ByteOff -> CmmLit

cmmOffsetW :: CmmExpr -> WordOff -> CmmExpr

cmmOffsetB :: CmmExpr -> ByteOff -> CmmExpr

cmmOffsetLitW :: CmmLit -> WordOff -> CmmLit

cmmOffsetLitB :: CmmLit -> ByteOff -> CmmLit

cmmLoadIndexW :: CmmExpr -> Int -> CmmType -> CmmExpr

cmmConstrTag :: CmmExpr -> CmmExpr

cmmConstrTag1 :: CmmExpr -> CmmExpr

tagForCon :: DataCon -> ConTagZ

tagCons :: DataCon -> CmmExpr -> CmmExpr

isSmallFamily :: Int -> Bool

cmmUntag :: CmmExpr -> CmmExpr

cmmIsTagged :: CmmExpr -> CmmExpr

cmmGetTag :: CmmExpr -> CmmExpr

addToMem :: Width -> CmmExpr -> Int -> CmmStmt

addToMemE :: Width -> CmmExpr -> CmmExpr -> CmmStmt

mkWordCLit :: StgWord -> CmmLit

newStringCLit :: String -> FCode CmmLit

newByteStringCLit :: [Word8] -> FCode CmmLit

packHalfWordsCLit :: (Integral a, Integral b) => a -> b -> CmmLit

blankWord :: CmmStatic

getSRTInfo :: FCode C_SRT