This is an archive of the discontinued LLVM Phabricator instance.

WebAssembly: print basic integer assembly.
ClosedPublic

Authored by jfb on Jul 30 2015, 6:46 PM.

Details

Summary

This prints assembly for int32 integer operations defined in WebAssemblyInstrInteger.td only, with major caveats:

  • The operation names are currently incorrect.
  • Other integer and floating-point types will be added later.
  • The printer isn't factored out to handle recursive AST code yet, since it can't even handle control flow anyways.
  • The assembly format isn't full s-expressions yet either, this will be added later.
  • This currently disables PrologEpilogCodeInserter as well as MachineCopyPropagation becasue they don't like virtual registers, which WebAssembly likes quite a bit. This will be fixed by factoring out NVPTX's change (currently a fork of PrologEpilogCodeInserter).

Diff Detail

Repository
rL LLVM

Event Timeline

jfb updated this revision to Diff 31100.Jul 30 2015, 6:46 PM
jfb retitled this revision from to WebAssembly: print basic integer assembly..
jfb updated this object.
jfb added a reviewer: sunfish.
jfb added a subscriber: llvm-commits.
sunfish accepted this revision.Jul 31 2015, 10:18 AM
sunfish edited edge metadata.
sunfish added inline comments.
lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
82 ↗(On Diff #31100)

&& "Instructions with multiple result values not implemented yet" or so.

84 ↗(On Diff #31100)

Please use NumDefs != 0, for clarity.

87 ↗(On Diff #31100)

virtReg2Index asserts this, so it's not necessary to assert it here too.

100 ↗(On Diff #31100)

Does the default case below not handle this?

117 ↗(On Diff #31100)

!= 0, as above

lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
149 ↗(On Diff #31100)

Instead of appending one element at a time, RetOps.append(OutVals.begin(), OutVals.end());

195 ↗(On Diff #31100)

It's not actually necessary to check the ArgVT here. If VT is MVT::i32, it doesn't matter what the original type was.

lib/Target/WebAssembly/WebAssemblyInstrCtrl.td
1 ↗(On Diff #31100)

Update the top-line comment to match the file.

28 ↗(On Diff #31100)

Do we really need the Uses of SP32,SP64 here? It's a little unusual, since we only use one or the other for the stack pointer, so using both here will always mean that we're using a register that isn't actually live.

I see that ARM and AArch64 have return instruction use SP, but no other targets seem to do this. Perhaps we can omit these for now until we figure out whether they're really needed?

lib/Target/WebAssembly/WebAssemblyInstrInfo.td
67 ↗(On Diff #31100)

In-tree precedent for the filename here is X86InstrControl.td, so we should be WebAssemblyInstrControl.td.

This revision is now accepted and ready to land.Jul 31 2015, 10:18 AM
jfb updated this revision to Diff 31131.Jul 31 2015, 10:32 AM
jfb marked 10 inline comments as done.
jfb edited edge metadata.
  • Address sunfish's comments.
jfb updated this revision to Diff 31134.Jul 31 2015, 10:34 AM
  • Update cpus.ll test to use the currently-supported instructions (it errors out otherwise).
jfb updated this revision to Diff 31135.Jul 31 2015, 10:41 AM
  • Update test, return prints as RETURN for now.
lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
100 ↗(On Diff #31100)

True, it's just uppercase. I'll fix with the other ones (removed this case for now).

This revision was automatically updated to reflect the committed changes.