CmmMachOp

ghc-8.10.5: The GHC API

Safe Haskell | None
Language | Haskell2010

CmmMachOp

Synopsis

- 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_XX_Conv Width Width
  - | MO_FF_Conv Width Width
  - | MO_V_Insert Length Width
  - | MO_V_Extract Length Width
  - | MO_V_Add Length Width
  - | MO_V_Sub Length Width
  - | MO_V_Mul Length Width
  - | MO_VS_Quot Length Width
  - | MO_VS_Rem Length Width
  - | MO_VS_Neg Length Width
  - | MO_VU_Quot Length Width
  - | MO_VU_Rem Length Width
  - | MO_VF_Insert Length Width
  - | MO_VF_Extract Length Width
  - | MO_VF_Add Length Width
  - | MO_VF_Sub Length Width
  - | MO_VF_Neg Length Width
  - | MO_VF_Mul Length Width
  - | MO_VF_Quot Length Width
  - | MO_AlignmentCheck Int Width
- pprMachOp :: MachOp -> SDoc
- isCommutableMachOp :: MachOp -> Bool
- isAssociativeMachOp :: MachOp -> Bool
- isComparisonMachOp :: MachOp -> Bool
- maybeIntComparison :: MachOp -> Maybe Width
- machOpResultType :: DynFlags -> MachOp -> [CmmType] -> CmmType
- machOpArgReps :: DynFlags -> MachOp -> [Width]
- maybeInvertComparison :: MachOp -> Maybe MachOp
- isFloatComparison :: MachOp -> Bool
- mo_wordAdd :: DynFlags -> MachOp
- mo_wordSub :: DynFlags -> MachOp
- mo_wordEq :: DynFlags -> MachOp
- mo_wordNe :: DynFlags -> MachOp
- mo_wordMul :: DynFlags -> MachOp
- mo_wordSQuot :: DynFlags -> MachOp
- mo_wordSRem :: DynFlags -> MachOp
- mo_wordSNeg :: DynFlags -> MachOp
- mo_wordUQuot :: DynFlags -> MachOp
- mo_wordURem :: DynFlags -> MachOp
- mo_wordSGe :: DynFlags -> MachOp
- mo_wordSLe :: DynFlags -> MachOp
- mo_wordSGt :: DynFlags -> MachOp
- mo_wordSLt :: DynFlags -> MachOp
- mo_wordUGe :: DynFlags -> MachOp
- mo_wordULe :: DynFlags -> MachOp
- mo_wordUGt :: DynFlags -> MachOp
- mo_wordULt :: DynFlags -> MachOp
- mo_wordAnd :: DynFlags -> MachOp
- mo_wordOr :: DynFlags -> MachOp
- mo_wordXor :: DynFlags -> MachOp
- mo_wordNot :: DynFlags -> MachOp
- mo_wordShl :: DynFlags -> MachOp
- mo_wordSShr :: DynFlags -> MachOp
- mo_wordUShr :: DynFlags -> MachOp
- mo_u_8To32 :: MachOp
- mo_s_8To32 :: MachOp
- mo_u_16To32 :: MachOp
- mo_s_16To32 :: MachOp
- mo_u_8ToWord :: DynFlags -> MachOp
- mo_s_8ToWord :: DynFlags -> MachOp
- mo_u_16ToWord :: DynFlags -> MachOp
- mo_s_16ToWord :: DynFlags -> MachOp
- mo_u_32ToWord :: DynFlags -> MachOp
- mo_s_32ToWord :: DynFlags -> MachOp
- mo_32To8 :: MachOp
- mo_32To16 :: MachOp
- mo_WordTo8 :: DynFlags -> MachOp
- mo_WordTo16 :: DynFlags -> MachOp
- mo_WordTo32 :: DynFlags -> MachOp
- mo_WordTo64 :: DynFlags -> MachOp
- data CallishMachOp
  - = MO_F64_Pwr
  - | MO_F64_Sin
  - | MO_F64_Cos
  - | MO_F64_Tan
  - | MO_F64_Sinh
  - | MO_F64_Cosh
  - | MO_F64_Tanh
  - | MO_F64_Asin
  - | MO_F64_Acos
  - | MO_F64_Atan
  - | MO_F64_Asinh
  - | MO_F64_Acosh
  - | MO_F64_Atanh
  - | MO_F64_Log
  - | MO_F64_Log1P
  - | MO_F64_Exp
  - | MO_F64_ExpM1
  - | MO_F64_Fabs
  - | MO_F64_Sqrt
  - | MO_F32_Pwr
  - | MO_F32_Sin
  - | MO_F32_Cos
  - | MO_F32_Tan
  - | MO_F32_Sinh
  - | MO_F32_Cosh
  - | MO_F32_Tanh
  - | MO_F32_Asin
  - | MO_F32_Acos
  - | MO_F32_Atan
  - | MO_F32_Asinh
  - | MO_F32_Acosh
  - | MO_F32_Atanh
  - | MO_F32_Log
  - | MO_F32_Log1P
  - | MO_F32_Exp
  - | MO_F32_ExpM1
  - | MO_F32_Fabs
  - | MO_F32_Sqrt
  - | MO_UF_Conv Width
  - | MO_S_QuotRem Width
  - | MO_U_QuotRem Width
  - | MO_U_QuotRem2 Width
  - | MO_Add2 Width
  - | MO_AddWordC Width
  - | MO_SubWordC Width
  - | MO_AddIntC Width
  - | MO_SubIntC Width
  - | MO_U_Mul2 Width
  - | MO_ReadBarrier
  - | MO_WriteBarrier
  - | MO_Touch
  - | MO_Prefetch_Data Int
  - | MO_Memcpy Int
  - | MO_Memset Int
  - | MO_Memmove Int
  - | MO_Memcmp Int
  - | MO_PopCnt Width
  - | MO_Pdep Width
  - | MO_Pext Width
  - | MO_Clz Width
  - | MO_Ctz Width
  - | MO_BSwap Width
  - | MO_BRev Width
  - | MO_AtomicRMW Width AtomicMachOp
  - | MO_AtomicRead Width
  - | MO_AtomicWrite Width
  - | MO_Cmpxchg Width
