This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] v128.const
ClosedPublic

Authored by tlively on Aug 16 2018, 3:45 PM.

Details

Summary

This CL implements v128.const for each vector type. New operand types
are added to ensure the vector contents can be serialized without LEB
encoding.

Diff Detail

Repository
rL LLVM

Event Timeline

tlively created this revision.Aug 16 2018, 3:45 PM

Generally looks good.. but what about some tests?

Should also add support for these to the assembler, or in a follow-up?

Generally looks good.. but what about some tests?

I'm always down for more tests. What tests could I add?

Should also add support for these to the assembler, or in a follow-up?

Can you point me to the code that will need to be modified for this?

Assembler is in WebAssemblyAsmParser.cpp
There's some disassembler tests in test/MC/Disassembler/wasm.txt

Instruction selection part looks good. I guess other reviewers can give better feedback on the encoding/disassembling parts.

lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp
184 ↗(On Diff #161136)

Are these added in order to prevent elements from being LEB-encoded one by one? SIMD immediates do not use LEB encoding?

lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
94 ↗(On Diff #161136)

clang-format this switch-case block and also possibly other modified parts.

112 ↗(On Diff #161136)

Fix indentation (I guess it will be fixed anyway if you run clang-format though)

tlively updated this revision to Diff 161616.Aug 20 2018, 4:33 PM
  • Add disassembler test
  • Formatting
  • Assembler support
tlively marked 2 inline comments as done.Aug 20 2018, 4:36 PM
tlively added inline comments.
lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp
184 ↗(On Diff #161136)

That's correct. The spec says that the vector immediate is actually an array of 16 immediate bytes, i.e. not LEB-encoded. However, ISEL wants to treat v16i8, v8i16, v4i32, etc. all separately rather than converting them all to v16i8 first, so we need these new operand types in order to encode the larger lane values without LEB.

dschuff added inline comments.Aug 21 2018, 1:26 PM
lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp
95 ↗(On Diff #161616)

For extra fun template points you could combine this with the FP case below for a single parseImmediate, where you could add something like
if (std::is_floating_point<T>::value) { ... } else { ... }
You can probably even do the conditional statically, although I'm not sure that would be more readable.

tlively updated this revision to Diff 161811.Aug 21 2018, 1:52 PM
  • Add disassembler test
  • Formatting
  • Assembler support
  • Combine parseImmediate functions
dschuff accepted this revision.Aug 21 2018, 1:54 PM
This revision is now accepted and ready to land.Aug 21 2018, 1:54 PM
This revision was automatically updated to reflect the committed changes.
tlively marked an inline comment as done.