Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[WebAssembly] Add ref.test_func handling to AsmParser #139642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
Loading
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[WebAssembly] Add ref.test_func handling to AsmParser
  • Loading branch information
hoodmane committed May 12, 2025
commit ba4e21486455fcee36e5521050562cd9be35e9b4
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,8 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
if (parseFunctionTableOperand(&FunctionTable))
return true;
ExpectFuncType = true;
} else if (Name == "ref.test_func") {
ExpectFuncType = true;
}

// Returns true if the next tokens are a catch clause
Expand Down
8 changes: 8 additions & 0 deletions 8 llvm/lib/Target/WebAssembly/WebAssemblyInstrRef.td
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ multiclass REF_I<WebAssemblyRegClass rc, ValueType vt, string ht> {
Requires<[HasReferenceTypes]>;
}

defm REF_TEST_FUNCREF :
I<(outs I32: $res),
(ins TypeIndex:$type, FUNCREF: $ref),
(outs),
(ins TypeIndex:$type),
[],
"ref.test_func\t$type, $ref", "ref.test_func $type", 0xfb14>;

defm "" : REF_I<FUNCREF, funcref, "func">;
defm "" : REF_I<EXTERNREF, externref, "extern">;
defm "" : REF_I<EXNREF, exnref, "exn">;
Expand Down
15 changes: 15 additions & 0 deletions 15 llvm/test/MC/WebAssembly/reference-types.s
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ ref_null_test:
drop
end_function

# CHECK-LABEL: ref_test_test:
# CHECK: ref.null_func # encoding: [0xd0,0x70]
# CHECK: ref.test () -> () # encoding: [0xfb,0x14,0x80'A',0x80'A',0x80'A',0x80'A',A]
hoodmane marked this conversation as resolved.
Show resolved Hide resolved
# CHECK: # fixup A - offset: 2, value: .Ltypeindex0@TYPEINDEX, kind: fixup_uleb128_i32
# CHECK: ref.null_func # encoding: [0xd0,0x70]
# CHECK: ref.test () -> (i32) # encoding: [0xfb,0x14,0x80'A',0x80'A',0x80'A',0x80'A',A]
# CHECK: # fixup A - offset: 2, value: .Ltypeindex1@TYPEINDEX, kind: fixup_uleb128_i32
ref_test_test:
.functype ref_test_test () -> (i32, i32)
ref.null_func
ref.test_func () -> ()
ref.null_func
ref.test_func () -> (i32)
end_function

# CHECK-LABEL: ref_sig_test_funcref:
# CHECK-NEXT: .functype ref_sig_test_funcref (funcref) -> (funcref)
ref_sig_test_funcref:
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.