- callishMachOpHints :: CallishMachOp -> ([ForeignHint], [ForeignHint])
- callishMachOpReps :: CallishMachOp -> (PrimRep, [PrimRep])
- pprCallishMachOp :: CallishMachOp -> SDoc
- machOpMemcpyishAlign :: CallishMachOp -> Maybe Int
- data AtomicMachOp
  - = AMO_Add
  - | AMO_Sub
  - | AMO_And
  - | AMO_Nand
  - | AMO_Or
  - | AMO_Xor

# Documentation

data MachOp Source #

Machine-level primops; ones which we can reasonably delegate to the native code generators to handle.

Most operations are parameterised by the `Width` that they operate on. Some operations have separate signed and unsigned versions, and float and integer versions.

Note that there are variety of places in the native code generator where we assume that the code produced for a MachOp does not introduce new blocks.

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_XX_Conv Width Width |
MO_FF_Conv Width Width |
MO_V_Insert Length Width |
MO_V_Extract Length Width |
MO_V_Add Length Width |
MO_V_Sub Length Width |
MO_V_Mul Length Width |
MO_VS_Quot Length Width |
MO_VS_Rem Length Width |
MO_VS_Neg Length Width |
MO_VU_Quot Length Width |
MO_VU_Rem Length Width |
MO_VF_Insert Length Width |
MO_VF_Extract Length Width |
MO_VF_Add Length Width |
MO_VF_Sub Length Width |
MO_VF_Neg Length Width |
MO_VF_Mul Length Width |
MO_VF_Quot Length Width |
MO_AlignmentCheck Int Width |

#### Instances

Instances details

Eq MachOp # |
Instance details Defined in CmmMachOp Methods (==) :: MachOp -> MachOp -> Bool # (/=) :: MachOp -> MachOp -> Bool #
Show MachOp # |
Instance details Defined in CmmMachOp Methods showsPrec :: Int -> MachOp -> ShowS Source # show :: MachOp -> String Source # showList :: [MachOp] -> ShowS Source #

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.

maybeIntComparison :: MachOp -> Maybe Width Source #

Returns `Just w` if the operation is an integer comparison with width `w`, or `Nothing` otherwise.

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

Returns the MachRep of the result of a MachOp.

machOpArgReps :: DynFlags -> 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 #

isFloatComparison :: MachOp -> Bool Source #

mo_wordAdd :: DynFlags -> MachOp Source #

mo_wordSub :: DynFlags -> MachOp Source #

mo_wordEq :: DynFlags -> MachOp Source #

mo_wordNe :: DynFlags -> MachOp Source #

mo_wordMul :: DynFlags -> MachOp Source #

mo_wordSQuot :: DynFlags -> MachOp Source #

mo_wordSRem :: DynFlags -> MachOp Source #

mo_wordSNeg :: DynFlags -> MachOp Source #

mo_wordUQuot :: DynFlags -> MachOp Source #

mo_wordURem :: DynFlags -> MachOp Source #

mo_wordSGe :: DynFlags -> MachOp Source #

mo_wordSLe :: DynFlags -> MachOp Source #

mo_wordSGt :: DynFlags -> MachOp Source #

mo_wordSLt :: DynFlags -> MachOp Source #

mo_wordUGe :: DynFlags -> MachOp Source #

mo_wordULe :: DynFlags -> MachOp Source #

mo_wordUGt :: DynFlags -> MachOp Source #

mo_wordULt :: DynFlags -> MachOp Source #

