ghc-7.0.4: The GHC API

CmmExpr

Synopsis

- data CmmType
- b8 :: CmmType
- b16 :: CmmType
- b32 :: CmmType
- b64 :: CmmType
- f32 :: CmmType
- f64 :: CmmType
- bWord :: CmmType
- bHalfWord :: CmmType
- gcWord :: CmmType
- cInt :: CmmType
- cLong :: CmmType
- cmmBits :: Width -> CmmType
- cmmFloat :: Width -> CmmType
- typeWidth :: CmmType -> Width
- cmmEqType :: CmmType -> CmmType -> Bool
- cmmEqType_ignoring_ptrhood :: CmmType -> CmmType -> Bool
- isFloatType :: CmmType -> Bool
- isGcPtrType :: CmmType -> Bool
- isWord32 :: CmmType -> Bool
- isWord64 :: CmmType -> Bool
- isFloat64 :: CmmType -> Bool
- isFloat32 :: CmmType -> Bool
- data Width
  - = W8
  - | W16
  - | W32
  - | W64
  - | W80
  - | W128
- widthInBits :: Width -> Int
- widthInBytes :: Width -> Int
- widthInLog :: Width -> Int
- widthFromBytes :: Int -> Width
- wordWidth :: Width
- halfWordWidth :: Width
- cIntWidth :: Width
- cLongWidth :: Width
- narrowU :: Width -> Integer -> Integer
- narrowS :: Width -> Integer -> Integer
- data CmmExpr
  - = CmmLit CmmLit
  - | CmmLoad CmmExpr CmmType
  - | CmmReg CmmReg
  - | CmmMachOp MachOp [CmmExpr]
  - | CmmStackSlot Area Int
  - | CmmRegOff CmmReg Int
- cmmExprType :: CmmExpr -> CmmType
- cmmExprWidth :: CmmExpr -> Width
- maybeInvertCmmExpr :: CmmExpr -> Maybe CmmExpr
- data CmmReg
  - = CmmLocal LocalReg
  - | CmmGlobal GlobalReg
- cmmRegType :: CmmReg -> CmmType
- data CmmLit
  - = CmmInt Integer Width
  - | CmmFloat Rational Width
  - | CmmLabel CLabel
  - | CmmLabelOff CLabel Int
  - | CmmLabelDiffOff CLabel CLabel Int
  - | CmmBlock BlockId
  - | CmmHighStackMark
- cmmLitType :: CmmLit -> CmmType
- data LocalReg = LocalReg !Unique CmmType
- localRegType :: LocalReg -> CmmType
- data GlobalReg
  - = VanillaReg !Int VGcPtr
  - | FloatReg !Int
  - | DoubleReg !Int
  - | LongReg !Int
  - | Sp
  - | SpLim
  - | Hp
  - | HpLim
  - | CurrentTSO
  - | CurrentNursery
  - | HpAlloc
  - | EagerBlackholeInfo
  - | GCEnter1
  - | GCFun
  - | BaseReg
  - | PicBaseReg
- globalRegType :: GlobalReg -> CmmType
- spReg :: CmmReg
- hpReg :: CmmReg
- spLimReg :: CmmReg
- nodeReg :: CmmReg
- node :: GlobalReg
- data VGcPtr
  - = VGcPtr
  - | VNonGcPtr
- vgcFlag :: CmmType -> VGcPtr
- class DefinerOfLocalRegs a where
  - foldRegsDefd :: (b -> LocalReg -> b) -> b -> a -> b
- class UserOfLocalRegs a where
  - foldRegsUsed :: (b -> LocalReg -> b) -> b -> a -> b
- filterRegsUsed :: UserOfLocalRegs e => (LocalReg -> Bool) -> e -> RegSet
- class DefinerOfSlots a where
  - foldSlotsDefd :: (b -> SubArea -> b) -> b -> a -> b
- class UserOfSlots a where
  - foldSlotsUsed :: (b -> SubArea -> b) -> b -> a -> b
