ghc-9.6.3: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

GHC.CmmToAsm.Wasm.Types

Synopsis

- data WasmType
  - = I32
  - | I64
  - | F32
  - | F64
- data WasmTypeTag :: WasmType -> Type where
  - TagI32 :: WasmTypeTag 'I32
  - TagI64 :: WasmTypeTag 'I64
  - TagF32 :: WasmTypeTag 'F32
  - TagF64 :: WasmTypeTag 'F64
- data SomeWasmType where
  - SomeWasmType :: WasmTypeTag t -> SomeWasmType
- data TypeList :: [WasmType] -> Type where
  - TypeListNil :: TypeList '[]
  - TypeListCons :: WasmTypeTag t -> TypeList ts -> TypeList (t : ts)
- someWasmTypesFromTypeList :: TypeList ts -> [SomeWasmType]
- data WasmFunctionType pre post = WasmFunctionType {
  - ft_pops :: TypeList pre
  - ft_pushes :: TypeList post
  }
- newtype SymName = SymName FastString
- data SymVisibility
  - = SymUndefined
  - | SymStatic
  - | SymDefault
- data SymKind
  - = SymData
  - | SymFunc
- data DataSectionKind
  - = SectionData
  - | SectionROData
- data DataSectionContent
  - = DataI8 Word8
  - | DataI16 Word16
  - | DataI32 Word32
  - | DataI64 Word64
  - | DataF32 Float
  - | DataF64 Double
  - | DataSym SymName Int
  - | DataSkip Int
  - | DataASCII ByteString
  - | DataIncBin FilePath Int
- data DataSection = DataSection {
  - dataSectionKind :: DataSectionKind
  - dataSectionAlignment :: Alignment
  - dataSectionContents :: [DataSectionContent]
  }
- type GlobalInfo = (SymName, SomeWasmType)
- type LocalInfo = (Int, SomeWasmType)
- data FuncBody w = FuncBody {
  - funcLocals :: [SomeWasmType]
  - funcBody :: WasmControl (WasmStatements w) (WasmExpr w w) '[] '[w]
  }
- data Signage
  - = Signed
  - | Unsigned