mo_wordAnd :: DynFlags -> MachOp Source #

mo_wordOr :: DynFlags -> MachOp Source #

mo_wordXor :: DynFlags -> MachOp Source #

mo_wordNot :: DynFlags -> MachOp Source #

mo_wordShl :: DynFlags -> MachOp Source #

mo_wordSShr :: DynFlags -> MachOp Source #

mo_wordUShr :: DynFlags -> 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 :: DynFlags -> MachOp Source #

mo_s_8ToWord :: DynFlags -> MachOp Source #

mo_u_16ToWord :: DynFlags -> MachOp Source #

mo_s_16ToWord :: DynFlags -> MachOp Source #

mo_u_32ToWord :: DynFlags -> MachOp Source #

mo_s_32ToWord :: DynFlags -> MachOp Source #

mo_32To8 :: MachOp Source #

mo_32To16 :: MachOp Source #

mo_WordTo8 :: DynFlags -> MachOp Source #

mo_WordTo16 :: DynFlags -> MachOp Source #

mo_WordTo32 :: DynFlags -> MachOp Source #

mo_WordTo64 :: DynFlags -> MachOp Source #

data CallishMachOp Source #

Constructors

MO_F64_Pwr |
MO_F64_Sin |
MO_F64_Cos |
MO_F64_Tan |
MO_F64_Sinh |
MO_F64_Cosh |
MO_F64_Tanh |
MO_F64_Asin |
MO_F64_Acos |
MO_F64_Atan |
MO_F64_Asinh |
MO_F64_Acosh |
MO_F64_Atanh |
MO_F64_Log |
MO_F64_Log1P |
MO_F64_Exp |
MO_F64_ExpM1 |
MO_F64_Fabs |
MO_F64_Sqrt |
MO_F32_Pwr |
MO_F32_Sin |
MO_F32_Cos |
MO_F32_Tan |
MO_F32_Sinh |
MO_F32_Cosh |
MO_F32_Tanh |
MO_F32_Asin |
MO_F32_Acos |
MO_F32_Atan |
MO_F32_Asinh |
MO_F32_Acosh |
MO_F32_Atanh |
MO_F32_Log |
MO_F32_Log1P |
MO_F32_Exp |
MO_F32_ExpM1 |
MO_F32_Fabs |
MO_F32_Sqrt |
MO_UF_Conv Width |
MO_S_QuotRem Width |
MO_U_QuotRem Width |
MO_U_QuotRem2 Width |
MO_Add2 Width |
MO_AddWordC Width |
MO_SubWordC Width |
MO_AddIntC Width |
MO_SubIntC Width |
MO_U_Mul2 Width |
MO_ReadBarrier |
MO_WriteBarrier |
MO_Touch |
MO_Prefetch_Data Int |
MO_Memcpy Int |
MO_Memset Int |
MO_Memmove Int |
MO_Memcmp Int |
MO_PopCnt Width |
MO_Pdep Width |
MO_Pext Width |
MO_Clz Width |
MO_Ctz Width |
MO_BSwap Width |
MO_BRev Width |
MO_AtomicRMW Width AtomicMachOp |
MO_AtomicRead Width |
MO_AtomicWrite Width |
MO_Cmpxchg Width |

#### Instances

Instances details

Eq CallishMachOp # |
Instance details Defined in CmmMachOp Methods (==) :: CallishMachOp -> CallishMachOp -> Bool # (/=) :: CallishMachOp -> CallishMachOp -> Bool #
Show CallishMachOp # |
Instance details Defined in CmmMachOp Methods showsPrec :: Int -> CallishMachOp -> ShowS Source # show :: CallishMachOp -> String Source # showList :: [CallishMachOp] -> ShowS Source #

callishMachOpHints :: CallishMachOp -> ([ForeignHint], [ForeignHint]) Source #

callishMachOpReps :: CallishMachOp -> (PrimRep, [PrimRep]) Source #

pprCallishMachOp :: CallishMachOp -> SDoc Source #

machOpMemcpyishAlign :: CallishMachOp -> Maybe Int Source #

The alignment of a `memcpy`-ish operation.

data AtomicMachOp Source #

The operation to perform atomically.

Constructors

AMO_Add |
AMO_Sub |
AMO_And |
AMO_Nand |
AMO_Or |
AMO_Xor |

#### Instances

Instances details

Eq AtomicMachOp # |
Instance details Defined in CmmMachOp Methods (==) :: AtomicMachOp -> AtomicMachOp -> Bool # (/=) :: AtomicMachOp -> AtomicMachOp -> Bool #
Show AtomicMachOp # |
Instance details Defined in CmmMachOp Methods showsPrec :: Int -> AtomicMachOp -> ShowS Source # show :: AtomicMachOp -> String Source # showList :: [AtomicMachOp] -> ShowS Source #