This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] TableGen backend for stackifying instructions
ClosedPublic

Authored by tlively on Aug 27 2018, 12:57 PM.

Details

Summary

The new stackification backend generates the giant switch statement
used to translate instructions to their stackified forms. I did this
because it was more interesting than adding all the different vector
versions of the various SIMD instructions to the switch statment
manually.

Diff Detail

Event Timeline

tlively created this revision.Aug 27 2018, 12:57 PM

Wow! That was quick! Simpler than expected. Thanks for cleaning it up :)

utils/TableGen/WebAssemblyStackifierEmitter.cpp
22

This will work, but it seems a bit of a hack. We actually have a flag you can use:

auto Bit = Record.TheDef.getValue("StackBased")->getValue()->getCastTo(BitRecTy::get());
auto IsStackBased = Bit && reinterpret_cast<const BitInit *>(Bit)->getValue();
tlively updated this revision to Diff 162746.Aug 27 2018, 2:12 PM
  • Use StackBased field of WebAssemblyInst class
tlively marked an inline comment as done.Aug 27 2018, 2:13 PM
aardappel added inline comments.Aug 27 2018, 2:51 PM
utils/TableGen/WebAssemblyStackifierEmitter.cpp
25

This is going to throw an exception if the field isn't there, but I guess that is ok in this situation?

aardappel accepted this revision.Aug 27 2018, 2:51 PM
This revision is now accepted and ready to land.Aug 27 2018, 2:51 PM
tlively added inline comments.Aug 27 2018, 2:59 PM
utils/TableGen/WebAssemblyStackifierEmitter.cpp
25

This is why I check to make sure the Record is a subclass of WebAssemblyInst first.

This revision was automatically updated to reflect the committed changes.
aheejin added inline comments.Aug 28 2018, 10:08 AM
llvm/trunk/utils/TableGen/WebAssemblyStackifierEmitter.cpp
29 ↗(On Diff #162757)

Sorry for the late comment, but can you clang-format this?

tlively marked an inline comment as done.Aug 28 2018, 10:25 AM
tlively added inline comments.
llvm/trunk/utils/TableGen/WebAssemblyStackifierEmitter.cpp
29 ↗(On Diff #162757)

Yep! See D51367.