This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Swap operand order of call_indirect in text format
ClosedPublic

Authored by wingo on Mar 2 2021, 3:25 AM.

Details

Summary

The WebAssembly text and binary formats have different operand orders
for the "type" and "table" fields of call_indirect (and
return_call_indirect). In LLVM we use the binary order for the MCInstr,
but when we produce or consume the text format we should use the text
order. For compilation units targetting WebAssembly 1.0 (without the
reference types feature), we omit the table operand entirely.

Diff Detail

Event Timeline

wingo created this revision.Mar 2 2021, 3:25 AM
wingo requested review of this revision.Mar 2 2021, 3:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 2 2021, 3:25 AM
wingo added a subscriber: aardappel.Mar 2 2021, 3:29 AM

Related to https://reviews.llvm.org/D90948#2572528. Note that this patch parses call_indirect () -> () the same as call_indirect __indirect_function_table, () -> () when reference-types is enabled, i.e. supplying the "missing" operand. Advantage is that you can compile the same input with or without reference types. Disadvantage is that it's slightly magical. Feedback welcome.

tlively accepted this revision.Mar 2 2021, 3:02 PM

LGTM with the current behavior of implicitly inserting the __indirect_function_table operand. Thanks, @wingo!

This revision is now accepted and ready to land.Mar 2 2021, 3:02 PM
This revision was landed with ongoing or failed builds.Mar 2 2021, 11:52 PM
This revision was automatically updated to reflect the committed changes.