ghc-7.10.2: The GHC API

Safe Haskell | None
Language | Haskell2010

StgCmmExtCode

Description

Our extended FCode monad.

Synopsis

- data CmmParse a
- unEC :: CmmParse a -> String -> Env -> Decls -> FCode (Decls, a)
- data Named
  - = VarN CmmExpr
  - | FunN PackageKey
  - | LabelN BlockId
- type Env = UniqFM Named
- loopDecls :: CmmParse a -> CmmParse a
- getEnv :: CmmParse Env
- withName :: String -> CmmParse a -> CmmParse a
- getName :: CmmParse String
- newLocal :: CmmType -> FastString -> CmmParse LocalReg
- newLabel :: FastString -> CmmParse BlockId
- newBlockId :: CmmParse BlockId
- newFunctionName :: FastString -> PackageKey -> ExtCode
- newImport :: (FastString, CLabel) -> CmmParse ()
- lookupLabel :: FastString -> CmmParse BlockId
- lookupName :: FastString -> CmmParse CmmExpr
- code :: FCode a -> CmmParse a
- emit :: CmmAGraph -> CmmParse ()
- emitLabel :: BlockId -> CmmParse ()
- emitAssign :: CmmReg -> CmmExpr -> CmmParse ()
- emitStore :: CmmExpr -> CmmExpr -> CmmParse ()
- getCode :: CmmParse a -> CmmParse CmmAGraph
- getCodeR :: CmmParse a -> CmmParse (a, CmmAGraph)
- getCodeScoped :: CmmParse a -> CmmParse (a, CmmAGraphScoped)
- emitOutOfLine :: BlockId -> CmmAGraphScoped -> CmmParse ()
- withUpdFrameOff :: UpdFrameOffset -> CmmParse () -> CmmParse ()
- getUpdFrameOff :: CmmParse UpdFrameOffset

# Documentation

data CmmParse a Source

Does a computation in the FCode monad, with a current environment and a list of local declarations. Returns the resulting list of declarations.

Instances

Monad CmmParse |
Functor CmmParse |
Applicative CmmParse |
HasDynFlags CmmParse |

unEC :: CmmParse a -> String -> Env -> Decls -> FCode (Decls, a) Source

data Named Source

The environment contains variable definitions or blockids.

Constructors

VarN CmmExpr | Holds CmmLit(CmmLabel ..) which gives the label type, eg, RtsLabel, ForeignLabel, CmmLabel etc.
FunN PackageKey | A function name from this package
LabelN BlockId | A blockid of some code or data.

type Env = UniqFM Named Source

An environment of named things.

loopDecls :: CmmParse a -> CmmParse a Source

Takes the variable decarations and imports from the monad and makes an environment, which is looped back into the computation. In this way, we can have embedded declarations that scope over the whole procedure, and imports that scope over the entire module. Discards the local declaration contained within decl'

getEnv :: CmmParse Env Source

Get the current environment from the monad.

withName :: String -> CmmParse a -> CmmParse a Source

Set context name for a sub-parse

getName :: CmmParse String Source

Get the current context name from the monad

newLocal Source

Arguments

:: CmmType | data type
-> FastString | name of variable
-> CmmParse LocalReg | register holding the value

Create a fresh local variable of a given type.

newLabel :: FastString -> CmmParse BlockId Source

Allocate a fresh label.

newBlockId :: CmmParse BlockId Source

newFunctionName Source

Arguments

:: FastString | name of the function
-> PackageKey | package of the current module
-> ExtCode |

Add add a local function to the environment.

newImport :: (FastString, CLabel) -> CmmParse () Source

Add an imported foreign label to the list of local declarations. If this is done at the start of the module the declaration will scope over the whole module.

lookupLabel :: FastString -> CmmParse BlockId Source

Lookup the BlockId bound to the label with this name. If one hasn't been bound yet, create a fresh one based on the Unique of the name.

lookupName :: FastString -> CmmParse CmmExpr Source

Lookup the location of a named variable. Unknown names are treated as if they had been 'import'ed from the runtime system. This saves us a lot of bother in the RTS sources, at the expense of deferring some errors to link time.

code :: FCode a -> CmmParse a Source

Lift an FCode computation into the CmmParse monad

emit :: CmmAGraph -> CmmParse () Source

emitLabel :: BlockId -> CmmParse () Source

emitAssign :: CmmReg -> CmmExpr -> CmmParse () Source

emitStore :: CmmExpr -> CmmExpr -> CmmParse () Source

getCode :: CmmParse a -> CmmParse CmmAGraph Source

getCodeR :: CmmParse a -> CmmParse (a, CmmAGraph) Source

getCodeScoped :: CmmParse a -> CmmParse (a, CmmAGraphScoped) Source

emitOutOfLine :: BlockId -> CmmAGraphScoped -> CmmParse () Source

withUpdFrameOff :: UpdFrameOffset -> CmmParse () -> CmmParse () Source

getUpdFrameOff :: CmmParse UpdFrameOffset Source