- data WasmInstr :: WasmType -> [WasmType] -> [WasmType] -> Type where
  - WasmComment :: String -> WasmInstr w pre pre
  - WasmNop :: WasmInstr w pre pre
  - WasmDrop :: WasmInstr w (t : pre) pre
  - WasmUnreachable :: WasmInstr w pre post
  - WasmConst :: WasmTypeTag t -> Integer -> WasmInstr w pre (t : pre)
  - WasmSymConst :: SymName -> WasmInstr w pre (w : pre)
  - WasmLoad :: WasmTypeTag t -> Maybe Int -> Signage -> Int -> AlignmentSpec -> WasmInstr w (w : pre) (t : pre)
  - WasmStore :: WasmTypeTag t -> Maybe Int -> Int -> AlignmentSpec -> WasmInstr w (t : (w : pre)) pre
  - WasmGlobalGet :: WasmTypeTag t -> SymName -> WasmInstr w pre (t : pre)
  - WasmGlobalSet :: WasmTypeTag t -> SymName -> WasmInstr w (t : pre) pre
  - WasmLocalGet :: WasmTypeTag t -> Int -> WasmInstr w pre (t : pre)
  - WasmLocalSet :: WasmTypeTag t -> Int -> WasmInstr w (t : pre) pre
  - WasmLocalTee :: WasmTypeTag t -> Int -> WasmInstr w (t : pre) (t : pre)
  - WasmCCall :: SymName -> WasmInstr w pre post
  - WasmCCallIndirect :: TypeList arg_tys -> TypeList ret_tys -> WasmInstr w (w : pre) post
  - WasmConcat :: WasmInstr w pre mid -> WasmInstr w mid post -> WasmInstr w pre post
  - WasmReinterpret :: WasmTypeTag t0 -> WasmTypeTag t1 -> WasmInstr w (t0 : pre) (t1 : pre)
  - WasmTruncSat :: Signage -> WasmTypeTag t0 -> WasmTypeTag t1 -> WasmInstr w (t0 : pre) (t1 : pre)
  - WasmConvert :: Signage -> WasmTypeTag t0 -> WasmTypeTag t1 -> WasmInstr w (t0 : pre) (t1 : pre)
  - WasmAdd :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre)
  - WasmSub :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre)
  - WasmMul :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre)
  - WasmDiv :: Signage -> WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre)
  - WasmRem :: Signage -> WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre)
  - WasmAnd :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre)
  - WasmOr :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre)
  - WasmXor :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre)
  - WasmEq :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (w : pre)
  - WasmNe :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (w : pre)
  - WasmLt :: Signage -> WasmTypeTag t -> WasmInstr w (t : (t : pre)) (w : pre)
  - WasmGt :: Signage -> WasmTypeTag t -> WasmInstr w (t : (t : pre)) (w : pre)
  - WasmLe :: Signage -> WasmTypeTag t -> WasmInstr w (t : (t : pre)) (w : pre)
  - WasmGe :: Signage -> WasmTypeTag t -> WasmInstr w (t : (t : pre)) (w : pre)
  - WasmShl :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre)
  - WasmShr :: Signage -> WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre)
  - WasmI32Extend8S :: WasmInstr w ('I32 : pre) ('I32 : pre)
  - WasmI32Extend16S :: WasmInstr w ('I32 : pre) ('I32 : pre)
  - WasmI64Extend8S :: WasmInstr w ('I64 : pre) ('I64 : pre)
  - WasmI64Extend16S :: WasmInstr w ('I64 : pre) ('I64 : pre)
  - WasmI64Extend32S :: WasmInstr w ('I64 : pre) ('I64 : pre)
  - WasmI64ExtendI32 :: Signage -> WasmInstr w ('I32 : pre) ('I64 : pre)
  - WasmI32WrapI64 :: WasmInstr w ('I64 : pre) ('I32 : pre)
  - WasmF32DemoteF64 :: WasmInstr w ('F64 : pre) ('F32 : pre)
  - WasmF64PromoteF32 :: WasmInstr w ('F32 : pre) ('F64 : pre)
  - WasmAbs :: WasmTypeTag t -> WasmInstr w (t : pre) (t : pre)
  - WasmNeg :: WasmTypeTag t -> WasmInstr w (t : pre) (t : pre)
  - WasmCond :: WasmInstr w pre pre -> WasmInstr w (w : pre) pre
- newtype WasmExpr w t = WasmExpr (forall pre. WasmInstr w pre (t : pre))
- data SomeWasmExpr w where
  - SomeWasmExpr :: WasmTypeTag t -> WasmExpr w t -> SomeWasmExpr w
