Safe Haskell | None |
---|---|
Language | GHC2021 |
Synopsis
- cgForeignCall :: ForeignCall -> Type -> [StgArg] -> Type -> FCode ReturnKind
- emitPrimCall :: [CmmFormal] -> CallishMachOp -> [CmmActual] -> FCode ()
- emitCCall :: [(CmmFormal, ForeignHint)] -> CmmExpr -> [(CmmActual, ForeignHint)] -> FCode ()
- emitCCallNeverReturns :: [(CmmFormal, ForeignHint)] -> CmmExpr -> [(CmmActual, ForeignHint)] -> FCode ()
- emitForeignCall :: Safety -> [CmmFormal] -> ForeignTarget -> [CmmActual] -> FCode ReturnKind
- emitSaveThreadState :: FCode ()
- saveThreadState :: MonadGetUnique m => Profile -> m CmmAGraph
- emitLoadThreadState :: FCode ()
- emitSaveRegs :: GlobalArgRegs -> FCode ()
- emitRestoreRegs :: GlobalArgRegs -> FCode ()
- emitPushArgRegs :: GlobalArgRegs -> CmmExpr -> FCode ()
- emitPopArgRegs :: GlobalArgRegs -> CmmExpr -> FCode ()
- loadThreadState :: MonadGetUnique m => Profile -> m CmmAGraph
- emitOpenNursery :: FCode ()
- emitCloseNursery :: FCode ()
Documentation
cgForeignCall :: ForeignCall -> Type -> [StgArg] -> Type -> FCode ReturnKind Source #
Emit code for a foreign call, and return the results to the sequel. Precondition: the length of the arguments list is the same as the arity of the foreign function.
emitPrimCall :: [CmmFormal] -> CallishMachOp -> [CmmActual] -> FCode () Source #
emitCCall :: [(CmmFormal, ForeignHint)] -> CmmExpr -> [(CmmActual, ForeignHint)] -> FCode () Source #
emitCCallNeverReturns :: [(CmmFormal, ForeignHint)] -> CmmExpr -> [(CmmActual, ForeignHint)] -> FCode () Source #
emitForeignCall :: Safety -> [CmmFormal] -> ForeignTarget -> [CmmActual] -> FCode ReturnKind Source #
emitSaveThreadState :: FCode () Source #
saveThreadState :: MonadGetUnique m => Profile -> m CmmAGraph Source #
Produce code to save the current thread state to CurrentTSO
emitLoadThreadState :: FCode () Source #
emitSaveRegs :: GlobalArgRegs -> FCode () Source #
Save STG registers
STG registers must be saved around a C call, just in case the STG register is mapped to a caller-saves machine register. Normally we don't need to worry about this the code generator has already loaded any live STG registers into variables for us, but in hand-written low-level Cmm code where we don't know which registers are live, we might have to save them all.
emitRestoreRegs :: GlobalArgRegs -> FCode () Source #
Restore STG registers (see emitSaveRegs
)
emitPushArgRegs :: GlobalArgRegs -> CmmExpr -> FCode () Source #
Push a subset of STG registers onto the stack, specified by the bitmap
Sometimes, a "live" subset of the STG registers needs to be saved on the stack, for example when storing an unboxed tuple to be used in the GHCi bytecode interpreter.
The "live registers" bitmap corresponds to the list of registers given by
allArgRegsCover
, with the least significant bit indicating liveness of
the first register in the list.
Each register is saved to a stack slot of one or more machine words, even if the register size itself is smaller.
The resulting Cmm code looks like this, with a line for each real or virtual register used for returning tuples:
... if((mask & 2) != 0) { Sp_adj(-1); Sp(0) = R2; } if((mask & 1) != 0) { Sp_adj(-1); Sp(0) = R1; }
See Note [GHCi and native call registers]
emitPopArgRegs :: GlobalArgRegs -> CmmExpr -> FCode () Source #
Pop a subset of STG registers from the stack (see emitPushArgRegs
)
loadThreadState :: MonadGetUnique m => Profile -> m CmmAGraph Source #
Produce code to load the current thread state from CurrentTSO
emitOpenNursery :: FCode () Source #
emitCloseNursery :: FCode () Source #