- type RegSet = UniqSet LocalReg
- emptyRegSet :: RegSet
- elemRegSet :: LocalReg -> RegSet -> Bool
- extendRegSet :: RegSet -> LocalReg -> RegSet
- deleteFromRegSet :: RegSet -> LocalReg -> RegSet
- mkRegSet :: [LocalReg] -> RegSet
- plusRegSet :: RegSet -> RegSet -> RegSet
- minusRegSet :: RegSet -> RegSet -> RegSet
- timesRegSet :: RegSet -> RegSet -> RegSet
- regUsedIn :: CmmReg -> CmmExpr -> Bool
- data Area
  - = RegSlot LocalReg
  - | CallArea AreaId
- data AreaId
  - = Old
  - | Young BlockId
- type SubArea = (Area, Int, Int)
- type SubAreaSet = Map Area [SubArea]
- type AreaMap = Map Area Int
- isStackSlotOf :: CmmExpr -> LocalReg -> Bool
- data MachOp
  - = MO_Add Width
  - | MO_Sub Width
  - | MO_Eq Width
  - | MO_Ne Width
  - | MO_Mul Width
  - | MO_S_MulMayOflo Width
  - | MO_S_Quot Width
  - | MO_S_Rem Width
  - | MO_S_Neg Width
  - | MO_U_MulMayOflo Width
  - | MO_U_Quot Width
  - | MO_U_Rem Width
  - | MO_S_Ge Width
  - | MO_S_Le Width
  - | MO_S_Gt Width
  - | MO_S_Lt Width
  - | MO_U_Ge Width
  - | MO_U_Le Width
  - | MO_U_Gt Width
  - | MO_U_Lt Width
  - | MO_F_Add Width
  - | MO_F_Sub Width
  - | MO_F_Neg Width
  - | MO_F_Mul Width
  - | MO_F_Quot Width
  - | MO_F_Eq Width
  - | MO_F_Ne Width
  - | MO_F_Ge Width
  - | MO_F_Le Width
  - | MO_F_Gt Width
  - | MO_F_Lt Width
  - | MO_And Width
  - | MO_Or Width
  - | MO_Xor Width
  - | MO_Not Width
  - | MO_Shl Width
  - | MO_U_Shr Width
  - | MO_S_Shr Width
  - | MO_SF_Conv Width Width
  - | MO_FS_Conv Width Width
  - | MO_SS_Conv Width Width
  - | MO_UU_Conv Width Width
  - | MO_FF_Conv Width Width
- pprMachOp :: MachOp -> SDoc
- isCommutableMachOp :: MachOp -> Bool
- isAssociativeMachOp :: MachOp -> Bool
- isComparisonMachOp :: MachOp -> Bool
- machOpResultType :: MachOp -> [CmmType] -> CmmType
- machOpArgReps :: MachOp -> [Width]
- maybeInvertComparison :: MachOp -> Maybe MachOp
- mo_wordAdd :: MachOp
- mo_wordSub :: MachOp
- mo_wordEq :: MachOp
- mo_wordNe :: MachOp
- mo_wordMul :: MachOp
- mo_wordSQuot :: MachOp
- mo_wordSRem :: MachOp
- mo_wordSNeg :: MachOp
- mo_wordUQuot :: MachOp
- mo_wordURem :: MachOp
- mo_wordSGe :: MachOp
- mo_wordSLe :: MachOp
- mo_wordSGt :: MachOp
- mo_wordSLt :: MachOp
- mo_wordUGe :: MachOp
- mo_wordULe :: MachOp
- mo_wordUGt :: MachOp
- mo_wordULt :: MachOp
- mo_wordAnd :: MachOp
- mo_wordOr :: MachOp
- mo_wordXor :: MachOp
- mo_wordNot :: MachOp
- mo_wordShl :: MachOp
- mo_wordSShr :: MachOp
- mo_wordUShr :: MachOp
- mo_u_8To32 :: MachOp
- mo_s_8To32 :: MachOp
- mo_u_16To32 :: MachOp
- mo_s_16To32 :: MachOp
- mo_u_8ToWord :: MachOp
- mo_s_8ToWord :: MachOp
- mo_u_16ToWord :: MachOp
- mo_s_16ToWord :: MachOp
- mo_u_32ToWord :: MachOp
- mo_s_32ToWord :: MachOp
- mo_32To8 :: MachOp
- mo_32To16 :: MachOp
- mo_WordTo8 :: MachOp
- mo_WordTo16 :: MachOp
- mo_WordTo32 :: MachOp

# Documentation

data CmmType Source

Instances

Outputable CmmType |

b8 :: CmmType Source

