This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] __builtin_wasm_extract_lane_* builtins
ClosedPublic

Authored by tlively on Oct 3 2018, 4:14 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

tlively created this revision.Oct 3 2018, 4:14 PM
aheejin added inline comments.Oct 3 2018, 4:56 PM
include/clang/Basic/BuiltinsWebAssembly.def
46 ↗(On Diff #168199)
  • I guess the return types should be the same as its element type, because we are translating to not wasm but LLVM IR instructions and extractelement's return type and element type are the same.
  • What does I mean in the second argument? The instruction says it is required for constant folding. How is the generated IR different if we use it?
test/CodeGen/builtins-wasm.c
112 ↗(On Diff #168199)

The same for the return values here.

craig.topper added inline comments.
include/clang/Basic/BuiltinsWebAssembly.def
46 ↗(On Diff #168199)

The I makes Sema ensure it is a Integer Constant Expression.

lib/CodeGen/CGBuiltin.cpp
12433 ↗(On Diff #168199)

I believe you need to use isIntegerConstantExpr to force clang to really evaluate it as a constant integer. if its a more complicated expression.

tlively updated this revision to Diff 168222.Oct 3 2018, 8:41 PM
tlively marked an inline comment as done.
  • use isIntegerConstantExpr to force constant folding of lanes
tlively added inline comments.Oct 3 2018, 8:53 PM
include/clang/Basic/BuiltinsWebAssembly.def
46 ↗(On Diff #168199)

I want these builtins to mimic the underlying wasm instructions as much as possible. I believe end users are more likely to be looking at the WebAssembly spec than the LLVM language reference when using these functions.

tlively updated this revision to Diff 168385.EditedOct 4 2018, 2:45 PM
  • Replace Wi with LLi in signature string
  • Remove unnecessary V:128: attribute
aheejin accepted this revision.Oct 4 2018, 5:26 PM
This revision is now accepted and ready to land.Oct 4 2018, 5:26 PM
This revision was automatically updated to reflect the committed changes.