What assembly syntax "should" wasm `asm!` use?

I see there as being basically three reasonable choices:

  • GNU assembler (GAS), the current implemented behavior and easy to hand directly to LLVM
  • WAT (WebAssembly text format), the specification text format for WebAssembly
  • WAST (WebAssembly script syntax), an unofficial superset of WAT syntax which is easier to write by hand, used for reference implementation tests

For inline asm!, GAS syntax is reasonable and seems to fall somewhere between WAT and WAST (e.g. allows using symbolic names instead of indices, but doesn't allow s-expression parameters instead of stack parameters). But for global_asm!, the .directives required are much more opaque (and bordering undocumented) than WAST (func $name ...), (import ...), (export ...), etc.

Pure WAT seems unusable due to reliance on global order indices. But WAST is "official unofficial" (since it's used by reference material) and certainly moreso than GAS. Given we already set .syntax for GAS, it seems reasonable that we'd choose to use WAST instead of GAS on wasm, so long as there isn't anything useful doable with GAS that isn't with WAST.

I'm far from familiar with GAS, let alone wasm GAS, so: is there functionality available through GAS that wouldn't be through just WAST that would be useful for Rust on wasm?

11 Likes

I haven't checked, but I'd guess from my gas experience that there is functionality available that isn't in WAST: putting things in different sections (the linker will concatenate them all together at the end) and the directives that help generate DWARF debug info.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.