b16 :: CmmType Source

b32 :: CmmType Source

b64 :: CmmType Source

f32 :: CmmType Source

f64 :: CmmType Source

bWord :: CmmType Source

bHalfWord :: CmmType Source

gcWord :: CmmType Source

cInt :: CmmType Source

cLong :: CmmType Source

cmmBits :: Width -> CmmType Source

cmmFloat :: Width -> CmmType Source

typeWidth :: CmmType -> Width Source

cmmEqType :: CmmType -> CmmType -> Bool Source

cmmEqType_ignoring_ptrhood :: CmmType -> CmmType -> Bool Source

isFloatType :: CmmType -> Bool Source

isGcPtrType :: CmmType -> Bool Source

isWord32 :: CmmType -> Bool Source

isWord64 :: CmmType -> Bool Source

isFloat64 :: CmmType -> Bool Source

isFloat32 :: CmmType -> Bool Source

data Width Source

Constructors

W8 |
W16 |
W32 |
W64 |
W80 |
W128 |

Instances

Eq Width |
Ord Width |
Show Width |
Outputable Width |

widthInBits :: Width -> Int Source

widthInBytes :: Width -> Int Source

widthInLog :: Width -> Int Source

widthFromBytes :: Int -> Width Source

wordWidth :: Width Source

halfWordWidth :: Width Source

cIntWidth :: Width Source

cLongWidth :: Width Source

narrowU :: Width -> Integer -> Integer Source

narrowS :: Width -> Integer -> Integer Source

data CmmExpr Source

Constructors

CmmLit CmmLit |
CmmLoad CmmExpr CmmType |
CmmReg CmmReg |
CmmMachOp MachOp [CmmExpr] |
CmmStackSlot Area Int |
CmmRegOff CmmReg Int |

Instances

Eq CmmExpr |
Outputable CmmExpr |
UserOfSlots CmmExpr |
UserOfLocalRegs CmmExpr |

cmmExprType :: CmmExpr -> CmmType Source

cmmExprWidth :: CmmExpr -> Width Source

maybeInvertCmmExpr :: CmmExpr -> Maybe CmmExpr Source

data CmmReg Source

Constructors

CmmLocal LocalReg |
CmmGlobal GlobalReg |

Instances

Eq CmmReg |
Ord CmmReg |
Outputable CmmReg |
DefinerOfLocalRegs CmmReg |
UserOfLocalRegs CmmReg |

cmmRegType :: CmmReg -> CmmType Source

data CmmLit Source

Constructors

CmmInt Integer Width |
CmmFloat Rational Width |
CmmLabel CLabel |
CmmLabelOff CLabel Int |
CmmLabelDiffOff CLabel CLabel Int |
CmmBlock BlockId |
CmmHighStackMark |

Instances

Eq CmmLit |
Outputable CmmLit |

cmmLitType :: CmmLit -> CmmType Source

data LocalReg Source

Constructors

LocalReg !Unique CmmType | Parameters: 1. Identifier 2. Type

Instances

Eq LocalReg |
Ord LocalReg |
Outputable LocalReg |
Uniquable LocalReg |
DefinerOfLocalRegs LocalReg |
UserOfLocalRegs RegSet |
UserOfLocalRegs LocalReg |

localRegType :: LocalReg -> CmmType Source

data GlobalReg Source

Constructors

VanillaReg !Int VGcPtr |
FloatReg !Int |
DoubleReg !Int |
LongReg !Int |
Sp |
SpLim |
Hp |
HpLim |
CurrentTSO |
CurrentNursery |
HpAlloc |
EagerBlackholeInfo |
GCEnter1 |
GCFun |
BaseReg |
PicBaseReg |

Instances

Eq GlobalReg |
Ord GlobalReg |
Show GlobalReg |
Outputable GlobalReg |

globalRegType :: GlobalReg -> CmmType Source

spReg :: CmmReg Source

hpReg :: CmmReg Source

spLimReg :: CmmReg Source

nodeReg :: CmmReg Source

node :: GlobalReg Source

data VGcPtr Source

Constructors

VGcPtr |
VNonGcPtr |

Instances

Eq VGcPtr |
Show VGcPtr |

vgcFlag :: CmmType -> VGcPtr Source

class DefinerOfLocalRegs a where Source

Methods

