xref: /llvm-project/llvm/test/MC/WebAssembly/call-indirect-relocs.s (revision 9ac5620cb8548c0bd0150f0da68219dd3a5a657a)
1# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+reference-types < %s | FileCheck --check-prefix=CHECK %s
2# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+reference-types -filetype=obj < %s | obj2yaml | FileCheck -check-prefix=BIN %s
3
4test0:
5    .functype   test0 () -> ()
6    i32.const 42
7    f64.const 2.5
8    i32.const   0
9    call_indirect empty_fref_table, (i32, f64) -> ()
10    end_function
11
12.tabletype empty_fref_table, funcref
13empty_fref_table:
14
15
16# CHECK:           .text
17# CHECK-LABEL: test0:
18# CHECK-NEXT:      .functype   test0 () -> ()
19# CHECK-NEXT:      i32.const   42
20# CHECK-NEXT:      f64.const   0x1.4p1
21# CHECK-NEXT:      i32.const   0
22# CHECK-NEXT:      call_indirect empty_fref_table, (i32, f64) -> ()
23# CHECK-NEXT:      end_function
24
25# CHECK:           .tabletype empty_fref_table, funcref
26# CHECK: empty_fref_table:
27
28# BIN: --- !WASM
29# BIN-NEXT: FileHeader:
30# BIN-NEXT:   Version:         0x1
31# BIN-NEXT: Sections:
32# BIN-NEXT:   - Type:            TYPE
33# BIN-NEXT:     Signatures:
34# BIN-NEXT:       - Index:           0
35# BIN-NEXT:         ParamTypes:      []
36# BIN-NEXT:         ReturnTypes:     []
37# BIN-NEXT:       - Index:           1
38# BIN-NEXT:         ParamTypes:
39# BIN-NEXT:           - I32
40# BIN-NEXT:           - F64
41# BIN-NEXT:         ReturnTypes:     []
42# BIN-NEXT:   - Type:            IMPORT
43# BIN-NEXT:     Imports:
44# BIN-NEXT:       - Module:          env
45# BIN-NEXT:         Field:           __linear_memory
46# BIN-NEXT:         Kind:            MEMORY
47# BIN-NEXT:         Memory:
48# BIN-NEXT:           Minimum:         0x0
49# BIN-NEXT:   - Type:            FUNCTION
50# BIN-NEXT:     FunctionTypes:   [ 0 ]
51# BIN-NEXT:   - Type:            TABLE
52# BIN-NEXT:     Tables:
53# BIN-NEXT:       - Index:           0
54# BIN-NEXT:         ElemType:        FUNCREF
55# BIN-NEXT:         Limits:
56# BIN-NEXT:           Minimum:         0x0
57# BIN-NEXT:   - Type:            CODE
58# BIN-NEXT:     Relocations:
59# BIN-NEXT:       - Type:            R_WASM_TYPE_INDEX_LEB
60# BIN-NEXT:         Index:           1
61# BIN-NEXT:         Offset:          0x11
62# BIN-NEXT:       - Type:            R_WASM_TABLE_NUMBER_LEB
63# BIN-NEXT:         Index:           1
64# BIN-NEXT:         Offset:          0x16
65# BIN-NEXT:     Functions:
66# BIN-NEXT:       - Index:           0
67# BIN-NEXT:         Locals:          []
68# BIN-NEXT:         Body:            412A440000000000000440410011818080800080808080000B
69# BIN-NEXT:   - Type:            CUSTOM
70# BIN-NEXT:     Name:            linking
71# BIN-NEXT:     Version:         2
72# BIN-NEXT:     SymbolTable:
73# BIN-NEXT:       - Index:           0
74# BIN-NEXT:         Kind:            FUNCTION
75# BIN-NEXT:         Name:            test0
76# BIN-NEXT:         Flags:           [ BINDING_LOCAL ]
77# BIN-NEXT:         Function:        0
78# BIN-NEXT:       - Index:           1
79# BIN-NEXT:         Kind:            TABLE
80# BIN-NEXT:         Name:            empty_fref_table
81# BIN-NEXT:         Flags:           [ BINDING_LOCAL ]
82# BIN-NEXT:         Table:           0
83# BIN-NEXT: ...
84