194 Commits

Author SHA1 Message Date
Thomas Lively
f41ccb2277 [WebAssembly] vNxM.load_splat instructions
Summary:
Adds the new load_splat instructions as specified at
https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#load-and-splat.

DAGISel does not allow matching multiple copies of the same load in a
single pattern, so we use a new node in WebAssemblyISD to wrap loads
that should be splatted.

Depends on D67783.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D67784

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372655 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-23 20:42:12 +00:00
Thomas Lively
3bb14be030 [WebAssembly] Restore defaults for stores per memop
Summary:
Large slowdowns were observed in Rust due to many small, constant
sized copies in conjunction with poorly-optimized memory.copy
implementations. Since memory.copy cannot be expected to be inlined
efficiently by engines at this time, stop using it for the smallest
copies. We continue to lower all memcpy intrinsics to memory.copy,
though.

Reviewers: aheejin, alexcrichton

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, JDevlieghere, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D67639

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372275 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-18 23:18:16 +00:00
Graham Hunter
464b4d0dfb [SVE][MVT] Fixed-length vector MVT ranges
* Reordered MVT simple types to group scalable vector types
    together.
  * New range functions in MachineValueType.h to only iterate over
    the fixed-length int/fp vector types.
  * Stopped backends which don't support scalable vector types from
    iterating over scalable types.

Reviewers: sdesmalen, greened

Reviewed By: greened

Differential Revision: https://reviews.llvm.org/D66339


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372099 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-17 10:19:23 +00:00
Shiva Chen
bbb2620939 [TargetLowering] Remove optional arguments passing to makeLibCall
The patch introduces MakeLibCallOptions struct as suggested by @efriedma on D65497.
The struct contain argument flags which will pass to makeLibCall function.
The patch should not has any functionality changes.

Differential Revision: https://reviews.llvm.org/D65795

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369622 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-22 04:59:43 +00:00
Thomas Lively
20e34c7805 [WebAssembly] Stop unrolling SIMD shifts since they are fixed in V8
Summary:
Fixes PR42973. Tests don't change because simd-arith.ll tests behavior
on unimplemented-simd128, which does not include any temporary
workarounds such as the one removed in this revision.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, dmgreen, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D66166

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368868 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-14 16:24:37 +00:00
Daniel Sanders
1311d23a62 [webassembly] Apply llvm-prefer-register-over-unsigned from clang-tidy to LLVM
Summary:
This clang-tidy check is looking for unsigned integer variables whose initializer
starts with an implicit cast from llvm::Register and changes the type of the
variable to llvm::Register (dropping the llvm:: where possible).

Reviewers: aheejin

Subscribers: jholewinski, MatzeB, qcolombet, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, wdng, nhaehnle, sbc100, jgravelle-google, kristof.beyls, hiraditya, aheejin, kbarton, fedor.sergeev, javed.absar, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, tpr, PkmX, jocewei, jsji, Petar.Avramovic, asbirlea, Jim, s.egerton, llvm-commits

Tags: #llvm

Differential Revision for whole review: https://reviews.llvm.org/D65962

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368627 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-12 22:40:45 +00:00
Keno Fischer
22147c3f5c [WebAssembly] Fix conflict between ret legalization and sjlj
Summary:
When the WebAssembly backend encounters a return type that doesn't
fit within i32, SelectionDAG performs sret demotion, adding an
additional argument to the start of the function that contains
a pointer to an sret buffer to use instead. However, this conflicts
with the emscripten sjlj lowering pass. There we translate calls like:

```
	call {i32, i32} @foo()
```

into (in pseudo-llvm)
```
	%addr = @foo
	call {i32, i32} @__invoke_{i32,i32}(%addr)
```

i.e. we perform an indirect call through an extra function.
However, the sret transform now transforms this into
the equivalent of
```
        %addr = @foo
        %sret = alloca {i32, i32}
        call {i32, i32} @__invoke_{i32,i32}(%sret, %addr)
```
(while simultaneously translation the implementation of @foo as well).
Unfortunately, this doesn't work out. The __invoke_ ABI expected
the function address to be the first argument, causing crashes.