foldRegsDefd :: (b -> LocalReg -> b) -> b -> a -> bSource

Instances

DefinerOfLocalRegs LocalReg |
DefinerOfLocalRegs CmmReg |
DefinerOfLocalRegs Last |
DefinerOfLocalRegs Middle |
DefinerOfLocalRegs a => DefinerOfLocalRegs [a] |
DefinerOfLocalRegs a => DefinerOfLocalRegs (Maybe a) |
DefinerOfLocalRegs a => DefinerOfLocalRegs (CmmHinted a) |

class UserOfLocalRegs a where Source

Methods

foldRegsUsed :: (b -> LocalReg -> b) -> b -> a -> bSource

Instances

UserOfLocalRegs RegSet |
UserOfLocalRegs LocalReg |
UserOfLocalRegs CmmReg |
UserOfLocalRegs CmmExpr |
UserOfLocalRegs CmmCallTarget |
UserOfLocalRegs CmmStmt | enable us to fold used registers over `CmmActuals` and `CmmFormals`
UserOfLocalRegs MidCallTarget |
UserOfLocalRegs Last |
UserOfLocalRegs Middle |
UserOfLocalRegs a => UserOfLocalRegs [a] |
UserOfLocalRegs a => UserOfLocalRegs (Maybe a) |
UserOfLocalRegs a => UserOfLocalRegs (CmmHinted a) |
UserOfLocalRegs i => UserOfLocalRegs (GenBasicBlock i) |
UserOfLocalRegs a => UserOfLocalRegs (ZLast a) |

filterRegsUsed :: UserOfLocalRegs e => (LocalReg -> Bool) -> e -> RegSet Source

class DefinerOfSlots a where Source

Methods

foldSlotsDefd :: (b -> SubArea -> b) -> b -> a -> bSource

Instances

DefinerOfSlots Last |
DefinerOfSlots Middle |
DefinerOfSlots l => DefinerOfSlots (ZLast l) |

class UserOfSlots a where Source

Methods

foldSlotsUsed :: (b -> SubArea -> b) -> b -> a -> bSource

Instances

UserOfSlots CmmExpr |
UserOfSlots CmmCallTarget |
UserOfSlots MidCallTarget |
UserOfSlots Last |
UserOfSlots Middle |
UserOfSlots a => UserOfSlots [a] |
UserOfSlots a => UserOfSlots (Maybe a) |
UserOfSlots a => UserOfSlots (CmmHinted a) |
UserOfSlots l => UserOfSlots (ZLast l) |

type RegSet = UniqSet LocalReg Source

Sets of local registers

emptyRegSet :: RegSet Source

elemRegSet :: LocalReg -> RegSet -> Bool Source

extendRegSet :: RegSet -> LocalReg -> RegSet Source

deleteFromRegSet :: RegSet -> LocalReg -> RegSet Source

mkRegSet :: [LocalReg] -> RegSet Source

plusRegSet :: RegSet -> RegSet -> RegSet Source

minusRegSet :: RegSet -> RegSet -> RegSet Source

timesRegSet :: RegSet -> RegSet -> RegSet Source

regUsedIn :: CmmReg -> CmmExpr -> Bool Source

data Area Source

A stack area is either the stack slot where a variable is spilled or the stack space where function arguments and results are passed.

Constructors

RegSlot LocalReg |
CallArea AreaId |

Instances

Eq Area |
Ord Area |
Outputable Area |

data AreaId Source

Constructors

Old |
Young BlockId |

Instances

Eq AreaId |
Ord AreaId |

type SubArea = (Area, Int, Int)Source

type SubAreaSet = Map Area [SubArea]Source

type AreaMap = Map Area Int Source

isStackSlotOf :: CmmExpr -> LocalReg -> Bool Source

data MachOp Source

Machine-level primops; ones which we can reasonably delegate to the native code generators to handle. Basically contains C's primops and no others.

Nomenclature: all ops indicate width and signedness, where appropriate. Widths: 8/16/32/64 means the given size, obviously. Nat means the operation works on STG word sized objects. Signedness: S means signed, U means unsigned. For operations where signedness is irrelevant or makes no difference (for example integer add), the signedness component is omitted.

An exception: NatP is a ptr-typed native word. From the point of view of the native code generators this distinction is irrelevant, but the C code generator sometimes needs this info to emit the right casts.

