This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Implementation of intrinsic for ref.null and HeapType removal
ClosedPublic

Authored by pmatos on Dec 2 2021, 11:43 AM.

Details

Summary

This patch implements the intrinsic for ref.null.
In the process of implementing int_wasm_ref_null_func() and
int_wasm_ref_null_extern() intrinsics, it removes the redundant
HeapType.

This also causes the textual assembler syntax for ref.null to
change. Instead of receiving an argument: func or extern, the
instruction mnemonic is either ref.null_func or ref.null_extern,
without the need for a further operand.

Diff Detail

Event Timeline

pmatos created this revision.Dec 2 2021, 11:43 AM
pmatos requested review of this revision.Dec 2 2021, 11:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 2 2021, 11:43 AM
tlively accepted this revision.Dec 3 2021, 8:31 PM

LGTM modulo comments. It's nice that we get to delete so much code this way.

llvm/lib/IR/Function.cpp
944–945

It would be good to undo these unrelated formatting changes.

llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
91

Can we roll these values into the opcodes defined in the tablegen files? That would remove the need for this exception and would make the disassembler recover the correct instruction. The only issue I can think of is that there might be code paths that depend on the opcodes being in a certain range that this would exceed.

This revision is now accepted and ready to land.Dec 3 2021, 8:31 PM
pmatos added inline comments.Dec 6 2021, 12:45 AM
llvm/lib/IR/Function.cpp
944–945

Yes, well, I want clang-format and it suggested the change, which is why I accepted it but fair enough... I will roll them back.

llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
91

Ah - love the suggestion. Completely forgot I could and should roll these into tablegen. Also bonus points as I learned to use !cond(...).