There is several possible ways to fix this:
1. Implementing the sret rewrite at the IR level as well and performing
   it as part of lowering to __invoke
2. Fixing the wasm backend to recognize that __invoke has a special ABI
3. A change to the binaryen/emscripten ABI to recognize this situation

This revision implements the middle option, teaching the backend to
treat __invoke_ functions specially in sret lowering. This is achieved
by
1) Introducing a new CallingConv ID for invoke functions
2) When this CallingConv ID is seen in the backend and the first argument
   is marked as sret (a function pointer would never be marked as sret),
   swapping the first two arguments.

Reviewed By: tlively, aheejin
Differential Revision: https://reviews.llvm.org/D65463

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367935 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-05 21:36:09 +00:00
Guillaume Chatelet
0845c69be9 [LLVM][Alignment] Introduce Alignment Type
Summary:
This is patch is part of a serie to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet, jfb, jakehehrlich

Reviewed By: jfb

Subscribers: wuzish, jholewinski, arsenm, dschuff, nemanjai, jvesely, nhaehnle, javed.absar, sbc100, jgravelle-google, hiraditya, aheejin, kbarton, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, dexonsmith, PkmX, jocewei, jsji, s.egerton, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D65514

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367828 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-05 11:02:05 +00:00
Thomas Lively
549b051f54 [WebAssembly] Do not emit tail calls with return type mismatch
Summary:
return_call and return_call_indirect are only valid if the return
types of the callee and caller match. We were previously not enforcing
that, which was producing invalid modules.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D65246

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367339 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-30 18:08:39 +00:00
Thomas Lively
78cbc90959 [WebAssembly] Implement tail calls and unify tablegen call classes
Summary:
Implements direct and indirect tail calls enabled by the 'tail-call'
feature in both DAG ISel and FastISel. Updates existing call tests and
adds new tests including a binary encoding test.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D62877

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364445 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-26 16:17:15 +00:00
Simon Pilgrim
9b95d3f22f [TargetLowering] Add MachineMemOperand::Flags to allowsMemoryAccess tests (PR42123)
As discussed on D62910, we need to check whether particular types of memory access are allowed, not just their alignment/address-space.

This NFC patch adds a MachineMemOperand::Flags argument to allowsMemoryAccess and allowsMisalignedMemoryAccesses, and wires up calls to pass the relevant flags to them.

If people are happy with this approach I can then update X86TargetLowering::allowsMisalignedMemoryAccesses to handle misaligned NT load/stores.

Differential Revision: https://reviews.llvm.org/D63075

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363179 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-12 17:14:03 +00:00
Thomas Lively
073a3cd215 [WebAssembly] Fix ISel crash on sext_inreg/extract type mismatch
Summary:
Adjusts the index and adds a bitcast around the vector operand of
EXTRACT_VECTOR_ELT so that its lane type matches the source type of
its parent sext_inreg. Without this bitcast the ISel patterns do not
match and ISel fails.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D62646

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362547 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-04 21:08:20 +00:00
Thomas Lively
608234d380 [WebAssembly] Expand more SIMD float ops
Summary: These were previously causing ISel failures.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D62354

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361577 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-24 00:15:04 +00:00
Thomas Lively
a94cd9166b [WebAssembly] Implement ReplaceNodeResults to fix a SIMD crash
Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D61037

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361526 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-23 18:09:26 +00:00
Thomas Lively
b7f3617104 [WebAssembly] Implement __builtin_return_address for emscripten
Summary:
In this patch, `ISD::RETURNADDR` is lowered on the emscripten target
to the new Emscripten runtime function `emscripten_return_address`, which
implements the functionality.

Patch by Guanzhong Chen

Reviewers: tlively, aheejin

