1 ; RUN: llc -filetype=asm -asm-verbose=false %s -o %t.s
2 ; RUN: FileCheck -check-prefix=ASM -input-file %t.s %s
3 ; RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=asm %t.s -o - | FileCheck -check-prefix=ASM %s
4 ; RUN: llc -filetype=obj %s -o - | obj2yaml | FileCheck %s
5 ; RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj %t.s -o - | obj2yaml | FileCheck %s
7 ; This specifically tests that we can generate a binary from the assembler
8 ; that produces the same binary as the backend would.
10 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
11 target triple = "wasm32-unknown-unknown"
15 define void @foo(i32 %n) {
21 ; Checking assembly is not the point of this test, but if something breaks
22 ; it is easier to spot it here than in the yaml output.
25 ; ASM: .file "assembler-binary.ll"
28 ; ASM-NEXT: .functype foo (i32) -> ()
30 ; ASM-NEXT: end_function
31 ; ASM: .functype bar () -> ()
35 ; CHECK-NEXT: FileHeader:
36 ; CHECK-NEXT: Version: 0x00000001
37 ; CHECK-NEXT: Sections:
38 ; CHECK-NEXT: - Type: TYPE
39 ; CHECK-NEXT: Signatures:
40 ; CHECK-NEXT: - Index: 0
41 ; CHECK-NEXT: ParamTypes:
43 ; CHECK-NEXT: ReturnTypes: []
44 ; CHECK-NEXT: - Index: 1
45 ; CHECK-NEXT: ParamTypes: []
46 ; CHECK-NEXT: ReturnTypes: []
47 ; CHECK-NEXT: - Type: IMPORT
48 ; CHECK-NEXT: Imports:
49 ; CHECK-NEXT: - Module: env
50 ; CHECK-NEXT: Field: __linear_memory
51 ; CHECK-NEXT: Kind: MEMORY
53 ; CHECK-NEXT: Initial: 0x00000000
54 ; CHECK-NEXT: - Module: env
55 ; CHECK-NEXT: Field: __indirect_function_table
56 ; CHECK-NEXT: Kind: TABLE
58 ; CHECK-NEXT: ElemType: FUNCREF
60 ; CHECK-NEXT: Initial: 0x00000000
61 ; CHECK-NEXT: - Module: env
62 ; CHECK-NEXT: Field: bar
63 ; CHECK-NEXT: Kind: FUNCTION
64 ; CHECK-NEXT: SigIndex: 1
65 ; CHECK-NEXT: - Type: FUNCTION
66 ; CHECK-NEXT: FunctionTypes: [ 0 ]
67 ; CHECK-NEXT: - Type: CODE
68 ; CHECK-NEXT: Relocations:
69 ; CHECK-NEXT: - Type: R_WASM_FUNCTION_INDEX_LEB
70 ; CHECK-NEXT: Index: 1
71 ; CHECK-NEXT: Offset: 0x00000004
72 ; CHECK-NEXT: Functions:
73 ; CHECK-NEXT: - Index: 1
74 ; CHECK-NEXT: Locals: []
75 ; CHECK-NEXT: Body: 1080808080000B
76 ; CHECK-NEXT: - Type: CUSTOM
77 ; CHECK-NEXT: Name: linking
78 ; CHECK-NEXT: Version: 2
79 ; CHECK-NEXT: SymbolTable:
80 ; CHECK-NEXT: - Index: 0
81 ; CHECK-NEXT: Kind: FUNCTION
82 ; CHECK-NEXT: Name: foo
83 ; CHECK-NEXT: Flags: [ ]
84 ; CHECK-NEXT: Function: 1
85 ; CHECK-NEXT: - Index: 1
86 ; CHECK-NEXT: Kind: FUNCTION
87 ; CHECK-NEXT: Name: bar
88 ; CHECK-NEXT: Flags: [ UNDEFINED ]
89 ; CHECK-NEXT: Function: 0