- newtype WasmStatements w = WasmStatements (forall pre. WasmInstr w pre pre)
- data WasmControl :: Type -> Type -> [WasmType] -> [WasmType] -> Type where
  - WasmPush :: WasmTypeTag t -> e -> WasmControl s e stack (t : stack)
  - WasmBlock :: WasmFunctionType pre post -> WasmControl s e pre post -> WasmControl s e pre post
  - WasmLoop :: WasmFunctionType pre post -> WasmControl s e pre post -> WasmControl s e pre post
  - WasmIfTop :: WasmFunctionType pre post -> WasmControl s e pre post -> WasmControl s e pre post -> WasmControl s e ('I32 : pre) post
  - WasmBr :: Int -> WasmControl s e dropped destination
  - WasmFallthrough :: WasmControl s e dropped destination
  - WasmBrTable :: e -> BrTableInterval -> [Int] -> Int -> WasmControl s e dropped destination
  - WasmTailCall :: e -> WasmControl s e t1star t2star
  - WasmActions :: s -> WasmControl s e stack stack
  - WasmSeq :: WasmControl s e pre mid -> WasmControl s e mid post -> WasmControl s e pre post
- data BrTableInterval = BrTableInterval {
  - bti_lo :: Integer
  - bti_count :: Integer
  }
- wasmControlCast :: WasmControl s e pre post -> WasmControl s e pre' post'
- data WasmCodeGenState w = WasmCodeGenState {
  - wasmPlatform :: Platform
  - defaultSyms :: SymSet
  - funcTypes :: SymMap ([SomeWasmType], [SomeWasmType])
  - funcBodies :: SymMap (FuncBody w)
  - dataSections :: SymMap DataSection
  - ctors :: [SymName]
  - localRegs :: UniqFM LocalReg LocalInfo
  - localRegsCount :: Int
  - wasmUniqSupply :: UniqSupply
  }
- initialWasmCodeGenState :: Platform -> UniqSupply -> WasmCodeGenState w
- newtype WasmCodeGenM w a = WasmCodeGenM (State (WasmCodeGenState w) a)
- wasmGetsM :: (WasmCodeGenState w -> a) -> WasmCodeGenM w a
- wasmPlatformM :: WasmCodeGenM w Platform
- wasmWordTypeM :: WasmCodeGenM w (WasmTypeTag w)
- wasmWordCmmTypeM :: WasmCodeGenM w CmmType
- wasmStateM :: (WasmCodeGenState w -> (# a, WasmCodeGenState w #)) -> WasmCodeGenM w a
- wasmModifyM :: (WasmCodeGenState w -> WasmCodeGenState w) -> WasmCodeGenM w ()
- wasmExecM :: WasmCodeGenM w a -> WasmCodeGenState w -> WasmCodeGenState w
- wasmUniq :: WasmCodeGenM w Unique

# Documentation

data WasmType Source #

WebAssembly type of a WebAssembly value that WebAssembly code could either expect on the evaluation stack or leave on the evaluation stack.

Constructors

I32 |
I64 |
F32 |
F64 |

#### Instances

Instances details

TestEquality WasmTypeTag Source # |
Instance details Defined in GHC.CmmToAsm.Wasm.Types Methods testEquality :: forall (a :: k) (b :: k). WasmTypeTag a -> WasmTypeTag b -> Maybe (a :~: b) Source #

data WasmTypeTag :: WasmType -> Type where Source #

Singleton type useful for programming with `WasmType` at the type level.

Constructors

TagI32 :: WasmTypeTag 'I32 |
TagI64 :: WasmTypeTag 'I64 |
TagF32 :: WasmTypeTag 'F32 |
TagF64 :: WasmTypeTag 'F64 |

#### Instances

Instances details

TestEquality WasmTypeTag Source # |
Instance details Defined in GHC.CmmToAsm.Wasm.Types Methods testEquality :: forall (a :: k) (b :: k). WasmTypeTag a -> WasmTypeTag b -> Maybe (a :~: b) Source #
Show (WasmTypeTag t) Source # |
Instance details Defined in GHC.CmmToAsm.Wasm.Types Methods showsPrec :: Int -> WasmTypeTag t -> ShowS Source # show :: WasmTypeTag t -> String Source # showList :: [WasmTypeTag t] -> ShowS Source #

data SomeWasmType where Source #

Constructors

SomeWasmType :: WasmTypeTag t -> SomeWasmType |

#### Instances

Instances details

Eq SomeWasmType Source # |
Instance details Defined in GHC.CmmToAsm.Wasm.Types Methods (==) :: SomeWasmType -> SomeWasmType -> Bool # (/=) :: SomeWasmType -> SomeWasmType -> Bool #

data TypeList :: [WasmType] -> Type where Source #

List of WebAssembly types used to describe the sequence of WebAssembly values that a block of code may expect on the stack or leave on the stack.

Constructors

TypeListNil :: TypeList '[] |
TypeListCons :: WasmTypeTag t -> TypeList ts -> TypeList (t : ts) |

someWasmTypesFromTypeList :: TypeList ts -> [SomeWasmType] Source #

data WasmFunctionType pre post Source #

The type of a WebAssembly function, loop, block, or conditional. This type says what values the code expects to pop off the stack and what values it promises to push. The WebAssembly standard requires that this type appear explicitly in the code.

Constructors

WasmFunctionType |

Fields

- ft_pops :: TypeList pre
- ft_pushes :: TypeList post

newtype SymName Source #

For simplicity, we record other metadata in `WasmCodeGenState` by need, instead of carrying them along with `SymName`.

Constructors

SymName FastString |

#### Instances

Instances details

IsString SymName Source # |
Instance details Defined in GHC.CmmToAsm.Wasm.Types Methods fromString :: String -> SymName Source #
Show SymName Source # |
Instance details Defined in GHC.CmmToAsm.Wasm.Types Methods showsPrec :: Int -> SymName -> ShowS Source # show :: SymName -> String Source # showList :: [SymName] -> ShowS Source #
Uniquable SymName Source # |
Instance details Defined in GHC.CmmToAsm.Wasm.Types Methods getUnique :: SymName -> Unique Source #
Eq SymName Source # |
Instance details Defined in GHC.CmmToAsm.Wasm.Types Methods (==) :: SymName -> SymName -> Bool # (/=) :: SymName -> SymName -> Bool #
Ord SymName Source # |
Instance details Defined in GHC.CmmToAsm.Wasm.Types Methods compare :: SymName -> SymName -> Ordering # (<) :: SymName -> SymName -> Bool # (<=) :: SymName -> SymName -> Bool # (>) :: SymName -> SymName -> Bool # (>=) :: SymName -> SymName -> Bool # max :: SymName -> SymName -> SymName # min :: SymName -> SymName -> SymName #

data SymVisibility Source #

Constructors

SymUndefined

Not defined in the current compilation unit.

    [ undefined binding=global vis=default ]

SymStatic

Defined, not visible to other compilation units.

    [ binding=local vis=default ]

SymDefault

Defined, visible to other compilation units.

Adds `.hidden` & `.globl` directives in the output assembly.

    [ binding=global vis=hidden ]

data SymKind Source #

Represents whether a symbol is a data symbol or a function symbol. Unlike linkers for other targets, `wasm-ld` does panic at link-time if it finds symbol kind inconsistency between the definition site and other use sites.

Currently we solely rely on `isCFunctionLabel` to determine a symbol's kind, but it does take extra effort to make it work. The main source of inconsistency arises from hand-written Cmm sources, where it's possible to refer to external entities like `xxx_info` and `xxx_closure` without explicit `import CLOSURE` declarations. The Cmm parser will implicitly assume those are foreign function labels, and then this will break the WebAssembly backend. #22368 provides more context on this issue.

tl;dr for any GHC contributor that accidentally triggers `wasm-ld` errors when hacking Cmm: whatever data symbols are used in new code, just add the corresponding `import CLOSURE` declarations at the top of that Cmm file.

Constructors

SymData |
SymFunc |

#### Instances

Instances details

Eq SymKind Source # |
Instance details Defined in GHC.CmmToAsm.Wasm.Types Methods (==) :: SymKind -> SymKind -> Bool # (/=) :: SymKind -> SymKind -> Bool #

data DataSectionKind Source #

WebAssembly doesn't really have proper read-only memory regions yet. Neverthless we add the .rodata logic here, wasm-ld will aggregate all .rodata sections into a single one, which adds possibility for runtime checks later, either via a customized runtime, or via code instrumentation. See https://github.com/llvm/llvm-project/blob/b296aed8ae239c20ebdd7969e978f8d2a3b9c178/lld/wasm/Writer.cpp#L856

Constructors

SectionData |
SectionROData |

data DataSectionContent Source #

Neither Cmm or Wasm type system takes integer signedness into account, therefore we always round up a `CmmExpr` to the right width and handle it as an untyped integer.

Constructors

DataI8 Word8 |
DataI16 Word16 |
DataI32 Word32 |
DataI64 Word64 |
DataF32 Float |
DataF64 Double |
DataSym SymName Int |
DataSkip Int |
DataASCII ByteString |
DataIncBin FilePath Int |

data DataSection Source #

Constructors

DataSection |

Fields

- dataSectionKind :: DataSectionKind
- dataSectionAlignment :: Alignment
- dataSectionContents :: [DataSectionContent]

type GlobalInfo = (SymName, SomeWasmType) Source #

type LocalInfo = (Int, SomeWasmType) Source #

data FuncBody w Source #

Constructors

FuncBody |

Fields

- funcLocals :: [SomeWasmType]
- funcBody :: WasmControl (WasmStatements w) (WasmExpr w w) '[] '[w]

  Most are Cmm functions, but may also contain synthesized function of other types, sigh.

data Signage Source #

Constructors

Signed |
Unsigned |

data WasmInstr :: WasmType -> [WasmType] -> [WasmType] -> Type where Source #

The `w` type variable in the Wasm IR stands for "platform word type", so `TagI32` on wasm32, and `TagI64` on wasm64. This way, we can make the codegen logic work on both wasm32/wasm64 in a type-safe manner.

Constructors

WasmComment :: String -> WasmInstr w pre pre |
WasmNop :: WasmInstr w pre pre |
WasmDrop :: WasmInstr w (t : pre) pre |
WasmUnreachable :: WasmInstr w pre post |
WasmConst :: WasmTypeTag t -> Integer -> WasmInstr w pre (t : pre) |
WasmSymConst :: SymName -> WasmInstr w pre (w : pre) |
WasmLoad :: WasmTypeTag t -> Maybe Int -> Signage -> Int -> AlignmentSpec -> WasmInstr w (w : pre) (t : pre) |
WasmStore :: WasmTypeTag t -> Maybe Int -> Int -> AlignmentSpec -> WasmInstr w (t : (w : pre)) pre |
WasmGlobalGet :: WasmTypeTag t -> SymName -> WasmInstr w pre (t : pre) |
WasmGlobalSet :: WasmTypeTag t -> SymName -> WasmInstr w (t : pre) pre |
WasmLocalGet :: WasmTypeTag t -> Int -> WasmInstr w pre (t : pre) |
WasmLocalSet :: WasmTypeTag t -> Int -> WasmInstr w (t : pre) pre |
WasmLocalTee :: WasmTypeTag t -> Int -> WasmInstr w (t : pre) (t : pre) |
WasmCCall :: SymName -> WasmInstr w pre post |
WasmCCallIndirect :: TypeList arg_tys -> TypeList ret_tys -> WasmInstr w (w : pre) post |
WasmConcat :: WasmInstr w pre mid -> WasmInstr w mid post -> WasmInstr w pre post |
WasmReinterpret :: WasmTypeTag t0 -> WasmTypeTag t1 -> WasmInstr w (t0 : pre) (t1 : pre) |
WasmTruncSat :: Signage -> WasmTypeTag t0 -> WasmTypeTag t1 -> WasmInstr w (t0 : pre) (t1 : pre) |
WasmConvert :: Signage -> WasmTypeTag t0 -> WasmTypeTag t1 -> WasmInstr w (t0 : pre) (t1 : pre) |
WasmAdd :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre) |
WasmSub :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre) |
WasmMul :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre) |
WasmDiv :: Signage -> WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre) |
WasmRem :: Signage -> WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre) |
WasmAnd :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre) |
WasmOr :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre) |
WasmXor :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre) |
WasmEq :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (w : pre) |
WasmNe :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (w : pre) |
WasmLt :: Signage -> WasmTypeTag t -> WasmInstr w (t : (t : pre)) (w : pre) |
WasmGt :: Signage -> WasmTypeTag t -> WasmInstr w (t : (t : pre)) (w : pre) |
WasmLe :: Signage -> WasmTypeTag t -> WasmInstr w (t : (t : pre)) (w : pre) |
WasmGe :: Signage -> WasmTypeTag t -> WasmInstr w (t : (t : pre)) (w : pre) |
WasmShl :: WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre) |
WasmShr :: Signage -> WasmTypeTag t -> WasmInstr w (t : (t : pre)) (t : pre) |
WasmI32Extend8S :: WasmInstr w ('I32 : pre) ('I32 : pre) |
WasmI32Extend16S :: WasmInstr w ('I32 : pre) ('I32 : pre) |
WasmI64Extend8S :: WasmInstr w ('I64 : pre) ('I64 : pre) |
WasmI64Extend16S :: WasmInstr w ('I64 : pre) ('I64 : pre) |
WasmI64Extend32S :: WasmInstr w ('I64 : pre) ('I64 : pre) |
WasmI64ExtendI32 :: Signage -> WasmInstr w ('I32 : pre) ('I64 : pre) |
WasmI32WrapI64 :: WasmInstr w ('I64 : pre) ('I32 : pre) |
WasmF32DemoteF64 :: WasmInstr w ('F64 : pre) ('F32 : pre) |
WasmF64PromoteF32 :: WasmInstr w ('F32 : pre) ('F64 : pre) |
WasmAbs :: WasmTypeTag t -> WasmInstr w (t : pre) (t : pre) |
WasmNeg :: WasmTypeTag t -> WasmInstr w (t : pre) (t : pre) |
WasmCond :: WasmInstr w pre pre -> WasmInstr w (w : pre) pre |

