1 ; RUN: llc -mcpu=mvp -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 -mcpu=mvp -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 triple = "wasm32-unknown-unknown"
14 define void @foo(i32 %n) {
20 ; Checking assembly is not the point of this test, but if something breaks
21 ; it is easier to spot it here than in the yaml output.
23 ; ASM: .file "assembler-binary.ll"
24 ; ASM: .functype bar () -> ()
27 ; ASM-NEXT: .functype foo (i32) -> ()
29 ; ASM-NEXT: end_function
33 ; CHECK-NEXT: FileHeader:
34 ; CHECK-NEXT: Version: 0x1
35 ; CHECK-NEXT: Sections:
36 ; CHECK-NEXT: - Type: TYPE
37 ; CHECK-NEXT: Signatures:
38 ; CHECK-NEXT: - Index: 0
39 ; CHECK-NEXT: ParamTypes:
41 ; CHECK-NEXT: ReturnTypes: []
42 ; CHECK-NEXT: - Index: 1
43 ; CHECK-NEXT: ParamTypes: []
44 ; CHECK-NEXT: ReturnTypes: []
45 ; CHECK-NEXT: - Type: IMPORT
46 ; CHECK-NEXT: Imports:
47 ; CHECK-NEXT: - Module: env
48 ; CHECK-NEXT: Field: __linear_memory
49 ; CHECK-NEXT: Kind: MEMORY
51 ; CHECK-NEXT: Minimum: 0x0
52 ; CHECK-NEXT: - Module: env
53 ; CHECK-NEXT: Field: bar
54 ; CHECK-NEXT: Kind: FUNCTION
55 ; CHECK-NEXT: SigIndex: 1
56 ; CHECK-NEXT: - Type: FUNCTION
57 ; CHECK-NEXT: FunctionTypes: [ 0 ]
58 ; CHECK-NEXT: - Type: CODE
59 ; CHECK-NEXT: Relocations:
60 ; CHECK-NEXT: - Type: R_WASM_FUNCTION_INDEX_LEB
61 ; CHECK-NEXT: Index: 1
62 ; CHECK-NEXT: Offset: 0x4
63 ; CHECK-NEXT: Functions:
64 ; CHECK-NEXT: - Index: 1
65 ; CHECK-NEXT: Locals: []
66 ; CHECK-NEXT: Body: 1080808080000B
67 ; CHECK-NEXT: - Type: CUSTOM
68 ; CHECK-NEXT: Name: linking
69 ; CHECK-NEXT: Version: 2
70 ; CHECK-NEXT: SymbolTable:
71 ; CHECK-NEXT: - Index: 0
72 ; CHECK-NEXT: Kind: FUNCTION
73 ; CHECK-NEXT: Name: foo
74 ; CHECK-NEXT: Flags: [ ]
75 ; CHECK-NEXT: Function: 1
76 ; CHECK-NEXT: - Index: 1
77 ; CHECK-NEXT: Kind: FUNCTION
78 ; CHECK-NEXT: Name: bar
79 ; CHECK-NEXT: Flags: [ UNDEFINED ]
80 ; CHECK-NEXT: Function: 0