Constructors

MO_Add Width |
MO_Sub Width |
MO_Eq Width |
MO_Ne Width |
MO_Mul Width |
MO_S_MulMayOflo Width |
MO_S_Quot Width |
MO_S_Rem Width |
MO_S_Neg Width |
MO_U_MulMayOflo Width |
MO_U_Quot Width |
MO_U_Rem Width |
MO_S_Ge Width |
MO_S_Le Width |
MO_S_Gt Width |
MO_S_Lt Width |
MO_U_Ge Width |
MO_U_Le Width |
MO_U_Gt Width |
MO_U_Lt Width |
MO_F_Add Width |
MO_F_Sub Width |
MO_F_Neg Width |
MO_F_Mul Width |
MO_F_Quot Width |
MO_F_Eq Width |
MO_F_Ne Width |
MO_F_Ge Width |
MO_F_Le Width |
MO_F_Gt Width |
MO_F_Lt Width |
MO_And Width |
MO_Or Width |
MO_Xor Width |
MO_Not Width |
MO_Shl Width |
MO_U_Shr Width |
MO_S_Shr Width |
MO_SF_Conv Width Width |
MO_FS_Conv Width Width |
MO_SS_Conv Width Width |
MO_UU_Conv Width Width |
MO_FF_Conv Width Width |

Instances

Eq MachOp |
Show MachOp |

pprMachOp :: MachOp -> SDoc Source

isCommutableMachOp :: MachOp -> Bool Source

Returns `True` if the MachOp has commutable arguments. This is used in the platform-independent Cmm optimisations.

If in doubt, return `False`. This generates worse code on the native routes, but is otherwise harmless.

isAssociativeMachOp :: MachOp -> Bool Source

Returns `True` if the MachOp is associative (i.e. `(x+y)+z == x+(y+z)`) This is used in the platform-independent Cmm optimisations.

If in doubt, return `False`. This generates worse code on the native routes, but is otherwise harmless.

isComparisonMachOp :: MachOp -> Bool Source

Returns `True` if the MachOp is a comparison.

If in doubt, return False. This generates worse code on the native routes, but is otherwise harmless.

machOpResultType :: MachOp -> [CmmType] -> CmmType Source

Returns the MachRep of the result of a MachOp.

machOpArgReps :: MachOp -> [Width]Source

This function is used for debugging only: we can check whether an application of a MachOp is type-correct by checking that the MachReps of its arguments are the same as the MachOp expects. This is used when linting a CmmExpr.

maybeInvertComparison :: MachOp -> Maybe MachOp Source

mo_wordAdd :: MachOp Source

mo_wordSub :: MachOp Source

mo_wordEq :: MachOp Source

mo_wordNe :: MachOp Source

mo_wordMul :: MachOp Source

mo_wordSQuot :: MachOp Source

mo_wordSRem :: MachOp Source

mo_wordSNeg :: MachOp Source

mo_wordUQuot :: MachOp Source

mo_wordURem :: MachOp Source

mo_wordSGe :: MachOp Source

mo_wordSLe :: MachOp Source

mo_wordSGt :: MachOp Source

mo_wordSLt :: MachOp Source

mo_wordUGe :: MachOp Source

mo_wordULe :: MachOp Source

mo_wordUGt :: MachOp Source

mo_wordULt :: MachOp Source

mo_wordAnd :: MachOp Source

mo_wordOr :: MachOp Source

mo_wordXor :: MachOp Source

mo_wordNot :: MachOp Source

mo_wordShl :: MachOp Source

mo_wordSShr :: MachOp Source

mo_wordUShr :: MachOp Source

mo_u_8To32 :: MachOp Source

mo_s_8To32 :: MachOp Source

mo_u_16To32 :: MachOp Source

mo_s_16To32 :: MachOp Source

mo_u_8ToWord :: MachOp Source

mo_s_8ToWord :: MachOp Source

mo_u_16ToWord :: MachOp Source

mo_s_16ToWord :: MachOp Source

mo_u_32ToWord :: MachOp Source

mo_s_32ToWord :: MachOp Source

mo_32To8 :: MachOp Source

mo_32To16 :: MachOp Source

mo_WordTo8 :: MachOp Source

mo_WordTo16 :: MachOp Source

mo_WordTo32 :: MachOp Source