HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleghc-9.10.3GHC2021

GHC.Cmm.MachOp

  • 5 types
  • 54 values
  • Packageghc-9.10.3
  • Exports59
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceMachOp.hs
datadata MachOp
#

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.

Instances2Eq, Show
  • Eq MachOpDefined in ghc-9.10.3 · GHC.Cmm.MachOp
  • Show MachOpDefined in ghc-9.10.3 · GHC.Cmm.MachOp

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.

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.

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.

valuemachOpArgReps :: Platform -> MachOp -> [Width]
#

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.

datadata CallishMachOp
#

Constructors

Instances2Eq, Show
datadata FMASign
#

Where are the signs in a fused multiply-add instruction?

x*y + z vs x*y - z vs -x*y+z vs -x*y-z.

Warning: the signs aren't consistent across architectures (X86, PowerPC, AArch64). The user-facing implementation uses the X86 convention, while the relevant backends use their corresponding conventions.

Constructors

  • FMAdd

    Fused multiply-add x*y + z.

  • FMSub

    Fused multiply-subtract. On X86: x*y - z.

  • FNMAdd

    Fused multiply-add. On X86: -x*y + z.

  • FNMSub

    Fused multiply-subtract. On X86: -x*y - z.

Instances2Eq, Show
  • Eq FMASignDefined in ghc-9.10.3 · GHC.Cmm.MachOp
  • Show FMASignDefined in ghc-9.10.3 · GHC.Cmm.MachOp