Reviewed By: tlively

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D62210

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361454 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-23 01:24:01 +00:00
Sanjay Patel
14debde13b [SelectionDAG] remove constant folding limitations based on FP exceptions
We don't have FP exception limits in the IR constant folder for the binops (apart from strict ops),
so it does not make sense to have them here in the DAG either. Nothing else in the backend tries
to preserve exceptions (again outside of strict ops), so I don't see how this could have ever
worked for real code that cares about FP exceptions.

There are still cases (examples: unary opcodes in SDAG, FMA in IR) where we are trying (at least
partially) to preserve exceptions without even asking if the target supports FP exceptions. Those
should be corrected in subsequent patches.

Real support for FP exceptions requires several changes to handle the constrained/strict FP ops.

Differential Revision: https://reviews.llvm.org/D61331

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359791 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-02 14:47:59 +00:00
Dan Gohman
8171cf2106 [WebAssembly] Support f16 libcalls
Add support for f16 libcalls in WebAssembly. This entails adding signatures
for the remaining F16 libcalls, and renaming gnu_f2h_ieee/gnu_h2f_ieee to
truncsfhf2/extendhfsf2 for consistency between f32 and f64/f128 (compiler-rt
already supports this).

Differential Revision: https://reviews.llvm.org/D61287

Reviewer: dschuff


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359600 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-30 19:17:59 +00:00
Heejin Ahn
65db0de9a6 [WebAssembly] Emit br_table for most switch instructions
Summary:
Always convert switches to br_tables unless there is only one case,
which is equivalent to a simple branch. This reduces code size for wasm,
and we defer possible jump table optimizations to the VM.
Addresses PR41502.

Reviewers: kripken, sunfish

Subscribers: dschuff, sbc100, jgravelle-google, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60966

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359038 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-23 21:30:30 +00:00
Sam Clegg
c1819f5966 [WebAssembly] Add new explicit relocation types for PIC relocations
See https://github.com/WebAssembly/tool-conventions/pull/106

Differential Revision: https://reviews.llvm.org/D59907

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357710 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-04 17:43:50 +00:00
Sam Clegg
3207e11ca3 [WebAssembly] Remove unneeded target operand flags
This change is in preparation for the addition of new target
operand flags for new relocation types.  Have a symbol type as part
of the flag set makes it harder to use and AFAICT these are serving
no purpose.

Differential Revision: https://reviews.llvm.org/D60014

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357548 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-03 00:17:29 +00:00
Sam Clegg
23fe8db89f [WebAssembly] Initial implementation of PIC code generation
This change implements lowering of references global symbols in PIC
mode.

This change implements lowering of global references in PIC mode using a
new @GOT reference type. @GOT references can be used with function or
data symbol names combined with the get_global instruction. In this case
the linker will insert the wasm global that stores the address of the
symbol (either in memory for data symbols or in the wasm table for
function symbols).

For now I'm continuing to use the R_WASM_GLOBAL_INDEX_LEB relocation
type for this type of reference which means that this relocation type
can refer to either a global or a function or data symbol. We could
choose to introduce specific relocation types for GOT entries in the
future.  See the current dynamic linking proposal:

https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md

Differential Revision: https://reviews.llvm.org/D54647

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357022 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-26 19:46:15 +00:00
Sam Clegg
ca5bbb310e [WebAssembly] Don't override default implementation of isOffsetFoldingLegal. NFC.
The default implementation does we want and is going to more compatible
with dynamic linking (-fPIC) support that is planned.

This is NFC because currently we only build wasm with
`-relocation-model=static` which in turn means that the default
`isOffsetFoldingLegal` always returns true today.

Differential Revision: https://reviews.llvm.org/D54661

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356410 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-18 21:21:12 +00:00
Sam Clegg
a5cf8e0cbf [WebAssembly] Remove unused load/store patterns that use texternalsym
Differential Revision: https://reviews.llvm.org/D59395

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356221 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-15 00:20:13 +00:00
Heejin Ahn
097c1aa112 [WebAssembly] Simplify iterator navigations (NFC)
Summary:
- Replaces some uses of `MachineFunction::iterator(MBB)` with
  `MBB->getIterator()` and `MachineBasicBlock::iterator(MI)` with
  `MI->getIterator()`, which are simpler.
