HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleghc-9.10.3GHC2021

GHC.CmmToAsm.Wasm.Types

  • 23 types
  • 10 values
  • Packageghc-9.10.3
  • Exports33
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceTypes.hs
datadata WasmType
#

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

Instances1TestEquality
newtypenewtype SymName
#

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

Constructors

Instances5Eq, Ord, Show, IsString, Uniquable
  • Eq SymNameDefined in ghc-9.10.3 · GHC.CmmToAsm.Wasm.Types
  • Ord SymNameDefined in ghc-9.10.3 · GHC.CmmToAsm.Wasm.Types
  • Show SymNameDefined in ghc-9.10.3 · GHC.CmmToAsm.Wasm.Types
  • IsString SymNameDefined in ghc-9.10.3 · GHC.CmmToAsm.Wasm.Types
  • Uniquable SymNameDefined in ghc-9.10.3 · GHC.CmmToAsm.Wasm.Types
datadata SymVisibility
#

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 ]
datadata SymKind
#

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.

Instances1Eq
  • Eq SymKindDefined in ghc-9.10.3 · GHC.CmmToAsm.Wasm.Types
datadata WasmInstr (a :: WasmType) (b :: [WasmType]) (c :: [WasmType]) where
#

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

datadata WasmControl a b (c :: [WasmType]) (d :: [WasmType]) where
#

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

datadata WasmCodeGenState (w :: WasmType)
#

Constructors