ghc-9.0.2: The GHC API

GHC.StgToCmm.Foreign

Synopsis

# Documentation

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.

Produce code to save the current thread state to CurrentTSO

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.

Restore STG registers (see emitSaveRegs)

Produce code to load the current thread state from CurrentTSO