- Replaces some uses of `std::prev` of `std::next` that takes a
  MachineFunction or MachineBasicBlock iterator with `getPrevNode` and
  `getNextNode`, which are also simpler.

Reviewers: sbc100

Subscribers: dschuff, sunfish, jgravelle-google, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D58913

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355444 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-05 21:05:09 +00:00
Thomas Lively
341140cf85 [WebAssembly] Expand operations not supported by SIMD
Summary:
This prevents crashes in instruction selection when these operations
are used. The tests check that the scalar version of the instruction
is used where applicable, although some expansions do not use the
scalar version.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D58859

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355261 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-02 03:32:25 +00:00
Thomas Lively
0afea149b6 Revert "[WebAssembly][WIP] Expand operations not supported by SIMD"
This was accidentally committed without tests or review.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355254 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-02 00:55:16 +00:00
Thomas Lively
141f394c31 [WebAssembly][WIP] Expand operations not supported by SIMD
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355247 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-02 00:18:07 +00:00
Thomas Lively
eb716ca256 Revert "[WebAssembly] Lower SIMD shifts since they are fixed in V8"
They weren't fixed in V8. Oops.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355208 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-01 17:43:55 +00:00
Thomas Lively
759fd6ca16 [WebAssembly] Lower SIMD shifts since they are fixed in V8
Reviewers: sbc100

Subscribers: dschuff, jgravelle-google, hiraditya, aheejin, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D58800

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355163 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-01 01:38:54 +00:00
Dan Gohman
6ad42d1fab [WebAssembly] Properly align fp128 arguments in outgoing varargs arguments
For outgoing varargs arguments, it's necessary to check the OrigAlign field
of the corresponding OutputArg entry to determine argument alignment, rather
than just computing an alignment from the argument value type. This is
because types like fp128 are split into multiple argument values, with
narrower types that don't reflect the ABI alignment of the full fp128.

This fixes the printf("printfL: %4.*Lf\n", 2, lval); testcase.

Differential Revision: https://reviews.llvm.org/D58656


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354846 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-26 05:20:19 +00:00
Thomas Lively
d0db64f72f [WebAssembly] memory.fill
Summary:
memset lowering, fix argument types in memcpy lowering, and
test encodings. Depends on D57736.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57791

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353986 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-13 22:25:18 +00:00
Thomas Lively
3a517c5b25 [WebAssembly] Lower memmove to memory.copy
Summary: The lowering is identical to the memcpy lowering.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57727

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353216 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-05 20:57:40 +00:00
Thomas Lively
c85eac3a24 [WebAssembly] memory.copy
Summary: Depends on D57495.

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, hiraditya, sunfish

Differential Revision: https://reviews.llvm.org/D57498

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353127 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-05 00:49:55 +00:00
Heejin Ahn
9ac1c04558 [WebAssembly] clang-tidy (NFC)
Summary:
This patch fixes clang-tidy warnings on wasm-only files.
The list of checks used is:
`-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,readability-identifier-naming,modernize-*`
(LLVM's default .clang-tidy list is the same except it does not have
`modernize-*`. But I've seen in multiple CLs in LLVM the modernize style
was recommended and code was fixed based on the style, so I added it as
well.)

The common fixes are:
- Variable names start with an uppercase letter
- Function names start with a lowercase letter
- Use `auto` when you use casts so the type is evident
- Use inline initialization for class member variables
- Use `= default` for empty constructors / destructors
- Use `using` in place of `typedef`

Reviewers: sbc100, tlively, aardappel

Subscribers: dschuff, sunfish, jgravelle-google, yurydelendik, kripken, MatzeB, mgorny, rupprecht, llvm-commits