newtype WasmExpr w t Source #

Constructors

WasmExpr (forall pre. WasmInstr w pre (t : pre)) |

data SomeWasmExpr w where Source #

Constructors

SomeWasmExpr :: WasmTypeTag t -> WasmExpr w t -> SomeWasmExpr w |

newtype WasmStatements w Source #

Constructors

WasmStatements (forall pre. WasmInstr w pre pre) |

data WasmControl :: Type -> Type -> [WasmType] -> [WasmType] -> Type where Source #

Representation of WebAssembly control flow. Normally written as `WasmControl s e pre post` Type parameter `s` is the type of (unspecified) statements. It might be instantiated with an open Cmm block or with a sequence of Wasm instructions. Parameter `e` is the type of expressions. Parameter `pre` represents the values that are expected on the WebAssembly stack when the code runs, and `post` represents the state of the stack on completion.

Constructors

WasmPush :: WasmTypeTag t -> e -> WasmControl s e stack (t : stack) |
WasmBlock :: WasmFunctionType pre post -> WasmControl s e pre post -> WasmControl s e pre post |
WasmLoop :: WasmFunctionType pre post -> WasmControl s e pre post -> WasmControl s e pre post |
WasmIfTop :: WasmFunctionType pre post -> WasmControl s e pre post -> WasmControl s e pre post -> WasmControl s e ('I32 : pre) post |
WasmBr :: Int -> WasmControl s e dropped destination |
WasmFallthrough :: WasmControl s e dropped destination |
WasmBrTable :: e -> BrTableInterval -> [Int] -> Int -> WasmControl s e dropped destination |
WasmTailCall :: e -> WasmControl s e t1star t2star |
WasmActions :: s -> WasmControl s e stack stack |
WasmSeq :: WasmControl s e pre mid -> WasmControl s e mid post -> WasmControl s e pre post |

data BrTableInterval Source #

Constructors

BrTableInterval |

Fields

- bti_lo :: Integer
- bti_count :: Integer

#### Instances

Instances details

Show BrTableInterval Source # |
Instance details Defined in GHC.CmmToAsm.Wasm.Types Methods showsPrec :: Int -> BrTableInterval -> ShowS Source # show :: BrTableInterval -> String Source # showList :: [BrTableInterval] -> ShowS Source #
Outputable BrTableInterval Source # |
Instance details Defined in GHC.CmmToAsm.Wasm.Types Methods ppr :: BrTableInterval -> SDoc Source #

wasmControlCast :: WasmControl s e pre post -> WasmControl s e pre' post' Source #

data WasmCodeGenState w Source #

Constructors

WasmCodeGenState |

Fields

- wasmPlatform :: Platform

  Target platform

- defaultSyms :: SymSet

  Defined symbols with `SymDefault` visibility.

- funcTypes :: SymMap ([SomeWasmType], [SomeWasmType])

  Function types, defined or not. There may exist a function whose type is unknown (e.g. as a function pointer), in that case we fall back to () -> (), it's imperfect but works with wasm-ld.

- funcBodies :: SymMap (FuncBody w)

  Defined function bodies.

- dataSections :: SymMap DataSection

  Defined data sections.

- ctors :: [SymName]

  ctors in the current compilation unit.

- localRegs :: UniqFM LocalReg LocalInfo
- localRegsCount :: Int
- wasmUniqSupply :: UniqSupply

initialWasmCodeGenState :: Platform -> UniqSupply -> WasmCodeGenState w Source #

newtype WasmCodeGenM w a Source #

Constructors

WasmCodeGenM (State (WasmCodeGenState w) a) |

#### Instances

Instances details

Applicative (WasmCodeGenM w) Source # |

Instance details

Defined in GHC.CmmToAsm.Wasm.Types

Methods

pure :: a -> WasmCodeGenM w a Source #

(<*>) :: WasmCodeGenM w (a -> b) -> WasmCodeGenM w a -> WasmCodeGenM w b Source #

liftA2 :: (a -> b -> c) -> WasmCodeGenM w a -> WasmCodeGenM w b -> WasmCodeGenM w c Source #

(*>) :: WasmCodeGenM w a -> WasmCodeGenM w b -> WasmCodeGenM w b Source #

(<*) :: WasmCodeGenM w a -> WasmCodeGenM w b -> WasmCodeGenM w a Source #

Functor (WasmCodeGenM w) Source # |
Instance details Defined in GHC.CmmToAsm.Wasm.Types Methods fmap :: (a -> b) -> WasmCodeGenM w a -> WasmCodeGenM w b Source # (<$) :: a -> WasmCodeGenM w b -> WasmCodeGenM w a Source #
Monad (WasmCodeGenM w) Source # |
Instance details Defined in GHC.CmmToAsm.Wasm.Types Methods (>>=) :: WasmCodeGenM w a -> (a -> WasmCodeGenM w b) -> WasmCodeGenM w b Source # (>>) :: WasmCodeGenM w a -> WasmCodeGenM w b -> WasmCodeGenM w b Source # return :: a -> WasmCodeGenM w a Source #

wasmGetsM :: (WasmCodeGenState w -> a) -> WasmCodeGenM w a Source #

wasmPlatformM :: WasmCodeGenM w Platform Source #

wasmWordTypeM :: WasmCodeGenM w (WasmTypeTag w) Source #

wasmWordCmmTypeM :: WasmCodeGenM w CmmType Source #

wasmStateM :: (WasmCodeGenState w -> (# a, WasmCodeGenState w #)) -> WasmCodeGenM w a Source #

wasmModifyM :: (WasmCodeGenState w -> WasmCodeGenState w) -> WasmCodeGenM w () Source #

wasmExecM :: WasmCodeGenM w a -> WasmCodeGenState w -> WasmCodeGenState w Source #

wasmUniq :: WasmCodeGenM w Unique Source #