Emscripten documentation in general, and this page in particular:
* https://github.com/kripken/emscripten/wiki/New-WebAssembly-Backend
-
+
Rust provides WebAssembly support integrated into Cargo. There are two
main options:
- wasm32-unknown-unknown, which provides a relatively minimal environment
; ModuleID = 'fib.bc'
source_filename = "fib.c"
; void swap(int* a, int* b);
-;
+;
; __attribute__ ((visibility ("default")))
; int fib(int n) {
; int i, t, a = 0, b = 1;
; All lifetime markers and attributes were removed.
source_filename = "fib.c"
; void swap(int* a, int* b);
-;
+;
; __attribute__ ((visibility ("default")))
; int fib(int n) {
; int i, t, a = 0, b = 1;
; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ]
; CHECK-NEXT: Segment: 0
; CHECK-NEXT: Size: 2
-; CHECK-NEXT: SegmentInfo:
+; CHECK-NEXT: SegmentInfo:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Name: .data
; CHECK-NEXT: Alignment: 0
; CHECK-NEXT: Flags: [ ]
; CHECK-NEXT: Segment: 3
; CHECK-NEXT: Size: 0
-; CHECK-NEXT: SegmentInfo:
+; CHECK-NEXT: SegmentInfo:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Name: .bss.g0
; CHECK-NEXT: Alignment: 2
ret i32 0
}
-; CHECK: Sections:
+; CHECK: Sections:
; CHECK-NEXT: - Type: TYPE
-; CHECK-NEXT: Signatures:
+; CHECK-NEXT: Signatures:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: ReturnType: I32
-; CHECK-NEXT: ParamTypes:
+; CHECK-NEXT: ParamTypes:
; CHECK-NEXT: - Type: IMPORT
-; CHECK-NEXT: Imports:
+; CHECK-NEXT: Imports:
; CHECK-NEXT: - Module: env
; CHECK-NEXT: Field: __linear_memory
; CHECK-NEXT: Kind: MEMORY
-; CHECK-NEXT: Memory:
+; CHECK-NEXT: Memory:
; CHECK-NEXT: Initial: 0x00000001
; CHECK-NEXT: - Module: env
; CHECK-NEXT: Field: __indirect_function_table
; CHECK-NEXT: Kind: TABLE
-; CHECK-NEXT: Table:
+; CHECK-NEXT: Table:
; CHECK-NEXT: ElemType: FUNCREF
-; CHECK-NEXT: Limits:
+; CHECK-NEXT: Limits:
; CHECK-NEXT: Initial: 0x00000000
; CHECK-NEXT: - Module: env
; CHECK-NEXT: Field: funcImport
; CHECK: - Type: DATA
-; CHECK-NEXT: Segments:
+; CHECK-NEXT: Segments:
; CHECK-NEXT: - SectionOffset: 6
; CHECK-NEXT: InitFlags: 0
; CHECK-NEXT: Offset:
; CHECK-NEXT: Flags: [ ]
; CHECK-NEXT: Segment: 2
; CHECK-NEXT: Size: 4
-; CHECK-NEXT: SegmentInfo:
+; CHECK-NEXT: SegmentInfo:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Name: .data.global0
; CHECK-NEXT: Alignment: 3
}
; CHECK: --- !WASM
-; CHECK-NEXT: FileHeader:
+; CHECK-NEXT: FileHeader:
; CHECK-NEXT: Version: 0x00000001
-; CHECK-NEXT: Sections:
+; CHECK-NEXT: Sections:
; CHECK-NEXT: - Type: TYPE
-; CHECK-NEXT: Signatures:
+; CHECK-NEXT: Signatures:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: ReturnType: NORESULT
; CHECK-NEXT: ParamTypes:
; CHECK: - Type: CUSTOM
; CHECK-NEXT: Name: linking
; CHECK-NEXT: Version: 2
-; CHECK-NEXT: SymbolTable:
+; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Name: foo
]
; CHECK: - Type: IMPORT
-; CHECK-NEXT: Imports:
+; CHECK-NEXT: Imports:
; CHECK-NEXT: - Module: env
; CHECK-NEXT: Field: __linear_memory
; CHECK-NEXT: Kind: MEMORY
-; CHECK-NEXT: Memory:
+; CHECK-NEXT: Memory:
; CHECK-NEXT: Initial: 0x00000001
; CHECK-NEXT: - Module: env
; CHECK-NEXT: Field: __indirect_function_table
; CHECK-NEXT: Kind: TABLE
-; CHECK-NEXT: Table:
+; CHECK-NEXT: Table:
; CHECK-NEXT: ElemType: FUNCREF
-; CHECK-NEXT: Limits:
+; CHECK-NEXT: Limits:
; CHECK-NEXT: Initial: 0x00000002
; CHECK-NEXT: - Module: env
; CHECK-NEXT: Field: func3
; CHECK-NEXT: - Type: FUNCTION
; CHECK-NEXT: FunctionTypes: [ 0, 1, 0, 1 ]
; CHECK-NEXT: - Type: ELEM
-; CHECK-NEXT: Segments:
-; CHECK-NEXT: - Offset:
+; CHECK-NEXT: Segments:
+; CHECK-NEXT: - Offset:
; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 1
; CHECK-NEXT: Functions: [ 5, 7 ]
; CHECK-NEXT: - Type: CODE
-; CHECK-NEXT: Relocations:
+; CHECK-NEXT: Relocations:
; CHECK-NEXT: - Type: R_WASM_FUNCTION_INDEX_LEB
; CHECK-NEXT: Index: 1
; CHECK-NEXT: Offset: 0x00000004
; CHECK-NEXT: - Type: R_WASM_FUNCTION_INDEX_LEB
; CHECK-NEXT: Index: 4
; CHECK-NEXT: Offset: 0x00000045
-; CHECK-NEXT: Functions:
+; CHECK-NEXT: Functions:
; CHECK-NEXT: - Index: 5
-; CHECK-NEXT: Locals:
+; CHECK-NEXT: Locals:
; CHECK-NEXT: Body: 1080808080000B
; CHECK-NEXT: - Index: 6
-; CHECK-NEXT: Locals:
+; CHECK-NEXT: Locals:
; CHECK-NEXT: Body: 02404181808080004100418080808000108180808000450D0000000B0B
; CHECK-NEXT: - Index: 7
-; CHECK-NEXT: Locals:
+; CHECK-NEXT: Locals:
; CHECK-NEXT: Body: 1082808080000B
; CHECK-NEXT: - Index: 8
-; CHECK-NEXT: Locals:
+; CHECK-NEXT: Locals:
; CHECK-NEXT: Body: 02404182808080004100418080808000108180808000450D0000000B0B
; CHECK-NEXT: - Type: DATA
-; CHECK-NEXT: Segments:
+; CHECK-NEXT: Segments:
; CHECK-NEXT: - SectionOffset: 6
; CHECK-NEXT: InitFlags: 0
; CHECK-NEXT: Offset:
; CHECK-NEXT: Name: .data.global1
; CHECK-NEXT: Alignment: 3
; CHECK-NEXT: Flags: [ ]
-; CHECK-NEXT: InitFunctions:
+; CHECK-NEXT: InitFunctions:
; CHECK-NEXT: - Priority: 42
; CHECK-NEXT: Symbol: 9
; CHECK-NEXT: - Priority: 42
attributes #0 = { "wasm-import-module"="bar" "wasm-import-name"="qux" }
; CHECK: - Type: IMPORT
-; CHECK-NEXT: Imports:
+; CHECK-NEXT: Imports:
; CHECK: - Module: bar
; CHECK-NEXT: Field: qux
; CHECK-NEXT: Kind: FUNCTION
}
; CHECK-NEXT: - Index: 1
-; CHECK-NEXT: Locals:
+; CHECK-NEXT: Locals:
; CHECK-NEXT: Body: 41002802030B
define i32 @load_i32_from_wrapped_address() {
%t = load i32, i32* inttoptr (i32 4294967299 to i32*)
; CHECK: - Type: DATA
-; CHECK-NEXT: Relocations:
+; CHECK-NEXT: Relocations:
; CHECK-NEXT: - Type: R_WASM_MEMORY_ADDR_I32
; CHECK-NEXT: Index: 0
; CHECK-NEXT: Offset: 0x0000001C
; CHECK-NEXT: - Type: R_WASM_MEMORY_ADDR_I32
; CHECK-NEXT: Index: 1
; CHECK-NEXT: Offset: 0x00000025
-; CHECK-NEXT: Segments:
+; CHECK-NEXT: Segments:
; CHECK-NEXT: - SectionOffset: 6
; CHECK-NEXT: InitFlags: 0
; CHECK-NEXT: Offset:
; CHECK-NEXT: - Type: CUSTOM
; CHECK-NEXT: Name: linking
; CHECK-NEXT: Version: 2
-; CHECK-NEXT: SymbolTable:
+; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: DATA
; CHECK-NEXT: Name: .L.str1
; CHECK-NEXT: Flags: [ ]
; CHECK-NEXT: Segment: 3
; CHECK-NEXT: Size: 4
-; CHECK-NEXT: SegmentInfo:
+; CHECK-NEXT: SegmentInfo:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Name: .rodata..L.str1
; CHECK-NEXT: Alignment: 0
}
; CHECK: - Type: IMPORT
-; CHECK-NEXT: Imports:
+; CHECK-NEXT: Imports:
; CHECK: - Module: env
; CHECK-NEXT: Field: __linear_memory
; CHECK: - Module: env
; CHECK-NEXT: Field: __indirect_function_table
-; CHECK: SymbolTable:
+; CHECK: SymbolTable:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Name: weak_function