Differential Revision: https://reviews.llvm.org/D57500

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353075 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-04 19:13:39 +00:00
Heejin Ahn
cceb4ae4ea [WebAssembly] Exception handling: Switch to the new proposal
Summary:
This switches the EH implementation to the new proposal:
https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md
(The previous proposal was
 https://github.com/WebAssembly/exception-handling/blob/master/proposals/old/Exceptions.md)

- Instruction changes
  - Now we have one single `catch` instruction that returns a except_ref
    value
  - `throw` now can take variable number of operations
  - `rethrow` does not have 'depth' argument anymore
  - `br_on_exn` queries an except_ref to see if it matches the tag and
    branches to the given label if true.
  - `extract_exception` is a pseudo instruction that simulates popping
    values from wasm stack. This is to make `br_on_exn`, a very special
    instruction, work: `br_on_exn` puts values onto the stack only if it
    is taken, and the # of values can vay depending on the tag.

- Now there's only one `catch` per `try`, this patch removes all special
  handling for terminate pad with a call to `__clang_call_terminate`.
  Before it was the only case there are two catch clauses (a normal
  `catch` and `catch_all` per `try`).

- Make `rethrow` act as a terminator like `throw`. This splits BB after
  `rethrow` in WasmEHPrepare, and deletes an unnecessary `unreachable`
  after `rethrow` in LateEHPrepare.

- Now we stop at all catchpads (because we add wasm `catch` instruction
  that catches all exceptions), this creates new
  `findWasmUnwindDestinations` function in SelectionDAGBuilder.

- Now we use `br_on_exn` instrution to figure out if an except_ref
  matches the current tag or not, LateEHPrepare generates this sequence
  for catch pads:
```
  catch
  block i32
  br_on_exn $__cpp_exception
  end_block
  extract_exception
```

- Branch analysis for `br_on_exn` in WebAssemblyInstrInfo

- Other various misc. changes to switch to the new proposal.

Reviewers: dschuff

Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits

Differential Revision: https://reviews.llvm.org/D57134

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352598 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-30 03:21:57 +00:00
Thomas Lively
20c54d96c7 [WebAssembly] Optimize BUILD_VECTOR lowering for size
Summary:
Implements custom lowering logic that finds the optimal value for the
initial splat of the vector and either uses it or uses v128.const if
it is available and if it would produce smaller code. This logic
replaces large TableGen ISEL patterns that would lower all non-splat
BUILD_VECTORs into a splat followed by a fixed number of replace_lane
instructions. This CL fixes PR39685.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, sunfish, llvm-commits

Differential Revision: https://reviews.llvm.org/D56633

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352592 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-30 02:23:29 +00:00
Thomas Lively
03dc0681a4 [WebAssembly] Expand BUILD_PAIR nodes
Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish

Differential Revision: https://reviews.llvm.org/D57276

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352442 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-28 23:44:31 +00:00
Thomas Lively
7221fef06a [WebAssembly][NFC] Group SIMD-related ISel configuration
Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish

Differential Revision: https://reviews.llvm.org/D57263

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352262 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-26 01:25:37 +00:00
Chandler Carruth
6b547686c5 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-19 08:50:56 +00:00
Thomas Lively
9fbbcd0441 [WebAssembly] Expand SIMD shifts while V8's implementation disagrees
Summary:
V8 currently implements SIMD shifts as taking an immediate operation,
which disagrees with the spec proposal and the toolchain
implementation. As a stopgap measure to get things working, unroll all
vector shifts. Since this is a temporary measure, there are no tests.

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, sunfish, dmgreen, llvm-commits

Differential Revision: https://reviews.llvm.org/D56520

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351151 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-15 02:16:03 +00:00
Thomas Lively
09b0852040 [WebAssembly] Add unimplemented-simd128 subtarget feature
Summary:
This is a third attempt, but this time we have vetted it on Windows
first. The previous errors were due to an uninitialized class member.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, sunfish, jfb, llvm-commits

Differential Revision: https://reviews.llvm.org/D56560

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350901 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-10 22:32:11 +00:00
Thomas Lively
54f94c3a2e Revert "[WebAssembly] Add simd128-unimplemented subtarget feature"
This reverts rL350791.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350795 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-10 04:09:25 +00:00
Thomas Lively
38f7d82a39 [WebAssembly] Add simd128-unimplemented subtarget feature
This is a second attempt at r350778, which was reverted in
r350789. The only change is that the unimplemented-simd128 feature has
been renamed simd128-unimplemented, since naming it
unimplemented-simd128 somehow made the simd128 feature flag enable the
unimplemented-simd128 feature on Windows.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350791 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-10 02:55:52 +00:00
Thomas Lively
b56b09db88 Revert "[WebAssembly] Add unimplemented-simd128 subtarget feature"
This reverts L350778.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350789 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-10 01:37:44 +00:00
Thomas Lively
6d3d2f90b1 [WebAssembly] Add unimplemented-simd128 subtarget feature
Summary:
This replaces the old ad-hoc -wasm-enable-unimplemented-simd
flag. Also makes the new unimplemented-simd128 feature imply the
simd128 feature.

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits, alexcrichton

Differential Revision: https://reviews.llvm.org/D56501

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350778 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-09 23:59:37 +00:00
Thomas Lively
37a984b8bc [WebAssembly] Massive instruction renaming
Summary:
An automated renaming of all the instructions listed at
https://github.com/WebAssembly/spec/issues/884#issuecomment-426433329
as well as some similarly-named identifiers.

Reviewers: aheejin, dschuff, aardappel

Subscribers: sbc100, jgravelle-google, eraman, sunfish, jfb, llvm-commits

Differential Revision: https://reviews.llvm.org/D56338

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350609 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-08 06:25:55 +00:00
Thomas Lively
d0092eb5f9 [WebAssembly] Gate unimplemented SIMD ops on flag
Summary:
Gates v128.const, f32x4.sqrt, f32x4.div, i8x16.extract_lane_u, and
i16x8.extract_lane_u on the --wasm-enable-unimplemented-simd flag,
since these ops are not implemented yet in V8.

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits

Differential Revision: https://reviews.llvm.org/D55904

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349720 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-20 02:10:22 +00:00
Thomas Lively
f080288279 [WebAssembly] Expand unavailable integer operations for vectors
Summary:
Expands for vector types all of the integer operations that are
expanded for scalars because they are not supported at all by
WebAssembly.

This CL has no tests because such tests would really be testing the
target-independent expansion, but I'm happy to add tests if reviewers
think it would be helpful.

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits

Differential Revision: https://reviews.llvm.org/D55010

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347923 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-29 22:01:01 +00:00
Heejin Ahn
8bcdd04bce [WebAssembly] Add support for the event section
Summary:
This adds support for the 'event section' specified in the exception
handling proposal. (This was named 'exception section' first, but later
renamed to 'event section' to take possibilities of other kinds of
events into consideration. But currently we only store exception info in
this section.)

The event section is added between the global section and the export
section. This is for ease of validation per request of the V8 team.

This patch:
- Creates the event symbol type, which is a weak symbol
- Makes 'throw' instruction take the event symbol '__cpp_exception'
- Adds relocation support for events
- Adds WasmObjectWriter / WasmObjectFile (Reader) support
- Adds obj2yaml / yaml2obj support
- Adds '.eventtype' printing support

Reviewers: dschuff, sbc100, aardappel

Subscribers: jgravelle-google, sunfish, llvm-commits

Differential Revision: https://reviews.llvm.org/D54096

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346825 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-14 02:46:21 +00:00
Thomas Lively
b1c6e08d95 [WebAssembly] Lower select for vectors
Summary:

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits

Differential Revision: https://reviews.llvm.org/D53675

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346462 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-09 01:38:44 +00:00