This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Gate i64x2 and f64x2 on -wasm-enable-unimplemented
ClosedPublic

Authored by tlively on Aug 7 2018, 6:01 PM.

Details

Summary

i64x2 and f64x2 operations are not implemented in V8, so we normally
do not want to emit them. However, they are in the SIMD spec proposal,
so we still want to be able to test them in the toolchain. This patch
adds a flag to enable their emission.

Diff Detail

Event Timeline

tlively created this revision.Aug 7 2018, 6:01 PM
dschuff added inline comments.Aug 8 2018, 10:32 AM
lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
45 ↗(On Diff #159634)

Could putting this declaration in WebAssemblyTargetMachine.h avoid all these extern declarations?

tlively added inline comments.Aug 8 2018, 10:52 AM
lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
45 ↗(On Diff #159634)

Not all, just some.

aheejin added inline comments.Aug 8 2018, 11:04 AM
lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
49 ↗(On Diff #159634)

Are we planning to use this flag only for simd or also for other instructions? For example, exception handling is not currently implemented in the VM yet, but we are adding opcodes for it (under -mattr=+exception-handling flag). And in case if other stage 0~1 proposals come up, we may want to add them in the toolchain before they are implemented in the VM. Are we gonna use this flag for all these cases? If not, how about changing it to wasm-enable-unimplemented-simd?

test/CodeGen/WebAssembly/simd-arith.ll
11

How about leaving the meaning of SIMD128 as is and create another check mode for SIMD without the two opcodes? That way we can only delete that when we have the remaining two in the VM. And I think that also makes more sense if we are eventually gonna have them in the VM.

tlively added inline comments.Aug 8 2018, 11:06 AM
lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
45 ↗(On Diff #159634)

It also doesn't work that way because you end up with duplicate symbols.

aheejin added inline comments.Aug 8 2018, 11:13 AM
lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
45 ↗(On Diff #159634)

I guess what he meant is putting the definition where it is now and putting that extern declaration in the header file, but anyway.

tlively marked an inline comment as done.Aug 8 2018, 11:24 AM
tlively added inline comments.
lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
49 ↗(On Diff #159634)

It may make sense to use the same flag for all cases where ops are implemented in the toolchain but not the VM. However, I'd be happy to change the name if this will only be used for SIMD. Would you want to have a single general flag for this use case, or are other existing mechanisms sufficient?

tlively updated this revision to Diff 159765.Aug 8 2018, 11:41 AM
  • Update FileCheck prefixes
aheejin added inline comments.Aug 8 2018, 1:28 PM
lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
49 ↗(On Diff #159634)

I don't think we need a separate flag that handles all unimplemented opcodes because we already have feature flags for each not-fully-implemented-and-ongoing feature. If we have enough cases like this, where a feature is controlled by a feature flag but we need a separation even within it, using this flag for all those cases might make sense. But before that, I guess making it clear that this applies only for SIMD is less confusing, because currently it sounds like it encompasses all unimplemented features.

aheejin added inline comments.Aug 8 2018, 1:37 PM
lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
45 ↗(On Diff #159634)

Would WebAssembly.h work then?

tlively updated this revision to Diff 159788.Aug 8 2018, 2:02 PM
tlively marked 2 inline comments as done.
  • Change flag name, move extern decl to header

Addressed comments

aheejin added inline comments.Aug 8 2018, 2:13 PM
lib/Target/WebAssembly/WebAssembly.h
21 ↗(On Diff #159788)

Hmm, I'm not sure if we want to include this big header (and all other headers included by it) into all WebAssembly cpp files. Sorry. Maybe the original way would be better..?

lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
49 ↗(On Diff #159634)

Nit: can you also change the variable name to include simd?

tlively updated this revision to Diff 159796.Aug 8 2018, 2:26 PM
  • Restore individual extern decls
tlively updated this revision to Diff 159799.Aug 8 2018, 2:30 PM
  • Update flag variable name
tlively marked an inline comment as done.Aug 8 2018, 2:30 PM
dschuff added inline comments.Aug 8 2018, 2:33 PM
lib/Target/WebAssembly/WebAssemblyFastISel.cpp
690 ↗(On Diff #159796)

I don't think it's necessary to have checks at every single place where these types are used. It's enough e.g. to prevent them from reaching here with a check somewhere else, but still handle everything once the instructions get here. (Basically the same reason we have unconditional definitions and handling for simd instructions in some places, but have checks on the SIMD cpu feature in other places.

tlively updated this revision to Diff 159811.Aug 8 2018, 3:07 PM
  • Remove all redundant checks

Without all the checks I believe to be redundant this CL is much, much smaller. I'm concerned that it's possible the checks could save me a great deal of pain down the road, though.

@aheejin I think this is ready to land if it looks good to you

aheejin accepted this revision.Aug 9 2018, 4:40 PM
This revision is now accepted and ready to land.Aug 9 2018, 4:40 PM
This revision was automatically updated to reflect the committed changes.