Skip to content

Commit 1262dce

Browse files
Add support for ref.func to AsmParser/MC (llvm#163326)
This is step 1 of exposing WASM `ref.func` to LLVM. This PR only handles creating the instruction and a test for assembling it.
1 parent bd9030e commit 1262dce

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

llvm/lib/Target/WebAssembly/WebAssemblyInstrRef.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ defm REF_TEST_FUNCREF : I<(outs I32:$res), (ins TypeIndex:$type, FUNCREF:$ref),
4141
"ref.test\t$type, $ref", "ref.test $type", 0xfb14>,
4242
Requires<[HasGC]>;
4343

44+
defm REF_FUNC : I<(outs FUNCREF:$res), (ins function32_op:$func),
45+
(outs), (ins function32_op:$func), [],
46+
"ref.func\t$func", "ref.func $func", 0xd2>,
47+
Requires<[HasReferenceTypes]>;
48+
4449
defm "" : REF_I<FUNCREF, funcref, "func">;
4550
defm "" : REF_I<EXTERNREF, externref, "extern">;
4651
defm "" : REF_I<EXNREF, exnref, "exn">;

llvm/test/MC/WebAssembly/reference-types.s

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,12 @@ ref_block_test:
105105
end_block
106106
drop
107107
end_function
108+
109+
# CHECK-LABEL: ref_func_test:
110+
# CHECK-NEXT: .functype ref_func_test () -> (funcref)
111+
# CHECK-NEXT: ref.func ref_func_test # encoding: [0xd2,0x80'A',0x80'A',0x80'A',0x80'A',A]
112+
# CHECK-NEXT: # fixup A - offset: 1, value: ref_func_test, kind: fixup_uleb128_i32
113+
ref_func_test:
114+
.functype ref_func_test () -> (funcref)
115+
ref.func ref_func_test
116+
end_function

0 commit comments

Comments
 (0)