linearscan-hoopl-1.0.0: Makes it easy to use the linearscan register allocator with Hoopl

Safe HaskellNone
LanguageHaskell2010

LinearScan.Hoopl

Documentation

class HooplNode nv => NodeAlloc nv nr | nv -> nr, nr -> nv where Source

Methods

isCall :: nv O O -> Bool Source

Return True if the operation node represents a call to another procedure.

isBranch :: nv O C -> Bool Source

Return True if the operation node is a branch at the end of a basic block. Often, the only other possibility is a return instruction.

retargetBranch :: nv O C -> Label -> Label -> nv O C Source

Given a branching node and a destination label, retarget the branch so it goes to the second label in place of the first.

mkLabelOp :: Label -> nv C O Source

Construct a label operation.

mkJumpOp :: Label -> nv O C Source

Construct a jump operation to the given label.

getReferences :: nv e x -> [VarInfo] Source

Given a node, return its list of VarInfo references.

setRegisters :: [((VarId, VarKind), PhysReg)] -> nv e x -> Env (nr e x) Source

Given a set of register allocations and an operation node, apply those allocations within the provided Env environment and produce a result node with the allocations applied.

mkMoveOps :: PhysReg -> VarId -> PhysReg -> Env [nr O O] Source

Construct operation(s) to move a variable's value from one register to another.

mkSaveOps :: PhysReg -> VarId -> Env [nr O O] Source

Construct operation(s) that spill a variable's value from a register to the spill stack.

mkRestoreOps :: VarId -> PhysReg -> Env [nr O O] Source

Construct operation(s) that load a variable's value into a register from the spill stack.

op1ToString :: nv e x -> String Source

Render the given operation node as a String.

allocateHoopl Source

Arguments

:: (NodeAlloc nv nr, NonLocal nv, NonLocal nr) 
=> Int

Number of machine registers available

-> Int

Offset of the spill stack in bytes

-> Int

Size of a spilled register in bytes

-> UseVerifier

Whether to use the runtime allocation verifier

-> Label

Entry label of the program graph

-> Graph nv C C

Hoopl program graph

-> (String, Either [String] (Graph nr C C))

Status dump and allocated blocks, or error w/ context